From c5685f44df1121bcfab59d436ccbdb19022ef694 Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Fri, 7 Apr 2017 14:15:08 +0200 Subject: [PATCH] upgrade org-plus-contrib and org-mime - upgrade to org-plus-contrib-20170407 - upgrade to org-mime-20170218.501 Signed-off-by: Andreas Gerler --- bba.org | 7 +- .../org-mime-autoloads.el | 28 + elpa/org-mime-20170218.501/org-mime-pkg.el | 2 + elpa/org-mime-20170218.501/org-mime.el | 386 + elpa/org-mime-readme.txt | 52 + elpa/org-plus-contrib-20150831/ob-clojure.el | 115 - elpa/org-plus-contrib-20150831/ob-exp.el | 449 - elpa/org-plus-contrib-20150831/ob-lisp.el | 111 - elpa/org-plus-contrib-20150831/ob-lob.el | 179 - elpa/org-plus-contrib-20150831/ob-sql.el | 228 - elpa/org-plus-contrib-20150831/org-bullets.el | 122 - elpa/org-plus-contrib-20150831/org-colview.el | 1610 --- elpa/org-plus-contrib-20150831/org-compat.el | 546 - .../org-plus-contrib-20150831/org-datetree.el | 219 - .../org-plus-contrib-20150831/org-download.el | 392 - elpa/org-plus-contrib-20150831/org-ebib.el | 47 - elpa/org-plus-contrib-20150831/org-faces.el | 811 -- elpa/org-plus-contrib-20150831/org-index.el | 2497 ---- elpa/org-plus-contrib-20150831/org-info.el | 99 - elpa/org-plus-contrib-20150831/org-mime.el | 346 - .../org-plus-contrib-autoloads.el | 1179 -- .../org-plus-contrib-pkg.el | 3 - elpa/org-plus-contrib-20150831/orgcard.pdf | Bin 124864 -> 0 bytes elpa/org-plus-contrib-20150831/ox-gfm.el | 193 - .../COPYING | 0 .../README_ELPA | 0 .../dir | 0 .../etc/ORG-NEWS | 1126 +- .../etc/styles/OrgOdtContentTemplate.xml | 0 .../etc/styles/OrgOdtStyles.xml | 0 .../etc/styles/README | 0 .../ob-C.el | 172 +- .../ob-J.el | 27 +- .../ob-R.el | 86 +- .../ob-abc.el | 22 +- .../ob-asymptote.el | 44 +- .../ob-awk.el | 29 +- .../ob-calc.el | 22 +- elpa/org-plus-contrib-20170407/ob-clojure.el | 198 + .../ob-comint.el | 36 +- .../ob-coq.el | 11 +- .../ob-core.el | 2257 +-- elpa/org-plus-contrib-20170407/ob-csharp.el | 83 + .../ob-css.el | 10 +- .../ob-ditaa.el | 22 +- .../ob-dot.el | 17 +- .../ob-ebnf.el | 10 +- .../ob-emacs-lisp.el | 55 +- .../ob-eukleides.el | 10 +- .../ob-eval.el | 29 +- elpa/org-plus-contrib-20170407/ob-exp.el | 413 + .../ob-fomus.el | 10 +- .../ob-forth.el | 17 +- .../ob-fortran.el | 59 +- .../ob-gnuplot.el | 54 +- .../ob-groovy.el | 28 +- .../ob-haskell.el | 54 +- elpa/org-plus-contrib-20170407/ob-hledger.el | 70 + .../ob-io.el | 40 +- .../ob-java.el | 26 +- .../ob-js.el | 23 +- .../ob-julia.el | 39 +- .../ob-keys.el | 8 +- .../ob-latex.el | 76 +- .../ob-ledger.el | 9 +- .../ob-lilypond.el | 43 +- elpa/org-plus-contrib-20170407/ob-lisp.el | 127 + elpa/org-plus-contrib-20170407/ob-lob.el | 151 + elpa/org-plus-contrib-20170407/ob-lua.el | 403 + .../ob-makefile.el | 10 +- .../ob-mathematica.el | 12 +- .../ob-mathomatic.el | 68 +- .../ob-matlab.el | 4 +- .../ob-maxima.el | 18 +- .../ob-mscgen.el | 12 +- .../ob-ocaml.el | 60 +- .../ob-octave.el | 76 +- .../ob-org.el | 10 +- .../ob-oz.el | 12 +- .../ob-perl.el | 33 +- .../ob-picolisp.el | 16 +- .../ob-plantuml.el | 57 +- .../ob-processing.el | 32 +- .../ob-python.el | 110 +- .../ob-ref.el | 168 +- .../ob-ruby.el | 87 +- .../ob-sass.el | 11 +- .../ob-scala.el | 34 +- .../ob-scheme.el | 35 +- .../ob-screen.el | 22 +- .../ob-sed.el | 4 +- .../ob-shell.el | 119 +- .../ob-shen.el | 11 +- elpa/org-plus-contrib-20170407/ob-sql.el | 332 + .../ob-sqlite.el | 27 +- elpa/org-plus-contrib-20170407/ob-stan.el | 84 + .../ob-stata.el | 39 +- .../ob-table.el | 16 +- .../ob-tangle.el | 317 +- .../ob-tcl.el | 14 +- elpa/org-plus-contrib-20170407/ob-vbnet.el | 84 + .../ob.el | 4 +- .../org | 8756 ++++++----- .../org-agenda.el | 2634 ++-- .../org-annotate-file.el | 0 .../org-archive.el | 328 +- .../org-attach.el | 134 +- .../org-bbdb.el | 147 +- .../org-bibtex-extras.el | 14 +- .../org-bibtex.el | 147 +- .../org-bookmark.el | 7 +- .../org-capture.el | 1262 +- .../org-checklist.el | 0 .../org-choose.el | 0 .../org-clock.el | 1452 +- .../org-collector.el | 2 +- elpa/org-plus-contrib-20170407/org-colview.el | 1624 +++ elpa/org-plus-contrib-20170407/org-compat.el | 575 + .../org-contacts.el | 408 +- .../org-contribdir.el | 2 +- .../org-crypt.el | 150 +- .../org-ctags.el | 112 +- .../org-plus-contrib-20170407/org-datetree.el | 248 + .../org-depend.el | 4 +- .../org-docview.el | 17 +- .../org-drill.el | 0 .../org-plus-contrib-20170407/org-duration.el | 447 + .../org-effectiveness.el | 161 +- .../org-eldoc.el | 28 +- .../org-element.el | 2049 +-- .../org-elisp-symbol.el | 7 +- .../org-entities.el | 120 +- .../org-eshell.el | 11 +- .../org-eval-light.el | 2 +- .../org-eval.el | 2 +- .../org-eww.el | 108 +- .../org-expiry.el | 16 +- elpa/org-plus-contrib-20170407/org-faces.el | 653 + .../org-feed.el | 157 +- .../org-footnote.el | 1143 +- .../org-git-link.el | 12 +- .../org-gnus.el | 57 +- .../org-habit.el | 110 +- .../org-id.el | 30 +- .../org-indent.el | 104 +- elpa/org-plus-contrib-20170407/org-index.el | 3178 ++++ elpa/org-plus-contrib-20170407/org-info.el | 148 + .../org-inlinetask.el | 34 +- .../org-install.el | 0 .../org-interactive-query.el | 4 +- .../org-invoice.el | 40 +- .../org-irc.el | 32 +- .../org-learn.el | 2 +- .../org-license.el | 2 +- .../org-link-edit.el | 327 + elpa/org-plus-contrib-20170407/org-lint.el | 1240 ++ .../org-list.el | 1047 +- .../org-loaddefs.el | 1330 +- .../org-mac-iCal.el | 0 .../org-mac-link.el | 284 +- .../org-macro.el | 209 +- .../org-macs.el | 156 +- .../org-mairix.el | 7 +- .../org-man.el | 6 +- .../org-mew.el | 22 +- .../org-mhe.el | 41 +- .../org-mobile.el | 294 +- .../org-mouse.el | 153 +- .../org-notify.el | 6 +- .../org-notmuch.el | 20 +- .../org-panel.el | 0 .../org-passwords.el | 0 .../org-pcomplete.el | 91 +- .../org-plot.el | 167 +- .../org-plus-contrib-pkg.el | 5 + .../org-protocol.el | 357 +- .../org-registry.el | 0 .../org-rmail.el | 26 +- .../org-screen.el | 0 .../org-screenshot.el | 13 +- .../org-secretary.el | 0 .../org-src.el | 331 +- .../org-static-mathjax.el | 0 .../org-sudoku.el | 2 +- .../org-table.el | 1541 +- .../org-timer.el | 196 +- .../org-toc.el | 6 +- .../org-track.el | 3 +- .../org-velocity.el | 387 +- .../org-version.el | 10 +- .../org-vm.el | 26 +- .../org-w3m.el | 18 +- .../org-wikinodes.el | 4 +- .../org-wl.el | 23 +- .../org.el | 12064 ++++++++-------- elpa/org-plus-contrib-20170407/orgcard.pdf | Bin 0 -> 81692 bytes .../orgtbl-sqlinsert.el | 118 + .../ox-ascii.el | 480 +- .../ox-beamer.el | 235 +- .../ox-bibtex.el | 15 +- .../ox-confluence.el | 82 +- .../ox-deck.el | 0 .../ox-extra.el | 4 +- .../ox-freemind.el | 3 +- .../ox-groff.el | 36 +- .../ox-html.el | 1234 +- .../ox-icalendar.el | 117 +- .../ox-koma-letter.el | 279 +- .../ox-latex.el | 1109 +- .../ox-man.el | 393 +- .../ox-md.el | 362 +- .../ox-odt.el | 1198 +- .../ox-org.el | 83 +- .../ox-publish.el | 1134 +- .../ox-rss.el | 123 +- .../ox-s5.el | 0 .../ox-taskjuggler.el | 6 +- .../ox-texinfo.el | 337 +- .../ox.el | 3170 ++-- 219 files changed, 39581 insertions(+), 35504 deletions(-) create mode 100644 elpa/org-mime-20170218.501/org-mime-autoloads.el create mode 100644 elpa/org-mime-20170218.501/org-mime-pkg.el create mode 100644 elpa/org-mime-20170218.501/org-mime.el create mode 100644 elpa/org-mime-readme.txt delete mode 100644 elpa/org-plus-contrib-20150831/ob-clojure.el delete mode 100644 elpa/org-plus-contrib-20150831/ob-exp.el delete mode 100644 elpa/org-plus-contrib-20150831/ob-lisp.el delete mode 100644 elpa/org-plus-contrib-20150831/ob-lob.el delete mode 100644 elpa/org-plus-contrib-20150831/ob-sql.el delete mode 100644 elpa/org-plus-contrib-20150831/org-bullets.el delete mode 100644 elpa/org-plus-contrib-20150831/org-colview.el delete mode 100644 elpa/org-plus-contrib-20150831/org-compat.el delete mode 100644 elpa/org-plus-contrib-20150831/org-datetree.el delete mode 100644 elpa/org-plus-contrib-20150831/org-download.el delete mode 100644 elpa/org-plus-contrib-20150831/org-ebib.el delete mode 100644 elpa/org-plus-contrib-20150831/org-faces.el delete mode 100644 elpa/org-plus-contrib-20150831/org-index.el delete mode 100644 elpa/org-plus-contrib-20150831/org-info.el delete mode 100644 elpa/org-plus-contrib-20150831/org-mime.el delete mode 100644 elpa/org-plus-contrib-20150831/org-plus-contrib-autoloads.el delete mode 100644 elpa/org-plus-contrib-20150831/org-plus-contrib-pkg.el delete mode 100644 elpa/org-plus-contrib-20150831/orgcard.pdf delete mode 100644 elpa/org-plus-contrib-20150831/ox-gfm.el rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/COPYING (100%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/README_ELPA (100%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/dir (100%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/etc/ORG-NEWS (77%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/etc/styles/OrgOdtContentTemplate.xml (100%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/etc/styles/OrgOdtStyles.xml (100%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/etc/styles/README (100%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-C.el (76%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-J.el (89%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-R.el (86%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-abc.el (82%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-asymptote.el (78%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-awk.el (80%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-calc.el (87%) create mode 100644 elpa/org-plus-contrib-20170407/ob-clojure.el rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-comint.el (86%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-coq.el (90%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-core.el (64%) create mode 100644 elpa/org-plus-contrib-20170407/ob-csharp.el rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-css.el (82%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-ditaa.el (86%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-dot.el (84%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-ebnf.el (90%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-emacs-lisp.el (52%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-eukleides.el (92%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-eval.el (87%) create mode 100644 elpa/org-plus-contrib-20170407/ob-exp.el rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-fomus.el (91%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-forth.el (85%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-fortran.el (78%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-gnuplot.el (86%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-groovy.el (82%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-haskell.el (83%) create mode 100644 elpa/org-plus-contrib-20170407/ob-hledger.el rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-io.el (73%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-java.el (77%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-js.el (89%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-julia.el (91%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-keys.el (93%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-latex.el (77%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-ledger.el (88%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-lilypond.el (94%) create mode 100644 elpa/org-plus-contrib-20170407/ob-lisp.el create mode 100644 elpa/org-plus-contrib-20170407/ob-lob.el create mode 100644 elpa/org-plus-contrib-20170407/ob-lua.el rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-makefile.el (79%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-mathematica.el (91%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-mathomatic.el (76%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-matlab.el (89%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-maxima.el (87%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-mscgen.el (87%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-ocaml.el (79%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-octave.el (82%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-org.el (87%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-oz.el (97%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-perl.el (83%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-picolisp.el (94%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-plantuml.el (55%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-processing.el (90%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-python.el (79%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-ref.el (62%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-ruby.el (80%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-sass.el (86%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-scala.el (77%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-scheme.el (87%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-screen.el (88%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-sed.el (96%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-shell.el (71%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-shen.el (88%) create mode 100644 elpa/org-plus-contrib-20170407/ob-sql.el rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-sqlite.el (87%) create mode 100644 elpa/org-plus-contrib-20170407/ob-stan.el rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-stata.el (91%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-table.el (90%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-tangle.el (71%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob-tcl.el (89%) create mode 100644 elpa/org-plus-contrib-20170407/ob-vbnet.el rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ob.el (88%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org (83%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-agenda.el (86%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-annotate-file.el (100%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-archive.el (71%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-attach.el (82%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-bbdb.el (75%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-bibtex-extras.el (92%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-bibtex.el (90%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-bookmark.el (94%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-capture.el (65%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-checklist.el (100%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-choose.el (100%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-clock.el (72%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-collector.el (99%) create mode 100644 elpa/org-plus-contrib-20170407/org-colview.el create mode 100644 elpa/org-plus-contrib-20170407/org-compat.el rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-contacts.el (82%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-contribdir.el (96%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-crypt.el (69%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-ctags.el (86%) create mode 100644 elpa/org-plus-contrib-20170407/org-datetree.el rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-depend.el (99%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-docview.el (88%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-drill.el (100%) create mode 100644 elpa/org-plus-contrib-20170407/org-duration.el rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-effectiveness.el (70%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-eldoc.el (87%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-element.el (81%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-elisp-symbol.el (96%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-entities.el (92%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-eshell.el (86%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-eval-light.el (99%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-eval.el (99%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-eww.el (60%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-expiry.el (97%) create mode 100644 elpa/org-plus-contrib-20170407/org-faces.el rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-feed.el (87%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-footnote.el (54%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-git-link.el (96%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-gnus.el (87%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-habit.el (84%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-id.el (96%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-indent.el (84%) create mode 100644 elpa/org-plus-contrib-20170407/org-index.el create mode 100644 elpa/org-plus-contrib-20170407/org-info.el rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-inlinetask.el (93%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-install.el (100%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-interactive-query.el (99%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-invoice.el (93%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-irc.el (90%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-learn.el (99%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-license.el (99%) create mode 100644 elpa/org-plus-contrib-20170407/org-link-edit.el create mode 100644 elpa/org-plus-contrib-20170407/org-lint.el rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-list.el (81%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-loaddefs.el (77%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-mac-iCal.el (100%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-mac-link.el (79%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-macro.el (62%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-macs.el (64%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-mairix.el (98%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-man.el (95%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-mew.el (94%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-mhe.el (85%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-mobile.el (85%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-mouse.el (91%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-notify.el (98%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-notmuch.el (89%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-panel.el (100%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-passwords.el (100%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-pcomplete.el (86%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-plot.el (77%) create mode 100644 elpa/org-plus-contrib-20170407/org-plus-contrib-pkg.el rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-protocol.el (64%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-registry.el (100%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-rmail.el (81%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-screen.el (100%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-screenshot.el (98%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-secretary.el (100%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-src.el (78%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-static-mathjax.el (100%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-sudoku.el (99%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-table.el (84%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-timer.el (76%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-toc.el (99%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-track.el (99%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-velocity.el (68%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-version.el (65%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-vm.el (88%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-w3m.el (93%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-wikinodes.el (99%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org-wl.el (94%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/org.el (75%) mode change 100755 => 100644 create mode 100644 elpa/org-plus-contrib-20170407/orgcard.pdf create mode 100644 elpa/org-plus-contrib-20170407/orgtbl-sqlinsert.el rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ox-ascii.el (85%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ox-beamer.el (87%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ox-bibtex.el (97%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ox-confluence.el (72%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ox-deck.el (100%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ox-extra.el (99%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ox-freemind.el (99%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ox-groff.el (98%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ox-html.el (78%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ox-icalendar.el (93%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ox-koma-letter.el (78%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ox-latex.el (80%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ox-man.el (76%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ox-md.el (57%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ox-odt.el (84%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ox-org.el (82%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ox-publish.el (54%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ox-rss.el (82%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ox-s5.el (100%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ox-taskjuggler.el (99%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ox-texinfo.el (85%) rename elpa/{org-plus-contrib-20150831 => org-plus-contrib-20170407}/ox.el (74%) diff --git a/bba.org b/bba.org index 03a81dcf..17f03ec7 100644 --- a/bba.org +++ b/bba.org @@ -780,11 +780,10 @@ With [[https://github.com/fniessen/org-html-themes.git][org html themes]] it's e Some extra functionality from the org package repository. -#+BEGIN_SRC emacs-lisp :tangle no +#+BEGIN_SRC emacs-lisp :tangle yes (if (>= emacs-major-version 24) (progn - (add-to-list 'load-path "~/.emacs.d/elpa/org-plus-contrib-20150831" t) - (require 'org-mime) + (add-to-list 'load-path "~/.emacs.d/elpa/org-plus-contrib-20170407" t) )) #+END_SRC @@ -1596,7 +1595,7 @@ Use =C-c M= to send a multipart email with .org as text and exported html. #+BEGIN_SRC emacs-lisp :tangle yes - (load-file "~/.emacs.d/elpa/org-plus-contrib-20150831/org-mime.el") + (load-file "~/.emacs.d/elpa/org-mime-20170218.501/org-mime.el") (add-hook 'org-mode-hook (lambda() (define-key org-mode-map "\C-c\S-m" 'org-mime-org-buffer-htmlize))) diff --git a/elpa/org-mime-20170218.501/org-mime-autoloads.el b/elpa/org-mime-20170218.501/org-mime-autoloads.el new file mode 100644 index 00000000..f5352ecb --- /dev/null +++ b/elpa/org-mime-20170218.501/org-mime-autoloads.el @@ -0,0 +1,28 @@ +;;; org-mime-autoloads.el --- automatically extracted autoloads +;; +;;; Code: +(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path)))) + +;;;### (autoloads nil "org-mime" "org-mime.el" (22759 32883 0 0)) +;;; Generated autoloads from org-mime.el + +(autoload 'org-mime-org-buffer-htmlize "org-mime" "\ +Create buffer where text encoded in html&org formats as mime alternatives. + +\(fn)" t nil) + +(autoload 'org-mime-org-subtree-htmlize "org-mime" "\ +Create an email buffer containing the current subtree of the +current org-mode file exported to html and encoded in both html +and in org formats as mime alternatives. + +\(fn)" t nil) + +;;;*** + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; End: +;;; org-mime-autoloads.el ends here diff --git a/elpa/org-mime-20170218.501/org-mime-pkg.el b/elpa/org-mime-20170218.501/org-mime-pkg.el new file mode 100644 index 00000000..9c76b2ce --- /dev/null +++ b/elpa/org-mime-20170218.501/org-mime-pkg.el @@ -0,0 +1,2 @@ +;;; -*- no-byte-compile: t -*- +(define-package "org-mime" "20170218.501" "org html export for text/html MIME emails" '((emacs "24") (cl-lib "0.5")) :url "http://github.com/org-mime/org-mime" :keywords '("mime" "mail" "email" "html")) diff --git a/elpa/org-mime-20170218.501/org-mime.el b/elpa/org-mime-20170218.501/org-mime.el new file mode 100644 index 00000000..e806a180 --- /dev/null +++ b/elpa/org-mime-20170218.501/org-mime.el @@ -0,0 +1,386 @@ +;;; org-mime.el --- org html export for text/html MIME emails + +;; Copyright (C) 2010-2015 Eric Schulte + +;; Author: Eric Schulte +;; Maintainer: Chen Bin (redguardtoo) +;; Keywords: mime, mail, email, html +;; Package-Version: 20170218.501 +;; Homepage: http://github.com/org-mime/org-mime +;; Version: 0.0.6 +;; Package-Requires: ((emacs "24") (cl-lib "0.5")) + +;; This file is not part of GNU Emacs. + +;;; License: + +;; 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, 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 GNU Emacs. If not, see . + +;;; Commentary: + +;; WYSWYG, html mime composition using org-mode +;; +;; For mail composed using the orgstruct-mode minor mode, this +;; provides a function for converting all or part of your mail buffer +;; to embedded html as exported by org-mode. Call `org-mime-htmlize' +;; in a message buffer to convert either the active region or the +;; entire buffer to html. +;; +;; Similarly the `org-mime-org-buffer-htmlize' function can be called +;; from within an org-mode buffer to convert the buffer to html, and +;; package the results into an email handling with appropriate MIME +;; encoding. +;; +;; `org-mime-org-subtree-htmlize' is similar to `org-mime-org-buffer-htmlize' +;; but works on subtree. It can also read subtree properties MAIL_SUBJECT, +;; MAIL_TO, MAIL_CC, and MAIL_BCC. Here is the sample of subtree: +;; +;; * mail one +;; :PROPERTIES: +;; :MAIL_SUBJECT: mail title +;; :MAIL_TO: person1@gmail.com +;; :MAIL_CC: person2@gmail.com +;; :MAIL_BCC: person3@gmail.com +;; :END: +;; +;; To avoid exporting TOC, you can setup `org-mime-export-options', +;; (setq org-mime-export-options '(:section-numbers nil +;; :with-author nil +;; :with-toc nil)) +;; Or just setup your export options in org buffer/subtree which is overrided +;; by `org-mime-export-options' when it's NOT nil. +;; +;; You can change `org-mime-up-subtree-heading' before exporting subtree. +;; heck its documentation. +;; +;; Quick start: +;; Write mail in message-mode, make sure the mail body follows org format. +;; Before sending mail, `M-x org-mime-htmlize' +;; +;; Setup (OPTIONAL): +;; you might want to bind this to a key with something like the +;; following message-mode binding +;; +;; (add-hook 'message-mode-hook +;; (lambda () +;; (local-set-key (kbd "C-c M-o") 'org-mime-htmlize))) +;; +;; and the following org-mode binding +;; +;; (add-hook 'org-mode-hook +;; (lambda () +;; (local-set-key (kbd "C-c M-o") 'org-mime-org-buffer-htmlize))) + +;;; Code: +(require 'cl-lib) +(require 'org) + +(defcustom org-mime-use-property-inheritance nil + "Non-nil means al MAIL_ properties apply also for sublevels." + :group 'org-mime + :type 'boolean) + +(defcustom org-mime-default-header + "#+OPTIONS: latex:t toc:nil H:3\n" + "Default header to control html export options. +And ensure first line isn't assumed to be a title line." + :group 'org-mime + :type 'string) + +(defcustom org-mime-library 'mml + "Library to use for marking up MIME elements." + :group 'org-mime + :type '(choice 'mml 'semi 'vm)) + +(defcustom org-mime-preserve-breaks t + "Temporary value of `org-export-preserve-breaks' during mime encoding." + :group 'org-mime + :type 'boolean) + +(defcustom org-mime-fixedwith-wrap + "
\n%s
\n" + "Format string used to wrap a fixedwidth HTML email." + :group 'org-mime + :type 'string) + +(defvar org-mime-export-options nil + "Default export options which may overrides org buffer/subtree options. +You avoid exporting section-number/author/toc with below setup, +`(setq org-mime-export-options '(:section-numbers nil :with-author nil :with-toc nil))'") + +(defvar org-mime-html-hook nil + "Hook to run over the html buffer before attachment to email. +This could be used for example to post-process html elements.") + +(defvar org-mime-pre-html-hook nil + "Hook to run before html export. +Functions should take no arguments and will be run in a +buffer holding\nthe text to be exported.") + +(defvar org-mime-send-buffer-hook nil + "Hook to run in the Org-mode file before export.") + +(defvar org-mime-debug nil + "Enable debug logger.") + +(defvar org-mime-up-subtree-heading 'org-up-heading-safe + "Funtion to call before exporting subtree. +You could use either `org-up-heading-safe' or `org-back-to-heading'.") + + +(defun org-mime--chomp (str) + "Chomp leading and tailing whitespace from STR." + (while (string-match "\\`[\n\r]+\\|^\\s-+\\|\\s-+$\\|[\n\r]+\\'" + str) + (setq str (replace-match "" t t str))) + str) + +(defun org-mime--export-string (s fmt &optional opts) + "Export string S into HTML format. OPTS is export options." + (if org-mime-debug (message "org-mime--export-string called => %s" opts)) + ;; we won't export title from org file anyway + (if opts (setq opts (plist-put opts 'title nil))) + (if (fboundp 'org-export-string-as) + ;; emacs24.4+ + (org-export-string-as s fmt t (if org-mime-export-options org-mime-export-options opts)) + ;; emacs 24.3 + (org-export-string s (symbol-name fmt)))) + +;; example hook, for setting a dark background in
 elements
+(defun org-mime-change-element-style (element style)
+  "Set  elements in exported html with new default html STYLE."
+  (while (re-search-forward (format "<%s" element) nil t)
+    (replace-match (format "<%s style=\"%s\"" element style))))
+
+(defun org-mime-change-class-style (class style)
+  "CLASS is used for new default html STYLE in exported html."
+  (while (re-search-forward (format "class=\"%s\"" class) nil t)
+    (replace-match (format "class=\"%s\" style=\"%s\"" class style))))
+
+;; ;; example addition to `org-mime-html-hook' adding a dark background
+;; ;; color to 
 elements
+;; (add-hook 'org-mime-html-hook
+;;           (lambda ()
+;;             (org-mime-change-element-style
+;;              "pre" (format "color: %s; background-color: %s;"
+;;                            "#E6E1DC" "#232323"))
+;; 	    (org-mime-change-class-style
+;;              "verse" "border-left: 2px solid gray; padding-left: 4px;")))
+
+(defun org-mime-file (ext path id)
+  "Markup a file with EXT, PATH and ID for attachment."
+  (if org-mime-debug (message "org-mime-file called => %s %s %s" ext path id))
+  (cl-case org-mime-library
+    (mml (format (concat "<#part type=\"%s\" filename=\"%s\" "
+			  "disposition=inline id=\"<%s>\">\n<#/part>\n")
+		  ext path id))
+    (semi (concat
+            (format (concat "--[[%s\nContent-Disposition: "
+			    "inline;\nContent-ID: <%s>][base64]]\n")
+		    ext id)
+            (base64-encode-string
+             (with-temp-buffer
+               (set-buffer-multibyte nil)
+               (insert-file-contents-literally path)
+               (buffer-string)))))
+    (vm "?")))
+
+(defun org-mime-multipart (plain html &optional images)
+  "Markup a multipart/alternative PLAIN with PLAIN and HTML alternatives.
+If html portion of message includes IMAGES they are wrapped in multipart/related part."
+  (cl-case org-mime-library
+    (mml (concat "<#multipart type=alternative><#part type=text/plain>"
+		  plain
+		  (when images "<#multipart type=related>")
+		  "<#part type=text/html>"
+		  html
+		  images
+		  (when images "<#/multipart>\n")
+		  "<#/multipart>\n"))
+    (semi (concat
+            "--" "<>-{\n"
+            "--" "[[text/plain]]\n" plain
+	    (when images (concat "--" "<>-{\n"))
+            "--" "[[text/html]]\n"  html
+	    images
+	    (when images (concat "--" "}-<>\n"))
+            "--" "}-<>\n"))
+    (vm "?")))
+
+(defun org-mime-replace-images (str current-file)
+  "Replace images in STR with cid links.
+CURRENT-FILE is used to calculate full path of images."
+  (if org-mime-debug (message "org-mime-replace-images called => %s" current-file)
+)  (let* (html-images)
+    (cons
+     (replace-regexp-in-string ;; replace images in html
+      "src=\"\\([^\"]+\\)\""
+      (lambda (text)
+        (format
+         "src=\"cid:%s\""
+         (let* ((url (and (string-match "src=\"\\([^\"]+\\)\"" text)
+                          (match-string 1 text)))
+                (path (if (string-match-p "^file:///" url) (replace-regexp-in-string "^file://" "" url)
+                        (expand-file-name url (file-name-directory current-file))))
+                (ext (file-name-extension path))
+                (id (replace-regexp-in-string "[\/\\\\]" "_" path)))
+           (add-to-list 'html-images
+                        (org-mime-file (concat "image/" ext) path id))
+           id)))
+      str)
+     html-images)))
+
+(defun org-mime-htmlize (arg)
+  "Export a portion of an email to html using `org-mode'.
+If called with an active region only export that region, otherwise entire body.
+If ARG is not NIL, use `org-mime-fixedwith-wrap' to wrap the exported text."
+  (interactive "P")
+  (if org-mime-debug (message "org-mime-htmlize called"))
+  (let* ((region-p (org-region-active-p))
+         (html-start (or (and region-p (region-beginning))
+                         (save-excursion
+                           (goto-char (point-min))
+                           (search-forward mail-header-separator)
+                           (+ (point) 1))))
+         (html-end (or (and region-p (region-end))
+                       ;; TODO: should catch signature...
+                       (point-max)))
+         (body (concat org-mime-default-header
+                       (buffer-substring html-start html-end)))
+         (tmp-file (make-temp-name (expand-file-name
+                                    "mail" temporary-file-directory)))
+         ;; because we probably don't want to export a huge style file
+         (org-export-htmlize-output-type 'inline-css)
+         ;; makes the replies with ">"s look nicer
+         (org-export-preserve-breaks org-mime-preserve-breaks)
+         ;; dvipng for inline latex because MathJax doesn't work in mail
+         (org-html-with-latex 'dvipng)
+         ;; to hold attachments for inline html images
+         (html-and-images
+          (org-mime-replace-images
+           (org-mime--export-string body
+                                    'html
+                                    (if (fboundp 'org-export--get-inbuffer-options)
+                                        (org-export--get-inbuffer-options)))
+           tmp-file))
+         (html-images (unless arg (cdr html-and-images)))
+         (html (org-mime-apply-html-hook
+                (if arg
+                    (format org-mime-fixedwith-wrap body)
+                  (car html-and-images)))))
+    (delete-region html-start html-end)
+    (save-excursion
+      (goto-char html-start)
+      (insert (org-mime-multipart
+	       body html (mapconcat 'identity html-images "\n"))))))
+
+(defun org-mime-apply-html-hook (html)
+  "Apply HTML hook."
+  (if org-mime-html-hook
+      (with-temp-buffer
+        (insert html)
+        (goto-char (point-min))
+        (run-hooks 'org-mime-html-hook)
+        (buffer-string))
+    html))
+
+(defun org-mime--get-buffer-title ()
+  "Get buffer title."
+  (let* ((tmp (if (fboundp 'org-export--get-inbuffer-options)
+                  (plist-get (org-export--get-inbuffer-options) :title))))
+    (when tmp
+      (let ((txt (car tmp)))
+        (set-text-properties 0 (length txt) nil txt)
+        txt))))
+
+(defun org-mime-compose (body file &optional to subject headers opts)
+  "Create mail BODY in FILE with SUBJECT, HEADERS and OPTS."
+  (if org-mime-debug (message "org-mime-compose called => %s %s" file opts))
+  (let* ((fmt 'html))
+    (unless (featurep 'message)
+      (require 'message))
+    (message-mail to subject headers nil)
+    (message-goto-body)
+    (cl-labels ((bhook (body fmt)
+                       (let ((hook 'org-mime-pre-html-hook))
+                         (if (> (eval `(length ,hook)) 0)
+                             (with-temp-buffer
+                               (insert body)
+                               (goto-char (point-min))
+                               (eval `(run-hooks ',hook))
+                               (buffer-string))
+                           body))))
+      (let* ((org-link-file-path-type 'absolute)
+             (plain (org-mime--export-string (org-mime--chomp body) 'ascii))
+             ;; we probably don't want to export a huge style file
+             (org-export-htmlize-output-type 'inline-css)
+             (html-and-images
+              (org-mime-replace-images
+               (org-mime--export-string (bhook body 'html) 'html opts)
+               file))
+             (images (cdr html-and-images))
+             (html (org-mime-apply-html-hook (car html-and-images))))
+        (insert (org-mime-multipart plain html)
+                (mapconcat 'identity images "\n"))))))
+
+;;;###autoload
+(defun org-mime-org-buffer-htmlize ()
+  "Create buffer where text encoded in html&org formats as mime alternatives."
+  (interactive)
+  (run-hooks 'org-mime-send-buffer-hook)
+  (let* ((region-p (org-region-active-p))
+         (file (buffer-file-name (current-buffer)))
+         (subject (or (org-mime--get-buffer-title)
+                      (if (not file) (buffer-name (buffer-base-buffer))
+                        (file-name-sans-extension
+                         (file-name-nondirectory file)))))
+         (body-start (or (and region-p (region-beginning))
+                         (save-excursion (goto-char (point-min)))))
+         (body-end (or (and region-p (region-end)) (point-max)))
+         (temp-body-file (make-temp-file "org-mime-export"))
+         (body (buffer-substring body-start body-end)))
+    (org-mime-compose body
+                      file
+                      nil ; TO
+                      subject
+                      nil ; HEADERS (CC, BCC ...)
+                      (if (fboundp 'org-export--get-inbuffer-options)
+                          (org-export--get-inbuffer-options)))))
+
+;;;###autoload
+(defun org-mime-org-subtree-htmlize ()
+  "Create an email buffer containing the current subtree of the
+current org-mode file exported to html and encoded in both html
+and in org formats as mime alternatives."
+  (interactive)
+  (save-excursion
+    (funcall org-mime-up-subtree-heading)
+    (flet ((mp (p) (org-entry-get nil p org-mime-use-property-inheritance)))
+      (let* ((file (buffer-file-name (current-buffer)))
+             (subject (or (mp "MAIL_SUBJECT") (nth 4 (org-heading-components))))
+             (to (mp "MAIL_TO"))
+             (cc (mp "MAIL_CC"))
+             (bcc (mp "MAIL_BCC"))
+             ;; Thanks for Matt Price improving handling of cc & bcc headers
+             (other-headers (cond
+                             ((and cc bcc) `((cc . ,cc) (bcc . ,bcc)))
+                             (cc `((cc . ,cc)))
+                             (bcc `((bcc . ,bcc)))
+                             (t nil)))
+             (opts (if (fboundp 'org-export--get-subtree-options) (org-export--get-subtree-options)))
+             (body (org-get-entry)))
+        (org-mime-compose body file to subject other-headers opts)))))
+
+(provide 'org-mime)
+;;; org-mime.el ends here
diff --git a/elpa/org-mime-readme.txt b/elpa/org-mime-readme.txt
new file mode 100644
index 00000000..02bed600
--- /dev/null
+++ b/elpa/org-mime-readme.txt
@@ -0,0 +1,52 @@
+WYSWYG, html mime composition using org-mode
+
+For mail composed using the orgstruct-mode minor mode, this
+provides a function for converting all or part of your mail buffer
+to embedded html as exported by org-mode.  Call `org-mime-htmlize'
+in a message buffer to convert either the active region or the
+entire buffer to html.
+
+Similarly the `org-mime-org-buffer-htmlize' function can be called
+from within an org-mode buffer to convert the buffer to html, and
+package the results into an email handling with appropriate MIME
+encoding.
+
+`org-mime-org-subtree-htmlize' is similar to `org-mime-org-buffer-htmlize'
+but works on subtree. It can also read subtree properties MAIL_SUBJECT,
+MAIL_TO, MAIL_CC, and MAIL_BCC. Here is the sample of subtree:
+
+* mail one
+  :PROPERTIES:
+  :MAIL_SUBJECT: mail title
+  :MAIL_TO: person1@gmail.com
+  :MAIL_CC: person2@gmail.com
+  :MAIL_BCC: person3@gmail.com
+  :END:
+
+To avoid exporting TOC, you can setup `org-mime-export-options',
+  (setq org-mime-export-options '(:section-numbers nil
+                                  :with-author nil
+                                  :with-toc nil))
+Or just setup your export options in org buffer/subtree which is overrided
+by `org-mime-export-options' when it's NOT nil.
+
+You can change `org-mime-up-subtree-heading' before exporting subtree.
+heck its documentation.
+
+Quick start:
+Write mail in message-mode, make sure the mail body follows org format.
+Before sending mail, `M-x org-mime-htmlize'
+
+Setup (OPTIONAL):
+you might want to bind this to a key with something like the
+following message-mode binding
+
+  (add-hook 'message-mode-hook
+            (lambda ()
+              (local-set-key (kbd "C-c M-o") 'org-mime-htmlize)))
+
+and the following org-mode binding
+
+  (add-hook 'org-mode-hook
+            (lambda ()
+              (local-set-key (kbd "C-c M-o") 'org-mime-org-buffer-htmlize)))
diff --git a/elpa/org-plus-contrib-20150831/ob-clojure.el b/elpa/org-plus-contrib-20150831/ob-clojure.el
deleted file mode 100644
index 68f748ca..00000000
--- a/elpa/org-plus-contrib-20150831/ob-clojure.el
+++ /dev/null
@@ -1,115 +0,0 @@
-;;; ob-clojure.el --- org-babel functions for clojure evaluation
-
-;; Copyright (C) 2009-2015 Free Software Foundation, Inc.
-
-;; Author: Joel Boehland, Eric Schulte, Oleh Krehel
-;;
-;; 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 .
-
-;;; Commentary:
-
-;; Support for evaluating clojure code
-
-;; Requirements:
-
-;; - clojure (at least 1.2.0)
-;; - clojure-mode
-;; - either cider or SLIME
-
-;; For Cider, see https://github.com/clojure-emacs/cider
-
-;; For SLIME, 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)
-(eval-when-compile
-  (require 'cl))
-
-(declare-function nrepl-dict-get "ext:nrepl-client" (dict key))
-(declare-function nrepl-sync-request:eval "ext:nrepl-client" (input &optional ns session))
-(declare-function slime-eval "ext:slime" (sexp &optional package))
-
-(defvar org-babel-tangle-lang-exts)
-(add-to-list 'org-babel-tangle-lang-exts '("clojure" . "clj"))
-
-(defvar org-babel-default-header-args:clojure '())
-(defvar org-babel-header-args:clojure '((package . :any)))
-
-(defcustom org-babel-clojure-backend
-  (cond ((featurep 'cider) 'cider)
-	(t 'slime))
-  "Backend used to evaluate Clojure code blocks."
-  :group 'org-babel
-  :type '(choice
-	  (const :tag "cider" cider)
-	  (const :tag "SLIME" slime)))
-
-(defun org-babel-expand-body:clojure (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)))
-	 (print-level nil) (print-length nil)
-	 (body (org-babel-trim
-		(if (> (length vars) 0)
-		    (concat "(let ["
-			    (mapconcat
-			     (lambda (var)
-			       (format "%S (quote %S)" (car var) (cdr var)))
-			     vars "\n      ")
-			    "]\n" body ")")
-		  body))))
-    (if (or (member "code" result-params)
-	    (member "pp" result-params))
-	(format "(clojure.pprint/pprint (do %s))" body)
-      body)))
-
-(defun org-babel-execute:clojure (body params)
-  "Execute a block of Clojure code with Babel."
-  (let ((expanded (org-babel-expand-body:clojure body params))
-	result)
-    (case org-babel-clojure-backend
-      (cider
-       (require 'cider)
-       (let ((result-params (cdr (assoc :result-params params))))
-	 (setq result
-	       (nrepl-dict-get
-		(nrepl-sync-request:eval expanded)
-		(if (or (member "output" result-params)
-			(member "pp" result-params))
-		    "out"
-		  "value")))))
-      (slime
-       (require 'slime)
-       (with-temp-buffer
-    	 (insert expanded)
-	 (setq result
-	       (slime-eval
-		`(swank:eval-and-grab-output
-		  ,(buffer-substring-no-properties (point-min) (point-max)))
-		(cdr (assoc :package params)))))))
-    (org-babel-result-cond (cdr (assoc :result-params params))
-      result
-      (condition-case nil (org-babel-script-escape result)
-	(error result)))))
-
-(provide 'ob-clojure)
-
-;;; ob-clojure.el ends here
diff --git a/elpa/org-plus-contrib-20150831/ob-exp.el b/elpa/org-plus-contrib-20150831/ob-exp.el
deleted file mode 100644
index 1f019732..00000000
--- a/elpa/org-plus-contrib-20150831/ob-exp.el
+++ /dev/null
@@ -1,449 +0,0 @@
-;;; ob-exp.el --- Exportation of org-babel source blocks
-
-;; Copyright (C) 2009-2015 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 .
-
-;;; Code:
-(require 'ob-core)
-(require 'org-src)
-(eval-when-compile
-  (require 'cl))
-
-(defvar org-babel-lob-one-liner-regexp)
-(defvar org-babel-ref-split-regexp)
-(defvar org-list-forbidden-blocks)
-
-(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-commented-heading-p "org" (&optional no-inheritance))
-(declare-function org-in-block-p "org" (names))
-(declare-function org-in-verbatim-emphasis "org" ())
-(declare-function org-link-search "org" (s &optional avoid-pos stealth))
-(declare-function org-fill-template "org" (template alist))
-(declare-function org-split-string "org" (string &optional separators))
-(declare-function org-element-at-point "org-element" ())
-(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-id-get "org-id" (&optional pom create prefix))
-(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.  When set to 'inline-only, only inline code blocks will
-be executed."
-  :group 'org-babel
-  :version "24.1"
-  :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)))
-
-(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)))
-	  (heading-query (or (org-id-get)
-			     ;; CUSTOM_IDs don't work, maybe they are
-			     ;; stripped, or maybe they resolve too
-			     ;; late in `org-link-search'.
-			     ;; (org-entry-get nil "CUSTOM_ID")
-			     (nth 4 (ignore-errors (org-heading-components)))))
-	  (export-buffer (current-buffer))
-	  results)
-     (when org-babel-exp-reference-buffer
-       ;; Resolve parameters in the original file so that headline and
-       ;; file-wide parameters are included, attempt to go to the same
-       ;; heading in the original file
-       (set-buffer org-babel-exp-reference-buffer)
-       (save-restriction
-	 (when heading-query
-	   (condition-case nil
-	       (let ((org-link-search-inhibit-query t))
-		 ;; TODO: When multiple headings have the same title,
-		 ;;       this returns the first, which is not always
-		 ;;       the right heading.  Consider a better way to
-		 ;;       find the proper heading.
-		 (org-link-search heading-query))
-	     (error (when heading-query
-		      (goto-char (point-min))
-		      (re-search-forward (regexp-quote heading-query) nil t)))))
-	 (setq results ,@body))
-       (set-buffer export-buffer)
-       results)))
-(def-edebug-spec org-babel-exp-in-export-file (form body))
-
-(defun org-babel-exp-src-block (&rest headers)
-  "Process source block for export.
-Depending on the 'export' headers argument, replace the source
-code block like this:
-
-both ---- display the code and the results
-
-code ---- the default, display the code inside the block but do
-          not process
-
-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
-
-Assume point is at the beginning of block's starting line."
-  (interactive)
-  (save-excursion
-    (let* ((info (org-babel-get-src-block-info 'light))
-	   (line (org-current-line))
-	   (lang (nth 0 info))
-	   (raw-params (nth 2 info)) hash)
-      ;; bail if we couldn't get any info from the block
-      (unless noninteractive
-	(message "org-babel-exp process %s at line %d..." lang line))
-      (when info
-	;; if we're actually going to need the parameters
-	(when (member (cdr (assoc :exports (nth 2 info))) '("both" "results"))
-	  (org-babel-exp-in-export-file lang
-	    (setf (nth 2 info)
-		  (org-babel-process-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)))))
-
-(defcustom org-babel-exp-call-line-template
-  ""
-  "Template used to export call lines.
-This template may be customized to include the call line name
-with any export markup.  The template is filled out using
-`org-fill-template', and the following %keys may be used.
-
- line --- call line
-
-An example value would be \"\\n: call: %line\" to export the call line
-wrapped in a verbatim environment.
-
-Note: the results are inserted separately after the contents of
-this template."
-  :group 'org-babel
-  :type 'string)
-
-(defvar org-babel-default-lob-header-args)
-(defun org-babel-exp-process-buffer (reference-buffer)
-  "Execute all Babel blocks in current buffer.
-REFERENCE-BUFFER is the buffer containing a pristine copy of the
-buffer being processed.  It is used to properly resolve
-references in source blocks, as modifications in current buffer
-may make them unreachable."
-  (interactive)
-  (save-window-excursion
-    (save-excursion
-      (let ((case-fold-search t)
-	    (org-babel-exp-reference-buffer reference-buffer)
-	    (regexp (concat org-babel-inline-src-block-regexp "\\|"
-			    org-babel-lob-one-liner-regexp "\\|"
-			    "^[ \t]*#\\+BEGIN_SRC")))
-	(goto-char (point-min))
-	(while (re-search-forward regexp nil t)
-	  (unless (save-match-data (org-in-commented-heading-p))
-	    (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))
-		   (begin (copy-marker (org-element-property :begin element)))
-		   (end (copy-marker
-			 (save-excursion
-			   (goto-char (org-element-property :end element))
-			   (skip-chars-backward " \r\t\n")
-			   (point)))))
-	      (case type
-		(inline-src-block
-		 (let* ((head (match-beginning 0))
-			(info (append (org-babel-parse-inline-src-block-match)
-				      (list nil nil head)))
-			(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-reference-buffer)
-			   (nth 1 info)))
-		   (goto-char begin)
-		   (let ((replacement (org-babel-exp-do-export info 'inline)))
-		     (if (equal replacement "")
-			 ;; Replacement code is empty: remove inline
-			 ;; source block, including extra white space
-			 ;; that might have been created when
-			 ;; inserting results.
-			 (delete-region begin
-					(progn (goto-char end)
-					       (skip-chars-forward " \t")
-					       (point)))
-		       ;; Otherwise: remove inline src block but
-		       ;; preserve following white spaces.  Then
-		       ;; insert value.
-		       (delete-region begin end)
-		       (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
-			begin
-			(progn (goto-char end)
-			       (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 begin)
-		     (delete-region begin end)
-		     (insert rep))))
-		(src-block
-		 (let* ((match-start (copy-marker (match-beginning 0)))
-			(ind (org-get-indentation))
-			(lang (or (org-element-property :language element)
-				  (user-error
-				   "No language for src block: %s"
-				   (or (org-element-property :name element)
-				       "(unnamed)"))))
-			(headers
-			 (cons lang
-			       (let ((params
-				      (org-element-property
-				       :parameters element)))
-				 (and params (org-split-string params))))))
-		   ;; 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 end))
-			   ((equal replacement "")
-			    (goto-char end)
-			    (skip-chars-forward " \r\t\n")
-			    (beginning-of-line)
-			    (delete-region begin (point)))
-			   (t
-			    (goto-char match-start)
-			    (delete-region (point)
-					   (save-excursion (goto-char end)
-							   (line-end-position)))
-			    (insert replacement)
-			    (if (or org-src-preserve-indentation
-				    (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)))))
-		   (set-marker match-start nil))))
-	      (set-marker begin nil)
-	      (set-marker end nil))))))))
-
-(defun org-babel-in-example-or-verbatim ()
-  "Return true if point is in example or verbatim code.
-Example and verbatim code include escaped portions of
-an org-mode buffer code that should be treated as normal
-org-mode text."
-  (or (save-match-data
-	(save-excursion
-	  (goto-char (point-at-bol))
-	  (looking-at "[ \t]*:[ \t]")))
-      (org-in-verbatim-emphasis)
-      (org-in-block-p org-list-forbidden-blocks)
-      (org-between-regexps-p "^[ \t]*#\\+begin_src" "^[ \t]*#\\+end_src")))
-
-(defun org-babel-exp-do-export (info type &optional hash)
-  "Return a string with the exported content of a code block.
-The function respects the value of the :exports header argument."
-  (let ((silently (lambda () (let ((session (cdr (assoc :session (nth 2 info)))))
-			       (when (not (and session (equal "none" session)))
-				 (org-babel-exp-results info type 'silent)))))
-	(clean (lambda () (if (eq type 'inline)
-			      (org-babel-remove-inline-result)
-			    (org-babel-remove-result info)))))
-    (case (intern (or (cdr (assoc :exports (nth 2 info))) "code"))
-      ('none (funcall silently) (funcall clean) "")
-      ('code (funcall silently) (funcall clean) (org-babel-exp-code info type))
-      ('results (org-babel-exp-results info type nil hash) "")
-      ('both (org-babel-exp-results info type nil hash)
-	     (org-babel-exp-code info type)))))
-
-(defcustom org-babel-exp-code-template
-  "#+BEGIN_SRC %lang%switches%flags\n%body\n#+END_SRC"
-  "Template used to export the body of code blocks.
-This template may be customized to include additional information
-such as the code block name, or the values of particular header
-arguments.  The template is filled out using `org-fill-template',
-and the following %keys may be used.
-
- lang ------ the language of the code block
- name ------ the name of the code block
- body ------ the body of the code block
- switches -- the switches associated to the code block
- flags ----- the flags passed to the code block
-
-In addition to the keys mentioned above, every header argument
-defined for the code block may be used as a key and will be
-replaced with its value."
-  :group 'org-babel
-  :type 'string)
-
-(defcustom org-babel-exp-inline-code-template
-  "src_%lang[%switches%flags]{%body}"
-  "Template used to export the body of inline code blocks.
-This template may be customized to include additional information
-such as the code block name, or the values of particular header
-arguments.  The template is filled out using `org-fill-template',
-and the following %keys may be used.
-
- lang ------ the language of the code block
- name ------ the name of the code block
- body ------ the body of the code block
- switches -- the switches associated to the code block
- flags ----- the flags passed to the code block
-
-In addition to the keys mentioned above, every header argument
-defined for the code block may be used as a key and will be
-replaced with its value."
-  :group 'org-babel
-  :type 'string
-  :version "25.1"
-  :package-version '(Org . "8.3"))
-
-(defun org-babel-exp-code (info type)
-  "Return the original code block formatted for export."
-  (setf (nth 1 info)
-	(if (string= "strip-export" (cdr (assoc :noweb (nth 2 info))))
-	    (replace-regexp-in-string
-	     (org-babel-noweb-wrap) "" (nth 1 info))
-	  (if (org-babel-noweb-p (nth 2 info) :export)
-	      (org-babel-expand-noweb-references
-	       info org-babel-exp-reference-buffer)
-	    (nth 1 info))))
-  (org-fill-template
-   (if (eq type 'inline)
-       org-babel-exp-inline-code-template 
-       org-babel-exp-code-template)
-   `(("lang"  . ,(nth 0 info))
-     ("body"  . ,(org-escape-code-in-string (nth 1 info)))
-     ("switches" . ,(let ((f (nth 3 info)))
-		      (and (org-string-nw-p f) (concat " " f))))
-     ("flags" . ,(let ((f (assq :flags (nth 2 info))))
-		   (and f (concat " " (cdr f)))))
-     ,@(mapcar (lambda (pair)
-		 (cons (substring (symbol-name (car pair)) 1)
-		       (format "%S" (cdr pair))))
-	       (nth 2 info))
-     ("name"  . ,(or (nth 4 info) "")))))
-
-(defun org-babel-exp-results (info type &optional silent hash)
-  "Evaluate and return the results of the current code block for export.
-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 (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-reference-buffer)
-		  (nth 1 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)
-	(prog1 nil
-	  (setf (nth 1 info) body)
-	  (setf (nth 2 info)
-		(org-babel-exp-in-export-file lang
-		  (org-babel-process-params
-		   (org-babel-merge-params
-		    (nth 2 info)
-		    `((:results . ,(if silent "silent" "replace")))))))
-	  (cond
-	   ((equal type 'block)
-	    (org-babel-execute-src-block nil info))
-	   ((equal type 'inline)
-	    ;; position the point on the inline source block allowing
-	    ;; `org-babel-insert-result' to check that the block is
-	    ;; inline
-	    (re-search-backward "[ \f\t\n\r\v]" nil t)
-	    (re-search-forward org-babel-inline-src-block-regexp nil t)
-	    (re-search-backward "src_" nil t)
-	    (org-babel-execute-src-block nil info))
-	   ((equal type 'lob)
-	    (save-excursion
-	      (re-search-backward org-babel-lob-one-liner-regexp nil t)
-	      (let (org-confirm-babel-evaluate)
-		(org-babel-execute-src-block nil info))))))))))
-
-
-(provide 'ob-exp)
-
-;;; ob-exp.el ends here
diff --git a/elpa/org-plus-contrib-20150831/ob-lisp.el b/elpa/org-plus-contrib-20150831/ob-lisp.el
deleted file mode 100644
index bd80dee4..00000000
--- a/elpa/org-plus-contrib-20150831/ob-lisp.el
+++ /dev/null
@@ -1,111 +0,0 @@
-;;; ob-lisp.el --- org-babel functions for common lisp evaluation
-
-;; Copyright (C) 2009-2015 Free Software Foundation, Inc.
-
-;; Authors: Joel Boehland
-;;	 Eric Schulte
-;;	 David T. O'Toole 
-;; 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 .
-
-;;; Commentary:
-
-;;; support for evaluating common lisp code, relies on slime for all eval
-
-;;; Requirements:
-
-;; Requires SLIME (Superior Lisp Interaction Mode for Emacs.)
-;; See http://common-lisp.net/project/slime/
-
-;;; Code:
-(require 'ob)
-
-(declare-function slime-eval "ext:slime" (sexp &optional package))
-
-(defvar org-babel-tangle-lang-exts)
-(add-to-list 'org-babel-tangle-lang-exts '("lisp" . "lisp"))
-
-(defvar org-babel-default-header-args:lisp '())
-(defvar org-babel-header-args:lisp '((package . :any)))
-
-(defcustom org-babel-lisp-dir-fmt
-  "(let ((*default-pathname-defaults* #P%S\n)) %%s\n)"
-  "Format string used to wrap code bodies to set the current directory.
-For example a value of \"(progn ;; %s\\n   %%s)\" would ignore the
-current directory string."
-  :group 'org-babel
-  :version "24.1"
-  :type 'string)
-
-(defun org-babel-expand-body:lisp (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)))
-	 (print-level nil) (print-length nil)
-	 (body (org-babel-trim
-		(if (> (length vars) 0)
-		    (concat "(let ("
-			    (mapconcat
-			     (lambda (var)
-			       (format "(%S (quote %S))" (car var) (cdr var)))
-			     vars "\n      ")
-			    ")\n" body ")")
-		  body))))
-    (if (or (member "code" result-params)
-	    (member "pp" result-params))
-	(format "(pprint %s)" body)
-      body)))
-
-(defun org-babel-execute:lisp (body params)
-  "Execute a block of Common Lisp code with Babel."
-  (require 'slime)
-  (org-babel-reassemble-table
-   (let ((result
-	  (funcall (if (member "output" (cdr (assoc :result-params params)))
-		       #'car #'cadr)
-		   (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\n)")
-				       (buffer-substring-no-properties
-					(point-min) (point-max)))))
-				 (cdr (assoc :package params)))))))
-     (org-babel-result-cond (cdr (assoc :result-params params))
-       result
-       (condition-case nil
-           (read (org-babel-lisp-vector-to-list result))
-         (error 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)))))
-
-(defun org-babel-lisp-vector-to-list (results)
-  ;; TODO: better would be to replace #(...) with [...]
-  (replace-regexp-in-string "#(" "(" results))
-
-(provide 'ob-lisp)
-
-
-
-;;; ob-lisp.el ends here
diff --git a/elpa/org-plus-contrib-20150831/ob-lob.el b/elpa/org-plus-contrib-20150831/ob-lob.el
deleted file mode 100644
index 0267f443..00000000
--- a/elpa/org-plus-contrib-20150831/ob-lob.el
+++ /dev/null
@@ -1,179 +0,0 @@
-;;; ob-lob.el --- functions supporting the Library of Babel
-
-;; Copyright (C) 2009-2015 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 .
-
-;;; Code:
-(eval-when-compile
-  (require 'cl))
-(require 'ob-core)
-(require 'ob-table)
-
-(declare-function org-babel-in-example-or-verbatim "ob-exp" nil)
-
-(defvar org-babel-library-of-babel nil
-  "Library of source-code blocks.
-This is an association list.  Populate the library by adding
-files to `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
-  :version "24.1"
-  :type '(repeat file))
-
-(defvar org-babel-default-lob-header-args '((:exports . "results"))
-  "Default header arguments to use when exporting #+lob/call lines.")
-
-(defun org-babel-lob-ingest (&optional file)
-  "Add all named source blocks defined in FILE to `org-babel-library-of-babel'."
-  (interactive "fFile: ")
-  (let ((lob-ingest-count 0))
-    (org-babel-map-src-blocks file
-      (let* ((info (org-babel-get-src-block-info 'light))
-	     (source-name (nth 4 info)))
-	(when source-name
-	  (setq source-name (intern source-name)
-		org-babel-library-of-babel
-		(cons (cons source-name info)
-		      (assq-delete-all source-name org-babel-library-of-babel))
-		lob-ingest-count (1+ lob-ingest-count)))))
-    (message "%d src block%s added to Library of Babel"
-	     lob-ingest-count (if (> lob-ingest-count 1) "s" ""))
-    lob-ingest-count))
-
-(defconst org-babel-block-lob-one-liner-regexp
-  (concat
-   "^\\([ \t]*?\\)#\\+call:[ \t]+\\([^\(\)\n]+?\\)\\(\\[\\(.*\\)\\]\\|\\(\\)\\)"
-   "\(\\([^\n]*?\\)\)\\(\\[.+\\]\\|\\)[ \t]*\\(\\([^\n]*\\)\\)?")
-  "Regexp to match non-inline calls to predefined source block functions.")
-
-(defconst org-babel-inline-lob-one-liner-regexp
-  (concat
-   "\\([^\n]*?\\)call_\\([^\(\)[:space:]\n]+?\\)\\(\\[\\(.*?\\)\\]\\|\\(\\)\\)"
-   "\(\\(.*?\\)\)\\(\\[\\(.*?\\)\\]\\)?")
-  "Regexp to match inline calls to predefined source block functions.")
-
-(defconst org-babel-lob-one-liner-regexp
-  (concat "\\(" org-babel-block-lob-one-liner-regexp
-	  "\\|" org-babel-inline-lob-one-liner-regexp "\\)")
-  "Regexp to match calls to predefined source block functions.")
-
-;; functions for executing lob one-liners
-
-;;;###autoload
-(defun org-babel-lob-execute-maybe ()
-  "Execute a Library of Babel source block, if appropriate.
-Detect if this is context for a Library Of Babel source block and
-if so then run the appropriate source block from the Library."
-  (interactive)
-  (let ((info (org-babel-lob-get-info)))
-    (if (and (nth 0 info) (not (org-babel-in-example-or-verbatim)))
-	(progn (org-babel-lob-execute info) t)
-      nil)))
-
-;;;###autoload
-(defun org-babel-lob-get-info ()
-  "Return a Library of Babel function call as a string."
-  (let ((case-fold-search t)
-	(nonempty (lambda (a b)
-		    (let ((it (match-string a)))
-		      (if (= (length it) 0) (match-string b) it)))))
-    (save-excursion
-      (beginning-of-line 1)
-      (when (looking-at org-babel-lob-one-liner-regexp)
-	(append
-	 (mapcar #'org-no-properties
-		 (list
-		  (format "%s%s(%s)%s"
-			  (funcall nonempty 3 12)
-			  (if (not (= 0 (length (funcall nonempty 5 14))))
-			      (concat "[" (funcall nonempty 5 14) "]") "")
-			  (or (funcall nonempty 7 16) "")
-			  (or (funcall nonempty 8 19) ""))
-		  (funcall nonempty 9 18)))
-	 (list (length (if (= (length (match-string 12)) 0)
-			   (match-string 2) (match-string 11)))
-	       (save-excursion
-		 (forward-line -1)
-		 (save-match-data
-		   (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
-			 (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-p (and (cdr (assoc :cache pre-params))
-		       (string= "yes" (cdr (assoc :cache pre-params)))))
-	 (new-hash (when cache-p
-		     (org-babel-sha1-hash
-		      ;; Do *not* pre-process params for call line
-		      ;; hash evaluation, since for a call line :var
-		      ;; extension *is* execution.
-		      (let* ((params (nth 2 pre-info))
-			     (sha1-nth2 (list
-				    (cons
-				     (cons :c-var (cdr (assoc :var params)))
-				     (assq-delete-all :var (copy-tree params)))))
-			     (sha1-info (copy-tree pre-info)))
-			(prog1 sha1-info
-			  (setcar (cddr sha1-info) sha1-nth2))))))
-	 (old-hash (when cache-p (org-babel-current-result-hash pre-info)))
-	 (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
-				    nil pre-info))
-			(forward-line 1)
-			(message "%S" (org-babel-read-result)))
-      (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 pre-info))))))
-
-(provide 'ob-lob)
-
-;; Local variables:
-;; generated-autoload-file: "org-loaddefs.el"
-;; End:
-
-;;; ob-lob.el ends here
diff --git a/elpa/org-plus-contrib-20150831/ob-sql.el b/elpa/org-plus-contrib-20150831/ob-sql.el
deleted file mode 100644
index 2748b43a..00000000
--- a/elpa/org-plus-contrib-20150831/ob-sql.el
+++ /dev/null
@@ -1,228 +0,0 @@
-;;; ob-sql.el --- org-babel functions for sql evaluation
-
-;; Copyright (C) 2009-2015 Free Software Foundation, Inc.
-
-;; Author: Eric Schulte
-;; 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 .
-
-;;; Commentary:
-
-;; Org-Babel support for evaluating sql source code.
-;; (see also ob-sqlite.el)
-;;
-;; SQL is somewhat unique in that there are many different engines for
-;; the evaluation of sql (Mysql, PostgreSQL, etc...), so much of this
-;; file will have to be implemented engine by engine.
-;;
-;; Also SQL evaluation generally takes place inside of a database.
-;;
-;; Header args used:
-;; - engine
-;; - cmdline
-;; - dbhost
-;; - dbport
-;; - 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
-;; - support for more engines (currently only supports mysql)
-;; - what's a reasonable way to drop table data into SQL?
-;;
-
-;;; Code:
-(require 'ob)
-(eval-when-compile (require 'cl))
-
-(declare-function org-table-import "org-table" (file arg))
-(declare-function orgtbl-to-csv "org-table" (table params))
-(declare-function org-table-to-lisp "org-table" (&optional txt))
-
-(defvar org-babel-default-header-args:sql '())
-
-(defconst org-babel-header-args:sql
-  '((engine	       . :any)
-    (out-file	       . :any)
-    (dbhost	       . :any)
-    (dbport	       . :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 org-babel-sql-dbstring-mysql (host port user password database)
-  "Make MySQL cmd line args for database connection.  Pass nil to omit that arg."
-  (combine-and-quote-strings
-   (delq nil
-	 (list (when host     (concat "-h" host))
-	       (when port     (format "-P%d" port))
-	       (when user     (concat "-u" user))
-	       (when password (concat "-p" password))
-	       (when database (concat "-D" database))))))
-
-(defun org-babel-sql-dbstring-postgresql (host user database)
-  "Make PostgreSQL command line args for database connection.
-Pass nil to omit that arg."
-  (combine-and-quote-strings
-   (delq nil
-	 (list (when host (concat "-h" host))
-	       (when user (concat "-U" user))
-	       (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)))
-         (dbport (cdr (assq :dbport 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"
-				  (or cmdline "")
-				  (org-babel-process-file-name in-file)
-				  "/^+/d;s/^\|//;s/(NULL)/ /g;$d"
-				  (org-babel-process-file-name out-file)))
-                    ('monetdb (format "mclient -f tab %s < %s > %s"
-                                      (or cmdline "")
-                                      (org-babel-process-file-name in-file)
-                                      (org-babel-process-file-name out-file)))
-                    ('msosql (format "osql %s -s \"\t\" -i %s -o %s"
-                                     (or cmdline "")
-                                     (org-babel-process-file-name in-file)
-                                     (org-babel-process-file-name out-file)))
-                    ('mysql (format "mysql %s %s %s < %s > %s"
-				    (org-babel-sql-dbstring-mysql
-				     dbhost dbport dbuser dbpassword database)
-				    (if colnames-p "" "-N")
-                                    (or cmdline "")
-				    (org-babel-process-file-name in-file)
-				    (org-babel-process-file-name out-file)))
-		    ('postgresql (format
-				  "psql --set=\"ON_ERROR_STOP=1\" %s -A -P footer=off -F \"\t\"  %s -f %s -o %s %s"
-				  (if colnames-p "" "-t")
-				  (org-babel-sql-dbstring-postgresql dbhost dbuser database)
-				  (org-babel-process-file-name in-file)
-				  (org-babel-process-file-name out-file)
-				  (or cmdline "")))
-                    (t (error "No support for the %s SQL engine" engine)))))
-    (with-temp-file in-file
-      (insert
-       (case (intern engine)
-	 ('dbi "/format partbox\n")
-	 (t ""))
-       (org-babel-expand-body:sql body params)))
-    (message command)
-    (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
-	(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)
-		   (if (string= (car x) header-delim)
-		       'hline
-		     x))
-		 (org-table-to-lisp))
-	 (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-sql-expand-vars (body vars)
-  "Expand the variables held in VARS in BODY."
-  (mapc
-   (lambda (pair)
-     (setq body
-	   (replace-regexp-in-string
-	    (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)
-
-(defun org-babel-prep-session:sql (session params)
-  "Raise an error because Sql sessions aren't implemented."
-  (error "SQL sessions not yet implemented"))
-
-(provide 'ob-sql)
-
-
-
-;;; ob-sql.el ends here
diff --git a/elpa/org-plus-contrib-20150831/org-bullets.el b/elpa/org-plus-contrib-20150831/org-bullets.el
deleted file mode 100644
index 2951bf8a..00000000
--- a/elpa/org-plus-contrib-20150831/org-bullets.el
+++ /dev/null
@@ -1,122 +0,0 @@
-;;; org-bullets.el --- Show bullets in org-mode as UTF-8 characters
-;; Version: 0.2.2
-;; Author: sabof
-;; URL: https://github.com/sabof/org-bullets
-
-;; This file is NOT part of GNU Emacs.
-;;
-;; 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, 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 ; see the file COPYING.  If not, write to
-;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
-
-;;; Commentary:
-
-;; The project is hosted at https://github.com/sabof/org-bullets
-;; The latest version, and all the relevant information can be found there.
-
-;;; Code:
-
-(eval-when-compile (require 'cl))
-
-(defgroup org-bullets nil
-  "Display bullets as UTF-8 characters."
-  :group 'org-appearance)
-
-;; A nice collection of unicode bullets:
-;; http://nadeausoftware.com/articles/2007/11/latency_friendly_customized_bullets_using_unicode_characters
-(defcustom org-bullets-bullet-list
-  '(;;; Large
-    "◉"
-    "○"
-    "✸"
-    "✿"
-    ;; ♥ ● ◇ ✚ ✜ ☯ ◆ ♠ ♣ ♦ ☢ ❀ ◆ ◖ ▶
-    ;;; Small
-    ;; ► • ★ ▸
-    )
-  "This variable contains the list of bullets.
-It can contain any number of one-character strings.
-For levels beyond the size of the list, the stars will be
-displayed using the first items again."
-  :group 'org-bullets
-  :type '(repeat (string :tag "Bullet character")))
-
-(defcustom org-bullets-face-name nil
-  "Allows to override `org-mode' bullets face.
-If set to a name of a face, that face will be used.
-Otherwise the face of the heading level will be used."
-  :group 'org-bullets
-  :type 'symbol)
-
-(defvar org-bullets-bullet-map
-  '(keymap
-    (mouse-1 . org-cycle)
-    (mouse-2 . (lambda (e)
-		 (interactive "e")
-		 (mouse-set-point e)
-		 (org-cycle))))
-  "Mouse events for bullets.
-If this is undesirable, one can remove them with
-
-\(setcdr org-bullets-bullet-map nil\)")
-
-(defun org-bullets-level-char (level)
-  "Return a character corresponding to LEVEL."
-  (string-to-char
-   (nth (mod (1- level)
-             (length org-bullets-bullet-list))
-        org-bullets-bullet-list)))
-
-;;;###autoload
-(define-minor-mode org-bullets-mode
-  "UTF-8 bullets for `org-mode'."
-  nil nil nil
-  (let* ((keyword
-	  `((,org-outline-regexp-bol
-	     (0 (let (( level (- (match-end 0) (match-beginning 0) 1)))
-		  (compose-region (- (match-end 0) 2)
-				  (- (match-end 0) 1)
-				  (org-bullets-level-char level))
-		  (when (facep org-bullets-face-name)
-		    (put-text-property (- (match-end 0) 2)
-				       (- (match-end 0) 1)
-				       'face
-				       org-bullets-face-name))
-		  (put-text-property (match-beginning 0)
-				     (- (match-end 0) 2)
-				     'face (list :foreground
-						 (face-attribute
-						  'default :background)))
-		  (put-text-property (match-beginning 0)
-				     (match-end 0)
-				     'keymap
-				     org-bullets-bullet-map)
-		  nil))))))
-    (if org-bullets-mode
-        (progn (font-lock-add-keywords nil keyword)
-               (font-lock-fontify-buffer))
-      (save-excursion
-	(goto-char (point-min))
-	(font-lock-remove-keywords nil keyword)
-	(while (re-search-forward org-outline-regexp-bol nil t)
-	  (decompose-region (match-beginning 0) (match-end 0)))
-	(font-lock-fontify-buffer)))))
-
-(provide 'org-bullets)
-
-;; Local Variables:
-;; coding: utf-8-emacs
-;; End:
-
-;;; org-bullets.el ends here
diff --git a/elpa/org-plus-contrib-20150831/org-colview.el b/elpa/org-plus-contrib-20150831/org-colview.el
deleted file mode 100644
index 3838531a..00000000
--- a/elpa/org-plus-contrib-20150831/org-colview.el
+++ /dev/null
@@ -1,1610 +0,0 @@
-;;; org-colview.el --- Column View in Org-mode
-
-;; Copyright (C) 2004-2015 Free Software Foundation, Inc.
-
-;; Author: Carsten Dominik 
-;; 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 .
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;
-;;; Commentary:
-
-;; This file contains the column view for Org.
-
-;;; Code:
-
-(eval-when-compile (require 'cl))
-(require 'org)
-
-(declare-function org-agenda-redo "org-agenda" ())
-(declare-function org-agenda-do-context-action "org-agenda" ())
-(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' from the contrib/ directory"))
-
-;;; Column View
-
-(defvar org-columns-overlays nil
-  "Holds the list of current column overlays.")
-
-(defvar org-columns-current-fmt nil
-  "Local variable, holds the currently active column format.")
-(make-variable-buffer-local 'org-columns-current-fmt)
-(defvar org-columns-current-fmt-compiled nil
-  "Local variable, holds the currently active column format.
-This is the compiled version of the format.")
-(make-variable-buffer-local 'org-columns-current-fmt-compiled)
-(defvar org-columns-current-widths nil
-  "Loval variable, holds the currently widths of fields.")
-(make-variable-buffer-local 'org-columns-current-widths)
-(defvar org-columns-current-maxwidths nil
-  "Loval variable, holds the currently active maximum column widths.")
-(make-variable-buffer-local 'org-columns-current-maxwidths)
-(defvar org-columns-begin-marker (make-marker)
-  "Points to the position where last a column creation command was called.")
-(defvar org-columns-top-level-marker (make-marker)
-  "Points to the position where current columns region starts.")
-
-(defvar org-columns-map (make-sparse-keymap)
-  "The keymap valid in column display.")
-
-(defun org-columns-content ()
-  "Switch to contents view while in columns view."
-  (interactive)
-  (org-overview)
-  (org-content))
-
-(org-defkey org-columns-map "c" 'org-columns-content)
-(org-defkey org-columns-map "o" 'org-overview)
-(org-defkey org-columns-map "e" 'org-columns-edit-value)
-(org-defkey org-columns-map "\C-c\C-t" 'org-columns-todo)
-(org-defkey org-columns-map "\C-c\C-c" 'org-columns-set-tags-or-toggle)
-(org-defkey org-columns-map "\C-c\C-o" 'org-columns-open-link)
-(org-defkey org-columns-map "v" 'org-columns-show-value)
-(org-defkey org-columns-map "q" 'org-columns-quit)
-(org-defkey org-columns-map "r" 'org-columns-redo)
-(org-defkey org-columns-map "g" 'org-columns-redo)
-(org-defkey org-columns-map [left] 'backward-char)
-(org-defkey org-columns-map "\M-b" 'backward-char)
-(org-defkey org-columns-map "a" 'org-columns-edit-allowed)
-(org-defkey org-columns-map "s" 'org-columns-edit-attributes)
-(org-defkey org-columns-map "\M-f"
-	    (lambda () (interactive) (goto-char (1+ (point)))))
-(org-defkey org-columns-map [right]
-	    (lambda () (interactive) (goto-char (1+ (point)))))
-(org-defkey org-columns-map [down]
-	    (lambda () (interactive)
-	      (let ((col (current-column)))
-		(beginning-of-line 2)
-		(while (and (org-invisible-p2) (not (eobp)))
-		  (beginning-of-line 2))
-		(move-to-column col)
-		(if (eq major-mode 'org-agenda-mode)
-		    (org-agenda-do-context-action)))))
-(org-defkey org-columns-map [up]
-	    (lambda () (interactive)
-	      (let ((col (current-column)))
-		(beginning-of-line 0)
-		(while (and (org-invisible-p2) (not (bobp)))
-		  (beginning-of-line 0))
-		(move-to-column col)
-		(if (eq major-mode 'org-agenda-mode)
-		    (org-agenda-do-context-action)))))
-(org-defkey org-columns-map [(shift right)] 'org-columns-next-allowed-value)
-(org-defkey org-columns-map "n" 'org-columns-next-allowed-value)
-(org-defkey org-columns-map [(shift left)] 'org-columns-previous-allowed-value)
-(org-defkey org-columns-map "p" 'org-columns-previous-allowed-value)
-(org-defkey org-columns-map "<" 'org-columns-narrow)
-(org-defkey org-columns-map ">" 'org-columns-widen)
-(org-defkey org-columns-map [(meta right)] 'org-columns-move-right)
-(org-defkey org-columns-map [(meta left)] 'org-columns-move-left)
-(org-defkey org-columns-map [(shift meta right)] 'org-columns-new)
-(org-defkey org-columns-map [(shift meta left)] 'org-columns-delete)
-(dotimes (i 10)
-  (org-defkey org-columns-map (number-to-string i)
-	      `(lambda () (interactive)
-		 (org-columns-next-allowed-value nil ,i))))
-
-(easy-menu-define org-columns-menu org-columns-map "Org Column Menu"
-  '("Column"
-    ["Edit property" org-columns-edit-value t]
-    ["Next allowed value" org-columns-next-allowed-value t]
-    ["Previous allowed value" org-columns-previous-allowed-value t]
-    ["Show full value" org-columns-show-value t]
-    ["Edit allowed values" org-columns-edit-allowed t]
-    "--"
-    ["Edit column attributes" org-columns-edit-attributes t]
-    ["Increase column width" org-columns-widen t]
-    ["Decrease column width" org-columns-narrow t]
-    "--"
-    ["Move column right" org-columns-move-right t]
-    ["Move column left" org-columns-move-left t]
-    ["Add column" org-columns-new t]
-    ["Delete column" org-columns-delete t]
-    "--"
-    ["CONTENTS" org-columns-content t]
-    ["OVERVIEW" org-overview t]
-    ["Refresh columns display" org-columns-redo t]
-    "--"
-    ["Open link" org-columns-open-link t]
-    "--"
-    ["Quit" org-columns-quit t]))
-
-(defun org-columns--value (property pos)
-  "Return value for PROPERTY at buffer position POS."
-  (or (cdr (assoc-string property (get-text-property pos 'org-summaries) t))
-      (org-entry-get pos property 'selective t)))
-
-(defun org-columns-new-overlay (beg end &optional string face)
-  "Create a new column overlay and add it to the list."
-  (let ((ov (make-overlay beg end)))
-    (overlay-put ov 'face (or face 'secondary-selection))
-    (org-overlay-display ov string face)
-    (push ov org-columns-overlays)
-    ov))
-
-(defun org-columns-display-here (&optional props dateline)
-  "Overlay the current line with column display."
-  (interactive)
-  (save-excursion
-    (beginning-of-line)
-    (let* ((level-face (and (looking-at "\\(\\**\\)\\(\\* \\)")
-			    (org-get-level-face 2)))
-	   (ref-face (or level-face
-			 (and (eq major-mode 'org-agenda-mode)
-			      (org-get-at-bol 'face))
-			 'default))
-	   (color (list :foreground (face-attribute ref-face :foreground)))
-	   (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))
-	   (pom (and (eq major-mode 'org-agenda-mode)
-		     (or (org-get-at-bol 'org-hd-marker)
-			 (org-get-at-bol 'org-marker))))
-	   (props (cond (props)
-			((eq major-mode 'org-agenda-mode)
-			 (and pom (org-entry-properties pom)))
-			(t (org-entry-properties)))))
-      ;; Each column is an overlay on top of a character.  So there has
-      ;; to be at least as many characters available on the line as
-      ;; columns to display.
-      (let ((columns (length org-columns-current-fmt-compiled))
-	    (chars (- (line-end-position) (line-beginning-position))))
-	(when (> columns chars)
-	  (save-excursion
-	    (end-of-line)
-	    (let ((inhibit-read-only t))
-	      (insert (make-string (- columns chars) ?\s))))))
-      ;; Walk the format.  Create and install the overlay for the
-      ;; current column on the next character.
-      (dolist (column org-columns-current-fmt-compiled)
-	(let* ((property (car column))
-	       (title (nth 1 column))
-	       (ass (assoc-string property props t))
-	       (width
-		(or
-		 (cdr (assoc-string property org-columns-current-maxwidths t))
-		 (nth 2 column)
-		 (length property)))
-	       (f (format "%%-%d.%ds | " width width))
-	       (fm (nth 4 column))
-	       (fc (nth 5 column))
-	       (calc (nth 7 column))
-	       (val (or (cdr ass) ""))
-	       (modval
-		(cond
-		 ((functionp org-columns-modify-value-for-display-function)
-		  (funcall org-columns-modify-value-for-display-function
-			   title val))
-		 ((equal property "ITEM") (org-columns-compact-links val))
-		 (fc (org-columns-number-to-string
-		      (org-columns-string-to-number val fm) fm fc))
-		 ((and calc (functionp calc)
-		       (not (string= val ""))
-		       (not (get-text-property 0 'org-computed val)))
-		  (org-columns-number-to-string
-		   (funcall calc (org-columns-string-to-number val fm)) fm))))
-	       (string
-		(format f
-			(let ((v (org-columns-add-ellipses
-				  (or modval val) width)))
-			  (cond
-			   ((equal property "PRIORITY")
-			    (propertize v 'face (org-get-priority-face val)))
-			   ((equal property "TAGS")
-			    (if (not org-tags-special-faces-re)
-				(propertize v 'face 'org-tag)
-			      (replace-regexp-in-string
-			       org-tags-special-faces-re
-			       (lambda (m)
-				 (propertize m 'face (org-get-tag-face m)))
-			       v nil nil 1)))
-			   ((equal property "TODO")
-			    (propertize v 'face (org-get-todo-face val)))
-			   (t v)))))
-	       (ov (org-columns-new-overlay
-		    (point) (1+ (point)) string (if dateline face1 face))))
-	  (overlay-put ov 'keymap org-columns-map)
-	  (overlay-put ov 'org-columns-key property)
-	  (overlay-put ov 'org-columns-value (cdr ass))
-	  (overlay-put ov 'org-columns-value-modified modval)
-	  (overlay-put ov 'org-columns-pom pom)
-	  (overlay-put ov 'org-columns-format f)
-	  (overlay-put ov 'line-prefix "")
-	  (overlay-put ov 'wrap-prefix "")
-	  (forward-char)))
-      ;; Make the rest of the line disappear.
-      (let ((ov (org-columns-new-overlay (point) (line-end-position))))
-	(overlay-put ov 'invisible t)
-	(overlay-put ov 'keymap org-columns-map)
-	(overlay-put ov 'line-prefix "")
-	(overlay-put ov 'wrap-prefix ""))
-      (let ((ov (make-overlay (1- (line-end-position))
-			      (line-beginning-position 2))))
-	(overlay-put ov 'keymap org-columns-map)
-	(push ov org-columns-overlays))
-      (org-with-silent-modifications
-       (let ((inhibit-read-only t))
-	 (put-text-property
-	  (line-end-position 0)
-	  (line-beginning-position 2)
-	  'read-only
-	  (substitute-command-keys
-	   "Type \\\\[org-columns-edit-value] \
-to edit property")))))))
-
-(defun org-columns-add-ellipses (string width)
-  "Truncate STRING with WIDTH characters, with ellipses."
-  (cond
-   ((<= (length string) width) string)
-   ((<= width (length org-columns-ellipses))
-    (substring org-columns-ellipses 0 width))
-   (t (concat (substring string 0 (- width (length org-columns-ellipses)))
-	      org-columns-ellipses))))
-
-(defvar org-columns-full-header-line-format nil
-  "The full header line format, will be shifted by horizontal scrolling." )
-(defvar org-previous-header-line-format nil
-  "The header line format before column view was turned on.")
-(defvar org-columns-inhibit-recalculation nil
-  "Inhibit recomputing of columns on column view startup.")
-(defvar org-columns-flyspell-was-active nil
-  "Remember the state of `flyspell-mode' before column view.
-Flyspell-mode can cause problems in columns view, so it is turned off
-for the duration of the command.")
-
-(defvar header-line-format)
-(defvar org-columns-previous-hscroll 0)
-
-(defun org-columns-display-here-title ()
-  "Overlay the newline before the current line with the table title."
-  (interactive)
-  (let ((fmt org-columns-current-fmt-compiled)
-	string (title "")
-	property width f column str widths)
-    (while (setq column (pop fmt))
-      (setq property (car column)
-	    str (or (nth 1 column) property)
-	    width (or (cdr (assoc-string property
-					 org-columns-current-maxwidths
-					 t))
-		      (nth 2 column)
-		      (length str))
-	    widths (push width widths)
-	    f (format "%%-%d.%ds | " width width)
-	    string (format f str)
-	    title (concat title string)))
-    (setq title (concat
-		 (org-add-props " " nil 'display '(space :align-to 0))
-		 ;;(org-add-props title nil 'face '(:weight bold :underline t :inherit default))))
-		 (org-add-props title nil 'face 'org-column-title)))
-    (org-set-local 'org-previous-header-line-format header-line-format)
-    (org-set-local 'org-columns-current-widths (nreverse widths))
-    (setq org-columns-full-header-line-format title)
-    (setq org-columns-previous-hscroll -1)
-					;    (org-columns-hscoll-title)
-    (org-add-hook 'post-command-hook 'org-columns-hscoll-title nil 'local)))
-
-(defun org-columns-hscoll-title ()
-  "Set the `header-line-format' so that it scrolls along with the table."
-  (sit-for .0001) ; need to force a redisplay to update window-hscroll
-  (when (not (= (window-hscroll) org-columns-previous-hscroll))
-    (setq header-line-format
-	  (concat (substring org-columns-full-header-line-format 0 1)
-		  (substring org-columns-full-header-line-format
-			     (1+ (window-hscroll))))
-	  org-columns-previous-hscroll (window-hscroll))
-    (force-mode-line-update)))
-
-(defvar org-colview-initial-truncate-line-value nil
-  "Remember the value of `truncate-lines' across colview.")
-
-;;;###autoload
-(defun org-columns-remove-overlays ()
-  "Remove all currently active column overlays."
-  (interactive)
-  (when (marker-buffer org-columns-begin-marker)
-    (with-current-buffer (marker-buffer org-columns-begin-marker)
-      (when (local-variable-p 'org-previous-header-line-format)
-	(setq header-line-format org-previous-header-line-format)
-	(kill-local-variable 'org-previous-header-line-format)
-	(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-with-silent-modifications
-       (mapc 'delete-overlay org-columns-overlays)
-       (setq org-columns-overlays nil)
-       (let ((inhibit-read-only t))
-	 (remove-text-properties (point-min) (point-max) '(read-only t))))
-      (when org-columns-flyspell-was-active
-	(flyspell-mode 1))
-      (when (local-variable-p 'org-colview-initial-truncate-line-value)
-	(setq truncate-lines org-colview-initial-truncate-line-value)))))
-
-(defun org-columns-compact-links (s)
-  "Replace [[link][desc]] with [desc] or [link]."
-  (while (string-match org-bracket-link-regexp s)
-    (setq s (replace-match
-	     (concat "[" (match-string (if (match-end 3) 3 1) s) "]")
-	     t t s)))
-  s)
-
-(defun org-columns-show-value ()
-  "Show the full value of the property."
-  (interactive)
-  (let ((value (get-char-property (point) 'org-columns-value)))
-    (message "Value is: %s" (or value ""))))
-
-(defvar org-agenda-columns-active) ;; defined in org-agenda.el
-
-(defun org-columns-quit ()
-  "Remove the column overlays and in this way exit column editing."
-  (interactive)
-  (org-with-silent-modifications
-   (org-columns-remove-overlays)
-   (let ((inhibit-read-only t))
-     (remove-text-properties (point-min) (point-max) '(read-only t))))
-  (when (eq major-mode 'org-agenda-mode)
-    (setq org-agenda-columns-active nil)
-    (message
-     "Modification not yet reflected in Agenda buffer, use `r' to refresh")))
-
-(defun org-columns-check-computed ()
-  "Check if this column value is computed.
-If yes, throw an error indicating that changing it does not make sense."
-  (let ((val (get-char-property (point) 'org-columns-value)))
-    (when (and (stringp val)
-	       (get-char-property 0 'org-computed val))
-      (error "This value is computed from the entry's children"))))
-
-(defun org-columns-todo (&optional arg)
-  "Change the TODO state during column view."
-  (interactive "P")
-  (org-columns-edit-value "TODO"))
-
-(defun org-columns-set-tags-or-toggle (&optional arg)
-  "Toggle checkbox at point, or set tags for current headline."
-  (interactive "P")
-  (if (string-match "\\`\\[[ xX-]\\]\\'"
-		    (get-char-property (point) 'org-columns-value))
-      (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."
-  (interactive)
-  (org-columns-check-computed)
-  (let* ((col (current-column))
-	 (key (or key (get-char-property (point) 'org-columns-key)))
-	 (value (get-char-property (point) 'org-columns-value))
-	 (bol (point-at-bol)) (eol (point-at-eol))
-	 (pom (or (get-text-property bol 'org-hd-marker)
-		  (point)))	     ; keep despite of compiler waring
-	 (line-overlays
-	  (delq nil (mapcar (lambda (x)
-			      (and (eq (overlay-buffer x) (current-buffer))
-				   (>= (overlay-start x) bol)
-				   (<= (overlay-start x) eol)
-				   x))
-			    org-columns-overlays)))
-	 (org-columns-time (time-to-number-of-days (current-time)))
-	 nval eval allowed)
-    (cond
-     ((equal key "CLOCKSUM")
-      (error "This special column cannot be edited"))
-     ((equal key "ITEM")
-      (setq eval '(org-with-point-at pom
-		    (org-edit-headline))))
-     ((equal key "TODO")
-      (setq eval '(org-with-point-at
-		      pom
-		    (call-interactively 'org-todo))))
-     ((equal key "PRIORITY")
-      (setq eval '(org-with-point-at pom
-		    (call-interactively 'org-priority))))
-     ((equal key "TAGS")
-      (setq eval '(org-with-point-at pom
-		    (let ((org-fast-tag-selection-single-key
-			   (if (eq org-fast-tag-selection-single-key 'expert)
-			       t org-fast-tag-selection-single-key)))
-		      (call-interactively 'org-set-tags)))))
-     ((equal key "DEADLINE")
-      (setq eval '(org-with-point-at pom
-		    (call-interactively 'org-deadline))))
-     ((equal key "SCHEDULED")
-      (setq eval '(org-with-point-at pom
-		    (call-interactively 'org-schedule))))
-     ((equal key "BEAMER_env")
-      (setq eval '(org-with-point-at pom
-		    (call-interactively 'org-beamer-select-environment))))
-     (t
-      (setq allowed (org-property-get-allowed-values pom key 'table))
-      (if allowed
-	  (setq nval (org-icompleting-read
-		      "Value: " allowed nil
-		      (not (get-text-property 0 'org-unrestricted
-					      (caar allowed)))))
-	(setq nval (read-string "Edit: " value)))
-      (setq nval (org-trim nval))
-      (when (not (equal nval value))
-	(setq eval '(org-entry-put pom key nval)))))
-    (when eval
-
-      (cond
-       ((equal major-mode 'org-agenda-mode)
-	(org-columns-eval eval)
-	;; The following let preserves the current format, and makes sure
-	;; that in only a single file things need to be updated.
-	(let* ((org-agenda-overriding-columns-format org-columns-current-fmt)
-	       (buffer (marker-buffer pom))
-	       (org-agenda-contributing-files
-		(list (with-current-buffer buffer
-			(buffer-file-name (buffer-base-buffer))))))
-	  (org-agenda-columns)))
-       (t
-	(let ((inhibit-read-only t))
-	  (org-with-silent-modifications
-	   (remove-text-properties
-	    (max (point-min) (1- bol)) eol '(read-only t)))
-	  (unwind-protect
-	      (progn
-		(setq org-columns-overlays
-		      (org-delete-all line-overlays org-columns-overlays))
-		(mapc 'delete-overlay line-overlays)
-		(org-columns-eval eval))
-	    (org-columns-display-here)))
-	(org-move-to-column col)
-	(if (and (derived-mode-p 'org-mode)
-		 (nth 3 (assoc-string key org-columns-current-fmt-compiled t)))
-	    (org-columns-update key)))))))
-
-(defun org-edit-headline () ; FIXME: this is not columns specific.  Make interactive?????  Use from agenda????
-  "Edit the current headline, the part without TODO keyword, TAGS."
-  (org-back-to-heading)
-  (when (looking-at org-todo-line-regexp)
-    (let ((pos (point))
-	  (pre (buffer-substring (match-beginning 0) (match-beginning 3)))
-	  (txt (match-string 3))
-	  (post "")
-	  txt2)
-      (if (string-match (org-re "[ \t]+:[[:alnum:]:_@#%]+:[ \t]*$") txt)
-	  (setq post (match-string 0 txt)
-		txt (substring txt 0 (match-beginning 0))))
-      (setq txt2 (read-string "Edit: " txt))
-      (when (not (equal txt txt2))
-	(goto-char pos)
-	(insert pre txt2 post)
-	(delete-region (point) (point-at-eol))
-	(org-set-tags nil t)))))
-
-(defun org-columns-edit-allowed ()
-  "Edit the list of allowed values for the current property."
-  (interactive)
-  (let* ((pom (or (org-get-at-bol 'org-marker)
-		  (org-get-at-bol 'org-hd-marker)
-		  (point)))
-	 (key (get-char-property (point) 'org-columns-key))
-	 (key1 (concat key "_ALL"))
-	 (allowed (org-entry-get pom key1 t))
-	 nval)
-    ;; FIXME: Cover editing TODO, TAGS etc in-buffer settings.????
-    ;; FIXME: Write back to #+PROPERTY setting if that is needed.
-    (setq nval (read-string "Allowed: " allowed))
-    (org-entry-put
-     (cond ((marker-position org-entry-property-inherited-from)
-	    org-entry-property-inherited-from)
-	   ((marker-position org-columns-top-level-marker)
-	    org-columns-top-level-marker)
-	   (t pom))
-     key1 nval)))
-
-(defun org-columns-eval (form)
-  (let (hidep)
-    (save-excursion
-      (beginning-of-line 1)
-      ;; `next-line' is needed here, because it skips invisible line.
-      (condition-case nil (org-no-warnings (next-line 1)) (error nil))
-      (setq hidep (org-at-heading-p 1)))
-    (eval form)
-    (and hidep (hide-entry))))
-
-(defun org-columns-previous-allowed-value ()
-  "Switch to the previous allowed value for this column."
-  (interactive)
-  (org-columns-next-allowed-value t))
-
-(defun org-columns-next-allowed-value (&optional previous nth)
-  "Switch to the next allowed value for this column.
-When PREVIOUS is set, go to the previous value.  When NTH is
-an integer, select that value."
-  (interactive)
-  (org-columns-check-computed)
-  (let* ((col (current-column))
-	 (key (get-char-property (point) 'org-columns-key))
-	 (value (get-char-property (point) 'org-columns-value))
-	 (bol (point-at-bol)) (eol (point-at-eol))
-	 (pom (or (get-text-property bol 'org-hd-marker)
-		  (point)))	     ; keep despite of compiler waring
-	 (line-overlays
-	  (delq nil (mapcar (lambda (x)
-			      (and (eq (overlay-buffer x) (current-buffer))
-				   (>= (overlay-start x) bol)
-				   (<= (overlay-start x) eol)
-				   x))
-			    org-columns-overlays)))
-	 (allowed (or (org-property-get-allowed-values pom key)
-		      (and (memq
-			    (nth 4 (assoc-string key
-						 org-columns-current-fmt-compiled
-						 t))
-			    '(checkbox checkbox-n-of-m checkbox-percent))
-			   '("[ ]" "[X]"))
-		      (org-colview-construct-allowed-dates value)))
-	 nval)
-    (when (integerp nth)
-      (setq nth (1- nth))
-      (if (= nth -1) (setq nth 9)))
-    (when (equal key "ITEM")
-      (error "Cannot edit item headline from here"))
-    (unless (or allowed (member key '("SCHEDULED" "DEADLINE" "CLOCKSUM")))
-      (error "Allowed values for this property have not been defined"))
-    (if (member key '("SCHEDULED" "DEADLINE" "CLOCKSUM"))
-	(setq nval (if previous 'earlier 'later))
-      (if previous (setq allowed (reverse allowed)))
-      (cond
-       (nth
-	(setq nval (nth nth allowed))
-	(if (not nval)
-	    (error "There are only %d allowed values for property `%s'"
-		   (length allowed) key)))
-       ((member value allowed)
-	(setq nval (or (car (cdr (member value allowed)))
-		       (car allowed)))
-	(if (equal nval value)
-	    (error "Only one allowed value for this property")))
-       (t (setq nval (car allowed)))))
-    (cond
-     ((equal major-mode 'org-agenda-mode)
-      (org-columns-eval '(org-entry-put pom key nval))
-      ;; The following let preserves the current format, and makes sure
-      ;; that in only a single file things need to be updated.
-      (let* ((org-agenda-overriding-columns-format org-columns-current-fmt)
-	     (buffer (marker-buffer pom))
-	     (org-agenda-contributing-files
-	      (list (with-current-buffer buffer
-		      (buffer-file-name (buffer-base-buffer))))))
-	(org-agenda-columns)))
-     (t
-      (let ((inhibit-read-only t))
-	(remove-text-properties (1- bol) eol '(read-only t))
-	(unwind-protect
-	    (progn
-	      (setq org-columns-overlays
-		    (org-delete-all line-overlays org-columns-overlays))
-	      (mapc 'delete-overlay line-overlays)
-	      (org-columns-eval '(org-entry-put pom key nval)))
-	  (org-columns-display-here)))
-      (org-move-to-column col)
-      (and (nth 3 (assoc-string key org-columns-current-fmt-compiled t))
-	   (org-columns-update key))))))
-
-(defun org-colview-construct-allowed-dates (s)
-  "Construct a list of three dates around the date in S.
-This respects the format of the time stamp in S, active or non-active,
-and also including time or not.  S must be just a time stamp, no text
-around it."
-  (when (and s (string-match (concat "^" org-ts-regexp3 "$") s))
-    (let* ((time (org-parse-time-string s 'nodefaults))
-	   (active (equal (string-to-char s) ?<))
-	   (fmt (funcall (if (nth 1 time) 'cdr 'car) org-time-stamp-formats))
-	   time-before time-after)
-      (unless active (setq fmt (concat "[" (substring fmt 1 -1) "]")))
-      (setf (car time) (or (car time) 0))
-      (setf (nth 1 time) (or (nth 1 time) 0))
-      (setf (nth 2 time) (or (nth 2 time) 0))
-      (setq time-before (copy-sequence time))
-      (setq time-after (copy-sequence time))
-      (setf (nth 3 time-before) (1- (nth 3 time)))
-      (setf (nth 3 time-after) (1+ (nth 3 time)))
-      (mapcar (lambda (x) (format-time-string fmt (apply 'encode-time x)))
-	      (list time-before time time-after)))))
-
-(defun org-verify-version (task)
-  (cond
-   ((eq task 'columns)
-    (if (or (featurep 'xemacs)
-	    (< emacs-major-version 22))
-	(error "Emacs 22 is required for the columns feature")))))
-
-(defun org-columns-open-link (&optional arg)
-  (interactive "P")
-  (let ((value (get-char-property (point) 'org-columns-value)))
-    (org-open-link-from-string value arg)))
-
-;;;###autoload
-(defun org-columns-get-format-and-top-level ()
-  (let ((fmt (org-columns-get-format)))
-    (org-columns-goto-top-level)
-    fmt))
-
-(defun org-columns-get-format (&optional fmt-string)
-  (interactive)
-  (let (fmt-as-property fmt)
-    (when (condition-case nil (org-back-to-heading) (error nil))
-      (setq fmt-as-property (org-entry-get nil "COLUMNS" t)))
-    (setq fmt (or fmt-string fmt-as-property org-columns-default-format))
-    (org-set-local 'org-columns-current-fmt fmt)
-    (org-columns-compile-format fmt)
-    fmt))
-
-(defun org-columns-goto-top-level ()
-  "Move to the beginning of the column view area.
-Also sets `org-columns-top-level-marker' to the new position."
-  (goto-char
-   (move-marker
-    org-columns-top-level-marker
-    (cond ((org-before-first-heading-p) (point-min))
-	  ((org-entry-get nil "COLUMNS" t) org-entry-property-inherited-from)
-	  (t (org-back-to-heading) (point))))))
-
-;;;###autoload
-(defun org-columns (&optional columns-fmt-string)
-  "Turn on column view on an org-mode file.
-When COLUMNS-FMT-STRING is non-nil, use it as the column format."
-  (interactive)
-  (org-verify-version 'columns)
-  (org-columns-remove-overlays)
-  (move-marker org-columns-begin-marker (point))
-  (org-columns-goto-top-level)
-  ;; Initialize `org-columns-current-fmt' and
-  ;; `org-columns-current-fmt-compiled'.
-  (let ((org-columns-time (time-to-number-of-days (current-time))))
-    (org-columns-get-format columns-fmt-string))
-  (unless org-columns-inhibit-recalculation (org-columns-compute-all))
-  (save-excursion
-    (save-restriction
-      (narrow-to-region
-       (point)
-       (if (org-at-heading-p) (org-end-of-subtree t t) (point-max)))
-      (when (assoc "CLOCKSUM" org-columns-current-fmt-compiled)
-	(org-clock-sum))
-      (when (assoc "CLOCKSUM_T" org-columns-current-fmt-compiled)
-	(org-clock-sum-today))
-      (let* ((column-names (mapcar #'car org-columns-current-fmt-compiled))
-	     (cache
-	      (org-map-entries
-	       (lambda ()
-		 (cons (point)
-		       (mapcar (lambda (p)
-				 (cons p (org-columns--value p (point))))
-			       column-names)))
-	       nil nil (and org-columns-skip-archived-trees 'archive))))
-	(when cache
-	  (org-set-local 'org-columns-current-maxwidths
-			 (org-columns-get-autowidth-alist
-			  org-columns-current-fmt
-			  cache))
-	  (org-columns-display-here-title)
-	  (when (org-set-local 'org-columns-flyspell-was-active
-			       (org-bound-and-true-p flyspell-mode))
-	    (flyspell-mode 0))
-	  (unless (local-variable-p 'org-colview-initial-truncate-line-value)
-	    (org-set-local 'org-colview-initial-truncate-line-value
-			   truncate-lines))
-	  (setq truncate-lines t)
-	  (dolist (x cache)
-	    (goto-char (car x))
-	    (org-columns-display-here (cdr x))))))))
-
-(eval-when-compile (defvar org-columns-time))
-
-(defvar org-columns-compile-map
-  '(("none" none +)
-    (":" add_times +)
-    ("+" add_numbers +)
-    ("$" currency +)
-    ("X" checkbox +)
-    ("X/" checkbox-n-of-m +)
-    ("X%" checkbox-percent +)
-    ("max" max_numbers max)
-    ("min" min_numbers min)
-    ("mean" mean_numbers
-     (lambda (&rest x) (/ (apply '+ x) (float (length x)))))
-    (":max" max_times max)
-    (":min" min_times min)
-    (":mean" mean_times
-     (lambda (&rest x) (/ (apply '+ x) (float (length x)))))
-    ("@min" min_age min (lambda (x) (- org-columns-time x)))
-    ("@max" max_age max (lambda (x) (- org-columns-time x)))
-    ("@mean" mean_age
-     (lambda (&rest x) (/ (apply '+ x) (float (length x))))
-     (lambda (x) (- org-columns-time x)))
-    ("est+" estimate org-estimate-combine))
-  "Operator <-> format,function,calc  map.
-Used to compile/uncompile columns format and completing read in
-interactive function `org-columns-new'.
-
-operator    string used in #+COLUMNS definition describing the
-	    summary type
-format      symbol describing summary type selected interactively in
-	    `org-columns-new' and internally in
-	    `org-columns-number-to-string' and
-	    `org-columns-string-to-number'
-function    called with a list of values as argument to calculate
-	    the summary value
-calc        function called on every element before summarizing.  This is
-	    optional and should only be specified if needed")
-
-(defun org-columns-new (&optional prop title width op fmt fun &rest rest)
-  "Insert a new column, to the left of the current column."
-  (interactive)
-  (let ((editp (and prop
-		    (assoc-string prop org-columns-current-fmt-compiled t)))
-	cell)
-    (setq prop (org-icompleting-read
-		"Property: " (mapcar 'list (org-buffer-property-keys t nil t))
-		nil nil prop))
-    (setq title (read-string (concat "Column title [" prop "]: ") (or title prop)))
-    (setq width (read-string "Column width: " (if width (number-to-string width))))
-    (if (string-match "\\S-" width)
-	(setq width (string-to-number width))
-      (setq width nil))
-    (setq fmt (org-icompleting-read
-	       "Summary [none]: "
-	       (mapcar (lambda (x) (list (symbol-name (cadr x))))
-		       org-columns-compile-map)
-	       nil t))
-    (setq fmt (intern fmt)
-	  fun (cdr (assoc fmt (mapcar 'cdr org-columns-compile-map))))
-    (if (eq fmt 'none) (setq fmt nil))
-    (if editp
-	(progn
-	  (setcar editp prop)
-	  (setcdr editp (list title width nil fmt nil fun)))
-      (setq cell (nthcdr (1- (current-column))
-			 org-columns-current-fmt-compiled))
-      (setcdr cell (cons (list prop title width nil fmt nil
-			       (car fun) (cadr fun))
-			 (cdr cell))))
-    (org-columns-store-format)
-    (org-columns-redo)))
-
-(defun org-columns-delete ()
-  "Delete the column at point from columns view."
-  (interactive)
-  (let* ((n (current-column))
-	 (title (nth 1 (nth n org-columns-current-fmt-compiled))))
-    (when (y-or-n-p
-	   (format "Are you sure you want to remove column \"%s\"? " title))
-      (setq org-columns-current-fmt-compiled
-	    (delq (nth n org-columns-current-fmt-compiled)
-		  org-columns-current-fmt-compiled))
-      (org-columns-store-format)
-      (org-columns-redo)
-      (if (>= (current-column) (length org-columns-current-fmt-compiled))
-	  (backward-char 1)))))
-
-(defun org-columns-edit-attributes ()
-  "Edit the attributes of the current column."
-  (interactive)
-  (let* ((n (current-column))
-	 (info (nth n org-columns-current-fmt-compiled)))
-    (apply 'org-columns-new info)))
-
-(defun org-columns-widen (arg)
-  "Make the column wider by ARG characters."
-  (interactive "p")
-  (let* ((n (current-column))
-	 (entry (nth n org-columns-current-fmt-compiled))
-	 (width (or (nth 2 entry)
-		    (cdr (assoc-string (car entry)
-				       org-columns-current-maxwidths
-				       t)))))
-    (setq width (max 1 (+ width arg)))
-    (setcar (nthcdr 2 entry) width)
-    (org-columns-store-format)
-    (org-columns-redo)))
-
-(defun org-columns-narrow (arg)
-  "Make the column narrower by ARG characters."
-  (interactive "p")
-  (org-columns-widen (- arg)))
-
-(defun org-columns-move-right ()
-  "Swap this column with the one to the right."
-  (interactive)
-  (let* ((n (current-column))
-	 (cell (nthcdr n org-columns-current-fmt-compiled))
-	 e)
-    (when (>= n (1- (length org-columns-current-fmt-compiled)))
-      (error "Cannot shift this column further to the right"))
-    (setq e (car cell))
-    (setcar cell (car (cdr cell)))
-    (setcdr cell (cons e (cdr (cdr cell))))
-    (org-columns-store-format)
-    (org-columns-redo)
-    (forward-char 1)))
-
-(defun org-columns-move-left ()
-  "Swap this column with the one to the left."
-  (interactive)
-  (let* ((n (current-column)))
-    (when (= n 0)
-      (error "Cannot shift this column further to the left"))
-    (backward-char 1)
-    (org-columns-move-right)
-    (backward-char 1)))
-
-(defun org-columns-store-format ()
-  "Store the text version of the current columns format in appropriate place.
-This is either in the COLUMNS property of the node starting the current column
-display, or in the #+COLUMNS line of the current buffer."
-  (let (fmt (cnt 0))
-    (setq fmt (org-columns-uncompile-format org-columns-current-fmt-compiled))
-    (org-set-local 'org-columns-current-fmt fmt)
-    (if (marker-position org-columns-top-level-marker)
-	(save-excursion
-	  (goto-char org-columns-top-level-marker)
-	  (if (and (org-at-heading-p)
-		   (org-entry-get nil "COLUMNS"))
-	      (org-entry-put nil "COLUMNS" fmt)
-	    (goto-char (point-min))
-	    ;; Overwrite all #+COLUMNS lines....
-	    (while (re-search-forward "^[ \t]*#\\+COLUMNS:.*" nil t)
-	      (setq cnt (1+ cnt))
-	      (replace-match (concat "#+COLUMNS: " fmt) t t))
-	    (unless (> cnt 0)
-	      (goto-char (point-min))
-	      (or (org-at-heading-p t) (outline-next-heading))
-	      (let ((inhibit-read-only t))
-		(insert-before-markers "#+COLUMNS: " fmt "\n")))
-	    (org-set-local 'org-columns-default-format fmt))))))
-
-(defun org-columns-get-autowidth-alist (s cache)
-  "Derive the maximum column widths from the format and the cache."
-  (let ((start 0) rtn)
-    (while (string-match (org-re "%\\([[:alpha:]][[:alnum:]_-]*\\)") s start)
-      (push (cons (match-string 1 s) 1) rtn)
-      (setq start (match-end 0)))
-    (mapc (lambda (x)
-	    (setcdr x
-		    (apply #'max
-			   (let ((prop (car x)))
-			     (mapcar
-			      (lambda (y)
-				(length (or (cdr (assoc-string prop (cdr y) t))
-					    " ")))
-			      cache)))))
-	  rtn)
-    rtn))
-
-(defun org-columns-compute-all ()
-  "Compute all columns that have operators defined."
-  (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)))
-	col)
-    (while (setq col (pop columns))
-      (when (nth 3 col)
-	(save-excursion
-	  (org-columns-compute (car col)))))))
-
-(defun org-columns-update (property)
-  "Recompute PROPERTY, and update the columns display for it."
-  (org-columns-compute property)
-  (let (fmt val pos)
-    (save-excursion
-      (mapc (lambda (ov)
-	      (when (equal (overlay-get ov 'org-columns-key) property)
-		(setq pos (overlay-start ov))
-		(goto-char pos)
-		(when (setq val (cdr (assoc-string
-				      property
-				      (get-text-property
-				       (point-at-bol) 'org-summaries)
-				      t)))
-		  (setq fmt (overlay-get ov 'org-columns-format))
-		  (overlay-put ov 'org-columns-value val)
-		  (overlay-put ov 'display (format fmt val)))))
-	    org-columns-overlays))))
-
-(defvar org-inlinetask-min-level
-  (if (featurep 'org-inlinetask) org-inlinetask-min-level 15))
-
-;;;###autoload
-(defun org-columns-compute (property)
-  "Sum the values of property PROPERTY hierarchically, for the entire buffer."
-  (interactive)
-  (let* ((re org-outline-regexp-bol)
-	 (lmax 30)		    ; Does anyone use deeper levels???
-	 (lvals (make-vector lmax nil))
-	 (lflag (make-vector lmax nil))
-	 (level 0)
-	 (ass (assoc-string property org-columns-current-fmt-compiled t))
-	 (format (nth 4 ass))
-	 (printf (nth 5 ass))
-	 (fun (nth 6 ass))
-	 (calc (or (nth 7 ass) 'identity))
-	 (beg org-columns-top-level-marker)
-	 (inminlevel org-inlinetask-min-level)
-	 (last-level org-inlinetask-min-level)
-	 val valflag flag end sumpos sum-alist sum str str1 useval)
-    (save-excursion
-      ;; Find the region to compute
-      (goto-char beg)
-      (setq end (condition-case nil (org-end-of-subtree t) (error (point-max))))
-      (goto-char end)
-      ;; Walk the tree from the back and do the computations
-      (while (re-search-backward re beg t)
-	(setq sumpos (match-beginning 0)
-	      last-level (if (not (or (zerop level) (eq level inminlevel)))
-			     level last-level)
-	      level (org-outline-level)
-	      val (org-entry-get nil property)
-	      valflag (and val (string-match "\\S-" val)))
-	(cond
-	 ((< level last-level)
-	  ;; Put the sum of lower levels here as a property.  If
-	  ;; values are estimate, use an appropriate sum function.
-	  (setq sum (funcall
-		     (if (eq fun 'org-estimate-combine) #'org-estimate-combine
-		       #'+)
-		     (if (and (/= last-level inminlevel)
-			      (aref lvals last-level))
-			 (apply fun (aref lvals last-level)) 0)
-		     (if (aref lvals inminlevel)
-			 (apply fun (aref lvals inminlevel)) 0))
-		flag (or (aref lflag last-level) ; any valid entries from children?
-			 (aref lflag inminlevel)) ; or inline tasks?
-		str (org-columns-number-to-string sum format printf)
-		str1 (org-add-props (copy-sequence str) nil 'org-computed t 'face 'bold)
-		useval (if flag str1 (if valflag val ""))
-		sum-alist (get-text-property sumpos 'org-summaries))
-	  (let ((old (assoc-string property sum-alist t)))
-	    (if old (setcdr old useval)
-	      (push (cons property useval) sum-alist)
-	      (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))))
-	    (org-entry-put nil property (if flag str val)))
-	  ;; add current to current level accumulator
-	  (when (or flag valflag)
-	    (push (if flag
-		      sum
-		    (funcall calc (org-columns-string-to-number
-				   (if flag str val) format)))
-		  (aref lvals level))
-	    (aset lflag level t))
-	  ;; clear accumulators for deeper levels
-	  (loop for l from (1+ level) to (1- lmax) do
-		(aset lvals l nil)
-		(aset lflag l nil)))
-	 ((>= level last-level)
-	  ;; add what we have here to the accumulator for this level
-	  (when valflag
-	    (push (funcall calc (org-columns-string-to-number val format))
-		  (aref lvals level))
-	    (aset lflag level t)))
-	 (t (error "This should not happen")))))))
-
-(defun org-columns-redo ()
-  "Construct the column display again."
-  (interactive)
-  (message "Recomputing columns...")
-  (let ((line (org-current-line))
-	(col (current-column)))
-    (save-excursion
-      (if (marker-position org-columns-begin-marker)
-	  (goto-char org-columns-begin-marker))
-      (org-columns-remove-overlays)
-      (if (derived-mode-p 'org-mode)
-	  (call-interactively 'org-columns)
-	(org-agenda-redo)
-	(call-interactively 'org-agenda-columns)))
-    (org-goto-line line)
-    (move-to-column col))
-  (message "Recomputing columns...done"))
-
-(defun org-columns-not-in-agenda ()
-  (if (eq major-mode 'org-agenda-mode)
-      (error "This command is only allowed in Org-mode buffers")))
-
-(defun org-string-to-number (s)
-  "Convert string to number, and interpret hh:mm:ss."
-  (if (not (string-match ":" s))
-      (string-to-number s)
-    (let ((l (nreverse (org-split-string s ":"))) (sum 0.0))
-      (while l
-	(setq sum (+ (string-to-number (pop l)) (/ sum 60))))
-      sum)))
-
-;;;###autoload
-(defun org-columns-number-to-string (n fmt &optional printf)
-  "Convert a computed column number to a string value, according to FMT."
-  (cond
-   ((memq fmt '(estimate)) (org-estimate-print n printf))
-   ((not (numberp n)) "")
-   ((memq fmt '(add_times max_times min_times mean_times))
-    (org-hours-to-clocksum-string n))
-   ((eq fmt 'checkbox)
-    (cond ((= n (floor n)) "[X]")
-	  ((> n 1.) "[-]")
-	  (t "[ ]")))
-   ((memq fmt '(checkbox-n-of-m checkbox-percent))
-    (let* ((n1 (floor n)) (n2 (floor (+ .5 (* 1000000 (- n n1))))))
-      (org-nofm-to-completion n1 (+ n2 n1) (eq fmt 'checkbox-percent))))
-   (printf (format printf n))
-   ((eq fmt 'currency)
-    (format "%.2f" n))
-   ((memq fmt '(min_age max_age mean_age))
-    (org-format-time-period n))
-   (t (number-to-string n))))
-
-(defun org-nofm-to-completion (n m &optional percent)
-  (if (not percent)
-      (format "[%d/%d]" n m)
-    (format "[%d%%]" (round (* 100.0 n) m))))
-
-
-(defun org-columns-string-to-number (s fmt)
-  "Convert a column value to a number that can be used for column computing."
-  (if s
-      (cond
-       ((memq fmt '(min_age max_age mean_age))
-        (cond ((string= s "") org-columns-time)
-              ((string-match
-                "\\([0-9]+\\)d \\([0-9]+\\)h \\([0-9]+\\)m \\([0-9]+\\)s"
-                s)
-               (+ (* 60 (+ (* 60 (+ (* 24 (string-to-number (match-string 1 s)))
-                                    (string-to-number (match-string 2 s))))
-                           (string-to-number (match-string 3 s))))
-                  (string-to-number (match-string 4 s))))
-              (t (time-to-number-of-days (apply 'encode-time
-                                                (org-parse-time-string s t))))))
-       ((string-match ":" s)
-        (let ((l (nreverse (org-split-string s ":"))) (sum 0.0))
-          (while l
-            (setq sum (+ (string-to-number (pop l)) (/ sum 60))))
-          sum))
-       ((memq fmt '(checkbox checkbox-n-of-m checkbox-percent))
-        (if (equal s "[X]") 1. 0.000001))
-       ((memq fmt '(estimate)) (org-string-to-estimate s))
-       ((string-match (concat "\\([0-9.]+\\) *\\("
-			      (regexp-opt (mapcar 'car org-effort-durations))
-			      "\\)") s)
-	(setq s (concat "0:" (org-duration-string-to-minutes s t)))
-        (let ((l (nreverse (org-split-string s ":"))) (sum 0.0))
-          (while l
-            (setq sum (+ (string-to-number (pop l)) (/ sum 60))))
-          sum))
-       (t (string-to-number s)))))
-
-(defun org-columns-uncompile-format (cfmt)
-  "Turn the compiled columns format back into a string representation."
-  (let ((rtn "") e s prop title op op-match width fmt printf fun calc ee map)
-    (while (setq e (pop cfmt))
-      (setq prop (car e)
-	    title (nth 1 e)
-	    width (nth 2 e)
-	    op (nth 3 e)
-	    fmt (nth 4 e)
-	    printf (nth 5 e)
-	    fun (nth 6 e)
-	    calc (nth 7 e))
-      (setq map (copy-sequence org-columns-compile-map))
-      (while (setq ee (pop map))
-	(if (equal fmt (nth 1 ee))
-	    (setq op (car ee) map nil)))
-      (if (and op printf) (setq op (concat op ";" printf)))
-      (if (equal title prop) (setq title nil))
-      (setq s (concat "%" (if width (number-to-string width))
-		      prop
-		      (if title (concat "(" title ")"))
-		      (if op (concat "{" op "}"))))
-      (setq rtn (concat rtn " " s)))
-    (org-trim rtn)))
-
-(defun org-columns-compile-format (fmt)
-  "Turn a column format string FMT into an alist of specifications.
-
-The alist has one entry for each column in the format.  The elements of
-that list are:
-property     the property
-title        the title field for the columns
-width        the column width in characters, can be nil for automatic
-operator     the operator if any
-format       the output format for computed results, derived from operator
-printf       a printf format for computed values
-fun          the lisp function to compute summary values, derived from operator
-calc         function to get values from base elements
-
-This function updates `org-columns-current-fmt-compiled'."
-  (let ((start 0) width prop title op op-match f printf fun calc)
-    (setq org-columns-current-fmt-compiled nil)
-    (while (string-match
-	    (org-re "%\\([0-9]+\\)?\\([[:alnum:]_-]+\\)\\(?:(\\([^)]+\\))\\)?\\(?:{\\([^}]+\\)}\\)?\\s-*")
-	    fmt start)
-      (setq start (match-end 0)
-	    width (match-string 1 fmt)
-	    prop (match-string 2 fmt)
-	    title (or (match-string 3 fmt) prop)
-	    op (match-string 4 fmt)
-	    f nil
-	    printf nil
-	    fun '+
-	    calc nil)
-      (if width (setq width (string-to-number width)))
-      (when (and op (string-match ";" op))
-	(setq printf (substring op (match-end 0))
-	      op (substring op 0 (match-beginning 0))))
-      (when (setq op-match (assoc op org-columns-compile-map))
-	(setq f (cadr op-match)
-	      fun (caddr op-match)
-	      calc (cadddr op-match)))
-      (push (list prop title width op f printf fun calc)
-	    org-columns-current-fmt-compiled))
-    (setq org-columns-current-fmt-compiled
-	  (nreverse org-columns-current-fmt-compiled))))
-
-
-;;; Dynamic block for Column view
-
-(defvar org-heading-regexp) ; defined in org.el
-(defvar org-heading-keyword-regexp-format) ; defined in org.el
-(defun org-columns-capture-view (&optional maxlevel skip-empty-rows)
-  "Get the column view of the current buffer or subtree.
-The first optional argument MAXLEVEL sets the level limit.  A
-second optional argument SKIP-EMPTY-ROWS tells whether to skip
-empty rows, an empty row being one where all the column view
-specifiers except ITEM are empty.  This function returns a list
-containing the title row and all other rows.  Each row is a list
-of fields."
-  (save-excursion
-    (let* ((title (mapcar 'cadr org-columns-current-fmt-compiled))
-	   (re-archive (concat ".*:" org-archive-tag ":"))
-	   (n (length title)) row tbl)
-      (goto-char (point-min))
-      (while (re-search-forward org-heading-regexp nil t)
-	(catch 'next
-	  (when (and (or (null maxlevel)
-			 (>= maxlevel
-			     (if org-odd-levels-only
-				 (/ (1+ (length (match-string 1))) 2)
-			       (length (match-string 1)))))
-		     (get-char-property (match-beginning 0) 'org-columns-key))
-	    (when (or (org-in-commented-heading-p t)
-		      (save-excursion
-			(beginning-of-line)
-			(looking-at re-archive)))
-	      (org-end-of-subtree t)
-	      (throw 'next t))
-	    (setq row nil)
-	    (loop for i from 0 to (1- n) do
-		  (push
-		   (org-quote-vert
-		    (or (get-char-property (+ (match-beginning 0) i) 'org-columns-value-modified)
-			(get-char-property (+ (match-beginning 0) i) 'org-columns-value)
-			""))
-		   row))
-	    (setq row (nreverse row))
-	    (unless (and skip-empty-rows
-			 (eq 1 (length (delete "" (delete-dups (copy-sequence row))))))
-	      (push row tbl)))))
-      (append (list title 'hline) (nreverse tbl)))))
-
-;;;###autoload
-(defun org-dblock-write:columnview (params)
-  "Write the column view table.
-PARAMS is a property list of parameters:
-
-:width    enforce same column widths with  specifiers.
-:id       the :ID: property of the entry where the columns view
-	  should be built.  When the symbol `local', call locally.
-	  When `global' call column view with the cursor at the beginning
-	  of the buffer (usually this means that the whole buffer switches
-	  to column view).  When \"file:path/to/file.org\", invoke column
-	  view at the start of that file.  Otherwise, the ID is located
-	  using `org-id-find'.
-:hlines   When t, insert a hline before each item.  When a number, insert
-	  a hline before each level <= that number.
-:vlines   When t, make each column a colgroup to enforce vertical lines.
-:maxlevel When set to a number, don't capture headlines below this level.
-:skip-empty-rows
-	  When t, skip rows where all specifiers other than ITEM are empty.
-:format   When non-nil, specify the column view format to use."
-  (let ((pos (point-marker))
-	(hlines (plist-get params :hlines))
-	(vlines (plist-get params :vlines))
-	(maxlevel (plist-get params :maxlevel))
-	(content-lines (org-split-string (plist-get params :content) "\n"))
-	(skip-empty-rows (plist-get params :skip-empty-rows))
-	(columns-fmt (plist-get params :format))
-	(case-fold-search t)
-	tbl id idpos nfields tmp recalc line
-	id-as-string view-file view-pos)
-    (when (setq id (plist-get params :id))
-      (setq id-as-string (cond ((numberp id) (number-to-string id))
-			       ((symbolp id) (symbol-name id))
-			       ((stringp id) id)
-			       (t "")))
-      (cond ((not id) nil)
-	    ((eq id 'global) (setq view-pos (point-min)))
-	    ((eq id 'local))
-	    ((string-match "^file:\\(.*\\)" id-as-string)
-	     (setq view-file (match-string 1 id-as-string)
-		   view-pos 1)
-	     (unless (file-exists-p view-file)
-	       (error "No such file: \"%s\"" id-as-string)))
-	    ((setq idpos (org-find-entry-with-id id))
-	     (setq view-pos idpos))
-	    ((setq idpos (org-id-find id))
-	     (setq view-file (car idpos))
-	     (setq view-pos (cdr idpos)))
-	    (t (error "Cannot find entry with :ID: %s" id))))
-    (with-current-buffer (if view-file
-			     (get-file-buffer view-file)
-			   (current-buffer))
-      (save-excursion
-	(save-restriction
-	  (widen)
-	  (goto-char (or view-pos (point)))
-	  (org-columns columns-fmt)
-	  (setq tbl (org-columns-capture-view maxlevel skip-empty-rows))
-	  (setq nfields (length (car tbl)))
-	  (org-columns-quit))))
-    (goto-char pos)
-    (move-marker pos nil)
-    (when tbl
-      (when (plist-get params :hlines)
-	(setq tmp nil)
-	(while tbl
-	  (if (eq (car tbl) 'hline)
-	      (push (pop tbl) tmp)
-	    (if (string-match "\\` *\\(\\*+\\)" (caar tbl))
-		(if (and (not (eq (car tmp) 'hline))
-			 (or (eq hlines t)
-			     (and (numberp hlines)
-				  (<= (- (match-end 1) (match-beginning 1))
-				      hlines))))
-		    (push 'hline tmp)))
-	    (push (pop tbl) tmp)))
-	(setq tbl (nreverse tmp)))
-      (when vlines
-	(setq tbl (mapcar (lambda (x)
-			    (if (eq 'hline x) x (cons "" x)))
-			  tbl))
-	(setq tbl (append tbl (list (cons "/" (make-list nfields "<>"))))))
-      (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)))
-				 org-columns-current-widths "|")))
-      (while (setq line (pop content-lines))
-	(when (string-match "^#" line)
-	  (insert "\n" line)
-	  (when (string-match "^[ \t]*#\\+tblfm" line)
-	    (setq recalc t))))
-      (if recalc
-	  (progn (goto-char pos) (org-table-recalculate 'all))
-	(goto-char pos)
-	(org-table-align)))))
-
-(defun org-listtable-to-string (tbl)
-  "Convert a listtable TBL to a string that contains the Org-mode table.
-The table still need to be aligned.  The resulting string has no leading
-and tailing newline characters."
-  (mapconcat
-   (lambda (x)
-     (cond
-      ((listp x)
-       (concat "|" (mapconcat 'identity x "|") "|"))
-      ((eq x 'hline) "|-|")
-      (t (error "Garbage in listtable: %s" x))))
-   tbl "\n"))
-
-;;;###autoload
-(defun org-insert-columns-dblock ()
-  "Create a dynamic block capturing a column view table."
-  (interactive)
-  (let ((defaults '(:name "columnview" :hlines 1))
-	(id (org-icompleting-read
-	     "Capture columns (local, global, entry with :ID: property) [local]: "
-	     (append '(("global") ("local"))
-		     (mapcar 'list (org-property-values "ID"))))))
-    (if (equal id "") (setq id 'local))
-    (if (equal id "global") (setq id 'global))
-    (setq defaults (append defaults (list :id id)))
-    (org-create-dblock defaults)
-    (org-update-dblock)))
-
-;;; Column view in the agenda
-
-(defvar org-agenda-view-columns-initially nil
-  "When set, switch to columns view immediately after creating the agenda.")
-
-(defvar org-agenda-columns-show-summaries) ; defined in org-agenda.el
-(defvar org-agenda-columns-compute-summary-properties); defined in org-agenda.el
-(defvar org-agenda-columns-add-appointments-to-effort-sum); as well
-
-;;;###autoload
-(defun org-agenda-columns ()
-  "Turn on or update column view in the agenda."
-  (interactive)
-  (org-verify-version 'columns)
-  (org-columns-remove-overlays)
-  (move-marker org-columns-begin-marker (point))
-  (let ((org-columns-time (time-to-number-of-days (current-time)))
-	(fmt
-	 (cond
-	  ((org-bound-and-true-p org-agenda-overriding-columns-format))
-	  ((let ((m (org-get-at-bol 'org-hd-marker)))
-	     (and m
-		  (or (org-entry-get m "COLUMNS" t)
-		      (with-current-buffer (marker-buffer m)
-			org-columns-default-format)))))
-	  ((and (local-variable-p 'org-columns-current-fmt)
-		org-columns-current-fmt))
-	  ((let ((m (next-single-property-change (point-min) 'org-hd-marker)))
-	     (and m
-		  (let ((m (get-text-property m 'org-hd-marker)))
-		    (or (org-entry-get m "COLUMNS" t)
-			(with-current-buffer (marker-buffer m)
-			  org-columns-default-format))))))
-	  (t org-columns-default-format))))
-    (org-set-local 'org-columns-current-fmt fmt)
-    (org-columns-compile-format fmt)
-    (when org-agenda-columns-compute-summary-properties
-      (org-agenda-colview-compute org-columns-current-fmt-compiled))
-    (save-excursion
-      ;; Collect properties for each headline in current view.
-      (goto-char (point-min))
-      (let (cache)
-	(let ((names (mapcar #'car org-columns-current-fmt-compiled)) m)
-	  (while (not (eobp))
-	    (when (setq m (or (org-get-at-bol 'org-hd-marker)
-			      (org-get-at-bol 'org-marker)))
-	      (push
-	       (cons
-		(line-beginning-position)
-		(org-with-point-at m
-		  (mapcar
-		   (lambda (name)
-		     (let ((value (org-columns--value name (point))))
-		       (cons
-			name
-			(if (and org-agenda-columns-add-appointments-to-effort-sum
-				 (not value)
-				 (eq (compare-strings name nil nil
-						      org-effort-property nil nil
-						      t)
-				     t)
-				 ;; Effort property is not defined.  Try
-				 ;; to use appointment duration.
-				 (get-text-property (point) 'duration))
-			    (org-propertize
-			     (org-minutes-to-clocksum-string
-			      (get-text-property (point) 'duration))
-			     'face 'org-warning)
-			  value))))
-		   names)))
-	       cache))
-	    (forward-line)))
-	(when cache
-	  (org-set-local 'org-columns-current-maxwidths
-			 (org-columns-get-autowidth-alist fmt cache))
-	  (org-columns-display-here-title)
-	  (when (org-set-local 'org-columns-flyspell-was-active
-			       (org-bound-and-true-p flyspell-mode))
-	    (flyspell-mode 0))
-	  (dolist (x cache)
-	    (goto-char (car x))
-	    (org-columns-display-here (cdr x)))
-	  (when org-agenda-columns-show-summaries
-	    (org-agenda-colview-summarize cache)))))))
-
-(defun org-agenda-colview-summarize (cache)
-  "Summarize the summarizable columns in column view in the agenda.
-This will add overlays to the date lines, to show the summary for each day."
-  (let* ((fmt (mapcar (lambda (x)
-			(if (string-match "CLOCKSUM.*" (car x))
-			    (list (match-string 0 (car x))
-				  (nth 1 x) (nth 2 x) ":" 'add_times
-				  nil '+ nil)
-			  x))
-		      org-columns-current-fmt-compiled))
-	 line c c1 stype calc sumfunc props lsum entries prop v title)
-    (catch 'exit
-      (when (delq nil (mapcar 'cadr fmt))
-	;; OK, at least one summation column, it makes sense to try this
-	(goto-char (point-max))
-	(while t
-	  (when (or (get-text-property (point) 'org-date-line)
-		    (eq (get-text-property (point) 'face)
-			'org-agenda-structure))
-	    ;; OK, this is a date line that should be used
-	    (setq line (org-current-line))
-	    (setq entries nil c cache cache nil)
-	    (while (setq c1 (pop c))
-	      (if (> (car c1) line)
-		  (push c1 entries)
-		(push c1 cache)))
-	    ;; now ENTRIES are the ones we want to use, CACHE is the rest
-	    ;; Compute the summaries for the properties we want,
-	    ;; set nil properties for the rest.
-	    (when (setq entries (mapcar 'cdr entries))
-	      (setq props
-		    (mapcar
-		     (lambda (f)
-		       (setq prop (car f)
-			     title (nth 1 f)
-			     stype (nth 4 f)
-			     sumfunc (nth 6 f)
-			     calc (or (nth 7 f) 'identity))
-		       (cond
-			((equal prop "ITEM")
-			 (cons prop (buffer-substring (point-at-bol)
-						      (point-at-eol))))
-			((not stype) (cons prop ""))
-			(t ;; do the summary
-			 (setq lsum nil)
-			 (dolist (x entries)
-			   (setq v (cdr (assoc-string prop x t)))
-			   (if v
-			       (push
-				(funcall
-				 (if (not (get-text-property 0 'org-computed v))
-				     calc
-				   'identity)
-				 (org-columns-string-to-number
-				  v stype))
-				lsum)))
-			 (setq lsum (remove nil lsum))
-			 (setq lsum
-			       (cond ((> (length lsum) 1)
-				      (org-columns-number-to-string
-				       (apply sumfunc lsum) stype))
-				     ((eq (length lsum) 1)
-				      (org-columns-number-to-string
-				       (car lsum) stype))
-				     (t "")))
-			 (put-text-property 0 (length lsum) 'face 'bold lsum)
-			 (unless (eq calc 'identity)
-			   (put-text-property 0 (length lsum) 'org-computed t lsum))
-			 (cons prop lsum))))
-		     fmt))
-	      (org-columns-display-here props 'dateline)
-	      (org-set-local 'org-agenda-columns-active t)))
-	  (if (bobp) (throw 'exit t))
-	  (beginning-of-line 0))))))
-
-(defun org-agenda-colview-compute (fmt)
-  "Compute the relevant columns in the contributing source buffers."
-  (let ((files org-agenda-contributing-files)
-	(org-columns-begin-marker (make-marker))
-	(org-columns-top-level-marker (make-marker))
-	f fm a b)
-    (while (setq f (pop files))
-      (setq b (find-buffer-visiting f))
-      (with-current-buffer (or (buffer-base-buffer b) b)
-	(save-excursion
-	  (save-restriction
-	    (widen)
-	    (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))
-	      (cond ((equal (car fm) "CLOCKSUM")
-		     (org-clock-sum))
-		    ((equal (car fm) "CLOCKSUM_T")
-		     (org-clock-sum-today))
-		    ((and (nth 4 fm)
-			  (setq a (assoc-string (car fm)
-						org-columns-current-fmt-compiled
-						t))
-			  (equal (nth 4 a) (nth 4 fm)))
-		     (org-columns-compute (car fm)))))))))))
-
-(defun org-format-time-period (interval)
-  "Convert time in fractional days to days/hours/minutes/seconds."
-  (if (numberp interval)
-      (let* ((days (floor interval))
-	     (frac-hours (* 24 (- interval days)))
-	     (hours (floor frac-hours))
-	     (minutes (floor (* 60 (- frac-hours hours))))
-	     (seconds (floor (* 60 (- (* 60 (- frac-hours hours)) minutes)))))
-	(format "%dd %02dh %02dm %02ds" days hours minutes seconds))
-    ""))
-
-(defun org-estimate-mean-and-var (v)
-  "Return the mean and variance of an estimate."
-  (let* ((v (cond ((consp v) v)
-		  ((numberp v) (list v v))
-		  (t (error "Invalid estimate type"))))
-	 (low (float (car v)))
-         (high (float (cadr v)))
-         (mean (/ (+ low high) 2.0))
-         (var (/ (+ (expt (- mean low) 2.0) (expt (- high mean) 2.0)) 2.0)))
-    (list  mean var)))
-
-(defun org-estimate-combine (&rest el)
-  "Combine a list of estimates, using mean and variance.
-The mean and variance of the result will be the sum of the means
-and variances (respectively) of the individual estimates."
-  (let ((mean 0)
-        (var 0))
-    (mapc (lambda (e)
-	    (let ((stats (org-estimate-mean-and-var e)))
-	      (setq mean (+ mean (car stats)))
-	      (setq var (+ var (cadr stats)))))
-	  el)
-    (let ((stdev (sqrt var)))
-      (list (- mean stdev) (+ mean stdev)))))
-
-(defun org-estimate-print (e &optional fmt)
-  "Prepare a string representation of an estimate.
-This formats these numbers as two numbers with a \"-\" between them."
-  (let ((fmt (or fmt "%.0f"))
-	(e (cond ((consp e) e)
-		 ((numberp e) (list e e))
-		 (t (error "Invalid estimate type")))))
-    (format "%s" (mapconcat (lambda (n) (format fmt n)) e "-"))))
-
-(defun org-string-to-estimate (s)
-  "Convert a string to an estimate.
-The string should be two numbers joined with a \"-\"."
-  (if (string-match "\\(.*\\)-\\(.*\\)" s)
-      (list (string-to-number (match-string 1 s))
-	    (string-to-number(match-string 2 s)))
-    (list (string-to-number s) (string-to-number s))))
-
-(provide 'org-colview)
-
-;;; org-colview.el ends here
diff --git a/elpa/org-plus-contrib-20150831/org-compat.el b/elpa/org-plus-contrib-20150831/org-compat.el
deleted file mode 100644
index a762b8e1..00000000
--- a/elpa/org-plus-contrib-20150831/org-compat.el
+++ /dev/null
@@ -1,546 +0,0 @@
-;;; org-compat.el --- Compatibility code for Org-mode
-
-;; Copyright (C) 2004-2015 Free Software Foundation, Inc.
-
-;; Author: Carsten Dominik 
-;; 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 .
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;
-;;; Commentary:
-
-;; This file contains code needed for compatibility with XEmacs and older
-;; versions of GNU Emacs.
-
-;;; Code:
-
-(eval-when-compile
-  (require 'cl))
-
-(require 'org-macs)
-
-(declare-function w32-focus-frame "term/w32-win" (frame))
-
-;; The following constant is for backward compatibility.  We do not use
-;; it in org-mode, because the Byte compiler evaluates (featurep 'xemacs)
-;; at compilation time and can therefore optimize code better.
-(defconst org-xemacs-p (featurep 'xemacs))
-
-(defun org-compatible-face (inherits specs)
-  "Make a compatible face specification.
-If INHERITS is an existing face and if the Emacs version supports it,
-just inherit the face.  If INHERITS is set and the Emacs version does
-not support it, copy the face specification from the inheritance face.
-If INHERITS is not given and SPECS is, use SPECS to define the face.
-XEmacs and Emacs 21 do not know about the `min-colors' attribute.
-For them we convert a (min-colors 8) entry to a `tty' entry and move it
-to the top of the list.  The `min-colors' attribute will be removed from
-any other entries, and any resulting duplicates will be removed entirely."
-  (when (and inherits (facep inherits) (not specs))
-    (setq specs (or specs
-		    (get inherits 'saved-face)
-		    (get inherits 'face-defface-spec))))
-  (cond
-   ((and inherits (facep inherits)
-	 (not (featurep 'xemacs))
-	 (>= emacs-major-version 22)
-	 ;; do not inherit outline faces before Emacs 23
-	 (or (>= emacs-major-version 23)
-	     (not (string-match "\\`outline-[0-9]+"
-				(symbol-name inherits)))))
-    (list (list t :inherit inherits)))
-   ((or (featurep 'xemacs) (< emacs-major-version 22))
-    ;; These do not understand the `min-colors' attribute.
-    (let (r e a)
-      (while (setq e (pop specs))
-	(cond
-	 ((memq (car e) '(t default)) (push e r))
-	 ((setq a (member '(min-colors 8) (car e)))
-	  (nconc r (list (cons (cons '(type tty) (delq (car a) (car e)))
-			       (cdr e)))))
-	 ((setq a (assq 'min-colors (car e)))
-	  (setq e (cons (delq a (car e)) (cdr e)))
-	  (or (assoc (car e) r) (push e r)))
-	 (t (or (assoc (car e) r) (push e r)))))
-      (nreverse r)))
-   (t specs)))
-(put 'org-compatible-face 'lisp-indent-function 1)
-
-(defun org-version-check (version feature level)
-  (let* ((v1 (mapcar 'string-to-number (split-string version "[.]")))
-	 (v2 (mapcar 'string-to-number (split-string emacs-version "[.]")))
-	 (rmaj (or (nth 0 v1) 99))
-	 (rmin (or (nth 1 v1) 99))
-	 (rbld (or (nth 2 v1) 99))
-	 (maj (or (nth 0 v2) 0))
-	 (min (or (nth 1 v2) 0))
-	 (bld (or (nth 2 v2) 0)))
-    (if (or (< maj rmaj)
-	    (and (= maj rmaj)
-		 (< min rmin))
-	    (and (= maj rmaj)
-		 (= min rmin)
-		 (< bld rbld)))
-	(if (eq level :predicate)
-	    ;; just return if we have the version
-	    nil
-	  (let ((msg (format "Emacs %s or greater is recommended for %s"
-			     version feature)))
-	    (display-warning 'org msg level)
-	    t))
-      t)))
-
-
-;;;; 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])
-    ([mouse-2] . [button2])
-    ([mouse-3] . [button3])
-    ([C-mouse-4] . [(control mouse-4)])
-    ([C-mouse-5] . [(control mouse-5)]))
-  "Translation alist for a couple of keys.")
-
-;; Overlay compatibility functions
-(defun org-detach-overlay (ovl)
-  (if (featurep 'xemacs) (detach-extent ovl) (delete-overlay ovl)))
-(defun org-overlay-display (ovl text &optional face evap)
-  "Make overlay OVL display TEXT with face FACE."
-  (if (featurep 'xemacs)
-      (let ((gl (make-glyph text)))
-	(and face (set-glyph-face gl face))
-	(set-extent-property ovl 'invisible t)
-	(set-extent-property ovl 'end-glyph gl))
-    (overlay-put ovl 'display text)
-    (if face (overlay-put ovl 'face face))
-    (if evap (overlay-put ovl 'evaporate t))))
-(defun org-overlay-before-string (ovl text &optional face evap)
-  "Make overlay OVL display TEXT with face FACE."
-  (if (featurep 'xemacs)
-      (let ((gl (make-glyph text)))
-	(and face (set-glyph-face gl face))
-	(set-extent-property ovl 'begin-glyph gl))
-    (if face (org-add-props text nil 'face face))
-    (overlay-put ovl 'before-string text)
-    (if evap (overlay-put ovl 'evaporate t))))
-(defun org-find-overlays (prop &optional pos delete)
-  "Find all overlays specifying PROP at POS or point.
-If DELETE is non-nil, delete all those overlays."
-  (let ((overlays (overlays-at (or pos (point))))
-	ov found)
-    (while (setq ov (pop overlays))
-      (if (overlay-get ov prop)
-          (if delete (delete-overlay ov) (push ov found))))
-    found))
-
-(defun org-get-x-clipboard (value)
-  "Get the value of the x or Windows clipboard, compatible with XEmacs, and GNU Emacs 21."
-  (cond ((eq window-system 'x)
-	 (let ((x (org-get-x-clipboard-compat value)))
-	   (if x (org-no-properties x))))
-	((and (eq window-system 'w32) (fboundp 'w32-get-clipboard-data))
-	 (w32-get-clipboard-data))))
-
-(defsubst org-decompose-region (beg end)
-  "Decompose from BEG to END."
-  (if (featurep 'xemacs)
-      (let ((modified-p (buffer-modified-p))
-	    (buffer-read-only nil))
-	(remove-text-properties beg end '(composition nil))
-	(set-buffer-modified-p modified-p))
-    (decompose-region beg end)))
-
-;; Miscellaneous functions
-
-(defun org-add-hook (hook function &optional append local)
-  "Add-hook, compatible with both Emacsen."
-  (if (and local (featurep 'xemacs))
-      (add-local-hook hook function append)
-    (add-hook hook function append local)))
-
-(defun org-add-props (string plist &rest props)
-  "Add text properties to entire string, from beginning to end.
-PLIST may be a list of properties, PROPS are individual properties and values
-that will be added to PLIST.  Returns the string that was modified."
-  (add-text-properties
-   0 (length string) (if props (append plist props) plist) string)
-  string)
-(put 'org-add-props 'lisp-indent-function 2)
-
-(defun org-fit-window-to-buffer (&optional window max-height min-height
-					   shrink-only)
-  "Fit WINDOW to the buffer, but only if it is not a side-by-side window.
-WINDOW defaults to the selected window.  MAX-HEIGHT and MIN-HEIGHT are
-passed through to `fit-window-to-buffer'.  If SHRINK-ONLY is set, call
-`shrink-window-if-larger-than-buffer' instead, the height limit is
-ignored in this case."
-  (cond ((if (fboundp 'window-full-width-p)
-	     (not (window-full-width-p window))
-	   ;; do nothing if another window would suffer
-	   (> (frame-width) (window-width window))))
-	((and (fboundp 'fit-window-to-buffer) (not shrink-only))
-	 (fit-window-to-buffer window max-height min-height))
-	((fboundp 'shrink-window-if-larger-than-buffer)
-	 (shrink-window-if-larger-than-buffer window)))
-  (or window (selected-window)))
-
-(defun org-number-sequence (from &optional to inc)
-  "Call `number-sequence' or emulate it."
-  (if (fboundp 'number-sequence)
-      (number-sequence from to inc)
-    (if (or (not to) (= from to))
-	(list from)
-      (or inc (setq inc 1))
-      (when (zerop inc) (error "The increment can not be zero"))
-      (let (seq (n 0) (next from))
-	(if (> inc 0)
-	    (while (<= next to)
-	      (setq seq (cons next seq)
-		    n (1+ n)
-		    next (+ from (* n inc))))
-	  (while (>= next to)
-	    (setq seq (cons next seq)
-		  n (1+ n)
-		  next (+ from (* n inc)))))
-	(nreverse seq)))))
-
-;; `set-transient-map' is only in Emacs >= 24.4
-(defalias 'org-set-transient-map
-  (if (fboundp 'set-transient-map)
-      'set-transient-map
-    'set-temporary-overlay-map))
-
-;; Region compatibility
-
-(defvar org-ignore-region nil
-  "Non-nil means temporarily disable the active region.")
-
-(defun org-region-active-p ()
-  "Is `transient-mark-mode' on and the region active?
-Works on both Emacs and XEmacs."
-  (if org-ignore-region
-      nil
-    (if (featurep 'xemacs)
-	(and zmacs-regions (region-active-p))
-      (if (fboundp 'use-region-p)
-	  (use-region-p)
-	(and transient-mark-mode mark-active))))) ; Emacs 22 and before
-
-(defun org-cursor-to-region-beginning ()
-  (when (and (org-region-active-p)
-	     (> (point) (region-beginning)))
-    (exchange-point-and-mark)))
-
-;; Old alias for emacs 22 compatibility, now dropped
-(define-obsolete-function-alias 'org-activate-mark 'activate-mark)
-
-;; Invisibility compatibility
-
-(defun org-remove-from-invisibility-spec (arg)
-  "Remove elements from `buffer-invisibility-spec'."
-  (if (fboundp 'remove-from-invisibility-spec)
-      (remove-from-invisibility-spec arg)
-    (if (consp buffer-invisibility-spec)
-	(setq buffer-invisibility-spec
-	      (delete arg buffer-invisibility-spec)))))
-
-(defun org-in-invisibility-spec-p (arg)
-  "Is ARG a member of `buffer-invisibility-spec'?"
-  (if (consp buffer-invisibility-spec)
-      (member arg buffer-invisibility-spec)))
-
-(defmacro org-xemacs-without-invisibility (&rest body)
-  "Turn off extents with invisibility while executing BODY."
-  `(let ((ext-inv (extent-list nil (point-at-bol) (point-at-eol)
-			       'all-extents-closed-open 'invisible))
-	 ext-inv-specs)
-     (dolist (ext ext-inv)
-       (when (extent-property ext 'invisible)
-	 (add-to-list 'ext-inv-specs (list ext (extent-property
-						ext 'invisible)))
-	 (set-extent-property ext 'invisible nil)))
-     ,@body
-     (dolist (ext-inv-spec ext-inv-specs)
-       (set-extent-property (car ext-inv-spec) 'invisible
-			    (cadr ext-inv-spec)))))
-(def-edebug-spec org-xemacs-without-invisibility (body))
-
-(defun org-indent-to-column (column &optional minimum buffer)
-  "Work around a bug with extents with invisibility in XEmacs."
-  (if (featurep 'xemacs)
-      (org-xemacs-without-invisibility (indent-to-column column minimum buffer))
-    (indent-to-column column minimum)))
-
-(defun org-indent-line-to (column)
-  "Work around a bug with extents with invisibility in XEmacs."
-  (if (featurep 'xemacs)
-      (org-xemacs-without-invisibility (indent-line-to column))
-    (indent-line-to column)))
-
-(defun org-move-to-column (column &optional force buffer)
-  "Move to column COLUMN.
-Pass COLUMN and FORCE to `move-to-column'.
-Pass BUFFER to the XEmacs version of `move-to-column'."
-  (let ((buffer-invisibility-spec
-	 (remove '(org-filtered) buffer-invisibility-spec)))
-    (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."
-  (cond ((featurep 'xemacs)
-	 (org-no-warnings (get-selection-no-error value)))
-	((fboundp 'x-get-selection)
-	 (condition-case nil
-	     (or (x-get-selection value 'UTF8_STRING)
-		 (x-get-selection value 'COMPOUND_TEXT)
-		 (x-get-selection value 'STRING)
-		 (x-get-selection value 'TEXT))
-	   (error nil)))))
-
-(defun org-propertize (string &rest properties)
-  (if (featurep 'xemacs)
-      (progn
-	(add-text-properties 0 (length string) properties string)
-	string)
-    (apply 'propertize string properties)))
-
-(defmacro org-find-library-dir (library)
-  `(file-name-directory (or (locate-library ,library) "")))
-
-(defun org-count-lines (s)
-  "How many lines in string S?"
-  (let ((start 0) (n 1))
-    (while (string-match "\n" s start)
-      (setq start (match-end 0) n (1+ n)))
-    (if (and (> (length s) 0) (= (aref s (1- (length s))) ?\n))
-	(setq n (1- n)))
-    n))
-
-(defun org-kill-new (string &rest args)
-  (remove-text-properties 0 (length string) '(line-prefix t wrap-prefix t)
-			  string)
-  (apply 'kill-new string args))
-
-(defun org-select-frame-set-input-focus (frame)
-  "Select FRAME, raise it, and set input focus, if possible."
-  (cond ((featurep 'xemacs)
-	 (if (fboundp 'select-frame-set-input-focus)
-	     (select-frame-set-input-focus frame)
-	   (raise-frame frame)
-	   (select-frame frame)
-	   (focus-frame frame)))
-	;; `select-frame-set-input-focus' defined in Emacs 21 will not
-	;; set the input focus.
-	((>= emacs-major-version 22)
-	 (select-frame-set-input-focus frame))
-	(t
-	 (raise-frame frame)
-	 (select-frame frame)
-	 (cond ((memq window-system '(x ns mac))
-		(x-focus-frame frame))
-	       ((eq window-system 'w32)
-		(w32-focus-frame frame)))
-	 (when focus-follows-mouse
-	   (set-mouse-position frame (1- (frame-width frame)) 0)))))
-
-(defalias 'org-float-time
-  (if (featurep 'xemacs) 'time-to-seconds 'float-time))
-
-;; `user-error' is only available from 24.2.50 on
-(unless (fboundp 'user-error)
-  (defalias 'user-error 'error))
-
-;; `font-lock-ensure' is only available from 24.4.50 on
-(unless (fboundp 'font-lock-ensure)
-  (defalias 'font-lock-ensure 'font-lock-fontify-buffer))
-
-(defmacro org-no-popups (&rest body)
-  "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 (fboundp 'string-match-p)
-    (defalias 'org-string-match-p 'string-match-p)
-  (defun org-string-match-p (regexp string &optional start)
-    (save-match-data
-      (funcall 'string-match regexp string start))))
-
-(if (fboundp 'looking-at-p)
-    (defalias 'org-looking-at-p 'looking-at-p)
-  (defun org-looking-at-p (&rest args)
-    (save-match-data
-      (apply 'looking-at args))))
-
-;; XEmacs does not have `looking-back'.
-(if (fboundp 'looking-back)
-    (defalias 'org-looking-back 'looking-back)
-  (defun org-looking-back (regexp &optional limit greedy)
-    "Return non-nil if text before point matches regular expression REGEXP.
-Like `looking-at' except matches before point, and is slower.
-LIMIT if non-nil speeds up the search by specifying a minimum
-starting position, to avoid checking matches that would start
-before LIMIT.
-
-If GREEDY is non-nil, extend the match backwards as far as
-possible, stopping when a single additional previous character
-cannot be part of a match for REGEXP.  When the match is
-extended, its starting position is allowed to occur before
-LIMIT."
-    (let ((start (point))
-	  (pos
-	   (save-excursion
-	     (and (re-search-backward (concat "\\(?:" regexp "\\)\\=") limit t)
-		  (point)))))
-      (if (and greedy pos)
-	  (save-restriction
-	    (narrow-to-region (point-min) start)
-	    (while (and (> pos (point-min))
-			(save-excursion
-			  (goto-char pos)
-			  (backward-char 1)
-			  (looking-at (concat "\\(?:"  regexp "\\)\\'"))))
-	      (setq pos (1- pos)))
-	    (save-excursion
-	      (goto-char pos)
-	      (looking-at (concat "\\(?:"  regexp "\\)\\'")))))
-      (not (null pos)))))
-
-(defun org-floor* (x &optional y)
-  "Return a list of the floor of X and the fractional part of X.
-With two arguments, return floor and remainder of their quotient."
-  (let ((q (floor x y)))
-    (list q (- x (if y (* y q) q)))))
-
-;; `pop-to-buffer-same-window' has been introduced in Emacs 24.1.
-(defun org-pop-to-buffer-same-window
-  (&optional buffer-or-name norecord label)
-  "Pop to buffer specified by BUFFER-OR-NAME in the selected window."
-  (if (fboundp 'pop-to-buffer-same-window)
-      (funcall
-       'pop-to-buffer-same-window buffer-or-name norecord)
-    (funcall 'switch-to-buffer buffer-or-name norecord)))
-
-;; RECURSIVE has been introduced with Emacs 23.2.
-;; This is copying and adapted from `tramp-compat-delete-directory'
-(defun org-delete-directory (directory &optional recursive)
-  "Compatibility function for `delete-directory'."
-  (if (null recursive)
-      (delete-directory directory)
-    (condition-case nil
-	(funcall 'delete-directory directory recursive)
-      ;; This Emacs version does not support the RECURSIVE flag.  We
-      ;; use the implementation from Emacs 23.2.
-      (wrong-number-of-arguments
-       (setq directory (directory-file-name (expand-file-name directory)))
-       (if (not (file-symlink-p directory))
-	   (mapc (lambda (file)
-		   (if (eq t (car (file-attributes file)))
-		       (org-delete-directory file recursive)
-		     (delete-file file)))
-		 (directory-files
-		  directory 'full "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*")))
-       (delete-directory directory)))))
-
-;;;###autoload
-(defmacro org-check-version ()
-  "Try very hard to provide sensible version strings."
-  (let* ((org-dir        (org-find-library-dir "org"))
-	 (org-version.el (concat org-dir "org-version.el"))
-	 (org-fixup.el   (concat org-dir "../mk/org-fixup.el")))
-    (if (require 'org-version org-version.el 'noerror)
-	'(progn
-	   (autoload 'org-release     "org-version.el")
-	   (autoload 'org-git-version "org-version.el"))
-      (if (require 'org-fixup org-fixup.el 'noerror)
-	  '(org-fixup)
-	;; provide fallback definitions and complain
-	(warn "Could not define org version correctly.  Check installation!")
-	'(progn
-	   (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
diff --git a/elpa/org-plus-contrib-20150831/org-datetree.el b/elpa/org-plus-contrib-20150831/org-datetree.el
deleted file mode 100644
index a97a9d0b..00000000
--- a/elpa/org-plus-contrib-20150831/org-datetree.el
+++ /dev/null
@@ -1,219 +0,0 @@
-;;; org-datetree.el --- Create date entries in a tree
-
-;; Copyright (C) 2009-2015 Free Software Foundation, Inc.
-
-;; Author: Carsten Dominik 
-;; 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 .
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;
-;;; Commentary:
-
-;; This file contains code to create entries in a tree where the top-level
-;; nodes represent years, the level 2 nodes represent the months, and the
-;; level 1 entries days.
-
-;;; Code:
-
-(require 'org)
-
-(defvar org-datetree-base-level 1
-  "The level at which years should be placed in the date tree.
-This is normally one, but if the buffer has an entry with a DATE_TREE
-property (any value), the date tree will become a subtree under that entry,
-so the base level will be properly adjusted.")
-
-(defcustom org-datetree-add-timestamp nil
-  "When non-nil, add a time stamp matching date of entry.
-Added time stamp is active unless value is `inactive'."
-  :group 'org-capture
-  :version "24.3"
-  :type '(choice
-	  (const :tag "Do not add a time stamp" nil)
-	  (const :tag "Add an inactive time stamp" inactive)
-	  (const :tag "Add an active time stamp" active)))
-
-;;;###autoload
-(defun org-datetree-find-date-create (date &optional keep-restriction)
-  "Find or create an entry for DATE.
-If KEEP-RESTRICTION is non-nil, do not widen the buffer.
-When it is nil, the buffer will be widened to make sure an existing date
-tree can be found."
-  (org-set-local 'org-datetree-base-level 1)
-  (or keep-restriction (widen))
-  (save-restriction
-    (let ((prop (org-find-property "DATE_TREE")))
-      (when prop
-	(goto-char prop)
-	(org-set-local 'org-datetree-base-level
-		       (org-get-valid-level (org-current-level) 1))
-	(org-narrow-to-subtree)))
-    (goto-char (point-min))
-    (let ((year (nth 2 date))
-	  (month (car date))
-	  (day (nth 1 date)))
-      (org-datetree-find-year-create year)
-      (org-datetree-find-month-create year month)
-      (org-datetree-find-day-create year month day))))
-
-(defun org-datetree-find-year-create (year)
-  "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))
-		(goto-char (match-beginning 1))
-		(< (string-to-number (match-string 1)) year)))
-    (cond
-     ((not match)
-      (goto-char (point-max))
-      (or (bolp) (newline))
-      (org-datetree-insert-line year))
-     ((= (string-to-number (match-string 1)) year)
-      (goto-char (point-at-bol)))
-     (t
-      (beginning-of-line 1)
-      (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)
-    (goto-char (point-min))
-    (while (and (setq match (re-search-forward re nil t))
-		(goto-char (match-beginning 1))
-		(< (string-to-number (match-string 1)) month)))
-    (cond
-     ((not match)
-      (goto-char (point-max))
-      (or (bolp) (newline))
-      (org-datetree-insert-line year month))
-     ((= (string-to-number (match-string 1)) month)
-      (goto-char (point-at-bol)))
-     (t
-      (beginning-of-line 1)
-      (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)
-    (goto-char (point-min))
-    (while (and (setq match (re-search-forward re nil t))
-		(goto-char (match-beginning 1))
-		(< (string-to-number (match-string 1)) day)))
-    (cond
-     ((not match)
-      (goto-char (point-max))
-      (or (bolp) (newline))
-      (org-datetree-insert-line year month day))
-     ((= (string-to-number (match-string 1)) day)
-      (goto-char (point-at-bol)))
-     (t
-      (beginning-of-line 1)
-      (org-datetree-insert-line year month day)))))
-
-(defun org-datetree-insert-line (year &optional month day)
-  (delete-region (save-excursion (skip-chars-backward " \t\n") (point)) (point))
-  (insert "\n" (make-string org-datetree-base-level ?*) " \n")
-  (backward-char)
-  (when month (org-do-demote))
-  (when day (org-do-demote))
-  (insert (format "%d" year))
-  (when month
-    (insert
-     (format "-%02d" month)
-     (if day
-	 (format "-%02d %s"
-		 day
-		 (format-time-string "%A" (encode-time 0 0 0 day month year)))
-       (format " %s"
-	       (format-time-string "%B" (encode-time 0 0 0 1 month year))))))
-  (when (and day org-datetree-add-timestamp)
-    (save-excursion
-      (insert "\n")
-      (org-indent-line)
-      (org-insert-time-stamp
-       (encode-time 0 0 0 day month year)
-       nil
-       (eq org-datetree-add-timestamp 'inactive))))
-  (beginning-of-line))
-
-(defun org-datetree-file-entry-under (txt date)
-  "Insert a node TXT into the date tree under DATE."
-  (org-datetree-find-date-create date)
-  (let ((level (org-get-valid-level (funcall outline-level) 1)))
-    (org-end-of-subtree t t)
-    (org-back-over-empty-lines)
-    (org-paste-subtree level txt)))
-
-(defun org-datetree-cleanup ()
-  "Make sure all entries in the current tree are under the correct date.
-It may be useful to restrict the buffer to the applicable portion
-before running this command, even though the command tries to be smart."
-  (interactive)
-  (goto-char (point-min))
-  (let ((dre (concat "\\<" org-deadline-string "\\>[ \t]*\\'"))
-	(sre (concat "\\<" org-scheduled-string "\\>[ \t]*\\'"))
-	dct ts tmp date year month day pos hdl-pos)
-    (while (re-search-forward org-ts-regexp nil t)
-      (catch 'next
-	(setq ts (match-string 0))
-	(setq tmp (buffer-substring
-		   (max (point-at-bol) (- (match-beginning 0)
-					  org-ds-keyword-length))
-		   (match-beginning 0)))
-	(if (or (string-match "-\\'" tmp)
-		(string-match dre tmp)
-		(string-match sre tmp))
-	    (throw 'next nil))
-	(setq dct (decode-time (org-time-string-to-time (match-string 0)))
-	      date (list (nth 4 dct) (nth 3 dct) (nth 5 dct))
-	      year (nth 2 date)
-	      month (car date)
-	      day (nth 1 date)
-	      pos (point))
-	(org-back-to-heading t)
-	(setq hdl-pos (point))
-	(unless (org-up-heading-safe)
-	  ;; No parent, we are not in a date tree
-	  (goto-char pos)
-	  (throw 'next nil))
-	(unless (looking-at "\\*+[ \t]+[0-9]+-[0-1][0-9]-[0-3][0-9]")
-	  ;; Parent looks wrong, we are not in a date tree
-	  (goto-char pos)
-	  (throw 'next nil))
-	(when (looking-at (format "\\*+[ \t]+%d-%02d-%02d" year month day))
-	  ;; At correct date already, do nothing
-	  (progn (goto-char pos) (throw 'next nil)))
-	;; OK, we need to refile this entry
-	(goto-char hdl-pos)
-	(org-cut-subtree)
-	(save-excursion
-	  (save-restriction
-	    (org-datetree-file-entry-under (current-kill 0) date)))))))
-
-(provide 'org-datetree)
-
-;; Local variables:
-;; generated-autoload-file: "org-loaddefs.el"
-;; End:
-
-;;; org-datetree.el ends here
diff --git a/elpa/org-plus-contrib-20150831/org-download.el b/elpa/org-plus-contrib-20150831/org-download.el
deleted file mode 100644
index 6bff649c..00000000
--- a/elpa/org-plus-contrib-20150831/org-download.el
+++ /dev/null
@@ -1,392 +0,0 @@
-;;; org-download.el --- Image drag-and-drop for Emacs org-mode
-
-;; Copyright (C) 2014-2015 Free Software Foundation, Inc.
-
-;; Author: Oleh Krehel
-;; Keywords: images, screenshots, download
-;; Homepage: http://orgmode.org
-
-;; This file is not 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 .
-
-;;; Commentary:
-;;
-;; This extension facilitates moving images from point A to point B.
-;;
-;; Point A (the source) can be:
-;; 1. An image inside your browser that you can drag to Emacs.
-;; 2. An image on your file system that you can drag to Emacs.
-;; 3. A local or remote image address in kill-ring.
-;;    Use the `org-download-yank' command for this.
-;;    Remember that you can use "0 w" in `dired' to get an address.
-;; 4. An screenshot taken using `gnome-screenshot' or `scrot' or `gm'.
-;;    Use the `org-download-screenshot' command for this.
-;;    Customize the backend with  `org-download-screenshot-method'.
-;;
-;; Point B (the target) is an Emacs `org-mode' buffer where the inline
-;; link will be inserted.  Several customization options will determine
-;; where exactly on the file system the file will be stored.
-;;
-;; They are:
-;; `org-download-method':
-;; a. 'attach => use `org-mode' attachment machinery
-;; b. 'directory => construct the directory in two stages:
-;;    1. first part of the folder name is:
-;;       * either "." (current folder)
-;;       * or `org-download-image-dir' (if it's not nil).
-;;         `org-download-image-dir' becomes buffer-local when set,
-;;         so each file can customize this value, e.g with:
-;;         # -*- mode: Org; org-download-image-dir: "~/Pictures/foo"; -*-
-;;    2. second part is:
-;;       * `org-download-heading-lvl' is nil => ""
-;;       * `org-download-heading-lvl' is n => the name of current
-;;         heading with level n. Level count starts with 0,
-;;         i.e. * is 0, ** is 1, *** is 2 etc.
-;;         `org-download-heading-lvl' becomes buffer-local when set,
-;;         so each file can customize this value, e.g with:
-;;         # -*- mode: Org; org-download-heading-lvl: nil; -*-
-;;
-;; `org-download-timestamp':
-;; optionally add a timestamp to the file name.
-;;
-;; Customize `org-download-backend' to choose between `url-retrieve'
-;; (the default) or `wget' or `curl'.
-;;
-;;; Code:
-
-
-(eval-when-compile
-  (require 'cl))
-(require 'url-parse)
-(require 'url-http)
-
-(defgroup org-download nil
-  "Image drag-and-drop for org-mode."
-  :group 'org
-  :prefix "org-download-")
-
-(defcustom org-download-method 'directory
-  "The way images should be stored."
-  :type '(choice
-          (const :tag "Directory" directory)
-          (const :tag "Attachment" attach))
-  :group 'org-download)
-
-(defcustom org-download-image-dir nil
-  "If set, images will be stored in this directory instead of \".\".
-See `org-download--dir-1' for more info."
-  :type '(choice
-          (const :tag "Default" nil)
-          (string :tag "Directory"))
-  :group 'org-download)
-(make-variable-buffer-local 'org-download-image-dir)
-
-(defcustom org-download-heading-lvl 0
-  "Heading level to be used in `org-download--dir-2'."
-  :group 'org-download)
-(make-variable-buffer-local 'org-download-heading-lvl)
-
-(defcustom org-download-backend t
-  "Method to use for downloading."
-  :type '(choice
-          (const :tag "wget" "wget \"%s\" -O \"%s\"")
-          (const :tag "curl" "curl \"%s\" -o \"%s\"")
-          (const :tag "url-retrieve" t))
-  :group 'org-download)
-
-(defcustom org-download-timestamp "_%Y-%m-%d_%H:%M:%S"
-  "This `format-time-string'-style string will be appended to the file name.
-Set this to \"\" if you don't want time stamps."
-  :type 'string
-  :group 'org-download)
-
-(defcustom org-download-img-regex-list
-  '("= (decf times) 0)
-                (re-search-forward "\\[\\[\\([^]]*\\)\\]\\]" end t))
-      (let ((str (match-string-no-properties 1)))
-        (delete-region beg
-                       (match-end 0))
-        (when (file-exists-p str)
-          (delete-file str))))))
-
-(defun org-download-dnd (uri action)
-  "When in `org-mode' and URI points to image, download it.
-Otherwise, pass URI and ACTION back to dnd dispatch."
-  (cond ((eq major-mode 'org-mode)
-      ;; probably shouldn't redirect
-      (unless (org-download-image uri)
-           (message "not an image URL")))
-        ((eq major-mode 'dired-mode)
-         (org-download-dired uri))
-    ;; redirect to someone else
-        (t
-    (let ((dnd-protocol-alist
-           (rassq-delete-all
-            'org-download-dnd
-            (copy-alist dnd-protocol-alist))))
-           (dnd-handle-one-url nil action uri)))))
-
-(defun org-download-dired (uri)
-  "Download URI to current directory."
-  (raise-frame)
-  (let ((filename (file-name-nondirectory
-                   (car (url-path-and-query
-                         (url-generic-parse-url uri))))))
-    (message "Downloading %s to %s ..."
-             filename
-             (expand-file-name filename))
-    (url-retrieve
-     uri
-     (lambda (status filename)
-       (let ((err (plist-get status :error)))
-         (if err (error
-                  "\"%s\" %s" uri
-                  (downcase (nth 2 (assq (nth 2 err) url-http-codes))))))
-       (let ((coding-system-for-write 'no-conversion))
-         (write-region nil nil filename nil nil nil 'confirm)))
-     (list
-      (expand-file-name filename))
-     t t)))
-
-(defun org-download-enable ()
-  "Enable org-download."
-  (unless (eq (cdr (assoc "^\\(https?\\|ftp\\|file\\|nfs\\)://" dnd-protocol-alist))
-              'org-download-dnd)
-    (setq dnd-protocol-alist
-          `(("^\\(https?\\|ftp\\|file\\|nfs\\)://" . org-download-dnd) ,@dnd-protocol-alist))))
-
-(defun org-download-disable ()
-  "Disable org-download."
-  (rassq-delete-all 'org-download-dnd dnd-protocol-alist))
-
-(org-download-enable)
-
-(provide 'org-download)
-
-;;; org-download.el ends here
diff --git a/elpa/org-plus-contrib-20150831/org-ebib.el b/elpa/org-plus-contrib-20150831/org-ebib.el
deleted file mode 100644
index 2136a134..00000000
--- a/elpa/org-plus-contrib-20150831/org-ebib.el
+++ /dev/null
@@ -1,47 +0,0 @@
-;;; org-ebib.el - Support for links to Ebib's entries in Org
-;;
-;; Author: Grégoire Jadi 
-;;
-;; This file is not yet part of GNU Emacs.
-;;
-;; 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, 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 GNU Emacs.  If not, see .
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;
-;;; Commentary:
-
-(require 'org)
-
-(org-add-link-type "ebib" 'org-ebib-open)
-
-(add-hook 'org-store-link-functions 'org-ebib-store-link)
-
-(defun org-ebib-open (key)
-  "Open Ebib and jump to KEY."
-  (ebib nil key))
-
-(defun org-ebib-store-link ()
-  "Store a key to an Ebib entry."
-  (when (memq major-mode '(ebib-index-mode ebib-entry-mode))
-    ;; This is an Ebib entry
-    (let* ((key (ebib-cur-entry-key))
-           (link (concat "ebib:" key))
-           (description (ignore-errors (ebib-db-get-field-value 'title key ebib-cur-db))))
-      (org-store-link-props
-       :type "ebib"
-       :link link
-       :description description))))
-
-(provide 'org-ebib)
-
-;;; org-ebib.el ends here
diff --git a/elpa/org-plus-contrib-20150831/org-faces.el b/elpa/org-plus-contrib-20150831/org-faces.el
deleted file mode 100644
index 1eac660c..00000000
--- a/elpa/org-plus-contrib-20150831/org-faces.el
+++ /dev/null
@@ -1,811 +0,0 @@
-;;; org-faces.el --- Face definitions for Org-mode.
-
-;; Copyright (C) 2004-2015 Free Software Foundation, Inc.
-
-;; Author: Carsten Dominik 
-;; 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 .
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;
-;;; Commentary:
-
-;; This file contains the face definitions for Org.
-
-;;; Code:
-
-(require 'org-macs)
-(require 'org-compat)
-
-(when (featurep 'xemacs)
-  (put 'mode-line 'face-alias 'modeline))
-
-(defgroup org-faces nil
-  "Faces in Org-mode."
-  :tag "Org Faces"
-  :group 'org-appearance)
-
-(defface org-default
-  (org-compatible-face 'default nil)
-  "Face used for default text."
-  :group 'org-faces)
-
-(defface org-hide
-  '((((background light)) (:foreground "white"))
-    (((background dark)) (:foreground "black")))
-  "Face used to hide leading stars in headlines.
-The foreground color of this face should be equal to the background
-color of the frame."
-  :group 'org-faces)
-
-(defface org-level-1 ;; originally copied from font-lock-function-name-face
-  (org-compatible-face 'outline-1
-    '((((class color) (min-colors 88) (background light)) (:foreground "Blue1"))
-      (((class color) (min-colors 88) (background dark)) (:foreground "LightSkyBlue"))
-      (((class color) (min-colors 16) (background light)) (:foreground "Blue"))
-      (((class color) (min-colors 16) (background dark)) (:foreground "LightSkyBlue"))
-      (((class color) (min-colors 8)) (:foreground "blue" :bold t))
-      (t (:bold t))))
-  "Face used for level 1 headlines."
-  :group 'org-faces)
-
-(defface org-level-2 ;; originally copied from font-lock-variable-name-face
-  (org-compatible-face 'outline-2
-    '((((class color) (min-colors 16) (background light)) (:foreground "DarkGoldenrod"))
-      (((class color) (min-colors 16) (background dark))  (:foreground "LightGoldenrod"))
-      (((class color) (min-colors 8)  (background light)) (:foreground "yellow"))
-      (((class color) (min-colors 8)  (background dark))  (:foreground "yellow" :bold t))
-      (t (:bold t))))
-  "Face used for level 2 headlines."
-  :group 'org-faces)
-
-(defface org-level-3 ;; originally copied from font-lock-keyword-face
-  (org-compatible-face 'outline-3
-    '((((class color) (min-colors 88) (background light)) (:foreground "Purple"))
-      (((class color) (min-colors 88) (background dark))  (:foreground "Cyan1"))
-      (((class color) (min-colors 16) (background light)) (:foreground "Purple"))
-      (((class color) (min-colors 16) (background dark))  (:foreground "Cyan"))
-      (((class color) (min-colors 8)  (background light)) (:foreground "purple" :bold t))
-      (((class color) (min-colors 8)  (background dark))  (:foreground "cyan" :bold t))
-      (t (:bold t))))
-  "Face used for level 3 headlines."
-  :group 'org-faces)
-
-(defface org-level-4   ;; originally copied from font-lock-comment-face
-  (org-compatible-face 'outline-4
-    '((((class color) (min-colors 88) (background light)) (:foreground "Firebrick"))
-      (((class color) (min-colors 88) (background dark))  (:foreground "chocolate1"))
-      (((class color) (min-colors 16) (background light)) (:foreground "red"))
-      (((class color) (min-colors 16) (background dark))  (:foreground "red1"))
-      (((class color) (min-colors 8) (background light))  (:foreground "red" :bold t))
-      (((class color) (min-colors 8) (background dark))   (:foreground "red" :bold t))
-      (t (:bold t))))
-  "Face used for level 4 headlines."
-  :group 'org-faces)
-
-(defface org-level-5 ;; originally copied from font-lock-type-face
-  (org-compatible-face 'outline-5
-    '((((class color) (min-colors 16) (background light)) (:foreground "ForestGreen"))
-      (((class color) (min-colors 16) (background dark)) (:foreground "PaleGreen"))
-      (((class color) (min-colors 8)) (:foreground "green"))))
-  "Face used for level 5 headlines."
-  :group 'org-faces)
-
-(defface org-level-6 ;; originally copied from font-lock-constant-face
-  (org-compatible-face 'outline-6
-    '((((class color) (min-colors 16) (background light)) (:foreground "CadetBlue"))
-      (((class color) (min-colors 16) (background dark)) (:foreground "Aquamarine"))
-      (((class color) (min-colors 8)) (:foreground "magenta"))))
-  "Face used for level 6 headlines."
-  :group 'org-faces)
-
-(defface org-level-7 ;; originally copied from font-lock-builtin-face
-  (org-compatible-face 'outline-7
-    '((((class color) (min-colors 16) (background light)) (:foreground "Orchid"))
-      (((class color) (min-colors 16) (background dark)) (:foreground "LightSteelBlue"))
-      (((class color) (min-colors 8)) (:foreground "blue"))))
-  "Face used for level 7 headlines."
-  :group 'org-faces)
-
-(defface org-level-8 ;; originally copied from font-lock-string-face
-  (org-compatible-face 'outline-8
-    '((((class color) (min-colors 16) (background light)) (:foreground "RosyBrown"))
-      (((class color) (min-colors 16) (background dark)) (:foreground "LightSalmon"))
-      (((class color) (min-colors 8)) (:foreground "green"))))
-  "Face used for level 8 headlines."
-  :group 'org-faces)
-
-(defface org-special-keyword ;; 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 special keywords."
-  :group 'org-faces)
-
-(defface org-drawer ;; originally copied from font-lock-function-name-face
-  (org-compatible-face nil
-    '((((class color) (min-colors 88) (background light)) (:foreground "Blue1"))
-      (((class color) (min-colors 88) (background dark)) (:foreground "LightSkyBlue"))
-      (((class color) (min-colors 16) (background light)) (:foreground "Blue"))
-      (((class color) (min-colors 16) (background dark)) (:foreground "LightSkyBlue"))
-      (((class color) (min-colors 8)) (:foreground "blue" :bold t))
-      (t (:bold t))))
-  "Face used for drawers."
-  :group 'org-faces)
-
-(defface org-property-value nil
-  "Face used for the value of a property."
-  :group 'org-faces)
-
-(defface org-column
-  (org-compatible-face nil
-    '((((class color) (min-colors 16) (background light))
-       (:background "grey90" :weight normal :slant normal :strike-through nil
-		    :underline nil))
-      (((class color) (min-colors 16) (background dark))
-       (:background "grey30" :weight normal :slant normal :strike-through nil
-		    :underline nil))
-      (((class color) (min-colors 8))
-       (:background "cyan" :foreground "black"
-		    :weight normal :slant normal :strike-through nil
-		    :underline nil))
-      (t (:inverse-video t))))
-  "Face for column display of entry properties.
-This is actually only part of the face definition for the text in column view.
-The following faces apply, with this priority.
-
-1. The color of the reference face.  This is normally the level fact that
-   is used in the outline.  In agenda-mode, it will be the face of the
-   first character in the line.  The color is explicitly retained to
-   make sure that the column line still looks a bit like the structure
-   line it is masking.
-
-2. The `org-column' face.
-
-3. The remaining properties of the reference face.
-
-Since column view works by putting overlays with a display property
-over individual characters in the buffer, the face of the underlining
-character (this might for example be the a TODO keyword) might still
-shine through in some properties.  So when your column view looks
-funny, with \"random\" colors, weight, strike-through, try to explicitly
-set the properties in the `org-column' face.  For example, set
-:underline to nil, or the :slant to `normal'.
-
-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' in Org's contrib/ directory for details."
-  :group 'org-faces)
-
-(defface org-column-title
-  (org-compatible-face nil
-    '((((class color) (min-colors 16) (background light))
-       (:background "grey90" :underline t :weight bold))
-      (((class color) (min-colors 16) (background dark))
-       (:background "grey30" :underline t :weight bold))
-      (((class color) (min-colors 8))
-       (:background "cyan" :foreground "black" :underline t :weight bold))
-      (t (:inverse-video t))))
-  "Face for column display of entry properties."
-  :group 'org-faces)
-
-(defface org-agenda-column-dateline
-  (org-compatible-face 'org-column
-    '((t nil)))
-  "Face used in agenda column view for datelines with summaries."
-  :group 'org-faces)
-
-(defface org-warning
-  (org-compatible-face 'font-lock-warning-face
-    '((((class color) (min-colors 16) (background light)) (:foreground "Red1" :bold t))
-      (((class color) (min-colors 16) (background dark))  (:foreground "Pink" :bold t))
-      (((class color) (min-colors 8)  (background light)) (:foreground "red"  :bold t))
-      (((class color) (min-colors 8)  (background dark))  (:foreground "red"  :bold t))
-      (t (:bold t))))
-  "Face for deadlines and TODO keywords."
-  :group 'org-faces)
-
-(defface org-archived    ; similar to shadow
-  (org-compatible-face 'shadow
-    '((((class color grayscale) (min-colors 88) (background light))
-       (:foreground "grey50"))
-      (((class color grayscale) (min-colors 88) (background dark))
-       (:foreground "grey70"))
-      (((class color) (min-colors 8) (background light))
-       (:foreground "green"))
-      (((class color) (min-colors 8) (background dark))
-       (:foreground "yellow"))))
-  "Face for headline with the ARCHIVE tag."
-  :group 'org-faces)
-
-(defface org-link
-  (org-compatible-face 'link
-    '((((class color) (background light)) (:foreground "Purple" :underline t))
-      (((class color) (background dark)) (:foreground "Cyan" :underline t))
-      (t (:underline t))))
-  "Face for links."
-  :group 'org-faces)
-
-(defface org-footnote
-  '((((class color) (background light)) (:foreground "Purple" :underline t))
-    (((class color) (background dark)) (:foreground "Cyan" :underline t))
-    (t (:underline t)))
-  "Face for footnotes."
-  :group 'org-faces)
-
-(defface org-ellipsis
-  '((((class color) (background light)) (:foreground "DarkGoldenrod" :underline t))
-    (((class color) (background dark)) (:foreground "LightGoldenrod" :underline t))
-    (t (:strike-through t)))
-  "Face for the ellipsis in folded text."
-  :group 'org-faces)
-
-(defface org-target
-  '((((class color) (background light)) (:underline t))
-    (((class color) (background dark)) (:underline t))
-    (t (:underline t)))
-  "Face for link targets."
-  :group 'org-faces)
-
-(defface org-date
-  '((((class color) (background light)) (:foreground "Purple" :underline t))
-    (((class color) (background dark)) (:foreground "Cyan" :underline t))
-    (t (:underline t)))
-  "Face for date/time stamps."
-  :group 'org-faces)
-
-(defface org-date-selected
-  (org-compatible-face nil
-    '((((class color) (min-colors 16) (background light)) (:foreground "Red1" :inverse-video t))
-      (((class color) (min-colors 16) (background dark))  (:foreground "Pink" :inverse-video t))
-      (((class color) (min-colors 8)  (background light)) (:foreground "red"  :inverse-video t))
-      (((class color) (min-colors 8)  (background dark))  (:foreground "red"  :inverse-video t))
-      (t (:inverse-video t))))
-  "Face for highlighting the calendar day when using `org-read-date'.
-Using a bold face here might cause discrepancies while displaying the
-calendar."
-  :group 'org-faces)
-
-(defface org-sexp-date
-  '((((class color) (background light)) (:foreground "Purple"))
-    (((class color) (background dark)) (:foreground "Cyan"))
-    (t (:underline t)))
-  "Face for diary-like sexp date specifications."
-  :group 'org-faces)
-
-(defface org-tag
-  '((t (:bold t)))
-  "Default face for tags.
-Note that the variable `org-tag-faces' can be used to overrule this face for
-specific tags."
-  :group 'org-faces)
-
-(defface org-list-dt
-  '((t (:bold t)))
-  "Default face for definition terms in lists."
-  :group 'org-faces)
-
-(defface org-todo ; font-lock-warning-face
-  (org-compatible-face nil
-    '((((class color) (min-colors 16) (background light)) (:foreground "Red1" :bold t))
-      (((class color) (min-colors 16) (background dark))  (:foreground "Pink" :bold t))
-      (((class color) (min-colors 8)  (background light)) (:foreground "red"  :bold t))
-      (((class color) (min-colors 8)  (background dark))  (:foreground "red"  :bold t))
-      (t (:inverse-video t :bold t))))
-  "Face for TODO keywords."
-  :group 'org-faces)
-
-(defface org-done ;; originally copied from font-lock-type-face
-  (org-compatible-face nil
-    '((((class color) (min-colors 16) (background light)) (:foreground "ForestGreen" :bold t))
-      (((class color) (min-colors 16) (background dark)) (:foreground "PaleGreen" :bold t))
-      (((class color) (min-colors 8)) (:foreground "green"))
-      (t (:bold t))))
-  "Face used for todo keywords that indicate DONE items."
-  :group 'org-faces)
-
-(defface org-agenda-done ;; originally copied from font-lock-type-face
-  (org-compatible-face nil
-    '((((class color) (min-colors 16) (background light)) (:foreground "ForestGreen"))
-      (((class color) (min-colors 16) (background dark)) (:foreground "PaleGreen"))
-      (((class color) (min-colors 8)) (:foreground "green"))
-      (t (:bold nil))))
-  "Face used in agenda, to indicate lines switched to DONE.
-This face is used to de-emphasize items that where brightly colored in the
-agenda because they were things to do, or overdue.  The DONE state itself
-is of course immediately visible, but for example a passed deadline is
-\(by default) very bright read.  This face could be simply the default face
-of the frame, for example."
-  :group 'org-faces)
-
-(defface org-headline-done ;; originally copied from font-lock-string-face
-  (org-compatible-face nil
-    '((((class color) (min-colors 16) (background light)) (:foreground "RosyBrown"))
-      (((class color) (min-colors 16) (background dark)) (:foreground "LightSalmon"))
-      (((class color) (min-colors 8)  (background light)) (:bold nil))))
-  "Face used to indicate that a headline is DONE.
-This face is only used if `org-fontify-done-headline' is set.  If applies
-to the part of the headline after the DONE keyword."
-  :group 'org-faces)
-
-(defcustom org-faces-easy-properties
-  '((todo . :foreground) (tag . :foreground) (priority . :foreground))
-  "The property changes by easy faces.
-This is an alist, the keys show the area of application, the values
-can be `:foreground' or `:background'.  A color string for special
-keywords will then be interpreted as either foreground or background
-color."
-  :group 'org-faces
-  :group 'org-todo
-  :version "24.1"
-  :type '(repeat
-	  (cons (choice (const todo) (const tag) (const priority))
-		(choice (const :foreground) (const :background)))))
-
-(defcustom org-todo-keyword-faces nil
-  "Faces for specific TODO keywords.
-This is a list of cons cells, with TODO keywords in the car
-and faces in the cdr.  The face can be a symbol, a color
-as a string (in which case the rest is inherited from the `org-todo' face),
-or a property list of attributes, like
-   (:foreground \"blue\" :weight bold :underline t).
-If it is a color string, the variable `org-faces-easy-properties'
-determines if it is a foreground or a background color."
-  :group 'org-faces
-  :group 'org-todo
-  :type '(repeat
-	  (cons
-	   (string :tag "Keyword")
-	   (choice :tag "Face   "
-		   (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
-and faces in the cdr.  The face can be a symbol, a color as
-as a string, or a property list of attributes, like
-    (:foreground \"blue\" :weight bold :underline t).
-If it is a color string, the variable `org-faces-easy-properties'
-determines if it is a foreground or a background color."
-  :group 'org-faces
-  :group 'org-todo
-  :type '(repeat
-	  (cons
-	   (character :tag "Priority")
-	   (choice    :tag "Face    "
-		      (string :tag "Color")
-		      (sexp :tag "Face")))))
-
-(defvar org-tags-special-faces-re nil)
-(defun org-set-tag-faces (var value)
-  (set var value)
-  (if (not value)
-      (setq org-tags-special-faces-re nil)
-    (setq org-tags-special-faces-re
-	  (concat ":\\(" (mapconcat 'car value "\\|") "\\):"))))
-
-(defface org-checkbox
-  (org-compatible-face 'bold
-    '((t (:bold t))))
-  "Face for checkboxes."
-  :group 'org-faces)
-
-(defface org-checkbox-statistics-todo
-  '((t (:inherit org-todo)))
-  "Face used for unfinished checkbox statistics."
-  :group 'org-faces)
-
-(defface org-checkbox-statistics-done
-  '((t (:inherit org-done)))
-  "Face used for finished checkbox statistics."
-  :group 'org-faces)
-
-(defcustom org-tag-faces nil
-  "Faces for specific tags.
-This is a list of cons cells, with tags in the car and faces in the cdr.
-The face can be a symbol, a foreground color (in which case the rest is
-inherited from the `org-tag' face) or a property list of attributes,
-like (:foreground \"blue\" :weight bold :underline t).
-If you set this variable through customize, it will immediately be effective
-in new buffers and in modified lines.
-If you set it with Lisp, a restart of Emacs is required to activate the
-changes."
-  :group 'org-faces
-  :group 'org-tags
-  :set 'org-set-tag-faces
-  :type '(repeat
-	  (cons
-	   (string :tag "Tag ")
-	   (choice :tag "Face"
-		   (string :tag "Foreground color")
-		   (sexp :tag "Face")))))
-
-(defface org-table ;; originally copied from font-lock-function-name-face
-  (org-compatible-face nil
-    '((((class color) (min-colors 88) (background light)) (:foreground "Blue1"))
-      (((class color) (min-colors 88) (background dark)) (:foreground "LightSkyBlue"))
-      (((class color) (min-colors 16) (background light)) (:foreground "Blue"))
-      (((class color) (min-colors 16) (background dark)) (:foreground "LightSkyBlue"))
-      (((class color) (min-colors 8)  (background light)) (:foreground "blue"))
-      (((class color) (min-colors 8)  (background dark)))))
-  "Face used for tables."
-  :group 'org-faces)
-
-(defface org-formula
-  (org-compatible-face nil
-    '((((class color) (min-colors 88) (background light)) (:foreground "Firebrick"))
-      (((class color) (min-colors 88) (background dark)) (:foreground "chocolate1"))
-      (((class color) (min-colors 8)  (background light)) (:foreground "red"))
-      (((class color) (min-colors 8)  (background dark)) (:foreground "red"))
-      (t (:bold t :italic t))))
-  "Face for formulas."
-  :group 'org-faces)
-
-(defface org-code
-  (org-compatible-face 'shadow
-    '((((class color grayscale) (min-colors 88) (background light))
-       (:foreground "grey50"))
-      (((class color grayscale) (min-colors 88) (background dark))
-       (:foreground "grey70"))
-      (((class color) (min-colors 8) (background light))
-       (:foreground "green"))
-      (((class color) (min-colors 8) (background dark))
-       (:foreground "yellow"))))
-  "Face for fixed-width text like code snippets."
-  :group 'org-faces
-  :version "22.1")
-
-(defface org-meta-line
-  (org-compatible-face 'font-lock-comment-face nil)
-  "Face for meta lines starting with \"#+\"."
-  :group 'org-faces
-  :version "22.1")
-
-(defface org-document-title
-  '((((class color) (background light)) (:foreground "midnight blue" :weight bold))
-    (((class color) (background dark)) (:foreground "pale turquoise" :weight bold))
-    (t (:weight bold)))
-  "Face for document title, i.e. that which follows the #+TITLE: keyword."
-  :group 'org-faces)
-
-(defface org-document-info
-  '((((class color) (background light)) (:foreground "midnight blue"))
-    (((class color) (background dark)) (:foreground "pale turquoise"))
-    (t nil))
-  "Face for document date, author and email; i.e. that which
-follows a #+DATE:, #+AUTHOR: or #+EMAIL: keyword."
-  :group 'org-faces)
-
-(defface org-document-info-keyword
-  (org-compatible-face 'shadow
-    '((((class color grayscale) (min-colors 88) (background light))
-       (:foreground "grey50"))
-      (((class color grayscale) (min-colors 88) (background dark))
-       (:foreground "grey70"))
-      (((class color) (min-colors 8) (background light))
-       (:foreground "green"))
-      (((class color) (min-colors 8) (background dark))
-       (:foreground "yellow"))))
-  "Face for #+TITLE:, #+AUTHOR:, #+EMAIL: and #+DATE: keywords."
-  :group 'org-faces)
-
-(defface org-block
-  (org-compatible-face 'shadow
-    '((((class color grayscale) (min-colors 88) (background light))
-       (:foreground "grey50"))
-      (((class color grayscale) (min-colors 88) (background dark))
-       (:foreground "grey70"))
-      (((class color) (min-colors 8) (background light))
-       (:foreground "green"))
-      (((class color) (min-colors 8) (background dark))
-       (:foreground "yellow"))))
-  "Face text in #+begin ... #+end blocks."
-  :group 'org-faces
-  :version "22.1")
-
-(defface org-block-begin-line
-  '((t (:inherit org-meta-line)))
-  "Face used for the line delimiting the begin of source blocks."
-  :group 'org-faces)
-
-(defface org-block-end-line
-  '((t (:inherit org-block-begin-line)))
-  "Face used for the line delimiting the end of source blocks."
-  :group 'org-faces)
-
-(defface org-verbatim
-  (org-compatible-face 'shadow
-    '((((class color grayscale) (min-colors 88) (background light))
-       (:foreground "grey50" :underline t))
-      (((class color grayscale) (min-colors 88) (background dark))
-       (:foreground "grey70" :underline t))
-      (((class color) (min-colors 8) (background light))
-       (:foreground "green" :underline t))
-      (((class color) (min-colors 8) (background dark))
-       (:foreground "yellow" :underline t))))
-  "Face for fixed-with text like code snippets."
-  :group 'org-faces
-  :version "22.1")
-
-(defface org-quote
-  '((t (:inherit org-block)))
-  "Face for #+BEGIN_QUOTE ... #+END_QUOTE blocks."
-  :group 'org-faces)
-
-(defface org-verse
-  '((t (:inherit org-block)))
-  "Face for #+BEGIN_VERSE ... #+END_VERSE blocks."
-  :group 'org-faces)
-
-(defcustom org-fontify-quote-and-verse-blocks nil
-  "Non-nil means, add a special face to #+begin_quote and #+begin_verse block.
-When nil, format these as normal Org.  This is the default, because the
-content of these blocks will still be treated as Org syntax."
-  :group 'org-faces
-  :version "24.1"
-  :type 'boolean)
-
-(defface org-clock-overlay ;; copied from secondary-selection
-  (org-compatible-face nil
-    '((((class color) (min-colors 88) (background light))
-       (:background "LightGray" :foreground "black"))
-      (((class color) (min-colors 88) (background dark))
-       (:background "SkyBlue4" :foreground "white"))
-      (((class color) (min-colors 16) (background light))
-       (:background "gray" :foreground "black"))
-      (((class color) (min-colors 16) (background dark))
-       (:background "SkyBlue4" :foreground "white"))
-      (((class color) (min-colors 8))
-       (:background "cyan" :foreground "black"))
-      (t (:inverse-video t))))
-  "Basic face for displaying the secondary selection."
-  :group 'org-faces)
-
-(defface org-agenda-structure ;; originally copied from font-lock-function-name-face
-  (org-compatible-face nil
-    '((((class color) (min-colors 88) (background light)) (:foreground "Blue1"))
-      (((class color) (min-colors 88) (background dark)) (:foreground "LightSkyBlue"))
-      (((class color) (min-colors 16) (background light)) (:foreground "Blue"))
-      (((class color) (min-colors 16) (background dark)) (:foreground "LightSkyBlue"))
-      (((class color) (min-colors 8)) (:foreground "blue" :bold t))
-      (t (:bold t))))
-  "Face used in agenda for captions and dates."
-  :group 'org-faces)
-
-(defface org-agenda-date
-  '((t (:inherit org-agenda-structure)))
-  "Face used in agenda for normal days."
-  :group 'org-faces)
-
-(defface org-agenda-date-today
-  '((t (:inherit org-agenda-date :weight bold :italic t)))
-  "Face used in agenda for today."
-  :group 'org-faces)
-
-(defface org-agenda-clocking
-  '((t (:inherit secondary-selection)))
-  "Face marking the current clock item in the agenda."
-  :group 'org-faces)
-
-(defface org-agenda-date-weekend
-  '((t (:inherit org-agenda-date :weight bold)))
-  "Face used in agenda for weekend days.
-
-See the variable `org-agenda-weekend-days' for a definition of
-which days belong to the weekend."
-  :group 'org-faces)
-
-(defface org-scheduled
-  (org-compatible-face nil
-    '((((class color) (min-colors 88) (background light)) (:foreground "DarkGreen"))
-      (((class color) (min-colors 88) (background dark)) (:foreground "PaleGreen"))
-      (((class color) (min-colors 8)) (:foreground "green"))
-      (t (:bold t :italic t))))
-  "Face for items scheduled for a certain day."
-  :group 'org-faces)
-
-(defface org-scheduled-today
-  (org-compatible-face nil
-    '((((class color) (min-colors 88) (background light)) (:foreground "DarkGreen"))
-      (((class color) (min-colors 88) (background dark)) (:foreground "PaleGreen"))
-      (((class color) (min-colors 8)) (:foreground "green"))
-      (t (:bold t :italic t))))
-  "Face for items scheduled for a certain day."
-  :group 'org-faces)
-
-(defface org-agenda-dimmed-todo-face
-  '((((background light)) (:foreground "grey50"))
-    (((background dark)) (:foreground "grey50")))
-  "Face used to dim blocked tasks in the agenda."
-  :group 'org-faces)
-
-(defface org-scheduled-previously
-  (org-compatible-face nil
-    '((((class color) (min-colors 88) (background light)) (:foreground "Firebrick"))
-      (((class color) (min-colors 88) (background dark)) (:foreground "chocolate1"))
-      (((class color) (min-colors 8)  (background light)) (:foreground "red"))
-      (((class color) (min-colors 8)  (background dark)) (:foreground "red" :bold t))
-      (t (:bold t))))
-  "Face for items scheduled previously, and not yet done."
-  :group 'org-faces)
-
-(defface org-upcoming-deadline
-  (org-compatible-face nil
-    '((((class color) (min-colors 88) (background light)) (:foreground "Firebrick"))
-      (((class color) (min-colors 88) (background dark)) (:foreground "chocolate1"))
-      (((class color) (min-colors 8)  (background light)) (:foreground "red"))
-      (((class color) (min-colors 8)  (background dark)) (:foreground "red" :bold t))
-      (t (:bold t))))
-  "Face for items scheduled previously, and not yet done."
-  :group 'org-faces)
-
-(defcustom org-agenda-deadline-faces
-  '((1.0 . org-warning)
-    (0.5 . org-upcoming-deadline)
-    (0.0 . default))
-  "Faces for showing deadlines in the agenda.
-This is a list of cons cells.  The cdr of each cell is a face to be used,
-and it can also just be like '(:foreground \"yellow\").
-Each car is a fraction of the head-warning time that must have passed for
-this the face in the cdr to be used for display.  The numbers must be
-given in descending order.  The head-warning time is normally taken
-from `org-deadline-warning-days', but can also be specified in the deadline
-timestamp itself, like this:
-
-   DEADLINE: <2007-08-13 Mon -8d>
-
-You may use d for days, w for weeks, m for months and y for years.  Months
-and years will only be treated in an approximate fashion (30.4 days for a
-month and 365.24 days for a year)."
-  :group 'org-faces
-  :group 'org-agenda-daily/weekly
-  :type '(repeat
-	  (cons
-	   (number :tag "Fraction of head-warning time passed")
-	   (sexp :tag "Face"))))
-
-(defface org-agenda-restriction-lock
-  (org-compatible-face nil
-    '((((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)
-  "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 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
-  (org-compatible-face nil
-    '((((class color) (min-colors 16) (background light)) (:foreground "DarkGoldenrod"))
-      (((class color) (min-colors 16) (background dark)) (:foreground "LightGoldenrod"))
-      (((class color) (min-colors 8)) (:foreground "yellow" :weight light))))
-  "Face used for time grids."
-  :group 'org-faces)
-
-(defface org-agenda-current-time
-  '((t (:inherit org-time-grid)))
-  "Face used to show the current time in the time grid."
-  :group 'org-faces)
-
-(defface org-agenda-diary
-  (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)
-  "Face used to show events and appointments in the agenda."
-  :group 'org-faces)
-
-(defface org-agenda-calendar-sexp
-  (org-compatible-face 'default nil)
-  "Face used to show events computed from a S-expression."
-  :group 'org-faces)
-
-(defconst org-level-faces
-  '(org-level-1 org-level-2 org-level-3 org-level-4
-		org-level-5 org-level-6 org-level-7 org-level-8
-		))
-
-(defcustom org-n-level-faces (length org-level-faces)
-  "The number of different faces to be used for headlines.
-Org-mode defines 8 different headline faces, so this can be at most 8.
-If it is less than 8, the level-1 face gets re-used for level N+1 etc."
-  :type 'integer
-  :group 'org-faces)
-
-(defcustom org-cycle-level-faces t
-  "Non-nil means level styles cycle after level `org-n-level-faces'.
-Then so level org-n-level-faces+1 is styled like level 1.
-If nil, then all levels >=org-n-level-faces are styled like
-level org-n-level-faces"
-  :group 'org-appearance
-  :group 'org-faces
-  :version "24.1"
-  :type 'boolean)
-
-(defface org-latex-and-related
-  (let ((font (cond ((assq :inherit custom-face-attributes)
-		     '(:inherit underline))
-		    (t '(:underline t)))))
-    `((((class grayscale) (background light))
-       (:foreground "DimGray" ,@font))
-      (((class grayscale) (background dark))
-       (:foreground "LightGray" ,@font))
-      (((class color) (background light))
-       (:foreground "SaddleBrown"))
-      (((class color) (background dark))
-       (:foreground "burlywood"))
-      (t (,@font))))
-  "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"))
-
-(defface org-mode-line-clock
-  '((t (:inherit mode-line)))
-  "Face used for clock display in mode line."
-  :group 'org-faces)
-
-(defface org-mode-line-clock-overrun
-  '((t (:inherit mode-line :background "red")))
-  "Face used for clock display for overrun tasks in mode line."
-  :group 'org-faces)
-
-(provide 'org-faces)
-
-;;; org-faces.el ends here
diff --git a/elpa/org-plus-contrib-20150831/org-index.el b/elpa/org-plus-contrib-20150831/org-index.el
deleted file mode 100644
index 52bd2fc4..00000000
--- a/elpa/org-plus-contrib-20150831/org-index.el
+++ /dev/null
@@ -1,2497 +0,0 @@
-;;; org-index.el --- A personal index for org and beyond
-
-;; Copyright (C) 2011-2015 Free Software Foundation, Inc.
-
-;; Author: Marc Ihm 
-;; Version: 4.2.1
-;; Keywords: outlines index
-
-;; This file is not part of GNU Emacs.
-
-;;; License:
-
-;; 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, 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 GNU Emacs.  If not, see .
-
-;;; Commentary:
-
-;; Purpose:
-;;
-;;  Fast search for selected org headings and things outside of org.
-;;
-;;  This package creates and updates an index table of headings or
-;;  keywords, references and ids, where each line points to a heading
-;;  within org or references something outside.  This table is sorted by
-;;  usage count, so that frequently used lines appear among the first
-;;  search results.
-;;
-;;  References are essentially small numbers (e.g. 'R237' or '--455--'), as
-;;  created by this package; they are well suited to be used outside of
-;;  org, e.g. in folder names, issue trackers or on printed documents.
-;;
-;;  On first invocation org-index will guide you to create a dedicated node
-;;  for its index table and its configuration flags.
-;;
-;;  For basic usage, subcommands 'add' and 'occur' are most important.
-;;
-;;
-;; Setup:
-;;
-;;  - Add these lines to your .emacs:
-;;
-;;    (require 'org-index)
-;;    (org-index-default-keybindings)   ; optional
-;;
-;;  - Restart your Emacs to make these lines effective.
-;;
-;;  - Invoke `org-index', which will assist in creating your index
-;;    table.  The variable org-index-id will be persisted within your
-;;    customization file (typically .emacs).
-;;
-;;
-;; Further reading:
-;;
-;;  See the documentation of `org-index', which can also be read
-;;  by invoking `org-index' and choosing the help-command.
-;;
-;;
-;; Updates:
-;;
-;;  The latest tested version of this file can always be found at:
-;;
-;;    http://orgmode.org/cgit.cgi/org-mode.git/plain/contrib/lisp/org-index.el
-
-;;; Change Log:
-
-;;   [2015-03-18 We] Version 4.2.1
-;;   - No garbage in kill-ring
-;;   - No recentering after add
-;;
-;;   [2015-03-08 Su] Version 4.2.0
-;;   - Reference numbers for subcommands can be passed as a prefix argument
-;;   - Renamed subcommand 'point' to 'ping'
-;;   - New variable org-index-default-keybindings-list with a list of
-;;     default keybindings for org-index-default-keybindings
-;;   - Added new column level
-;;   - removed flags get-category-on-add and get-heading-on-add
-;;
-;;   [2015-03-05 Th] Version 4.1.1 and 4.1.2
-;;   - org-mark-ring is now used more consistently
-;;   - Bugfix when going to a heading by ref
-;;
-;;   [2015-02-26 Th] Version 4.0.0 and 4.1.0:
-;;   - Removed command "leave"; rather go back with org-mark-ring-goto
-;;   - Property "org-index-ref" is no longer used or needed
-;;   - Renamed column "link" to "id"
-;;   - Added maintainance options to find duplicate rows, to check ids,
-;;     update index or remove property org-index-ref from nodes
-;;   - New command point
-;;   - Shortened versin history
-;;
-;;   [2014-12-07 Sa] to [2015-01-31 Sa] Version 3.0.0 to 3.2.0:
-;;   - Complete sorting of index only occurs in idle-timer
-;;   - New command "maintain"  with some subcommands
-;;   - Rewrote command "occur" with overlays in an indirect buffer
-;;   - introduced variable org-index-version
-;;   - Command "add" updates index, if node is already present
-;;   - New commands "add" and "delete" to easily add and remove
-;;     the current node to or from your index.
-;;   - New command "example" to create an example index.
-;;   - Moved flags to a list within the same node as the index table;
-;;     this breaks compatibility to prior versions of the package.
-;;   - Several new flags that are explained within index node.
-;;   - Removed commands "reuse", "missing", "put", "goto",
-;;     "update", "link", "fill", "unhighlight"
-;;   - New function `org-index-default-keybindings'
-;;
-;;   [2012-12-07 Fr] to [2014-04-26 Sa] Version 2.0.0 to 2.4.3:
-;;   - New functions org-index-new-line and org-index-get-line
-;;     offer access to org-index from other lisp programs
-;;   - Regression tests with ert
-;;   - Renamed from "org-favtable" to "org-index"
-;;   - Added an assistant to set up the index table
-;;   - occur is now incremental, searching as you type
-;;   - Integrated with org-mark-ring-goto
-;;   - Added full support for ids
-;;   - Renamed the package from "org-reftable" to "org-favtable"
-;;   - Additional columns are required (e.g. "link"). Error messages will
-;;     guide you
-;;   - Ask user explicitly, which command to invoke
-;;   - Renamed the package from "org-refer-by-number" to "org-reftable"
-;;
-;;   [2011-12-10 Sa] to [2012-09-22 Sa] Version Version 1.2.0 to 1.5.0:
-;;    - New command "sort" to sort a buffer or region by reference number
-;;    - New commands "highlight" and "unhighlight" to mark references
-;;    - New command "head" to find a headline with a reference number
-;;    - New commands occur and multi-occur
-;;    - Started this Change Log
-
-;;; Code:
-
-(require 'org-table)
-(require 'cl)
-
-(defcustom org-index-id nil
-  "Id of the Org-mode node, which contains the index table."
-  :group 'org
-  :group 'org-index)
-
-;; Version of this package
-(defvar org-index-version "4.2.1" "Version of `org-index', format is major.minor.bugfix, where \"major\" is a change in index-table and \"minor\" are new features.")
-
-;; Variables to hold the configuration of the index table
-(defvar org-index--maxref nil "Maximum number from reference table (e.g. '153').")
-(defvar org-index--head nil "Any header before number (e.g. 'R').")
-(defvar org-index--tail nil "Tail after number (e.g. '}' or ')'.")
-(defvar org-index--numcols nil "Number of columns in index table.")
-(defvar org-index--ref-regex nil "Regular expression to match a reference.")
-(defvar org-index--ref-format nil "Format, that can print a reference.")
-(defvar org-index--columns nil "Columns of index-table.")
-(defvar org-index--special-columns nil "Columns with flags, that may appear only once.")
-(defvar org-index--flagged-columns nil "Columns with flags, that may appear multiple times.")
-(defvar org-index--buffer nil "Buffer of index table.")
-(defvar org-index--point nil "Position at start of headline of index table.")
-(defvar org-index--below-hline nil "Position of first cell in first line below hline.")
-(defvar org-index--headings nil "Headlines of index-table as a string.")
-(defvar org-index--headings-visible nil "Visible part of headlines of index-table as a string.")
-(defvar org-index--keymap nil "Keymap for shortcuts for some commands of `org-index'. Filled and activated by `org-index-default-keybings'.")
-
-;; Variables to hold context and state
-(defvar org-index--last-ref nil "Last reference created or visited.")
-(defvar org-index--category-before nil "Category of node before.")
-(defvar org-index--active-region nil "Active region, initially.  I.e. what has been marked.")
-(defvar org-index--below-cursor nil "Word below cursor.")
-(defvar org-index--within-node nil "True, if we are within node of the index table.")
-(defvar org-index--message-text nil "Text that was issued as an explanation; helpful for regression tests.")
-(defvar org-index--occur-help-text nil "Text for help in occur buffer.")
-(defvar org-index--occur-help-overlay nil "Overlay for help in occur buffer.")
-(defvar org-index--occur-stack nil "Stack with overlays for hiding lines.")
-(defvar org-index--occur-tail-overlay nil "Overlay to cover invisible lines.")
-(defvar org-index--last-sort nil "Last column, the index has been sorted after.")
-(defvar org-index--sort-timer nil "Timer to sort index in correct order.")
-(defvar org-index--aligned nil "Remember for this Emacs session, if table has been aligned at least once.")
-
-;; static information for this program package
-(defconst org-index--commands '(occur add delete head ping enter ref help example sort multi-occur highlight maintain) "List of commands available.")
-(defconst org-index--required-flags '(sort) "Flags that are required.")
-(defconst org-index--single-flags '(sort point-on-add yank-after-add shift-ref-and-date-on-add) "Flags, that may only appear once; these can appear as special-columns.")
-(defconst org-index--multiple-flags '(edit-on-add) "Flags, that might appear multiple times.")
-(defconst org-index--all-flags (append org-index--single-flags org-index--multiple-flags) "All flags.")
-(defconst org-index--required-headings '(ref id created last-accessed count) "All required headings.")
-(defconst org-index--valid-headings (append org-index--required-headings '(keywords category level)) "All valid headings.")
-(defconst org-index--occur-buffer-name "*org-index-occur*" "Name of occur buffer.")
-(defconst org-index--sort-idle-delay 300 "Delay in seconds after which buffer will sorted.")
-(defvar org-index-default-keybindings-list '(("a" . 'add) ("i " . nil) ("o" . 'occur) ("a" . 'add) ("d" . 'delete) ("h" . 'head) ("e" . 'enter) ("p." . 'ping) ("r" . 'ref) ("?" . 'help)) "One-letter short cuts for selected subcommands of `org-index', put in effect by `org-index-default-keybindings'")
-(defconst org-index--sample-flags
-"
-  - columns-and-flags :: associate columns of index table with flags. Do not remove.
-    - ref
-      - yank-after-add
-    - category
-      - edit-on-add
-    - keywords
-      - edit-on-add
-      - point-on-add
-    - count
-      - sort
-    - last-accessed
-    - created
-    - id
-    - all-columns-explained :: All columns of the index table and their meaning.
-      - ref :: The reference number; will be generated automatically.
-      - id :: id of the node, that this line represents
-      - created :: When has this entry been created ?
-      - last-accessed :: When has this entry been accessed last ?
-      - count :: How many times has this entry been picked ?
-      - keywords :: Optional column, suggested to keep a list of keywords,
-        which may match your input during occur. While adding a line to your index,
-        this column will be filled with the nodes heading.
-      - category :: (optional) column to store the category of newly added nodes.
-      - level :: Nesting level of node
-      - Any name starting with a dot (`.') :: No predefined meaning,
-        depends on its flags.
-    - all-flags-explained :: All flags, that can be associated with columns.
-      - sort :: Sort whole table according to this column.
-      - yank-after-add :: This column will be yanked after picking this line during
-        occur.
-      - edit-on-add :: This field will be presented for editing, when adding
-        a new line to your index.
-      - point-on-add :: Point will land here, when adding a new line, e.g. with
-        command ref.
-      - shift-ref-and-date-on-add :: Remove leading reference and timestamp on add."
-"A sample string of flags.")
-
-
-(defmacro org-index--on (column value &rest body)
-  "Execute the forms in BODY with point on index line whose COLUMN is VALUE.
-The value returned is the value of the last form in BODY or nil,
-if VALUE cannot be found."
-  (declare (indent 2) (debug t))
-  (let ((pointvar (make-symbol "point")) ; avoid clash with same-named variables in body
-        (foundvar (make-symbol "found"))
-        (retvar (make-symbol "ret")))
-    `(save-current-buffer
-       (set-buffer org-index--buffer)
-       (setq ,pointvar (point))
-       (setq ,foundvar nil)
-       (setq ,retvar nil)
-
-       (setq ,foundvar (org-index--go ,column ,value))
-       (when ,foundvar
-         (setq ,retvar (progn ,@body)))
-       
-       (goto-char ,pointvar)
-       
-       ,retvar)))
-
-
-(defun org-index (&optional command search-ref arg)
-  "Fast search for selected org headings and things outside of org.
-
-This package creates and updates an index table of headings or
-keywords, references and ids, where each line points to a heading
-within org or references something outside.  This table is sorted by
-usage count, so that frequently used lines appear among the first
-search results.
-
-References are essentially small numbers (e.g. 'R237' or '--455--'), as
-created by this package; they are well suited to be used outside of
-org, e.g. in folder names, issue trackers or on printed documents.
-
-On first invocation `org-index' will guide you to create a dedicated node
-for its index table and its configuration flags.
-
-For basic usage, subcommands 'add' and 'occur' are most important.
-
-This is version 4.2.1 of org-index.el.
-\\
-The function `org-index' operates on a dedicated table, the index
-table, which lives within its own Org-mode node.  The table and
-its containing node will be created, when you first invoke
-`org-index'.  The node also contains a commented list, describing
-the columns of the index table and their associated flags.  The
-node is found through its id, which is stored within the variable
-`org-index-id'.
-
-
-The function `org-index' is the only interactive function of this
-package and its main entry point; it will present you with a list
-of subcommands to choose from:
-
-  occur: Incremental search, that shows matching lines from the
-    index table.  It is updated after every keystroke.  You may
-    enter a list of words seperated by space or comma (`,'), to
-    select lines that contain all of the given words.
-
-  add: Add the current node to your index, so that it can be
-    found through the subcommand \"occur\". Update index,
-    if node has already been present.
-
-  delete: Delete the current node from your index.
-
-  head: Ask for a reference number and search for this heading.
-
-  enter: Enter index table and maybe go to a specific reference;
-    use `org-mark-ring-goto' (\\[org-mark-ring-goto]) to go back.
-
-  ping: Echo line from index table for current node or first of
-    its ancestor from index.
-
-  ref: Create a new reference.
-
-  help: Show this text.
-
-  example: Create a temporary index, that will not be saved, but
-    may serve as an example.
-
-  sort: Sort lines in index, in region or buffer by contained
-    reference, or sort index by count, reference or last access.
-
-  multi-occur: Apply Emacs standard `multi-occur' operation on all
-    `org-mode' buffers to search for the given reference.
-
-  highlight: Highlight or unhiglight references in active region or buffer.
-     Call with prefix argument (`C-u') to remove highlights.
-
-  maintain: Offers some choices to check, update or fix your index.
-
-If you invoke `org-index' for the first time, an assistant will be
-invoked, that helps you to create your own, commented index.
-
-Use `org-index-default-keybindings' to establish convenient
-keyboard shortcuts.
-
-See the commented list of flags within your index node for ways to
-modify the behaviour of org-index.
-
-A numeric prefix argument is used as a reference number for
-commands, that need one (e.g. 'head').
-
-Optional arguments for use from elisp: COMMAND is a symbol naming
-the command to execute. SEARCH-REF specifies a reference to
-search for, if needed. ARG allows passing in a prefix argument
-as in interactive calls."
-
-  (interactive "i\ni\nP")
-
-  (let (search-id             ; id to search for
-        sort-what             ; sort what ?
-        kill-new-text         ; text that will be appended to kill ring
-        message-text)         ; text that will be issued as an explanation
-
-
-    ;;
-    ;; Initialize and parse
-    ;;
-
-    ;; creates index table, if necessary
-    (org-index--verify-id)
-
-    ;; Get configuration of index table
-    (org-index--parse-table)
-
-    ;; store context information
-    (org-index--retrieve-context)
-
-
-    ;;
-    ;; Arrange for proper sorting of index
-    ;;
-
-    ;; lets assume, that it has been sorted this way (we try hard to make sure)
-    (unless org-index--last-sort (setq org-index--last-sort (org-index--special-column 'sort)))
-    ;; rearrange for index beeing sorted into default sort order after 300 secs of idle time
-    (unless org-index--sort-timer
-      (setq org-index--sort-timer
-            (run-with-idle-timer org-index--sort-idle-delay t 'org-index--sort-silent)))
-
-
-    ;;
-    ;; Find out, what we are supposed to do
-    ;;
-
-    ;; check or read command
-    (if command
-        (unless (memq command org-index--commands)
-          (error "Unknown command '%s' passed as argument, valid choices are any of these symbols: %s"
-                 command (mapconcat 'symbol-name org-index--commands ",")))
-      (setq command (intern (org-completing-read
-                             "Please choose: "
-                             (mapcar 'symbol-name org-index--commands)))))
-
-
-    ;;
-    ;; Get search string, if required; process possible sources one after
-    ;; another (lisp argument, prefix argumen, user input).
-    ;;
-
-    ;; Try prefix, if no lisp argument given
-    (if (and (not search-ref)
-             (numberp arg))
-        (setq search-ref (format "%s%d%s" org-index--head arg org-index--tail)))
-    
-    ;; These actions really need a search string and may even prompt for it
-    (when (memq command '(enter head multi-occur))
-
-      ;; search from surrounding text ?
-      (unless search-ref
-        (if org-index--within-node
-
-            (if (org-at-table-p)
-                (setq search-ref (org-index--get-or-set-field 'ref)))
-          
-          (if (and org-index--below-cursor
-                   (string-match (concat "\\(" org-index--ref-regex "\\)")
-                                 org-index--below-cursor))
-              (setq search-ref (match-string 1 org-index--below-cursor)))))
-      
-      ;; If we still do not have a search string, ask user explicitly
-      (unless search-ref
-        (if (eq command 'enter)
-            (let ((r (org-index--read-search-for-enter)))
-              (setq search-ref (car r))
-              (setq search-id (cdr r)))
-          (setq search-ref (read-from-minibuffer "Search reference number: "))))
-
-      ;; Clean up search string
-      (when search-ref
-        (setq search-ref (org-trim search-ref))
-        (if (string-match "^[0-9]+$" search-ref)
-            (setq search-ref (concat org-index--head search-ref org-index--tail)))
-        (if (string= search-ref "") (setq search-ref nil)))
-
-      (if (and (not search-ref)
-               (not (eq command 'enter)))
-        (error "Command %s needs a reference number" command)))
-
-    
-    ;;
-    ;; Command sort needs to know in advance, what to sort for
-    ;;
-    
-    (when (eq command 'sort)
-      (setq sort-what (intern (org-completing-read "You may sort:\n  - index  : your index table by various columns\n  - region : the active region by contained reference\n  - buffer : the whole current buffer\nPlease choose what to sort: " (list "index" "region" "buffer") nil t))))
-    
-    
-    ;;
-    ;; Enter table
-    ;;
-
-    ;; Arrange for beeing able to return
-    (when (and (memq command '(occur head enter ref example sort maintain))
-               (not (string= (buffer-name) org-index--occur-buffer-name)))
-      (org-mark-ring-push))
-
-    ;; These commands will leave user in index table after they are finished
-    (when (or (memq command '(enter ref maintain))
-              (and (eq command 'sort)
-                   (eq sort-what 'index)))
-
-      (pop-to-buffer-same-window org-index--buffer)
-      (goto-char org-index--point)
-      (org-index--unfold-buffer))
-
-
-    ;;
-    ;; Actually do, what is requested
-    ;;
-
-    (cond
-
-
-     ((eq command 'help)
-
-      ;; bring up help-buffer for this function
-      (describe-function 'org-index))
-
-
-     ((eq command 'multi-occur)
-
-      ;; Construct list of all org-buffers
-      (let (buff org-buffers)
-        (dolist (buff (buffer-list))
-          (set-buffer buff)
-          (if (string= major-mode "org-mode")
-              (setq org-buffers (cons buff org-buffers))))
-
-        ;; Do multi-occur
-        (multi-occur org-buffers (org-index--make-guarded-search search-ref))
-
-        ;; Present results
-        (if (get-buffer "*Occur*")
-            (progn
-              (setq message-text (format "multi-occur for '%s'" search-ref))
-              (other-window 1)
-              (toggle-truncate-lines 1))
-          (setq message-text (format "Did not find '%s'" search-ref)))))
-
-
-     ((eq command 'add)
-
-      (let ((r (org-index--do-add-or-update)))
-        (setq message-text (car r))
-        (setq kill-new-text (cdr r))))
-
-
-     ((eq command 'delete)
-
-      (setq message-text (org-index--do-delete)))
-
-
-     ((eq command 'head)
-
-      (if (and org-index--within-node
-               (org-at-table-p))
-          (setq search-id (org-index--get-or-set-field 'id)))
-
-      (setq search-id (or search-id (org-index--id-from-ref search-ref))) 
-      (setq message-text
-            (if search-id
-                (org-index--do-head search-ref search-id)
-              (message "Current line has no id."))))
-
-
-     ((eq command 'enter)
-
-      (goto-char org-index--below-hline)
-
-      (setq message-text
-
-            (if search-ref
-                (if (org-index--go 'ref search-ref)
-                    (progn
-                      (org-index--update-current-line)
-                      (org-table-goto-column (org-index--column-num 'ref))
-                      (format "Found index line '%s'" search-ref))
-                  (format "Did not find index line with reference '%s'" search-ref))
-
-              (if search-id
-                  (if (org-index--go 'id search-id)
-                      (progn
-                        (org-index--update-current-line)
-                        (org-table-goto-column (org-index--column-num 'ref))
-                        (format "Found index line '%s'" (org-index--get-or-set-field 'ref)))
-                    (format "Did not find index line with id '%s'" search-id))
-
-                ;; simply go into table
-                (setq message-text "At index table"))))
-
-      (recenter))
-
-
-     ((eq command 'ping)
-
-      (let ((moved-up 0) id info reached-top)
-
-        (unless (string= major-mode "org-mode") (error "No node at point"))
-        ;; take id from current node or reference
-        (setq id (if search-ref
-                     (org-index--id-from-ref search-ref)
-                   (org-id-get)))
-
-        ;; move up until we find a node in index
-        (save-excursion
-          (outline-back-to-heading)
-          (while (not (or info
-                          reached-top))
-            (if id
-                (setq info (org-index--on 'id id
-                             (mapcar (lambda (x) (org-index--get-or-set-field x))
-                                     (list 'ref 'count 'created 'last-accessed 'category 'keywords 'ref)))))
-
-            (setq reached-top (= (org-outline-level) 1))
-
-            (unless (or info
-                        reached-top)
-              (outline-up-heading 1 t)
-              (incf moved-up))
-
-            (setq id (org-id-get))))
-        
-        (if info
-            (progn
-              (setq message-text
-                    (apply 'format
-                           (append (list "'%s'%shas been accessed %s times between %s and %s; category is '%s', keywords are '%s'"
-                                         (pop info)
-                                         (if (> moved-up 0) (format " (parent node, %d level up) " moved-up) " "))
-                                   info)))
-              (setq kill-new-text (car (last info))))
-          (setq message-text "Neither this node nor any of its parents is part of index"))))
-
-
-     ((eq command 'occur)
-
-      (set-buffer org-index--buffer)
-      (org-index--do-occur))
-
-
-     ((eq command 'ref)
-
-      (let (new)
-
-        ;; add a new row
-        (setq new (org-index--create-new-line))
-
-        ;; fill special columns with standard values
-        (org-table-goto-column (org-index--column-num 'ref))
-        (insert new)
-        (setq org-index--last-ref new)
-
-        ;; goto point-field or first empty one or first field
-        (if (org-index--special-column 'point-on-add)
-            (org-table-goto-column (org-index--column-num (org-index--special-column 'point-on-add)))
-          (unless (catch 'empty
-                    (dotimes (col org-index--numcols)
-                      (org-table-goto-column (+ col 1))
-                      (if (string= (org-trim (org-table-get-field)) "")
-                          (throw 'empty t))))
-            ;; none found, goto first
-            (org-table-goto-column 1)))
-
-        (if org-index--active-region (setq kill-new-text org-index--active-region))
-        (setq message-text (format "Adding a new row with ref '%s'" new))))
-
-
-     ((eq command 'sort)
-
-      (let ((columns (list "ref" "count" "created" "last-accessed" "id"))
-            sort groups-and-counts)
-
-        (cond
-         ((eq sort-what 'index)
-          (setq sort
-                (intern
-                 (org-icompleting-read
-                  "Please choose column to sort index table: "
-                  (append (copy-list columns) (list "group-by"))
-                  nil t nil nil (symbol-name (org-index--special-column 'sort)))))
-
-          (when (eq sort 'group-by)
-              (setq sort
-                    (intern
-                     (org-icompleting-read
-                      "Please choose column to group index table by: "
-                      columns
-                      nil t nil nil (symbol-name (org-index--special-column 'sort)))))
-              (setq groups-and-counts (org-index--collect-sort-groups sort)))
-
-          (org-index--do-sort-index sort (first groups-and-counts))
-          (org-table-goto-column (org-index--column-num sort))
-          ;; When saving index, it should again be sorted correctly
-          (with-current-buffer org-index--buffer
-            (add-hook 'before-save-hook 'org-index--sort-silent t))
-          
-          (setq message-text
-                (format
-                 (concat "Your index has been sorted temporarily by %s and will be sorted again by %s after %d seconds of idle time"
-                         (if groups-and-counts
-                             "; %d groups with equal %s and a total of %d lines have been found"
-                           ""))
-                 (symbol-name sort)
-                 (org-index--special-column 'sort)
-                 org-index--sort-idle-delay
-                 (second groups-and-counts)
-                 (symbol-name sort)
-                 (third groups-and-counts))))
-
-         ((memq sort-what '(region buffer))
-          (org-index--do-sort-lines sort-what)
-          (setq message-text (format "Sorted %s by contained references" sort-what))))))
-
-
-     ((eq command 'highlight)
-
-      (let ((where "buffer"))
-        (save-excursion
-          (save-restriction
-            (when (and transient-mark-mode
-                       mark-active)
-              (narrow-to-region (region-beginning) (region-end))
-              (setq where "region"))
-
-            (if arg
-                (progn
-                  (unhighlight-regexp org-index--ref-regex)
-                  (setq message-text (format "Removed highlights for references in %s" where)))
-              (highlight-regexp org-index--ref-regex 'isearch)
-              (setq message-text (format "Highlighted references in %s" where)))))))
-
-
-     ((eq command 'maintain)
-      (setq message-text (org-index--do-maintain)))
-
-     
-     ((eq command 'example)
-
-      (if (y-or-n-p "This assistant will help you to create a temporary index with detailed comments.\nDo you want to proceed ? ")
-          (org-index--create-index t)))
-
-
-     (t (error "Unknown subcommand '%s'" command)))
-
-
-    ;; tell, what we have done and what can be yanked
-    (if kill-new-text (setq kill-new-text
-                            (substring-no-properties kill-new-text)))
-    (if (string= kill-new-text "") (setq kill-new-text nil))
-    (let ((m (concat
-              message-text
-              (if (and message-text kill-new-text)
-                  " and r"
-                (if kill-new-text "R" ""))
-              (if kill-new-text (format "eady to yank '%s'." kill-new-text) (if message-text "." "")))))
-      (unless (string= m "")
-        (message m)
-        (setq org-index--message-text m)))
-    (if kill-new-text (kill-new kill-new-text))))
-
-
-(defun org-index-default-keybindings (&optional prefix)
-  "Set default keybindings for `org-index'.
-
-Invoke subcommands of org index with a single key
-sequence. Establish the common prefix key 'C-c i' which should be
-followed by the first letter of a subcommand.
-
-The ist of letters and subcommands is specified in within
-`org-index-default-keybindings-list'.
-  
-See `org-index' for a description of all subcommands.
-
-Optional argument PREFIX specifies common prefix, defaults to 'C-c i'"
-  (interactive)
-
-  (define-prefix-command 'org-index--keymap)
-  ;; prefix command
-  (global-set-key (kbd (or prefix "C-c i")) 'org-index--keymap)
-  ;; loop over subcommands
-  (mapcar
-   (lambda (x)
-     ;; loop over letters, that invoke the same subcommand
-     (mapcar (lambda (c)
-               (define-key org-index--keymap (kbd (char-to-string c))
-                 `(lambda (arg) (interactive "P")
-                    (message nil)
-                    (org-index ,(cdr x) nil arg))))
-             (car x)))
-   org-index-default-keybindings-list))
-
-
-(defun org-index-new-line (&rest keys-values)
-  "Create a new line within the index table, returning its reference.
-
-The function takes a varying number of argument pairs; each pair
-is a symbol for an existing column heading followed by its value.
-The return value is the new reference.
-
-Example:
-
-  (message \"Created reference %s\"
-           (org-index-new-line 'keywords \"foo bar\" 'category \"baz\"))
-
-Optional argument KEYS-VALUES specifies content of new line."
-
-  (org-index--verify-id)
-  (org-index--parse-table)
-
-  (car (apply 'org-index--do-new-line keys-values)))
-
-
-(defun org-index--do-new-line (&rest keys-values)
-  "Do the work for `org-index-new-line'.
-Optional argument KEYS-VALUES specifies content of new line."
-
-  (save-excursion
-    (org-index--retrieve-context)
-    (with-current-buffer org-index--buffer
-      (goto-char org-index--point)
-
-      ;; check arguments early; they might come from lisp-user
-      (let ((kvs keys-values)
-            k v)
-        (while kvs
-          (setq k (car kvs))
-          (setq v (cadr kvs))
-          (if (eq k 'ref)
-              (unless (memq v '(t nil))
-                (error "Column 'ref' accepts only \"t\" or \"nil\""))
-            (if (or (not (symbolp k))
-                    (and (symbolp v) (not (eq v t)) (not (eq v nil))))
-                (error "Arguments must be alternation of key and value")))
-          (unless (org-index--column-num k)
-            (error "Unknown column or column not defined in table: '%s'" (symbol-name k)))
-          (setq kvs (cddr kvs))))
-
-      (let (ref yank)
-        ;; create new line
-        (setq ref (org-index--create-new-line))
-        (plist-put keys-values 'ref ref)
-
-        ;; fill columns
-        (let ((kvs keys-values)
-              k v n)
-          (while kvs
-            (setq k (car kvs))
-            (setq v (cadr kvs))
-            (org-table-goto-column (org-index--column-num k))
-            (insert (org-trim v))
-            (setq kvs (cddr kvs))))
-
-        ;; align and fontify line
-        (org-index--promote-current-line)
-        (org-index--align-and-fontify-current-line)
-        
-        ;; get column to yank
-        (setq yank (org-index--get-or-set-field (org-index--special-column 'yank-after-add)))
-
-        (cons ref yank)))))
-
-
-(defun org-index-get-line (column value)
-  "Retrieve an existing line within the index table by ref or id.
-Return its contents as a property list.
-
-The function `plist-get' may be used to retrieve specific elements
-from the result.
-
-Example:
-
-  (plist-get (org-index-get-line 'ref \"R12\") 'count)
-
-retrieves the value of the count-column for reference number 12.
-
-Argument COLUMN is a symbol, either ref or id,
-argument VALUE specifies the value to search for."
-  ;; check arguments
-  (unless (memq column '(ref id))
-    (error "Argument column can only be 'ref' or 'id'"))
-
-  (unless value
-    (error "Need a value to search for"))
-  
-  (org-index--verify-id)
-  (org-index--parse-table)
-
-  (org-index--get-line column value))
-
-
-(defun org-index--get-line (column value)
-  "Find a line by ID, return its contents.
-Argument COLUMN and VALUE specify line to get."
-  (let (content)
-    (org-index--on
-     column value
-     (mapc (lambda (x)
-             (if (and (numberp (cdr x))
-                      (> (cdr x) 0))
-                 (setq content (cons (car x) (cons (or (org-index--get-or-set-field (car x)) "") content)))))
-           (reverse org-index--columns)))
-    content))
-
-
-(defun org-index--delete-line (id)
-  "Delete a line specified by ID."
-  (let (content)
-    (org-index--on
-     'id id
-     (let ((start (line-beginning-position)))
-       (beginning-of-line)
-       (forward-line)
-       (delete-region start (point))
-       t))))
-
-
-(defun org-index--ref-from-id (id)
-  "Get reference from line ID."
-  (org-index--on 'id id (org-index--get-or-set-field 'ref)))
-
-
-(defun org-index--id-from-ref (ref)
-  "Get id from line REF."
-  (org-index--on 'ref ref (org-index--get-or-set-field 'id)))
-
-
-(defun org-index--read-search-for-enter ()
-    "Special input routine for command enter."
-  ;; Accept single char commands or switch to reading a sequence of digits
-  (let (char prompt search-ref search-id)
-    
-    ;; start with short prompt but give more help on next iteration
-    (setq prompt "Please specify, where to go in index (0-9.,space,backspace,return or ? for help): ")
-    
-    ;; read one character
-    (while (not (memq char (append (number-sequence ?0 ?9) (list ?\d ?\b ?\r ?\j ?\s ?.))))
-      (setq char (read-char prompt))
-      (setq prompt "Go to index table and specific position. Digits specify a reference number to got to,  goes to top of index,  or  to last line created and  or `.' to index line of current node. Please choose: "))
-    
-    (if (memq char (number-sequence ?0 ?9))
-        ;; read rest of digits
-        (setq search-ref (read-from-minibuffer "Search reference number: " (char-to-string char))))
-    ;; decode single chars
-    (if (memq char '(?\r ?\n ?.)) (setq search-id (org-id-get)))
-    (if (memq char '(?\d ?\b)) (setq search-ref (number-to-string org-index--maxref)))
-
-    (cons search-ref search-id)))
-
-
-(defun org-index--verify-id ()
-  "Check, that we have a valid id."
-
-  ;; Check id
-  (unless org-index-id
-    (let ((answer (org-completing-read "Cannot find an index (org-index-id is not set). You may:\n  - read-help    : to learn more about org-index\n  - create-index : invoke an assistant to create an initial index\nPlease choose: " (list "read-help" "create-index") nil t nil nil "read-help")))
-      (if (string= "create-index" answer)
-          (org-index--create-missing-index "Variable org-index-id is not set, so probably no index table has been created yet.")
-        (describe-function 'org-index))))
-
-  ;; Find node
-  (let (marker)
-    (setq marker (org-id-find org-index-id 'marker))
-    (unless marker (org-index--create-missing-index "Cannot find the node with id \"%s\" (as specified by variable org-index-id)." org-index-id))
-    ; Try again with new node
-    (setq marker (org-id-find org-index-id 'marker))
-    (unless marker (error "Could not create node"))
-    (setq org-index--buffer (marker-buffer marker)
-          org-index--point (marker-position marker))
-    (move-marker marker nil)))
-
-
-(defun org-index--retrieve-context ()
-  "Collect context information before starting with command."
-
-  ;; Get the content of the active region or the word under cursor
-  (setq org-index--active-region
-        (if (and transient-mark-mode mark-active)
-            (buffer-substring (region-beginning) (region-end))
-          nil))
-  (setq org-index--below-cursor (thing-at-point 'symbol))
-
-  ;; get category of current node
-  (setq org-index--category-before
-        (save-excursion ; workaround: org-get-category does not give category when at end of buffer
-          (beginning-of-line)
-          (org-get-category (point) t)))
-
-  ;; Find out, if we are within index table or not
-  (setq org-index--within-node (string= (org-id-get) org-index-id)))
-
-
-(defun org-index--parse-table ()
-  "Parse content of index table."
-
-  (let (ref-field
-        id-field
-        initial-point
-        end-of-headings
-        start-of-headings)
-
-    (with-current-buffer org-index--buffer
-
-      (setq org-index--maxref 0)
-      (setq initial-point (point))
-
-      (org-index--go-below-hline)
-
-      ;; align and fontify table once for this emacs session
-      (unless org-index--aligned
-        (org-table-align) ; needs to happen before fontification to be effective ?
-        (let ((is-modified (buffer-modified-p))
-              (below (point)))
-          (while (org-at-table-p)
-            (forward-line))
-          (font-lock-fontify-region below (point))
-          (org-index--go-below-hline)
-          (setq org-index--aligned t)
-          (set-buffer-modified-p is-modified)))
-      
-      (org-index--go-below-hline)
-      (setq org-index--below-hline (point-marker))
-      (beginning-of-line)
-
-      ;; get headings to display during occur
-      (setq end-of-headings (point))
-      (while (org-at-table-p) (forward-line -1))
-      (forward-line)
-      (setq start-of-headings (point))
-      (setq org-index--headings-visible (substring-no-properties (org-index--copy-visible start-of-headings end-of-headings)))
-      (setq org-index--headings (buffer-substring start-of-headings end-of-headings))
-
-      ;; count columns
-      (org-table-goto-column 100)
-      (setq org-index--numcols (- (org-table-current-column) 1))
-
-      ;; go to top of table
-      (while (org-at-table-p)
-        (forward-line -1))
-      (forward-line)
-
-      ;; parse line of headings
-      (org-index--parse-headings)
-
-      ;; parse list of flags
-      (goto-char org-index--point)
-      (org-index--parse-flags)
-
-      ;; Retrieve any decorations around the number within the first nonempty ref-field
-      (goto-char org-index--below-hline)
-      (while (and (org-at-table-p)
-                  (not (setq ref-field (org-index--get-or-set-field 'ref))))
-        (forward-line))
-
-      ;; Some Checking
-      (unless ref-field
-        (org-index--report-index-error "Reference column is empty"))
-
-      (unless (string-match "^\\([^0-9]*\\)\\([0-9]+\\)\\([^0-9]*\\)$" ref-field)
-        (org-index--report-index-error
-         "First reference in index table ('%s') does not contain a number" ref-field))
-
-      ;; These are the decorations used within the first ref of index
-      (setq org-index--head (match-string 1 ref-field))
-      (setq org-index--tail (match-string 3 ref-field))
-      (setq org-index--ref-regex (concat (regexp-quote org-index--head)
-                                         "\\([0-9]+\\)"
-                                         (regexp-quote org-index--tail)))
-      (setq org-index--ref-format (concat org-index--head "%d" org-index--tail))
-
-      ;; Go through table to find maximum number and do some checking
-      (let ((ref 0))
-
-        (while (org-at-table-p)
-
-          (setq ref-field (org-index--get-or-set-field 'ref))
-          (setq id-field (org-index--get-or-set-field 'id))
-
-          (when (and (not ref-field)
-                     (not id-field))
-            (kill-whole-line)
-            (message "Removing line from index-table with both ref and id empty"))
-
-          (if ref-field
-              (if (string-match org-index--ref-regex ref-field)
-                  ;; grab number
-                  (setq ref (string-to-number (match-string 1 ref-field)))
-                (kill-whole-line)
-                (message "Removing line from index-table whose ref does not contain a number")))
-
-          ;; check, if higher ref
-          (if (> ref org-index--maxref) (setq org-index--maxref ref))
-
-          (forward-line 1)))
-
-      ;; go back to initial position
-      (goto-char initial-point))))
-
-
-(defun org-index--do-maintain ()
-  "Choose among and perform some tasks to maintain index."
-  (let ((check-what) (max-mini-window-height 1.0) message-text)
-    (setq check-what (intern (org-completing-read "These checks and fixes are available:\n  - statistics : compute statistics about index table\n  - check      : check ids by visiting their nodes\n  - duplicates : check index for duplicate rows (any column)\n  - clean      : remove obsolete property org-index-id\n  - update     : update content of index lines, with an id \nPlease choose: " (list "statistics" "check" "duplicates" "clean" "update") nil t nil nil "statistics")))
-    (message nil)
-    
-    (cond
-     ((eq check-what 'check)
-      (setq message-text (or (org-index--check-ids)
-                             "No problems found")))
-
-     ((eq check-what 'statistics)
-      (setq message-text (org-index--do-statistics)))
-
-     ((eq check-what 'duplicates)
-      (setq message-text "Finding duplcates can be done by sorting your index appropriately: Choose 'group-by' and select a column; rows will then be sorted together, if they have the same value within the coosen column."))
-
-     ((eq check-what 'clean)
-      (let ((lines 0))
-        (org-map-entries
-         (lambda ()
-           (when (org-entry-get (point) "org-index-ref")
-             (incf lines)
-             (org-entry-delete (point) "org-index-ref")))
-         nil 'agenda)
-        (setq message-text (format "Removed property 'org-index-ref' from %d lines" lines))))
-     
-     ((eq check-what 'update)
-      (if (y-or-n-p "Updating your index will overwrite certain columns with content from the associated heading and category.  If unsure, you may try this for a single, already existing line of your index by doing `add' from within your index.  Are you SURE to proceed for ALL INDEX LINES ? ")
-          (setq message-text (org-index--update-all-lines))
-        (setq message-text "Canceled."))))
-    message-text))
-
-
-(defun org-index--do-sort-index (sort &optional groups)
-  "Sort index table according to SORT, optinally with GROUPS."
-
-  (let ((is-modified (buffer-modified-p))
-        top
-        bottom
-        ref-field
-        count-field)
-
-    (unless buffer-read-only
-
-      (message "Sorting table for %s..." (symbol-name sort))
-      (undo-boundary)
-
-      (let ((message-log-max nil)) ; we have just issued a message, dont need those of sort-subr
-
-        ;; get boundaries of table
-        (goto-char org-index--below-hline)
-        (forward-line 0)
-        (setq top (point))
-        (while (org-at-table-p) (forward-line))
-
-        ;; kill all empty rows at bottom
-        (while (progn
-                 (forward-line -1)
-                 (org-table-goto-column 1)
-                 (and
-                  (not (org-index--get-or-set-field 'ref))
-                  (not (org-index--get-or-set-field 'id))))
-          (org-table-kill-row))
-        (forward-line 1)
-        (setq bottom (point))
-        
-        ;; sort lines
-        (save-restriction
-          (narrow-to-region top bottom)
-          (goto-char top)
-          (sort-subr t
-                     'forward-line
-                     'end-of-line
-                     (lambda ()
-                       (concat
-                        (if groups
-                            (format "%06d-" (cdr (assoc (org-index--get-or-set-field sort) groups)))
-                          "")
-                        (org-index--get-sort-key sort t)))
-                     nil
-                     'string<)
-          (goto-char (point-min))
-
-          ;; restore modification state
-          (set-buffer-modified-p is-modified)))
-
-        (setq org-index--last-sort sort))))
-
-
-(defun org-index--collect-sort-groups (sort)
-  "Collect groups to SORT for."
-  (let ((count-groups 0) (count-lines 0)
-        groups key key-value)
-    
-    (org-index--on
-        nil nil
-        (while (org-at-table-p)
-          (setq key (org-index--get-or-set-field sort))
-          (setq key-value (assoc key groups))
-          (if key-value
-              (progn
-                (incf (cdr key-value)))
-            (setq groups (cons (cons key 1) groups)))
-          (forward-line)))
-
-    (mapc (lambda (x) (when (> (cdr x) 1)
-                   (incf count-groups)
-                   (incf count-lines (cdr x))))
-          groups)
-
-    (list groups count-groups count-lines)))
-
-
-(defun org-index--do-sort-lines (what)
-  "Sort lines in WHAT according to contained reference."
-  (save-restriction
-    (cond
-     ((eq what 'region)
-      (if (region-active-p)
-          (narrow-to-region (region-beginning) (region-end))
-        (error "No active region, cannot sort")))
-     ((eq what 'buffer)
-      (unless (y-or-n-p "Sort whole current buffer ? ")
-        (error "Canceled"))
-      (narrow-to-region (point-min) (point-max))))
-
-    (goto-char (point-min))
-    (sort-subr nil 'forward-line 'end-of-line
-               (lambda ()
-                 (if (looking-at (concat ".*"
-                                         (org-index--make-guarded-search org-index--ref-regex 'dont-quote)))
-                     (string-to-number (match-string 1))
-                   0)))))
-
-
-(defun org-index--go-below-hline ()
-  "Move below hline in index-table."
-
-  (let ((count 0)
-        (errstring (format "index table within node %s" org-index-id)))
-
-    (goto-char org-index--point)
-
-    ;; go to heading of node
-    (while (not (org-at-heading-p)) (forward-line -1))
-    (forward-line 1)
-
-    ;; go to first table, but make sure we do not get into another node
-    (while (and (not (org-at-table-p))
-                (not (org-at-heading-p))
-                (not (eobp)))
-      (forward-line))
-
-    ;; check, if there really is a table
-    (unless (org-at-table-p)
-      (org-index--create-missing-index "Cannot find %s." errstring))
-
-    ;; go just after hline
-    (while (and (not (org-at-table-hline-p))
-                (org-at-table-p))
-      (forward-line))
-    (forward-line)
-
-    ;; and check
-    (unless (org-at-table-p)
-      (org-index--report-index-error "Cannot find a hline within %s" errstring))
-
-    (org-table-goto-column 1)))
-
-
-(defun org-index--parse-headings ()
-  "Parse headings of index table."
-
-  (let (field        ;; field content
-        field-symbol ;; and as a symbol
-        found)
-
-    (setq org-index--columns nil)
-
-    ;; For each column
-    (dotimes (col org-index--numcols)
-
-      (setq field (substring-no-properties (downcase (org-trim (org-table-get-field (+ col 1))))))
-
-      (if (string= field "")
-          (error "Heading of column cannot be empty"))
-      (if (and (not (string= (substring field 0 1) "."))
-               (not (member (intern field) org-index--valid-headings)))
-
-          (if (string= field "link")
-              ;; Ask user to migrate his index to new version (since [2015-02-11 Mi])
-              (progn
-                ;; pop to index buffer
-                (pop-to-buffer-same-window org-index--buffer)
-                (goto-char org-index--below-hline)
-                (org-reveal t)
-                ;; go to column
-                (while (org-at-table-p)
-                  (forward-line -1))
-                (forward-line)
-                (org-table-goto-column (+ 1 col))
-                (error "Column 'link' should be named 'id' with recent versions of org-index,\nplease adjust your table (cursor is already positioned right)"))
-            (error "Column name '%s' is not a valid heading (custom headings may start with a dot, e.g. '.foo')" field)))
-
-      (setq field-symbol (intern field))
-
-      ;; check if heading has already appeared
-      (if (assoc field-symbol org-index--columns)
-          (org-index--report-index-error
-           "'%s' appears two times as column heading" (downcase field))
-        ;; add it to list at front, reverse later
-        (setq org-index--columns (cons (cons field-symbol (+ col 1)) org-index--columns)))))
-
-  (setq org-index--columns (reverse org-index--columns))
-
-  ;; check if all necessary headings have appeared
-  (mapc (lambda (head)
-          (unless (cdr (assoc head org-index--columns))
-            (org-index--report-index-error "No column has heading '%s'" head)))
-        org-index--required-headings))
-
-
-(defun org-index--parse-flags ()
-  "Parse list of flags in index table."
-
-  (let (parent parent-is-comment child)
-
-    ;; reset configuration variables
-    (setq org-index--special-columns nil)
-    (setq org-index--flagged-columns nil)
-
-    (org-index--goto-list "columns-and-flags" t)
-    (forward-line 1)
-
-    ;; outer loop over columns
-    (while (and (setq parent (org-index--parse-list-item))
-                parent
-                (> (cdr (assoc :indent parent)) 0))
-
-      (setq parent-is-comment (member (cdr (assoc :text parent)) '("all-columns-explained" "all-flags-explained")))
-
-      ;; check, that we have a valid heading
-      (unless (or parent-is-comment
-                  (assoc (cdr (assoc :sym parent)) org-index--columns))
-        (when (string= "link" (cdr (assoc :text parent)))
-          (pop-to-buffer-same-window org-index--buffer)
-          (org-reveal t)
-          (error "Flag 'link' should be named 'id' with recent versions of org-index,\nplease adjust this flag (cursor is already positioned right)"))
-        (org-index--report-index-error "'%s' appears within flags, but not as a index column.  " (cdr (assoc :text parent))))
-
-      ;; inner loop over children
-      (while (and (forward-line 1)
-                  (setq child (org-index--parse-list-item))
-                  child
-                  (> (cdr (assoc :indent child))
-                     (cdr (assoc :indent parent))))
-
-        (unless parent-is-comment
-          ;; check, that we have a valid flag
-          (unless (memq (cdr (assoc :sym child)) org-index--all-flags)
-            (org-index--report-index-error "'%s' is not a valid flag" (cdr (assoc :text child))))
-
-          ;; process flag with respect to current index-column
-          (if (memq (cdr (assoc :sym child)) org-index--single-flags)
-              ;; Check, that none of org-index--single-flags appears twice
-              (if (assoc (cdr (assoc :sym child)) org-index--special-columns)
-                  (org-index--report-index-error
-                   "More than one column is marked with flag '%s'" (cdr (assoc :text child)))
-                ;; add it to list
-                (setq org-index--special-columns (cons (cons (cdr (assoc :sym child)) (cdr (assoc :sym parent)))
-                                                       org-index--special-columns))))
-
-          ;; all flags are stored in org-index--flagged-columns
-          (let ((l (assoc (cdr (assoc :sym child)) org-index--flagged-columns))) ;; list of flag and columns, that carry this flag
-            (unless l
-              ;; no list of columns with this flag is present, create one
-              (setq org-index--flagged-columns
-                    (cons (cons (cdr (assoc :sym child)) nil)
-                          org-index--flagged-columns))
-              (setq l (car org-index--flagged-columns)))
-            ;; prepend this column to list of columns with this flag
-            (setcdr l (cons (cdr (assoc :sym parent)) (cdr l)))))))
-
-    ;; check, that all needed flags have been specified
-    (mapc (lambda (x)
-            (unless (assoc x org-index--special-columns)
-              (org-index--report-index-error "Required flag '%s' does not appear" (substring (symbol-name x) 1))))
-          org-index--required-flags)))
-
-
-(defun org-index--goto-list (name &optional required non-top)
-  "Goto list NAME (maybe NON-TOP Level) in index node, err if REQUIRED list is not present."
-  (goto-char org-index--point)
-
-  ;; go to heading of node
-  (while (not (org-at-heading-p)) (forward-line -1))
-  (forward-line 1)
-
-  ;; go to named list
-  (while (and (not (let ((item (org-index--parse-list-item)))
-                     (if item
-                         (and (or non-top (= (cdr (assoc :indent item)) 0)) ;; accept only toplevel ?
-                              (string= (cdr (assoc :text item)) name)) ;; with requested name
-                       nil)))
-              (not (org-at-table-p))
-              (not (org-at-heading-p))
-              (not (eobp)))
-    (forward-line 1))
-
-  (if (org-at-item-p)
-      t
-    (if required
-        (org-index--report-index-error "Could not find required list '%s'" name)
-      nil)))
-
-
-(defun org-index--parse-list-item ()
-  "Parse a list item into an assoc array (indent, checkbox, text, value)."
-
-  ;; matche full list-item, maybe with checkbox and double-colon
-  (if (looking-at org-list-full-item-re)
-
-      ;; retrieve interesting parts of list item from match data
-      (let (indent checkbox text value next-line)
-
-        (setq indent
-              (- (save-excursion (goto-char (match-beginning 1)) (current-column)) ; first column
-                 (save-match-data (org-current-level)) ; indent-level
-                 1))
-        (setq checkbox (match-string 3))
-        (setq text (match-string 4))
-        (set (if text 'value 'text) (buffer-substring (match-end 0) (line-end-position))) ; regexp did not capture this
-
-        ;; peek ahead, if item continues on next line
-        (forward-line 1)
-        (if (looking-at org-list-full-item-re)
-            (forward-line -1) ; already at next item; go back
-          (setq next-line (buffer-substring (line-beginning-position) (line-end-position))))
-        
-        ;; clean up strings
-        (mapc (lambda (x)
-                (if (stringp (symbol-value x))
-                    (set x (org-trim (substring-no-properties (symbol-value x))))))
-              '(text value next-line))
-
-        (if next-line (setq text (concat text " " next-line))) ; append next line if
-        
-        (list (cons :indent indent) (cons :text text) (cons :value value) (cons :sym (intern text))))
-    nil))
-
-
-(defun org-index--create-missing-index (&rest reasons)
-  "Create a new empty index table with detailed explanation.  Argument REASONS explains why."
-
-  (org-index--ask-before-create-index "Cannot find your index table: "
-                                      "new permanent" "."
-                                      reasons)
-  (org-index--create-index))
-
-
-(defun org-index--report-index-error (&rest reasons)
-  "Report an error (explained by REASONS) with the existing index and offer to create a valid one to compare with."
-
-  (when org-index--buffer
-    (pop-to-buffer-same-window org-index--buffer)
-    (goto-char org-index--below-hline)
-    (org-reveal t))
-  (org-index--ask-before-create-index "The existing index contains this error: "
-                                      "temporary" ", to compare with."
-                                      reasons)
-  (org-index--create-index t t))
-
-
-(defun org-index--ask-before-create-index (explanation type for-what reasons)
-                                                  ; checkdoc-params: (explanation type for-what reasons)
-  "Ask the user before creating an index or throw error.  Arguments specify bits of issued message."
-  (let (reason prompt)
-
-    (setq reason (apply 'format reasons))
-
-    (setq prompt (concat explanation reason "\n\n"
-                         "However, this assistant can help you to create a "
-                         type " index with detailed comments" for-what "\n\n"
-                         "Do you want to proceed ?"))
-
-    (unless (let ((max-mini-window-height 1.0))
-              (y-or-n-p prompt))
-      (error (concat explanation reason)))))
-
-
-(defun org-index--create-index (&optional temporary compare)
-  "Create a new empty index table with detailed explanation.
-specify flag TEMPORARY for th new table temporary, maybe COMPARE it with existing index."
-  (let (buffer
-        title
-        firstref
-        id)
-
-    (if temporary
-        (let ((file-name (concat temporary-file-directory "org-index--example-index.org"))
-              (buffer-name "*org-index-example-index*"))
-          (setq buffer (get-buffer-create buffer-name))
-          (with-current-buffer buffer
-            ;; but it needs a file for its index to be found
-            (unless (string= (buffer-file-name) file-name)
-              (set-visited-file-name file-name))
-            (rename-buffer buffer-name) ; name is change by line above
-
-            (erase-buffer)
-            (org-mode)))
-
-      (setq buffer (get-buffer (org-completing-read "Please choose the buffer, where the new node for the index table should be created; the new node will be inserted at its end.\n\nBuffer: " (mapcar 'buffer-name (org-buffer-list))))))
-
-    (setq title (read-from-minibuffer "Please enter the title of the index node: "))
-
-    (while (progn
-             (setq firstref (read-from-minibuffer "Please enter your first reference-number. This is a number preceeded by some non-digit chars and optionally followed by some more non-digit chars, e.g. 'R1', '-1-' or '#1#' (and your initial number does not need to be '1'). The format of your reference-numbers only needs to make sense for yourself, so that you can spot it easily in your texts or write it on a piece of paper; it should however not already appear to frequently within your existing notes, to avoid too many false hits when searching.\n\nPlease choose: "))
-             (let (desc)
-               (when (string-match "[[:blank:]]" firstref)
-                 (setq desc "Contains whitespace"))
-               (when (string-match "[[:cntrl:]]" firstref)
-                 (setq desc "Contains control characters"))
-               (unless (string-match "^[^0-9]+[0-9]+[^0-9]*$" firstref)
-                 ;; firstref not okay, report details
-                 (setq desc
-                       (cond ((string= firstref "") "is empty")
-                             ((not (string-match "^[^0-9]+" firstref)) "starts with a digit")
-                             ((not (string-match "^[^0-9]+[0-9]+" firstref)) "does not contain a number")
-                             ((not (string-match "^[^0-9]+[0-9]+[^0-9]*$" firstref)) "contains more than one sequence of digits")
-
-                             )))
-               (if desc
-                   (progn
-                     (read-from-minibuffer (format "Your input '%s' does not meet the requirements because it %s.\nPlease hit RET and try again: " firstref desc))
-                     t)
-                 nil))))
-
-    (with-current-buffer buffer
-      (goto-char (point-max))
-      (insert (format "* %s %s\n" firstref title))
-      (if temporary
-          (insert "
-  Below you find your temporary index table, which WILL NOT LAST LONGER
-  THAN YOUR CURRENT EMACS SESSION.
-")
-        (insert "
-  Below you find your initial index table, which will grow over time.
-"))
-      (insert "
-  You may start using it by adding some lines. Just move to
-  another heading, invoke `org-index' and choose the command
-  'add'.  After adding a few nodes, try the command 'occur'
-  to search among them.
-
-  To gain further insight you may invoke the subcommand 'help', or
-  read the description of `org-index'.
-
-  Within the index table below, dhe sequence of columns does not
-  matter. You may reorder them in any way you please. Columns are
-  found by their heading. You may also add your own columns,
-  which should start with a dot (e.g. '.custom').
-
-  Following this explanations you will find the item-list
-  `columns-and-flags', which influences the behaviour of
-  `org-index'. See the explanations which are part of this list.
-
-  This node needs not be a top level node; its name is completely
-  at your choice; it is found through its ID only.
-")
-      (unless temporary
-        (insert "
-  Remark: These lines of explanation can be removed at any time.
-"))
-
-      (setq id (org-id-get-create))
-      (insert (format "
-%s
-
-
-  | ref |  category | keywords | count | last-accessed | created | id |
-  |     |           |          |       |               |         | <4>  |
-  |-----+-----------+----------+-------+---------------+---------+------|
-  | %s  |           | %s       |       |               | %s      | %s   |
-
-"
-                      org-index--sample-flags
-                      firstref
-                      "This node"
-                      (with-temp-buffer (org-insert-time-stamp nil nil t))
-                      id))
-
-      ;; make sure, that node can be found
-      (org-id-add-location id (buffer-file-name))
-      (setq buffer-save-without-query t)
-      (basic-save-buffer)
-
-      (while (not (org-at-table-p)) (forward-line -1))
-      (unless buffer-read-only (org-table-align))
-      (while (not (org-at-heading-p)) (forward-line -1))
-
-      ;; read back some info about new index
-      (let ((org-index-id id))
-	(org-index--verify-id))
-
-      ;; remember at least for this session
-      (setq org-index-id id)
-
-      ;; present results to user
-      (if temporary
-          (progn
-            ;; Present existing and temporary index together
-            (when compare
-              (pop-to-buffer-same-window org-index--buffer)
-              (goto-char org-index--point)
-              (org-index--unfold-buffer)
-              (delete-other-windows)
-              (select-window (split-window-vertically)))
-            ;; show new index
-            (pop-to-buffer-same-window buffer)
-            (org-id-goto id)
-            (org-index--unfold-buffer)
-            (if compare
-                (error "Please compare your existing index (upper window) and a temporary new one (lower window) to fix your index")
-              (message "This is your new temporary index.")))
-        (progn
-          ;; Only show the new index
-          (pop-to-buffer-same-window buffer)
-          (delete-other-windows)
-          (org-id-goto id)
-          (org-index--unfold-buffer)
-          (if (y-or-n-p "This is your new index table.  It is already set for this Emacs session, so you may try it out.  Do you want to save its id to make it available for future Emacs sessions too ? ")
-              (progn
-                (customize-save-variable 'org-index-id id)
-                (error "Saved org-index-id '%s' to %s" id (or custom-file
-							      user-init-file)))
-            (let (sq)
-              (setq sq (format "(setq org-index-id \"%s\")" id))
-              (kill-new sq)
-              (error "Did not make the id of this new index permanent; you may want to put\n\n   %s\n\ninto your own initialization; it is copied already, just yank it" sq))))))))
-
-
-(defun org-index--unfold-buffer ()
-  "Helper function to unfold buffer."
-  (org-show-context)
-  (org-show-subtree)
-  (recenter 1)
-  (save-excursion
-    (org-back-to-heading)
-    (forward-line) ;; on property drawer
-    (org-cycle)
-    (org-index--goto-list "columns-and-flags")
-    (org-cycle)))
-
-
-(defun org-index--update-line (&optional ref-or-id)
-  "Update columns count and last-accessed in line REF-OR-ID."
-
-  (let ((newcount 0)
-        initial)
-
-    (with-current-buffer org-index--buffer
-      (unless buffer-read-only
-
-        ;; search reference or id, if given (or assume, that we are already positioned right)
-        (when ref-or-id
-          (setq initial (point))
-          (goto-char org-index--below-hline)
-          (while (and (org-at-table-p)
-                      (not (or (string= ref-or-id (org-index--get-or-set-field 'ref))
-                               (string= ref-or-id (org-index--get-or-set-field 'id)))))
-            (forward-line)))
-
-        (if (not (org-at-table-p))
-            (error "Did not find reference or id '%s'" ref-or-id)
-          (org-index--update-current-line))
-
-        (if initial (goto-char initial))))))
-
-
-(defun org-index--update-current-line ()
-  "Update current lines columns count and last-accessed."
-  (let (newcount (count-field (org-index--get-or-set-field 'count)))
-
-    ;; update count field only if number or empty
-    (when (or (not count-field)
-              (string-match "^[0-9]+$" count-field))
-      (setq newcount (+ 1 (string-to-number (or count-field "0"))))
-      (org-index--get-or-set-field 'count
-                            (number-to-string newcount)))
-
-    ;; update timestamp
-    (org-table-goto-column (org-index--column-num 'last-accessed))
-    (org-table-blank-field)
-    (org-insert-time-stamp nil t t)
-
-    ;; move line according to new content
-    (org-index--promote-current-line)
-    (org-index--align-and-fontify-current-line)))
-
-
-(defun org-index--align-and-fontify-current-line ()
-  "Make current line blend well among others."
-  (let ((line (substring-no-properties (delete-and-extract-region (line-beginning-position) (line-end-position)))))
-    ;; create minimum table with fixed-width columns to align and fontiry new line
-    (insert (with-temp-buffer
-              (org-set-font-lock-defaults)
-              (insert org-index--headings-visible)
-              (goto-char (point-min))
-              ;; fill columns, so that aligning cannot shrink them
-              (search-forward "|")
-              (replace-string " " "." nil (point) (line-end-position))
-              (replace-string ".|." " | " nil (line-beginning-position) (line-end-position))
-              (replace-string "|." "| " nil (line-beginning-position) (line-end-position))
-              (goto-char (point-max))
-              (insert line)
-              (forward-line 0)
-              (org-table-align)
-              (font-lock-fontify-region (point-min) (point-max))
-              (goto-char (point-max))
-              (forward-line -1)
-              (buffer-substring (line-beginning-position) (line-end-position))))))
-
-
-(defun org-index--promote-current-line ()
-  "Move current line up in table according to changed sort fields."
-  (let (begin end key
-        (to-skip 0))
-
-    (forward-line 0) ; stay at beginning of line
-
-    (setq key (org-index--get-sort-key))
-    (setq begin (point))
-    (setq end (line-beginning-position 2))
-
-    (forward-line -1)
-    (while (and (org-at-table-p)
-                (not (org-at-table-hline-p))
-                (string< (org-index--get-sort-key) key))
-
-      (incf to-skip)
-      (forward-line -1))
-    (forward-line 1)
-
-    ;; insert line at new position
-    (when (> to-skip 0)
-      (insert (delete-and-extract-region begin end))
-      (forward-line -1))))
-
-
-(defun org-index--get-sort-key (&optional sort with-ref)
-  "Get value for sorting from column SORT, optional WITH-REF."
-  (let (ref
-        ref-field
-        key)
-
-    (unless sort (setq sort org-index--last-sort)) ; use default value
-
-    (when (or with-ref
-              (eq sort 'ref))
-      ;; get reference with leading zeroes, so it can be
-      ;; sorted as text
-      (setq ref-field (org-index--get-or-set-field 'ref))
-      (string-match org-index--ref-regex ref-field)
-      (setq ref (format
-                 "%06d"
-                 (string-to-number
-                  (or (match-string 1 ref-field)
-                      "0")))))
-
-    (setq key
-          (cond
-           ((eq sort 'count)
-            (format "%08d" (string-to-number (or (org-index--get-or-set-field 'count) ""))))
-           ((eq sort 'ref)
-            ref)
-           ((eq sort 'id)
-            (org-index--get-or-set-field sort))
-           ((eq sort 'last-accessed)
-            (org-index--get-or-set-field sort))
-           ((eq sort 'created)
-            (org-index--get-or-set-field sort))
-           (t (error "This is a bug: unmatched case '%s'" sort))))
-
-    (if with-ref (setq key (concat key ref)))
-
-    key))
-
-
-(defun org-index--get-or-set-field (key &optional value)
-  "Retrieve field KEY from index table or set it to VALUE."
-  (let (field)
-    (save-excursion
-      (setq field (org-trim (org-table-get-field (cdr (assoc key org-index--columns)) value)))
-      (if (string= field "") (setq field nil))
-
-      (org-no-properties field))))
-
-
-(defun org-index--column-num (key)
-  "Return number of column KEY."
-  (if (numberp key)
-      key
-    (cdr (assoc key org-index--columns))))
-
-
-(defun org-index--special-column (key)
-  "Return column (not a number) for special column KEY."
-  (cdr (assoc key org-index--special-columns)))
-
-
-(defun org-index--flag-p (flag column)
-  "Check if COLUMN has FLAG set."
-  (unless (memq flag org-index--all-flags)
-    (error (format "Internal error: unknown flag %s" (symbol-name flag))))
-  (memq column (assoc flag org-index--flagged-columns)))
-
-
-(defun org-index--make-guarded-search (ref &optional dont-quote)
-  "Make robust search string from REF; DONT-QUOTE it, if requested."
-  (concat "\\_<" (if dont-quote ref (regexp-quote ref)) "\\_>"))
-
-
-(defun org-index--do-statistics ()
-  "Compute statistics about index table."
-  (let ((total 0)
-        ref-field ref min max message)
-
-
-    ;; go through table and remove all refs, that we see
-    (goto-char org-index--below-hline)
-    (while (org-at-table-p)
-
-      ;; get ref-field and number
-      (setq ref-field (org-index--get-or-set-field 'ref))
-      (if (and ref-field
-               (string-match org-index--ref-regex ref-field))
-          (setq ref (string-to-number (match-string 1 ref-field))))
-
-      ;; record min and max
-      (if (or (not min) (< ref min)) (setq min ref))
-      (if (or (not max) (> ref max)) (setq max ref))
-
-      ;; count
-      (setq total (1+ total))
-
-      (forward-line))
-
-    (setq message (format "First reference is %s, last %s; %d values in between, %d of them are used (%d percent)"
-                               (format org-index--ref-format min)
-                               (format org-index--ref-format max)
-                               (1+ (- max min))
-                               total
-                               (truncate (* 100 (/ (float total) (1+ (- max min)))))
-                                                              
-))
-
-    (goto-char org-index--below-hline)
-    message))
-
-
-(defun org-index--do-add-or-update ()
-  "For current node or current line in index, add a new line to index table or update existing."
-
-  (let* (id ref args yank ref-and-yank)
-
-    ;; do the same things from within index and from outside
-    (if org-index--within-node
-
-        (progn
-          (unless (org-at-table-p)
-            (error "Within index node but not on table"))
-
-          (setq id (org-index--get-or-set-field 'id))
-          (setq ref (org-index--get-or-set-field 'ref))
-          (setq args (org-index--collect-values-for-add-update-remote id))
-          (org-index--write-fields-for-add-update args)
-          (setq yank (org-index--get-or-set-field (org-index--special-column 'yank-after-add)))
-           
-          (cons (format "Updated index line %s" ref) yank))
-
-      (unless (org-at-heading-p)
-        (error "Not at headline"))
-
-      (setq id (org-id-get-create))
-      (setq ref (org-index--on 'id id (org-index--get-or-set-field 'ref)))
-      (setq args (org-index--collect-values-for-add-update id ref))
-
-      (if ref
-          ;; already have a ref, find it in index and update fields
-          (let ((kvs args)
-                found-and-message)
-
-            (org-index--on
-                'ref ref
-                (org-index--write-fields-for-add-update args)
-                (setq yank (org-index--get-or-set-field (org-index--special-column 'yank-after-add))))
-           
-            (cons (format "Updated index line %s" ref) yank))
-
-        ;; no ref here, create new line in index
-        (setq ref-and-yank (apply 'org-index--do-new-line args))
-
-        (cons (format "Added index line %s" (car ref-and-yank)) (concat (cdr ref-and-yank) " "))))))
-
-
-(defun org-index--check-ids ()
-  "Check, that ids really point to a node."
-
-  (let ((lines 0)
-        id ids marker)
-    
-    (goto-char org-index--below-hline)
-
-    (catch 'problem
-      (while (org-at-table-p)
-
-        (when (setq id (org-index--get-or-set-field 'id))
-
-          ;; check for double ids
-          (when (member id ids)
-            (org-table-goto-column (org-index--column-num 'id))
-            (throw 'problem "This id appears twice in index; please use command 'maintain' to check for duplicate ids"))
-          (incf lines)
-          (setq ids (cons id ids))
-
-          ;; check, if id is valid
-          (setq marker (org-id-find id t))
-          (unless marker
-            (org-table-goto-column (org-index--column-num 'id))
-            (throw 'problem "This id cannot be found")))
-
-        (forward-line))
-
-      (goto-char org-index--below-hline)
-      nil)))
-
-  
-(defun org-index--update-all-lines ()
-  "Update all lines of index at once."
-
-  (let ((lines 0)
-        id ref kvs)
-    
-    ;; check for double ids
-    (or
-     (org-index--check-ids)
-
-     (progn
-       (goto-char org-index--below-hline)
-       (while (org-at-table-p)
-         
-         ;; update single line
-         (when (setq id (org-index--get-or-set-field 'id))
-           (setq ref (org-index--get-or-set-field 'ref))
-           (setq kvs (org-index--collect-values-for-add-update-remote id))
-           (org-index--write-fields-for-add-update kvs)
-           (incf lines))
-         (forward-line))
-
-       (goto-char org-index--below-hline)
-       (org-table-align)
-       (format "Updated %d lines" lines)))))
-
-
-(defun org-index--collect-values-for-add-update (id &optional silent category)
-  "Collect values for adding or updating line specified by ID, do not ask if SILENT, use CATEGORY, if given."
-  
-  (let ((args (list 'ref t 'id id))
-        content)
-    
-    (dolist (col-num org-index--columns)
-    
-      (setq content "")
-    
-      (if (eq (car col-num) 'keywords)
-          (setq content (nth 4 (org-heading-components))))
-    
-      (if (eq (car col-num) 'category)
-          (setq content (or category org-index--category-before)))
-
-      (if (eq (car col-num) 'level)
-          (setq content (number-to-string (org-outline-level))))
-    
-      ;; Shift ref and timestamp ?
-      (if (org-index--flag-p 'shift-ref-and-date-on-add (car col-num))
-          (dotimes (i 2)
-            (if (or (string-match (concat "^\\s-*" org-index--ref-regex) content)
-                    (string-match (concat org-ts-regexp-both) content))
-                (setq content (substring content (match-end 0))))))
-    
-      (if (and (not silent)    ; do not edit, if heading has already been added
-               (org-index--flag-p 'edit-on-add (car col-num)))
-          (setq content (read-from-minibuffer
-                         (format "Edit text for column '%s': " (symbol-name (car col-num)))
-                         content)))
-    
-      (if (not (string= content ""))
-          (setq args (append (list (car col-num) content) args))))
-    args))
-
-
-(defun org-index--collect-values-for-add-update-remote (id)
-  "Wrap `org-index--collect-values-for-add-update' by prior moving to remote node identified by ID."
-  
-  (let (marker point args)
-
-    (setq marker (org-id-find id t))
-    ;; enter buffer and collect information
-    (with-current-buffer (marker-buffer marker)
-      (setq point (point))
-      (goto-char marker)
-      (setq args (org-index--collect-values-for-add-update id t (org-get-category (point) t)))
-      (goto-char point))
-
-    args))
-
-
-(defun org-index--write-fields-for-add-update (kvs)
-  "Update current line with values from KVS (keys-values)."
-  (while kvs
-    (unless (eq (car kvs) 'ref)
-      (org-index--get-or-set-field (car kvs) (org-trim (cadr kvs))))
-    (setq kvs (cddr kvs))))
-
-
-(defun org-index--do-delete ()
-  "Perform command delete."
-
-  (unless (org-at-heading-p)
-    (error "Not at headline"))
-
-  (let* ((id (org-entry-get (point) "ID"))
-         (ref (org-index--ref-from-id id)))
-
-    ;; maybe delete from heading
-    (if ref
-        (save-excursion
-          (end-of-line)
-          (let ((end (point)))
-            (beginning-of-line)
-            (when (search-forward ref end t)
-              (delete-char (- (length ref)))
-              (just-one-space)))))
-
-    ;; delete from index table
-    (if  (org-index--delete-line id)
-        (format "Deleted index line %s" ref)
-      (format "Did not find id %s in index" id))))
-
-
-(defun org-index--go (&optional column value)
-  "Position cursor on index line where COLUMN equals VALUE.
-Return t or nil, leave point on line or at top of table, needs to be in buffer initially."
-  (let (found text)
-
-    (unless (eq (current-buffer) org-index--buffer)
-      (error "This is a bug: Not in index buffer"))
-
-    ;; loop over lines
-    (goto-char org-index--below-hline)
-    (if column
-        (progn
-          (forward-line -1)
-          (while (and (not found)
-                      (forward-line)
-                      (org-at-table-p))
-            (setq found (string= value (org-index--get-or-set-field column)))))
-      (setq found t))
-
-    ;; return value
-    (if found
-        t
-      (goto-char org-index--below-hline)
-      nil)))
-
-
-(defun org-index--do-head (ref id &optional other)
-  "Perform command head: Find node with REF or ID and present it.
-If OTHER in separate window."
-  
-  (setq org-index--last-ref ref)
-
-  (let (message marker)
-
-    (setq marker (org-id-find id t))
-
-    (if marker
-        (progn
-          (org-index--update-line id)
-          (let (cb)
-            (if other
-                (progn
-                  (setq cb (current-buffer))
-                  (pop-to-buffer (marker-buffer marker)))
-              (pop-to-buffer-same-window (marker-buffer marker)))
-              
-            (goto-char marker)
-            (org-reveal t)
-            (org-show-entry)
-            (recenter))
-          (setq message (format "Found headline %s" ref)))
-      (setq message (format "Did not find headline %s" ref)))))
-
-
-(defun org-index--do-occur ()
-  "Perform command occur."
-  (let ((word "") ; last word to search for growing and shrinking on keystrokes
-        (prompt "Search for: ")
-        (lines-wanted (window-body-height))
-        (lines-found 0)                      ; number of lines found
-        words                                ; list words that should match
-        occur-buffer
-        begin ; position of first line
-        narrow                         ; start of narrowed buffer
-        help-text                      ; cons with help text short and long
-        key-help                       ; for keys with special function
-        search-text                    ; description of text to search for
-        done                           ; true, if loop is done
-        in-c-backspace                 ; true, while processing C-backspace
-        show-headings                  ; true, if headings should be shown
-        help-overlay                   ; Overlay with help text
-        last-point                     ; Last position before end of search
-        key                            ; input from user
-        key-sequence)                  ; as a sequence
-
-    
-    ;; make and show buffer
-    (if (get-buffer org-index--occur-buffer-name)
-        (kill-buffer org-index--occur-buffer-name))
-    (setq occur-buffer (make-indirect-buffer org-index--buffer org-index--occur-buffer-name))
-    (pop-to-buffer-same-window occur-buffer)
-    ;; avoid modifying direct buffer
-    (setq buffer-read-only t)
-    (toggle-truncate-lines 1)
-    (setq font-lock-keywords-case-fold-search t)
-    (setq case-fold-search t)
-
-    ;; reset stack and overlays
-    (setq org-index--occur-stack nil)
-    (setq org-index--occur-tail-overlay nil)
-    
-    ;; narrow to table rows and one line before
-    (goto-char (marker-position org-index--below-hline))
-    (forward-line 0)
-    (setq begin (point))
-    (forward-line -1)
-    (setq narrow (point))
-    (while (org-at-table-p)
-      (forward-line))
-    (narrow-to-region narrow (point))
-    (goto-char (point-min))
-    (forward-line)
-
-    ;; initialize help text
-    (setq help-text (cons
-                     "Incremental occur; `?' toggles help and headlines.\n"
-                     (concat
-                      (org-index--wrap
-                       (concat
-                        "Normal keys add to search word;  or  start additional word;  erases last char,  last word;  jumps to heading,  jumps to heading in other window; all other keys end search.\n"))
-                      org-index--headings)))
-    
-    ;; insert overlays for help text and to cover unsearched lines
-    (setq help-overlay (make-overlay (point-min) begin))
-    (overlay-put help-overlay 'display (car help-text))
-    (overlay-put help-overlay 'face 'org-agenda-dimmed-todo-face)
-    (setq org-index--occur-tail-overlay (make-overlay (point-max) (point-max)))
-    (overlay-put org-index--occur-tail-overlay 'invisible t)
-
-    (while (not done)
-
-      (if in-c-backspace
-          (setq key "")
-        (setq search-text (mapconcat 'identity (reverse (cons word words)) ","))
-        ;; read key
-        (setq key-sequence
-              (vector (read-key
-                       (format "%s%s%s"
-                               prompt
-                               search-text
-                               (if (string= search-text "") "" " ")))))
-        (setq key (key-description key-sequence)))
-
-      (cond
-
-
-       ((string= key "")
-        (setq in-c-backspace t))
-
-
-       ((member key (list "" "DEL"))   ; erase last char
-
-        (if (= (length word) 0)
-
-            ;; nothing more to delete from current word; try next
-            (progn
-              (setq word (car words))
-              (setq words (cdr words))
-              (setq in-c-backspace nil))
-
-          ;; unhighlight longer match
-          (unhighlight-regexp (regexp-quote word))
-
-          ;; some chars are left; shorten word
-          (setq word (substring word 0 -1))
-          (when (= (length word) 0) ; when nothing left, use next word from list
-            (setq word (car words))
-            (setq words (cdr words))
-            (setq in-c-backspace nil))
-
-          ;; free top list of overlays and remove list
-          (setq lines-found (or (org-index--unhide) lines-wanted))
-          (move-overlay org-index--occur-tail-overlay
-                        (if org-index--occur-stack (cdr (assoc :end-of-visible (car org-index--occur-stack)))
-                          (point-max))
-                        (point-max))
-        
-                
-          ;; highlight shorter word
-          (unless (= (length word) 0)
-            (highlight-regexp (regexp-quote word) 'isearch))
-
-          ;; make sure, point is still visible
-          (goto-char begin)))
-
-
-       ((member key (list "SPC" ",")) ; space or comma: enter an additional search word
-
-        ;; push current word and clear, no need to change display
-        (setq words (cons word words))
-        (setq word ""))
-
-
-       ((string= key "?") ; question mark: toggle display of headlines and help
-        (setq help-text (cons (cdr help-text) (car help-text)))
-        (overlay-put help-overlay 'display (car help-text)))
-
-       ((and (= (length key) 1)
-             (aref printable-chars (elt key 0))) ; any printable char: add to current search word
-
-        ;; unhighlight short word
-        (unless (= (length word) 0)
-          (unhighlight-regexp (regexp-quote word)))
-
-        ;; add to word
-        (setq word (concat word key))
-                
-        ;; make overlays to hide lines, that do not match longer word any more
-        (goto-char begin)
-        (setq lines-found (org-index--hide-with-overlays (cons word words) lines-wanted))
-        (move-overlay org-index--occur-tail-overlay
-                      (if org-index--occur-stack (cdr (assoc :end-of-visible (car org-index--occur-stack)))
-                        (point-max))
-                      (point-max))
-        
-        (goto-char begin)
-                
-        ;; highlight longer word
-        (highlight-regexp (regexp-quote word) 'isearch)
-
-        ;; make sure, point is on a visible line
-        (line-move -1 t)
-        (line-move 1 t))
-
-       ;; anything else terminates loop
-       (t (setq done t))))
-
-    ;; put back input event, that caused the loop to end
-    (unless (string= key "C-g")
-      (setq unread-command-events (listify-key-sequence key-sequence))
-      (message key))
-    
-    ;; postprocessing
-    (setq last-point (point))
-    
-    ;; For performance reasons do not show matching lines for rest of table. So no code here.
-    
-    ;; make permanent copy
-    ;; copy visible lines
-    (let ((lines-collected 0)
-          keymap line all-lines end-of-head)
-
-      (setq cursor-type t)
-      (goto-char begin)
-
-      ;; collect all visible lines
-      (while (and (not (eobp))
-                  (< lines-collected lines-wanted))
-        ;; skip over invisible lines
-        (while (and (invisible-p (point))
-                    (not (eobp)))
-          (goto-char (1+ (overlay-end (car (overlays-at (point)))))))
-        (setq line (buffer-substring (line-beginning-position) (line-end-position)))
-        (unless (string= line "")
-          (incf lines-collected)
-          (setq all-lines (cons (concat line
-                                        "\n")
-                                all-lines)))
-        (forward-line 1))
-        
-      (kill-buffer org-index--occur-buffer-name) ; cannot keep this buffer; might become stale soon
-
-      ;; create new buffer
-      (setq occur-buffer (get-buffer-create org-index--occur-buffer-name))
-      (pop-to-buffer-same-window occur-buffer)
-      (insert org-index--headings)
-      (setq end-of-head (point))
-
-      ;; insert into new buffer
-      (save-excursion
-        (apply 'insert (reverse all-lines))
-        (if (= lines-collected lines-wanted)
-            (insert "\n(more lines omitted)\n")))
-      
-      (org-mode)
-      (setq truncate-lines t)
-      (if (org-at-table-p) (org-table-align))
-      (font-lock-fontify-buffer)
-
-      ;; prepare help text
-      (setq org-index--occur-help-overlay (make-overlay (point-min) end-of-head))
-      (setq org-index--occur-help-text
-            (cons
-             (org-index--wrap
-              (concat "Search is done; `?' toggles help and headlines.\n"))
-             (concat
-              (org-index--wrap (format (concat "Search is done. "
-                                               (if (< lines-collected lines-wanted)
-                                                   " Showing all %d matches for "
-                                                 " Showing one window of matches for ")
-                                               "\"" search-text
-                                               "\".  jumps to heading,  jumps to heading in other window,  to matching line in index,  increments count.\n" )
-                                       (length all-lines)))
-              org-index--headings)))
-      
-      (overlay-put org-index--occur-help-overlay 'display (car org-index--occur-help-text))
-      (overlay-put org-index--occur-help-overlay 'face 'org-agenda-dimmed-todo-face)
-
-      ;; highlight words
-      (setq case-fold-search t)
-      (setq font-lock-keywords-case-fold-search t)
-      (mapc (lambda (w) (unless (or (not w) (string= w "")) (highlight-regexp (regexp-quote w) 'isearch)))
-            (cons word words))
-
-      (setq buffer-read-only t)
-
-      ;; install keyboard-shortcuts
-      (setq keymap (make-sparse-keymap))
-      (set-keymap-parent keymap org-mode-map)
-
-      (mapc (lambda (x) (define-key keymap (kbd x)
-                     (lambda () (interactive)
-                       (message "%s" (org-index--occur-to-head)))))
-            (list "" "RET"))
-
-      (define-key keymap (kbd "")
-        (lambda () (interactive)
-          (message (org-index--occur-to-head t))))
-      
-      (define-key keymap (kbd "SPC")
-        (lambda () (interactive)
-          ;; increment in index
-          (let ((ref (org-index--get-or-set-field 'ref))
-                count)
-            (org-index--on
-                'ref ref
-                (setq count (+ 1 (string-to-number (org-index--get-or-set-field 'count))))
-                (org-index--get-or-set-field 'count (number-to-string count))
-                (org-index--promote-current-line)
-                (org-index--align-and-fontify-current-line))
-            ;; increment in this buffer
-            (let ((inhibit-read-only t))
-              (org-index--get-or-set-field 'count (number-to-string count)))
-            (message "Incremented count to %d" count))))
-      
-      (define-key keymap (kbd "")
-        (lambda () (interactive)
-          (org-index 'enter (org-index--get-or-set-field 'ref))))
-      
-      (define-key keymap (kbd "?")
-        (lambda () (interactive)
-          (setq-local org-index--occur-help-text (cons (cdr org-index--occur-help-text) (car org-index--occur-help-text)))
-          (overlay-put org-index--occur-help-overlay 'display (car org-index--occur-help-text))))
-    
-      (use-local-map keymap))))
-
-
-(defun org-index--wrap (text)
-  "Wrap TEXT at fill column."
-  (with-temp-buffer
-    (insert text)
-    (fill-region (point-min) (point-max) nil t)
-    (buffer-string)))
-
-
-(defun org-index--occur-to-head (&optional other)
-  "Helper for `org-index--occur', find heading with ref or id; if OTHER, in other window."
-  (let ((ref (org-index--get-or-set-field 'ref))
-        (id (org-index--get-or-set-field 'id)))
-    (if id
-        (org-index--do-head ref id other)
-      (message "Current line has no id."))))
-
-
-(defun org-index--hide-with-overlays (words lines-wanted)
-  "Hide text that is currently visible and does not match WORDS by creating overlays; leave LINES-WANTED lines visible."
-  (let ((lines-found 0)
-        (end-of-visible (point))
-        overlay overlays start matched)
-
-    ;; main loop
-    (while (and (not (eobp))
-                (< lines-found lines-wanted))
-
-      ;; skip invisible lines
-      (while (and (not (eobp))
-                  (and
-                   (invisible-p (point))
-                   (< (point) (overlay-start org-index--occur-tail-overlay))))
-        (goto-char (overlay-end (car (overlays-at (point))))))
-
-      ;; find stretch of lines, that are currently visible but should be invisible now
-      (setq matched nil)
-      (setq start (point))
-      (while (and (not (eobp))
-                  (not
-                   (and
-                    (invisible-p (point))
-                    (< (point) (overlay-start org-index--occur-tail-overlay))))
-                  (not (and (org-index--test-words words)
-                            (setq matched t)))) ; for its side effect
-        (forward-line 1))
-
-      ;; create overlay to hide this stretch
-      (when (< start (point))           ; avoid creating an empty overlay
-        (setq overlay (make-overlay start (point)))
-        (overlay-put overlay 'invisible t)
-        (setq overlays (cons overlay overlays)))
-
-      ;; skip and count line, that matched
-      (when matched
-        (forward-line 1)
-        (setq end-of-visible (point))
-        (incf lines-found)))
-    
-    ;; put new list on top of stack
-    (setq org-index--occur-stack
-          (cons (list (cons :overlays overlays)
-                      (cons :end-of-visible end-of-visible)
-                      (cons :lines lines-found))
-                org-index--occur-stack))
-
-    lines-found))
-
-
-(defun org-index--unhide ()
-  "Unhide text that does has been hidden by `org-index--hide-with-overlays'."
-  (when org-index--occur-stack
-    ;; delete overlays and make visible again
-    (mapc (lambda (y)
-            (delete-overlay y))
-          (cdr (assoc :overlays (car org-index--occur-stack))))
-          ;; remove from stack
-    (setq org-index--occur-stack (cdr org-index--occur-stack))
-    ;; return number of lines, that are now visible
-    (if org-index--occur-stack (cdr (assoc :lines (car org-index--occur-stack))))))
-
-
-(defun org-index--test-words (words)
-  "Test current line for match against WORDS."
-  (let (line)
-    (setq line (downcase (buffer-substring (line-beginning-position) (line-beginning-position 2))))
-    (catch 'not-found
-      (dolist (w words)
-        (or (search w line)
-            (throw 'not-found nil)))
-      t)))
-
-
-(defun org-index--create-new-line ()
-  "Do the common work for `org-index-new-line' and `org-index'."
-
-  (let (new)
-
-    ;; construct new reference
-    (unless new
-      (setq new (format "%s%d%s" org-index--head (1+ org-index--maxref) org-index--tail)))
-
-    ;; insert ref or id as last or first line, depending on sort-column
-    (goto-char org-index--below-hline)
-    (if (eq (org-index--special-column 'sort) 'count)
-        (progn
-          (while (org-at-table-p)
-            (forward-line))
-          (forward-line -1)
-          (org-table-insert-row t))
-      (org-table-insert-row))
-
-    ;; insert some of the standard values
-    (org-table-goto-column (org-index--column-num 'created))
-    (org-insert-time-stamp nil nil t)
-    (org-table-goto-column (org-index--column-num 'count))
-    (insert "1")
-
-    new))
-
-
-(defun org-index--sort-silent ()
-  "Sort index for default column to remove any effects of temporary sorting."
-  (save-excursion
-    (org-index--verify-id)
-    (org-index--parse-table)
-    (org-index--on nil nil
-      (org-index--do-sort-index (org-index--special-column 'sort))
-      (org-table-align)
-      (remove-hook 'before-save-hook 'org-index--sort-silent))))
-
-
-(defun org-index--copy-visible (beg end)
-  "Copy the visible parts of the region without adding it to kill-ring; copy of `org-copy-visible'"
-  (let (snippets s)
-    (save-excursion
-      (save-restriction
-	(narrow-to-region beg end)
-	(setq s (goto-char (point-min)))
-	(while (not (= (point) (point-max)))
-	  (goto-char (org-find-invisible))
-	  (push (buffer-substring s (point)) snippets)
-	  (setq s (goto-char (org-find-visible))))))
-    (apply 'concat (nreverse snippets))))
-
-
-(provide 'org-index)
-
-;; Local Variables:
-;; fill-column: 75
-;; comment-column: 50
-;; End:
-
-;;; org-index.el ends here
diff --git a/elpa/org-plus-contrib-20150831/org-info.el b/elpa/org-plus-contrib-20150831/org-info.el
deleted file mode 100644
index b9f7ba00..00000000
--- a/elpa/org-plus-contrib-20150831/org-info.el
+++ /dev/null
@@ -1,99 +0,0 @@
-;;; org-info.el --- Support for links to Info nodes from within Org-Mode
-
-;; Copyright (C) 2004-2015 Free Software Foundation, Inc.
-
-;; Author: Carsten Dominik 
-;; 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 .
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;
-;;; Commentary:
-
-;; This file implements links to Info nodes 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 Info-find-node "info" (filename nodename
-						  &optional no-going-back))
-(defvar Info-current-file)
-(defvar Info-current-node)
-
-;; Install the link type
-(org-add-link-type "info" 'org-info-open 'org-info-export)
-(add-hook 'org-store-link-functions 'org-info-store-link)
-
-;; Implementation
-(defun org-info-store-link ()
-  "Store a link to an Info file and node."
-  (when (eq major-mode 'Info-mode)
-    (let (link desc)
-      (setq link (concat "info:"
-			 (file-name-nondirectory Info-current-file)
-			 "#" Info-current-node))
-      (setq desc (concat (file-name-nondirectory Info-current-file)
-			 "#" Info-current-node))
-      (org-store-link-props :type "info" :file Info-current-file
-			    :node Info-current-node
-			    :link link :desc desc)
-      link)))
-
-(defun org-info-open (path)
-  "Follow an Info file and node link specified by PATH."
-  (org-info-follow-link path))
-
-
-(defun org-info-follow-link (name)
-  "Follow an Info file and node link specified by NAME."
-  (if (or (string-match "\\(.*\\)[#:]:?\\(.*\\)" name)
-          (string-match "\\(.*\\)" name))
-      (let ((filename (match-string 1 name))
-	    (nodename-or-index (or (match-string 2 name) "Top")))
-	(require 'info)
-	;; If nodename-or-index is invalid node name, then look it up
-	;; in the index.
-	(condition-case nil
-	    (Info-find-node filename nodename-or-index)
-	  (user-error (Info-find-node filename "Top")
-		      (condition-case nil
-			  (Info-index nodename-or-index)
-			(user-error "Could not find '%s' node or index entry"
-				    nodename-or-index)))))
-    (user-error "Could not open: %s" name)))
-
-(defun org-info-export (path desc format)
-  "Export an info link.
-See `org-add-link-type' for details about PATH, DESC and FORMAT."
-  (when (eq format 'html)
-    (or (string-match "\\(.*\\)[#:]:?\\(.*\\)" path)
-	(string-match "\\(.*\\)" path))
-    (let ((filename (match-string 1 path))
-	  (node (or (match-string 2 path) "Top")))
-      (format "%s"
-	      filename
-	      (replace-regexp-in-string " " "-" node)
-	      (or desc path)))))
-
-(provide 'org-info)
-
-;;; org-info.el ends here
diff --git a/elpa/org-plus-contrib-20150831/org-mime.el b/elpa/org-plus-contrib-20150831/org-mime.el
deleted file mode 100644
index 682f635e..00000000
--- a/elpa/org-plus-contrib-20150831/org-mime.el
+++ /dev/null
@@ -1,346 +0,0 @@
-;;; org-mime.el --- org html export for text/html MIME emails
-
-;; Copyright (C) 2010-2015 Eric Schulte
-
-;; Author: Eric Schulte
-;; Keywords: mime, mail, email, html
-;; Homepage: http://orgmode.org/worg/org-contrib/org-mime.php
-;; Version: 0.01
-
-;; This file is not part of GNU Emacs.
-
-;;; License:
-
-;; 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, 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 GNU Emacs.  If not, see .
-
-;;; Commentary:
-
-;; WYSWYG, html mime composition using org-mode
-;;
-;; For mail composed using the orgstruct-mode minor mode, this
-;; provides a function for converting all or part of your mail buffer
-;; to embedded html as exported by org-mode.  Call `org-mime-htmlize'
-;; in a message buffer to convert either the active region or the
-;; entire buffer to html.
-;;
-;; Similarly the `org-mime-org-buffer-htmlize' function can be called
-;; from within an org-mode buffer to convert the buffer to html, and
-;; package the results into an email handling with appropriate MIME
-;; encoding.
-;;
-;; you might want to bind this to a key with something like the
-;; following message-mode binding
-;;
-;;   (add-hook 'message-mode-hook
-;;             (lambda ()
-;;               (local-set-key "\C-c\M-o" 'org-mime-htmlize)))
-;;
-;; and the following org-mode binding
-;;
-;;   (add-hook 'org-mode-hook
-;;             (lambda ()
-;;               (local-set-key "\C-c\M-o" 'org-mime-org-buffer-htmlize)))
-
-;;; Code:
-(require 'cl)
-
-(declare-function org-export-string-as "ox"
-		  (string backend &optional body-only ext-plist))
-
-(defcustom org-mime-use-property-inheritance nil
-  "Non-nil means al MAIL_ properties apply also for sublevels."
-  :group 'org-mime
-  :type 'boolean)
-
-(defcustom org-mime-default-header
-  "#+OPTIONS: latex:t\n"
-  "Default header to control html export options, and ensure
-  first line isn't assumed to be a title line."
-  :group 'org-mime
-  :type 'string)
-
-(defcustom org-mime-library 'mml
-  "Library to use for marking up MIME elements."
-  :group 'org-mime
-  :type '(choice 'mml 'semi 'vm))
-
-(defcustom org-mime-preserve-breaks t
-  "Used as temporary value of `org-export-preserve-breaks' during
-  mime encoding."
-  :group 'org-mime
-  :type 'boolean)
-
-(defcustom org-mime-fixedwith-wrap
-  "
\n%s
\n" - "Format string used to wrap a fixedwidth HTML email." - :group 'org-mime - :type 'string) - -(defcustom org-mime-html-hook nil - "Hook to run over the html buffer before attachment to email. - This could be used for example to post-process html elements." - :group 'org-mime - :type 'hook) - -(mapc (lambda (fmt) - (eval `(defcustom - ,(intern (concat "org-mime-pre-" fmt "-hook")) - nil - (concat "Hook to run before " fmt " export.\nFunctions " - "should take no arguments and will be run in a " - "buffer holding\nthe text to be exported.")))) - '("ascii" "org" "html")) - -(defcustom org-mime-send-subtree-hook nil - "Hook to run in the subtree in the Org-mode file before export.") - -(defcustom org-mime-send-buffer-hook nil - "Hook to run in the Org-mode file before export.") - -;; example hook, for setting a dark background in
 elements
-(defun org-mime-change-element-style (element style)
-  "Set new default htlm style for  elements in exported html."
-  (while (re-search-forward (format "<%s\\>" element) nil t)
-    (replace-match (format "<%s style=\"%s\"" element style))))
-
-(defun org-mime-change-class-style (class style)
-  "Set new default htlm style for objects with classs=CLASS in
-exported html."
-  (while (re-search-forward (format "class=\"%s\"" class) nil t)
-    (replace-match (format "class=\"%s\" style=\"%s\"" class style))))
-
-;; ;; example addition to `org-mime-html-hook' adding a dark background
-;; ;; color to 
 elements
-;; (add-hook 'org-mime-html-hook
-;;           (lambda ()
-;;             (org-mime-change-element-style
-;;              "pre" (format "color: %s; background-color: %s;"
-;;                            "#E6E1DC" "#232323"))
-;; 	    (org-mime-change-class-style
-;;              "verse" "border-left: 2px solid gray; padding-left: 4px;")))
-
-(defun org-mime-file (ext path id)
-  "Markup a file for attachment."
-  (case org-mime-library
-    ('mml (format (concat "<#part type=\"%s\" filename=\"%s\" "
-			  "disposition=inline id=\"<%s>\">\n<#/part>\n")
-		  ext path id))
-    ('semi (concat
-            (format (concat "--[[%s\nContent-Disposition: "
-			    "inline;\nContent-ID: <%s>][base64]]\n")
-		    ext id)
-            (base64-encode-string
-             (with-temp-buffer
-               (set-buffer-multibyte nil)
-               (binary-insert-encoded-file path)
-               (buffer-string)))))
-    ('vm "?")))
-
-(defun org-mime-multipart (plain html &optional images)
-  "Markup a multipart/alternative with text/plain and text/html alternatives.
-If the html portion of the message includes images wrap the html
-and images in a multipart/related part."
-  (case org-mime-library
-    ('mml (concat "<#multipart type=alternative><#part type=text/plain>"
-		  plain
-		  (when images "<#multipart type=related>")
-		  "<#part type=text/html>"
-		  html
-		  images
-		  (when images "<#/multipart>\n")
-		  "<#/multipart>\n"))
-    ('semi (concat
-            "--" "<>-{\n"
-            "--" "[[text/plain]]\n" plain
-	    (if (and images (> (length images) 0))
-		(concat "--" "<>-{\n"
-			"--" "[[text/html]]\n"  html
-			images
-			"--" "}-<>\n")
-	      (concat "--" "[[text/html]]\n"  html
-		      images))
-            "--" "}-<>\n"))
-    ('vm "?")))
-
-(defun org-mime-replace-images (str current-file)
-  "Replace images in html files with cid links."
-  (let (html-images)
-    (cons
-     (replace-regexp-in-string ;; replace images in html
-      "src=\"\\([^\"]+\\)\""
-      (lambda (text)
-        (format
-         "src=\"cid:%s\""
-         (let* ((url (and (string-match "src=\"\\([^\"]+\\)\"" text)
-                          (match-string 1 text)))
-                (path (expand-file-name
-                       url (file-name-directory current-file)))
-                (ext (file-name-extension path))
-                (id (replace-regexp-in-string "[\/\\\\]" "_" path)))
-           (add-to-list 'html-images
-                        (org-mime-file (concat "image/" ext) path id))
-           id)))
-      str)
-     html-images)))
-
-(defun org-mime-htmlize (&optional arg)
-  "Export to HTML an email body composed using `mml-mode'.
-If called with an active region only export that region,
-otherwise export the entire body."
-  (interactive "P")
-  (require 'ox-org)
-  (require 'ox-html)
-  (let* ((region-p (org-region-active-p))
-         (html-start (or (and region-p (region-beginning))
-                         (save-excursion
-                           (goto-char (point-min))
-                           (search-forward mail-header-separator)
-                           (+ (point) 1))))
-         (html-end (or (and region-p (region-end))
-                       ;; TODO: should catch signature...
-                       (point-max)))
-         (raw-body (concat org-mime-default-header
-			   (buffer-substring html-start html-end)))
-         (tmp-file (make-temp-name (expand-file-name
-				    "mail" temporary-file-directory)))
-         (body (org-export-string-as raw-body 'org t))
-         ;; because we probably don't want to export a huge style file
-         (org-export-htmlize-output-type 'inline-css)
-         ;; makes the replies with ">"s look nicer
-         (org-export-preserve-breaks org-mime-preserve-breaks)
-	 ;; dvipng for inline latex because MathJax doesn't work in mail
-	 (org-html-with-latex 'dvipng)
-         ;; to hold attachments for inline html images
-         (html-and-images
-          (org-mime-replace-images
-	   (org-export-string-as raw-body 'html t) tmp-file))
-         (html-images (unless arg (cdr html-and-images)))
-         (html (org-mime-apply-html-hook
-                (if arg
-                    (format org-mime-fixedwith-wrap body)
-                  (car html-and-images)))))
-    (delete-region html-start html-end)
-    (save-excursion
-      (goto-char html-start)
-      (insert (org-mime-multipart
-	       body html (mapconcat 'identity html-images "\n"))))))
-
-(defun org-mime-apply-html-hook (html)
-  (if org-mime-html-hook
-      (with-temp-buffer
-        (insert html)
-        (goto-char (point-min))
-        (run-hooks 'org-mime-html-hook)
-        (buffer-string))
-    html))
-
-(defmacro org-mime-try (&rest body)
-  `(condition-case nil ,@body (error nil)))
-
-(defun org-mime-send-subtree (&optional fmt)
-  (save-restriction
-    (org-narrow-to-subtree)
-    (run-hooks 'org-mime-send-subtree-hook)
-    (let* ((mp (lambda (p) (org-entry-get nil p org-mime-use-property-inheritance)))
-	   (file (buffer-file-name (current-buffer)))
-	   (subject (or (funcall mp "MAIL_SUBJECT") (nth 4 (org-heading-components))))
-	   (to (funcall mp "MAIL_TO"))
-	   (cc (funcall mp "MAIL_CC"))
-	   (bcc (funcall mp "MAIL_BCC"))
-	   (body (buffer-substring
-		  (save-excursion (goto-char (point-min))
-				  (forward-line 1)
-				  (when (looking-at "[ \t]*:PROPERTIES:")
-				    (re-search-forward ":END:" nil)
-				    (forward-char))
-				  (point))
-		  (point-max))))
-      (org-mime-compose body (or fmt 'org) file to subject
-			`((cc . ,cc) (bcc . ,bcc))))))
-
-(defun org-mime-send-buffer (&optional fmt)
-  (run-hooks 'org-mime-send-buffer-hook)
-  (let* ((region-p (org-region-active-p))
-	 (file (buffer-file-name (current-buffer)))
-	 (subject (if (not file) (buffer-name (buffer-base-buffer))
-		   (file-name-sans-extension
-		    (file-name-nondirectory file))))
-         (body-start (or (and region-p (region-beginning))
-                         (save-excursion (goto-char (point-min)))))
-         (body-end (or (and region-p (region-end)) (point-max)))
-	 (temp-body-file (make-temp-file "org-mime-export"))
-	 (body (buffer-substring body-start body-end)))
-    (org-mime-compose body (or fmt 'org) file nil subject)))
-
-(defun org-mime-compose (body fmt file &optional to subject headers)
-  (require 'message)
-  (compose-mail to subject headers nil)
-  (message-goto-body)
-  (let ((bhook
-	 (lambda (body fmt)
-	   (let ((hook (intern (concat "org-mime-pre-"
-				       (symbol-name fmt)
-				       "-hook"))))
-	     (if (> (eval `(length ,hook)) 0)
-		 (with-temp-buffer
-		   (insert body)
-		   (goto-char (point-min))
-		   (eval `(run-hooks ',hook))
-		   (buffer-string))
-	       body))))
-	(fmt (if (symbolp fmt) fmt (intern fmt))))
-    (cond
-     ((eq fmt 'org)
-      (require 'ox-org)
-      (insert (org-export-string-as
-	       (org-babel-trim (funcall bhook body 'org)) 'org t)))
-     ((eq fmt 'ascii)
-      (require 'ox-ascii)
-      (insert (org-export-string-as
-	       (concat "#+Title:\n" (funcall bhook body 'ascii)) 'ascii t)))
-     ((or (eq fmt 'html) (eq fmt 'html-ascii))
-      (require 'ox-ascii)
-      (require 'ox-org)
-      (let* ((org-link-file-path-type 'absolute)
-	     ;; we probably don't want to export a huge style file
-	     (org-export-htmlize-output-type 'inline-css)
-	     (html-and-images
-	      (org-mime-replace-images
-	       (org-export-string-as (funcall bhook body 'html) 'html t) file))
-	     (images (cdr html-and-images))
-	     (html (org-mime-apply-html-hook (car html-and-images))))
-	(insert (org-mime-multipart
-		 (org-export-string-as
-		  (org-babel-trim
-		   (funcall bhook body (if (eq fmt 'html) 'org 'ascii)))
-		  (if (eq fmt 'html) 'org 'ascii) t)
-		 html)
-		(mapconcat 'identity images "\n")))))))
-
-(defun org-mime-org-buffer-htmlize ()
-  "Create an email buffer containing the current org-mode file
-  exported to html and encoded in both html and in org formats as
-  mime alternatives."
-  (interactive)
-  (org-mime-send-buffer 'html))
-
-(defun org-mime-subtree ()
-  "Create an email buffer containing the current org-mode subtree
-  exported to a org format or to the format specified by the
-  MAIL_FMT property of the subtree."
-  (interactive)
-  (org-mime-send-subtree
-   (or (org-entry-get nil "MAIL_FMT" org-mime-use-property-inheritance) 'org)))
-
-(provide 'org-mime)
diff --git a/elpa/org-plus-contrib-20150831/org-plus-contrib-autoloads.el b/elpa/org-plus-contrib-20150831/org-plus-contrib-autoloads.el
deleted file mode 100644
index 949b79df..00000000
--- a/elpa/org-plus-contrib-20150831/org-plus-contrib-autoloads.el
+++ /dev/null
@@ -1,1179 +0,0 @@
-;;; org-plus-contrib-autoloads.el --- automatically extracted autoloads
-;;
-;;; Code:
-(add-to-list 'load-path (or (file-name-directory #$) (car load-path)))
-
-;;;### (autoloads nil "org" "org.el" (21988 3440 0 0))
-;;; Generated autoloads from org.el
-
-(autoload 'org-babel-do-load-languages "org" "\
-Load the languages defined in `org-babel-load-languages'.
-
-\(fn SYM VALUE)" nil nil)
-
-(autoload 'org-babel-load-file "org" "\
-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.
-
-\(fn FILE &optional COMPILE)" t nil)
-
-(autoload 'org-version "org" "\
-Show the org-mode version.
-Interactively, or when MESSAGE is non-nil, show it in echo area.
-With prefix argument, or when HERE is non-nil, insert it at point.
-In non-interactive uses, a reduced version string is output unless
-FULL is given.
-
-\(fn &optional HERE FULL MESSAGE)" t nil)
-
-(autoload 'turn-on-orgtbl "org" "\
-Unconditionally turn on `orgtbl-mode'.
-
-\(fn)" nil nil)
-
-(autoload 'org-clock-persistence-insinuate "org" "\
-Set up hooks for clock persistence.
-
-\(fn)" nil nil)
-
-(autoload 'org-mode "org" "\
-Outline-based notes management and organizer, alias
-\"Carsten's outline-mode for keeping track of everything.\"
-
-Org-mode develops organizational tasks around a NOTES file which
-contains information about projects as plain text.  Org-mode is
-implemented on top of outline-mode, which is ideal to keep the content
-of large files well structured.  It supports ToDo items, deadlines and
-time stamps, which magically appear in the diary listing of the Emacs
-calendar.  Tables are easily created with a built-in table editor.
-Plain text URL-like links connect to websites, emails (VM), Usenet
-messages (Gnus), BBDB entries, and any files related to the project.
-For printing and sharing of notes, an Org-mode file (or a part of it)
-can be exported as a structured ASCII or HTML file.
-
-The following commands are available:
-
-\\{org-mode-map}
-
-\(fn)" t nil)
-
-(autoload 'org-cycle "org" "\
-TAB-action and visibility cycling for Org-mode.
-
-This is the command invoked in Org-mode by the TAB key.  Its main purpose
-is outline visibility cycling, but it also invokes other actions
-in special contexts.
-
-- When this function is called with a prefix argument, rotate the entire
-  buffer through 3 states (global cycling)
-  1. OVERVIEW: Show only top-level headlines.
-  2. CONTENTS: Show all headlines of all levels, but no body text.
-  3. SHOW ALL: Show everything.
-  When called with two `C-u C-u' prefixes, switch to the startup visibility,
-  determined by the variable `org-startup-folded', and by any VISIBILITY
-  properties in the buffer.
-  When called with three `C-u C-u C-u' prefixed, show the entire buffer,
-  including any drawers.
-
-- When inside a table, re-align the table and move to the next field.
-
-- When point is at the beginning of a headline, rotate the subtree started
-  by this line through 3 different states (local cycling)
-  1. FOLDED:   Only the main headline is shown.
-  2. CHILDREN: The main headline and the direct children are shown.
-               From this state, you can move to one of the children
-               and zoom in further.
-  3. SUBTREE:  Show the entire subtree, including body text.
-  If there is no subtree, switch directly from CHILDREN to FOLDED.
-
-- When point is at the beginning of an empty headline and the variable
-  `org-cycle-level-after-item/entry-creation' is set, cycle the level
-  of the headline by demoting and promoting it to likely levels.  This
-  speeds up creation document structure by pressing TAB once or several
-  times right after creating a new headline.
-
-- When there is a numeric prefix, go up to a heading with level ARG, do
-  a `show-subtree' and return to the previous cursor position.  If ARG
-  is negative, go up that many levels.
-
-- When point is not at the beginning of a headline, execute the global
-  binding for TAB, which is re-indenting the line.  See the option
-  `org-cycle-emulate-tab' for details.
-
-- Special case: if point is at the beginning of the buffer and there is
-  no headline in line 1, this function will act as if called with prefix arg
-  (C-u TAB, same as S-TAB) also when called without prefix arg.
-  But only if also the variable `org-cycle-global-at-bob' is t.
-
-\(fn &optional ARG)" t nil)
-
-(autoload 'org-global-cycle "org" "\
-Cycle the global visibility.  For details see `org-cycle'.
-With \\[universal-argument] prefix arg, switch to startup visibility.
-With a numeric prefix, show all headlines up to that level.
-
-\(fn &optional ARG)" t nil)
-(put 'orgstruct-heading-prefix-regexp 'safe-local-variable 'stringp)
-
-(autoload 'orgstruct-mode "org" "\
-Toggle the minor mode `orgstruct-mode'.
-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).
-
-\(fn &optional ARG)" t nil)
-
-(autoload 'turn-on-orgstruct "org" "\
-Unconditionally turn on `orgstruct-mode'.
-
-\(fn)" nil nil)
-
-(autoload 'turn-on-orgstruct++ "org" "\
-Unconditionally turn on `orgstruct++-mode'.
-
-\(fn)" nil nil)
-
-(autoload 'org-run-like-in-org-mode "org" "\
-Run a command, pretending that the current buffer is in Org-mode.
-This will temporarily bind local variables that are typically bound in
-Org-mode to the values they have in Org-mode, and then interactively
-call CMD.
-
-\(fn CMD)" nil nil)
-
-(autoload 'org-store-link "org" "\
-\\Store an org-link to the current location.
-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'.
-
-A double prefix ARG force skipping storing functions that are not
-part of Org's core.
-
-A triple prefix ARG force storing a link for each line in the
-active region.
-
-\(fn ARG)" t nil)
-
-(autoload 'org-insert-link-global "org" "\
-Insert a link like Org-mode does.
-This command can be called in any mode to insert a link in Org-mode syntax.
-
-\(fn)" t nil)
-
-(autoload 'org-open-at-point-global "org" "\
-Follow a link like Org-mode does.
-This command can be called in any mode to follow a link that has
-Org-mode syntax.
-
-\(fn)" t nil)
-
-(autoload 'org-open-link-from-string "org" "\
-Open a link in the string S, as if it was in Org-mode.
-
-\(fn S &optional ARG REFERENCE-BUFFER)" t nil)
-
-(autoload 'org-switchb "org" "\
-Switch between Org buffers.
-With one prefix argument, restrict available buffers to files.
-With two prefix arguments, restrict available buffers to agenda files.
-
-Defaults to `iswitchb' for buffer name completion.
-Set `org-completion-use-ido' to make it use ido instead.
-
-\(fn &optional ARG)" t nil)
-
-(defalias 'org-ido-switchb 'org-switchb)
-
-(defalias 'org-iswitchb 'org-switchb)
-
-(autoload 'org-cycle-agenda-files "org" "\
-Cycle through the files in `org-agenda-files'.
-If the current buffer visits an agenda file, find the next one in the list.
-If the current buffer does not, find the first agenda file.
-
-\(fn)" t nil)
-
-(autoload 'org-submit-bug-report "org" "\
-Submit a bug report on Org-mode via mail.
-
-Don't hesitate to report any problems or inaccurate documentation.
-
-If you don't have setup sending mail from (X)Emacs, please copy the
-output buffer into your mail program, as it gives us important
-information about your Org-mode version and configuration.
-
-\(fn)" t nil)
-
-(autoload 'org-reload "org" "\
-Reload all org lisp files.
-With prefix arg UNCOMPILED, load the uncompiled versions.
-
-\(fn &optional UNCOMPILED)" t nil)
-
-(autoload 'org-customize "org" "\
-Call the customize function with org as argument.
-
-\(fn)" t nil)
-
-;;;***
-
-;;;### (autoloads nil "org-agenda" "org-agenda.el" (21988 3437 0
-;;;;;;  0))
-;;; Generated autoloads from org-agenda.el
-
-(autoload 'org-toggle-sticky-agenda "org-agenda" "\
-Toggle `org-agenda-sticky'.
-
-\(fn &optional ARG)" t nil)
-
-(autoload 'org-agenda "org-agenda" "\
-Dispatch agenda commands to collect entries to the agenda buffer.
-Prompts for a command to execute.  Any prefix arg will be passed
-on to the selected command.  The default selections are:
-
-a     Call `org-agenda-list' to display the agenda for current day or week.
-t     Call `org-todo-list' to display the global todo list.
-T     Call `org-todo-list' to display the global todo list, select only
-      entries with a specific TODO keyword (the user gets a prompt).
-m     Call `org-tags-view' to display headlines with tags matching
-      a condition  (the user is prompted for the condition).
-M     Like `m', but select only TODO entries, no ordinary headlines.
-L     Create a timeline for the current buffer.
-e     Export views to associated files.
-s     Search entries for keywords.
-S     Search entries for keywords, only with TODO keywords.
-/     Multi occur across all agenda files and also files listed
-      in `org-agenda-text-search-extra-files'.
-<     Restrict agenda commands to buffer, subtree, or region.
-      Press several times to get the desired effect.
->     Remove a previous restriction.
-#     List \"stuck\" projects.
-!     Configure what \"stuck\" means.
-C     Configure custom agenda commands.
-
-More commands can be added by configuring the variable
-`org-agenda-custom-commands'.  In particular, specific tags and TODO keyword
-searches can be pre-defined in this way.
-
-If the current buffer is in Org-mode and visiting a file, you can also
-first press `<' once to indicate that the agenda should be temporarily
-\(until the next use of \\[org-agenda]) restricted to the current file.
-Pressing `<' twice means to restrict to the current subtree or region
-\(if active).
-
-\(fn &optional ARG ORG-KEYS RESTRICTION)" t nil)
-
-(autoload 'org-batch-agenda "org-agenda" "\
-Run an agenda command in batch mode and send the result to STDOUT.
-If CMD-KEY is a string of length 1, it is used as a key in
-`org-agenda-custom-commands' and triggers this command.  If it is a
-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.
-
-\(fn CMD-KEY &rest PARAMETERS)" nil t)
-
-(autoload 'org-batch-agenda-csv "org-agenda" "\
-Run an agenda command in batch mode and send the result to STDOUT.
-If CMD-KEY is a string of length 1, it is used as a key in
-`org-agenda-custom-commands' and triggers this command.  If it is a
-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.
-
-The output gives a line for each selected agenda item.  Each
-item is a list of comma-separated values, like this:
-
-category,head,type,todo,tags,date,time,extra,priority-l,priority-n
-
-category     The category of the item
-head         The headline, without TODO kwd, TAGS and PRIORITY
-type         The type of the agenda entry, can be
-                todo               selected in TODO match
-                tagsmatch          selected in tags match
-                diary              imported from diary
-                deadline           a deadline on given date
-                scheduled          scheduled on given date
-                timestamp          entry has timestamp on given date
-                closed             entry was closed on given date
-                upcoming-deadline  warning about deadline
-                past-scheduled     forwarded scheduled item
-                block              entry has date block including g. date
-todo         The todo keyword, if any
-tags         All tags including inherited ones, separated by colons
-date         The relevant date, like 2007-2-14
-time         The time, like 15:00-16:50
-extra        Sting with extra planning info
-priority-l   The priority letter if any was given
-priority-n   The computed numerical priority
-agenda-day   The day in the agenda where this is listed
-
-\(fn CMD-KEY &rest PARAMETERS)" nil t)
-
-(autoload 'org-store-agenda-views "org-agenda" "\
-Store agenda views.
-
-\(fn &rest PARAMETERS)" t nil)
-
-(autoload 'org-batch-store-agenda-views "org-agenda" "\
-Run all custom agenda commands that have a file argument.
-
-\(fn &rest PARAMETERS)" nil t)
-
-(autoload 'org-agenda-list "org-agenda" "\
-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.
-
-With a numeric prefix argument in an interactive call, the agenda will
-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'.
-
-When WITH-HOUR is non-nil, only include scheduled and deadline
-items if they have an hour specification like [h]h:mm.
-
-\(fn &optional ARG START-DAY SPAN WITH-HOUR)" t nil)
-
-(autoload 'org-search-view "org-agenda" "\
-Show all entries that contain a phrase or words or regular expressions.
-
-With optional prefix argument TODO-ONLY, only consider entries that are
-TODO entries.  The argument STRING can be used to pass a default search
-string into this function.  If EDIT-AT is non-nil, it means that the
-user should get a chance to edit this string, with cursor at position
-EDIT-AT.
-
-The search string can be viewed either as a phrase that should be found as
-is, or it can be broken into a number of snippets, each of which must match
-in a Boolean way to select an entry.  The default depends on the variable
-`org-agenda-search-view-always-boolean'.
-Even if this is turned off (the default) you can always switch to
-Boolean search dynamically by preceding the first word with  \"+\" or \"-\".
-
-The default is a direct search of the whole phrase, where each space in
-the search string can expand to an arbitrary amount of whitespace,
-including newlines.
-
-If using a Boolean search, the search string is split on whitespace and
-each snippet is searched separately, with logical AND to select an entry.
-Words prefixed with a minus must *not* occur in the entry.  Words without
-a prefix or prefixed with a plus must occur in the entry.  Matching is
-case-insensitive.  Words are enclosed by word delimiters (i.e. they must
-match whole words, not parts of a word) if
-`org-agenda-search-view-force-full-words' is set (default is nil).
-
-Boolean search snippets enclosed by curly braces are interpreted as
-regular expressions that must or (when preceded with \"-\") must not
-match in the entry.  Snippets enclosed into double quotes will be taken
-as a whole, to include whitespace.
-
-- If the search string starts with an asterisk, search only in headlines.
-- If (possibly after the leading star) the search string starts with an
-  exclamation mark, this also means to look at TODO entries only, an effect
-  that can also be achieved with a prefix argument.
-- If (possibly after star and exclamation mark) the search string starts
-  with a colon, this will mean that the (non-regexp) snippets of the
-  Boolean search must match as full words.
-
-This command searches the agenda files, and in addition the files listed
-in `org-agenda-text-search-extra-files'.
-
-\(fn &optional TODO-ONLY STRING EDIT-AT)" t nil)
-
-(autoload 'org-todo-list "org-agenda" "\
-Show all (not done) TODO entries from all agenda file in a single list.
-The prefix arg can be used to select a specific TODO keyword and limit
-the list to these.  When using \\[universal-argument], you will be prompted
-for a keyword.  A numeric prefix directly selects the Nth keyword in
-`org-todo-keywords-1'.
-
-\(fn &optional ARG)" t nil)
-
-(autoload 'org-tags-view "org-agenda" "\
-Show all headlines for all `org-agenda-files' matching a TAGS criterion.
-The prefix arg TODO-ONLY limits the search to TODO entries.
-
-\(fn &optional TODO-ONLY MATCH)" t nil)
-
-(autoload 'org-agenda-list-stuck-projects "org-agenda" "\
-Create agenda view for projects that are stuck.
-Stuck projects are project that have no next actions.  For the definitions
-of what a project is and how to check if it stuck, customize the variable
-`org-stuck-projects'.
-
-\(fn &rest IGNORE)" t nil)
-
-(autoload 'org-diary "org-agenda" "\
-Return diary information from org files.
-This function can be used in a \"sexp\" diary entry in the Emacs calendar.
-It accesses org files and extracts information from those files to be
-listed in the diary.  The function accepts arguments specifying what
-items should be listed.  For a list of arguments allowed here, see the
-variable `org-agenda-entry-types'.
-
-The call in the diary file should look like this:
-
-   &%%(org-diary) ~/path/to/some/orgfile.org
-
-Use a separate line for each org file to check.  Or, if you omit the file name,
-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 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)
-
-The function expects the lisp variables `entry' and `date' to be provided
-by the caller, because this is how the calendar works.  Don't use this
-function from a program - use `org-agenda-get-day-entries' instead.
-
-\(fn &rest ARGS)" nil nil)
-
-(autoload 'org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item "org-agenda" "\
-Do we have a reason to ignore this TODO entry because it has a time stamp?
-
-\(fn &optional END)" nil nil)
-
-(autoload 'org-agenda-set-restriction-lock "org-agenda" "\
-Set restriction lock for agenda, to current subtree or file.
-Restriction will be the file if TYPE is `file', or if type is the
-universal prefix '(4), or if the cursor is before the first headline
-in the file.  Otherwise, restriction will be to the current subtree.
-
-\(fn &optional TYPE)" t nil)
-
-(autoload 'org-calendar-goto-agenda "org-agenda" "\
-Compute the Org-mode agenda for the calendar date displayed at the cursor.
-This is a command that has to be installed in `calendar-mode-map'.
-
-\(fn)" t nil)
-
-(autoload 'org-agenda-to-appt "org-agenda" "\
-Activate appointments found in `org-agenda-files'.
-With a \\[universal-argument] prefix, refresh the list of
-appointments.
-
-If FILTER is t, interactively prompt the user for a regular
-expression, and filter out entries that don't match it.
-
-If FILTER is a string, use this string as a regular expression
-for filtering entries out.
-
-If FILTER is a function, filter out entries against which
-calling the function returns nil.  This function takes one
-argument: an entry from `org-agenda-get-day-entries'.
-
-FILTER can also be an alist with the car of each cell being
-either 'headline or 'category.  For example:
-
-  '((headline \"IMPORTANT\")
-    (category \"Work\"))
-
-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*
-\(i.e., deadlines and scheduled items with a hh:mm specification)
-and :timestamp entries.  See the docstring of `org-diary' for
-details and examples.
-
-If an entry has a APPT_WARNTIME property, its value will be used
-to override `appt-message-warning-time'.
-
-\(fn &optional REFRESH FILTER &rest ARGS)" t nil)
-
-;;;***
-
-;;;### (autoloads nil "org-annotate-file" "org-annotate-file.el"
-;;;;;;  (21988 3437 0 0))
-;;; Generated autoloads from org-annotate-file.el
-
-(autoload 'org-annotate-file "org-annotate-file" "\
-Visit `org-annotate-file-storage-file` and add a new annotation section.
-The annotation is opened at the new section which will be referencing
-the point in the current file.
-
-\(fn)" t nil)
-
-(autoload 'org-annotate-file-show-section "org-annotate-file" "\
-Add or show annotation entry in STORAGE-FILE and return the buffer.
-The annotation will link to ANNOTATED-BUFFER if specified,
-  otherwise the current buffer is used.
-
-\(fn STORAGE-FILE &optional ANNOTATED-BUFFER)" nil nil)
-
-;;;***
-
-;;;### (autoloads nil "org-bullets" "org-bullets.el" (21988 3437
-;;;;;;  0 0))
-;;; Generated autoloads from org-bullets.el
-
-(autoload 'org-bullets-mode "org-bullets" "\
-UTF-8 bullets for `org-mode'.
-
-\(fn &optional ARG)" t nil)
-
-;;;***
-
-;;;### (autoloads nil "org-capture" "org-capture.el" (21988 3437
-;;;;;;  0 0))
-;;; Generated autoloads from org-capture.el
-
-(autoload 'org-capture-string "org-capture" "\
-Capture STRING with the template selected by KEYS.
-
-\(fn STRING &optional KEYS)" t nil)
-
-(autoload 'org-capture "org-capture" "\
-Capture something.
-\\
-This will let you select a template from `org-capture-templates', and then
-file the newly captured information.  The text is immediately inserted
-at the target location, and an indirect buffer is shown where you can
-edit it.  Pressing \\[org-capture-finalize] brings you back to the previous state
-of Emacs, so that you can continue your work.
-
-When called interactively with a \\[universal-argument] prefix argument GOTO, don't capture
-anything, just go to the file/headline where the selected template
-stores its notes.  With a double prefix argument \\[universal-argument] \\[universal-argument], go to the last note
-stored.
-
-When called with a `C-0' (zero) prefix, insert a template at point.
-
-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.  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.
-
-\(fn &optional GOTO KEYS)" t nil)
-
-(autoload 'org-capture-import-remember-templates "org-capture" "\
-Set `org-capture-templates' to be similar to `org-remember-templates'.
-
-\(fn)" t nil)
-
-;;;***
-
-;;;### (autoloads nil "org-colview" "org-colview.el" (21988 3437
-;;;;;;  0 0))
-;;; Generated autoloads from org-colview.el
-
-(autoload 'org-columns-remove-overlays "org-colview" "\
-Remove all currently active column overlays.
-
-\(fn)" t nil)
-
-(autoload 'org-columns-get-format-and-top-level "org-colview" "\
-
-
-\(fn)" nil nil)
-
-(autoload 'org-columns "org-colview" "\
-Turn on column view on an org-mode file.
-When COLUMNS-FMT-STRING is non-nil, use it as the column format.
-
-\(fn &optional COLUMNS-FMT-STRING)" t nil)
-
-(autoload 'org-columns-compute "org-colview" "\
-Sum the values of property PROPERTY hierarchically, for the entire buffer.
-
-\(fn PROPERTY)" t nil)
-
-(autoload 'org-columns-number-to-string "org-colview" "\
-Convert a computed column number to a string value, according to FMT.
-
-\(fn N FMT &optional PRINTF)" nil nil)
-
-(autoload 'org-dblock-write:columnview "org-colview" "\
-Write the column view table.
-PARAMS is a property list of parameters:
-
-:width    enforce same column widths with  specifiers.
-:id       the :ID: property of the entry where the columns view
-	  should be built.  When the symbol `local', call locally.
-	  When `global' call column view with the cursor at the beginning
-	  of the buffer (usually this means that the whole buffer switches
-	  to column view).  When \"file:path/to/file.org\", invoke column
-	  view at the start of that file.  Otherwise, the ID is located
-	  using `org-id-find'.
-:hlines   When t, insert a hline before each item.  When a number, insert
-	  a hline before each level <= that number.
-:vlines   When t, make each column a colgroup to enforce vertical lines.
-:maxlevel When set to a number, don't capture headlines below this level.
-:skip-empty-rows
-	  When t, skip rows where all specifiers other than ITEM are empty.
-:format   When non-nil, specify the column view format to use.
-
-\(fn PARAMS)" nil nil)
-
-(autoload 'org-insert-columns-dblock "org-colview" "\
-Create a dynamic block capturing a column view table.
-
-\(fn)" t nil)
-
-(autoload 'org-agenda-columns "org-colview" "\
-Turn on or update column view in the agenda.
-
-\(fn)" t nil)
-
-;;;***
-
-;;;### (autoloads nil "org-compat" "org-compat.el" (21988 3437 0
-;;;;;;  0))
-;;; Generated autoloads from org-compat.el
-
-(autoload 'org-check-version "org-compat" "\
-Try very hard to provide sensible version strings.
-
-\(fn)" nil t)
-
-;;;***
-
-;;;### (autoloads nil "org-contacts" "org-contacts.el" (21988 3437
-;;;;;;  0 0))
-;;; Generated autoloads from org-contacts.el
-
-(autoload 'org-contacts "org-contacts" "\
-Create agenda view for contacts matching NAME.
-
-\(fn NAME)" t nil)
-
-;;;***
-
-;;;### (autoloads nil "org-eldoc" "org-eldoc.el" (21988 3438 0 0))
-;;; Generated autoloads from org-eldoc.el
-
-(autoload 'org-eldoc-load "org-eldoc" "\
-Set up org-eldoc documentation function.
-
-\(fn)" t nil)
-
-(add-hook 'org-mode-hook #'org-eldoc-load)
-
-;;;***
-
-;;;### (autoloads nil "org-macs" "org-macs.el" (21988 3439 0 0))
-;;; Generated autoloads from org-macs.el
-
-(autoload 'org-load-noerror-mustsuffix "org-macs" "\
-Load FILE with optional arguments NOERROR and MUSTSUFFIX.  Drop the MUSTSUFFIX argument for XEmacs, which doesn't recognize it.
-
-\(fn FILE)" nil t)
-
-;;;***
-
-;;;### (autoloads nil "org-passwords" "org-passwords.el" (21988 3439
-;;;;;;  0 0))
-;;; Generated autoloads from org-passwords.el
-
-(autoload 'org-passwords-mode "org-passwords" "\
-Mode for storing passwords
-
-\(fn)" t nil)
-
-(autoload 'org-passwords "org-passwords" "\
-Open the password file. Open the password file defined by the
-variable `org-password-file' in read-only mode and kill that
-buffer later according to the value of the variable
-`org-passwords-time-opened'. It also adds the `org-password-file'
-to the auto-mode-alist so that it is opened with its mode being
-`org-passwords-mode'.
-
-With prefix arg ARG, the command does not set up a timer to kill the buffer.
-
-With a double prefix arg \\[universal-argument] \\[universal-argument], open the file for editing.
-
-\(fn &optional ARG)" t nil)
-
-;;;***
-
-;;;### (autoloads nil "org-registry" "org-registry.el" (21988 3439
-;;;;;;  0 0))
-;;; Generated autoloads from org-registry.el
-
-(autoload 'org-registry-show "org-registry" "\
-Show Org files where there are links pointing to the current
-buffer.
-
-\(fn &optional VISIT)" t nil)
-
-(autoload 'org-registry-visit "org-registry" "\
-If an Org file contains a link to the current location, visit
-this file.
-
-\(fn)" t nil)
-
-(autoload 'org-registry-initialize "org-registry" "\
-Initialize `org-registry-alist'.
-If FROM-SCRATCH is non-nil or the registry does not exist yet,
-create a new registry from scratch and eval it. If the registry
-exists, eval `org-registry-file' and make it the new value for
-`org-registry-alist'.
-
-\(fn &optional FROM-SCRATCH)" t nil)
-
-(autoload 'org-registry-insinuate "org-registry" "\
-Call `org-registry-update' after saving in Org-mode.
-Use with caution.  This could slow down things a bit.
-
-\(fn)" t nil)
-
-(autoload 'org-registry-update "org-registry" "\
-Update the registry for the current Org file.
-
-\(fn)" t nil)
-
-;;;***
-
-;;;### (autoloads nil "org-screenshot" "org-screenshot.el" (21988
-;;;;;;  3439 0 0))
-;;; Generated autoloads from org-screenshot.el
-
-(autoload 'org-screenshot-take "org-screenshot" "\
-Take a screenshot and insert link to it at point, if image
-display is already on (see \\[org-toggle-inline-images])
-screenshot will be displayed as an image
-
-Screen area for the screenshot is selected with the mouse, left
-click on a window screenshots that window, while left click and
-drag selects a region. Pressing any key cancels the screen shot
-
-With `C-u' universal argument waits one second after target is
-selected before taking the screenshot. With double `C-u' wait two
-seconds.
-
-With triple `C-u' wait 3 seconds, and also rings the bell when
-screenshot is done, any more `C-u' after that increases delay by
-2 seconds
-
-\(fn &optional DELAY)" t nil)
-
-(autoload 'org-screenshot-rotate-prev "org-screenshot" "\
-Rotate last screenshot with one of the previously taken
-screenshots from the same directory. If DIR is negative, rotate
-in the other direction
-
-\(fn DIR)" t nil)
-
-(autoload 'org-screenshot-rotate-next "org-screenshot" "\
-Rotate last screenshot with one of the previously taken
-screenshots from the same directory. If DIR is negative, rotate
-in the other direction
-
-\(fn DIR)" t nil)
-
-(autoload 'org-screenshot-show-unused "org-screenshot" "\
-Open A Dired buffer with unused screenshots marked
-
-\(fn)" t nil)
-
-;;;***
-
-;;;### (autoloads nil "org-toc" "org-toc.el" (21988 3440 0 0))
-;;; Generated autoloads from org-toc.el
-
-(autoload 'org-toc-show "org-toc" "\
-Show the table of contents of the current Org-mode buffer.
-
-\(fn &optional DEPTH POSITION)" t nil)
-
-;;;***
-
-;;;### (autoloads nil "org-track" "org-track.el" (21988 3440 0 0))
-;;; Generated autoloads from org-track.el
-
-(autoload 'org-track-fetch-package "org-track" "\
-Fetch Org package depending on `org-track-fetch-package-extension'.
-If DIRECTORY is defined, unpack the package there, i.e. add the
-subdirectory org-mode/ to DIRECTORY.
-
-\(fn &optional DIRECTORY)" t nil)
-
-(autoload 'org-track-compile-org "org-track" "\
-Compile all *.el files that come with org-mode.
-Generate the autoloads file `org-loaddefs.el'.
-
-DIRECTORY is where the directory org-mode/ lives (i.e. the
-          parent directory of your local repo.
-
-\(fn &optional DIRECTORY)" t nil)
-
-;;;***
-
-;;;### (autoloads nil "org-version" "org-version.el" (21988 3440
-;;;;;;  0 0))
-;;; Generated autoloads from org-version.el
-
-(autoload 'org-release "org-version" "\
-The release version of org-mode.
-  Inserted by installing org-mode or when a release is made.
-
-\(fn)" nil nil)
-
-(autoload 'org-git-version "org-version" "\
-The Git version of org-mode.
-  Inserted by installing org-mode or when a release is made.
-
-\(fn)" nil nil)
-
-(defvar org-odt-data-dir "/usr/share/emacs/etc/org" "\
-The location of ODT styles.")
-
-;;;***
-
-;;;### (autoloads nil "ox-freemind" "ox-freemind.el" (21988 3440
-;;;;;;  0 0))
-;;; Generated autoloads from ox-freemind.el
-
-(autoload 'org-freemind-export-to-freemind "ox-freemind" "\
-Export current buffer to a Freemind Mindmap 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 \"\" and \"\" 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.
-
-\(fn &optional ASYNC SUBTREEP VISIBLE-ONLY BODY-ONLY EXT-PLIST)" t nil)
-
-;;;***
-
-;;;### (autoloads nil "ox-koma-letter" "ox-koma-letter.el" (21988
-;;;;;;  3440 0 0))
-;;; Generated autoloads from ox-koma-letter.el
-
-(autoload 'org-koma-letter-export-as-latex "ox-koma-letter" "\
-Export current buffer as a KOMA Scrlttr2 letter.
-
-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{letter}\" and \"\\end{letter}\".
-
-EXT-PLIST, when provided, is a proeprty list with external
-parameters overriding Org default settings, but still inferior to
-file-local settings.
-
-Export is done in a buffer named \"*Org KOMA-LETTER Export*\".  It
-will be displayed if `org-export-show-temporary-export-buffer' is
-non-nil.
-
-\(fn &optional ASYNC SUBTREEP VISIBLE-ONLY BODY-ONLY EXT-PLIST)" t nil)
-
-(autoload 'org-koma-letter-export-to-latex "ox-koma-letter" "\
-Export current buffer as a KOMA Scrlttr2 letter (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{letter}\" and \"\\end{letter}\".
-
-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 output file's name.
-
-\(fn &optional ASYNC SUBTREEP VISIBLE-ONLY BODY-ONLY EXT-PLIST)" t nil)
-
-(autoload 'org-koma-letter-export-to-pdf "ox-koma-letter" "\
-Export current buffer as a KOMA Scrlttr2 letter (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{letter}\" and \"\\end{letter}\".
-
-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.
-
-\(fn &optional ASYNC SUBTREEP VISIBLE-ONLY BODY-ONLY EXT-PLIST)" t nil)
-
-;;;***
-
-;;;### (autoloads nil "ox-rss" "ox-rss.el" (21988 3441 0 0))
-;;; Generated autoloads from ox-rss.el
-
-(autoload 'org-rss-export-as-rss "ox-rss" "\
-Export current buffer to a RSS 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 RSS Export*\", which will
-be displayed when `org-export-show-temporary-export-buffer' is
-non-nil.
-
-\(fn &optional ASYNC SUBTREEP VISIBLE-ONLY)" t nil)
-
-(autoload 'org-rss-export-to-rss "ox-rss" "\
-Export current buffer to a RSS 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.
-
-\(fn &optional ASYNC SUBTREEP VISIBLE-ONLY)" t nil)
-
-(autoload 'org-rss-publish-to-rss "ox-rss" "\
-Publish an org file to RSS.
-
-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.
-
-\(fn PLIST FILENAME PUB-DIR)" nil nil)
-
-;;;***
-
-;;;### (autoloads nil "ox-taskjuggler" "ox-taskjuggler.el" (21988
-;;;;;;  3441 0 0))
-;;; Generated autoloads from ox-taskjuggler.el
-
-(autoload 'org-taskjuggler-export "ox-taskjuggler" "\
-Export current buffer to a TaskJuggler file.
-
-The exporter looks for a tree with tag that matches
-`org-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 that matches
-`org-taskjuggler-resource-tag' this tree 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-taskjuggler-default-reports'.
-
-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.
-
-\(fn &optional ASYNC SUBTREEP VISIBLE-ONLY)" t nil)
-
-(autoload 'org-taskjuggler-export-and-process "ox-taskjuggler" "\
-Export current buffer to a TaskJuggler file and process it.
-
-The exporter looks for a tree with tag that matches
-`org-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 that matches
-`org-taskjuggler-resource-tag' this tree 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-taskjuggler-default-reports'.
-
-If narrowing is active in the current buffer, only export its
-narrowed part.
-
-If a region is active, export that region.
-
-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 a list of reports.
-
-\(fn &optional SUBTREEP VISIBLE-ONLY)" t nil)
-
-(autoload 'org-taskjuggler-export-process-and-open "ox-taskjuggler" "\
-Export current buffer to a TaskJuggler file, process and open it.
-
-Export and process the file using
-`org-taskjuggler-export-and-process' and open the generated
-reports with a browser.
-
-If you are targeting TaskJuggler 2.4 (see
-`org-taskjuggler-target-version') the processing and display of
-the reports is done using the TaskJuggler GUI.
-
-\(fn &optional SUBTREEP VISIBLE-ONLY)" t nil)
-
-;;;***
-
-;;;### (autoloads nil nil ("ob-C.el" "ob-J.el" "ob-R.el" "ob-abc.el"
-;;;;;;  "ob-asymptote.el" "ob-awk.el" "ob-calc.el" "ob-clojure.el"
-;;;;;;  "ob-comint.el" "ob-coq.el" "ob-core.el" "ob-css.el" "ob-ditaa.el"
-;;;;;;  "ob-dot.el" "ob-ebnf.el" "ob-emacs-lisp.el" "ob-eukleides.el"
-;;;;;;  "ob-eval.el" "ob-exp.el" "ob-fomus.el" "ob-forth.el" "ob-fortran.el"
-;;;;;;  "ob-gnuplot.el" "ob-groovy.el" "ob-haskell.el" "ob-io.el"
-;;;;;;  "ob-java.el" "ob-js.el" "ob-julia.el" "ob-keys.el" "ob-latex.el"
-;;;;;;  "ob-ledger.el" "ob-lilypond.el" "ob-lisp.el" "ob-lob.el"
-;;;;;;  "ob-makefile.el" "ob-mathematica.el" "ob-mathomatic.el" "ob-matlab.el"
-;;;;;;  "ob-maxima.el" "ob-mscgen.el" "ob-ocaml.el" "ob-octave.el"
-;;;;;;  "ob-org.el" "ob-oz.el" "ob-perl.el" "ob-picolisp.el" "ob-plantuml.el"
-;;;;;;  "ob-processing.el" "ob-python.el" "ob-ref.el" "ob-ruby.el"
-;;;;;;  "ob-sass.el" "ob-scala.el" "ob-scheme.el" "ob-screen.el"
-;;;;;;  "ob-sed.el" "ob-shell.el" "ob-shen.el" "ob-sql.el" "ob-sqlite.el"
-;;;;;;  "ob-stata.el" "ob-table.el" "ob-tangle.el" "ob-tcl.el" "ob.el"
-;;;;;;  "org-archive.el" "org-attach.el" "org-bbdb.el" "org-bibtex-extras.el"
-;;;;;;  "org-bibtex.el" "org-bookmark.el" "org-checklist.el" "org-choose.el"
-;;;;;;  "org-clock.el" "org-collector.el" "org-contribdir.el" "org-crypt.el"
-;;;;;;  "org-ctags.el" "org-datetree.el" "org-depend.el" "org-docview.el"
-;;;;;;  "org-download.el" "org-drill.el" "org-ebib.el" "org-effectiveness.el"
-;;;;;;  "org-element.el" "org-elisp-symbol.el" "org-entities.el"
-;;;;;;  "org-eshell.el" "org-eval-light.el" "org-eval.el" "org-eww.el"
-;;;;;;  "org-expiry.el" "org-faces.el" "org-feed.el" "org-footnote.el"
-;;;;;;  "org-git-link.el" "org-gnus.el" "org-habit.el" "org-id.el"
-;;;;;;  "org-indent.el" "org-index.el" "org-info.el" "org-inlinetask.el"
-;;;;;;  "org-install.el" "org-interactive-query.el" "org-invoice.el"
-;;;;;;  "org-irc.el" "org-learn.el" "org-license.el" "org-list.el"
-;;;;;;  "org-loaddefs.el" "org-mac-iCal.el" "org-mac-link.el" "org-macro.el"
-;;;;;;  "org-mairix.el" "org-man.el" "org-mew.el" "org-mhe.el" "org-mime.el"
-;;;;;;  "org-mobile.el" "org-mouse.el" "org-notify.el" "org-notmuch.el"
-;;;;;;  "org-panel.el" "org-pcomplete.el" "org-plot.el" "org-plus-contrib-pkg.el"
-;;;;;;  "org-protocol.el" "org-rmail.el" "org-screen.el" "org-secretary.el"
-;;;;;;  "org-src.el" "org-static-mathjax.el" "org-sudoku.el" "org-table.el"
-;;;;;;  "org-timer.el" "org-velocity.el" "org-vm.el" "org-w3m.el"
-;;;;;;  "org-wikinodes.el" "org-wl.el" "ox-ascii.el" "ox-beamer.el"
-;;;;;;  "ox-bibtex.el" "ox-confluence.el" "ox-deck.el" "ox-extra.el"
-;;;;;;  "ox-gfm.el" "ox-groff.el" "ox-html.el" "ox-icalendar.el"
-;;;;;;  "ox-latex.el" "ox-man.el" "ox-md.el" "ox-odt.el" "ox-org.el"
-;;;;;;  "ox-publish.el" "ox-s5.el" "ox-texinfo.el" "ox.el") (21988
-;;;;;;  3441 415802 0))
-
-;;;***
-
-;; Local Variables:
-;; version-control: never
-;; no-byte-compile: t
-;; no-update-autoloads: t
-;; End:
-;;; org-plus-contrib-autoloads.el ends here
diff --git a/elpa/org-plus-contrib-20150831/org-plus-contrib-pkg.el b/elpa/org-plus-contrib-20150831/org-plus-contrib-pkg.el
deleted file mode 100644
index 8a1975a9..00000000
--- a/elpa/org-plus-contrib-20150831/org-plus-contrib-pkg.el
+++ /dev/null
@@ -1,3 +0,0 @@
-(define-package "org-plus-contrib"
-  "20150831" "Outline-based notes management and organizer" ( ))
-;; no-byte-compile: t
diff --git a/elpa/org-plus-contrib-20150831/orgcard.pdf b/elpa/org-plus-contrib-20150831/orgcard.pdf
deleted file mode 100644
index 92bf70adda6de3669f0908c1d002f9fd735f60dd..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001

literal 124864
zcmeFYWmKHavM3C}2|Co}K-j@7%T5
zy?^hlMNK``)m2^6-8D4>ku<*`B`p;LG|{ig?pbJhJQ_SJT~j;`4rpp|14|=&V>|{X
zT3Wo<7c{k?iMhRjEgrR?xsJU7zk!~Wz5z5B7qp$dt$~gOwDbJ1x{KXH5AyR$hL6Q!
zfN1DFUgETcdADS2#m1y;%*bY9sTWZYB&abKn`})+^Ziwa4`>iru02~0`Wjw&tNZoW
zdlYKwbmcM-qxGA-oxr0_U0NtCyKS}@JQxWQND|ck&A`1zTazYANtn?z;>3rLroFFC
zZA2q_9Fv0xu$^7_VVCB*tU2tMu4f0=yai;U
z^Fcga-Ph;j&LoXg(^)3S{BwM;wyfC`1@q2y+YS@Y@iObfNNM=KB%_sD2}*V?KN6Mh
zGicF;?l6*>r5B@WJk`6DCW&XVMOm>4=;nAA${D>>E$bAUt9JiotA_3UYxl
zWfFBxGQiFiUj(xa>Wv5pF5k%p90?~`PX+$F8?22SqGWpgxydk<{IG$BuE+IR7oL;#hifZRCmJI`u(BU_
zc`SCr!r~|E-Gdqo;P*iYNt!Gx0$pR@bK8DB7_;M0;X;i4%nE~2a^T@{UbdG*!DO-(
z32dQ99HQP75&LpB2n|{?S01w;FLrfd3As=(Mq?8R;j8@fhf>iy!Frw8$Z^*yGCB`o
z<6Wa0bas(*7Bj>=OuSwq(|#4jPTR)!_K+3uYq0J~EjgiC;qUYKZ{o!W$U=yBpzE`e
z6~7;lbozyY6<2EIqJahRx>R}X>+-}o2|L-o8=Z$gFd37FSqM%HQarTh-kKH^1HFdp
zL08FQ+_4h;0X3c&=2cNnRr7rxv77s<2oueF&b8bcOemI0iI-jNqmXRgSoR?Gu2vg3S=HH*5N-nz_
zk6YI|*rEE44e=jFGE(TZ9*!Wc^EFQ$HD+KQN|`yz28l~kqVErsL{#^0f*H!%HpfIZ
zZ}K{oLPq>Ypb?mdN%}aUrzUK&Z>OD~fAfaS21?s_D^H4Jz1tfDXXRpXwb#A~anfqi
z+c@n{a6(Z?K@QisQyQ{EwsspFE)O7WVjPLc4)*%=Sm4EHT@6VX=jKk9W;PKdtVY!&
zr48~G&%CMc_*&ROzJy^c#VX`
z&_q4wF%k^*h$ve6FYz3TcRXkaoXG}`no1C|zg6)n{d-8CD&)y!2fY`=l${Nmh^-xGE@T|b6(4@(?&
zM&6AJualc(_`KV)$N!WycFeyF{;c7e1qb~#V!#_K&H%H>sVapVBUuvB@Kl@2pP$cH
z5lesMNnv_eTk*56pIo&GAE>WE+%fGSc5KME%j+|(JY?BBV0}=_MPQr9D@Ci_A=@=V!G}L{@ff$5e-*xdQBkE?JtOPEJKBQ@r
z71MQf`Hnw9n#XBUNK+)l)?K;Xt#iV--A&ComCgEN0IwZ*re(VkLZT9#3?O;+;3g{>f%e*t*PnpXcc#rQU}03
zp4zxnL=7cE*z|}~?-AC=RkQjm@u=pjbFs~-hFeS;YWG;f6L%k(jl+&xHKLTyp1^FF
z#fIJ?3Xkm$9f$ckus+pFY7hLj9%6a#OhIs@YUEJbnOZ-CXg0wBg>Q6J-N7FvO&Jdk
zkGc=@iHAc9Bfz=-;H#-~$B5&pJqra;O%t0zdO4!_RojT)Ch73*!RHB)f>
zIsVFaANaE6l`2RFjKp*JNvFY;d0Q8FiKQX?&V`FO8^ZnMjIT@jO<}=XA1SvfnKx+5}B`ldjo25m0apY$lHQP1pSAQKPl(s_o3W>mw
zp1?gjtTIuDq>4G^)yp3ujbm;0nPk`S>2WY#-;i8xt4SxcZhf*LV;sopid~%_F!&*0
zWJRB_Ln?Kr@|UL&Pr*NAc1|8dwJWGCZf_IGB|(FQrdJq+qx*R`JT=mnA|(>WqkOpy
z^|$#Jmh}y-#N`6w_C6m6Yh@NL`jy(DQna{JB<$WxB`lP0#^TFbimh7-H+Iydm}xsH}8CIunxTb_-EIgAFD}v-g&St@UK*b
zejE{BSr(fB_H=CVKAJK0x8YnJ)|?2Rvz54{$}#MB;^&O15hgysP~cusC?@^+ZPy2n
zwXH6ZAN`=N^vA*VTv%V|;#_;O??y7cTIn~geHSt9dAn=v>?3X!9cTbqz5R5iBkIh
zsRcLN(-tLt^)br^byj8-3d{A4B5`
zi7u%NXmmo281zU)704|;!S!e=cC6MdZHmLmW9$hCM
z9U~sS2iPS_94-#0o1IA3)K^_eH#)+xOG$nRm#n9E{cvCAV*D2GU3F8IIg%HDX_bGjz8_g9VG6bus!%27y^qaC0#ZXBg1O
zQMQ~f3((&_$~h2zw~)Z?BIY>ERRwsOXX3E&_bzx{7efkKTuoeZ$xQurNZ-h0CW1C5
zXOl?LaOoM>IDxS`HxPw>19o9U&ZpB{kT6c9yRTj20!w1cHYr6TVI#VikruJO)Afao
z4wu?wbsmM@$^1$mq|$2xRyJLg*DGgL6m;Xd9ESzb>@>eX)+z=$#2Zx8T%wtE=k|h8
z7ZaIK9pW%<&pY00pQjr&Fy#-VFtpCgm8U1skIF0z`z;}0enO`%YoHx-bXS5}y75pc
zIS?5kT$pg%-nGwQ{hHwOi^)TnXZJ`eTPpi~ys2>wHmod(r$X4l@~|NFRDnhhgZ7TH
zdlHtTXUyP|7ghsGl2bDeQ)M<>ET0O|H3)IgY>e2VVk5b!uu%n6_PlUSf~RQITDyj~qR*D?A@5yAf5lgp$y6u^S=anpH-+=R
zsuW>(-nTK+U_fTV8hmWcgy-8ZF)XvecWlmXaSVn1!L;|em%-~{GVrY(1>P+!gGN{@UqcCuACgzf@12}d|mtAyPuLz
ziGLqwtu>IA-E0Hz&8-#@ELnwnO}2bT|Hghu;d0<;ER^1tyBo|)ok2z4@=0AL8{%u$
zjWUwjdSO4mfl{q!zoUEY%o>euAIkXH*M-YP+{%((DAq#mFi$B*QkQe0kL9Q1a=
zblrFl=0M`h)gwQ@lilyWGIEL#uiPe$7I7v3LYGY%t3L~rk^dlzgPo#z5FJ_mGt@u@
z_>uTPjG-uPkq-iP<<~oiP$%oIx^Lw%(4NN1W6&dbi;C&Cu~2Q)6-rh4n+bf3FlWGUQ`1CrCN}
zJEmf50os@pIw;*QA6FDB_{Q#uKLSeJ{z1ezHJ1S~!n+DMQ=94tpgmwpScwEr_+o+z
zy!UQUd`;ipIW)7bI0?a$sVgwddLy;vErvA^fH{3sgUeT28#ShSDkL&dsW^w~OeYR%
zuMdTY>Q)q^N_jTko$KqXRK?e%RnIb=iUYd^1}Smg1ilc2kW*bqZM6GoP@TeZP*#|+
zC3ycB(N;V4z4K(pt_Ji&-JGCRef!x3dkZte+BLpgK;v(x;M$MDmaHD&vDUM7RHtA1
z`eClLczZdpAl9p-t#5KRZr!nW!qKbmTjOvGijMO3`!gQWBUH?14_22NV|HP1j<6S*
zo4Mnkzx1=b+B&oQ9IqvA{aLgGz>0%EV5E*bR
zgDw(mE$q#cvTHByU?x}Btyqd5GMFyWbxMHkK8Nei+$1Al(0)MG$yAboHn7zH(+vV(
zfKC!L-CrFgc^7K~JZfnjBLiq^J}XOm150~5yqA`fEHt&Oft{6ut)77$9_<@J!a(0d
zhu6v(PmKmZU}2!8VqwK&WM!nHV`kET21v05OveNCre3CVapC>Z_wxKt2TKs31JKF>
z^s5+Y@fcnh0Vq8l<3AW39@8I`5s&!~M#qH5^3OOc9_t^JmJyHkWf`(~fOZ$Pw5^q%
zoPj-_8o(HSK|E@C17~|YjlUQ1qU@hl{L@Ecq-Xul`)G$TDJ(X_N7SdzyPMFyD;7;X?xUU>
zUZ&kn*OV6jTpL2Yn)gh_miAy0`B&5vVw#*3t}b7jR5XD
zo=O*Wf(}CGoZH#{P}*Fc1l;tcRZ(lART}vyWK$AY*!{)iRcT(lp0l@aSm%2<7oHWz
zotS(xBc?11)tL49m59_#G{%TMv61|NGVmPabEEz!X?IJ7HHUdkUr{-MuyxHAiGdxpC%5UA
zr;LWQX8SL)rYLDsXXe`Rh^@H*sjqs?6!~M9lMWQFvJN82>s4|q)+k&p($TT}O}?R6
zWOiDS`GjR+ac$|68Z#%T;k#Go7mtSvakqO*qpihv4O>!G;ULZ7B8-cNwuScMByQza
zT)Si|=CUK(jZ(~Y8J1Qjx>}oGT?KOset4btB0O-dig=_S%AYi8hf{MAZKB_AuJ@4C
z^M4kmYeKfQJm}2+*dYg>EfF6S2&@7rX<|FuVUBR^Yyp8}>jqxCDe%DOBAQerlJp6U
zDVYCr=~O@BJgSH$A+ofSywZ46RrD@WLh*Mc=bN*;;WK7RCKUYykc4!!-VqsenJMA2
zvtGY1XVRPOPpG8j81{2@F^{(%1>Lg*;-b2Fp(jRy&a_=CAs;7q_EwIEQyM)zHh>7~l%A~``ZY}EF$xW$w
z+FdKfXOm29z{n5_Cx7qOpkdPQH_2l6wd32ndD0+mOkv&{|H*71KnJbm;V>^F9(NiD6}Zc&kU*d8u@pdrG
z>F4_iVZ(8(vF58}+5F8d{f_)NHcGdB42p7Z^S6{17oJu6@jCnUw-EC-0jSRi
zP82!3W_8`%QY>GwWoeFKz(mJ
z7#Vf86^pJ#zzLZM4I-xnV-uxZ&t}Q}T+m;hCehDlfYNVR1o2eZunICt-;Tmn^2>_8
zBquZ^oh+h*^DzC#QoLv@B|jE!m30EYbA=>=K-LJZlr|mE^v}B647LKQji7W@vN|lM
ziYTs06E@r0jB3BoE?u?~>9I$UtANuPtODX8DUL_j?E
z{S@IR+CShZlV=nS15onEL9uU^GlPQ-Tc=A8(RlDQsvR`a##iV$u%h+ffzi4XvV`m0
zPrG;-8AB~S+eVgWr^NZmbqV1LDs<>YV(@KnKJ%E(%TF&awzRlBA8k+udcx#}Bgbzs
z;4B^QY*E)SdwNpq>TeL)vr^XN9lx{3ftEv;TLI2O*PPDL({~Mx;>i^(90MU%$Qgl}
zsc@_!R$U!OwrS3bA{b)Q2NjBN#WHx}g{(OFz^XuF8XJ
zN{w65^@G-M5_@8icG2Y*o&pLJ6Mp2v2WU!^o{sa2Y+kbL1K5W?MPuc}MyyYWYI2dY
zy--{=!|?O!Ht#x3E`m^$8bZra1CCp*jm33%(FDFzNcm>zKwBELS8Ox#7MB^}tka8l
zY0f=}h|wv4*%3sKkH+CR>B;+{;t6Gm#o_47vIZPoOAqOPH2dDmN$`0h^wA~dyLvo=
zN~H6T9qjH6ebXep&R9nvK1%Yw?8B4j1xrU9k}a+eKjlI_dCQZZq2@>Q?OcO;`_{ah
zr8S`q<-s(5hFjg(;Y2C>?Cfw;L_cxRi6o7>$^U4sAEI-s*FGrW#dk$8GYqKc>_vLM
zP8kOuh(v4_DLZRM_gCSU{V=adAdnfEm;ylwyhgubJWN)`kCt0J(;<7#=nh3xVJKX&
zzx1Q}bNI5dXf^^+{{d)Lku_y@+h`E?XLouPcpO}6s^EE4kSz9<^;B2NNi?{TG$%Eb
zaQmepoRtcTkLobCA#)=Juww4~`oZ;NQ`p-HArt0lL`8^mgtOr%{FV0A
zL2p)!`vg}P!oiY0O+xiC&;y3(v7CC^1>T@0>$@nI;NHSdo27m;Ipt;`e|H#5x+}Wu
zDMQB~vJif#J}tjbZN^hk6)AIP&Iitl)V-(a{JlkztQ~d~mWAGT`hJBwe#cKnemhCR
zJCL*Uzo_YcqQXC{Z4p8ca`R^m6mIL-w=2wR(A=gGjExa`Jlk?u^!BtT`lhU?1^xQ*
z*fd)$e;|Ce(z-c6HAS<=lS-r
zbPnv>%boi%UPKZdn*#zA$4-tg9jjnM#V1>m1?w~z-@p__v?n9NWUWUBb%!+Gyl+yG
zd{YG1nC_0rkF*8t^kRZ|9m@-v8!Y;9$z*)cAgG@rINjCLNTLL@UjW32sRAQ$M
zdPn@hB8IsbX;F$FC?%@PwoV#&DD+yUFV1m)Y|L+Pi7j{{T0qg)451(a&w&?`v?h+lb@h-{1
zcU&&j97}2H;Dfuk8KCvRgTa;TDMxfsA>%szkhiuGklyCCVjN>9Z3O8J6lgB#Z();b
zoy(5Iur#Y(B^ykCC^h)>B}zln1`{fdOk!z^RU1RD`V+Kjutf7GSEAM`lT0Pwso_Ki
z$NUR^V5JK%bcnGauKlBPI}T
z%&k33Z`QFDMTag(>54|UX(`bS5)XV(7KYK_@UN~~gGh5YDI{XMcFjJ2){hCujS05w
zMGt0+nNAWyDTH?zDHXtt2ntn(a7A_@TB(7b`AoZ29a0%3$<6keTJ%Spp<6*MXTQ%5
zx(TM_75pXixZg)Z48=#-fnP06k{147bg62JMCH#1$MtqZc_f3edgF=v*E^6VN9#H_
z3z6u5xd58;`Dv7{LLyixY5W#)EH+Gf`boQ8iR~?3GuVfni(Td8bL|L#k;Zx
zq6vDD2A*T&d>=x3H4&cJjS}@8V|5{gCTA#tBRKLRioCAy(
z;EhBiNZL83{&llZi$I4(fj)vnK^r^Cxa+3-Q%U6k1pJQ3>g}TN)P>h?mjWW${2JC$
zM~m?7Wv?EBjG}%SvSj&r^KvKhc;P^0ZJNg-MKf-gJ^P&0=|QFSdWb?Bh4Amekxe;yEBlu4)%!M;*YP#s*i
zGB<)SMAaQaT*QesrIDXIfaHmCBYJqm4w2{TUw@{@53yQcBDk`{x(I^*dT{pxeRE4E
zbGGZ$Sz-D<@=%=cneEn?_alflt2SDP<-1`{0a7~|cBy0c*JN-vJf4RVD;|Pt;qiP^Dajr@V{8rNK{Vmyj@0v!u
zb!A>IP~f9`$juU8M}JLG+&~U0&a)xAex!wPuRp2-1V7T3MS#vP(~a?7RomTAIUaOh
z&|z1GW4hx+UB!6OS+FF4qZ2CGd9rpsxA`7p(f?vmS$3)_aoA^ZZ!+B_04_sC#=`1-
z2Bir6xCiX$)-o0OZ3I_a$7?
zQQAzdU@S(_y9)YLwBQ{g415RyVT*XQ46?9nBV%J1BQ$X)Ia}ve#KjV8NZUv%l$af`
zTfZ%=@pLg)a^JXdtgN=F9E%6eYEy4B!wJE;s|!8O@7g1v=AX26n}&hMjfY=*7MkO5@}wn!~i
zlb7{28hc_eXgn0bGTWNb*Qi)=x5##h-Lx014J^4*xBG~jxLLGb47!!_trx1^H)7}W
zGcDA!O%AN`7o2ncI10pz;tQTBTCt^Y|KjTkVh)1$y3TXisJlA3@~?uZbEu@j%H`ud==Atl+J#N;^wsS|D(Pg_9v`N>LbP3S
z@xi8i5@=_`fc?7bP`*Gg9W=cGJSV7%K<7K*a09Ifc}EO$L;Fv~a#n`U;b8X@VR$Eg
zuq#^Zu*xXi(dM<*5g+ykRHQXTm6COCOMt+p%0wq>X{*ZehWTQX6#GpZNBb@i8`4bG%AGn6g~w6H-vanP_h_fh%Tz3Gwiy&p&G&aY%E
zf}1?BtW<)eRbr5hf@gX4L+ycaFPO`>Ss{ouLvhh71q>D;U;YgEh1AvUWGSQ#DS<1s
zj*KT(5j{lP#e)hdT**Bkij>ilN5*^k0jkdxUL6jcc^IqppF2V&7=M8?1KoE-xzn|Q
zqk$@g;<02&e|peub*b}3IK&{%(6vA?GhJ|T1f7C!AF4!sWZI`U&O
zg!JlW5hpfUSt@P0r@jUC2mkN=FWSF185M8$yjpFmm~
zCORrcJVtt2DnKvq75*pF{u7=*qW`@8J>%a;{?`3A@-K^Cx`(e8(bKU~(cv*Nuuw7m
zU%@vye?u044*|WBJ?(gWtd!M`bQoPX2*p8H0pV`czoVqsVW9vRW1v20(~d0c!)S{B@$)
zv~&zF{&*YtN5f0tndq4SLHeWm&y=_2{LRb2{Ia3m;2YDwjnceE=5^iw(^~&?`k&SP
z@xsd*-*hoDv%KuoSNKMGv!8{D6+r)EIlv15oaV*;m!tw%3`j~kfP|McW?+1=_hqNE
z0wP9_$4vj?Em~Rt`Hg`U5C=e>(=!5$eZyI483BxM!D0cpl@^Z`5OPMq=!;ldy4Ta=
z?cohFzvbhbFJ687X3v}bf7|x*^#kJ{(SKt2niGt#+veZm|4RQSYA?CT#PG5?-zfjY
z?k%C-66OtmWn!dxF_nSkH6>re_$T#VN8jA`ChisfSHjZ0d`0ng_AmmzF2Q4NzWZ#X?*%K|8G9)0EcGxv=S*tUQ`
zzj~dP25{)Ut?+MlrdJjQ7Fqx!0}CKfuh<{H*ReOZz45)me+Bu^H(bzaf8Rp?5C4B2
z_zyhruPpjgBSNb&(Xs-L3P!+A15{J5kcH*tFnxn`fD?}vaBshyy8nCm%m7Y6CIiX{
zz>)BJVly+nlpSwX)Ek8rP!GIpYrvWIQgyssP;Uy};2YDM;=l2~IT_wA>R0%O=Px<*
zfJ=k!kIc8x{~P%C+TQR##?ZW+U5u~rjq+wZ^XqN%$L!bBff;b;08TbQiScqrz1B^y
zZlVWNQZH5E%XPv+_u_6QCVBvc72rNV?e@y^NAjzLKRDo+0L*#~(wmk)dSCegr{zoO
z_7a6R$i%=3i0R+1{qOkSlsCbDBKWH04ga_3ztZ1k{h>3x6hd#5KcRc&`Q!LE{FR3R
zP(=a0hX>@_3w*iU{$$%
zT`#iVu)nz&7+$2l!55Cd$LL>gt2b%?-
z_9fL`?E<6=Aek5$0X8zzy`~q<%l2Re+(`_tbq?d}OjbZ50}_z+C8=MM2=Mm8!UD)h
z!1UMK`VD7!EuG#R&+@|YTDra|rln|ga$mHB`9|GhJys{b^h(#Kgy1Kc9SGZTiE|7u=t5-JX
zuPdz{+h@8=kcWF)pdpx{XU?OQWlwBrf-w#g0*Na@%}J!?m&
zJP@?Gu;;C5bK$##wyO!o7H%dT^a9>wfM7LYJa2cJy&M(Y?
zh<_OXa#c%w_vNY0l@0ypJK&LUDsHP$PqL>3?W81NVw9c{FKTZ3_iD3W@;$$K=RL1S
zJh7|RgV-l=^+cezUCfMnW?XzB9_kvIp5KVLU7Z-Bc0LX=8mFH^=
z%2Yy%MQ>tJl#!n8XN>G;`?U>gv-fJ5(P=T=TGUuTob*T&&tvWfsTEVbV%>W=N}fet
zxa60u_}vy^hvHB3obeGYn5=9VE^QvwPrkFj=|i|;rtj>Zzt#eW!qhsB;8J--tTzGY
zIfj>eI>h=u>ZLv*K8COWg%WsvLuwKrRB(r-XU{e8fiq${Bbe-UZGAg_;6*(t7}p`L}^w>n4v0
z^}sL~MdXg>TLVvf5+b6w8-
z?2P(caTEDC@%%}m$a7UFeHt*%Z}GI+yWo9_E9Bl3fp+)=dSCu{qx;DB7*+U)dl^{v
z*eldIjbZ%zL1^H?YOnR`F5*}SI~*|ad)gC=`{seZ#isrfoNq+SgUxfIrJxaWqvww=
z9O_TrxC#wVAYbU5?t4FYIyXLpe38Al!F)E73)R5-GVb_vuW?l&_`KHoMTI+){TG^}
z$?`}db6+LfkIO7sw9zmRt5nYbHz|7mhO^FLKsOW?MXxVbWBxtA$HP=D|wKOz1F
zi+*Mffl9@nt6mLJrzvus+!7r(W_A8`;2s&P(wdrR;zH(klO7Kio7wOwr_ua)d@Ng3y0
zEVqPq)f0+4^q=jmk^Sf>^z~Sim|sYWy!qC1{0`CN#YZ!aNM^hRr<1k}Q;&>GbU3nr
zGBXJay-#6?siPSrNJ+5C=!V+rPTbvyh@``2-Z5rb>=PVtu*w~0o(4y>Z|j8Laa!^@
z_eRt%rLT3KoIrTYpx7EI@*q7tISolu?kg^}`iX4&
zn6>RUtV5hetX#Oz1jE&7+xaT)>hzMuj49rLrHEx;`lLFG3p$p&Y@Z{{G>Gf
zJGcH<7|-}mW}gPjT`*TC%UM2q7UMEUFP3y=D%{z{UvPB0pw41C;&T%=x^^g
z+hdWI>tEgN*kuzkM857W`r%R@mW`IjbG%Bv=;Zt!Ne$OmKN?fjeeNhYVH_l+FKW)T
zWZ@FENHSWjtE97q@8OJcN0h+&j)R5P%~oi%)5k*l*`wTk{0d6YF;GWMg^y~I1Fy&4Ub-S-=5(rLZOMv{U=Jh7
z?1RYlaLts?JFbAckw6zjNGFq$8CD4y_d8osG1@@q9gS+63E>oJDUV9~PVAM}{I0-v
zRsZ%|8J#VM2nAbZK&imd{A4r}?U8+mfccTG4SB7nJ|mT$=+&X
zvxLSg84vv3mF$TQx{&d;$m4`KyQ=ukCq=rKns6UWShG0m6yHIhpqDI(k@Vs18Xv_)
z^=c)nH-Mdbc%&2t$zvj(R-0FwPG__J(aXM`FP@+T5npCv)V&urk
z8@K3tax9*5nnL*a
zHbUy;dbz{Grn;VPUC46`RpWY$_S$yAQU+q2O_njl5PTCe1Y#JhM=XRhnVV;BbdWEJ
zwYg8M%=vgZ(6DI(+h$7G0E+k4BI@0_EV74zM(=3EPB%GI?PAVQfz$>5_1C#kwC;w!
zQ|(NHe0NCBlh!m!)-`SA`^_1S+SVtS`TPaM$)CpX^PaLiN{AKk^~-4-R4iXqY(7jy
zCQcwR)fHBX6;KB*@;|kM@qmKGL)&;rf=rD`!RO(H6&Gy
zf}DW^lRKjK35M5x!P|J60AyhSvVRPe+B^z6q1|g~Bwu=n7}y)uLt7EQ$hL#f9fK&Q
zce2NX)=`mRuLLHP*bB-~kMd)L+%YTK)U8jm8*(5cSyTpTgHaQ*Q3d+DBFKWT%VJ7I
z7Db|7OImEuls^bNE7nk!vFDl=7k!<3MfLa{%2Vn2F^+hK-F^vEuA#UOA366ubCD(&
zVrfoviD=w;KdV2R5F@KBn}O3&j__~uNHy|UjZ+{sX5
zWm+*RkK_WU+yS|I;Jb~CemPxre*bHh@uWFtuF9r0_uX>Bn%3$5C7crCmllKTZ<9tI
zYiB9u$>Y3@G;=Sz58ao
zN;)*1GUZ0eJo%F*Uo3mAkr
z`)<^;$O#a}TO>(@xXg0GpK~sON)$nNXGHlFMfA;fTDr;JbGIC}Oyil&3{M>fyM2(P
zRoLm)`5N-AaHLBnpwhe{+!MMm=zSoa85BO9*mAj=mH-|xiFB{Pu{k3gIjN;eZt^ft
z`63PjrT&z?JlHnMIB=~gv)sbR3I`ItjouHJpgD|bLO0;P=q@SQtNX%N3MZa(#SRHZ
zxpE0B$T|5TLi?<+rgWW7!{XfwL@46f-p&U@fs`^Kp#fUEHSZ}?ZgB-A`yl6my0Ee0
z5q&M|XJNMU1L~sK^13R2pN47Hv#vRvVX~8OdVWC8%ZdLDKZD_s=cHb%8JxvxWdrm<
zxOZf+Tgy}vX4EDiFcJxjF(qKD;*sF|^My$1&l!AhW}CLtI-*7%YG&skpJ2f-nDJw+
zRPNB>BIO0svzU?~QHH}O!UUcjmz85ba`-G|^T#j*b~jkU)^wqjNq3stVs^o>$*@ssq9WBvA>dexRdKzEyCEcYjd
z4Z`|&W~cCMI&iZ0xmIeUr*a>ev#m`=^I%tU$SwM5IX*Yb5J(CImDLPsdmACYN!%oo>nxH%XU?vSZO
zQ9G}Z-d&MWBHxULl1o_#r2ksX82rgZ8>vfB`!#_`x|?+KonSM}&N5oSK;?!;SU8iy
zb+ilXRKHM(bGy^#ssKM%2CLfES5L&_Wxm4miT81`JiEA`qJ%lwrg%$XPE{`xS)5Mi
z5a}8VZDfy9*{wc+e_`=6q35&OVdGKM6y`$M)$iY`ap5!=`P-JF@PReW`(u4K7hb(uQyyq$aG(
z6UmKI+}Ss_&@1qUa~Bfun+2^fxUbEpQj5t9hGd+t6&@&n^t
z2@>F>HFMkR9MQI(aIV`7oPT*r-0rf)NUkpF{E*0Bnn7lxr=upM33KPwR)%U|AgUo^$4gA2@%1i^r~@U#l~1o>F8upq(p0mL7n
z>s+p#KS>J*sWV}H6I)C-EzKCe<=cb1pI2jD8P551)#Py*;gnZgh}s-hbx>N{2%`gL
zyk5D!m1%2e+KLtulZ*9@bm7scm68u3P7s&Df`irt7y+u$5svTxz6(qd
zrJd$!P+6)~s{@;#$=$c{3^iWODn@imL-%O107MdB*AO=w~
zC!X55@lKnP6XBBM1z?j&=X|F^E$1YKfNcW`Bxy@k6+8UwV}nsulC$s3hKe<;@+#?|xihMWg)Kpn0;WJwp;
z9+1|_=sz3RY1r*u=Ydnem=I8Iz~tTwWR!y&axdeDjw!U2^6=m;koUktw2Kqe5P7eU
z8hnD`E<^C~PU|&`<#F6&0ArpPw4J3KI`)=5TZHA}syig`AaC!oIf-Ky%c3Kqb}M2R
z*Q(_Rs*ACbTxL)$;|!_%Lit{o-Cg$Q4V%BCZlkR7{y9a;l`9XWG&$@ca$d||429g{;b$B%a4G0
z6yg+^z3r34y5}!~mmzhu9HKD2lTx#f&6pN?lEf^r<8(7N?L{@Arb;YWTs6)`LLR`(
zV6o`n$zRi(P~^`EA2J+i!_Dy7Vb-sW%paW%2vMB^$!_68Y1b`$20t4wS`P1madC@+
zXl7n5m}s1cg#0rBm6>)WujYb??PVTDJKlm)w7^>T9{f5J$!%~|;!~_hZ2XpSJ!_>4vVQRfVFsam-?z91R3=PVdGB-XfT{pUUB{55DrYOr+AH!f
z7V4{>jT1Dc0V8%>65eWjWFBZ+af%44;$MiA!}=~^xuRBM>lH%T6;Uu%;l8?Z&<#Az
z-M8oa5?q`;%Sf$pswL{7T0U5(jz~tFYS95!`yO-D=S-+jpiT;uB+%1c^7LZpE29eO
zM%~-0^p|^l+{aFFr4j|7rPQ@%J4i$uy9^lIdL4eUn?pOd^GadqAz-(E%kd)7BWbER
z0-rGQE`s*{oKp~JU=yF3{3Swo!Ypqi%PM5i?LqfGg^UD-0fb6rJJtvegTANhd^y`-r1Fyj5Jv`BL+O@ww#{)-
zUXgh_NosqX){&~}<9F?G$M#eN>#;PaB2qgwYXQ2R1rEOILO*P8N@;noO^~lS9Uma0
zV|Ym1gExcYEFN(cXY!W{YixILNcID);^97hCVPMBw!`jKG?vGTCe#x!PE~AAzgwyR
z=ac3z$H5jlYsqf!sPGw7c8-FOLIe87pYGrhbA#)~9IKC9v&BA!m_Ywq`tPtqk2RtJ
zK2rtvq}6#_-opk*a$
zATffBZj2Hf(~7eOk-BDiu*HfIN#Xf8tMVyoLkctcDULZmFlq4~As?)iZn>i(M^e2-s)TvSHJ
zA~_NpXM?p?cd$`VOTqv4sJUx!;M#r5xIX-t6g{)h5{L;0LC?t3SN+~nw1bKe>-4kJ
z^H~VU9l{T;CymB!j<5h-n5+ltoh=u(srU4JXncOEkfBw)t=
z3Elqi3x{dx7NZ#3jC(j65oMBv!sr2kbRTeDinTQ~4~kNCcB&zmdZ&OX+L>npDXT|`
zAqwJ=kitWPuk4-DQ)#uMgZC|5_qZGO;Bn{{_}%$PbFyzCxZiHCS|L}INtoBPhL+1>1uL}52p#Ji!PDuaxb
z{+!3H)7u1~^Hc9@Clof>(cD;U8ULWBQ3wUpO@eX`+)s;5^$)Saq+chmPwJ35aW&pt
zvN#cm;{0(p)snZ>?;MB>uFRV{UIZTbZG%E|oVpBUEoB807)ifRwzFgG^B(nJa_7+V1tkMm^#AsIBE#`c9tIpdW4?S~Hb`x|XVbzl6fovldhs1|>sT7shMn{#*k
zeJb1|E{S4kefWn(4@#edS7QR!gan`zLF_DlwpTObMxZ^K^-BNEv^2B5{OY2<#*1kH
zEiB~NF|3!D=d0wm2}-C=;@-5@YCM$1H$hblQg
zg^`bSwB`SMF1L&5qJ{42a%263XO)VA!qvVI4nV18f8PrreG#47a8aEMO;-d+Dz{6j
zcTAlOGwc#&%=N(xuI=XYV*IHmcP%aDHB!9`q$%0PNQth2Lz$s+`3h!iWD9KS!cB4D#OFTt9*
z181&v=adn1xeRL}5hQQ_=#7pzNztZ$oivn<5meSykk80ps1PaeIelGmHKqvXJE7Yv
zdfjy6>VeBYZPl>_i`WR?#(&G4<5_p>_!K!cXLzlgeGhJepX8T22`?u=>~kMxRk12O
ziJk$%+*%Ox>jnjQ7*PvboOD;S-@#-VaVw)@Q{2hN`UKeFt(grc601u{W9(}G?Kg!#
z$$3T#DNlow^C;GAtN^bc!KR?o5dm~)Fmi1wm+Ix6_$B7L=Lc#nqVBCsp-yY+cxu9wOT
z`U8P5q2;3K=9Ts+A=1^4&foQqTCaQuS_ijignYQ?;>jMaaP`q9kxeN~!ewWo=%*Xe
z9P7WlS+1(^yMK~_)XcWYu}cY_P&^UXV1yy@QGMt8u!G;d!{1YWCBlFtD+!cxFw-k5
z78P9Bx_fC>kTbgjTS}%5iZ%d~=c#MVuA;v^z~c!_mI<4P?PCzFS$*v^h}mK`ceCqp
zzcz(uHlM$efVN_;$cz;`ydzdq)!gbqI-U9ONPA-B_FV3XCv_Xo^E2evP%Q0uBcpeV
zP|8$AD_DG`LS&n7{zqAuR+5L4Sw6e
zUBa_ixzX92fpQs)#D5q;Z-GuA(5x8lnzD_q4$p$?4A56{0Z&ns>AhV}a
zCWPdO&N#gbH9VicRwJYK=xuV++li@Nm;q=mcH>YO^B4$vtFs~sm(o1sCsyic_9x=KDZf$miX@&KXmDc4#C
zI}lJuMm5E3_O=5wpH48Y9&M-{XVE8>A%pmE7Pc${J(XW$WQRgP1;%r0n5JEulW1e)
z&YDb!@vD_4P)NNqILZxPTl1n`me$CI+>8Pc^0+`?Ikji&m!u65IS_D9y5B%2y1tts
z3h|`{wpbkN9t8#N9ObE+l5+#W4^c`$e=&9k<;yQmvm?qZEw0yzoqwQ_?}i?t;~&p^
zVx-w1J5x+>g#WB-V>n^rV|ae|He+dG+(oM}6ot+Jmh&Fzc7+M^9Uv^au2-4p<;s7%
zYMjG^G~$n7)rKzZt?DH8OW$-$l|tw-Fom&aqrIwZXngCNJN{uan?pgS>pGP9kQ-aMxVx^9x+oSHo~P+%Y_{o
zUwgw;rc!;gCru~u5@Rg`W4Aurn8cFOXPf+@O*vzXqnD0rGgZ$ep9+On=IQ-xZe$JM
z@LcvJM{;1z>}Xp($ay<*d+OO%oLXgLMQHYPN$NXtZ}39xT2;Ki+^V-?rM?r(yBfV3
zR$M;F!my~%1Lv;7iuPwW^7vEs#@~34-zZYPeJHGJL)=5XVRx-GUZQ`kWJOoh!91z>
z3cJ5SqUsHSMLsTzR9*b(%0Q&nyru?NndE7dD0v2k^pU%_n?>s68$EBZozbGHFP2z2
z4q6O{j{P_3Q~HHm2EWR2oH8DtS6@Tq(OIb12k|Xtv$M#%LoOO+Rj-6WeIUqv;Ue>B
zLVTftkYY`45>o5Ob4qIU1P&Ug2CugsS}W-99Lc1a{jLH_B*X?F@RZq5;_=bK_{^d;
zcXv9Phy+d(Z^?5X
z{in<#u?C#7wrKG?MaEb9+QW*|Av;5IQHfHCCYLz0vcH0_nV_9%dpw4s=$Rot_7tE@
z_EoZ~ID>O=vhC-&yrawVdej=RGC!wq^vqcW1mcFA?~h1IpN~M`d=e2N`p*2__jf|>;Pv7xK3{`z5D)cyO8l~`l1ye)Hj9nhHuvg}sGd9xe<29`uv%BqCayyHYW
zFT~tiw<=1;Dd|)~NDh5os?$LX&uiI;h#m>RZD}M{Ok5@zk2w){t_9s~mM5;ip~$tH
ze+A<^w!0`%aw?wCwgACZyPM9kheRM2@kh4`Y+tbz5gy!WYfQQYQ*ya??{9^)?LOR%
z!$?vkrQ95|TA$1oAA5=&ADOp1&#}NYD-3z_q`x;L_>1lJnBIE~H^y#BnZ&PlqW|bi
zU!fyXvm9a2AGh{;`#D|MJS0`*C``dL2kN~w0vUNF3c~MehcoSs74g|kQI%eu+Ao%t
ze#^VJ%X-dRXOpO3U!~Wl5Cnm#Sh@61L}CP{S8T5ySY9x@M5}-DT+sq5jRjP)10?bd
z+|I(dcpskT-RI4KMa9_fQOmd%b&5z=9K@d)yNHVka@_MMH>gL#;Si+|Jl+-e&x&^`
zdMsBT_EujLT@rgpDEOpKz93k3^la?6$8g
z%o{Hkq6_qI2URn`9c{*yIAPOn5@Nf)8;}r?_@}?r}hGf
znL6CVSIgLG)>1-6dSdKjVc$krtzD_;V_AA
z8{cPPW%+&DA-+456pW|`Se45OXBRq@-c5om%j$#Wb=oIOyK|Fyy?i>1@X!YvZq%8%
zO6pQ^5MGzQYVBFuP~!E(6$p}dw5t^|MmkD9kA=r6>l>uXioCtWuoBhG$5W}P?EXm+e=P@Zm%U)q&zj__u2?krRBXc|Lhs9SX!s$
za`2i}AsZRq!Df_jQ*tGq(7$n=Xax2*Uk5%=$;_Ek>N&))p;CtOaE)78lyjBitaJ~x
z7v$^0P5kKRTRMUY=;+!pvU-bptx<34fJ==KO>qD#W5e%b1y=WWKb?*(()W~!#C#DI
zyE-g1&+zbN4RCp(2;9iZpHr>{1J2)zn9>$Eoo&v})d+)_h!x|Z((2XWbqpeCBeqh#
zw7X0*7Kd#w=*1G`zv7(z)+<$0y^XzVMLuS
zVYGiRmY%MLeK6RthoX5Z+r3r>>o3lpxI5}
za|+bcxV%lbj~8`rC$4$c7j)9Petl3UTi?FwS&nHHBABuYroB*Fy@oOF_m(Wb>xMh}
zqwX2J=)d1Rzjc9&rE8(VGYhOP5#|064skb(nAAwNIw5T6Dh({$skx&Zxnd&ovfvwLb?y
zZiFb4XtM(sX(f@m;R2v|C#8Rt_(JGY`R*GM(D5h5TIcGeO1Vx-XZgE(03LaGsJTw~6;aUH4UJixs8yjV
z=aWF^h_RI#T$Q*xvnPzJ5>Z;ue3HAgiXd_)Hm!U90m`mmwFVAA$hz(E0nYP!aiaJE
zLK+G5<3DvCeB{mC>n
zV|UYq<722FU}3{P_L3^T+v*C6nu;fS)Dzozh`Zp>v(X<39RlrN)twZk6et3-n0X=)
zR3(i~U57CFt~{9B+C94wf@Z#(w&8q8WeByRBwy=o0!|TJ%RYkp?bo=QzXTPV9N&}UlBho@FJy(am1VWsU
z=xrVr4dWTqBZEjs{2n)@})G5o<#hM&{
zD1)tUsK?2u3%TQZj$n}H&gTU_O0XF%V%8)0j&Su1j})3CZCu&$mSRaJO}7s{-os(Q
z*iT5Svb6v)j)zP*?y%W3Hv>+`!~t4b$K5;(HDKWiHoHD0N6c2yL8M
zL(zKo@x86GLSA%x?-*jABBF_Uo^l)70`%u3&HVAP7K*T;3Rfl|u=e!9<#hV3n~L1;
zm6Gb_({au{5>9~T&D*iY7Re0th&v=En#v~^H_HiiE{{uW)RcX16jV;rz}KawTdn!M1(H`+I>hC-WuP7o$3I$z*1&PhP~U@2u+x{Y+B<7)2t3VwLnA=
z%dTpAQ!@XW##hDT;vh+NkYPg=FR~BYVWziZ-P9Qt)!DJ4;j7$VT>Irq<8X`N+M>~4
zKTiQOKqGkbvHQ#wqgnRKQooY1_t%PgO5;AseM(we_|wfPU=?LVETS1(O2r*rBP;_M
z{*hr7eBmsqP1JyMAw4pvUMSV)S|p?Wu80b2r-3KVrZqSoXjcC%FrC%y(*>$rmNF3r
zYKy!Jn!c#G(R5Vs{D-QRSU=J9SX6XZbg`QlIwQ?A;nuK#4J|qNEeUHXB&vb5E=>0J
z^5BmWOm`bB*e-hr1gvGDTaV!7CyKA__hAD3QY0#o`%XSJKV_uiMMEk)<`aBu(1g3Ic+*|y?z&>=5PtIBd!H|
z$s9YUd5|j|-1R*&>xgJ|h;s^>O*@op{*D@9Xe-+`GcieLV4Jf_canVIxO@mriuBC-(x*-tNUCfnu&h4VlE~glHBiU$bd~tFpd#9qTNG49VqK^kGxZAAE>h#cJztuJ|
zNj_mu(t6=mqT5X0G_dz24k(eko4i3#DJwbku9XuVs~
zAGFesp#3#o*G*C|0nq+uSn>Q
zJ_;h{I*~2PwH|Ck%MClM+v;#QK+eUf@$yn<-ARx(e=*Jxu)s1F{L
zeM#fY8R5ErPJqXbOmh3HMC`FiR%7RH)6QmlCcVZMf%wzdnZEHf2*JQxhH2Loe8b9q
z()57^1&ZWpx9oG4o6>L%pAvng62hFD&}F%LOIa(?q*(7+Q()_p^34@Eb0k(CVst|K
z9Md&tuLivS0xFIQqxixAA=m7Mn%@lNa-SGf!*T82Y2($@_mEh+w!?%DyxKdox3$?d
zzWoaRZMnePvvVLEAaV4k7e|s~K#t$xS#wQ;sjastLi#37%uLan9Ms`a9#azw!~{5f
zsFNjVmAeB^RO^hi6D-OQ8m_hUrfG!uA?83Vp@ECn^&^F|&F4))%uXRfgg>eow#}%s
zp|e?&OIY)7-3j&`M2Fo+?9Ca3ha?AIP{|X$`m<^m>POOZ#)zRPQ|G}EqwxsV1YT~U
zGGi?N$B_8t;5LuT{D8;QtL?f<#{Lx#93luOv(R?J2yLIUQ90vm6DFRSRo2xZRqhjR
zpH|5kcpqw^Y=obVI1_vbZES|MR8lkN$YP~qu{`|2@!CDci{HIWd_VP62RAiDE;|yx
zcsa0-b{~7&bA{%MqiWEk8XkIHyD42c
zFM^RTW-EB0C&j;$mIgiX?}*MLpo&WJLluyv+#L2gHMGLk>R*1f*J)bBD|jhQU-2;i`o%V|pN&nG&@*gjt=wH&s^qQMLJo(9gg*cZ)1-`;w}w4D4|bHhK&6u^2e;S=XF%R;Jyo^
z?ssgs>M;C*Gc>hEB;smp)P9tM#mlNFTM0(=+u&|b3LAE|dR
zON=#z*(M>H;h-Mpa=hMqZi-QeC0NV?=BBQq)(y7}C(po^W&ZT$lPY!2{zZ1_WC7#f
zur_Z(&@34gd4y@~lf|*e-H_)v0!{GbY{3hH$$-zwH23zKjLlJ3t*
z>k~B~3f_BxT||R6+{&qZHBG%m)H1mXtH^>VWT>{ffo(2_M*e6pM{593&Q#KqM@JP~
zQ%&*qIK9ce4Q^}~=wyjm7>ZPl!N_^?>MCu_qAEi+%f9b(nYz-*U-6NFqos?E`vBe-
zOv~nyuaJaqhOq981hfQ@0Ec7Xg5cJE3+y`fcxkqWr{qhsK|DcV&HHqtX`#-XC#`7;
zZj&H3AyQtIz#W1DW=5POwqD10
zW;CqO6~iIA&{wpIHmDYu&R7%?k|L$V(L^EzGUb#qAx#rZS-vMDpFN6M^crHrN5)A7
zHLLs&iaJ?3>_&?Eq(=FY#Vku~iMGhUFNgWqVdaWwP60(?hi|b^^y!z=TeU$v0jB|2wY1G0(@DSI
z#=Uek)nc8J;l2!s{j5sTd$rONUj$*&wjDG0TvI7Yr5{qX-^Xlar(0eHOgBtwkKlFf
zR5>1x@mZTOK3%w;1n2de_F~3qU1$FH;M)@))ooXXqqQ6>>e>cF_Lq(}>JHbibMZ(p
zpX>!Wjnx~R-(M{3wR>=fP*qF9mGGCI$iJ3}EOd5+{
zMEvA&;$Ge}kS3uez3wl{5yS(*4{;JSN%k;MBTum9Q4HNT(^8s1JS0*jotdfZ{SLek
z8O!72iRqRT{W`XDzmX;Mv&a_mrdWX%vgN};t=Oj0?v3K5-)ecr6vAx+e3H$#+uvt`
zPjL$er`SRnI%%qPL-{%iK6EGDPYdLnBfN>~loqw=$l2`Ha0X<@ndx9Gxq7S#cztYQ
zQ<7l$Qq%;~0=draJbfkF7N3`6|2XYNUpNQ{d}w>*md)@IBS4~l2Y8Cp{GG3<(pm^8
z?PC$$8vWsWV3@cu0};z05J9blhbJ~E^hP(5Sx7*vs^H_n}y!QLvv@U$tcR{WD+^-F&`2=P62QI8)o@a^^QQ~
zz(dKMs4HFl7xABkY1omY75BOvgtCJ1+6lRy*tbo5QeTl%J*O@#IclnOlsTZT!5IuQ
zdW+dSF|qhLd{SE*u@{2V-BhS;9#&0Uiv38-5y6>Q$z};h*hmEIaKp5`VQ0Yxok-dK
z!Z?4Ah^1^_(!SJ9VU|C7qLB`Mh;G+Q(Tcj6#9sQA3XO7d#?p4AQs;|Cb+c8w6ma&?
zwnJgjQgNcN8w>S;lbt>%|;(M(x#@
zCHYgZDJZwKwyEdnwv-&^BQNmr*<)Ombv+nxF^zA4-pX|d?ICH{Sh>Ng0&k;A1beV%
zC!$%sWjl>ML;WSsqfswXP?2s6lx6UD4oY#%&_r+11sahJvYuB9bcK7UjXUuYfy75k
zM9FFvx4gS`GI#25$mrc4v}u+gd}VqqCiex(dL+{7!n#Fc-FX+0(c4o{oisyWvcT);
zeMhd4y?v0omQ5*&h6IcOsjhVSVlJphgG%k71Z?b{z@GvppN>G7;-Y#agGeM6L_E%M
zRhfdf^Gz|^18g;wx%8}@(b#NfP-O3as)$f)_!{aK=t7z=U}_(I8qk7t$RA#SjXJ?X
zz231d!yybuSV9D487$n4{Xdf6Frlw8`EA5(W2I3wv$7-d{L4>y8Ie*?_+4#8$Pv4t
zR4FPQ)|(Y*=)_ink~cD@VL|Lcu9epksyC?H7J>Y99rM?C0}BVY-8rTUX8s_+0AG4H
zSxmqDmN?<#xTc)vjv1X7mv{}3UYsIeC~AM;5C*%W=Ao)vNE=tHy}j#vs+d(wN_Ll1SjbYR&Vo%V-!Ap95AuXpA&^4faZKEX)XUa|@=bFclcjdq7Zk&kS
z|NM5Zj4RQK6}}iNyY2HPc*RM(M9f$dWMQ|2R2Q;ae!9jbZCj+OPPzfT$>w-jP(z)w
zU+|ESiyvA_G3Ec5oVsOtKsHcd>$LBcz`ynYXFB)djEu`inA?j*Du!`I>>8nfr`Y;&
zgB}ixMfF5eg>H@FeMf;f%U3sItU>cGMTB(jzB;&|{u|1^046=WM*XDbhA7SZ*_L11
zm*A^QPCYvgGiSy0vF{xgwXxmgZj?gbudJ0kPys?jk<4H&M>?!%D(BgLFXBl}qHTbQ
zMRO@uz#otpcQdtpP!x&PGcEaajM8>Dbqjljfwx5=O}{py;j&FIX4+?AZo%x
zs^NgC*-)P$af_EiQGZ0q9xQ=IyuSVmH%99*mV5u~acpH1Dd;LNM5bdxMc7#>umJ`&
ztW1$_nCqhM&Gtf~yRx28=SWus5-KFvhM+}k$_fDog>8HrvZMv?K=7r)cdwOvCU6mQcVy0J%E^A|9v}ITv
z@n@)rwJlz39d;3}d>wXMC~dB)wb;P?eZo7&rYgMzQwMK!h)*}6*z2KzQUl!NxvE5G
z%tEVG=N~Jql>q)_I_nsZ7=H=-Vn@42ekA~irjE#s?HJt=PAB~UOSco@7<=*P6vH`1
z!~ztfp2v+N|Cn>lfK2A2&1tI~quBHg_X1+|q+}ha7?bG`3zO0^%$Sw}EcfFzP3
zUE75%fqXla2h;T48~QHbcWZy3C2n{YS!40{hm_TUNg`jeQ}l`ae1tcj?Fc!u-(^}uYMg~WbO)zW
zMNHc0=Nhe%rUWVE1sSLDFQWoGk*;DP(n|cMDBr->ZYk`hU%9r+XaHY0=j2I+T;dQ0
z#3P(~&tyG1Exeo&SDk6+ADXX`+3^ileUy!l9&zT`wR=fsT}KCd9@upI$Pec=VWQfA
zuIPXt$B(om@0czs;&EoI@SJUWMMvy$C?z4T)+QCwx)1ple9aUHrKT(xTb~C$(}QKK
zicSvjHu8ZyA#h@4RQ7N_zH*=%I}+FoPXq=u;L$SsY-IgBkyVaJ4w*~rZW_dQ(p%n$
z+w;0%NMem4_}^Gl+Qhx}lNH#nxnE7N*o{&n;1+p@l0AL0!W=_~x))2nXvR*H9E7yY
zVuo9T$jU9j`nCAYUvqz%gdVISz@}s8gGkL5yG;%HM!g(}aib%67Ot(+Og0rxV2@50
zxGILK3xI8)a`ygcH90CB8q6EXs?Vf;2q((f8-FnrC%2hHe51Bm^3GKp(;Ak$TxHk6
zat)@ahT)BzH%a{T;UOMPn3z+iXk^;ae0VJQjX7
z`?7YwPxR8P`%#7;lBiObTH?545Z6c>a!)j>xeDps5aaQ_
zjT5tij7#A|`hg+ECRTJLZ&y=jYmD#`2w%-~ZrG4yr*!xQUNI{P?B?NBCeQBm2L&_+
zoU-cI9e(j-oFvT6RJF&tq4qZp&?TT4UTq1bp~NT6L^5XEW)y!4*slra95p*$E0ELC
zeS^FHfj9j6i+*Zs6B~1k|Zs-Q51uXWb%s
zJbGvuB|MhaA8JB_ABMFn?U~Sg#wM$;(q2})vmyL)S=0zZzXowK_b>PumyPmF_n&$*
z&9cueBJ~jQuW8xWjP@wT3|GmRiR+guf5%XrpJ{mK@Ss3NMRZ$(M%F2`@wx2>ewZ&o
z&CVC9Cd#W2G}kem=l%*tV#3&N4I7lJ%KNP*RWvt;n7Ty94=E9aI547VPxN+SwP4s>
z!`^{bAxv`#L@hOOnSt6z8PxQ;&HF?1AXaiAk|V^zLA$0o5#L}zM%N7H*@K6Y^WNiz
zr`hvaa3aQj8?4YZU3KbWve{O$yKMdXvs2e2h~B_`I5(_2Py@ze36wF5>S!rU)GZt;
zOx}o~7<72Z!d(6MIGWFx(jY^Boj({v=ray+DeM{#1UY};3T)F~(pHPr6_a+MP@T6b
z?4jAf;^SdAv)lGQ2xKVU}^xS0*fn!qMo^a$V4-ib<-R_en5qWX2XF_DH;-*T0Jn=${XzA*T
zg~B<7dtR>(x`cj?Q$_nKGl$g^`!Vih&wC-M{(5idW1ZTC=iNBkF==w?$OC)26Paf6
zLl%lNyb6EB2TjGT*}rtoUJ7Gd4z0wR1&C{JG2YWCG4Wli?$97A62K_v#|6D=*_vhY
zGYj)a%=$yY{#L;v%p{gqyqIh_wC!!+Mjvi~Ek37Kt}08EJRedOZm2`8$prPeiD8{?
zNY?c{m-Q96dcDDzE|AHFy4{!Ty9OtJ6jZ(1@Lj?-xcUF0Zkhih!v4b#{%?Eu|DbOF
zqtA+(I2k!w*gM-f{u7A*%jFDg{#l@el;ky3)oDd!g*BM|VRQZ&#m$_E{-JdKs}TO*
z+9!H8b|QM_f7H-_IHrH}QZ~ka)+Zq+qyMZ=>|FmUMGWjEOf1aI|D~MlFo6Gt`LBAy}%X9H^sBOzNeYm@(|Jj%`{HfsM)^sh(b|2c^DKX8wTxq;(K_1kH0;p4O}7n0);-(il}{Z@49wCCrBh77$S_gz3acm113o{z}GGv
zC}Pi`HM7HY(o^YWRcZRY+}YW8UH4r;qO53y!Um2TRNU_>Cu2QT{R!kC#$=-lL`w_F
zLQBhof}YY@k_3Nh$ApqXF*Y!dVmFWkqLAK6e&mv8-Habj+zfI2ybl&?dbSZhtwR1At(3zNk>;(TRSDF^~V8*qS2(sVG(Lb{qL~xzJ_$963j~+y{f1ekqzLDt%<<>tA5m;mM$0D}5AxLWr
z-;qDX!W>FYA#DM)iOFis!N=QtizJc=qfkRI%3
z7w<1rNNF$1U#7pLvjn7!-$#nZU*RF
z@%})Vrn;7z`k@(|ThA66n7z$olhNL_jaNaP>1A+@LH7?&OiT<;!vpz%`ESY4X?#P~
zUE3nQD~~^iy|#eZ$$QoF^BO*ZKJ~{Y9ww
zZCCWu7hIfeWBskN_+9byQy$Qo%6{#K+a253w0NOO6{wdscq>L_2i5k^MaVlVTi?cPdfKUwL+Wh&q5}2`}q47KJ+GSg&
zTCWaubT#Q+8QgQb^hb``!VHA{%jjyYqa9cf5;C7>;bNeVgu$P3^TIbXaO)e-8VI%t
zf9-4;{8lrYqaW_l|8dmA@c~F<=m+U5~I`j9p>8I5EC&%l=`~l(E_*3N86}?~|rB}+=^^ern`@j7&#~iOx
z+s_>T^gMpBPmpZ4cDE^+U;jenpxrH7-Cw)g79Y930d<_2{{q8*p|-DOFC}#IUrp#o
z-fbVm#L)V{{!{Lk)4pEWmB8z)G(MOkXa*7ebdW4qU^UJ^KFWnCv`&WWXozXKYsh{e$ts`6UYj_t!PpoTz-wU^nz{_T@t?sK^w9*H=ap%Ui$gXjBc$(bGeHo`jXuauYh3{2G$pobL~g^e1A@`I1n_&1&9
z9!*=1!_i2KQuCN{#P5~C-*~pIhi4-M=Ud2JF_}FQ$|NhU5TRu?D%d!Q71I7
zbKCmSt!a;HwTdR5=Y8daivwg4JtOa&!e=xdiG)F&TRK{3yNSFU+7t(YtF4YT{ETXj
ztA0$1=4o17N^u=~3Gv5wt}Cv;8L#GLDRroK+7YlK+`-a?Nwsm8W+Zz_hw`&ZndvRy
zrlr>03R_su|JEpcJBy37^4MyBr}{e%yMBXmm7xtMkT4H)KPceFe;Pco9Cia}@C1w*
zMXeWC%k6T;MNO+|9_$8x3#UtkswTnZ&OV}1-Tq<>J$}v>1%Vs}ZKg(}iYK;23M2u(lZ+L5E^-jeB6
zmN6c|P7a7wr&NKVfZ*(`<#E;|9#oLi3e-*xO&y1CLC^m;zj*$X>SMZ}t((#-OIR+)
z#YaM7>!nON?!2V`OoWqDXK7rrUDd$taZ3m{1;)
z&Lz}V@Btca{8LM245ovfw+XSL&{63IVbF*hRrgQxu5^HT4N1LlKvp>NQeo4L(AOQ~
zv&-~gjXyDNL{wI8O&dAN*EB=R{1-uGtgj6b154_LqtRcimgyOP7!zA!5C46>Ilo{F
zt_+sg7#j}u=@zPjKSLVrCHAmYqg?f!S->7jbxvqRlRS#pZ<+z}SbuI*#1f
zhJ2c^u04Dtlv$b{7P-W6N}2O9n0A&Q~M#nNXtcvta!9iD)v&kuTzF5cx0YoJrn3td(s+Am{baDkz^T2f
z`^ce_e1qg=BjFUI(#;amW&{O5mY|i_i|%v39MOP{^7(qX1m}Mww|?EO)~WhQ45W+P
zTmG~QWo=JeL6-IF1gXO`cvAA7%
z*+2;Yn*tA?o@*_-yne01%VX8l9Zt%zYq%jQhHRud{KHdQG}~6O7fHl{rPI_q&k9)_
zFaPHV^9_HH?b<0U!!6&&v@pOsP1@i^oD&%FX0K5-NGJ_A{k!
zWO%^n)4NExWY5NHXMwPL2ccugcuGQYmTaz0NFlTUX_SF?jKM;MoGJ#}aK_+?pu=EQ
z&(-QS8UZHy%S(D>Je8&=ORsTKmS|u$kQQbWzE^WSpXaCvV{to>r7nXE>j%YiYLN@p
zgHA?3Q-!`{z?DK^s)^~fGp(Lx=n%2!@>1x{DwcE)LHhJS_~73ye3x|*Kc9R7^b0M?
z7-a>rN2C{dN`v$A5ghI^v+;0ou5R%NJ}tlWem3T9q>b36cq3Zk+oxwzQ{fYB`>DrY
zB%+IMXPXT2Ny;&hHly7^wtUXBNEe7~F6*dsoQ&H=rOn-WY7e7WW-^s%nr4u@RX1`;
zkp|_fDCvPIxgi7Mgvw!q*eTA}lgF?fxv5o;q9ZVxF|C*UYgOVljXhx)lwmWRsPxd^
z)i3Pmis0-I${&q>x?bZazqj`7E|mVg1kwksX{wjt=n6RH?eb5ZXzCoASgmL+@IE>X3g;3*C%n+?GK)G^?zho$>_abq}A0cc-N3uvj6;aCaVP
zv6lV1N)uBUz_0qDoVc}{-lBOv0EJ??q0x@NaeK4OzwFB~W?7codsQ-`&FN*I(>rXu
zQ_jd!)gi^KyW>Dahj(rK|JYWscnRfI6bnWLzn8v=(xyo}Pi2+0R^uh2whMQLl87Oe
zccI^kOZj;C$^HFc+cFYSnTJT{@>MS|4x1UEeM2ciLD$VQkpjXsnE1$rNsZ#4a?xg(
z7geD8r8+OKS61EJR^Uqd{YYWU%|G;wqvS-cv5gs+j_i)(Sp?qE73QCKM;I=mRWlgyJKJKJ19W>s@>7(%v>dCg_}~NKS2zgUU5DUkoku=p48`?GjX6&Ganj9^lVz=`NmQW4;5%I_Dn?-}<@nS{o!#9$4
zfm{;zIa7AQzkHbcL>Fo+ty|1XcfrU=eX9ClbPipuvY}m&tDisb|%8oKSLRpZFBD}Op^dZSpz(8nS_88-x4_5ofzd+z?MqLjBeVa+$}$Y||qy
zp4vkMLB>DyY|ObGGD`qS_Z@4Rw-KR=csVXN98_p^)0v)-!3liAXZn|XKXS{8a!kip$4-_ki-XJr=M
z(8_^FI<{9S|9FH3w71`gK(HADz7&s`+Lm{XVshR$;Ze=Lv8GjSqu2kWs}_`nh4};~
zABiQ$(o|tmt&~cMQ2fvd)pns$4_nGJxPKy`n#a=9f=k&w(~2eTbCVmV7P6qxs)sdlk(j79;rq3WdF)DXpg{;
zqy4&{_m2~_^l+?kbWl6$p?skXgK<5fnId>P#@NRc7GhXIk8dSnb{ueDJ=Y=n(A1ev
z_fH}0$Cx)7SZuRvPW%o$sKj~AF&~K{_t3^UryXc+MY}p9t6e#Wd13+LHBY#is)6uM7iGtFz=w|)
z2euxH+HViuH|Doh0N`!aIoS(wW0(5sbj9e7idBI^g?CH{EM!tDrBWRyB_=j%+-k`BwkHu9j2PeV|hmX
zH(3>+vX^@B_hEWDGiA1fJfGsoJAuTrJx<4=no*hZ4&_xhUe|+Wf;9WMNw<$y3X?rj
z7T=W;p|{Qqf@3>;87VRWCI*23iJV#GL`#S_E2Hml%tqXGC(cOq&Ac{pc20?JLo1b9
zz2O-FJpBbwfhnY#$G#ylUK1!FydzRKOX>E4M*AyYJrl--qD5355cC=uuHwV?q#1wc
z=p_5c?RdfC@h`VR#*%|I=shC$IM(~rjq{sP!Inw;-H0EBrr6ME)5O`eZ5-V8aA&p3
z12AKAQ>lnppY|pXDdr}xat_@8V(p${MTx>KQ7_xJ&An{fwr$(CZQHhO+uX~xSMNUE
z=cYTkr~5wK$I48ql9@_9%=*7EYA=EZhY{jYkMIZa?<1nZ6uIg~n7^2dkE&|TyVuoI
zp6EMV<-xoki~7Z%h#2W<9pK+Jc$?j{X&sxC@Ky85!IQG=YNl8HRELullZ{EBvy$7H
zn#vaMWrkB_y2R=Mio@=Cd(%7{-P+7q)
zZe(z$(1yx$;uzxsj(V!9|B6xEm~l9pNjklYPI&^7A_#2%$dR;Sc!3#h9Jp&=
zv4oEKszLTjodMTh#(4!5^9draMA!ZMuZiZpAKC`
zy$yvj#_ZBTly+WnC>mS|}+g#ra7wV!jEiMM#%0TK0HrEQRI(rdWHh
z?_GWY!@<1z`VY&&reY2mS^$Q+FBI0e4
zVue`MgoMFA`eXh+kXBOs{r-?GViDsHImtKeo9!uL=kkCKqiq3s&?m5^all9t(rz%s
zdm$oXYhL5Wwmh4>suY!ky8L#i4-UEr6Die9dEx{E3oq~`)vjDd2_$ag9-3-v6&BFN
zAUc86yP5>LR8Un-Q91&B!cuUg^G%)e<&vPkcWlC0Q-33^Vy11e4Yc`~pb+UW^d+`X
zSHu0VbOoS%sL{=zpVc@EaPuv~oOn2Qx??7upQp->2B;uRUomQuEL>;`PmeS&+UKt`
z_nXNWu;~m~ivlFHD4z*Nz>5lIa7GFo_7+zWMia2`VSe|N9C_)~S2mbHIfYGKj$1I;
z!5U1%S&|SewNRdHbDhE%NomEp>Pewf9t~g
zK)@=yNd{4kcE|vF=Qw}(ti~Ckvi}0`rJ`&ufpz#;f=B4#sRkNSyey`=0d$k~N%OrPUNE&*TAsMdCWo^A7$K83U
z7wJ+VMU}1tT9}Jl1X&f)OR!j5yP*$aAT2Yq7>TQ=MaTqKqMHq}X3SW?p>bC~NklVm
zfl1pF!D2=XOS<&y8A)Tg^n{-j+)z7eFdTSxr0`KwTE>WG90UaMKU@(I(uZBDm
zgn!^*mgflW?Pc`~nmf?{HI*+?O^yrC`TVK4*K7?qCfzH{Ml)&8cs`fW!+6Q1E?XPR
z$*Kc?fq~&Qhu*w3B$Q0JcQ(W5lPF@dc}p8ln>X1x?kH=V@~grS0OwDBVH);aDRp{c
zkFFiGS0A;X4)FrVgq?&EglmCR@v)Avedz(zyPZyiL=NUe!x=fG8dllzbd`{w(a<1!phonVlfeyYH}At(uhAnHIxLY)I`f5h*#K5%A&
za1pUfV#3cuN;Z@+%ehh~pGRGTdQZ=EHh6}D<&qOf(A1pznua4~coFIjk-xP$I&uNO
zf#)7&)EWtaOx>*OmtKPtI@!EQhya2jkVr}9df-SMmveg-5nKDU|3dS}lw1PI&aK|r
zGif65t_lNqlYrDlPiYR8$2*#x*72(eyjQ+PqJmO!lq10!DMnE`+qPsl&?5$?$YfZc
z%04rYfjdxqmQdkpOm8WN#ewe7jjt`-!P^Ze$B=N*f&6%B_
zInpDBchKR76e=#vZy=6Ugt&lJrYZ&o$a3)^e2({TROxz8=d|dz#GI+JKfDs~&G+@(
z3FBZc_bKw3aYh8D$oUi3b_cy1k5ok~`fINv*u+8pykrzQYcXI1=eS;+$At7c7k
z!6OZ&Ucxe5>ONyGGkj(zFHu}_La-OmUY)jMd}U|Sn`mvu;q2ex(&<_Y5q5A-R=g*$
znL&lMRh+#IGUH8=GzqI8PU6-ZTsaSAi-ySnG}d{f-`FVE_-!I`JU5Xlz|0hu#%8`I
z9u)tOH+v;hx>wN5&}q!4iD*~%#C)licK@`{c}}9qG|q+Ayk%E>WppkXm>4*-;iCl>
z4(*lhoDlm{&ofG_smnERh+;V{^V2KU`MkD0)bR&DZKeS~IKD`=6$Sc?e)^ZMl-Vmr
zDhlfF1WifR<}fX%t<}@{B*O(Vq6;x3Ce2|?h+kile`$$Rji6b5f=3O(%c
zBJ}M8B2n{~m=~U4nyhMDi(auH*Z>mcGnJq5@LA<{sMx>@36S6EWz~&xB$X!DZCmu_{9k^cYgxTb+-?G``nx>)<7a``l
z>3jXL{EgCzS`YVh^Uk9yl#K^bm7NAF!WEE18jCj9?0}7Hz1?dkqobw&an-_N9-_gPXKdsRA{BF)?
z-X~CYL6(O;_4nl3U)YdNSmAQR@G&4KRJBllp;lkepY+#Im`t16GmjFwQ>dQbBVoXKSpQtB~E{`l7pB|C{W8u
zk^$jR(M9u(W+ILCrrE8I_0;XlDGp4FAsjM8;kzHRMH-pMCE`h=I1$r<$-`UiynpJrSD+@eG}W@jLez=R{I|fz
zFvRo1y(2xM@x?#LM_24cC
zi@;h$s7`ZERrNI$V?3YC!!qh^MxHi`@_!P~<0hQJNW60bmlbk)v#4?zAcFQL*n~h;
z-Wo+_n8->)MHX3O83uZHYCz&2v+@)r2t}hOu|C@Vf>KasWCJ&VKm8$;D`E7BO@eY{
zQRi^r-q6QZ*`6g+opNUKLmG407L<0GM%0}<%;F|CS&w$P4#E550g2UL_A=weSh8Bt
zAd_R9npBl%E~gJ`))%ynwZ_|J&M_1m(nD0BH%dr}P%REvSGO=t)XLj~C=Q%(VMq>lShLuZ6`Xuklh=
z#+7oW!(}1fvymXE^7-UFKwHJ}608$jo`^ka%jB^C`|tN%m$VG7fr2fdu4~W~{5g6Nl$w+e%n12>o1(PO%Yl>BVW9$`fO8^?;Sy;dRXe2syS*PoET5>@>^c
zW8FvELrN9cDUo_Ygw{%H(vv5DIb=LIYKakd9^cZRu%KI0C(|KZ71_KiIH%Oibwz!R
zy;g!1(m%$r{l?zH8LxGbSB^>qVDDm#
z4=$yHskQ{M6CY>}cwCMrqpbrI(Z2ot7LYC~r2%x$23&Zh4RM-l`pca*!E$WjX2N6_
z$x}*NZkbrIQ@4|np1=+l2{W-MOk)xxit3{5o*A}_t3in8SEH`6!{)M4XoCCBu~E?4
zJnsoBk=NeGU-a*b`0QDhdO78WNBk!+y)EX~g>QR5o}r
z*XVZ`i$Kmr-HnZv5T=36NTAo0LUIQg|C4FlPrs~6gu1NEIE+zZaXyH)M>0%BXRes2
zjQc#SAa;murRQ6hMhetquUqA-S7`@Sa)?{+KJaGUODG`u~_msKGVrIMzVPV(V8pmXS&ptFVF{?C>b9)wBczF1`V
zlOB=oh3x__u2}JyvVLUmYFGT1I~C_JQx8e%4(0Mg?bal+TBw%2@v7>c`+TH?6eJM3
zI9CRK-F4SM32z|cC%t>x^HN%3<2stQxOh>2^}*dS{yA`c#Y<059L|@I2c>a**Ky#&
zgJlpps7UF?g=3Tn&vNA{l`eXxt|r19h-78<@spXc1qD#O{aB*rs+DAS;=;%2x=4Bj
zRQPm%W!pQvtxn-PdpxrU^PY$ySDEczyn;OM=xc`r@fhKB?gXEg&FxtgKYy^#rrbBq
z$jR{2SK)kXzO7(Z^~I3J@!JS$DeXfiL9Bn*LV(n60le_323xk)13`
zCk(nmDN_3%^b(RJg(I$PJ!3?8(HBm)UiJf%z4J|iN&Bx{xlE!i1zuUEDf;jAN2nWNDf-!RGr9Ze{PiPwVXBx!Es}Kb<3M$NII_Y
zZoX`f3lbgpt0~~NRVeab`J`C_QE~~V;#hSeFy11v+xTm@)z?N;S4ZT3g#uH#3vog2
z=BT(p<%TZ_rWERI2DdSO2iq>N`+Fq_T!I?pTGSY+mJ7-%n>ZIv^4ITes-9u_s&Vpu
zJ04~!S$DGAv{9oX-y!b;xc3TV8Vjl?DlY?wo`C!eV(Ku?0*&;-=-~P@?9z0+`DBOI
zeg}zMNCI?H*`FQKE?$^8_?F`0^+rUd$IydgZ*A@3Uteq_@cp#|g(yD1t2oRb=OEfj
zSQ^Pz_l%pn)9EeY{g!vt!{sROMoF8e*ojbq$0^Wl{CPOWw2YU2AT6M+^sf3H9U*_x
zT15?X16PFR;Y_T)GBpWzCKMB%;t9nu*A#`Zljf#csV%#lsbGvIk`KDnQ3G3@PtXRh
z9WZFNzRT@_n;CIiQanjqh9o4P%aPOSy=W$phTzK(1&sguJpW?)=)Uo$?B$aKf7WvY
zulK>)K8VELr;VhiIyco4lG<9mzX>)HU6HcDfHn4`KTq8xe${NYW|63Y4`pJt92$^p
z%IysSxnpI7@%{pXS$mxHLE$R`2Vxa5k!99`n_buD6={Vrj>&Pdy5&NHI4KT6W-XxM
zvy`Rl&l-#v6UAB@l@KNeOQAbj_>&v1pq1lCV=z-UOb;XVaRgjSGBjw4_{d?b&OIh9
zV#ed4?m30x-rp7nEb}up9mSJpsqL*0C5CRE3yow|V;B9lRmMmrTPGK6P+
z#er1%cRz$h)`zA=-qJ=?5}|(P-~SKLV}Lbv&C{tLxu08g{+i()S0EVa8@uONzXhjMA5s>h
zdX6$77`_96G2&DE!>8iiq1AdY^+Z`O-OsLqfqCCJHTTOkAd<2N1~TI%*fgPzik72g
z`kfA%nZX4&b*lF5Na^^T>Dq6$DJ)(BVVz*~9qmlhu7?c#yuE2|!^??Nlg9hdM;nvs
z8))V}=L<%AJH99bB8yF=ZSG6Dca(`=-cbfbim)ooBz)7f!M~DNGAnP(CI_NtNFVVi&uMz}
z;8^{1ujWWIRVo;HrHz6Y1$K+yLOiK>fa!{GUoJQJP
zFTt}wvqcr*`Bj2fAUIII7WkQ9Wkhd&$2fCr6(wn#KOC=#o*!7HdLd~LV!UH2HLSw2U)ga!srqA^U
zr?xT%E07<_Kn?AIN2U6WvMNMa0U$xfM1-P8_e#sD
zYD{@b0@_9G83}n=m}PgURUP)OM_C_@9z5I1?uw{lS$TS02=eIEs(0R1!+8#vMz@Dh
z0^m1o5Ocxz-}H-J53bqwXnOv7!i-FceX6GDzJ6<{9kc%at(fX?%$@itvJ2<=HyitK3ajrMaY_Lh%aUuR<0U&A(Y
zhb9pYap#ku>mw3=+@7`QFEmRG^SE92@AA(xzH+DKb;eNC9CIHX!F7iZ2;QWkqBY=O
z^+NRr^`s9MR5fD!l>IQ88q5k3>7xWsi3fslB7FoefkNIa{@ti&XwNsQx?%`NZg
zm}PMze2NV_Y}32Y4yypcBixMVM6*s*B*8r3!LF0n_a;}M%9>I0#kKP4crk5uLO9JR
z8vZ<=V6n2p&Z4+dFu6y!R*9G${LRHunb*UsN5L+1xzQ{5xUm+TLhL`*<~2lkvvK7i
z6t}Euo@iO(I&R&8Y7DCmbhnfWuG)Hrc+7=n+vjGn8NCV0by0b(D+mIAgq}rpYEgxY
zIWhOK@YM~w*8af>uNZhR>s4%&(A?72Y>Y)g4A90T&+Vh0P%BiKtZ+}YxUm{8yPs%W
zO8YEfYhG^9w>S)(NG@|
zSym{EC)QR=;aebuL#?|w=K-Hkv)*Dhx*4R+H3M&P^FbVy76E$Rt9#Am%vll~vnehf
zu~O?M2p?6eu^m0DH!gf5BJ&&=>(w9EzpasZQR!fE4Vg+%s!7^tytkr033vPOB;Se8
zdO2zvUxh%C+RRT}4lF#jJIZ`dysDVHM3mzDHp{Y@`qPL{u^?nH#E!~Chl(*t7ouHN
z`u0+Z?V-Jrk*yMaR=WimKH};U;}X3KL#9jaE$+PthLKSU@;Pg55w?npSz`@DX<9T~
z=QK}Pu(OpKnk0;1_%wv;^#?5b;1I^mV_=7^C94x9ZO^ye6WgJt9PK&DX^wF(eIX4Z
zGzao|3_}_v(P}N`mu+lx<_Dn$oXZ`F
zw9~AuOk8N+4U{K-*g8q$UDrdPOuX-QCwC-A^rGGTUtuN4-B+TBGW){L&Ks-ckvrPF
z(>{JDj&XPkP|}i#lA&~`07-x|osjW8O%TQ~wis#P*z@*yL|#j;L3$2xR8bIwy+1w~
z%142Is0q6Np79m*u=?s+6h(TIp%7obuz93pGLgmDZ!q+T`ZSys(s4fddd4C)5BNw%
z7G0a_PS8K6Tz)4zx2UcYkkI(CjNpe1=;E3T1WY
zJ-6Ci0
z72_XL7Tj5CqT-e(X(nspY`vhqS{NjxqXsbrA$FjLuhE8%S$fFcRz6f*=r~rI$Tp_@
zxJh5u35N$$s6=|)OMfgy$ex`Hh7s<>ih{4KlZnATf}nqWu<1)_?F4aU=#z7s
zm}|x&f<+o+&e~`0NHw3&NwGS1ePApTSV+QvMz-nLG8`8A;fwgUMGh5z9bdi?U97B0@neb|7{%V!v-?br*t
zqBrZ?5crmy!ioKANZBc3o~L|AD$!$h7fNG5k{`u=7lN
zuiIY<&*{XXy}I@-zMUb~FtwDNCXBvASDhYHDb_H+wJ3~U5^wQFb|q-qOAhpA0}H|0
zQ(hjy&!gznzd!Y%e_;DC(=j@{zIvm+L4Q6GAjZ~5G;amf=g!m{F@(pS$l#Ny%wi5|
z*3dd4m|8zrd5Jv{|3QRJlFIG5^_QbVP5Ouy*|R!%Gp+JeW7>K`Bk@o6yo}DrvZ5(8
z5*;yUB8M_4w<343XK0Ekc?Z>va-{=*CeZmVoDu4sqjo~!MTNRUS8uJ6Z{^AKl!LFM
z(8&TpQu;{mG*^XHn;^WSKJYD?!y{vC3tuvy)g1>v93SXwZeI&23LAklvxi-ccdcub
zwJbYukgh%_U;Y750<4|nEa|^7{DoeWPJpa8@~ZNvBABVoUbg3Oh>X}lwam7>w@Tez
znFVF_VrL<1w*>6hLkp#1zr@wyMpKnX&1i(r{35RA0;^$byhQ3PlX+1cZ~bwVNR2z*
zdz)5QT}
z@>Z8DsE5(8yNthUtKT7TP1-C!j=PGD*%VwBbpsfU=}Cp1h_-7<1w)GWLHx9rye28l
z5zhYAh#f^-*z>imnwqdre`niEwIE@kL=~5TWKz>=zm(%7$N%2o4OJ7kG5?af(nSup
z*FEZ6UPQrbwlvyn%D_=?!;`=oZpOFIWv?awz?bu#0{sp8{wS(&Vz#X2^PRmUF1Bi&~=sN=qD-43uLK7w$g3Ya5`
zVZcz>bf#oyy0Z@0wvEVX@R(aAEaTFAgD~q?u#Y#?=#5joCrUk=fR>Zv4)1K#6B%wq
zlx2WZrJ;bs$dE&N^hSSfTB-{0dYW_T#JC`hw$uMmLO^?V%~3_zzYXrCLntKT`_ZW5
z<}3YE`?G_h8W!^DC5eIywGo6;b8=6ND#9Tp&>Hy@pij1jcC7!@I&f!g)<|IQXwK1{{|u8=@o9crMAo^X;9
z@Wz_4#-$)e*By_dcJgX@BS&6dQ&0FOLKHBN{k}Q_vOH+E%-{nahTlV%OWp3js6l_s
z=K`+;pTE0QMxK(3mK66r-<&5QWXPMMH3a0>0%{LiyOFoL-Du~=6N0{^852FgQ`nZo
z5IZfB=EUQz1#I)a+C8ffti80cB%97%?wQE4TnqK~aB5bJB+Ci=O5H7E@UiNHnTqRV
zIAxCZ?Tk(0G}0yWBb$_N-@-~U9}AkS@{jh?$}(?Y$1%s+ZpbcFp7MRoxm0ANIRUE#
zF-_$C3}BUv^ZA^%@w8{7Zlul}#HO
z{eRi0|AcCcf0)?*Q>OicYD|nQEdP1=zdBVDPh>0
zy_w@HYrsXiRRA(H0AwyUWN@pmGY}~AW
z$=xTjvoG5)Ft)a~Pob=`Pp+}1U&_q@Y|v&-{*3dGXJ=5%fM2E1@ode2KO)h1sWADL
zwg*pb>Latu8#D8W5bo&eS{T4KIlH*p)-wLF{;%5rsFWK1fjsjsc19b0u;zfj7O?&i
zx#xNIzxO}5zx=~o9o?N3*8#)e`ewj+|pmkqBb(a*EiMyY;tn+
z{np4W4g
z0a!&vMd4)W0OkP!oY`2--f*>7hVb6f63^S-dVKNey|}#m&$&SJ<3cF!zQI?gCgxEg
z>|LD!Kit2y?)xB8BOvt+4X$AR0A*^d5B@~_(1B(C#O%rKE)3%4554iaO9PDV{dcIg
zYc@4JySjN4_pTQU{Gh<@OwJUHlj13=GdDhhzhgiY)p5fKI2fB&=p*r)Jw
z@T+&@CxHq}`=f+?lozhpTIvc=+eg{`deg_O{mX=${HuXZ)&FZ6-{zHPMBx80w|>dk
z$bi-7$MEfk_tU5S^E>l(OYuu@^y_zt=+@BsBPI2&_5EAK(%ex0@)q~w6RDHE$0j&?
z<3n%#TUP;gcT1WIoT=Wv{-sxw+;s413bB!?@w+4pP3{2gmLE|V($w(22mG|heK2{Zi~k{rLfJ=mBSHZSuW+@FT7MCpB1E{g8fa
z`GO|;_Pr$c^B}Hn&-@twF!VYxd>h?iZ*;K#Nd4+&ZTwpmedK%J!?wFIu!C#h1>J+({0fl19r>kR{%jf2e)7bCE8OW@
zXX;V=q^Faz3Wj${*xROz!=9@LiRY&)xV1
z>f(-JU{-M^T4oQ24-zY*a^L?x+^@mYe=fjn7R#iW8wf!bXaIOF+wu?gI?^B6Y?~kP
zDGAba#cV%~)ab-$G2iiD^l0=hx&oy!6gT7aHn&WcavOf{`s7I7u3!^92fx7f_J0XGac^xu-%tFGBIsnd8R(?_qGcJ^&R3IX;dimS=l-jk-BG#3FTq9UGk`>4z
z2JF6~4Y?42h_%ZxT9#B3lu;_tX~f_QlB#Hi2U%{u>w|YmedC*+Hv&aPDGtg-wG0LH
zt)1hcq(#lOWzptB(ZN>)X?Ay}J4E1{BJ|@7?4EAm5ID|h!9o9T8vb92!|DbT+I?IY
zAGDZWGnOr-Ppbyp%C)m@qFZ00Xv5evXjD#sz(;(enbq(~?
z2-x9kdW^y(g!$!gXriIN)*w1e=by5VOpOAT>#FLki7EIaxU0%CW6ctAw)9nIJxgow
zo9TTWT6L=w!5uUmZseH~I1KJVf{uBKQ(GT8iIQ=Vl(^dN-1xR&4ZShuU
z-f*5x&FlGkUb#bt?({EK_|-b{-uW83GoS?=c}d
zQnD^j+v2g$;*nBlyPl}^>+!ci84KmGRv
z5%5c6twUl>TcyVkv|YTaY1pOO4{dx*K!}j~=Q;jjs*@+l<-_YL0GkR(HHp=6`Efoo^hqi>}W8iVGPqBTHPjB-|
zA6(@kB(7O>0+U{8Sb4(IB9Mx2jLBlq9WU4H^R4&OMbbW48}eoP?gc7k@WSXGEkGeJ
z@J;O2G0_S>=E|Ka1HTvI+9km1*ypB9{s5Rx1HK7o2WNoiv}M_R(|;d;&1;~=uV#J_
znUSL2O7)fA)2S3=sOwa&5|)4;%jYP-@fMfOHOFFvJi57zE!~2@nFKdh*x_<=OS;5EG8yx0jR82oh{Eq92&nB%!3KjdEW^$1REs<=6bdn
zQ}q@AS}gLer-#^E{Vr6_W*Q}FB<85(ot<g0%Q97qI;PS3BbmSTrvm~6%z&<5
zG`{R22dCDzmLc95#!kd0*(p@!P1zcpRfm0bqd$ZpzWvax+l;MA`Co^HM
z7^}x3BMn&zbCsp=<75yZie0y6A05>-;!%{#Q^_m^Z{Axn<;$*|{@!*Zg+JY6DMDh)
z-HY(eQ(KSxu&i)g6qU)#6m0DS!91}AUN&X#t1%{r0pSvc`G*#X-5%o-b6^n{!-J+tO7|Xbz{_
zP2%X^FAeGpbsGMtHH~L=`7xtk9i1>p<6y4N0@JF|p-?;|12s>dZ)eb~p1RnpaWhM7
znlt}wtjBMeb8Eho8vilGS}1767IV_j<)I+NdI3J?JvXf#`fka6b8_Z80hiJx0<$`q
z9Bl6GIl^PjE=c~+ZDMnoA2z_4_OZlho}rPgz{#LA+S#gB0v$ZPTAc52$H!k;J_3J=
z(JR;9a4&31<{OO}IBBPQ;Nt>Js~2kAnN1#I=U@%TBD=go%0}91h|W&p`+!0pN2f&k
z`SPT!uwZ2b6d~FcXN{1J?|;Y8Og6mdVe8;|e|p)dc8Ap^;@}A2$v8rdpo~$=aAyb|
zTyD*b<&Z)ZU*YtYrzmDP#_b>c%ooW@T700ed^%J`K4AMhhcozA>f75ZtXij&1UMEJ
zr}Rw4g2b3@_e}EO?K+@=PBC70EToS@lv@Yv8||rd;~`{_Csw-%Dp<2BEIHqvEh!Iy
zgl%q~&rLki7H{Nul36X+UM*E$nxOMT(7ofJRu{K9vZ}~wUX|qABH~-)`n6bSq2Tk*
zBk&_t(=cTmcT_?hshpYHsl1^oQ(imy&e5Q34SO6w9jI4}3}ajvl$0ZM@>QBa_lPQss{{|1?E1D_JU4Gh1XHPY`<6`
z>ofd(q>Nurn87T-YAEgZd%CiyZwADa9fSR(z9d=4x~5$jlqPnY4!Rg%TML#I*GTlEjg&oe86Q$bW_*N*Io
z$ZHbW??is0laW|_*`6@h-Yt|_FaV4j@*2;pXb_Oq=b|(Ovq9EVkX79fGbV;55`L&Y
zDGvVvu*_bK^M{y4Tc4V-O4qmAOLa}gk{XCcJy6FodX_s!BD%WCdOW^nhObPHMha8$
zl1JIf4|+k{e!I{v>DBf5Zt&;%J+T9lgSnzb4H$5#DqMRgZ{VyA!shV?3Z##>*F4S0
zz@zBCVu`7{C5QFA0RQhrLP45iL9OO|4>vx_=INqUr4WoQwDlR`k(85-?PV^0OH%;8
z#|RVq$pEG~yPc(%^P^mE#HP
zN*L_5>GMnSkR#heMosl)0^3P$#)PEUnJ7n&DAj=|$ek|h9M5sB_2;g1h|}Z^8|U64
z43-XREnEYiC&UxwZ+HfXz*f3EP-8QT1re6z`Q9GUxvsVV{l|{C;`sIE;`*bx4(NfS
zF26we#UBx&P%vaSB!TM?4%CkM3kdnt;Dv(K2k}e&?KX^BQ)cEs_W_k-3jAmFtJr!s
z(t0Wto$uD-N@*e1aX`l(7@75YSrmo7NRy8y2^>UyvW5=W#F};N5t@9#(2E^IVb!+J
zk3>~_D!Ci(;h8wn(m$o7v_6Ee_o~U|xLL~gM>6V(u@J*+MNVj2z6V;z)~IK;y7q4`
zhBXtI+>PWz4hu_YQVXr5o`Q%j^rXGa<%TB&lp;0?E%Uh-bE&G^_fT$!sRLR?bJe}o
zo|zEPxZn{x@Nan?mhH+OT_;Xsj3%*sD525Ejs|Dq9zLqxhwy`thC=eL3}j{8b^Yym
zM%s1uGorTblT&{?o<0U14&iPdMe?G1v9~GE%M;vUwH5kdlpXj`L1B+cD5{5BxMcV?
z?=?RcKZ~9zrogcp$7WJhh3*;QYet!nX;?U;%o0R7wmF1-1RpKa?0{t5R!fS7*g-At
zu0&%Lhh5Hsviy&cqDvmL=)=uz5mUP!HHdyTWLzO9Bi2D`gbN;GkDHHbvk2byew6#;Jp>RevfHAb9_>XXlj
z!a$%h@~VzqVAf?7{-N`LxFTV;;;V1J$|tCt{UoEoVvwhp;a;y+DXbmb^!0Fo7aFi|
zlR=^q=@)BbG-b=$-Vn1$UzixhMm^o+`x<%sz3EKtJg^_zvofu~BlhjYW
zbEsgjOUAnbF<@?uTJA|k*dC@AAN2XPG{e6Xzi)@4t94|Q1g=|U;p~OO;)S0+A#vKQ+RR&l)J+n1dtkJs4
z8L{uVG86K?pzp$0u7$E5HrdRC1sm^)ii;CsgpKwDB7&V1j^8|$y!x`ItCZAa`Z+Hgxr;4^uE{Znw?g7>wo-HEQ~FM{oIhTyD_Gz`i+Nnc4dl
z7dtVkvujFIt>zZh9O*^4PggNF!+effUeM~UnnrI?NWdksQl6)yJ4Xpc8AevjA2J~y
zdl!VlY2x|q)=Twv@9kEpfnd}ud&*^32vth;l)vNXrKduPpA>CLX_jM!=iWNb%kEr=
zs{DlRnBO9I+7S~$oFBx`n@nX{of61W2Slf4<}M>LVFsOYUw>>fD;&*kecLmZKbaox
z?7F!qjFp)lP00Nvbb@5bze}p1N^77~V8v-~chZIb@5VGuLoA<~d4*fjF`w_P`ILE@
z7hU@@^}7U*cD?d=OB4>=%~$w{=%IPjM~W{Xg$VsuV6Q=GJbK%!>~Rt1dgVLFYCf8nuaG|cRNqtgj=(XMDs{MI
zYBQ%Sw!<|FusdV+Ywn&Tf8hNHS)Y!B3V55W5R`ZTrCcl92w$h6;#i2@*;@lCm^L|V
zPp-bxhHV*$(YTBd6);XU^z@SD$NBV+#8DLDZS0cjycYAwf2fx
zUJVyq23>!n1ec&Z4&Ik;VV?16`Fx6E@{m>awG@1
z*WOp@Ys^k&V56{@csg~RK*Ac;%Zj!xo@Qz0_U3X_*l3@S_4VdseEih?ISq+6Aqj%{
zl8W5$t5N(!O!>?`t-_@Ke$l>kZ=L%xTKki0z6X!Q%u(_r-9*$=L;gC@0tubh`>Z!Y
ziASdNO
zFLDp5zNZj+F30E~N)P2NS-1D_?&8xkYbNY)66qe6BCMKFKz=JsLtPR1!z-g?2y=*V
z=gc1As*-W@iP9MF&m!jFVO2^_0NV*|yi-^A$HF7BQ-zLbJftiMVp>MG%KGDe3L&by7!iU48)POSuW
zzbprf;>Pv-1VO*M_r_y_z`f`U(|sjk{0}JKoc$ZGvy+Cvk?uJs&&gMGG@_=fjq!*+
zj-mzg=_iO2lVQfjSR08*9=jG7$8B^O{$&VkZi$`Uu8!uaGU;kkeDui{7i$ZHyQ=Dh
zjI?E-x>+%Wj5&OUz2T|LlWB^H-8^V;EMu&y>MXu865g25+9}#U%G26jG$83N=GGf^
zwqxT@)5(UV_axJM;$BX-oF>
zR#Z_}4GdF(@)RPUmUvMwqd^lYyZIj3Qxa)FZABeMgOk&TyG5_Q$!j&>_i{eH7%z;(
zui`vyd0rg}tex+9aZIS$LqeYNV#MSo_ml)y`T*;+i0zF)Ug#I}=R^yi>}s+T@bf+=
zix|>jW0Tl~oS~7#oc~Z9RMYU$a%C+!UHYCgkHu03ldF2qO*?9-{Ok
z$oO7y4~~8gU;!H_>t9mP(noPhJ`NpzyZD#tYDtx34^j_r(C!zHVe`9>ZIa}0nKAE8
zCA8sB3f4^u&7z~Q;l||Q{4ASvGYj{o4hJJ8=%ZSXeE!(yUTUK37~2Lw81te5L-In#
ziY-5$Tp3_e4u2$LhoDrQPo}*|#CONcM3K?Ndo7OzHWMIzL4#
zJpp!2hxV388`frn5$g;takpghn-wS}4yy+8V!68;hd-CHRwtItG}hRQ!jNk9Y6W^)
zC$yjOCGtW=?<;;mBB7_#{@x`GTZ$0=9MW`cofNTs+_kh{%8ens4poK|1EMN$$nGlx
zg$6YrT;3!?iy)n|Pq(IgIs_#aR__+Qleb~s@Iowb}~a%(++#O>XG>G5amx
zE02X!({}E3k9`CiHm`iFT46LOSP_R|wOd{$|GYpJD4KoL#={sSGJ)!K9SiQ&t5B!S
z)#v-6TPK7R8QCR@&T(9%zVdN>`I9VQpTpmTOPxwM>E4EXNY%YF52CIjH;Xcy`AsnU#Fwu{1XaFT;RBPk&4lPL_G&m?vB
zI-`dKwZRXd2*^O$w>6+mlk%^AU3Db!pA?uy`*Uf6jOLo>_R;v0Exanzh@{HOKE8Hf
zkcnI>FQ$yrwxWmPjCzDPkJEt%HBxRm;2xgQc?pJ&^Ot6hKkRZ#B9paB<|57I^w-nS
z;2uDf@gA3y3z7XN=^Qt=3jI6l%p6$fit$S9N?cO8^u`GfusNCDXY&wMx#`EMBvfNk
z!{nrSY#+qP}nwz1o`ZQHhOcTfL_IWrLxXXdV=DzDZ>MP#mg
zzV{N^JQu$_?H@Zow{g91*pIxnrhjtE3x*f<>Nn_~F_*G8M7B~%3+1*#?oVWpu3>>T
zJJ+ILX{z?X3s5>C;~14n3KIjWDnds2(fPa>!x8)~c&mFNU&|Lv6WtpF&7#99{t2F4
zau4bRsOo}6;3zmVjQAtAWE;C0(}?A=A$hBh9XZ#2PSC03dVnHPpo{=IqlX>!7s``W
zE=lNEg}X4(D^9DX-LieF+)*UQD>TS6nW*cDGE2ZT3?~n>qccLHlRCFtqLWMYT7Juj
zMuwOL5D#Z&Pc_ks673cG2k%iF
znzGSHe+4}R`qngOx7Tp@17SfMSCXxMjO3os+Q0tc7bRu^0U;+vl#L8Uub`P(=nXhF
z^Y&{n&KzpAc-BKLJct+VF-*`FDPkBml1Ai5i7E9e5eM5y%MT>OmlKzwnA&L`rPI?W
zT;%w^fjwpP4@vu!Uc`*Cl(fB#k~@-d8tDC&>9o201OG*z2$TY4<93W!H#7ZVvVD*j
zJH@wYJnbH1{>lAu&%K6u0m*~2R&X%UAEb_6CjaB~ghPB`@#)=UGV$tY@_Z2saL$8g
zT}HXUcGE1Wrl2z!A8GC&%p_YT&W-Arr*QGu%oU84g93D8GPqw9pW@jryC%-64f;~W
z#asvxL>hsnZCl4|dNDs@x5-|eWzB|+P+=0F?^1VtqRwWsRQv_;(W>w~xa{Lems
zU=I^>Yv)pBPif9G7`l+y4%SYfS)(kVaGvTItQA)Er%{Y%#iFJ{JN`VQ&d*;L_^J&!
zZmV{hVR1VLD8>BWzrYxk=jB_-ddn(|Wn-)b*yizJ3gkQNK+NCyc=u_&>NGpa3(o~2Iyn=QNR%K4+^vv~
zYDQG=?ou&)F$wlF8aN-BFcMGra?Wkz&~CSnT2Y=*fatmB(~+a4*dAFpAUOlx&&hL@
z*8;>fEeF>6O&>WJJi%hw58k(r@K-H=ReC7pm=DR_CaSz6vV-9oVb!yiDJj*Qa(G-S
z6(_}5#DIzJ8hEJLaLrT@gNuV)O;&yMBnLz8q@c&E*0ThNChdam;uRu6Fr+3n@r9bm
z5VTOl4jT2Lc-LHIw&3P(su^1hgnd^xvBn2WhOKA{jU+kzOZrfskhh`wK$-tiO5I8X
zbFCjXNJUbX9OtG1qP7Y|g;QO|aoL@OYAM*^0KQ1YE`|NY6z)BsV0vy)Vqm7^9suW!
zX=8&N8e;QqUjrY|e(Io`Rg0!`)FCiMk_uF*iGLDzBVByh@8K(y;GQt$2pIBL9|Z!T
z_Srkoaeg)Ky=d(xlD|himTq%uSQm`tj2_TE$NGXMQdk9Kv!|627-Qy!5dM|`Bc7jL
z?T+GbJ<}?F<~oL3F`L6Es;U7Hc?>OEv@KKoYn`@lWjg{0=_zYWjish2O1HLcm39OZ
zZo>Pgf-A(iqkK>wz?6I!`P~0893LC;T;!=*0?ntj8{`&~BxLGTJPf
zL<16i8VsIMRj0)3r1^9cYxjA)Hd(umG&XqsCU0ge*Kl>0Y9MKnk|gO;(?8KW!d29e
zP00<8atRq~yoqWILMKFJi+Kv3+c7f9aJ*Q5S#%$XXdc87MfMBHu@J
zA!O3b4q4~)LTRzo;Jrp*>;
z3gP0dvWojDCE#O!G@~POu;7J?9*^$f=p@wQL!DqSZ>5C4b=a^z%30WS5H^PKP&G~%deKL
zYfy*@{UvIgG7-wh{_u4Qn>lP)nzb8QeQ0+@=&Y`-+1H%L>|d2=9X(`j?|u9ehsn-p
zAew?5aX&IAhwKxj``H&P`}A(uI;js&A-hwG21S*qdS`$z5wxg*pE9${vN}$X!zJ;;
zAQ14MW2xXy`G=!bxV(`YCN_tVNy{Qb%_`Hje0aLvk64RHF>RIxf!aCf@hq46*BxzD
zg_W^**)uqiHM1Px!qzn5*S8gCN9V{NOmouMuW96p;WC~eJ&qeTQiM2)+M#cI6gnUT
zSmLHY_c2FA+NAx>IAo_(@T>y*2X&d;b~_8SX#1%PpI#HR+8(7BkM5y*f-RmuMl5Qm
zZ7`&5@^NhkqQ$}Y^3Z#a29DAe5$n_I+6pTVOaF9?O-hUV6DB1EL(tp$o
z^PLrX@?`QpDHo!dmki+|1b~LuUcm%vieC`cMKXP9U~0DLsxt;2V+jAp4vEkOnCua_
zl}(0Q@3fV|vIa$2`$;b44Qp6*Ox4|4sdE+b-TP4p?01Ya@%5=glpbGc8l$Yz!8vH!&^usmP(}g@
z4+Ku47MZjrZogPx`hCu@O#+sy13QEo+ar=0*W{S0E=0-I)iLIXOZ9&2v0iYhz#^Ab
z-rtLY`s4jtg3qu25Z?s6tCS4wrx=@b5Wl<2zE&^m;vDPO^;8|`>bQA?l9t3J#AZ2h
zMnNTx;Isks%*2C4k}E}myFqR-`~+>f2TkQ!J3J5fhy@-$S$5R!BCR*U=H0Mw*HZ7y
z&A3``ddX6WLLiCu{vA~;`3?ibd@0weE_WLRrF-L(o@CG>Rn)u5>4^0HIghrmp&EUq
z6?!N-CigbHgi4g^6SF>SBCl675PR|G
zq+?wNbalDMotKPjSwyidJo79f@vu_kBcM4W+@vTzWsv-7*cyd&5n8X8->?F?(79BE
zGat4gIjebHJ=>~Kyu3c!IP*%Zu3qb`-ail|UghU+vIdC0dc@E%p$l>>(=z`PD5nFm
zF=aGK$1aSD0LM6+T28~us#uqCEDv|VKp`kF)sGT5J&Soarx4r)O#`?&WE6#QFu+md
z$=>TZm<%WxmML6PBZUvJs!YoO@%Rw|Oip1Q&7lX}F54g<@Z*LG;*nEw5(X#UeY4=^mZ;9r6Rd#O
z%7Xe6-YtNsx2eplaIV-e+kLI%>D$6?`?!xb@;6P0%-8-hXK>O6JVw*F*}qi?T6OLf
zSSo~?*#
zNY4a39QN7%f?(fYl>SGonqiMct4xxE0RfvZ
zl4IY&!!|$~>;|4Lc3Cr^pkJ`M7{;77JR~<9q{N(**H!eHacsIh!4e)hdGIs|^I8B%
z;g!gfG(>h9-SW_yO5Tv4{+N~FB~{i1c;h09z|=0vd|l3|sYr6*j>kze)7n)jX4a#_
z!&Pz4om=J_>y4mGn8&l!dCRmYnrT?+Bk`~8E7k)7nmHV^1gE<7eP?zi*+X1wVc~kz
zKCnaBhZYqyVh%A2)^IAX)?yjaeZ>1Tdsb;Bb8v4SV_J=!z7%6VL-$bO?E%{OqTY3W
zGVa_eN{V>B{&VTs;o)61aQa2N{PPS0sXf?vxP6_Z(-|@%ez+M4b4)*bTzZkdfZO_!
zZ`^wfp~b7spO+8+!RCXyx~XXUixi4V{Wni}5P$~!<+XS4qSOOL`}sJ2Ym}}-5;vvr
zy3*Sa^LOf%^IiPJ(S*`CfNDL~v67r?$CHZB^
zr3=XUw}Bng9{l5G0VlQ16ZeVbn=xbm8msHdg}CJ|Ji&d*39$B@wf^xxlSrs9s;Gzu
zyT@0PY%q$ZPXL!4uWnXH>do_8S;>SYc^OBiRR@W{E%y7-EsmugNK`ba3=+~Kr-0n+
zrg6eGE;cj&v?PtEF@)&GsJ#9=EUw?`Cj3=^G?8jGD2zF$@2QHCrS~a3=brpXXDN39N4?wWqz?yt1
zhf`fPysnn>z}5g&E|lxMx`f02$jH*xqF4T8cW$fTZX_0BV4ecI+;GsGd@qJw6J<>Y
z`9b2@^*oI}GEXA8YbF;VHP8c?CPp(CDSldgU$aUkGWMj
zT;$J`o^%xJ(+b#tYN_zm%&4G=1BMx8kyN`otV8k)G>IA|_rA?xJ}H6tAlyV*UWx~|kbbAAtEF!v4dV|N@MYG}q9@oSWcb(toGVp{<#c-Qs2eN-zb?65zQ
z5uguljo8BdQ#gCzsUc#VBG(T-iRff@@nUWDG)u53MN@U>v>)5OdElXWZJDw_xVCo(
zn|kP^MCK;&;7m`jFNA>edZrTg0Sh1ml29BMA7N2eQnJ=8hdh+tKE1{i%{LeW9x)+8&t%@xYlIWe_3RCu~{BBdpt5$8s=0EyLuM)9GDbAm|#>G)IwNL
zKla*rj<3E2GTxa@Kjl)SW}LA3Q~3miPK3?-+(L}LRW5)P_T`H<^+eP!Bjw7);L}|T
zqkgaV!eAMc3`b_f^}u&@IH^45xvhuVP=p`(dUOwDGG#89nZ&|>f?n#W-t~mE4DO8@
zVhY5~z+}+4R7W9Z_Z2n6&Yt8nC3=as%(cYPVS*QETvN;S7TsgB$Dx&{C7_r-%U(`n
z*t}gDodlhWR^-IRK&kT{f^;132m=#YJ)i2ON#ltT(-jb6&)+oBE=WcHLTg%K9-3R^G$BFxfh6#zFTWqdk$B72iY^FHK`(1MuAtl_s?~YPLdewP#s=h{{S7
zFD*9!%XM+%3?~eJ$*L{&s!H=@bXlC%?zKK38h&VU*BN)bPacUTs)Rqb(vca59
zv>?@bSxE-SVgTeH^+~3*;oIPBLezH7UO6JTPzm
zTHs6xZn5^n0l4HgbEw~Sxk@;*DNRZ$+Nr*qwm(t?NTBx6c07~_r>5iLFy<3y^`e|$
zl6-A+eY@SAwE{RrNQd=AlUme7EpqqOfCqAWDB
z_Z2H;nA1ka-T58F8lTI1lw=Wq&f$LfWUR(vSpmFDI%ei*xAqC1cNeHyov8!R9ieTT
zZH4cW4N@i)gX@&vedhTn7Z__;RAi!@eYI@bHeuAct8o!BU(eX_7PdvzM5<6LK{Dk%
zf|E5U3o|e?B)TG>&5$wCX+E{Qu#YO`&YD;JUBMqo4v8NApt^$KL-%~zZy&(*N)WUU
z`_uMsw*Wie*uR>)L&0kg51ANsu5atFy?R6mZU8lni+N8AUNsIddf!$3z|h4NhSCg_
zK)wF37;n5>Z8XrCFyv-vhN%RhwsIU?4~h{rv6w}e$OU9U?z^Cwt=;g%?Q;MdV03Nm
z)ngslRf$(Ku))5Af57P~>CsA_JMlbp=E%W2AIloCUPkmphUy+*DBub(VN+kd~
zaHB5P|iXnw|%!-t8u7tLeSX3M9<*VB{HzgEvcPbdkwZOy!n$+
zB}VBl2YLg3b1&Zmt7sONZ`9wG!%2J^HD3`l>$Io#LFtdColmhy&0IJt7oh<089MzJbyRpIZGns*)ksy_*q
zxYS7&1llZG&WmzEHkdqwoXu^bQ0K;2YI;Dy4wC6=tOET=*v=pa3D2(vUe0TL08QaF
ztlC6yslwgrZDRadjL%m&Qn4{`7!~`qJEc13W38MH7Ieh5ziQ_3=K|_gDj^6*MkXel
zQqL}yd=rqYMGR?Ecsa|Wu(2|iGJ8PJ9|mbpt@%zyj9}e{zlr>Z?j%tYbm3pR
z{_|0Qk3VI}d&a5Ngm<%d#rK|eilay0`#{mnFj>!jjY|4E;7+&~(#O`lIOtuZT4e5~
zYuA;dI$F{&0#qy@8_3U~Mpgo6JG}j9xa8LMyH^w#XouiWy*2fctmZsisIly?ZQrh6
zBe;r00V=liHl<~;G
z)W?~rSnO!qx5IWHGtUr|C!r)O!N;uKLz|PRy|dkNCD<*}Ty3y9tYkh8U&5hQq_&ah
zN<1a@nJK!<4LdL{wB%dCdR*F6tvYKIYv@b&;XJ~E2aC67W4bQG-i|7oBei%KeK|7;
z(M4Zk0K_Uy)1mk%86x$z@GBwPq*@##_VvXt4HCp?0kS3LJ7Vy@5s1j&sENHLWL08(
zN5wDlA?>*!$b^bh*=J`{{^}Dg-V8DsKWDxiH5wWQxf8RyWAa_1@>rJM0eW`lIRwBh
zfUH~~yS2oWO0rg+E*D99kcZL<^m+4+=&^C6?=
z`axql(fYKtZqP9O!^>#khFv^&!4+2>G62>!^YFepPuY|d$2?{R%(UBU}DQ{97=<
z=ts*vHB5tzH$Ap2o!?%_Ryj5J2<8P&ai{zb!59nd-@-Lczw{0i9rf6ml-7(OsFUxS
zW2e>6*^@jVbd^Bt6Z*F{^w4Wcd=f;j((tU^o+H&g5h?i#%I{nJM%?*1Fe1iCo(V@V
z4n&#&%2oT`7c~R+vTK3dT{s>)e4;f7HXmA9?P!1Wk82u{zkD~hi^Baa;J3fM@zN48!r(F_=zfla<5x|Y6m6h`(u5MVf*0%q
zp*w=a)di{7K2&Tj*ncqex@xqBup55Y1P1<m^y6@ZV=qs0abJb-0F8J
z=Wr1gE)E;=`!!#+vKsP?!+C&IY?@sfkfCT2Vw<(!f#gC}_cLlvG?WJ)r_u19nB7sI@eK3x+`c)gHpz0#YrtZQF
z7lY2$iXH12?|5U2mMj0
zo~XIJg!gSFH0_gp72AR|Q{gXGCeNGy2$RFw=JI3ce%H}}Y}aFiJrj73?v?;#E)7~<
z2t#6-*uR=54TZ?&3vGxthd&A0TkGsM7R73`uYQ|l)GTL>%roer42!o5d}XQ6#I{oh
zP|E+h9MSWsD?qHeCr$sh?An&xs31FWLWmAezm|*nKfxZ5Gqaa_V}r6YNr{Yfn>lmM
zV-mF{6j%Rh`3^C0aGfpQOyl7y^qWBa?L#E4zAjalLd?r_Cv%KV+`~{MPgd=KeQcZ%
z*GF!oOnX00(X=GrOD?(d2*3I1m5@CD4|^s7e|ew&8>rz#>7
z!++yZ#$PS@|6fJ??E(HjR1rCTm;KKuA~WOv9z_)X?;PTP2-5#bA^wLRHE_^3v@~}5
z&$!`#fBvt$p&|W$u~I`@Yis@g#HIgPX#9^_qOG&T|D~5`>|kzd^xxd{|7#<<(|Z^@
z*#2*M#Q#91|EoG>X82zo@c&e&tW5utnf|I%4i<)Ajr(6e{%`7(lY{O5Rh>rtr#f8+
zjo80N%L)O3zQ+3{r{@2`PPevrTftmIcY}8OkTz{^yrF*0Z_&6~cb
z!MOe*(*)^Z`OKqI%hPBCM+UHZ2EX+=M`n9FW+tFCOw6`#Q?rv_zsl&;!~i%t4_tU@
z~#;d)eJx>+Dd-_cScMPQ&&?Bzx=8(-H?!F85aUyVO3#hOJU-;
zzMXJvpg|B+z>vK6Z_Vt)x`N=Y2IQ{9;3r*FrcY5|i~7>4@Y?KX*xBVZ$i13R5gHu-
z;k;^3hEHAr2GC@H$2tbkfNq4&EEsKn0MkF{d9f?G
z5x&GAWMqEf!F9~N5N0O&k++$+B){YoJdo_hY!7bM1cVk3+3&7qhF`WlZ;Pp}q3QY6
z`uoKWGs#G#2qfA3o9-1qIW8`nyEif>7*}9qau`C-;7||bcZPx2_td@Y*H6WlZCOD6
zkgucR=M;sxr3LuzyDVhh_E!ze%Fi{(l5Z?D>+TNX;iZ5l42ay9jwh}do0#D&e(}%D
z#81n_Pfzww`L+V-OeUOaB9V&uTiZAZM(yF@bF#Hn5IsiHM{}iV|J;(nkPCq3d@dx34{I&MAEd0!90o9Y{3wY$9ikx{{kcg5`>^dL}C7<7QOaHO%iXCWZ;T7E8-+}QHye@zUgUjD#uz&2l1#-0S
zlpUz4cXV!c6$--RcTVk3O2a4d&rIFxAHed_S9YKybE`eGO9Mj-*o>W@L90BBVVC7R
z?Kkq|9vH!u{hPyY4I;2aUxHIAJ%+l5W;UnK0iYzDTXxD(pw}9$)t`CpRzI12eww^S
zK}jQPvj=eKQt09y!qJgO_}A3=eRx9z|22Gsq~^C9A^}H+ms)o4^>2N^gs(GriTQhY
zh>XxBe1t{x3x0yqR9}*D5Q|Y;6EuXns>tX$UG%gye83;7-fLG00;pN;Pk7c+f{z^w
zgd*NkQHzh7y?UlE)%TmZ`T&O(aN5Z1F?^>yAC6Bv_OQ*qq3PdlsnHj`7~1kqgl}TK
z-IwZvEh94W=s~PJvwyksdp2aLwajve%&{+qU&6-~TzfWV))cP4uN8Qyf+>3kKaKzn
zov(o0h4znMUgPHXDo|X@2R?$x%^f&M^3@yr=Ss546u~U6
zSyXMimFXn1)f&d8vo5{(u2>8IREt1&O^%H8Nz?i2)qNOHrjT|jZtImBbsEz%sP#by
z#Zq)H)>!09?6b*gZ4AlKH2IC`7f4atmrPJi1IGaK5I;y}NZ2mqnGy(Gr!G$C5>O?<
zMxSTV=mV}6hdc@t&{k#$)e5I*9T`DzhjF7?Tofl`4p&^X!{bd*Di-I!k1
zS=cV0fmV9~-S#G(-r-bdyg2DB!E4rVZIYY$6~hQ0jk}FX1q1ifo_Fs;KWRW`Us_hd
zEfSYRvPa9lvQGUKM|yM60`JolS^C&}*tnyv%-QzcYbqY-8w@)t9vv`AijmTzOQ^^{
zX-sn>7|ZFSkj3VXL;4sOVsec)kw|uT%NQ|~uRiLAw&F({a+jRIBzh?GZ%*?mYgWE#
zjO(dJ?}TcFc$&Zry|$7A<#vW1gq&BlX)kI`ai&^$M-ms@DtD6IHuADfWE2dP;hcmW
zBPIx+XsIEJ9Z3Z)Olw3Zw5r$lBE()d>PMmVlHF0v3B#79WeAz%txXn)r3zSIe1ZZM
zMp=sNIb^Xv&Y|K%MGEiN@j@FXBGSZlxI+(HV3!jkuAiZ~B=sF*{bXZD23+nOl+o48
zyMy`+hK*nf?+H<2QZ8{%G&1~)joL0+BbvL|{{U?hv+p&*Te?BRbG93=#`KRkjPjfxC43j}|b{qNW4SZ~HyE
z`LeT0`&2>2iEqfxn_6H)9Oy!v?-eGNAA?0geNKV{Yu7>|C{NOPq@)R?M5^xM+4bj_
z6mo{SNSfs#n6eG3bT9MBBwpg9M-?b=xtR=etQ$?3BGWffJJR{4McP)W8vn>B0$V=4
zpH_%VEoT9hup`Q*?6s!xvn
zVux*(ceSK+rQIG7Y`oXKwZ0Iz1iR(iU9
zMW!1WIhIN%-f$rIaoF4v>wIzLR|Mt8I&D4+yXt1FrD4Qtu=w8X-vTR83U9(fGAHyX
zUH4yZQ(}lt8Sz|i+Nc+)Dfv4W*NrEEVcR0wd-Pa_@uqK(*Fc_ch@T&`P(Ok!>!AOo
z#u2?)?YP%Q#iqEOlDM0iu=b&Z7hk;y8L+9&atuO6nUNPxeY4c&!*O?6SYJ@oaEY(R
zt)gWaJt3&3DiAB=^_c1qB2R~Inyto0XjC3;^}M20v3|D|!`VOpe{^Yh8!P|CFnkral1=yLOU2jywQoFRqVv)BtcpPOI{d--`9@5<+K<
z+b7J`P?By%@ONhdHv_-YXzW1Q%s$7L%hAw$9!l1v!nNi2b%Z~JRds_GFy~w-`w56I
zCjGGwN%mLhg7ihE{d!D(%wj5k?)p4mhF444!5Wg4&qTltqbSv5`AF
z%f`5?spapP;)+cn5y>D+c|-5h;3$EuXIib{1M~HCo9SGiPQs{`I2YiI1EM)tML@
z8|h$m1j&qcaRE7%!S;%Alp1@fqOXn36#^zsq-BavrGj35GDjkTMNr>0o)?GeJ+Qya
zUIb@Jm$Ws-CJw;5d2rW+5*j8HG$g3W?8PsuN<1R*;;R-2(kqD0$Z
z(W9**A$&xdAuEZ%sj@qk;dVl3h*Xn-e;k?tVqyQ5V-&l(J9^;={sd#7dvBgl<^tT;
zU|!kA`l(ka_jv3`7eJ%HPtWC}BWZjiuxuT@Zx%dTIcd*=#P&hv-#6OKn}ttEcvLPg
z#dm{Sb=pTQI%qHc11(RU4i&m%CNdMW$|-{nM<3v6?XJ>fH+;v-g|7)&v25TR4|?P1
zEz@dWSA(LzQN)p|NX>60v2JXkO5ZDr2x`
zJe`TEP91bb;qZtq%P8?M9Sxr4T>_fFPRCsLO&_6;Go~!X%PXGO;gD{i;5c8-UL9^y
zqXT_himC|l@+wsv7R8U2=rN*{;aOBtG`uqc-2^BCoxy-nB
z+x#wMRR1ERM_0lH?4fNq9+IOj+p&*UQ9&7G`nhHY)6tq2f5NoNHU7IF&iVT1ds3n`
z$iQVkVxCs`%pf6S-f}EaJdPu&;jLjJYBXIuitnl{_tzUC-9U^``F1a>5C(e7*FM0-
z)M!gV9X-<^>r81<-{t<`bZq2_F?uq#&K@m!S-&Sq`Y3^Mp%bSOV()^25LC=XD(~95
zDtx_DXS5Jpv>Li^CxmG)RXuw}ndLxk$KJTx{Ixa%7&X4~9SS=03i>ZjSi*@RcJ#($|xypVA)U
zH<;-6DPHzCni{!3v&DQ&16F;5Oi&{h>KSv=6Y-otnbP~>$et2*QlO$^Ds`*k>qC;!
zs?Bl>C&=O=8l-YNK&f|3<$bqz2!qO!;ZNA9y+{w7P9bQQ@U4ZtN%H1wz>HY+3Udh7
z$i|^8jn-CT20qT+AtR+{UY}c8Q_KdxABorGl6r5aC-anDWRHDA--d=n-G*;_GD9WuEfhCv*JOXgX|R^oku
zL2j&<|MqP!uof2!-M?XBmD9eIM$NUM@qy&1Dt+xiWc{|^L-qtz-%A@$EE=^r>|a&W
zY1n9+-y{sVk~S1!kZ-9>#g8ApWPGt&w5oFW6hWPOXk#Ffnu4^%XRn6cGPlJ2shgFa6>S998Hu>h_ARDd(kp$TrMZD
z26554?n~TWV`N!2F{?YAC?e)t;EI@(>Gnbz)8sO(zWY`>NZN4QE8ysfXxiwgb$gZh
zlWaYgH_&q4-Kudn7HJTJxo(ju7IyQ`nB4kOD^~$6XM&SN=nixt#jeBOafMZ9$JFw{
z@O24|>@dRY3e`qAp}Df;0YQ4o!JS06qvb>K6?%+mIT$SkU4+L3JKjjfn4d7rW*)8%
zE0ylW6Q6kZgCsAgK;Y(q7jN0HNvh2d`)@8Yf3C2TDBsyt?nT*-U>Q`o{bD=yJ5b$D
zZlr{C22-s+HDfBFx`}mk9t-_Clt5TMor#2kUZ$IC;jAAW3vt(M9bB73IgW8}2I{-?
zai1#9HfrbSF2SM2PmGj6(*O=Iiw3pKJ{t6I*WRw!mY(L3iOhu2U(w5ZS}&_UH&%lU
zTzVgQ{6N|70tV+qXSH~#B|0Lvu%N5e{lJv(8h{V3N|#R%gLrLfq^*6ptcYJcmDZcu
z@YS25b~cJ7VqpVEg+`=6ZClWwoqV-ZYJ``^ypBFOLdOw>4f1BePLiA^M}&mc%X9S+
zmDxXmxxy#_Iro}_peI-gBvS*DLiXFMov)#Zy%BHlux{hg#uC36irR~*w@Pyr>-{pX
zzMar@-v4i`mX-;x}Mex!~QSw02gqSXSlyCyJd
zLRpgO;Grw8!CrKD~Xj8fksy9rQG}I^jyZRCbp_dePsF!9!(axec^9wId$JV}^QCmjT_1=!<XZq8+4)texJW
zhvY!l+6%x%rg_~+ewKa_T?=HgjNu#UT-w}XJ}5J8T224AtvZdr&N@&Gi&PV;)2kK|
zXK`y$`!~6s9*n3gg2;m;zCOXz+dmMHxO7i6-rX6eu%b(fW*Y}&QEi)G7{<5-ezl7?
zXJ|EIJO64HqN?24=DV#@xprwJ`??Na#l-}nj`?}B6{GF(h41!CQeOw$&2f7Co!K?E
z1xTIcSm1+OEK6yiY``zQcLb`Zt?44_nX=3fBcis7mJq)rUw5;#=mcSc{Qx=EI~`0|
zR$yz*_KP{6OubJ}H>FTyG$bSJT~c<6MP2Fk!)WK7N!;MwWM4Qj=SDJD9K>a5s5r|v
z&-_ayMqvUUq^O+IrpMhU7G?Y6&86^zN0=sBNEsdW_iCfEa&ZP|2%{DjaXqfHzTTQh
zX~o@erMhWR%-gef{u#5e+v+jHg3m!HU4vr2CQWb5tHCx8|8t4D>lM@qqPw3BNkquvBB=o^wgg-PI`m9dTrwg`S<~d;sp41D*N88eu(XMM6dv
z^-4#>l1wtuKMa`6t^rNqC?B~k)g=_z&I4XbyK^6}+#i0yeeC7&j}5q8rn-|)XXKnXLWV@dbafWC16oUvrZRSfbIS6CDbV>>cuyb>L)Ksw6)&Ku
zSiaApkK4o7D_Z{8aa%Lb=8`EHsB1Ot*xUL?Dw_jnK4ts8qk83n&TS}<-HONk
z;{5jZOR&J;@7o;LPK3@Dhd&@4zcbHe4e
zBpa`kvbqgN62~6-;TtHr7>f#x*ftv#clA0V!;L!LCrSZ4lzd
zWTl}Iy1`9kOJReh(Y6Rb6z+x+f=w$Snhn-M%u?pU@m)9jl@qyd5#e@o@Zwv)(y3HA%Z2e$Y;c9F2c>-)^atbPl$
z)~EqWnmS?eX2UzP@&p>(d~SPK6;2(ogUc=l!&8Kq2^Z_Qk-&_<`JBGt9kK?
zTX+gfwYOw<;eYpJHK!^HU1y~37J|7}d
z)*tG0=YdsdRK6fU31aP-M`^Rj(sTK=Lp1RTN~)at!x?-x)iKNtJudFF-$7nbzoU9d
z)iFh`sBpR5SvC*#LHvCgbTfb27fu{Ttbj8A^6fTE_tJe>`hl9;_)1X+VIzN
za<(eGb+c9;^ELyLWk&BFdoe;vyabD^dce(o$|dDyfc%)QHiLF>Xu{yBVW8tu)$Ku>
zMx>m}Vzl9SExLWfYTYYa4~x~T{W%V0G%AXewaY3QvWpJcm|jEh1U931?ejV%J9jJ(
zUrwli&=s|ujn;9qglMdW(<3hW#9&B<>9W;OWm`WD2Q2pBviHT$gNbOZ7K7>t@q|s1fLny5JBs9Wz^K9L>9<2Mz_j6vuh9WBCuSH$3z>AqgH`~1=1B)3;JZ_=&9!9
zl)p8y{B-}V%)QYCS2+7NyS{{b0eTl^8MV|0d~y|i$L8Lo{3)M{42S4y%t*drFZ!T&
zR)SzkqTg*y)(cneOYhw-ywg?sIGRaCZb{=HZXX(@b!EcqI#!#htC_0me&|TtMYG`z
zH@(~^;0kaFb)ubD>i3FA0}ywnW6m&OuHjX|$GTeDVyS*y57e7?TB-iRHJo}gBTM;~
ztHJh;F-i*Rpv+e<*RG(y3e8y2hkgc+Kn&yL;C9ny{p%b)q`~x+{|>($(;xFPIzsf#
zp`1oY+vj9=+fa2cSfSo`2(YRa$XS+5g06{_Y(K6qJ$Zzs>;ZrLk=5BG#XgXY`)!E3
zi39pf&0#7An?8KBMqco@66OKzjf$bHFTKWmfnoU9fZ!%rO(Wg7y7Twy;hy}_>*wwP
z=f%_27Nf$zrv8HK_OAT0xms8A2!g*xGt&2IHuUPvXBj((A$DAt&0l(N4dsqGftW9g
zU+PjcPwopvq3eG$_3;fUF5#$qOuFCYbOBH$W~jE|wEC^zT2ez9_T`
zLqO*^Sc}@G;ba0g=O|wuj`y**9;+WOUHqcNga>&QP+O>|>y$3M7NyB3XTcg$q?ft&
z*qnH%V=lU;N`F`xa|nF=Aj^76Pr)z(QSdekp`3H@J)C3_t=l+R*BU#lL4_Fk9jMYI
zq1~d2(h7QvfTv~MCYBym&qzpdn-?Eyc^2^vz^BdB6eLQmi(Db9wTbQdmzdq~&|LZr
zE>88z9?0?@5vahOv*?oKwD;2h0D~S6o;-8T#58NQ*~{Mim+a=PqQp=>`3Y9sUbScC
zpE4tAlDWb&2mK?k`6J%_OJ@&~r)(Wp`}m7Rrgj=PVgH2f{%c*!o4N3PHQDxn0N0f@
zz@M${f~-%Pfoh<}lwYAEerk}~IR+2q=QusN=u;EZAXY|;63)#Feqr4>KIj)h(ANsj
zFNaGy#TAXP7tIp%TTnpa6&Lj~$I<1C8D2AO5$!Z{{p+?HgY7{+WYuR=Iea6jOMhPx
z(4S}_+n#tY>{uDE^OuL@?;Z%g(hdAfM4=Kihi5E~N2ffc(&TXprBksmrZy4RUMRW3
zq$PAEpL9!5G~!lvq4;fHiWY
zdxWhHif55Uwk=%eg|1yT*_)ybQ1b05`T{2Oa5|L@aWLv-`}>us2VZc-4d}H2qvo3K
ztPhBY60(uh6MN>nJS4OB;C)DivrbgLqn#ds&gmo`FK;Aev1z6ObI^ry+~nyJ*SLR>O)>{r1vWG!QpXDYiQVKPdx9Hr0jjA!&3P26gKiR#C{J3qF_`1yw&JfsqX*xn5Wz>lsp;zufu^KoUo$48zw8utu<)Y
zr&UO1D&4hzHSRapDG-U(RWjwdKrceTdpeDxUsH%2G%1^pFg}Cgwm9c>U
zHYcszA6hTU#+EG8-8xU>5$6(fEg!queP3HU+H00nFlZx(sUKzywHzDC{+J*b^UI*V
zX_b6DT}$Nd%{4iFDSicY;MKGCxY*F#nN|u$0w}3|GkY_g+$>%_hc66^@CLTv@&~Uw
z`c3R4;Se&|MZ#$!8Wq5|)^nKx1R;!MGTh%twF!sj{hoeMB(
zjdpd$!UJ_jJwd{59Sx*!YDX)%$mwsqoTxP0j8(2QVoyLvZ4ll_mbSvpKvd~9!XWi8
z8;KHqQeki(F!LHrB^^|#J+XsNa->P=BU$k8WrHJ#{tGZ=E~F5fxg1}*#($#K{+p$N
zo33Njn?K#Vd{H(LF}>x2M(I^pJxJYwpes5ND>n
zpewv4rOJ*ufG|jgWon
za@;wZcP;rd22yefGn_Ohkh3V@o@adkOIEVRC&7gF<6aW@@5U4nvsFn*xAS!nhZUEQ
zmApW9iOJdGK!(_5slqcI*IH`(QqaD?<6R|r_`O1zVn!d{C;n64+FvAUt#g!UDdUE7
zb98MGOBdtx4E}>$C)>PXB8tKeAr93btX?*RFWq@{U(91D=*g6RIYsrKfx`~;hBwVK!pyEuYeWW?C4tH`5kkXNg5Q-`1kC@R>~=4~q?eZV)Ge))a~jWCM;3(!tcjd>Q9p0)$pZ6@&5JI_i!
z_4aPKawi)|4>V#n;j0oo0}TIgtg}
zRu_lkxL-?N_H6Tun-X65&H^d||1tZh-F5~pq=2U$V3!;3gwC??
z9BtW`QQnej$`Kq{sL@%(q45wcRvkqy<{J(FnyFUl$*G)hQm=+N$i&nn>0JVzg(76p2Qr
z`I^*6tXTL)kkb*whJ}Rt?r$uXBNLG&imOYb2e#tI=UvDQ*67Tdu$-Oxnh1Rj@3rna
z#!G!?aF1-+XonNeWz%7<9?azjoRn1r++bpgnh}?QBao-K9h`-}X@vf!e2>-5F4sUHHMpZsn6%
zxeg=n8{1)*i3At|gkMEa6%h1tC&gau~tsNwABqgte4xoK6(QC>D*5I*OAPB+bMD#nJD?F9Gf*hO(Hvisi<2L%a6
zcD6z0Z_?%#9{29`)r*8s>@0tZ#5|^$RySE7!;!P;D~}q^I(SRVz%+Q$(Ao|XjvqD=
zAjwe{9NU@&8MuGXAb~2aU)hq?TC$P`&%U({g(;LFH|<83rNPQ0uxUz(N0H|{
z=ND6<>pS?DmtKE~O6S^8c==0i3)+Q?s2Po@yAZN_;D0+yaFq+wMJl_y^N!GqGD6Lg
z<)<45QN49yEMzjtDOrjL#AdBr;)7w)k1F18&TuRzp++N1toVJ3n9qf`rNg@V)x)Jf
ztRgeK`2B4{Y7xgLBTx+wAmG#%r3L;M2_jOyVqKq)L%LmJZA1=W5N?cl3ONRqegy4s
zoLDq(pp)!bs|OWuy6TH)>1FnMYerVpd(CDeq(lT*c1(nI)t3!4oKZe^mzTHZ>j@S%
z{C4u}jxs3oC(QpAPOf4bz#O1jrpi~Y*~9ZJAw*5{?6KMMwqWTcfBvIA)8PlBZ0?D+
z@X1p~RA6urMnv9c-i0gF5e`$59+=qZ3A(8Agxh0~7`7Qm;e5`&zJj6#QNi&gUwwvb
z!5&RQ!Ce_sBK%0L5DffMt=PQs?iwhhul@mt*piVpO~BM==o#~HwBL`@P$%zfK3Y+D
ze2B16?nwo%zTLmiv4G
zg7lfE>U~X@<@D3Vn-_Kt^bqdQ=3&-*kuLeUjzx$<*vHv%u}&{m2nB)pyllJN&Ze2-
zT{+Q)tb$M0>q0NIpmA$3
z&>W1HZvFUMq=-W9P7V?Kj`>gga_7(~AvGzij}mY1WGU9TY!E3`e-pU&HU@jB=oZWq1u{*F`_3p2;_?rD;_B8mbW*Nd+KCh^m3h}DWq9t5MEPL+~`TnY^
zXq9aa5dxaqob+Tv#UXQ4sp?8msXj3+nMy}tlI?j}+7HbOm$Ih3A^(*uJc_NWgnwYAA6#odSWkYbxyue~jWC$>yHVXIQA1maw
zvgCC|d5hM#KS{)kbp^acZuP&}8>+>o`{7{1J#@tJFyLeP4#Sq(S~BwF#k&S#|32ei
zVf!^){WdnSK)K@q_d~5#ad6Ygv<-IS{v;9lkV#&)&$9#kE7LGeD$#gSlZOTx?g-BuwCl}d4`dfii4^P>zxrM>v?5cF+Z5;8EFPv{
zXF3|;3iLhH`tas0D&2&U&mM8?{;CyAt4wfcV;(F@!FDH)Lm2|17IlaQ{KIm&(=^#ZAsJ@SFn1Z{G*;k4`!&>NR4dUy|E-=rEr5#N5E
z{aVV;09X3JJ~R(R_hri4sq`g{eBLey-YSpzh%l7!cVDdL{Prw7o-YHLs1^}Z!;ev)
zg^;XFFnO9Vgz6iRPbG;9Zk^o+W=A%|joNQWX|FtGu0m(9nVwDQKp+GcN}ZaPiU{85
z!bP3wu-LyaviSDE)$SxVE
z$}QtTX@i(Jp`u$dpeHk2_8MhYg8$>ug3*D?BdP0b-ZwN*ZOcu*VjN0!;rp%etvqP+
z91g>V!VPs<>?MPV*Am!zljTc$qsWEzxvSQK#wYbHOGq?tnSgdf+SYm}z&L1UeiO(*
zQ1M(z%#(7O2D5|$L6tp&Qrv`GRac)!{HhqTQOGIL;56kTnVsQDhS_gri|g&{FENC#
zje$n`p-U#a8ZL{qKZYLz@IGeM(a9Q|ji_}8M&wKQYb
z1Dw|#0F{;?0>&ws6^m7=@=j(*VYPq)czNt18{$%zX2AfIJ@*a1?AYEDscu>L99KOw
zc^)~m46itaa;wK&VD@?`bl*7(_@F@-_;3V#@M_&1g2j=lWvd00Pgu=`
zQ8@kN$`*OBUP}FvDufKO!0xO)$#z)EO29^~TaI4;Vc0(HY!~CvL;el&KC!6XR
z`DU0*qnViM*u~U(KTf;#Nc(8*#B+NA8Q;y5-aJznM&#e=huW`m5=N9r!S4*a6f%(RIb9vqcZ_7U
z(7{x6UB|}6>fj6}a$)@m3Rqn-;=O6^3s*aT%Zz}Ldg>%9%O
z&~mq?S904||M-0zD!KHDZ&9Ydcy`%8CKrKQY*e6L@=>uCy$?23A>g;-Fd?Z;MBB(<
z<@hpxy#20LOl+!Ow(-?ecKbntm*tKGz^Oh=;$6xhr~cC80N&x$4>E(wjz;ZmdP%~4
znt8t&@u7yfREsw1$s6a(QRpaB&GV+`W)R+|pok&_IPCWCe6HV&s0YrJo;d{6weQP`
zKJ7TIOnJ;7>B5hu&2-!H
zVDIvT&@MRiT2%TCUQ=x^-GO+lSneO0J=Tc+dPzuC+FeEH7-`o71QtU
z4QC+_iGi4O-WTCFmy$SO;3&3RiM%*mxKO5>db25wa>!BZ8BmX4NRdz!ZiaySx+#)#
zqWU5Lrj?=%6nHZzUV!X_+5W`}8$C09hba@MIU!8SPr*s$f(a1l=mZ!Zy~yvt?8%l4
z-g7k1zu`>D10qHNJMk%Z?jY6qRH`L*E#=Km_a}>s5z9vXjxfB!Oj07AD977kyV9yM
z4iu%#RjGFk?L0t6&%S;NQ$P)xfcAe7<&))^Orc$uRTyQ1jnt{??emripwhJ5qrJo(
z^)A_povPLSl8YsmEnJQA9h84CKmHZWS3zMVExDbAH(hypNc6}#G7h!5qg`hMLf50f
zG(*p#L%^TjXc-$7Zq4yuHAn=qtYZPjPUt)y3_olX6a<4Dpzg%8Dx6W8x>w?8_w|umq4>4JLmF7@Hi5
zxOCkHsyYYI#~5nZQIJ3_3}@gr$Vw7D7&rHAntxHBT17=YVvLbcuoA16SQXJl`HNPW
z=@IqLg|uf?Oqm}3PCD*6qZE{UODz$E${f!D#{Xlx)0|Lu^~e41UgXTTJSB|f4(^j!
zIYpZ3Dg`Y|sP~s9y7$M{k?4dPRPnS^qo|e4zPe4q(;s4`KLB}rkTpP(L
z0^s|3A-AyU?2N0s=2)+EdT$6W$%eVG8kUMO>dj=9q^x#tscUD&{^|AO{8iIV35p7b
z4*@OVWPjFf%=1jRjzJ_RATtm&*#km#^~#oF=i`7$TWBCQeKQW)G@J0
zd5MT6+2t}@RbJn~P%i~pRZsg_o@dm0XJ|PyJIXmW6i~ak)0`YM*gQ{c_AgO3XuY%f
zgN0@&NQ!C$^75wJAT(M?3r<;HlG+$_;g91xfsEvd~Kkz%#5OAyNop2
z_M`&`-CN#&$&Yzn~RZO}N-%VYzc=%4W
zpVXu`9tH-xNI7x1dL*ShA>xcy#|LG~iW$>dQfi7B$@9{k6o^8@LVo<^ew{U6Pv%iC
z%Uj0&qE3oF7lq!cK4PJHng(B1@yF}%Y@%(s;lIy`D;Go_l87UGB3~V}{}+QPpr-v2
z_K>S1Py#EeBG&|^7$fyonnqfK0|~jLL|_X=^IN+UU-jVV;Q633iQ(-AxJ%vL7d^}+H~D(
zF!gF;@x7{neeH1|mVkD=?<G
z)e_9!Sic@kMP96=+9D35uLsWXBk_ho#`Jqny{L_=yHUg_&1Qe1jXW&rH*AJF&1ZZ4`;*$})zoKKEHxelg_g!HjP6~dduOQW8
zWA{^7>626;iJ19>a$Q}Du&^QfG0XI*!ysfxpH5-CLA&+2`O`oxL}tZOBP`qU^|yD*
zV>e!KTo+(SALo7h~m>NAGhf}(4%y3
zS_i=L!glbm2|2t1L?3$CR^8P~xJDG@1^&#`nh2a&jEX2C71&AR94^z7k3~w-ox19D
zvCGjTnBW&5P`?az<>|Lp4}a9=8@3iIv|*74vS?JpK-?XXz2t%Q!XCoU&Rlg!^VhG-
z6Ng?DFP;32sy4;{aOBRMR*x3-z?osO+|S;i=DgqD(tbg2B!lpyeOxkmCafh2H>P3)I1(uO)u(SgJ~>=9=hJpx-Zjk}n7(alSU
zW%r!MTkN&-E<8Xu#IOaK+^8<{-EZAXm!#FZJE+KroH;gb&F8|;PGx;sql%bZI)8)e
zsdcHZ34Z~6JqlcFa#eMKjaz
zmy7!6-Lpd{J}2;IQ4q>QlGSORw&7v+g_DFA!G^8eIXq-g-E4G7e?194z_}wrrcaHn
ziy7ndTAn@|dSUzt_mM-4W3p1z`;xCm+c66c#nSA0L5!?n5~LY*tAdQ$j_P~-mLwEO
zS5X?NBU6^~CKzh|7<-z-GptYMQm5+j@)5k6a+;Dx-+p-y*4e)2mqz#lwvU0!OgpP3
zbVDe--1aG%HOQHpkKg`
zJS)CZV(Cv!du5`UhCDkr@O>Fj&V?S{3;Smo?3z=w_C3WCtOnEmpVQ=u2~h&`ozLz%
zR#irY_H%*qpMI@ao!{U!V>AX&%XK;p7eNT?txQTgj68H$=$~hG*G&3isD?r5(@z0r
zXuG4-bYl^>B-z-XAmlAFT*q?aO3MQyj?sqY5dS
z2R+Gr*ExO~U-0zi%1Ooo)lTNipJ<=SKZo*%YY^J9&g;(!mU+8HI(sdVcu7TbEPpbs
zM^R4+*D~4Z*gW7SV6t;cBI-cHr7GZ=3TGqF_Mr~)QF}v(rvk0@u>AbBG;JJL#Z?MK3n)MhoR3cxrQzu_*;diyg7f802KO?cOs
zuXhB-;#C$dv_<}5VEBzD4o>3(#e=h-*
zB%kM*hL`u
zZ7~Z;wC}X^9sOQFEm687_4%gia_;ac(WIVEIAzoh8i&Bvs)5@RW?<*L35cbO03eDT
zd_Y7Np3zi5naP#(pk}b1ZJEidA<@Ryis)sLzFcU*!xGsF;b4p7`WLIA^puVSdu;Uo
z4K2^if2PnUm^Tb$ymy6jr`#d_c<(*~dh(kH?+Whvl1pfLZS1ZXVju^pL!`qiWP!R
zRMzQUxxRPChGKjjR*c9%kz#e;z=u9!{f51KaL;E)izG;MHp?D1(6V0aNd~A)@UBTw
zq7S5h`_v6!;`~)r?9M{IoiCu5-&r<;oC?4|)?dsl^ToCnlChQXaqo{E;A{{c)Tc}w
z5*fIw_CK-ua|9JwtF~k^kJ_@UwB692Vhg$!!p&6Z$uU+>(=8a?P1@E8)imyDTz$&U
zW?aIXE@CRIj#SyFM~*UA1Ssa7KYT@
z^3(7zL#6LYByL;U@pWhYo2)Z$a}=|CU>?jHVo&y8GQo~v<~)zf1PR$=UH-=5hH&fW
z5rxMQ=x%v!)`G-Ydb(7rPGlh{XqJ&n*&|!m`)AD
zs*E?AD3}m_tv8x!t@$I5JUnkVkEPVC`(-059bsfQ8Dm-r=*dI}fp5x3fbPBWugzLP
zj`$`=VrAr(j$*e?n{P|YefedCUI&!bsuU@Ct0Fy#JgIRJUVwRck5{O#AoQJE@90Dw
zLp7U=zDRs=6vhhYt&7MwR20QrkB`rFQqudFNscV
z&^)FjL4-xUsTjiszd+rXPH*xkhX@p=O}C0jBx^$gwkQ^s;6`hco8T~zo{+MtZ#|85
zHVDG*VHuaN)?n#GoqDb$u8(DpW$MLHJ)mAVOXmMWy{KIhm{%WvG{l*M7!gR!Dltsv$rb3qAlE1Kxk*R2rs
zK3VY#S1Lxm=RT*T^?gh9GZtmKN+wHrHPweFSsrw2>2D`}vM@tEkDP65$xSE?XEh#~
z*h(2A9&a01mr|4*V5Mt+%$zD-n4oh8<7BzmXlHPL-$jKYNub#{1C>UT2*z|F4SA
zJfnxaRgHDKsMXVu+bgMBR^yBcZZ%qAZRYr0ahXe+YyXnV`b^-Rw_FTYpgUwXwA4)$
z^{4l%R90Nge&X(^=)qxaoi)#2e39hG8=qjm7$0JnSlphMNujrbJm9Hsq|B741r~pc3qk2E}X9D~v%d-CSlR(bN
zV@Rxy`Ets2bD=-N6V38+@OCDa3Ie-
ztCe(b@ztQ1o_s^7{|?lbM^eQJf!8VRd!%vK-i5c#MhrO(mJb2brJbnX3c9562Lu0@
zS$E7fyS)$fLf62<@`tfDX8*+iU%tC5YM9+x!g85ig>WYZ*ZZkoq(WSXhrEty!F#yB
zJYVnE@!xyxt<$wgxCt}FECkD?TTq&Kx}j-e4FFHt9_zOvsM3h0#0JXmHP)W=6m
zq!9#igi05gxgZZEg&RrcMoDC1;7at_6o7c*J}i$JNQTVb5f&?erCCC{i0e73d;Lr9
z5baX8(^}x`dp{&s=WaP#<0Z#HqpQO>-a`zqihUA1Dw#5?!(Sj{u}%w#5YO%bJdO?g
z^2lI?@`!!NH)iEFRNa43mBjbCkd&o;Di0*L?jdq#eZ_(X4Fk4VuHYBQ>t3BXADwP_
z)DQcErx=LP3vG5$(MvSP+V5iMo%Uk!if<@9tj6(*_RfMw>ZIEa+Rr$KEh{uD^dh0d
zS6`xR{Ty~nZXk*1gTn`&DUl2(PPd@Iqp3DVGXZJ1EH84%ja-rY5J1x585rAbjogFg
zv92f@&N_pqfn}i$-aMJw3!AU*KXqBF9h7%Hu?=KVa_ijPuDOU_CP$y>h7Fxrry&L)A0V6j}F`4G=*u=}m)!!Um_gg3B`$2~mk
zF4g+nq%~6JN!^}DqMJ-|PLII>m>hw7pX)1V5X5CjG_0c!cpOhC>7FFHm`*z|1jk>Z
z>BW@n%!0&H?xvy=4`Xj=F9e
zK5q|jqlv<7I)qKlVVz6151iy@Y}(n~&_~hsqIu2kwy`j>5kV!ZzFfIjIviI)J^Suz
z>%2JCv(x)7C9n^EHrnvr6Ob0VRui6h>Ll?PNT+(xR!Zfc20bZuK7ZuNY$5MPPZ-ym
zO%!{dd15^}UGj^gmD(GayRA=Y$)LKkTtv&B@N8ak3`xoaEh$p;Byk3wDA?UpXP*_q
zaq#?v3Z|b$Ndx>cj-S3co9qu`e5g8ihQ|nLlWwJ0;Cro4KWdML)6T@P>+HQpuMpR0
z(U2`FX1K4DV!lDD13?=AxTuPU!0<~@k9J`1`e)Ke&~VErx8D#^$@D(|hZg%m5W-1x
zzQdRTRg>-?_+7NXWPoFiQmg3}Xie!38#j(R+V$^X9z>R;Q|9$~0Thl~WK@Pv10LzM
zOOjh>w?*u3=p!WMAvwR3E{uwQu?6fX%9%iOR@Iuu4-LW%`Rc3Ka1bqNa&Q97a;dsE
znwkp3oy=He2zEST-@X46&TV`9UZ$Tijg@<_W7-BF#xq;?Z_`G6BBm?HZ*6o*_w^eV
zMd9+}HyVL&)teT*4n)I!aI0ry1fS@Q$O84*z7Hu4o=d}>%RzOgwb>Ct@tVdA_c9EJ
za3kp9dV`*^T$)dlN@D(D(8}>gWKX#q4FrM9cyT?!OhV(}MC*fK&;(-ti#wMYt7S4}
ztK=2TsbIdjraRX7Q}C0I+|1{oTRJvm0P-W(n-F8nJ4hY+WUqAF=!>JFYqiFc8#%GR
z?DfU+l+!qKo{GZ6up51CT@;*pp>lo~y{{x8nhT^1RLCc!iGEIONT-<1)NbZB=KJH)
zmyW%rG!fjx_;sOF^m@!~Q%IEH#-hw*K&;uFjj;-aa9$$tq5y}Ti|JDucu*sf0~+Ec
z%jyKIB&X{jMDDH@zTY4MQ(p1vD!q0oTdMpP2@xwMStC@RfB2O^RID{-8d-=AK-Fj!
zIdKHn8E#2r3Cn#sHu}w-RBoUs7W{raHFc}KkYF{#pw0@k*Oy>BX`sq`G73faR@A~3
z?xqW>zc7HiuCvXUfLbW&Krz|XZ#O}T@9W0Ah%S6AuFvZJcyKSsi91D+1g2YX%d;(B
zG4}JQil{n=>vEyEIl475?m
z)aiJTMj#5KWkCIIhAwYX<$K{y7Pk{15ZC|q-7oRazCXAyPvcz4jZazu7LK}2kD>=fEw2>MoAw^kM0c567b>6CpDxuW0#@zWC0!pn
z9L5-0yl9GZhEV=Z=1pxAo&^K@$}3NPVxZv|V;LV^eI-h{wSf!>yzoL**sE_2JlE@qye<3g(tIGcEWjSHTm_F{
z*S?q`I%}1l8tiXuf3!BO!Lr=ud2)q0bIJNwleDk>Y(du2=Ox`T`@4s9fa|z|eFbsTo_a$VjbO^%*4<4tiW1>h~s
zlO^%Zfd*)ohBVR-i36AI`1_**Obf|xanw2lw6;lJAQW@A?p-SX
zR))lHpKY!@2!B`B)r3GJQPWSp#bf=vBC37*#fl&hI`Zos5nm0%&I%Dy9fG8!*FW}`
z=WdveBYCqHd@8GqQBGg~zfW&7o>=e^jtB2t}PU}rZ4C`-@&(=5`LHrWu
zvtQ^qQKhrBV&BC0Fl1xTb5hmKmw1fe(!OClJjt%hy)mgAYihH;9@Io!pbj~_zkZ$A
zrIc1&kCkH~Mj$969lMUJh5bu|%KLq03ShopK@(NzVYC0@P;lqkmw-t@VXg|O0D_X@
z9mv4=#`Kluo5`cGZ+uW`o4K!2k2*E#B79E(>Wo;ICmY=hKANZGp~Xpdv#d_FplRxHV`%VHS5yxPO|FwS7+kIG
zchKW$53lrsawm6BWMesHn#bhYMVvIAv72?H3-a$39lN~S*yg7v=e|j8?ZB{4!h^AW7e3@E55d3P>+QT#5b;
zXCXaJ0t%IHG>jJ_y|=vPJQ=bJ0X>$lT;1*4uw4D$$b!X7_RSx(i7lqfLu9Rc$@EpF)J}AB6+uHx??XfWZ4;-*9}EPR6dbW;UiC{|}kZ#NNin&T@cv*JHiY
zwcB#v>wS`$`E}`OR(I=&of$1w{6#=ViU
z{eVFrP$-!1aO{L2M1zx%{_lotBRmH^BzI0AdqI-l4y+i22Z3P&JHW4pKq|I;0R^;p
zUy#)=kVGJ_7dAi!M6Uwp-%;PGP=Vk0aDl>1R2op5kb!PsoJ0u@0R>?MNT;!=z=HGj
z`hrj>(F0>5yu?ss!vu)0JqA{$sh1E`tg97YTSHNoyN#TxW2Z_BFV!YYgu
zsW@@MOI}+9*g|;lq6FLs8w7G)g^auB{ru_ikSsEW04R)z8Vx)aA=!{R+E)OmUD3Pv
z8RR%n$-v{{l7DQW0|(GH?q9NJ+MdjK+RrxB%5r2W$KS0cliva=t=5L5U
zeH}loI6_GNSMZMt!nVzz5JWHGAm5kYr3Y{6G+^IZSVH}Mv{(kW%3+{j-%7pkk}zN+
zKLI~|Pd_}zKNKJOTHpGUKR57}9z=l~Eo$&kq2#^U;|h`J9LNx=~QK1xXVw}I$`MhXta
zGHMRj!9o&(gM6hU3b-g@ewGA{a9p;*#^qP|uc=9hFxBf1Q8JLj2efyI_)rOY#74?U
z0e|+tQil%o_)p;yL5LbVydnYR83XkLAIaZU)x1W_!9_WQlN`+J;}3n^D}PpjED!DA
z3;6Yg1^|9u-e0PR4t5==MwY=KDv=I#uoqo)3Z_rUJ9!0}+vZU+4K}ceLyvx5m*=G7
zA0tm9vZL^;AFcE|7mlau51{?o3+l##ciFGB5Y3mGogBgb=0?--6ngRrJa6J3tQlrl
z#}S$=l473sk>fbeZ)%}x?@6|1aKfjaCuq`Zd%CR#>9!6Py2c1vp9wMjkK1~UwC2JmdpD%+LFN%vsx)q`{|u3@`hy_+hhGf}W_2vV{}JL*L^dx$PA!ZI3K|RKvmgo*{skfR5Ocbx4xOMut+w%
zK~~#YBG~E{J-64xwtnih@N8^L90wTQH(Y98UsO$(&yv+K{WNQ?fLs}nF%<6TCZ2p#
zwX|I(wa(&I!bI68g2CsYMD2Pv_iGD4Q&q
zQq=g#H9ofrjp5~W<64n69_2}|UpcW(@RuVh2es+W7+P&~5bHdh4)LlUqh~5j&X9k4It_$FpsU~->L_cSOR>}Z
z68>da)sG#C`d*H}PZJcau@GmUhieBOZ%+Gn6IWp*+nn9+beoa?b`_G(t5Nmgih4&i
zj=+|yG28Cvx4AW=MObvB&~&3|i?HL4E~7jxV(Djhma>php+OVpWX}7iZ5BHu&81cj
zj7EPOX(3WcadPUjg@X13Wh&L>V3e%m#NhiMV&PS#FC=ehZ9y&KG|!AbDrD$8PgWuD
zuY*vdCw^sBcfAsj9-F?W+CAf5qA7=?$6FGaDNvmk{O0zoGQJW51?If#G{Qa7&_L8CD>lqfd^aP3pbwvaX<)e_ydh^n
zR%H%ljW?~FwN+{&kp%En&?bqd?GTY6HX{mP4c)jlA38HAd6dMyCJ*9w13CKBT8N<$
zs-b8T@&hx1KfMOevw3K8qjO%EQn03rR=B%m42U48Q)9-K>4RX&9{ez_S*1upE4^HO
zzPC+|Hd&k8OCRj?+G0GR9zuWB4!(7Oy`%3nug|FSD35X9Vxq^hJC+Tk3iIOUJ{2oJ
zN$pcKiVu;lkMAQBgZ%UrdTY=>U8*J4nPD%&@v)M3RIV3}aa7Ir$}Bop7xMY;ZTZBqqQ}czmT*FbI6=yBRw@XgXtgEp%E`U~BET
zDNfFV#0-+k^I~btu8*uwQ9^iixzlqT=h!cnDlpiOcntUadE;fGWm`SM7`g>MFXLFH
zE~!;j)MKkFSI*)oFI)$PzP1=|De&5lIC5-Vcs+Ztc0wLF!YV0T9
z_w%&DU@B!2Fc`KqJy|6~gdZiT?zgx+K?}!=Tm9WDYVC^pF<^
z21d9@j?^s~hY|6sX?>463$}e@8|F7gXn(a@0ls%jzfUlW%|Qaa#8!$uZrs&d`3Nv^
z&=)uU)HJ2e?9v}|butVH>BUpQlw4GspJ+-l%czCNsiZ|Mhi&LrTCl%JO}V>bqfDZO
zji+F-Y1rv1TkSIulC(>^A=OR~kFhdZCvVO6=Ml}aZ@oB2`6?i*ddy*xZZ~_na4T);
zKyu@0J)CtUwDALG`lj_XlFRw(`do~D3#+Psb7vl0WjABX9mVZF)p-)9#v-SoB1LCG
zaro~nE(DbEs(*3u?79)1t!P*3O3mkQ|Ft*azEcR)^e)&_*EB1?kea?
z8M~4l{lY!5E`u8!@#h4_YsmT(%fj>3IKI2w=K0+Rl+h`yt5LwahO-`r!q2W;_n&3J6d(1bPKm{!P)wOA9V|gV`+a_-C2OikaJiSVQC-r?p!&
zI2I(`^_7v~M@&jbFVE686XlxwSckE?=tvYK7xJc!&&C~hWK9o1fRda7=Hiy!R}8iW%A0WL~vSDxDFil@0*Z4Vw#{;pe@x|0Vl2`*Zy*FsdVoG$@R);#SgBfbSXhyOd
z;EnelA%RX<)qC;M+q
zbQ8%cQ_7}xy%Nw|C=(t=(#|!z{RDRunxhXg)(<2<1mYDkkq_4_rXYQ@H+FWlAw!|eFR(mZ
z=OIA5qQvL184RTc9a*#VY#`sih~UBzgBafdg*lhg(sVw$~H06J^gCyPqluu+7(
z&h@W##u&lr1va&$d*+AW(UdJLIfy=DLl@)oCCYl$lZ6}-N1DT`^Qii
zdgcb&D=u=vi2U;kgKg+Tgj7jr9K7cz<-BQ$jrFKju5^aEHaB<}-j?g`GKV74jC*Mu
zhcB_0_?~~N??VG-XCcUZS-GOlf%8lxdly$pU7oaJPd>aCAxS+UfdIiSji>(MG+Rpb%IkGUNg@Te
zyIC@)eqBqQf5i!P)FJ1SS|v94SM9TAeln39zyA3bVBAkTiq_fk4Y>1yBIefa+#bJT
zq;8g3Vm95!U4?YKBz{^~zsqiUJL6w{KhHK^GB#dZbyH^%i<6_s7>^}ieB}w9-JPla
zuBHYS`$U!Fe$4`1zc$y2HUX&`lR>^Ko#@?UVe=|j|
z`MfDX=hk$%S(dTZ2zAO$rSN$=iipH)n(8ZOOQ`aJLwqfQrQh(OY+y+K9oLl+%qeX8
zm0r4fm#)b_Lk}y=cnkq;cOuOht
zT^#?Gz6%x#N><4J#{G`4(Ds0?UPa^-hBc!0Lj<g>2!(v
zw!#=*ienG(S!#~LC1rK>296)8hG{O57giIv*ROC>>58#X7gQe^&%sTa<
zN0LeYAFSO|kSAgHC-|~$c2!qZmu=g&ZQE9tZQHhO>sPjIySCrinBAG!`Nzz~=G_yK
z5gB=tIG^X7uNn4h!-Yp#iycU|_lN4X?oF>m)YMc#e@kgVHEr7q|7WiBBWStoXsLe(
z+_+bIBNs9w8#Ng`<2{PSJE#v9KXtB>Bh=s1NuY6o0bD}~z}~FI^$g)Qwz*7KS7AamlK;t{z9;X_>e%UQC+gbw~Q~>z8lazg*~H
zW?)&^~d`{uv_3x+?OYKhNbo3#1QZRb1_5mC?_g!Kv
z`_(NlU6mv0pVhI%7TVrHccINjQpu!0fPh0>iK9ui8roLH?LTmgGSUl(?>V|ApLHl5
zEI&P*dgK5xbi+0e2(QK{t!{}BaMSC(oGLs(ju
zFazD(%}~DKo#|XlBH?SR^yWZybRzoIQK^W49sV0E$eDv^a#J7~T?Xa;wU-3Vk<&vF
zD;+pT|Cx{}@-9{&NMizaLZ&@=c25#m4?CNA$|bF`EHR>iOQ1le+t`X^{*4c33c+^F
zzsoygsnb~N`uS08;ti92p>%}8L-%)LtC$9dju@b;$13Z$DUGKT-tC`suhP@XJ*(8g
zBaAj3^gmM63{}2H-!2aGMROTkx5q5YgwF7?WL@Wb)0=5ZTOciPORt643F8Ce#n+qt
z(0HjUlL2#h;kXcdZdCXyjC({NmgzMfon#?;u=a_|gQ9^x%s%)$Vq`Eq7>{(7t?4n9
zh<1bLkyG9(EibHIQ=4WkEizLKF))wC=(QtYY6#tPn6xJn7vrAZk_l^Nw95r|3V~r{
z%**>3lTTo=Nh#Hi-oTvxwak6!EEmJi`?z
zO3_nmR{cuw+;ub$nW6R8>$nv-7C((??ZT#qEzPc@VRBEM+@)k!89nF#^Dq5vUOnw4
zVl(zgGR$-39_JLsM|#8Hi?UDyA>QmIA
zQwI?~ZD-r4)n^xw7d1sb#N?YE7Q-Jw)sS3b#Iqw54t85)lYGk3VP4m}o+K&-a%r`C
zf#W=`+J4XWm8y3NGIL(vwL9R?2wUuxxds6IqZeeZy(eV&Ei(aqo@rxZvcL@t47mc^
z4te#aowc&EFWXVlwxjc};ilCdg%p-9TWiGyu?ms^cJ7}L>vNjhL>7$rmMaCm-^eEO
zN`jE>0)bbX3_+3vsUJfGG?MqG1ZaySRP4O;j6*n_`EGVYHS}gwQgDHwLZdrU+PsvL
zJ{;Vd_~%KfkaB3J6T4o$6-N?ncb=U-TAw-JNt@Cl>e{klGM1o)`3V%q^F;!?r3{nM
zx#c(E{*DWv0gVp$dwDwpHUQ-LWJLj
z0a>KXqjzb%?K+3urQ_R{ZgvZ67G?VC_Y>~f7)vORjg=r2OCj0aSr8Af07{=fc4|C$
zDjFH9&N|-&X|=X){|kcs7qLZXXJ|>t%?(5Mzav-~c|}=4iGKvEr14*5o-q^Ba4@qI
zGB7c65VEne>cG$mI2oDPI{(LG|K*h#*o*%+#Uy0?PnOw#9eGB>zzjpD@drai?ZB85vngt?2n5a&$fDoA@FXNj>3Og?>
zj9pw<7_M*F1Z1>h;5!gl+mxOeB1U-Zs}_uf87^wr;9Q@YR*oPXX#36{JR$;Ar1(&{
z_()jT-;ju?!HjtmcG5fb=@5Sbp%UkX0_USJSEyRMDFj}OG-w>Q6nhK5D|
z&JjO48x{@%FtPu;eiiBzJR35IEBLmM;4XdDY_H}mCA&dAIfsD(9UUFgDm|_p&LVbus~;_0AybKVB$I8
zYZy=*^YehZZFK=cEa0zXDA!>^hbMhG`b~7}SgC*FNH4E63c_ntpjSFeZr_aE5pUg|-}&zIm%
z@vIaB{%yY^J7OXVkba-=Z$I2!xA7mDm)?%g-lCr!+=WMbmoNO|FZ>_A0e!Z%%2_>V
zb_y?jhn6|9{i%T08)c_e0;-F_JbT2}pO|y~es-@iLOcf)Oq67xaPiOnJuI0vHaJVD
zQNgTlsI!~OzG?fv#QGuPaGxu?4!?egfM0*3Y_{n=xH`5{SgZZ9;4i~R@MD2q~g
zP~0lo=IqcQ3$%IYZS8|0kJ(;p(~%IFaZbi|7W!;XZ=UQv2KBe;q4Zs0pyLspe36$O
zwF?I>|1`bF90E>SPK76P$R(&>9+~*ax~ViY53VZ^^OD&h0Ptp##3Lo2>2JLRh+Z4c
zhhTI?7JS3|7LU}G*HB0QD#9-81GWP3(lNvfXY-TF8xo>y6u;C_H6FNGb2$-HuhH~s
zHL1GH2dlKkeZf0`BM~Up7Siftl^r*FP=+)c9DGN5nw#>YN=3EI+|y3eVziNl1`cAC
zwf3>(yi=+Vn097nUrrvMiz081FI-imR7B_K7v8rGCh?`Ojf$iu+5utx2dc^3%2YBk
z#%A8v82#P+P}gS}%_%mXjp5)-$J!oE*-f=;W#ghnQ`TFoOuk}JIQqSS2gB{%3Mu+#
z^GQ|ZUnFnNz8^EBcA(=GjCnGY+kX6lz4SdMb_xUiQGX=r<)Q!fSE^X`qjU6~_mC0F80-L8P4Mc`$Gs}kzLr$`Dob0ad_-+0_PyA4~m
z+Firq4?AK%1JF;ed)$OLR5CP*azG}wqK|;~(Oc)inTYNU^dhb~@sWNwMN{@6|zY8H)1Afe)t3~b
z6me`a1hCZHv4!q#JE-2}*4Uk|0@C(?M-?OowQ9LMqf!_b2Q89XN{JbrsvF`!Oo`#p
zzuiPe{5!>U-dD1vZrTY|n>&7w5Nco}NTKY1BA&=8$GkB~%h0&6{5~{4)^gVMuSx?x
zs$9e}r(BRLhj#?*WFW!9LXd}1_wd%#D_++UO*+6pqH7n6mw$1Eop^-lG%A#Gfi<9T
z90Fq^gQW+T8DAUIY}?r~SS@fg4lVz-wRUY)+DGdZJU0Tm{N1`%>*F4K4quU>vC`w>
zn;)zSvd$wNCDU!EGrhVln~Ys?ow>CKJ!ae8YBFJ|MG%x1G9l`jCdQEguf&)#Defa{fZv6j2j#a55E1;EYO-Z9Q$~~_
z9&hd+7*%$spQ!}_>_JpN;fFPvTamcRrr0oIv#nHp4;z5*T=)eLI-gob*iajPOBqXS
zMe3h`s6zJi>a8G&hCSzsyjJNVa+^Q0xpN($#DjUZ4yvP0uzGh#9aPiFpPq=IyHa7K{X&?jK#IdNoWNsi6zY=+;3Tx7Q22>kjDD@Blbj0z@
zJ}1A!O0nQ?23lR=SXEqc5`qJ)GcbT9I>_8bhes4otyBq&*k?Wr^f-hQ00Ddr>}Nv_}_jAW9h(pYTp=SZnf2kgMr3F0pO3gMO6f4nxAzRY5mH
zABHriofClA%yvQtu7loDK4CT1T%`&)-pDc!RVQkJW4^~EgliIvOI3jtUb5m`+ZN7D
zY^p2;ETVBU&5t@cbH@^4Zks?VYLMhQ^Zo1RqSFQp5Hm_%u~Z?hf7&Yms{5&tmuyq{
z=R4+^Q;<8|KT7#lx|YCpg0Muy)tvMFMzW(-dp>G(^;)?3@no2Vk#B^{Gc7t$%3kzO5F9;gd=rdo2T(RSB{l38
z=o%9Eh8_0QRV%GJNB5m);sDhIgSVtRA7N~D?{NCe5$=;E{hd;sC$nNe;3i$xs;8Nd
zRN;ZCX!^fs)^%X3aNsHU4zokb$=PrM$xL`z+2^A25>JBokSIi?v&u+`==!W`G{(0@
zLMFZOqY%VKkr9RZN;=RZi%oXdmj+Ic+YF}ZB_KFfUaafPLRukURg(ZpO|Qv%IGGs&
zxj?m^YHHCUTmpzjRkf=w$BjK%_q&3XXDegm0dD3)QGz1aM2yL(IfXAr(dl^xZc63ox&lDuIgOJG`2wyX5~z2wP&467=Z0k{d3^X9bFi9g
zA>N(1?|!tTvA=qM%bv=lFMF;HIjAjoy-aL$FUnSxnHWsx;n2mD^m3nZgixP)uc(&U
zmgv%IA!(;{p%N4J{8cB^AnYY>O6*@74d3M6m~L_KmFD4o5H!nx7H5zU;GFz-21!=1
z*030N$Ex5=MI8t{tF##XPB|GOn*@I10%`b87{30(Nr`i7S*G#Il90Y(*#qEsV;Lbwj^3Q9Cbh`E{&y)ZS9@7#J&Fbzovr#I8)y(^$+fsV+nd5fQi3l9dgI`5CUFS4ao$B@>
z;?%)ibrepcN@^B8oy6qGQ~?^LT=>EVD}pLU&LP#p*&ZG}hUFf`%0IcqZFN)nLvEms
zbmgM~xjg1AV8!QCjY0gn4@H!Xvd3gJCd}lNlm^|RZp|dgLE@8Mz)@*aR
z*fpsA5Q;&G{FTp&SWPAqJ5ryUV>{@F1nt__eiw)F)W8SU7lDO4FH{JnudTa3wDnd^
zhqARdSf`A96;ftfER1hrmb{-GO=R`?G#7qcnZFZJ~o|{kvSKc%8
ztEUifQZ|ujFyYN^xE)Yq=O^TJc`9&|UjlrEQ~qu{z*SKe?*Nma`F8I7C&yR7yGIal
z++Z3Y+_`D+L%#P6@y#>LxF{Vq;%G2MLm7UEm`L-&@mhV9OI>|q-kX@g=T^l{$H+m`
zgG`W!)RoyyfVxOmm4
z=YLDjhjI{x8g_&k*yT!j7o|X1xM-rCYx}BDo5!(jP`n+9*S$k8$+ZXHHn%^mxZ|dWjdY+AAqOw
z0U_7$OgO*&g*K!r(x}XIi2g2I&nlBr)6=>|r{Sn>`_xu)?R6#r(}5zhalIhR%gY67M#&{tA=qJ3@#L?=UYSo^C+j8;cjSP^F(r8D%f
z;g7>uXj&|n7YbSnmHDk`plbW#CnR`$(kk<1MNsM9>ajk&fa5dan>be1We3ohU`t~q
zqF2<=$h$_ga^4%gp7*fz(yXI_X#Gk6Z91%a26J5r-%V#aO3kbfZ;J}9Tf~+wPq8jM
zlC_Kx7r7pe4Xkviu1t99n6p*h3%^?NOd9T3KCyuV*+NJkSW9yLa;HmYfwdY-0G2f$
zy|vy+z8|E!Sa0HCn#a*zJ)5)TI9{+1S>%fP;s+qq>s@px&E9S+E(oIt=r*ZdU4#xpgXz2p+>#k}j|Q0np|*@2C|
zkj1KZp(giMDmEa4+2uF7g?1_yZj$Cf%2!xc
z#V=;SOnoKQO}(-9kQ3_al?HO%#3MII_#8=(#3e0UpYEk-Sn%>0#8_XC5C5X@1~?Fq
zzrbL`HM;%M6;4!8jLmBWlAc>J$8WNIpfr-aL3G$_+$%z{x;|2Mz?O&j-70FQDKjZl
zIhp4rkf;B#YbVpJH36hjE@79xy8(ZB;xRtXBp~$Nz=&d6+v)l=K_G%j+M!ez;+2)f
z@@o^5sfU}u8^|sv5t241oZOA`*F(guTdXJpx=qUoA73+E~g83f5dT_qw}`5r}0&%yKz`+Lf9^;Y2u`v>OC
zJa3XkBla0>U!Xgp59=$}@WHDf#5
z9Svjhd_R!%7lVJxjismdCuii8koO(_?1k6)9J81Gp`{mtGT
zsB_Z6Qyk!`Co{&VWY|x2(G%}w^+#1oK`%WCnbu@3@Fb&Ca_eLY#oeYH(C!$+CmxH6
zURd60vi$D1+#mbEE?DYT&ZQKoXQ2rFTq7SZUqRn
zsF+n?R{h+2#6c~e7Tj1Bs?dcamO?r#l~hElb=@5{KY~O$gV8saJy8m;D^=HG%g73b
z4Y1&>-$BSI4ZM{{ylHNS8b}lN!>;!RIxj{x-@i5ZH9Ktx!Zn>|m3!phN3{}*M+Rq>
zZ|vH@I=PD~^`($a$+okkc}Fm#1sM{DhjlK+_|~xL4+eIMDIv3@TesMd$TT?8Fy@cd
zEk~PUQgsLeOnZ
zfs1W!TI->##!Xd@IRi;f4vDI+@;GZ(UKV3*)l*3@psxYDq7nise)iGZR6K?;fln9r
z6HJ?=lDjVr@GxlM>aM>0191it-OCK<9=((?VX)TRuy;YrTloZ3dZk<|^;ywhsV-|B
ze%Ne9waVII#emCYl0HfIBuMDgdzC(W>gT%QV{E5d%m&E(@$PKYs2Dm(A(#Rk>_D*!
z^LlE!Fd34J3>AD@chPa@MtLcLN;&2BW0r_dxy(IZ+h0K~X&d8JHbgYvGpvb+*i|E#
zsPO-Di!~Yp4Qnb0;%%FozEh+AsQ=mSDd|Y%mvL?!Ht4`(78B69bpTy5qzH+cJcs=%
zjxz0a!xc(DbchkY?s&8*wHzO?0m+E}$^!9HxIoh_M8=IxqQo9K{>%jQi&A0WBr`(j
z508pIbJj2G(pLRsKR3P527&t3npPrnCLzLz`vm5KluQ1&)!sVo_*my^qt)%I2bV8Q
z{BB#sYCFg5ao#*{Xc6GP#XmB$AO4qU+&dvRG@e|obP`5AUd3_X*fVx^y7g)nYgXi>
z{gYiKc$V`MF^`qies{-JYM(jzZ~qFIRq0MA+{I4?BfL_g_#!HV>c`PX7Aps0Mk^7v
zV{<4h5Zel`dn+EEg=*Y4%LU`$orkUTP)AcS6PP%m7sv2hYV;wzZ{x%G&kxFl;HVWb
z-e}b09fNsD9NA9{T7_+t9yxO=Q|w;AVlv5-F>dVxlV?MVj^dIjL^9pK-P)QT0n16Pn#oMdc@T&kt}Bz#uyht3l(L
z#^~S=v+z0|<|-?|%GzEFIzo!{sbw}kpXjHKp0r;META~DK4A_7MSChTxw{XU1v}yw
z_S?pDDLCQRczUzW96Jyx?&V91m>h?DJ?18?FgkD-=~2cW=5HA^ZY9!=(^`J{^sU83
z!=U~Zdy^$95A2e8jgfzDrz2=$oN((3X;O^LnBDjgvQ^9~cS$A8mb1P!S4U@xb-7rJ
z(3;f;Xu}&+|B%57MT_%&7#791x}Rnq_IOMRHD`{#U340EwiZios)ouxqn^F5|MuA4
zWBKlMqs-3yC1ZWL-+H22jhbkuu9mAD=W&_b$lZiXXRK8!{z@X|t7iPOuomGc_G
z%+r%r(!^dH&nTp->6=qvx*$O)mY9QYp#!bEv&kS+p4pbFJxuaT?xQAN@`hL}u_aq>
zI-zih+F2z>6C`h7a%DYfJvg%%jT2`EQl{Mzsge$ygB7>)#%_Uxb);S=R|YdIe-9yb
z7NO|hfI)?J{60PiE^dw)L32B5be*(uG)tK#xy~;>0SpMzu<){+)%<0e#Cy+Q(a#&D~WAB_47Hhd%3
zoz5y1J-HyZ2ahRrMm+TD)sWN}qgWcJAkD&sqm`0z9rP-XgcdW-C`dP-<(|_jzF|Ga
zrw4p0sT40q8VliYD}PM<$h8UN=bUHRpbJDe`>CYb6mbV
zTZm^!E2$4h_|q!&c6%iTKAEAGf5VP=Q*7A*?puLj+6vxH5M_odwca0yLtLG!!$NiK
zhEsMHS@X_~&*L8F{MV?6bNFY7IU~YmW$OAdFP7Ndzt00Hjqs0&Nq`xYtGb1h$f0j3
za)UQQ)b_o6wJDT7HM!_#GO_T*$TH}9I0!z&0W+pVWJ)j&*dI_&f@{401+23C59av4
zgH=%t0T~6k{|2l7RdXx-KUrmAA!J}+XCY)`{t|J7;q`dutab
z8w*<(r~e69|Kq9u6R@)W4>$Y&04wW%uJC`a7zsI;{zJb1-=0nedggy%{Ga3hpr^A5
zTs~_Jg9eX;9}1zrIAHf$*4~_i9c%>x=PYC-NDJ!vKL^I95L6stfA(&GnCbD%RQHeG
zldi&&x7CHlN0pB`xyqu(&~$zYAvXC?_}`#p9VEi?BH%;Fx<;q^hDN7?g*kKoY-<6(
zbOnnhetI!_G@{p9APKCop|f#Pll@1uQn0^3huJp3c-lY+x&jEi0&I!3c?KVCX%FUNL#Zn6Os2$K#iftv@n}
zHf|W@lu|;{qy(=n`H{%P7I#h(K?eCv<&50SJ|0YM2<6qnM)mqY;22t8Wd=6aa%50J
zTTrl%sV+&tjjyyggGV|I?oAas8{%X|3`
zqe91Fu7W&1A}$Ti4}pW(2XX{;aerUE+67Pa1JgrhasW#Ur07GP^DX605k~Ue0geXy
zY=L;5$*vrLR{egyzD#aO=$y!hmcMdu`L0uCAj&Aqt0y1H4tjl1P~_SCAz?8Q{r@J0
z;`jCc?nBu1dcS?YVe~`Xw`+az_>
z*Lvv%$tk+Ld~CvyoGU%@|FkP(J)Koi1xXLezWQE)b!PO?M05x{N*vN)Z_`+7|7i-s
zH|et_bV9F7Okc_se4ka}eyRf(;-{1syS>3Yp@_`>^7EF{GBbU6tYGKWStX#I11NsE
z=~;wfFMhr}JKW!bNbA$1x-FJ|_z7|YA;y%lut2td<=X+_Qh}X6CV{x`pMux<56JuJ
zQPl$Z%e=RqAr6gxlhpOb0}=R79})~9>N9=ee(_RezV#A9`ollcjlt_TzGEH&*9H85
z=Sr@9!}4bLUlWYoDP!N$y((kBvmG9T*RAncK)%;**bReicyo5c-~L`c3dT3JVF+9xx@Jijik37_i(NaJ90uPf|mzg_^Z_
z8f2D_Nxq)BAWXYa@trWhcB1WJkUQLY;v2l>J-Bv4?Q7lO5jtyY)OMVXLK@bqyz{*|
z;2gB(1S59nx}z|k{tzmtmRiGrIkbuL)23mw`Xp$b65zkK=WNC6qo$hH(tcktaE_H;
zbLWo^?@L4kmmZg!3k%O%C&b-ds8}HC?OKESx_&2Zy-yz_ZTdoLqMwv#=5s4W!G!nf
z1v9?=tD}2Bjb8%gI<7%9C8*sY|5;w#ef{&
z^L9J*1Y`AVn(T&)g(qNRI|tg#%r(74=Z3_
zc@;O7!(BF?PT@AQedIW*eZ*-8!NG(r3Y0$SfDd)Bt}J4_w$b{?Wtq+bjJ?8WN$7RJ
zD26A1|L{UmFcl6T-gk^1sG^`(9UFvxFU&NGfzhTdrj$f*Ke_L5VNVoMup+6R=Q+@)jVqk!^bA!
zg(ivDu9?GY=_19Ey+kfo_*+j^*`kjTDkfwUDO9zXg4Tqn@!-4O*z9W=8mi0bG(!R{?BVxczHTxb*F1yA3XiP~>
zD`g@Aw}}x~Rw;PzgmKxt8adj;TPbU#6wZ!;c2D(*#7*54?7#KY(>S!k*rMhFpn?ir
zaVkw)=At&s4;7T&<_&CW*{sqXYf?kQb^<~BQTh#cjSWnCjb-006SwvS9Tjcn%u3DS
z!OqN|!TVE16Jp`kk_B}JStM`sxg)vx3~u#N)C6eFYHC$_LM71)ZH^9vX+vTqV_pez
z22b*rl&;jUi;Ca9aMr%z;(g#~NBI-|s!h}Gl8vNe$3|@`paZ9ogk3dHKvBbIygL
z&1MGmhy;|DtU5Pn<9J@D?HLhPW6Al5KbR1rvj5J(f!+1v4vmfI)SNY-{U{TW*qI>U@ZEw7|Djtf|MI~j>I6H
zs5x5$O_A&24p*fO%rc^1J4XJm6ztM)et?L{^Y;T|f1Bgb(9LW&
z;AGr%B;MuIjYJdm?~kg)_R*BAq)cUN5bzEGHA
zW7L1D=8fR+4Ib1u1iMtM+P=7AK)yFwYvWw|G}d_RD=
zr`e%jpCFo5&#l6Kv%rYV;^m3;BSFI(kA~>1=tM7cSK+1I8EL#w1gJY_AD2~5cr{{Y^;o4xzmCOY`q<1JbF>;G6j9(9Z
zY381D$z{sfI4IuydVQOL+!7w%95QB{QDrJ1X!&06pc&F1-WTq49yH;-7`H8zAzOT6
zeRMt_1cE2~Hywd(l|^hUkw5VgaG!dF3H*wJ9^HnD|CRd~4US`DX#rESKO2azBLyp)_kMeX?Nq7ues>6p
z`$$jb$muOZ2k6n$f-&%~5VV@uzUR6PM7OU)pCrcYb0fgnHHd!^N&9#6zRtqu@rxt~2xraR>N#%9x`&t3t|Oq~OOdRav!mf>FIcH8ik^B)K1<3G14Pg`ILF>E
zlVpZ-FO9B&Z`)M=y2DjZ`mHeF^4%LlPym?=K8qMpSV~H@C2#J|H9A$tp{xBlKrcy{
zo24q662vvM)W=)l#xA!n8$0v2GRWKB23RIMVej<(a^}H3_Y9IXsdwbfUcd7l+W3q7
zd#Y$SgxV@s#lcgBEOkGnUdcm0y2)imvCb}>IHq!8qh6QJCbdKkQYA`u#(#+;YxV9;
z0TDC__g2^h0K_eo?KbC8+tD_30p?h%GAB>zkAi|%bjERN>VJy&Tw1JOF@?p~VnK~j&FpSupD
zFRMZ!gM{da=JZgvJyvv_w`I&qJMS5>)VqbPMgvrJw<(LF*T*K`LvAJ5
ztMNi;Bt1N%Fy18q+{I|ri|
zQ_*#mcS~~hHz|=b5m)+f?;NsN<7_-wSr%y`%=hgoK5^YaZCgM;GY3nH7*8pl_Rp9}
zNOw$VRqkSKXpc(m+gpTe-H8a#0#8gug)|i}1^#{Ls@DaIXk
zTJA3SF`}%D@Vfu-;c4CK7-&z90CvAk>%wk}piZgR)jG0?gmr3ZHB)cRwR8zQE2b|z
z&4o%r4NlP#0tf{}r>pQ}f(dTT=)aNFLC%0jm7WbO7HXGFT
zrkRktWDD{m-^>A$IW1a8HhP2FmAf{ELsQ&+F!wQb-eYgL?DBoHRVfjfvK57{Z^)HWQj>ga%JHGu+y&t5H>@i4~p-XC6)UJ*xN-sef!A
zk{P9tYM#s7J^dk5WIFC=Q>@l>A_OL|A6p
zw{9t9z2T5$YfFgW_Y38hW|rHbR;z8l`Nbt*!df-f>WY2c|1|uWjZxZ~17yRRS;arw
zz@O`P@i-7|!B>M6XxJ2EPkjJ+y~tsC5tA=s9{0XjiEN8Rl?$1i%9ZOqd1QX7)9qJi
zo_Weq%-VI>8dt@Jz)YV3)7(1;y8>Hx_SE?;QGRmBQqWz;D9%|)3tP#Cin&G3v~%?S
zEjC|{Obn6onsd4RnuBSy315qs)2T%*D=KQxAvI|t4xO^)RH*Ueo6$lJ}x_VabV
z%=rO+uUNOrRoa+Two$PT
z`GBNZxMzVGwj|mgvu#!~7?Y3D$0hTA`7}Ljk<@h3+|U6GeJ0b3tM`Z_s%jarMyUfW
z;5YhWdN;7UV428^eWV8rx-|$7MSY;L(=UDqrhn}ytrz(zGZ1W1juARe
z=ehd`g>A}k@gOoa;+wY=C()~VRJ|cZrkGvHW5$ThCX*TPJVJ$sX*gQp%$g%%6M-&W
zOnaBwlh@O%qt6yS^6F$A<`fcwOf5q#(9z}cQut^le?4$gooL=+C5uU$RhEp>;-sA#;)#@P^D&(
zLK<~?msSXdh0!ITnP7&IOu)T}CZS0?WqfWLnA#Z0H9Ap{w|wO8uBw<)^5LIbk8^7jnt#L0EA75@jy1{0q=jHENp62bqhgz!2{Ce
z5|HGWj-LGablriQR6eaV*Ta6DGTnGK91fr??BO47RQ|#gKoAfeMJ^K6+GGse(tm{4SboSoIrl^18A)0D?v@Ve)QP?z9F{4+(lAA?Qi
z{R*c7U;AJaIvZ&Bfj(Gd{1b^wUW0O^lKAGpy#?DR4LU=*jo+gEsrZ-1vOKz+>k@fo
zYY-*p`wq*gxTsGvLzoIb^Xtwf@)z_*xMR3vFfa^*SG!PLNSL
zfrC(CS7_k3sq)Ia4q_vRYs*nM$ze1OQ%WW1wF=;*4m^V!W#iA5bu(~wijay-SJ%z3
z2WVu0_p6T86vP*y1mGQ{&
z+GMgBAc#i}#^7kqSSd@`m+!t!!&U>IRP#pVBw|KIO;yD&x^s11kg*M##$2g5bTj!!
zj6J%gIOJ=atiT8?$dr@eDT_mn)_nV05vm9`qO`6F5yB6;7bM9W4zg!r$XM%$-WQsr
z@k?|soJgNmPauO8v+Eee^wZb)mNU_0pN6W&q4bZ?15X*V^)P!WyUiPD2
z{hHm&^Ja&H55N^*^)~VdUh?zx0Gn9%5QXExYy1}1qa!5YD>Lvs{YFqI{QXxEaf8YhBH4Z^L
zmv6n3-QZ==Tp#HO
z+CCQ&8-giOoB5LDN0=FVHH!2giu+h$hceh;|M
z&lONUs)|cH9^<(WgrtOQaX#a-;GE~MPVasBR?jhk+tq}7tfvvK9vPW^78*T4m80%E
zPGj}!Efu_kmg
z>9_SV-|%2+I5MjQ!X!-C$BzG7nsHJ*w5-w7P;>|q&E??rLFDTXk5aCL>YFtGfP@Gk
zEvsd>MVv)9|JaXzEsM%uF!z#SOU1@T=m-aPU|ZmCckQgT>Y8O8NdJLu__ur{Mssl>
zkjXIOp=^U~H$tQ!VN%=TCznA7?(a&9?aISQ1R@KxfklUsJ_XSqK3uE&qDH*XENjZ^
zC+5NiN%&?kjcaaB&$DIdlUGT3GSq#1P`5B4hd;5dpCdW$B^B=D#e;L_ttm@PbiJvf
zwvSg=RP-y9YR2~_=Ii2Kl10m2@=rr>nzY4E!i(;;>IuV*C{2X|Xm$nn`N-Mg=Zh&%
zn+#_fvu?V$Bc1CB$RA^=6Zmdj%L*W9#m7J>L8t05x^V9cEiUjOm
zHPd5rGP~r}VFQ!97QgD|a4#+}GmP*JR3Go&i)3uc=GuVGnC=nbOM}0sTIjzI|EW0(
zA+p@;Jnrg<9Qz`cgRHo>-vv-B8J^1d`G@j%jQ7#a-brow^@d)NyP7(D*s{#^Um@Ae
z3zJ9rc#T^cjq&wRqSE%mW?sK%A8tLx%OJ>qdsjUeU0Zpq7AC#AgV9Nq0&v(l{v5KA
zqvvYvN9j^wy%GhWu%Uz#HQsfkrjcfewWqYcc8~;pab%N{AMq7D(*ULk8JZwd80~)$L@V+Ms(g+Tg))S;-Ui-R1x4ou;
zVTX@!QCScHz6xbzHqlZc7&4qDN_MBNiXz{@q>vQRYn~q*S0c^2|KoVv-sCD}ffJx%
z%ckNS*}%Ke_|YBz>(6^a`nZrhoSCXJ;g>-~g2O-_dm%zYMuT$`d5;eDZJ+OC
z_;5CoD=AMLamd%H3=W2oR<(8V#zlT!!AidnZ+Dk%CL>qt(jWLBuImyJi-=5}R!Hta
z3y|Kt&t|uoz*%-K^`(|BPYkaZ;0);Hc^tJydNfXvLoT@6K)-)GiB13fa8a+2~|&CJTNE0QA<(Q@Ma%K}tgpWHtoKQHiH4Wpm3F@QXaIwD&35Oj
zn7R2A@f%2)YmBNW@K$-)bL=PQeeEDSN%H~zoUCL$$HrKBv8-@zPc>UG
zUda{*&hHi`^Hzlyn(~{@R%T$TFTaLqSpZjAlZ2X}&Cmn;vA=0j^m}fwI?_wh_v_Ub
zCt*|io#n7~Sv~@F%5PS(36&Ay~LSfq^GbvlZeS!~VkBY^Tg12NfSCTN4(IKptT%?;@
zgERaUrbeEyjV?rk1VZ!JYc0A2Oj}xwy(2-QoOHj8-IS27Bj1gLj{PY^{uGIz%I&-~
zd0fgc_sre?x8Gsk0s^hp7B;yz0EDb;cS~%y7D+LMa3%*^yCCnK3j||?%e#);)If9x
zVAGO%VXKgYH&V1Ku1b{l4+|TZ?JasRP7HoiQk6{U#bD+9PL8APRkcF=c!z1OQII&_
zr{&Een|z+h>2qaz0(JL%(vfbH_Zl%V2(T3h{K6?Qd9iy{Y7yw1V2AnArzP`n^swZk
zFSqN+(B42!kqdrV4Plzktm|H^D$@IlUe3MRGk$FQj<7@`nP^OAo?$fFt#>I7Uix?|
zGfBZrur1kXh=L+nu2F7s@LW0~*+X|j>YWw&adKG}UU>)-Y{Ij`nyM0nO}2NJlhU)@
zXxC!jP>&Vkktuyum=snPq-@j2UPhXB(!)Bwlab~pONpch^^;z#Uo-|FPH|WUa-xKs
zgjQUai{!`AHOqO-8oUfxgMZfgwVBTiK~*frB5LqvM4PZz{&b`Hp9&@!I`id6nk}Nc
zzBoBU4=65CDhXU;~qTCAg{+GZ}>WWVU|H-ON=1L`-cP=o{B+~E{3!94n-ArE&|
zY+%A%-+%Q_-KW1uB0i^k!x9v8+QZG}A_TArpPw<`yNG@}jDPUuZ-7;$4Pt
z>NX$LM~B#78bS(@bfXiTF~tIodj@VLe9AM5_UQ<3jZJcPASn&*$q
z3$eVemmzH2bkIi@FwTeq`8FHVa`3>W`K;W?<6*8n0X9nyIX+FFRn3U`7Q
z{+Pr66Fi1z1wh(KNuV7;yNn9FH=CPv48?rigQacq?Nz3Xxv|1kS%`@+(y%dfH9A9z
zAC!xXI+0jkxJm_8V~J$eF0_OUNeV*Tb%Juu$^)UZKHe~yB@0x*xLjGAa81YD
zv9@fj?p-PPUHoLVOdJ{PEN(RJELEV4Fte_Z?|2Sv()n-M5QF3go%Ean-qT201V|dD
zA1Q8HU0=os?&8xZBbOCvCAx1ZP}(DSpcW}suT+6}8QXktv)S<)eG^Fd*p}E%maEF)
zU}Nr-6=dhh7(bn*eqzKj>^Db`;7?cC*M2$mf7T>?2fIbQe4Uc(HUf*BS{OVL=Nf;W
zKG$)=_kRR~#dcvOqz7`{OByj%?=-6;Ak=(=`aEtjlXOqev{i#v{`m;r0vEBTnYBh%
z+`=6GltrU_V}mr)0@p5^57GYn&LLG6cCV!
z_tDvBkMSSwuin0qaovF)#IsFQb=yN`!@Hmww~q>*V?rcdvM@{|CKY-bQ`T-N3*6Bt
zZ0#|ieRB3)FRurVE{c~9%gPai&TCYy&;81;9Z@>ChadJTK_2N@wspk$l^o4k`TMU~
zuiu%N*0tZlrU+rqiX7OJbS^
zdhggWQvHXE+q$BbK-V$wVGaqiaL_9%lfnTLaLV*7iTnOeXDqL
z!?yhq!nCXC(H)3{3XdgFHmPR0^^}D`+TcX4)+Phb?%c9P%~)Rt4bR;UJSu6|l{x%f
zQ7?_T2M&m=)__Kh+q26eV6@g|`mfsd1kOBZ%unhTT)6K1w`$;tSzK7r%_rrhSOs_l
zEJ0ngK=?^2*1MBEDz0fd?Y8-r=)^>sm)m;+4(K@6=_2}#&vIiVSjO~Z#UU2EYQrL?lAl?EyKjD}
z4;gEyl^30EOAiV#k-n&6jDFRhZw*NU<<~f&XqP{+ujS`}N7Pa)PYO|0owvULE4N%R
z{~KnM^}k`1|5s*ITwYLB;~z7sB>sP5Mw$Ohh(gc)|0P8EZ)rTN{}|5ygA(OGDir;H
zjuWGQsuD9g^Z!zi*wX!%T;xB}5GOikI=BA?B>fLJ`oDmrZ2#>E{7;aSftBUIfu!^d
zY^?v=s2+MICWilKlC%|63Hbt(R;m;qKbweTdTx80V*BqH1dMh9VfF&Pm_%TblWVAx
zn3yXogzJ`PZuIHbuf{9wN`U*$jcuNLc|||9iM}aVLQ5bUV`DwQJ0PM&Mn)F^eq10Z
zgpp`r{yYfhrr!@i;k=nYc6Of&{0}b(F*bk6j9f-hIir%y_#dD+*LuLZe<)(x`?}kk
zKOX=m{MaiVKc}dVUr{;L8c^O4P+V)EU)G!%@zoVKcE4>^R=&;8BLbhP44mHK;i3MA
zBo4j_v;#oBHaq&!)x9q18Ax?j_Vv5E`u5hAnv`|6+7iYk~N_&{RJ(eIRe8EC4L1Exyy=h2NX-=ntt4bs(F50F(<6)H63TQUHo!!?yg2SY(`KJ>``YYa>fAly|B}B>?91%zhM1{k{v1
z46Y!XoSgM+{?KWqSeS4XOq-4kZ+D}G=4
zb)Uq13^&h>&2?bvd~v_7{uKN(JSJH(MOFB|^?A^v>-T>QC;}!HRv(bn4a{HQZa~4g
zoGQU_{K;PWruP^uxhxf!ks=n&RN5n>lp{yM8yvde48!o_otGO7?sOfO*yv1JyPF-+pEQG&+8b
z_CIFj=Dr*MKKcE=A>{Val%Ib;0=DY7^P`SCUfn6l#A`@PHCG_is0CY6~}`5p%1
zPd)GDmf)YdruMPL;Y4HYTbiF=0)~aap>?69^&`V_;-=xd@ttP&O9nMKg;56NYkUM#
z+h8yFwjpOl^HaWJJ+~c#)kFCYYN`@WHUzDg>?Pm@pi=IO00-Yk`5m;DclaK(23XY~
z8wT7*`5MFqSoI(aff+e~6fjco7L->{&P`xOJ@KDY6TM+*n2{Gq0UoNp0&=&QvJe;A
zkC6P`y*>hRz8n9JWKVU6z>m{^BH8k|6g551M80~Qekb^>Gda=&`%m;l9nm&@&#kVu
ze*b3mv!Lero@ZV4j?dKtbE@;Aytg8pl4Z)tn#e*_=$lyBTpJl)7(Iu2&+HnF@^RwVfp7M@q{l@+7%=%V0d`q{0vHzxW;f?k_{mT2H?tbYGfx^yj&46)C|B{Zp
zXBt?3D%I^8&U`3Q{4wLFzOu6ViNf&sQp>d%{KjH$X3Y_32&8JHuA{1vttN*%fwVQaKz{@Vbzyi~rUx4}6
zZm-DLOADNFhr2aDmtL8jYyzKqU#p)`-PgbUzTSaA{#*PfW{!(4CqRIFm*wkmcnYtXos)y{YRD
z$r?BWy%p=G?qIBl7%@^~lau!_w0Y{()$f&V!D~ZCk=V_PCV=H?$$$1MV9&b`LJ#tn~ro=z0Mr-GUK!H$>UL?uvb$9E_y|%W7>{3Zy}D
zzkLzYY>yOh7_d|6{bo*l~4z)12l_HWntw_0z#aGhy)TtV1$!8y5z;mKx(jUbL&y7!g{|
zUU1N={)zd-^{5}tplnE&7Vw!JZ4I5v0!UUfqhMa8b)y*u0%0`Dg
zI--g|({Y4j^T@RuYEYH|7`}S-O>(_6*a%Vk+O2&vJ3&=K_#O7W6g~poGL{RHZor(*
z@^F8=2Khrz{0WR85u82M>-@Ji{2|I&YYxt7>y%7?T|E7ilNY)OU6t{C&8(v}
zN4bLIK~*ZPikLGI6za=5l0}?=1lI(5-!J2bWDVaVZ;3${q@#?
zXO8J|M6f4;S5-N8n1_eL1uW;>Jwxy4#lv&XxYe1m&^YiyTM@qbtCkk_^Dbh@7um0!
zt{vT(y`Id5K70#01n^^={ezIrheT3WQykWN8!<{_caEca_3n3^ryj>aDDCOW<4&VoO*`CiE#*5EGTYT2@W{-*y=rQYb2!Ik==lo7PKYv&)r
z#)r{~4*aESy)B^PRjbve{-;8SEp8;@MJ62x%UiR{m1UwuNxWwGLA}f;k
z3;AX7r!1pycg^*f>Yvp0m)vl~hl`Nczh2M+vqx>p?e?Nn@H7Fb6kiAW4rLCb-}mmy
zQfNI1^Z7p9agg0L`^LVkZ*2zVFD)#$oegTuN11g>=KQg;JPc8ptKhuP&;KH!>js-X
zC9K8-2=x;jf+Mpi{Fg+67h~B}X{C2>x~?vwHYBfmt8BKMSpZ64)?T&Egm))Q~TAF?xHnwun_6Qeom^wg&
zCa#5Zk`T&+3f3{-64{IkNV0=g#F~htoYw>+R(yA3_)7ykKA8!#KJ{eSvyM>6Qaiv_
z30JG9IM(Lvs5M^db`tu#v8m*52N<#A@n7!tmW5!wZKM%;#-oEK@
zBWfXr<(8*E#6lXD<&DBD7k}jAX_vxUYQmyXUy@0MuXS9?0{la7J)PU0u2jYdN7wg5
zvD8d#)6V#w3oN9#Eo((dyOnmEHp`l3xME9BidVCR}tXQ>igZ?kN+b(G08nF!KEH4$I;BT(I!?EeQPLsC~kZ+J-KEqL-#GxrMsZymrQkO8s
z){DG-uH5{T>~`m1O#?M+_dUpW#X~f?Pf|T+(8MB0uH1*O?kC;ix*!_dWFG8&;B61J
z-VS$NA-PfLUdT)6(cRyz!BAV&^>}hx|_xIp>h$<8wI6(EChV-
zOAI5*^?It@`^BEDVl6qiQ9z)ncduiOlutG|K&RR7^313$lXW&SvV0gj9^0{CS6zV)
zSl+pw4Jk7*0s1!Pr|4I}OxpWv4(<7|qs(EuUn~6nRa6K2Xvru+O2B(+a+OOkDXKJK
z>W*njjmO*wG?HyZ+7`|=RFD~XhHXZ;rr#!7^+`GN*E^G2B!}juB)PI6N
z!(gZ*dqe15`CDAzT~P?4+75O&nbqEtt?KXq&R*_
zC$C(bt7}I-O6LbryvY|tz0%eVdECu@b{;fy`{uS5NX)AWqBOB_sn`l9;|aPT^>gPH
zjM+UzN8O{o&F{C#;8`{>r^IS2#^g$VkLmCS6OROqg4JtTTUB9KfY`9Dn>1
zdVDe0A(T>umiL6Qo{fg5zDiZ6RwvGrsY%*?NQYNt)SCo%K-aaSWPyy1b5TDsDT)G%
z?^Wy(K!06G(@q+o$3ZGl?c%fKsSkgxyb&ByQqs;k|&Y
zPug&qRFU5@Oi9r!_JngigD+B%ort+iG2)mZI1v}tOe0SUC^#sQbEne7eb;lwny*Ml
z3{~%fvfAN+R}&*psdU=wxlte3cXPL%h!KnbLuEz!b%2E?!`=4u!11@slhC-Wu#2xf
zIfp!#1yTCpx^%M){w2XS$5M>4S*>S80sRd8FgXh1Xun;;jUoPhq_+bIq3bD#1=kYfXplJL{$Qs*Ivb5*xJuL8>KzWY&Ec~x96b}_}(s~8B)
zUyK3n%Lam+7pG+K@_pdy{YUj(PDrEL0HTM#Jt*_Y#XbR<_+
z!~lK-qlZgcp>%}N{jUqKnQj+Qg>k5lqb)t93d0+O0-Q1-{3e)wSWDi;uQPc#o5y-y
zyxzM35u^L%SxDqUDS6`8sv*guOtBG>j4^B6XLJ=T!Xq3fxwSyxoE>!c&Rz-1+zFux
z_}UBa`(&+IIKedu?f}m*jq)$RRFA=G^?X^HU5@wf&)HUcn{0E`^Tbw#v}f^-)kB=Y
zce)(rNf3-^v@wS>kVG&T2RmLJO;@BAJ>~7UVnBD5DkYBn0(tqd;Rq&&DFMOdy03+!
zdH7~KC@J|kpXwnV*6D*saePoSyd0M^L7RQFCjt2vjmPpLof&#NqTeq7%|X9jonT!1
z>;7Dfc=i&nxx?lkoB*{kbw!$C3B_>S`>%sT{20zoHZpDjGfuWK>%F8+>PE2;Dg}u*
zX15h6P8LLwP8fp#eMpFcHtC6mHV(S0Div6pdD!g-44bXV9H%dj4SGsucBvh
z*;9l_xAfc5f4*4D1IXQbsL5ELr7jZe_E&qd9(tkLQGPi9)98c*ydG$jGm=S-%BsUp
zc%9Q{Snd-9vE^<#a^)+&WRQx_gWWbt9wQAs4csIXN)9hg_M|r7#gaKb=io^IB8GZu
zx-!oelfM_n8-*GR_biG8kmT(T9lG?j+xwT&Ik;v2pogzG_k&F7ZIR=@SdpT1`*1vK
zrmaV=QIzGMC{tH8X3t{Q%pN=A-wn(A4+dwcZ5#BIjML^aL)Uh7M7nj)gr#Qv5-%c4
zhSYV@JV3=2C!Q;b1?nP0%7}`~fe6`=lMsRt5$)lFVdEO#+mG(%?QV1sZmku;s%AU>
z21;SP+b*8ery;kHk}D!*4eQANE>JsvH6`)+^EaZ1WWo7P(m5O=9JNuaoLb7~J!P&f
zM9Sw2gE5%4W61w?&93r&b3i>j+RF3R4`(~i;xSc_LL`14!l|VpRQ_(rBO-~NvWdl3
z&sx3Av9yNCcn{suy-+X)
z1(Yu(>>f;zKA~nrCZ)Qox@D0u3B7_iN2}ks54L2aWkAFESuBvc*DPAcfyElNv?Clm
zK}k2L9=~m1VKX$qzEgCPF9fG7xIK{8RT+LyQ*00S
zeKT7br|2jfqTx@9$D#bx1cI$4uT>6-yIb3*rhj=`OoN`g7WLc`TU9)Z!{4HxdA
zV!4EAy4xzVc6gq(t?5hAes0%Vjk`#;=dJFa9f#VYt+Dj%;_G}#{YDghL9&ZRW`W}|
z#8`im(qzzc;WZcjbiHqtD{ng^ohjJ{rrt3WTT1Z}Yn6xQB;Daa52YOCwdTvvS04&8
zW*+9%t1g+JHqiSGwK13z2SH%_NPG*hw2D~Euvivk3^ha$y%s4{x9)hCWh$A*Oi#
z6&(Z23OhMqia5DI-yR~)ds~P(iLdi3a{Bf)4khNw!|RRqu;YQgI~XJJs46$t+a^OPa>tq&LCD2G
z5}yQ-?w3aI>jgdXdKd-%)ExeA(8?G_2kiSUp8ABZMGwH1!*o!tb%n3+TG1)^H-CH7
zr>_A9u&CEnUCsO+#a)BXMJoo^#frHWx#3DS=d(m&4pdFN9)){gSxj7ja!Q{j6Kt`q
zkoRV#gOgg5#2PLc(c#8jJd%xyK6+haJZX?3wXhMVOQ)aN+D56FIN~+o$cEaT@>N&t
z?jeJ|h7fF5@{O#5w&}dRh6)CDxj!6Q_Xc1m1ZGc^tNJi~7CtF=lK0ysVK6k+~zTvhJ
zk}?Riuee6ccHqv;A-D{q2ld^OpR&^rURiZ#hb#vRg&GpZcB6F@ppucMG9Bk%-IYP(
zA6ibs0g>f1x9_N|N`-HRkh(+tZRFIB=^i~Bl0+dCZB2|Gf%DO55)&_
ze-62A#WznHFqL$}M$Bg|T^cA)LD#^;PCM3Joh$itC+%GVPQVR32$yNu2`9_!dBqG$
z+Ue5*m$c1Mt+r~s7uw!eQSHEJnrrGnL4aGEogoK~tF>5_
zhIcH38i!|h;K_!vygT+9Br=HZIj-;0wx6cR@2ZNN8RuFV3}3fW!4StyP#xMj-9OcI9c;&5=)oa{m_cD~
zI>$1!XySxIG?R{kws32Tn}4e21graQ9;RQ1f6P#qj%J3MsB~mr<+ne)BtVQ*91>>!
zOesd>7&Tfzv_R$KR3E1~M;WpH$@_9C5JUJaHjQC_w?S)$+|4NZV!ht~p{L^Ob1?{4
zLjPv29^`4IM7bhRUHE6YQ6fI_)<
z$0?|~#5<2~Wn*@KCmlf4@1!;o?$$~Qz9nW9LAys8Ohdybl{6)SRI@u_dkdRNqGHSP
zI1!j>+@Ke2d^Z8Hp{bA=JLL&=nlI09@{q(Mhqqs_!jy|2UQDx#3Wyj%EnM4K$aD+-
z2GG$p%y;{a7*{s`iibz!fDcVGO7N4h6>yAuiaJb=WQ$log(F~4(bd?*Yu;Lib=>ww
z#z-^nDIy!(_~!6}l?i9b?=)B-<2CH6;O<6q-q+U~UUrYS`0kk?c6qAMd9$i`(9liM
z!&I}&Xr;`0SLfCY-%)mcd$X^tj(7n?5I*_Lhy6^hoM^?{M=Z(jG>x8Dg3NA69l~yM
zr9}`%p?nItnm-^uOCSB4bnU*)cq`d64UaL9zen7h?r3+sol;IMb#w8yBirp#+j`tPs
za~ot#u5>j0)v3Q!sK-S@=jd28K|VWEf*YD^SyoGLU=%8k20FQ=TL(v^w_uy~5Z5U_
z^Xgrlvg9>$)IN4OEtZN&t!maK@NA$IctI9+W5SXVMKHU;nG=cKShSJm+5f8aMCjso
zQJOQMle<^5N5^u^VIPxWQM?22iykhTBk)??eDUoFXCrY{wkG`RVFW%PWxuNmU<*}W
zb`q+UL_*QhwZ1iLIFp7hZ;nFC>M(ArH+Tgq12b_nZpb0d5?eL8>*dbFZu<6Sg%5CI
zn(L9gG-&Y#)bKJhzS3ZIRtqyZ>8!MNm(m&aa|(YUQl26*`1UvG+17%;d>aqiI&gj4
z!cae{C0H}Oho~>C@?y}p4P<+^g2yahXAbvWj#UaorlU$=Dq0*WzM3|s=?psfk=HMR
z7hfK>h919phM6s5tX=
zK|c?YvCj)s@c}2->MzAUZnpXloEA^v@Kwg72a9=M%hGaow%BKx(F!J
zx$WoU=uInF>I)y{#4`U&bk$dLTQ(LwdOc$v9J3SeXBu*_yj2V*MHgmQjLn)2enFCc
z(DGWb?O#-a85QlJ-wTzPTlYzu<-k=Hf*H@Ho1Ve4fu%nUu>#h1KMu1z%h4+Ik(FC8
zYzo1?kd=esw}?*lLfA+w*k(x^L;f!R96rp~U~)jMkx))-~=X0#X~60`~l;lS+P
z3G@p*lFQ**y{X5M@>djW2VTtOL^==&s==^k6nEM4T;r_rFkG`(!VcyS$#x93MW(5|
z2E~sRm;@Y0;Oj@5;dEXv|Hf}f%fhE%pC#6%o1*{jV7l&xR4S6VeuxqAgIj-McjLyZ
z;AxkiG8jJ)$UBsA)Gip2#R*~TY4Li!gf&E
z3&QDLxrv0nXfJW5R0I9qrRf2MWOMkGG==jNd7}q_ab?uQZV*$2I|$P_tkHYsiC|@~
z^~GF12cY2Z=>0bfkr1&Q8(9ZXx87OhJ0LoJYA{r6%pe6vP;o<(Y$=O`=`-U~c9xi~mI9jKh@fM3K
zTU)(HYtPx!7G-*XV$QqhhDA9`1vP($C^^x!E!_PC7nPjZxq2<^s%y>g{m-EH?b@9-
z3ik~nSF=9+JMt_);iu&!!ILtM5x*042T8L6Y@q`^Y}6Tu^eVIU8pUkbcm+);IyI7{^oLobOP`PUk
z4&jryv)s`t7GCno9^jMw`0dNiC_OM=@&0B`XuJ&99mx|WV*+uqMtU7$1K|WvcY?d^
zq{P*2<@}^Ej*W)1y~oXBJeS*3RqUgYoKn5_l}2nf7)3II)hw-AScaYZg;GZ`>sLf)
zzy^g>Q5_)J|a2s*Ge4S+BUx)
z!`_NSD0*AGZYpz`gXY?Oe1>Hv#nmRYQBDb&%*0iDF)rP|x`gkmp{2IxQEzU)Za);+
z`(KWV`EmHOD<>?p>^At(uyl5=F|RGFUe1L9-`*0=Mv_ALHh0*Rj}-ix#|iOJIWbF!lPQp5)u`vPyW$2^m}_vlxS35G
z(2&xWz?a~>i%@vWGi<{+vsqQXMA%|)Xu@6OxFqLOi&7gA$%;}^p8&6j3I(%?YnY{C
ziWt4K1$1WM9pk;1B%5?zxN*XJYTO&wjGjLNnaYyf>(c<;nHXx2pCUyRb~27$p!6#3
zi8tLmlhMpQdoAYEf{_>i$;`3j**D+Cjk1=r*Vg66uv
z4s(aou2Ue2KE6N3o1(-&rR2KQ)#*YcMMv}mV{~VIGSBK9QIm}^lq9*QaSIMcdv#Js
zZ@@y(V}9HLa2Z-t7O!`3k-6>O#~+4VsPj+ep{|V>#wYQ`yTt1@(jiu@eKbR9&Sgu7
zmN|^q+Ih5_nX6_BaGqS3KPR0uSdtLEljli7;3iRA^Pn
z7Q^%s6SU3Zq~;6vjjmsyVdOgoNJPW^>&;S)*z*;@6ns%CH)P7$tw6620{D>Ol^gCy
zi;)(Uz)R+cR!_ka-Mn@}w+(z=T{C2XodmkNSlu>GNmM!;x(|Myv5
zW`Fc&aaft94G#_=Lq-r?($OO=F=|;q(Q}4j{0@_N>g;^F_`$GDWDm*30_+^Fx%<05
zp5qViw*c12&0U*Qe3Q-G!X(m{gV5>2lP&m&fO?tMeb*!lt>bTK6tT3d&|r#96p&+k
z*8ThW)f>;v_{ES0DHX{&G$1BH-R_SH-d_2$*cw8vrE8)bss~jUX~X3chFB@9FNYUh
z%z_i5@&5O-TJadAYItzM51oZZ^gZBaI>HYyFW|tkgQZf#)N5oK|BvQU?6k^8YZ?R(
zpmg)N1>`&3-BA2#$R@DoH=Y2OPl0m-J%`IjxCb|BegEZ?FWs=#GmQ$*bdQ^8lOz-W
zgut(5nhguV5JgO}BmUPqWJ~j8GQiY#SdhSYm?Pgev!J0e|FHnXh;dP#GkdOrHBibO
z%l0bqs$)7ZWBxxldf3M2wMZm=}Gug8SH(n
z9kuP@RNP)0v@b(rG(7k`b$4+4MA
zWnFG;@4vUUW15rgbY&0#UD}&9c;cb`Pb>Kd)A>HE;tG)*`h5u+Y4DP!U(VSCyOH3c
zKWLILLX2(1=~6FzN7~2;#p>SumS&Z!)oH<<{Ym}||GyoU-p@%u1Zb@7gK-po923b(EF1JAWyVRPZgwB?X7*Bt}y6@A@Hb1
z+sGCk!Sz>3c3pN|%cG&HEmwr-8
zjcae6rAd9~!w%40bau;g-d2@SKL{n0Vh3MX@2JZDiTaM%Z=>Ck6?xHBd?v
z*DFQ3DaVc@C?_%hlZ2)!T#m-O0~r1?csMMVID)A#@-<+ND^JD}ArTm@@|e=NP=eN0
zy(h0L^qOcq-fBZ`hNUs10xTbqH2V7nVh9PJX?~ch@r9mnYWKAm85oLgtm3C2uDd(;
z7C0vc_k9ZNCE7b44}9|Dg6+tST+1bc3jp6@%G3P896ubZj6#5ry>h%`H``1N;^v}>
zCU`QNm?pB!aO2DYH1dV$mDKo5x$BpUDH|z1DP7wN0Y(>K%PY;xt3KsRpaR&5-XP#F
z51(48^R!dx3go%EIA?lq)dlH&$(j
zsHTf0X1!dBa1))4YIJ*XKL95qyyp?^F8Hu4xKyESj&1+30gv0vn+I<>kW4*(ik2baOYu;|$06i6?cnpd&wZ%B@q(p9)b%AxL
zzBHfhR<7HUh%}F{e(OExuRWWNp+a&+tq%44BkoE>J}iatAtb?Swzbkso|
zN2I~}phURknia?t5qYAW{Zns^lLItnW%%youlCSa>DSfzQA%Gx1EK&rwK1x)k*e4r
zgg)8W?$&M1r~J9zt}!j~BwFVZRy&$y6*8^nqnso39ls9_I?#ducX0q6_<~81FzNKe
z)V%n_=1J8|cQetRMO_3Vl|DnbHxFmNGBIa_DU`TN$V^pxsfPb!Z#IsWKd(;w4#%(v~t~uW#0#7;Q8ZEle*qu)h-XHSrR%Ll_
zAkhnHS5OdIZbf(9Pl$ObkRX2R(5BE+62;SUGR{_
zuaBjAt`7-xSD}?+{v`pr{MoPKqI#KE&%L>64Mk2)HgYw&!soy%09{?~y(aU}-rDt8
zVu<)XP=D4E;pWxdF^zilRAU8;hF(RbpZNi&Bb;5Njv2ya)5&n47;rS3Ca`M?zk>(@
zs}*X76jg)a%E9mU+lGx;+abdgelkSq;@Xk%aLVVEMy3o!(&(}w`E*BWY0n?LZT_{S
z$?9q1itd_OFSwA~_%F4yyVXYR`x9P|!Vjm)1N-ZMT?_Zu($Eh&sxDd;vmt(ck@NxI99C$Nfi
z!{tQR3=J+uzeD|XkCberkFC&ENhtdir&%sEZGedM+%VH{+oTCX^1DX~e00Q#>_1Ab
zmt2zr8MkykY|Y|bZCdyThZNr8sV^^GtwSKtbC}3+ode#82D?rS8zui68Zyfn7w*b;
zHWA$^ZosjJ0;qbd8Mwn0vTh%W)bD~JeCM7x9Zq~CK3GqoU`QOI1gOU3(NC`3(;%u~yvq4ns5-rzdE(5*rD
zUI}Zt=yI+BA|j8N`gP>`05PkQ1-ijyLFrK`5!PSb?9ZH?U_L@`TTuzqhssM^(X#@a
zJP(W6bs>X9E|)
zh(jnhe@g7==$|;ZOP?SPUJW0btucAybo^uokhDX(m6hZEbCIfP^99Otv~1^RIpb&5lFf8
z^0zG1EDZ@Wl1Kx;4QzR+oHyuOTQ$qg0FeJkLiBFGc>)Xhy*
zs1jf`L56V4dqeyY&`1>)Jo-6)X-{st&O^?WBlRlPV6j}yF50YmGWJV9mBp(^#=G5l
z32q^NeTugqZcydbX$v5^pWpEHHYNxN?8SUML2BK>RL9_5A}L=h|Jru
zEg@?v+yDtPYqhlwB0+dgqC#VtpkHPdW{dQ<3?647*bbFY%F#M_c}L;|
zX^$5=lT}Uwsh(%VmX*G&?#ER^ZHs)pKYL&rWQK7e^NF2u{l!6Ah+;{+Q^ltTEB}gd
z{<>6c3wvkPg0UVC)q)HzI=!WIb-Do*~xN73AE!9!8)o2
zLW{wT07S9aOjK>G?KA@9Mb_6s8}bsrPbe%ciDQsn^9fdncllHRh-#2DnFrgTBClLp
z*F18oL^P9WUp=HXId>FWcGm$rEHy_oQ{!`9OS9m0PknCe%q^hDR!oZ9(v%&0J(LL0Iw8*|F0-+&-c_
z{lzJwY`RyO7dmnYj*6S43t$0~JV`LfBhjLIq84hPCD5S?e@t^ug1rw>hFlNL&HrSU
zxUgjCrEw9yL{Ny{w*0<20dDGg7V_Gg{molB`+(2yw`CEYMtL()RiSYnG=g)Ddpsm>C
zbGd0%_ajc~8w_%0UuVkb_Ne_l_?|fws5?yr#X=gBK>k@77Uhv7G6pmy&RwY5I~5wZ
z>mi)2IMEJaopg>55gGSGEd`U#OVw6kV@TR5$eYPMqo`gp>7L2`y)ae3E#`oKxh>2b
z@}Lmh_P544t`3uf(?S;m$RXcJE*iV8=e?&5Uj%&PBduzTH19q@AVJDe@QoKyo@Ixq?o7)o@)Rh*m6r{V{jB$zx=~dWlMVE(P@s3&j)?2yr
zD`i8VXi}|8bcT`g-?Td$nf&Dms8($}YXY;UJ7vr-R{9CI4dKJ$NOm39*!nR#_myNf
z*n-eNLG?&n@>y76?f2CX^R5juj#U?bsj0moaR&1DU!M)LIWAmy_*R
zS~?bf&FA{Y7?=5#{n=Y-U`c??OCNJy-JIg0R<6>;VsqIA1V2-WU
z;CYhNx25TSP{g=AC#Doa^;I9$);bogcu?*@{TWJt(_$pi!x>-wm!+gi1)ud2tYtkuK%=pxqj{i3>}6|_YwYF*au
z@wq-ui?-PPCJ{*n)HNq3=iV>(@w?ymyZ6pNzxfuvv_AefgEmzqFIY4@tzr4AJX(2n
zTh0Edx7InkN4zufjpV~anqU5AMcRaUzdv<5bj5b{x%b?iV-_zwR#ewO9{x1u=;FIW
zK7VEF?5OX$^gX<6?SduWelqm_@!9F!%Rk%GZGNM^*+>~iY_2y;>-wUp+cWa+4czzl
zw7%5-`0TP>JvY4>a`fe;+9USR8A-j97G2oduju#|!=uI5^5B&VwT;*A#qXPy-8p4v
z<Xf^e~uV_BD_)#o!KR9*jC^luo~!a~M~=kI
zDG061OPP?<@A$G!_>aXoiv~sP@l+SCpIdvv-s7ft=Rp3E(pjA@)tTmec|mZT_xxn~
zX!xxjVIwLp@{L#GPfxqvpPt_L`X)4gt)o}@e#iL9-A;aU_ss#sTSqMy_k6f=`1r&o
zJnOgTe|l8fka#e;?v7^mT6T3v_>PK!1-lIkD_7@)ou_KI&YO4OUGLti+f6Ci0}ghy)sJiLS{uLb7ExBb!%!FVxsEByX`J#)
zZP?{Q=NyCI8$`x+QW@wTD;}`d21i;7*AzD&E5F&;bavsEQOoC-{_c+-pR2t1=^4kC
zpJ#U1nDI)J>gM@}QT3#I;DC@r?swVOjKk)9s*09kza(K%bu5JtgYZ)j4;j
z9r?@0JN9;ro3qHcxp}i{N6LjOm-cXn*6mv#AGP~r^5F3?XG*Q3Ha44%P3aawzI5;V
zkh=bvKZNd`V!LqvY~%@7ZOX(ETMD<$q9@)djY|BwOXuEQmN*jj=KRV2zH0u-KbSYv
zHdGz!I&?zE_oG&>9_O
z1!x+dr|OJPFc_0fvZ^!vDXLCc)Jc(;My@{n
zdXS_FB}lB3H|t$CCx_uGlqPZc8JPCzSwQq?G%}!ABr7}P(HN9~646+cgpyGT8i!Jm
z38kTQ^ft;wS)lx6^Fit9VODa
zJCsC}E3#(J$ywnaxg^R<@D&}L^u!Eh{~u;#7My|$e)IEL5S&^BrxOO@5Le)3ors%i
zcCz`%ifqUxaxBaWf>e94+YayH;ZYuPfHu|1!5e?`kqfza7l&Nl{9FLf+gwOM0vO!L
z&5E4MH?^SBEHb$jP-O9QFcg@)T_}XSqXOO1zHa(iZpk!d>&K=8
z6cg}YiNrsAfK$}!rywD51(No&{yYnbDJd>dpC%(|>l2E2j!z(1E#V;*NQf7QlALNv
z8Jz%7(z4rnh4RNgz$=8D(B}zNpz;_Bp;UDfvX@?rwu+2M!Bl})v?-_}>%&`+P*7<>
z;^$O!G{(6s06^9LQT(j%7=vZ@3LtGb>q~jmf`lMp$F)FFZe`g?FXj`)-JpQdhO|^r
zc*s_-kbYLRdWDb;!B|pR8|Q)hMDW5P0xTQLTRhlAAIC7l$An3$)&bOQ18iX7wh?S9
za;n>GQ-4<&)mo<_ISL5LX4rif3KEdIn3I%gZ70%jNIM%Vy
z*ij@-XmExiaQVZG#5Kckd>FJ#7A((ek}k4tH)p|+k#%}F0Gb|`6>ju8ow=;bC1Xjq
z^BxSoeoP~<4Ec%>To@Hjs0odZq+4K)B*RG`KrD$b
zAW2FK*G6DFuxWMR|6m(M!6SvjM$#Gxc5pjVL$n!>B5~kza61a8f%6KRno;xxU(xN@
zG&JxzurH3oyT5^Efi_r&j%?FT$54uPFb4y<(}McqKpDENO+za25d2363LA}UwaRwzKq%k#
zL46s5z?JJ@2pU(8$1pUl^Z~;#I^`TXn$RjS>u9yoe*_NhQ>>T3wIrp$0-o10itz}N
z(x?^qz(&K)c(OK0WO*kisv;vXl*X5E^4>xwL69)tK?M&P2`;OEsr_dXN{GcKM$&qX
zQBN@%gPu_vW8>g~S*=&cX>p1nHMo}1MPtuzG6{>0R(T{=lze*{V1eIMLx;wVGphav
D+2)q<

diff --git a/elpa/org-plus-contrib-20150831/ox-gfm.el b/elpa/org-plus-contrib-20150831/ox-gfm.el
deleted file mode 100644
index f7acc946..00000000
--- a/elpa/org-plus-contrib-20150831/ox-gfm.el
+++ /dev/null
@@ -1,193 +0,0 @@
-;;; ox-gfm.el --- Github Flavored Markdown Back-End for Org Export Engine
-
-;; Copyright (C) 2014 Lars Tveito
-
-;; Author: Lars Tveito
-;; Keywords: org, wp, markdown, github
-
-;; This file is not 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 .
-
-;;; Commentary:
-
-;; This library implements a Markdown back-end (github flavor) for Org
-;; exporter, based on the `md' back-end.
-
-;;; Code:
-
-(require 'ox-md)
-
-
-
-;;; User-Configurable Variables
-
-(defgroup org-export-gfm nil
-  "Options specific to Markdown export back-end."
-  :tag "Org Github Flavored Markdown"
-  :group 'org-export
-  :version "24.4"
-  :package-version '(Org . "8.0"))
-
-(defcustom org-gfm-lang '(("emacs-lisp" . "lisp") ("elisp" . "lisp"))
-  "Alist of languages that are not recognized by Github, to
-  languages that are. Emacs lisp is a good example of this, where
-  we can use lisp as a nice replacement."
-  :group 'org-export-gfm)
-
-
-
-;;; Define Back-End
-
-(org-export-define-derived-backend 'gfm 'md
-  :export-block '("GFM" "GITHUB FLAVORED MARKDOWN")
-  :filters-alist '((:filter-parse-tree . org-md-separate-elements))
-  :menu-entry
-  '(?g "Export to Github Flavored Markdown"
-       ((?G "To temporary buffer"
-            (lambda (a s v b) (org-gfm-export-as-markdown a s v)))
-        (?g "To file" (lambda (a s v b) (org-gfm-export-to-markdown a s v)))
-        (?o "To file and open"
-            (lambda (a s v b)
-              (if a (org-gfm-export-to-markdown t s v)
-                (org-open-file (org-gfm-export-to-markdown nil s v)))))))
-  :translate-alist '((inner-template . org-gfm-inner-template)
-                     (strike-through . org-gfm-strike-through)
-                     (src-block . org-gfm-src-block)))
-
-
-
-;;; Transcode Functions
-
-;;;; Src Block
-
-(defun org-gfm-src-block (src-block contents info)
-  "Transcode SRC-BLOCK element into Github Flavored Markdown
-format. CONTENTS is nil.  INFO is a plist used as a communication
-channel."
-  (let* ((lang (org-element-property :language src-block))
-         (lang (or (assoc-default lang org-gfm-lang) lang))
-         (code (org-export-format-code-default src-block info))
-         (prefix (concat "```" lang "\n"))
-         (suffix "```"))
-    (concat prefix code suffix)))
-
-
-;;;; Strike-Through
-
-(defun org-html-strike-through (strike-through contents info)
-  "Transcode STRIKE-THROUGH from Org to Markdown (GFM).
-CONTENTS is the text with strike-through markup.  INFO is a plist
-holding contextual information."
-  (format "~~%s~~" contents))
-
-;;;; Table of contents
-
-(defun org-gfm-format-toc (headline)
-  "Return an appropriate table of contents entry for HEADLINE. INFO is a
-plist used as a communication channel."
-  (let* ((title (org-export-data
-                 (org-export-get-alt-title headline info) info))
-         (level (1- (org-element-property :level headline)))
-         (indent (concat (make-string (* level 2) ? )))
-         (ref-str (replace-regexp-in-string " " "-" (downcase title))))
-    (concat indent "- [" title "]" "(#" ref-str ")")))
-
-
-;;;; Template
-
-(defun org-gfm-inner-template (contents info)
-  "Return body of document after converting it to Markdown syntax.
-CONTENTS is the transcoded contents string.  INFO is a plist
-holding export options."
-  (let* ((depth (plist-get info :with-toc))
-         (headlines (and depth (org-export-collect-headlines info depth)))
-         (toc-string (or (mapconcat 'org-gfm-format-toc headlines "\n") ""))
-         (toc-tail (if headlines "\n\n" "")))
-    (concat toc-string toc-tail contents)))
-
-
-
-;;; Interactive function
-
-;;;###autoload
-(defun org-gfm-export-as-markdown (&optional async subtreep visible-only)
-  "Export current buffer to a Github Flavored 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 GFM Export*\", which will
-be displayed when `org-export-show-temporary-export-buffer' is
-non-nil."
-  (interactive)
-  (org-export-to-buffer 'gfm "*Org GFM Export*"
-    async subtreep visible-only nil nil (lambda () (text-mode))))
-
-
-;;;###autoload
-(defun org-gfm-convert-region-to-md ()
-  "Assume the current region has org-mode syntax, and convert it
-to Github Flavored 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 'gfm))
-
-
-;;;###autoload
-(defun org-gfm-export-to-markdown (&optional async subtreep visible-only)
-  "Export current buffer to a Github Flavored 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 'gfm outfile async subtreep visible-only)))
-
-(provide 'ox-gfm)
-
-;; Local variables:
-;; generated-autoload-file: "org-loaddefs.el"
-;; End:
-
-;;; ox-gfm.el ends here
diff --git a/elpa/org-plus-contrib-20150831/COPYING b/elpa/org-plus-contrib-20170407/COPYING
similarity index 100%
rename from elpa/org-plus-contrib-20150831/COPYING
rename to elpa/org-plus-contrib-20170407/COPYING
diff --git a/elpa/org-plus-contrib-20150831/README_ELPA b/elpa/org-plus-contrib-20170407/README_ELPA
similarity index 100%
rename from elpa/org-plus-contrib-20150831/README_ELPA
rename to elpa/org-plus-contrib-20170407/README_ELPA
diff --git a/elpa/org-plus-contrib-20150831/dir b/elpa/org-plus-contrib-20170407/dir
similarity index 100%
rename from elpa/org-plus-contrib-20150831/dir
rename to elpa/org-plus-contrib-20170407/dir
diff --git a/elpa/org-plus-contrib-20150831/etc/ORG-NEWS b/elpa/org-plus-contrib-20170407/etc/ORG-NEWS
similarity index 77%
rename from elpa/org-plus-contrib-20150831/etc/ORG-NEWS
rename to elpa/org-plus-contrib-20170407/etc/ORG-NEWS
index 779ed761..51c516fb 100644
--- a/elpa/org-plus-contrib-20150831/etc/ORG-NEWS
+++ b/elpa/org-plus-contrib-20170407/etc/ORG-NEWS
@@ -3,10 +3,994 @@ ORG NEWS -- history of user-visible changes.           -*- org -*-
 #+LINK: doc http://orgmode.org/worg/doc.html#%s
 #+LINK: git http://orgmode.org/cgit.cgi/org-mode.git/commit/?id=%s
 
-Copyright (C) 2012-2015 Free Software Foundation, Inc.
+Copyright (C) 2012-2017 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
-Please send Org bug reports to emacs-orgmode@gnu.org.
+Please send Org bug reports to mailto:emacs-orgmode@gnu.org.
+
+* Version 9.1
+
+** Incompatible changes
+
+*** Variables relative to clocksum duration are obsolete
+
+~org-time-clocksum-format~, ~org-time-clocksum-use-fractional~ and
+~org-time-clocksum-fractional-format~ are obsolete.  If you changed
+them, consider modifying ~org-duration-format~ instead.
+
+Variable ~org-time-clocksum-use-effort-durations~ is also obsolete.
+Consider setting ~org-duration-units~ instead.
+
+*** ~org-capture-templates~ no longer accepts S-expressions as file names
+
+Since functions are allowed there, a straightforward way to migrate
+is to turn, e.g.,
+
+: (file (sexp))
+
+into
+
+: (file (lambda () (sexp)))
+
+*** Deleted contributed packages
+
+=org-ebib.el, =org-bullets.el= and =org-mime.el= have been deleted
+from the contrib/ directory.
+
+You can now find them here :
+
+- https://github.com/joostkremers/ebib
+- https://github.com/sabof/org-bullets
+- https://github.com/org-mime/org-mime
+
+*** Removal of ~:sitemap-sans-extension~
+
+The publishing property is no longer recognized, as a consequence of
+changes to site-map generation.
+
+You can get the same functionality by setting ~:sitemap-format-entry~
+to the following
+
+#+BEGIN_SRC elisp
+(lambda (entry style project)
+  (cond ((not (directory-name-p entry))
+	 (format "[[file:%s][%s]]"
+		 (file-name-sans-extension entry)
+		 (org-publish-find-title entry project)))
+	((eq style 'tree) (file-name-nondirectory (directory-file-name entry)))
+	(t entry)))
+#+END_SRC
+
+*** Change signature for ~:sitemap-function~
+
+~:sitemap-function~ now expects to be called with two arguments.  See
+~org-publish-project-alist~ for details.
+
+*** Change signature for some properties in ~org-list-to-generic~
+
+~:istart~, ~:icount~, ~:iend~ and ~:isep~ now expect the type of the
+list as their first argument.
+
+*** Change signature for ~org-get-repeater~
+The optional argument is now a string to extract the repeater from.
+See docstring for details.
+
+** New features
+*** New Org duration library
+This new library implements tools to read and print time durations in
+various formats (e.g., "H:MM", or "1d 2h 3min"...).
+
+See ~org-duration-to-minutes~ and ~org-duration-from-minutes~
+docstrings.
+
+*** Agenda
+**** New variable : ~org-agenda-show-future-repeats~
+**** New variable : ~org-agenda-prefer-last-repeat~
+**** New variable : ~org-deadline-past-days~
+See docstring for details.
+**** Binding C-c C-x < for ~org-agenda-set-restriction-lock-from-agenda~
+*** New value for ~org-publish-sitemap-sort-folders~
+
+The new ~ignore~ value effectively allows toggling inclusion of
+directories in published site-maps.
+
+*** Babel
+
+**** Support for hledger accounting reports added
+**** Clojure: new setting ~org-babel-clojure-sync-nrepl-timeout~
+
+Creation of a new setting to specify the Cider timeout.  By setting
+the =org-babel-clojure-sync-nrepl-timeout= setting option.  The value
+is in seconds and if set to =nil= then no timeout will occur.
+**** Clojure: new header ~:show-process~
+
+A new block code header has been created for Org Babel that enables
+developers to output the process of an ongoing process into a new
+window/buffer.
+
+You can tell Org Babel to output the process of a running code block.
+
+To show that output you only have to specify the =:show-process=
+option in the code block's header like this:
+
+#+begin_example
+,#+BEGIN_SRC clojure :results output :show-process t
+  (dotimes [n 10]
+    (println n ".")
+    (Thread/sleep 500))
+,#+END_SRC
+#+end_example
+
+If =:show-process= is specified that way, then when you will run the
+code using =C-c C-c= a new window will open in Emacs.  Everything that
+is output by the REPL will immediately be added to that new window.
+
+When the processing of the code is finished, then the window and its
+buffer will be closed and the results will be reported in the
+=#+RESULTS= section.
+
+Note that the =:results= parameter's behavior is *not* changed.  If
+=silent= is specified, then no result will be displayed.  If =output=
+is specified then all the output from the window will appears in the
+results section.  If =value= is specified, then only the last returned
+value of the code will be displayed in the results section.
+
+**** Maxima: new headers ~:prologue~ and ~:epilogue~
+Babel options ~:prologue~ and ~:epilogue~ have been implemented for
+Maxima src blocks which prepend and append, respectively, the given
+code strings.  This can be useful for specifying formatting settings
+which would add clutter to exported code.  For instance, you can use
+this ~:prologue "fpprintprec: 2; linel: 50;"~ for presenting Maxima
+results in a beamer presentation.
+**** PlantUML: add support for header arguments
+
+[[http://plantuml.com/][Plantuml]] source blocks now support the [[http://orgmode.org/manual/prologue.html#prologue][~:prologue~]], [[http://orgmode.org/manual/epilogue.html#epilogue][~:epilogue~]] and
+[[http://orgmode.org/manual/var.html#var][~:var~]] header arguments.
+
+**** SQL: new engine added ~sqsh~
+
+A new engine was added to support ~sqsh~ command line utility for use
+against Microsoft SQL Server or Sybase SQL server.
+
+More information on ~sqsh~ can be found here: [[https://sourceforge.net/projects/sqsh/][sourceforge/sqsh]]
+
+To use ~sqsh~ in an *sql* =SRC_BLK= set the =:engine= like this:
+
+#+begin_example
+,#+BEGIN_SRC sql :engine sqsh :dbhost my_host :dbuser master :dbpassword pass :database support
+Select * From Users
+Where clue > 0
+,#+END_SRC
+#+end_example
+
+**** SQL: new engine added =vertica=
+
+A new engine was added to support vsql command line utility for use
+against HP Vertica.
+
+More information on =vsql= can be found here: [[https://my.vertica.com/docs/7.2.x/HTML/index.htm#Authoring/ConnectingToHPVertica/vsql/UsingVsql.htm][my.vertica.com]]
+
+To use =vertica= in an sql =SRC_BLK= set the =:engine= like this:
+
+#+BEGIN_EXAMPLE
+  ,#+BEGIN_SRC sql :engine vertica :dbhost my_host :dbuser dbadmin :dbpassword pw :database vmart
+  SELECT * FROM nodes;
+  ,#+END_SRC
+#+END_EXAMPLE
+
+*** New ~function~ scope argument for the Clock Table
+Added a nullary function that returns a list of files as a possible
+argument for the scope of the clock table.
+*** Export
+**** Implement vernacular table of contents in Markdown exporter
+Global table of contents are generated using vanilla Markdown syntax
+instead of HTML.  Also #+TOC keyword, including local table of
+contents, are now supported.
+**** Add Slovanian translations
+**** Implement ~org-export-insert-image-links~
+This new function is meant to be used in back-ends supporting images
+as descriptions of links, a.k.a. image links.  See its docstring for
+details.
+**** Add global macros through ~org-export-global-macros~
+With this variable, one can define macros available for all documents.
+**** New keyword ~#+EXPORT_FILE_NAME~
+Simiralry to ~:EXPORT_FILE_NAME:~ property, this keyword allows the
+user to specify the name of the output file upon exporting the
+document.  This also has an effect on publishing.
+**** Horizontal rules are no longer ignored in LaTeX table math mode
+**** Use ~compilation-mode~ for compilation output
+**** ~latex-environment~ elements support ~caption~ keywords for LaTeX export
+*** ~org-edit-special~ can edit LaTeX environments
+
+Using ~C-c '~ on a LaTeX environment opens a sub-editing buffer.  By
+default, major mode in that buffer is ~latex-mode~, but it can be
+changed by configuring ~org-src-lang-modes~.
+
+*** ~org-list-to-generic~ includes a new property: ~:ifmt~
+
+~:ifmt~ is a function to be called on the body of each item.  See
+~org-list-to-generic~ documentation for details.
+
+*** New variable : ~org-bibtex-headline-format-function~
+This allow to use a different title than entry title.
+
+*** ~org-attach~ supports attaching files from URLs
+
+Using ~C-c C-a u~ prompts for a URL pointing to a file to be attached
+to the document.
+
+** Removed functions
+
+*** Org Timeline
+
+This feature has been removed.  Use a custom agenda view, possibly
+narrowed to current buffer to achieve a similar functionality.
+
+*** ~org-agenda-skip-entry-when-regexp-matches~ is obsolete
+
+Use ~org-agenda-skip-if~ instead.
+
+*** ~org-agenda-skip-subtree-when-regexp-matches~ is obsolete
+
+Use ~org-agenda-skip-if~ instead.
+
+*** ~org-agenda-skip-entry-when-regexp-matches-in-subtree~ is obsolete
+
+Use ~org-agenda-skip-if~ instead.
+
+*** ~org-minutes-to-clocksum-string~ is obsolete
+
+Use ~org-duration-from-minutes~ instead.
+
+*** ~org-hh:mm-string-to-minutes~ is obsolete
+
+Use ~org-duration-to-minutes~ instead.
+
+*** ~org-duration-string-to-minutes~ is obsolete
+
+Use ~org-duration-to-minutes~ instead.
+
+** Removed options
+
+*** ~org-agenda-repeating-timestamp-show-all~ is removed.
+
+For an equivalent to a ~nil~ value, set
+~org-agenda-show-future-repeats~ to nil and
+~org-agenda-prefer-last-repeat~ to ~t~.
+
+*** ~org-publish-sitemap-file-entry-format~ is deprecated
+
+One can provide new ~:sitemap-format-entry~ property for a function
+equivalent to the removed format string.
+
+** New functions
+
+*** ~org-publish-find-property~
+
+This function can be used as a tool to format entries in a site-map,
+in addition to ~org-publish-find-title~ and ~org-publish-find-date~.
+
+*** ~org-list-to-org~
+
+It is the reciprocal of ~org-list-to-lisp~, which see.
+
+*** ~org-agenda-set-restriction-lock-from-agenda~
+
+Call ~org-agenda-set-restriction-lock~ from the agenda.
+
+** Miscellaneous
+
+*** More specific anniversary descriptions
+
+Anniversary descriptions (used in the agenda view, for instance)
+include the point in time, when the anniversary appears.  This is,
+in its most general form, just the date of the anniversary.  Or
+more specific terms, like "today", "tomorrow" or "in n days" are
+used to describe the time span.
+
+This feature allows to automatically change the description of an
+anniversary, depending on if it occurs in the next few days or
+far away in the future.
+
+*** Computed dates in tables appear as inactive time stamps
+
+*** Save point before opening a file with an unknown search option
+
+When following a file link with a search option (e.g., =::#custom-id=)
+that doesn't exist in the target file, save positon before raising an
+error.  As a consequence, it is possible to jump back to the original
+document with ~org-mark-ring-goto~ (default binding =C-c &=).
+
+*** ~org-get-heading~ accepts two more optional arguments
+
+See docstring for details.
+
+*** New option ~org-babel-uppercase-example-markers~
+
+This variable is a ~defcustom~ and replaces the variable
+~org-babel-capitalize-example-region-markers~, which is a ~defvar~ and
+is now obselete.
+
+* Version 9.0
+
+** Incompatible changes
+
+*** Emacs 23 support has been dropped
+
+From now on, Org expects at least Emacs 24.3, although Emacs 24.4 or
+above is suggested.
+
+*** XEmacs support has been dropped
+
+Incomplete compatibility layer with XEmacs has been removed.  If you
+want to take over maintainance of this compatibility, please contact
+our mailing list.
+
+*** New syntax for export blocks
+
+Export blocks are explicitly marked as such at the syntax level to
+disambiguate their parsing from special blocks.  The new syntax is
+
+#+BEGIN_SRC org
+,#+BEGIN_EXPORT backend
+...
+,#+END_EXPORT
+#+END_SRC
+
+instead of
+
+#+BEGIN_SRC org
+,#+BEGIN_backend
+...
+,#+END_backend
+#+END_SRC
+
+As a consequence, =INCLUDE= keywords syntax is modified, e.g.,
+
+#+BEGIN_SRC org
+,#+INCLUDE: "file.org" HTML
+#+END_SRC
+
+becomes
+
+#+BEGIN_SRC org
+,#+INCLUDE: "file.org" export html
+#+END_SRC
+
+The following function repairs export blocks and =INCLUDE= keywords
+using previous syntax:
+
+#+BEGIN_SRC emacs-lisp
+(defun org-repair-export-blocks ()
+  "Repair export blocks and INCLUDE keywords in current buffer."
+  (interactive)
+  (when (eq major-mode 'org-mode)
+    (let ((case-fold-search t)
+          (back-end-re (regexp-opt
+                        '("HTML" "ASCII" "LATEX" "ODT" "MARKDOWN" "MD" "ORG"
+                          "MAN" "BEAMER" "TEXINFO" "GROFF" "KOMA-LETTER")
+                        t)))
+      (org-with-wide-buffer
+       (goto-char (point-min))
+       (let ((block-re (concat "^[ \t]*#\\+BEGIN_" back-end-re)))
+         (save-excursion
+           (while (re-search-forward block-re nil t)
+             (let ((element (save-match-data (org-element-at-point))))
+               (when (eq (org-element-type element) 'special-block)
+                 (save-excursion
+                   (goto-char (org-element-property :end element))
+                   (save-match-data (search-backward "_"))
+                   (forward-char)
+                   (insert "EXPORT")
+                   (delete-region (point) (line-end-position)))
+                 (replace-match "EXPORT \\1" nil nil nil 1))))))
+       (let ((include-re
+              (format "^[ \t]*#\\+INCLUDE: .*?%s[ \t]*$" back-end-re)))
+         (while (re-search-forward include-re nil t)
+           (let ((element (save-match-data (org-element-at-point))))
+             (when (and (eq (org-element-type element) 'keyword)
+                        (string= (org-element-property :key element) "INCLUDE"))
+               (replace-match "EXPORT \\1" nil nil nil 1)))))))))
+#+END_SRC
+
+Moreover, ~:export-block~ keyword used in ~org-export-define-backend~ and
+~org-export-define-derived-backend~ is no longer used and needs to be
+removed.
+
+*** Footnotes
+
+**** [1]-like constructs are not valid footnotes
+
+Using =[1]= as a footnote was already discouraged in the manual, since
+it introduced too many false-positives in many Org documents.  These
+constructs are now unsupported.
+
+If you used =[N]= in some of your documents, consider turning them into
+=[fn:N]=.
+
+**** /Org Footnote/ library doesn't handle non-Org buffers
+
+Commands for footnotes in an Org document no longer try to do
+something in non-Org ones.  If you need to have footnotes there,
+consider using the =footnote.el= library, shipped with Emacs.
+
+In particular, ~org-footnote-tag-for-non-org-mode-files~ no longer
+exists.
+
+*** ~org-file-apps~ no longer accepts S-expressions as commands
+
+The variable now accepts functions of two arguments instead of plain
+S-expressions.  Replacing a S-expresion with an appropriate function
+is straightforward.  For example
+
+: ("pdf" . (foo))
+
+becomes
+
+: ("pdf" . (lambda (file link) (foo)))
+
+*** The ~{{{modification-time}}}~ macro can get time via =vc=
+
+The modification time will be determined via =vc.el= if the second
+argument is non-nil.  See the manual for details.
+
+*** Preparation and completion functions in publishing projects change signature
+
+Preparation and completion functions are now called with an argument,
+which is the project property list.  It used to be dynamically scoped
+through the ~project-plist~ variable.
+
+*** Old Babel header properties are no longer supported
+
+Using header arguments as property names is no longer possible.  As
+such, the following
+
+#+BEGIN_EXAMPLE
+,* Headline
+:PROPERTIES:
+:exports: code
+:var: a=1 b=2
+:var+: c=3
+:END:
+#+END_EXAMPLE
+
+should be written instead
+
+#+BEGIN_EXAMPLE
+,* Headline
+:PROPERTIES:
+:header-args: :exports code
+:header-args: :var a=1 b=2
+:header-args+: :var c=3
+:END:
+#+END_EXAMPLE
+
+Please note that, however, old properties were defined at the source
+block definition.  Current ones are defined where the block is called.
+
+** New features
+
+*** ~org-eww~ has been moved into core
+*** New org-protocol key=value syntax
+
+Org-protocol can now handle query-style parameters such as:
+
+#+begin_example
+org-protocol://store-link?url=http:%2F%2Flocalhost%2Findex.html&title=The%20title
+org-protocol://capture?template=x&title=Hello&body=World&url=http:%2F%2Fexample.com
+#+end_example
+
+Old-style links such as
+: org-protocol://store-link:/http:%2F%2Flocalhost%2Findex.html/The%20title
+continue to be supported.
+
+If you have defined your own handler functions for
+~org-protocol-protocol-alist~, change them to accept either a property
+list (for new-style links) or a string (for old-style links).  Use
+~org-protocol-parse-parameters~ to convert old-style links into property
+lists.
+
+*** New Org linter library
+
+~org-lint~ can check syntax and report common issues in Org documents.
+
+*** New option ~date-tree-last~ for ~org-agenda-insert-diary-strategy~
+
+When ~org-agenda-insert-diary-strategy~ is set to ~date-tree-last~, diary
+entries are added to last in the date tree.
+
+*** New ~vbar~ entity
+
+~\vbar~ or ~\vbar{}~ will be exported unconditionnally as a =|=,
+unlike to existing ~\vert~, which is expanded as ~|~ when using
+a HTML derived export back-end.
+
+*** Export
+
+**** New =#+latex_compiler= keyword to set LaTeX compiler.
+
+PDFLaTeX, XeLaTeX, and LuaLaTeX are supported.  See the manual for
+details.
+
+**** New option ~org-export-with-broken-links~
+
+This option tells the export process how to behave when encountering
+a broken internal link.  See its docstring for more information.
+
+**** Attributes support in custom language environments for LaTeX export
+
+Custom language environments for LaTeX export can now define the
+string to be inserted during export, using attributes to indicate the
+position of the elements. See variable ~org-latex-custom-lang-environments~
+for more details.
+
+**** New Texinfo ~options~ attribute on special blocks
+
+Using ~:options~ as a Texinfo attribute, it is possible to add
+information to custom environments.  See manual for details.
+
+**** New HTML ~id~ attributes on special, example and quote blocks
+
+If the block has a =#+NAME:= attribute assigned, then the HTML element
+will have an ~id~ attribute with that name in the HTML export. This
+enables one to create links to these elements in other places, e.g.,
+~text~.
+
+**** Listings with captions are now numbered in HTML export
+
+The class associated to the numbering is "listing-number".  If you
+don't want these blocks to be numbered, as it was the case until now,
+You may want to add ~.listing-number { display: none; }~ to the CSS
+used.
+
+**** Line Numbering in SRC/EXAMPLE blocks support arbitrary start number
+
+The ~-n~ option to ~SRC~ and ~EXAMPLE~ blocks can now take a numeric
+argument to specify the staring line number for the source or example
+block.  The ~+n~ option can now take a numeric argument that will be
+added to the last line number from the previous block as the starting
+point for the SRC/EXAMPLE block.
+
+#+BEGIN_SRC org
+,#+BEGIN_SRC emacs-lisp -n 20
+;; this will export with line number 20
+(message "This is line 21")
+,#+END_SRC
+,#+BEGIN_SRC emacs-lisp +n 10
+;; This will be listed as line 31
+(message "This is line 32")
+,#+END_SRC
+#+END_SRC
+
+**** Allow toggling center for images in LaTeX export
+
+With the global variable ~org-latex-images-centered~ or the local
+attribute ~:center~ it is now possible to center an image in LaTeX
+export.
+
+**** Default CSS class ~org-svg~ for SVG images in HTML export
+
+SVG images exported in HTML are now by default assigned a CSS class
+~org-svg~ if no CSS class is specified with the ~:class~ attribute. By
+default, the CSS styling of class ~org-svg~ specifies an image width of
+90\thinsp{}% of the container the image.
+
+**** Markdown footnote export customization
+
+Variables ~org-md-footnotes-section~ and ~org-md-footnote-format~
+introduced for =ox-md.el=.  Both new variables define template strings
+which can be used to customize the format of the exported footnotes
+section and individual footnotes, respectively.
+
+*** Babel
+
+**** Blocks with coderefs labels can now be evaluated
+
+The labels are removed prior to evaluating the block.
+
+**** Support for Lua language
+**** Support for SLY in Lisp blocks
+
+See ~org-babel-lisp-eval-fn~ to activate it.
+
+**** Support for Stan language
+
+New ob-stan.el library.
+
+Evaluating a Stan block can produce two different results.
+
+1. Dump the source code contents to a file.
+
+   This file can then be used as a variable in other blocks, which
+   allows interfaces like RStan to use the model.
+
+2. Compile the contents to a model file.
+
+   This provides access to the CmdStan interface.  To use this, set
+   ~org-babel-stan-cmdstan-directory~ and provide a ~:file~ argument
+   that does not end in ".stan".
+
+For more information and usage examples, visit
+http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-stan.html
+
+**** Support for Oracle databases via ~sqlplus~
+
+=ob-sql= library supports running SQL blocks against an Oracle
+database using ~sqlplus~.  Use with properties like this (all
+mandatory):
+
+#+BEGIN_EXAMPLE
+:engine oracle
+:dbhost 
+:dbport <1521>
+:dbuser 
+:database 
+:dbpassword 
+#+END_EXAMPLE
+
+**** Improved support to Microsoft SQL Server via ~sqlcmd~
+
+=ob-sql= library removes support to the ~msosql~ engine which uses the
+deprecated ~osql~ command line tool, and replaces it with ~mssql~
+engine which uses the ~sqlcmd~ command line tool.  Use with properties
+like this:
+
+#+BEGIN_EXAMPLE
+:engine mssql
+:dbhost 
+:dbuser 
+:dbpassword 
+:database 
+#+END_EXAMPLE
+
+If you want to use the *trusted connection* feature, omit *both* the
+=dbuser= and =dbpassword= properties and add =cmdline -E= to the properties.
+
+If your Emacs is running in a Cygwin environment, the =ob-sql= library
+can pass the converted path to the =sqlcmd= tool.
+
+**** Improved support of header arguments for postgresql
+
+The postgresql engine in a sql code block supports now ~:dbport~ nd
+~:dbpassword~ as header arguments.
+
+**** Support for additional plantuml output formats
+
+The support for output formats of [[http://plantuml.com/][plantuml]] has been extended to now
+include:
+
+All Diagrams:
+- png ::
+- svg ::
+- eps ::
+- pdf ::
+- vdx ::
+- txt :: ASCII art
+- utxt :: ASCII art using unicode characters
+
+Class Diagrams:
+- xmi ::
+- html ::
+
+State Diagrams:
+- scxml ::
+
+The output formats are determined by the file extension specified
+using the :file property, e.g.:
+
+#+begin_src plantuml :file diagram.png
+@startuml
+Alice -> Bob: Authentication Request
+Bob --> Alice: Authentication Response
+
+Alice -> Bob: Another authentication Request
+Alice <-- Bob: another authentication Response
+@enduml
+#+end_src
+
+Please note that *pdf* *does not work out of the box* and needs additional
+setup in addition to plantuml.  See [[http://plantuml.com/pdf.html]] for
+details and setup information.
+
+*** Rewrite of radio lists
+
+Radio lists, i.e, Org plain lists in foreign buffers, have been
+rewritten to be on par with Radio tables.  You can use a large set of
+parameters to control how a given list should be rendered.  See manual
+for details.
+
+*** org-bbdb-anniversaries-future
+
+Used like ~org-bbdb-anniversaries~, it provides a few days warning for
+upcoming anniversaries (default: 7 days).
+
+*** Clear non-repeated SCHEDULED upon repeating a task
+
+If the task is repeated, and therefore done at least one, scheduling
+information is no longer relevant.  It is therefore removed.
+
+See [[git:481719fbd5751aaa9c672b762cb43aea8ee986b0][commit message]] for more information.
+
+*** Support for ISO week trees
+
+ISO week trees are an alternative date tree format that orders entries
+by ISO week and not by month.
+
+For example:
+
+: * 2015
+: ** 2015-W35
+: ** 2015-W36
+: *** 2015-08-31 Monday
+
+They are supported in org-capture via ~file+weektree~ and
+~file+weektree+prompt~ target specifications.
+
+*** Accept ~:indent~ parameter when capturing column view
+
+When defining a "columnview" dynamic block, it is now possible to add
+an :indent parameter, much like the one in the clock table.
+
+On the other hand, stars no longer appear in an ITEM field.
+
+*** Columns view
+
+**** ~org-columns~ accepts a prefix argument
+
+When called with a prefix argument, ~org-columns~ apply to the whole
+buffer unconditionally.
+
+**** New variable : ~org-agenda-view-columns-initially~
+
+The variable used to be a ~defvar~, it is now a ~defcustom~.
+
+**** Allow custom summaries
+
+It is now possible to add new summary types, or override those
+provided by Org by customizing ~org-columns-summary-types~, which see.
+
+**** Allow multiple summaries for any property
+
+Columns can now summarize the same property using different summary
+types.
+
+*** Preview LaTeX snippets in buffers not visiting files
+*** New option ~org-attach-commit~
+
+When non-nil, commit attachments with git, assuming the document is in
+a git repository.
+
+*** Allow conditional case-fold searches in ~org-occur~
+
+When set to ~smart~, the new variable ~org-occur-case-fold-search~ allows
+to mimic =isearch.el=: if the regexp searched contains any upper case
+character (or character class), the search is case sensitive.
+Otherwise, it is case insensitive.
+
+*** More robust repeated =ox-latex= footnote handling
+
+Repeated footnotes are now numbered by referring to a label in the
+first footnote.
+
+*** The ~org-block~ face is inherited by ~src-blocks~
+
+This works also when =org-src-fontify-natively= is non-nil.  It is also
+possible to specify per-languages faces.  See =org-src-block-faces= and
+the manual for details.
+
+*** Links are now customizable
+
+Links can now have custom colors, tooltips, keymaps, display behavior,
+etc.  Links are now centralized in ~org-link-parameters~.
+
+** New functions
+
+*** ~org-next-line-empty-p~
+
+It replaces the deprecated ~next~ argument to ~org-previous-line-empty-p~.
+
+*** ~org-show-children~
+
+It is a faster implementation of ~outline-show-children~.
+
+** Removed functions
+
+*** ~org-agenda-filter-by-tag-refine~ has been removed.
+
+Use ~org-agenda-filter-by-tag~ instead.
+
+*** ~org-agenda-todayp~ is deprecated.
+
+Use ~org-agenda-today-p~ instead.
+
+*** ~org-babel-get-header~ is removed.
+
+Use ~org-babel--get-vars~ or ~assq~ instead, as applicable.
+
+*** ~org-babel-trim~ is deprecated.
+
+Use ~org-trim~ instead.
+
+*** ~org-element-remove-indentation~ is deprecated.
+
+Use ~org-remove-indentation~ instead.
+
+*** ~org-image-file-name-regexp~ is deprecated
+
+Use ~image-file-name-regexp~ instead.
+The never-used-in-core ~extensions~ argument has been dropped.
+
+*** ~org-list-parse-list~ is deprecated
+
+Use ~org-list-to-lisp~ instead.
+
+*** ~org-on-heading-p~ is deprecated
+
+A comment to this effect was in the source code since 7.8.03, but
+now a byte-compiler warning will be generated as well.
+
+*** ~org-table-p~ is deprecated
+
+Use ~org-at-table-p~ instead.
+
+*** ~org-table-recognize-table.el~ is deprecated
+
+It was not called by any org code since 2010.
+
+*** Various reimplementations of cl-lib functions are deprecated
+
+The affected functions are:
+- ~org-count~
+- ~org-remove-if~
+- ~org-remove-if-not~
+- ~org-reduce~
+- ~org-every~
+- ~org-some~
+
+Additionally, ~org-sublist~ is deprecated in favor of ~cl-subseq~.  Note
+the differences in indexing conventions: ~org-sublist~ is 1-based and
+end-inclusive; ~cl-subseq~ is 0-based and end-exclusive.
+
+** Removed options
+
+*** Remove all options related to ~ido~ or ~iswitchb~
+
+This includes ~org-completion-use-iswitchb~ and ~org-completion-use-ido~.
+Instead Org uses regular functions, e.g., ~completion-read~ so as to
+let those libraries operate.
+
+*** Remove ~org-list-empty-line-terminates-plain-lists~
+
+Two consecutive blank lines always terminate all levels of current
+plain list.
+
+*** ~fixltx2e~ is removed from ~org-latex-default-packages-alist~
+
+fixltx2e is obsolete, see LaTeX News 22.
+
+** Miscellaneous
+*** Add Icelandic smart quotes
+*** Allow multiple receiver locations in radio tables and lists
+*** Allow angular links within link descriptions
+
+It is now allowed to write, e.g.,
+~[[http:orgmode.org][]]~ as an equivalent to
+~[[http:orgmode.org][file:unicorn.png]]~.  The advantage of the former
+is that spaces are allowed within the path.
+
+*** Beamer export back-ends uses ~org-latex-prefer-user-labels~
+*** ~:preparation-function~ called earlier during publishing
+
+Functions in this list are called before any file is associated to the
+current projet.  Thus, they can be used to generate to be published
+Org files.
+
+*** Function ~org-remove-indentation~ changes.
+
+The new algorithm doesn't remove TAB characters not used for
+indentation.
+
+*** Secure placeholders in capture templates
+
+Placeholders in capture templates are no longer expanded recursively.
+However, ~%(...)~ constructs are expanded very late, so you can fill
+the contents of the S-exp with the replacement text of non-interactive
+placeholders.  As before, interactive ones are still expanded as the
+very last step, so the previous statement doesn't apply to them.
+
+Note that only ~%(...)~ placeholders initially present in the
+template, or introduced using a file placeholder, i.e., ~%[...]~ are
+expanded.  This prevents evaluating potentially malicious code when
+another placeholder, e.g., ~%i~ expands to a S-exp.
+
+*** Links stored by ~org-gnus-store-link~ in nnir groups
+
+Since gnus nnir groups are temporary, ~org-gnus-store-link~ now refers
+to the article's original group.
+
+*** ~org-babel-check-confirm-evaluate~ is now a function instead of a macro
+
+The calling convention has changed.
+
+*** HTML export table row customization changes
+
+Variable ~org-html-table-row-tags~ has been split into
+~org-html-table-row-open-tag~ and ~org-html-table-row-close-tag~.
+Both new variables can be either a string or a function which will be
+called with 6 parameters.
+
+*** =ITEM= special property returns headline without stars
+*** Rename ~org-insert-columns-dblock~ into ~org-columns-insert-dblock~
+
+The previous name is, for the time being, kept as an obsolete alias.
+
+*** ~org-trim~ can preserve leading indentation.
+
+When setting a new optional argument to a non-nil value, ~org-trim~
+preserves leading indentation while removing blank lines at the
+beginning of the string.  The behavior is identical for white space at
+the end of the string.
+
+*** Function ~org-info-export~ changes.
+
+HTML links created from certain info links now point to =gnu.org= URL's rather
+than just to local files. For example info links such as =info:emacs#List
+Buffers= used to be converted to HTML links like this:
+
+: emacs#List Buffers
+
+where local file =emacs.html= is referenced.
+For most folks this file does not exist.
+Thus the new behavior is to generate this HTML link instead:
+
+: emacs#List Buffers
+
+All emacs related info links are similarly translated plus few other
+=gnu.org= manuals.
+
+*** Repeaters with a ~++~ interval and a time can be shifted to later today
+
+Previously, if a recurring task had a timestamp of
+~<2016-01-01 Fri 20:00 ++1d>~ and was completed on =2016-01-02= at
+=08:00=, the task would skip =2016-01-02= and would be rescheduled for
+=2016-01-03=.  Timestamps with ~++~ cookies and a specific time will
+now shift to the first possible future occurrence, even if the
+occurrence is later the same day the task is completed.  (Timestamps
+already in the future are still shifted one time further into the
+future.)
+
+*** ~org-mobile-action-alist~ is now a defconst
+
+It used to be a defcustom, with a warning that it shouldn't be
+modified anyway.
+
+*** ~file+emacs~ and ~file+sys~ link types are deprecated
+
+They are still supported in Org 9.0 but will eventually be removed in
+a later release.  Use ~file~ link type along with universal arguments
+to force opening it in either Emacs or with system application.
+
+*** New defcustom ~org-babel-J-command~ stores the j command
+*** New defalias ~org-babel-execute:j~
+
+Allows J source blocks be indicated by letter j.  Previously the
+indication letter was solely J.
+
+*** ~org-open-line~ ignores tables at the very beginning of the buffer
+
+When ~org-special-ctrl-o~ is non-nil, it is impractical to create
+a blank line above a table at the beginning of the document. Now, as
+a special case, ~org-open-line~ behaves normally in this situation.
+
+*** ~org-babel-hash-show-time~ is now customizable
+
+The experimental variable used to be more or less confidential, as
+a ~defvar~.
+
+*** New ~:format~ property to parsed links
+
+It defines the format of the original link.  Possible values are:
+~plain~, ~bracket~ and ~angle~.
 
 * Version 8.3
 
@@ -102,10 +1086,10 @@ buffer name, as the title.  Instead, simply ignore the title.
 *** Default bindings of =C-c C-n= and =C-c C-p= changed
 
 The key sequences =C-c C-n= and =C-c C-p= are now bound to
-~org-next-visible-heading~ and ~org-next-visible-heading~ respectively,
-rather than the =outline-mode= versions of these functions.  The Org
-version of these functions skips over inline tasks (and even-level
-headlines when ~org-odd-levels-only~ is set).
+~org-next-visible-heading~ and ~org-previous-visible-heading~
+respectively, rather than the =outline-mode= versions of these
+functions.  The Org version of these functions skips over inline tasks
+(and even-level headlines when ~org-odd-levels-only~ is set).
 
 *** ~org-element-context~ no longer return objects in keywords
 
@@ -129,19 +1113,36 @@ docstring for more information.
 - ~org-latex-format-headline-function~
 - ~org-latex-format-inlinetask-function~
 - ~org-link-search~
+
 ** New features
 
+*** Default lexical evaluation of emacs-lisp src blocks
+
+Emacs-lisp src blocks in babel are now evaluated using lexical
+scoping.  There is a new header to control this behavior.
+
+The default results in an eval with lexical scoping.
+:lexical yes
+
+This turns lexical scoping off in the eval (the former behavior).
+:lexical no
+
+This uses the lexical environment with x=42 in the eval.
+:lexical '((x . 42))
+
 *** Behavior of ~org-return~ changed
 
 If point is before or after the headline title, insert a new line
 without changing the headline.
 
 *** Hierarchies of tags
+
 The functionality of nesting tags in hierarchies is added to org-mode.
 This is the generalization of what was previously called "Tag groups"
 in the manual.  That term is now changed to "Tag hierarchy".
 
 The following in-buffer definition:
+
 #+BEGIN_SRC org
   ,#+TAGS: [ Group : SubOne SubTwo ]
   ,#+TAGS: [ SubOne : SubOne1 SubOne2 ]
@@ -149,6 +1150,7 @@ The following in-buffer definition:
 #+END_SRC
 
 Should be seen as the following tree of tags:
+
 - Group
   - SubOne
     - SubOne1
@@ -163,25 +1165,27 @@ on SubOne filters also it's sub-tags.  Etc.
 There is no limit on the depth for the tag hierarchy.
 
 *** Additional syntax for non-unique grouptags
+
 Additional syntax is defined for grouptags if the tags in the group
 don't have to be distinct on a heading.
 
 Grouptags had to previously be defined with { }.  This syntax is
 already used for exclusive tags and Grouptags need their own,
-non-exclusive syntax.  This behaviour is achieved with [ ].  Note: {
-} can still be used also for Grouptags but then only one of the
-given tags can be used on the headline at the same time.  Example:
+non-exclusive syntax.  This behaviour is achieved with [ ].  Note: { }
+can still be used also for Grouptags but then only one of the given
+tags can be used on the headline at the same time.  Example:
 
 [ group : sub1 sub2 ]
 
 #+BEGIN_SRC org
-  ,* Test                                                            :sub1:sub2:
+,* Test                                                            :sub1:sub2:
 #+END_SRC
 
 This is a more general case than the already existing syntax for
 grouptags; { }.
 
 *** Define regular expression patterns as tags
+
 Tags can be defined as grouptags with regular expressions as
 "sub-tags".
 
@@ -191,13 +1195,13 @@ Example use:
 : #+TAGS: [ Project : {P@.+} ]
 
 Searching for the tag Project will now list all tags also including
-regular expression matches for P@.+.  Good for example if tags for a
-certain project is tagged with a common project-identifier,
-i.e. P@2014_OrgTags.
+regular expression matches for P@.+.  This is good for example for
+projects tagged with a common identifier, i.e. P@2014_OrgTags.
 
 *** Filtering in the agenda on grouptags (Tag hierarchies)
-Filtering in the agenda on grouptags filter all of the related tags.
-Exception if filter is applied with a (double) prefix-argument.
+
+Filtering in the agenda on grouptags filters all of the related tags.
+Except if a filter is applied with a (double) prefix-argument.
 
 Filtering in the agenda on subcategories does not filter the "above"
 levels anymore.
@@ -206,9 +1210,10 @@ If a grouptag contains a regular expression the regular expression
 is also used as a filter.
 
 *** Minor refactoring of ~org-agenda-filter-by-tag~
-Now uses the argument arg and optional argument exclude instead of
+
+Now uses the argument ARG and optional argument exclude instead of
 strip and narrow.  ARG because the argument has multiple purposes and
-makes more sense than strip now.  The term narrowing is changed to
+makes more sense than strip now.  The term "narrowing" is changed to
 exclude.
 
 The main purpose is for the function to make more logical sense when
@@ -226,16 +1231,17 @@ This library implements necessary functions for implementing editing
 of Processing code blocks, viewing the resulting sketches in an
 external viewer, and HTML export of the sketches.
 
-Check the documentation for more.
+Check the documentation for more details.
 
 Thanks to Jarmo Hurri for this feature.
 
-*** New behaviour for `org-toggle-latex-fragment'
+*** New behaviour for ~org-toggle-latex-fragment~
+
 The new behaviour is the following:
 
-- With a double prefix argument or with a single prefix argument
-  when point is before the first headline, toggle overlays in the
-  whole buffer;
+- With a double prefix argument or with a single prefix argument when
+  point is before the first headline, toggle overlays in the whole
+  buffer;
 
 - With a single prefix argument, toggle overlays in the current
   subtree;
@@ -277,18 +1283,18 @@ default is =hline=.
 
 *** Markdown export supports switches in source blocks
 
-For example, it is now possible to number lines using the =-n= switch
-in a source block.
+For example, it is now possible to number lines using the =-n= switch in
+a source block.
 
 *** New option in ASCII export
 
-Plain lists can have an extra margin by setting
-~org-ascii-list-margin~ variable to an appopriate integer.
+Plain lists can have an extra margin by setting ~org-ascii-list-margin~
+variable to an appopriate integer.
 
 *** New blocks in ASCII export
 
-ASCII export now supports =#+BEGIN_JUSTIFYRIGHT= and
-=#+BEGIN_JUSTIFYLEFT= blocks.  See documentation for details.
+ASCII export now supports =#+BEGIN_JUSTIFYRIGHT= and =#+BEGIN_JUSTIFYLEFT=
+blocks.  See documentation for details.
 
 *** More back-end specific publishing options
 
@@ -334,23 +1340,23 @@ will be exported using =@samp(myverbatim)= instead of =@samp(verbatim)=.
 
 Radio tables feature now relies on Org's export framework ("ox.el").
 ~:no-escape~ parameter no longer exists, but additional global
-parameters are now supported: ~:raw~, ~:backend~.  Moreover, there are
-new parameters specific to some pre-defined translators, e.g.,
+parameters are now supported: ~:raw~, ~:backend~.  Moreover, there are new
+parameters specific to some pre-defined translators, e.g.,
 ~:environment~ and ~:booktabs~ for ~orgtbl-to-latex~.  See translators
 docstrings (including ~orgtbl-to-generic~) for details.
 
 *** Non-floating minted listings in Latex export
 
-It is not possible to specify =#+attr_latex: :float nil= in conjunction with
-source blocks exported by the minted package.
+It is not possible to specify =#+attr_latex: :float nil= in conjunction
+with source blocks exported by the minted package.
 
 *** Field formulas can now create columns as needed
 
 Previously, evaluating formulas that referenced out-of-bounds columns
-would throw an error. A new variable
-~org-table-formula-create-columns~ was added to adjust this
-behavior. It is now possible to silently add new columns, to do so
-with a warning or to explicitly ask the user each time.
+would throw an error. A new variable ~org-table-formula-create-columns~
+was added to adjust this behavior. It is now possible to silently add
+new columns, to do so with a warning or to explicitly ask the user
+each time.
 
 *** ASCII plot
 
@@ -368,13 +1374,13 @@ When non-nil, attachments from archived subtrees are removed.
 
 *** New option: ~org-latex-caption-above~
 
-This variable generalizes ~org-latex-table-caption-above~, which is
-now deprecated.  In addition to tables, it applies to source blocks,
+This variable generalizes ~org-latex-table-caption-above~, which is now
+deprecated.  In addition to tables, it applies to source blocks,
 special blocks and images.  See docstring for more information.
 
 *** New option: ~org-latex-prefer-user-labels~
 
-See docstring for more information.
+See the docstring for more information.
 
 *** Export unnumbered headlines
 
@@ -385,13 +1391,13 @@ property is inherited by children.
 *** Tables can be sorted with an arbitrary function
 
 It is now possible to specify a function, both programatically,
-through a new optional argument, and interactively with ~f~ or ~F~
-keys, to sort a table.
+through a new optional argument, and interactively with ~f~ or ~F~ keys,
+to sort a table.
 
 *** Table of contents can be local to a section
 
-The ~TOC~ keywords now accepts an optional ~local~ parameter.  See
-manual for details.
+The ~TOC~ keywords now accepts an optional ~local~ parameter.  See manual
+for details.
 
 *** Countdown timers can now be paused
 
@@ -454,8 +1460,8 @@ for details.
 *** Remotely edit a footnote definition
 
 Calling ~org-edit-footnote-reference~ (C-c ') on a footnote reference
-allows to edit its definition, as long as it is not anonymous, in
-a dedicated buffer.  It works even if buffer is currently narrowed.
+allows to edit its definition, as long as it is not anonymous, in a
+dedicated buffer.  It works even if buffer is currently narrowed.
 
 *** New function ~org-delete-indentation~ bound to ~M-^~
 
@@ -464,7 +1470,7 @@ added to headline text.
 
 *** Support for images in Texinfo export
 
-~Texinfo~ back-end now handles images.  See manual for details.
+~Texinfo~ back-end now handles images.  See the manual for details.
 
 *** Support for captions in Texinfo export
 
@@ -479,9 +1485,9 @@ set using the hh:mm:ss format.
 
 *** Extend ~org-clone-subtree-with-time-shift~
 
-~org-clone-subtree-with-time-shift~ now accepts 0 as an argument for
-the number of clones, which removes the repeater from the original
-subtree and creates one shifted, repeating clone.
+~org-clone-subtree-with-time-shift~ now accepts 0 as an argument for the
+number of clones, which removes the repeater from the original subtree
+and creates one shifted, repeating clone.
 
 *** New time block for clock tables: ~untilnow~
 
@@ -527,6 +1533,7 @@ optional argument.
 
 These functions were left-over from pre 8.0 era.  They are not correct
 anymore.  Since they are not needed, they have no replacement.
+
 ** Removed options
 
 *** ~org-list-empty-line-terminates-plain-lists~ is deprecated
@@ -550,11 +1557,11 @@ everywhere in the buffer, possibly corrupting URLs.
 
 *** Removed option =org-babel-sh-command=
 
-This undocumented option defaulted to the value of =shell-file-name=
-at the time of loading =ob-shell=.  The new behaviour is to use the
-value of =shell-file-name= directly when the shell langage is =shell=.
-To chose a different shell, either customize =shell-file-name= or bind
-this variable locally.
+This undocumented option defaulted to the value of =shell-file-name= at
+the time of loading =ob-shell=.  The new behaviour is to use the value
+of =shell-file-name= directly when the shell langage is =shell=.  To chose
+a different shell, either customize =shell-file-name= or bind this
+variable locally.
 
 *** Removed option =org-babel-sh-var-quote-fmt=
 
@@ -594,6 +1601,7 @@ end-users browser.  You may force initial usage of MathML via
 ~org-export-filter-comment-functions~ and
 ~org-export-filter-comment-block-functions~ variables do not exist
 anymore.
+
 ** Miscellaneous
 
 *** Strip all meta data from ITEM special property
@@ -630,9 +1638,9 @@ particular test failure was introduced.
 *** Exact heading search for external links ignore spaces and cookies
 
 Exact heading search for links now ignore spaces and cookies. This is
-the case for links of the form ~file:projects.org::*task title~, as
-well as links of the form ~file:projects.org::some words~
-when ~org-link-search-must-match-exact-headline~ is not nil.
+the case for links of the form ~file:projects.org::*task title~, as well
+as links of the form ~file:projects.org::some words~ when
+~org-link-search-must-match-exact-headline~ is not nil.
 
 *** ~org-latex-hyperref-template~, ~org-latex-title-command~ formatting
 
@@ -642,12 +1650,12 @@ Note, ~org-latex-hyperref-template~ has a new default value.
 *** ~float, wasysym, marvosym~ are removed from ~org-latex-default-packages-alist~
 
 If you require any of these package add them to your preamble via
-~org-latex-packages-alist~. Org also uses default LaTeX ~\tolerance~
-now.
+~org-latex-packages-alist~. Org also uses default LaTeX ~\tolerance~ now.
 
 *** When exporting, throw an error on unresolved id/fuzzy links and code refs
 
 This helps spotting wrong links.
+
 * Version 8.2
 
 ** Incompatible changes
diff --git a/elpa/org-plus-contrib-20150831/etc/styles/OrgOdtContentTemplate.xml b/elpa/org-plus-contrib-20170407/etc/styles/OrgOdtContentTemplate.xml
similarity index 100%
rename from elpa/org-plus-contrib-20150831/etc/styles/OrgOdtContentTemplate.xml
rename to elpa/org-plus-contrib-20170407/etc/styles/OrgOdtContentTemplate.xml
diff --git a/elpa/org-plus-contrib-20150831/etc/styles/OrgOdtStyles.xml b/elpa/org-plus-contrib-20170407/etc/styles/OrgOdtStyles.xml
similarity index 100%
rename from elpa/org-plus-contrib-20150831/etc/styles/OrgOdtStyles.xml
rename to elpa/org-plus-contrib-20170407/etc/styles/OrgOdtStyles.xml
diff --git a/elpa/org-plus-contrib-20150831/etc/styles/README b/elpa/org-plus-contrib-20170407/etc/styles/README
similarity index 100%
rename from elpa/org-plus-contrib-20150831/etc/styles/README
rename to elpa/org-plus-contrib-20170407/etc/styles/README
diff --git a/elpa/org-plus-contrib-20150831/ob-C.el b/elpa/org-plus-contrib-20170407/ob-C.el
similarity index 76%
rename from elpa/org-plus-contrib-20150831/ob-C.el
rename to elpa/org-plus-contrib-20170407/ob-C.el
index f02950ab..795bcb2b 100644
--- a/elpa/org-plus-contrib-20150831/ob-C.el
+++ b/elpa/org-plus-contrib-20170407/ob-C.el
@@ -1,6 +1,6 @@
-;;; ob-C.el --- org-babel functions for C and similar languages
+;;; ob-C.el --- Babel Functions for C and Similar Languages -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2010-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2017 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;;      Thierry Banel
@@ -31,12 +31,14 @@
 ;; - not much in the way of error feedback
 
 ;;; Code:
-(require 'ob)
+
 (require 'cc-mode)
+(require 'ob)
+
 
-(declare-function org-entry-get "org"
-		  (pom property &optional inherit literal-nil))
+(declare-function org-entry-get "org" (pom property &optional inherit literal-nil))
 (declare-function org-remove-indentation "org" (code &optional n))
+(declare-function org-trim "org" (s &optional keep-lead))
 
 (defvar org-babel-tangle-lang-exts)
 (add-to-list 'org-babel-tangle-lang-exts '("C++" . "cpp"))
@@ -81,7 +83,7 @@ This function calls `org-babel-execute:C++'."
   (org-babel-execute:C++ body params))
 
 (defun org-babel-expand-body:cpp (body params)
-  "Expand a block of C++ code with org-babel according to it's
+  "Expand a block of C++ code with org-babel according to its
 header arguments."
   (org-babel-expand-body:C++ body params))
 
@@ -91,7 +93,7 @@ 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)
-  "Expand a block of C++ code with org-babel according to it's
+  "Expand a block of C++ code with org-babel according to its
 header arguments."
   (let ((org-babel-c-variant 'cpp)) (org-babel-C-expand-C++ body params)))
 
@@ -101,7 +103,7 @@ This function is called by `org-babel-execute-src-block'."
   (let ((org-babel-c-variant 'd)) (org-babel-C-execute body params)))
 
 (defun org-babel-expand-body:D (body params)
-  "Expand a block of D code with org-babel according to it's
+  "Expand a block of D code with org-babel according to its
 header arguments."
   (let ((org-babel-c-variant 'd)) (org-babel-C-expand-D body params)))
 
@@ -111,7 +113,7 @@ 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)
-  "Expand a block of C code with org-babel according to it's
+  "Expand a block of C code with org-babel according to its
 header arguments."
   (let ((org-babel-c-variant 'c)) (org-babel-C-expand-C body params)))
 
@@ -120,39 +122,47 @@ header arguments."
 or `org-babel-execute:C++' or `org-babel-execute:D'."
   (let* ((tmp-src-file (org-babel-temp-file
 			"C-src-"
-			(case org-babel-c-variant
-			 (c   ".c"  )
-			 (cpp ".cpp")
-			 (d   ".d"  ))))
-	 (tmp-bin-file (org-babel-temp-file "C-bin-" org-babel-exeext)) ;; not used for D
-	 (cmdline (cdr (assoc :cmdline params)))
+			(pcase org-babel-c-variant
+			  (`c ".c") (`cpp ".cpp") (`d ".d"))))
+	 (tmp-bin-file			;not used for D
+	  (org-babel-temp-file "C-bin-" org-babel-exeext))
+	 (cmdline (cdr (assq :cmdline params)))
 	 (cmdline (if cmdline (concat " " cmdline) ""))
-	 (flags (cdr (assoc :flags params)))
+	 (flags (cdr (assq :flags params)))
 	 (flags (mapconcat 'identity
 			   (if (listp flags) flags (list flags)) " "))
+	 (libs (org-babel-read
+		(or (cdr (assq :libs params))
+		    (org-entry-get nil "libs" t))
+		nil))
+	 (libs (mapconcat #'identity
+			  (if (listp libs) libs (list libs))
+			  " "))
 	 (full-body
-	  (case org-babel-c-variant
-	    (c   (org-babel-C-expand-C   body params))
-	    (cpp (org-babel-C-expand-C++ body params))
-	    (d   (org-babel-C-expand-D   body params)))))
+	  (pcase org-babel-c-variant
+	    (`c (org-babel-C-expand-C body params))
+	    (`cpp (org-babel-C-expand-C++ body params))
+	    (`d (org-babel-C-expand-D body params)))))
     (with-temp-file tmp-src-file (insert full-body))
-    (case org-babel-c-variant
-      ((c cpp)
+    (pcase org-babel-c-variant
+      ((or `c `cpp)
        (org-babel-eval
-	(format "%s -o %s %s %s"
-		(case org-babel-c-variant
-		 (c   org-babel-C-compiler)
-		 (cpp org-babel-C++-compiler))
+	(format "%s -o %s %s %s %s"
+		(pcase org-babel-c-variant
+		  (`c org-babel-C-compiler)
+		  (`cpp org-babel-C++-compiler))
 		(org-babel-process-file-name tmp-bin-file)
 		flags
-		(org-babel-process-file-name tmp-src-file)) ""))
-      (d nil)) ;; no separate compilation for D
+		(org-babel-process-file-name tmp-src-file)
+		libs)
+	""))
+      (`d nil)) ;; no separate compilation for D
     (let ((results
 	   (org-babel-eval
-	    (case org-babel-c-variant
-	      ((c cpp)
+	    (pcase org-babel-c-variant
+	      ((or `c `cpp)
 	       (concat tmp-bin-file cmdline))
-	      (d
+	      (`d
 	       (format "%s %s %s %s"
 		       org-babel-D-compiler
 		       flags
@@ -160,36 +170,36 @@ or `org-babel-execute:C++' or `org-babel-execute:D'."
 		       cmdline)))
 	    "")))
       (when results
-	(setq results (org-babel-trim (org-remove-indentation results)))
+	(setq results (org-trim (org-remove-indentation results)))
 	(org-babel-reassemble-table
-	 (org-babel-result-cond (cdr (assoc :result-params params))
+	 (org-babel-result-cond (cdr (assq :result-params params))
 	   (org-babel-read results t)
 	   (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)))
+	  (cdr (assq :colname-names params)) (cdr (assq :colnames params)))
 	 (org-babel-pick-name
-	  (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params)))))
+	  (cdr (assq :rowname-names params)) (cdr (assq :rownames params)))))
       )))
 
 (defun org-babel-C-expand-C++ (body params)
   "Expand a block of C or C++ code with org-babel according to
-it's header arguments."
+its header arguments."
   (org-babel-C-expand-C body params))
 
 (defun org-babel-C-expand-C (body params)
   "Expand a block of C or C++ code with org-babel according to
-it's header arguments."
-  (let ((vars (mapcar #'cdr (org-babel-get-header params :var)))
-	(colnames (cdar (org-babel-get-header params :colname-names)))
-	(main-p (not (string= (cdr (assoc :main params)) "no")))
+its header arguments."
+  (let ((vars (org-babel--get-vars params))
+	(colnames (cdr (assq :colname-names params)))
+	(main-p (not (string= (cdr (assq :main params)) "no")))
 	(includes (org-babel-read
-		   (or (cdr (assoc :includes params))
+		   (or (cdr (assq :includes params))
 		       (org-entry-get nil "includes" t))
 		   nil))
 	(defines (org-babel-read
-		  (or (cdr (assoc :defines params))
+		  (or (cdr (assq :defines params))
 		      (org-entry-get nil "defines" t))
 		  nil)))
     (when (stringp includes)
@@ -229,11 +239,11 @@ it's header arguments."
 
 (defun org-babel-C-expand-D (body params)
   "Expand a block of D code with org-babel according to
-it's header arguments."
-  (let ((vars (mapcar #'cdr (org-babel-get-header params :var)))
-	(colnames (cdar (org-babel-get-header params :colname-names)))
-	(main-p (not (string= (cdr (assoc :main params)) "no")))
-	(imports (or (cdr (assoc :imports params))
+its header arguments."
+  (let ((vars (org-babel--get-vars params))
+	(colnames (cdr (assq :colname-names params)))
+	(main-p (not (string= (cdr (assq :main params)) "no")))
+	(imports (or (cdr (assq :imports params))
 		     (org-babel-read (org-entry-get nil "imports" t)))))
     (when (stringp imports)
       (setq imports (split-string imports)))
@@ -265,12 +275,12 @@ it's header arguments."
       body
     (format "int main() {\n%s\nreturn 0;\n}\n" body)))
 
-(defun org-babel-prep-session:C (session params)
+(defun org-babel-prep-session:C (_session _params)
   "This function does nothing as C is a compiled language with no
 support for sessions"
   (error "C is a compiled languages -- no support for sessions"))
 
-(defun org-babel-load-session:C (session body params)
+(defun org-babel-load-session:C (_session _body _params)
   "This function does nothing as C is a compiled language with no
 support for sessions"
   (error "C is a compiled languages -- no support for sessions"))
@@ -290,14 +300,14 @@ 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."
   (let* ((basetype (org-babel-C-val-to-base-type val))
 	 (type
-	  (case basetype
-	    (integerp '("int" "%d"))
-	    (floatp '("double" "%f"))
-	    (stringp
+	  (pcase basetype
+	    (`integerp '("int" "%d"))
+	    (`floatp '("double" "%f"))
+	    (`stringp
 	     (list
-	      (if (equal org-babel-c-variant 'd) "string" "const char*")
+	      (if (eq org-babel-c-variant 'd) "string" "const char*")
 	      "\"%s\""))
-	    (t (error "unknown type %S" basetype)))))
+	    (_ (error "unknown type %S" basetype)))))
     (cond
      ((integerp val) type) ;; an integer declared in the #+begin_src line
      ((floatp val) type) ;; a numeric declared in the #+begin_src line
@@ -307,45 +317,45 @@ FORMAT can be either a format string or a function which is called with VAL."
 	  (cons
 	   (format "[%d][%d]" (length val) (length (car val)))
 	   (concat
-	    (if (equal org-babel-c-variant 'd) "[\n" "{\n")
+	    (if (eq org-babel-c-variant 'd) "[\n" "{\n")
 	    (mapconcat
 	     (lambda (v)
 	       (concat
-		(if (equal org-babel-c-variant 'd) " [" " {")
+		(if (eq org-babel-c-variant 'd) " [" " {")
 		(mapconcat (lambda (w) (format ,(cadr type) w)) v ",")
-		(if (equal org-babel-c-variant 'd) "]" "}")))
+		(if (eq org-babel-c-variant 'd) "]" "}")))
 	     val
 	     ",\n")
-	    (if (equal org-babel-c-variant 'd) "\n]" "\n}"))))))
+	    (if (eq org-babel-c-variant 'd) "\n]" "\n}"))))))
      ((or (listp val) (vectorp val)) ;; a list declared in the #+begin_src line
       `(,(car type)
 	(lambda (val)
 	  (cons
 	   (format "[%d]" (length val))
 	   (concat
-	    (if (equal org-babel-c-variant 'd) "[" "{")
+	    (if (eq org-babel-c-variant 'd) "[" "{")
 	    (mapconcat (lambda (v) (format ,(cadr type) v)) val ",")
-	    (if (equal org-babel-c-variant 'd) "]" "}"))))))
+	    (if (eq org-babel-c-variant 'd) "]" "}"))))))
      (t ;; treat unknown types as string
       type))))
 
 (defun org-babel-C-val-to-base-type (val)
   "Determine the base type of VAL which may be
-'integerp if all base values are integers
-'floatp if all base values are either floating points or integers
-'stringp otherwise."
+`integerp' if all base values are integers
+`floatp' if all base values are either floating points or integers
+`stringp' otherwise."
   (cond
    ((integerp val) 'integerp)
    ((floatp val) 'floatp)
    ((or (listp val) (vectorp val))
     (let ((type nil))
       (mapc (lambda (v)
-	      (case (org-babel-C-val-to-base-type v)
-		(stringp (setq type 'stringp))
-		(floatp
+	      (pcase (org-babel-C-val-to-base-type v)
+		(`stringp (setq type 'stringp))
+		(`floatp
 		 (if (or (not type) (eq type 'integerp))
 		     (setq type 'floatp)))
-		(integerp
+		(`integerp
 		 (unless type (setq type 'integerp)))))
 	    val)
       type))
@@ -387,8 +397,8 @@ of the same value."
 (defun org-babel-C-utility-header-to-C ()
   "Generate a utility function to convert a column name
 into a column number."
-  (case org-babel-c-variant
-    ((c cpp)
+  (pcase org-babel-c-variant
+    ((or `c `cpp)
      "int get_column_num (int nbcols, const char** header, const char* column)
 {
   int c;
@@ -397,9 +407,8 @@ into a column number."
       return c;
   return -1;
 }
-"
-     )
-    (d
+")
+    (`d
      "int get_column_num (string[] header, string column)
 {
   foreach (c, h; header)
@@ -407,8 +416,7 @@ into a column number."
       return to!int(c);
   return -1;
 }
-"
-     )))
+")))
 
 (defun org-babel-C-header-to-C (head)
   "Convert an elisp list of header table into a C or D vector
@@ -417,21 +425,21 @@ specifying a variable with the name of the table."
         (headers (cdr head)))
     (concat
      (format
-      (case org-babel-c-variant
-	((c cpp) "const char* %s_header[%d] = {%s};")
-	(d       "string %s_header[%d] = [%s];"))
+      (pcase org-babel-c-variant
+	((or `c `cpp) "const char* %s_header[%d] = {%s};")
+	(`d "string %s_header[%d] = [%s];"))
       table
       (length headers)
       (mapconcat (lambda (h) (format "%S" h)) headers ","))
      "\n"
-     (case org-babel-c-variant
-       ((c cpp)
+     (pcase org-babel-c-variant
+       ((or `c `cpp)
 	(format
 	 "const char* %s_h (int row, const char* col) { return %s[row][get_column_num(%d,%s_header,col)]; }"
 	 table table (length headers) table))
-       (d
+       (`d
 	(format
-	 "string %s_h (ulong row, string col) { return %s[row][get_column_num(%s_header,col)]; }"
+	 "string %s_h (size_t row, string col) { return %s[row][get_column_num(%s_header,col)]; }"
 	 table table table))))))
 
 (provide 'ob-C)
diff --git a/elpa/org-plus-contrib-20150831/ob-J.el b/elpa/org-plus-contrib-20170407/ob-J.el
similarity index 89%
rename from elpa/org-plus-contrib-20150831/ob-J.el
rename to elpa/org-plus-contrib-20170407/ob-J.el
index 500ce9e6..eba4bc63 100644
--- a/elpa/org-plus-contrib-20150831/ob-J.el
+++ b/elpa/org-plus-contrib-20170407/ob-J.el
@@ -1,6 +1,6 @@
-;;; ob-J.el --- org-babel functions for J evaluation
+;;; ob-J.el --- Babel Functions for J                -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2011-2013 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2017 Free Software Foundation, Inc.
 
 ;; Author: Oleh Krehel
 ;; Keywords: literate programming, reproducible research
@@ -29,12 +29,20 @@
 ;; (available in MELPA).
 
 ;;; Code:
+
 (require 'ob)
 
-(declare-function org-trim "org" (S))
+(declare-function org-trim "org" (s &optional keep-lead))
 (declare-function j-console-ensure-session "ext:j-console" ())
 
-(defun org-babel-expand-body:J (body params &optional processed-params)
+(defcustom org-babel-J-command "jconsole"
+  "Command to call J."
+  :group 'org-babel
+  :version "26.1"
+  :package-version '(Org . "9.0")
+  :type 'string)
+
+(defun org-babel-expand-body:J (body _params &optional _processed-params)
   "Expand BODY according to PARAMS, return the expanded body.
 PROCESSED-PARAMS isn't used yet."
   (org-babel-J-interleave-echos-except-functions body))
@@ -59,26 +67,25 @@ PROCESSED-PARAMS isn't used yet."
 	 (org-babel-J-interleave-echos-except-functions s3)))
     (org-babel-J-interleave-echos body)))
 
+(defalias 'org-babel-execute:j 'org-babel-execute:J)
+
 (defun org-babel-execute:J (body params)
   "Execute a block of J code BODY.
 PARAMS are given by org-babel.
 This function is called by `org-babel-execute-src-block'"
   (message "executing J source code block")
   (let* ((processed-params (org-babel-process-params params))
-	 (sessionp (cdr (assoc :session params)))
-         (session (org-babel-j-initiate-session sessionp))
-         (vars (nth 2 processed-params))
-         (result-params (nth 3 processed-params))
-         (result-type (nth 4 processed-params))
+	 (sessionp (cdr (assq :session params)))
          (full-body (org-babel-expand-body:J
                      body params processed-params))
 	 (tmp-script-file (org-babel-temp-file "J-src")))
+    (org-babel-j-initiate-session sessionp)
     (org-babel-J-strip-whitespace
      (if (string= sessionp "none")
 	 (progn
 	   (with-temp-file tmp-script-file
 	     (insert full-body))
-	   (org-babel-eval (format "jconsole < %s" tmp-script-file) ""))
+	   (org-babel-eval (format "%s < %s" org-babel-J-command tmp-script-file) ""))
        (org-babel-J-eval-string full-body)))))
 
 (defun org-babel-J-eval-string (str)
diff --git a/elpa/org-plus-contrib-20150831/ob-R.el b/elpa/org-plus-contrib-20170407/ob-R.el
similarity index 86%
rename from elpa/org-plus-contrib-20150831/ob-R.el
rename to elpa/org-plus-contrib-20170407/ob-R.el
index ac84d7d5..60990535 100644
--- a/elpa/org-plus-contrib-20150831/ob-R.el
+++ b/elpa/org-plus-contrib-20170407/ob-R.el
@@ -1,6 +1,6 @@
-;;; ob-R.el --- org-babel functions for R code evaluation
+;;; ob-R.el --- Babel Functions for R                -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2009-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2017 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;;	Dan Davison
@@ -27,8 +27,9 @@
 ;; Org-Babel support for evaluating R code
 
 ;;; Code:
+
+(require 'cl-lib)
 (require 'ob)
-(eval-when-compile (require 'cl))
 
 (declare-function orgtbl-to-tsv "org-table" (table params))
 (declare-function R "ext:essd-r" (&optional start-args))
@@ -36,10 +37,7 @@
 (declare-function ess-make-buffer-current "ext:ess-inf" ())
 (declare-function ess-eval-buffer "ext:ess-inf" (vis))
 (declare-function ess-wait-for-process "ext:ess-inf"
-		  (proc &optional sec-prompt wait force-redisplay))
-(declare-function org-number-sequence "org-compat" (from &optional to inc))
-(declare-function org-remove-if-not "org" (predicate seq))
-(declare-function org-every "org" (pred seq))
+		  (&optional proc sec-prompt wait force-redisplay))
 
 (defconst org-babel-header-args:R
   '((width		 . :any)
@@ -92,9 +90,11 @@ this variable.")
 (defvar ess-current-process-name) ; dynamically scoped
 (defvar ess-local-process-name)   ; dynamically scoped
 (defun org-babel-edit-prep:R (info)
-  (let ((session (cdr (assoc :session (nth 2 info)))))
-    (when (and session (string-match "^\\*\\(.+?\\)\\*$" session))
-      (save-match-data (org-babel-R-initiate-session session nil)))))
+  (let ((session (cdr (assq :session (nth 2 info)))))
+    (when (and session
+	       (string-prefix-p "*"  session)
+	       (string-suffix-p "*" session))
+      (org-babel-R-initiate-session session nil))))
 
 ;; The usage of utils::read.table() ensures that the command
 ;; read.table() can be found even in circumstances when the utils
@@ -139,30 +139,30 @@ This function is used when the table contains a header.")
 
 This function is used when the table does not contain a header.")
 
-(defun org-babel-expand-body:R (body params &optional graphics-file)
+(defun org-babel-expand-body:R (body params &optional _graphics-file)
   "Expand BODY according to PARAMS, return the expanded body."
   (mapconcat 'identity
 	     (append
-	      (when (cdr (assoc :prologue params))
-		(list (cdr (assoc :prologue params))))
+	      (when (cdr (assq :prologue params))
+		(list (cdr (assq :prologue params))))
 	      (org-babel-variable-assignments:R params)
 	      (list body)
-	      (when (cdr (assoc :epilogue params))
-		(list (cdr (assoc :epilogue params)))))
+	      (when (cdr (assq :epilogue params))
+		(list (cdr (assq :epilogue params)))))
 	     "\n"))
 
 (defun org-babel-execute:R (body params)
   "Execute a block of R code.
 This function is called by `org-babel-execute-src-block'."
   (save-excursion
-    (let* ((result-params (cdr (assoc :result-params params)))
-	   (result-type (cdr (assoc :result-type params)))
+    (let* ((result-params (cdr (assq :result-params params)))
+	   (result-type (cdr (assq :result-type params)))
            (session (org-babel-R-initiate-session
-		     (cdr (assoc :session params)) params))
-	   (colnames-p (cdr (assoc :colnames params)))
-	   (rownames-p (cdr (assoc :rownames params)))
+		     (cdr (assq :session params)) params))
 	   (graphics-file (and (member "graphics" (assq :result-params params))
 			       (org-babel-graphical-output-file params)))
+	   (colnames-p (unless graphics-file (cdr (assq :colnames params))))
+	   (rownames-p (unless graphics-file (cdr (assq :rownames params))))
 	   (full-body
 	    (let ((inside
 		   (list (org-babel-expand-body:R body params graphics-file))))
@@ -180,10 +180,10 @@ This function is called by `org-babel-execute-src-block'."
 	     session full-body result-type result-params
 	     (or (equal "yes" colnames-p)
 		 (org-babel-pick-name
-		  (cdr (assoc :colname-names params)) colnames-p))
+		  (cdr (assq :colname-names params)) colnames-p))
 	     (or (equal "yes" rownames-p)
 		 (org-babel-pick-name
-		  (cdr (assoc :rowname-names params)) rownames-p)))))
+		  (cdr (assq :rowname-names params)) rownames-p)))))
       (if graphics-file nil result))))
 
 (defun org-babel-prep-session:R (session params)
@@ -209,21 +209,21 @@ This function is called by `org-babel-execute-src-block'."
 
 (defun org-babel-variable-assignments:R (params)
   "Return list of R statements assigning the block's variables."
-  (let ((vars (mapcar 'cdr (org-babel-get-header params :var))))
+  (let ((vars (org-babel--get-vars params)))
     (mapcar
      (lambda (pair)
        (org-babel-R-assign-elisp
 	(car pair) (cdr pair)
-	(equal "yes" (cdr (assoc :colnames params)))
-	(equal "yes" (cdr (assoc :rownames params)))))
+	(equal "yes" (cdr (assq :colnames params)))
+	(equal "yes" (cdr (assq :rownames params)))))
      (mapcar
       (lambda (i)
 	(cons (car (nth i vars))
 	      (org-babel-reassemble-table
 	       (cdr (nth i vars))
-	       (cdr (nth i (cdr (assoc :colname-names params))))
-	       (cdr (nth i (cdr (assoc :rowname-names params)))))))
-      (org-number-sequence 0 (1- (length vars)))))))
+	       (cdr (nth i (cdr (assq :colname-names params))))
+	       (cdr (nth i (cdr (assq :rowname-names params)))))))
+      (number-sequence 0 (1- (length vars)))))))
 
 (defun org-babel-R-quote-tsv-field (s)
   "Quote field S for export to R."
@@ -234,7 +234,7 @@ This function is called by `org-babel-execute-src-block'."
 (defun org-babel-R-assign-elisp (name value colnames-p rownames-p)
   "Construct R code assigning the elisp VALUE to a variable named NAME."
   (if (listp value)
-      (let* ((lengths (mapcar 'length (org-remove-if-not 'sequencep value)))
+      (let* ((lengths (mapcar 'length (cl-remove-if-not 'sequencep value)))
 	     (max (if lengths (apply 'max lengths) 0))
 	     (min (if lengths (apply 'min lengths) 0)))
         ;; Ensure VALUE has an orgtbl structure (depth of at least 2).
@@ -262,7 +262,7 @@ This function is called by `org-babel-execute-src-block'."
 	  (ess-ask-for-ess-directory
 	   (and (boundp 'ess-ask-for-ess-directory)
 		ess-ask-for-ess-directory
-		(not (cdr (assoc :dir params))))))
+		(not (cdr (assq :dir params))))))
       (if (org-babel-comint-buffer-livep session)
 	  session
 	(save-window-excursion
@@ -316,8 +316,7 @@ Each member of this list is a list with three members:
 				:type :family :title :fonts :version
 				:paper :encoding :pagecentre :colormodel
 				:useDingbats :horizontal))
-	 (device (and (string-match ".+\\.\\([^.]+\\)" out-file)
-		      (match-string 1 out-file)))
+	 (device (file-name-extension out-file))
 	 (device-info (or (assq (intern (concat ":" device))
 				org-babel-R-graphics-devices)
                           (assq :png org-babel-R-graphics-devices)))
@@ -379,12 +378,12 @@ Has four %s escapes to be filled in:
      body result-type result-params column-names-p row-names-p)))
 
 (defun org-babel-R-evaluate-external-process
-  (body result-type result-params column-names-p row-names-p)
+    (body result-type result-params column-names-p row-names-p)
   "Evaluate BODY in external R process.
-If RESULT-TYPE equals 'output then return standard output as a
-string.  If RESULT-TYPE equals 'value then return the value of the
+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."
-  (case result-type
+  (cl-case result-type
     (value
      (let ((tmp-file (org-babel-temp-file "R-")))
        (org-babel-eval org-babel-R-command
@@ -399,7 +398,7 @@ last statement in BODY, as elisp."
 	(org-babel-result-cond result-params
 	  (with-temp-buffer
 	    (insert-file-contents tmp-file)
-	    (buffer-string))
+	    (org-babel-chomp (buffer-string) "\n"))
 	  (org-babel-import-elisp-from-file tmp-file '(16)))
 	column-names-p)))
     (output (org-babel-eval org-babel-R-command body))))
@@ -407,12 +406,12 @@ last statement in BODY, as elisp."
 (defvar ess-eval-visibly-p)
 
 (defun org-babel-R-evaluate-session
-  (session body result-type result-params column-names-p row-names-p)
+    (session body result-type result-params column-names-p row-names-p)
   "Evaluate BODY 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
+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."
-  (case result-type
+  (cl-case result-type
     (value
      (with-temp-buffer
        (insert (org-babel-chomp body))
@@ -433,7 +432,7 @@ last statement in BODY, as elisp."
 	(org-babel-result-cond result-params
 	  (with-temp-buffer
 	    (insert-file-contents tmp-file)
-	    (buffer-string))
+	    (org-babel-chomp (buffer-string) "\n"))
 	  (org-babel-import-elisp-from-file tmp-file '(16)))
 	column-names-p)))
     (output
@@ -446,7 +445,8 @@ last statement in BODY, as elisp."
 	      (mapcar
 	       (lambda (line) ;; cleanup extra prompts left in output
 		 (if (string-match
-		      "^\\([ ]*[>+\\.][ ]?\\)+\\([[0-9]+\\|[ ]\\)" line)
+		      "^\\([>+.]\\([ ][>.+]\\)*[ ]\\)"
+		      (car (split-string line "\n")))
 		     (substring line (match-end 1))
 		   line))
 	       (org-babel-comint-with-output (session org-babel-R-eoe-output)
diff --git a/elpa/org-plus-contrib-20150831/ob-abc.el b/elpa/org-plus-contrib-20170407/ob-abc.el
similarity index 82%
rename from elpa/org-plus-contrib-20150831/ob-abc.el
rename to elpa/org-plus-contrib-20170407/ob-abc.el
index a980b022..0ce503d3 100644
--- a/elpa/org-plus-contrib-20150831/ob-abc.el
+++ b/elpa/org-plus-contrib-20170407/ob-abc.el
@@ -1,6 +1,6 @@
-;;; ob-abc.el --- org-babel functions for template evaluation
+;;; ob-abc.el --- Org Babel Functions for ABC -*- lexical-binding: t; -*-
 
-;; Copyright (C) Free Software Foundation
+;; Copyright (C) 2013-2017 Free Software Foundation, Inc.
 
 ;; Author: William Waites
 ;; Keywords: literate programming, music
@@ -42,7 +42,7 @@
 
 (defun org-babel-expand-body:abc (body params)
   "Expand BODY according to PARAMS, return the expanded body."
-  (let ((vars (mapcar #'cdr (org-babel-get-header params :var))))
+  (let ((vars (org-babel--get-vars params)))
     (mapc
      (lambda (pair)
        (let ((name (symbol-name (car pair)))
@@ -59,12 +59,10 @@
   "Execute a block of ABC code with org-babel.  This function is
    called by `org-babel-execute-src-block'"
   (message "executing Abc source code block")
-  (let* ((result-params (split-string (or (cdr (assoc :results params)))))
-	 (cmdline (cdr (assoc :cmdline params)))
-	 (out-file ((lambda (el)
-		      (or el
-			  (error "abc code block requires :file header argument")))
-		    (replace-regexp-in-string "\.pdf$" ".ps" (cdr (assoc :file params)))))
+  (let* ((cmdline (cdr (assq :cmdline params)))
+	 (out-file (let ((file (cdr (assq :file params))))
+		     (if file (replace-regexp-in-string "\.pdf$" ".ps" file)
+		       (error "abc code block requires :file header argument"))))
 	 (in-file (org-babel-temp-file "abc-"))
 	 (render (concat "abcm2ps" " " cmdline
 		      " -O " (org-babel-process-file-name out-file)
@@ -79,14 +77,14 @@
 		    (file-name-extension out-file))
 		   out-file t))
     ;;; if we were asked for a pdf...
-    (when (string= (file-name-extension (cdr (assoc :file params))) "pdf")
-      (org-babel-eval (concat "ps2pdf" " " out-file " " (cdr (assoc :file params))) ""))
+    (when (string= (file-name-extension (cdr (assq :file params))) "pdf")
+      (org-babel-eval (concat "ps2pdf" " " out-file " " (cdr (assq :file params))) ""))
     ;;; indicate that the file has been written
     nil))
 
 ;; This function should be used to assign any variables in params in
 ;; the context of the session environment.
-(defun org-babel-prep-session:abc (session params)
+(defun org-babel-prep-session:abc (_session _params)
   "Return an error because abc does not support sessions."
   (error "ABC does not support sessions"))
 
diff --git a/elpa/org-plus-contrib-20150831/ob-asymptote.el b/elpa/org-plus-contrib-20170407/ob-asymptote.el
similarity index 78%
rename from elpa/org-plus-contrib-20150831/ob-asymptote.el
rename to elpa/org-plus-contrib-20170407/ob-asymptote.el
index ca58ecb3..1dbf4842 100644
--- a/elpa/org-plus-contrib-20150831/ob-asymptote.el
+++ b/elpa/org-plus-contrib-20170407/ob-asymptote.el
@@ -1,6 +1,6 @@
-;;; ob-asymptote.el --- org-babel functions for asymptote evaluation
+;;; ob-asymptote.el --- Babel Functions for Asymptote -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2009-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2017 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
@@ -43,7 +43,6 @@
 
 ;;; Code:
 (require 'ob)
-(eval-when-compile (require 'cl))
 
 (defvar org-babel-tangle-lang-exts)
 (add-to-list 'org-babel-tangle-lang-exts '("asymptote" . "asy"))
@@ -55,13 +54,10 @@
 (defun org-babel-execute:asymptote (body params)
   "Execute a block of Asymptote code.
 This function is called by `org-babel-execute-src-block'."
-  (let* ((result-params (split-string (or (cdr (assoc :results params)) "")))
-         (out-file (cdr (assoc :file params)))
-         (format (or (and out-file
-                          (string-match ".+\\.\\(.+\\)" out-file)
-                          (match-string 1 out-file))
+  (let* ((out-file (cdr (assq :file params)))
+         (format (or (file-name-extension out-file)
                      "pdf"))
-         (cmdline (cdr (assoc :cmdline params)))
+         (cmdline (cdr (assq :cmdline params)))
          (in-file (org-babel-temp-file "asymptote-"))
          (cmd
 	  (concat "asy "
@@ -79,7 +75,7 @@ This function is called by `org-babel-execute-src-block'."
     (message cmd) (shell-command cmd)
     nil)) ;; signal that output has already been written to file
 
-(defun org-babel-prep-session:asymptote (session params)
+(defun org-babel-prep-session:asymptote (_session _params)
   "Return an error if the :session header argument is set.
 Asymptote does not support sessions"
   (error "Asymptote does not support sessions"))
@@ -87,7 +83,7 @@ Asymptote does not support sessions"
 (defun org-babel-variable-assignments:asymptote (params)
   "Return list of asymptote statements assigning the block's variables."
   (mapcar #'org-babel-asymptote-var-to-asymptote
-	  (mapcar #'cdr (org-babel-get-header params :var))))
+	  (org-babel--get-vars params)))
 
 (defun org-babel-asymptote-var-to-asymptote (pair)
   "Convert an elisp value into an Asymptote variable.
@@ -124,21 +120,17 @@ a variable of the same value."
 
 DATA is a list.  Return type as a symbol.
 
-The type is `string' if any element in DATA is
-a string.  Otherwise, it is either `real', if some elements are
-floats, or `int'."
-  (let* ((type 'int)
-	 find-type			; for byte-compiler
-	 (find-type
-	  (function
-	   (lambda (row)
-	     (catch 'exit
-	       (mapc (lambda (el)
-		       (cond ((listp el) (funcall find-type el))
-			     ((stringp el) (throw 'exit (setq type 'string)))
-			     ((floatp el) (setq type 'real))))
-		     row))))))
-    (funcall find-type data) type))
+The type is `string' if any element in DATA is a string.
+Otherwise, it is either `real', if some elements are floats, or
+`int'."
+  (letrec ((type 'int)
+	   (find-type
+	    (lambda (row)
+	      (dolist (e row type)
+		(cond ((listp e) (setq type (funcall find-type e)))
+		      ((stringp e) (throw 'exit 'string))
+		      ((floatp e) (setq type 'real)))))))
+    (catch 'exit (funcall find-type data)) type))
 
 (provide 'ob-asymptote)
 
diff --git a/elpa/org-plus-contrib-20150831/ob-awk.el b/elpa/org-plus-contrib-20170407/ob-awk.el
similarity index 80%
rename from elpa/org-plus-contrib-20150831/ob-awk.el
rename to elpa/org-plus-contrib-20170407/ob-awk.el
index eb03b469..2db4eeae 100644
--- a/elpa/org-plus-contrib-20150831/ob-awk.el
+++ b/elpa/org-plus-contrib-20170407/ob-awk.el
@@ -1,6 +1,6 @@
-;;; ob-awk.el --- org-babel functions for awk evaluation
+;;; ob-awk.el --- Babel Functions for Awk            -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2011-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2017 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
@@ -27,13 +27,12 @@
 ;;
 ;; - :in-file takes a path to a file of data to be processed by awk
 ;;
-;; - :stdin takes an Org-mode data or code block reference, the value
-;;          of which will be passed to the awk process through STDIN
+;; - :stdin takes an Org data or code block reference, the value of
+;;          which will be passed to the awk process through STDIN
 
 ;;; Code:
 (require 'ob)
 (require 'org-compat)
-(eval-when-compile (require 'cl))
 
 (declare-function org-babel-ref-resolve "ob-ref" (ref))
 (declare-function orgtbl-to-generic "org-table" (table params))
@@ -44,7 +43,7 @@
 (defvar org-babel-awk-command "awk"
   "Name of the awk executable command.")
 
-(defun org-babel-expand-body:awk (body params)
+(defun org-babel-expand-body:awk (body _params)
   "Expand BODY according to PARAMS, return the expanded body."
   body)
 
@@ -52,13 +51,13 @@
   "Execute a block of Awk code with org-babel.  This function is
 called by `org-babel-execute-src-block'"
   (message "executing Awk source code block")
-  (let* ((result-params (cdr (assoc :result-params params)))
-         (cmd-line (cdr (assoc :cmd-line params)))
-         (in-file (cdr (assoc :in-file params)))
+  (let* ((result-params (cdr (assq :result-params params)))
+         (cmd-line (cdr (assq :cmd-line params)))
+         (in-file (cdr (assq :in-file params)))
 	 (full-body (org-babel-expand-body:awk body params))
 	 (code-file (let ((file (org-babel-temp-file "awk-")))
                       (with-temp-file file (insert full-body)) file))
-	 (stdin (let ((stdin (cdr (assoc :stdin params))))
+	 (stdin (let ((stdin (cdr (assq :stdin params))))
 		   (when stdin
 		     (let ((tmp (org-babel-temp-file "awk-stdin-"))
 			   (res (org-babel-ref-resolve stdin)))
@@ -71,10 +70,10 @@ called by `org-babel-execute-src-block'"
 				"-f" code-file cmd-line)
 			  (mapcar (lambda (pair)
 				    (format "-v %s='%s'"
-					    (cadr pair)
+					    (car pair)
 					    (org-babel-awk-var-to-awk
-					     (cddr pair))))
-				  (org-babel-get-header params :var))
+					     (cdr pair))))
+				  (org-babel--get-vars params))
 			  (list in-file))
 			 " ")))
     (org-babel-reassemble-table
@@ -91,9 +90,9 @@ called by `org-babel-execute-src-block'"
 	     (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)))
+      (cdr (assq :colname-names params)) (cdr (assq :colnames params)))
      (org-babel-pick-name
-      (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params))))))
+      (cdr (assq :rowname-names params)) (cdr (assq :rownames params))))))
 
 (defun org-babel-awk-var-to-awk (var &optional sep)
   "Return a printed value of VAR suitable for parsing with awk."
diff --git a/elpa/org-plus-contrib-20150831/ob-calc.el b/elpa/org-plus-contrib-20170407/ob-calc.el
similarity index 87%
rename from elpa/org-plus-contrib-20150831/ob-calc.el
rename to elpa/org-plus-contrib-20170407/ob-calc.el
index 5dec244a..d4b7260c 100644
--- a/elpa/org-plus-contrib-20150831/ob-calc.el
+++ b/elpa/org-plus-contrib-20170407/ob-calc.el
@@ -1,6 +1,6 @@
-;;; ob-calc.el --- org-babel functions for calc code evaluation
+;;; ob-calc.el --- Babel Functions for Calc          -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2010-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2017 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
@@ -28,18 +28,18 @@
 ;;; Code:
 (require 'ob)
 (require 'calc)
-(unless (featurep 'xemacs)
-  (require 'calc-trail)
-  (require 'calc-store))
+(require 'calc-trail)
+(require 'calc-store)
 
 (declare-function calc-store-into    "calc-store" (&optional var))
 (declare-function calc-recall        "calc-store" (&optional var))
 (declare-function math-evaluate-expr "calc-ext"   (x))
+(declare-function org-trim "org" (s &optional keep-lead))
 
 (defvar org-babel-default-header-args:calc nil
   "Default arguments for evaluating an calc source block.")
 
-(defun org-babel-expand-body:calc (body params)
+(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
@@ -48,7 +48,7 @@
   "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)))
+  (let* ((vars (org-babel--get-vars params))
 	 (org--var-syms (mapcar #'car vars))
 	 (var-names (mapcar #'symbol-name org--var-syms)))
     (mapc
@@ -85,15 +85,17 @@
                                    ;; parse line into calc objects
                                    (car (math-read-exprs line)))))))))
                   ))))))
-     (mapcar #'org-babel-trim
+     (mapcar #'org-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)))))
+      (prog1
+        (calc-eval (calc-top 1))
+        (calc-pop 1)))))
 
 (defun org-babel-calc-maybe-resolve-var (el)
   (if (consp el)
-      (if (and (equal 'var (car el)) (member (cadr el) org--var-syms))
+      (if (and (eq 'var (car el)) (member (cadr el) org--var-syms))
 	  (progn
 	    (calc-recall (cadr el))
 	    (prog1 (calc-top 1)
diff --git a/elpa/org-plus-contrib-20170407/ob-clojure.el b/elpa/org-plus-contrib-20170407/ob-clojure.el
new file mode 100644
index 00000000..ada35a4b
--- /dev/null
+++ b/elpa/org-plus-contrib-20170407/ob-clojure.el
@@ -0,0 +1,198 @@
+;;; ob-clojure.el --- Babel Functions for Clojure    -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2009-2017 Free Software Foundation, Inc.
+
+;; Author: Joel Boehland, Eric Schulte, Oleh Krehel, Frederick Giasson
+;;
+;; 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 .
+
+;;; Commentary:
+
+;; Support for evaluating clojure code
+
+;; Requirements:
+
+;; - clojure (at least 1.2.0)
+;; - clojure-mode
+;; - either cider or SLIME
+
+;; For Cider, see https://github.com/clojure-emacs/cider
+
+;; For SLIME, 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 'cl-lib)
+(require 'ob)
+
+(declare-function cider-current-connection "ext:cider-client" (&optional type))
+(declare-function cider-current-ns "ext:cider-client" ())
+(declare-function nrepl--merge "ext:nrepl-client" (dict1 dict2))
+(declare-function nrepl-dict-get "ext:nrepl-client" (dict key))
+(declare-function nrepl-dict-put "ext:nrepl-client" (dict key value))
+(declare-function nrepl-request:eval "ext:nrepl-client"
+		  (input callback connection &optional session ns line column additional-params))
+(declare-function nrepl-sync-request:eval "ext:nrepl-client"
+		  (input connection session &optional ns))
+(declare-function org-trim "org" (s &optional keep-lead))
+(declare-function slime-eval "ext:slime" (sexp &optional package))
+
+(defvar nrepl-sync-request-timeout)
+
+(defvar org-babel-tangle-lang-exts)
+(add-to-list 'org-babel-tangle-lang-exts '("clojure" . "clj"))
+
+(defvar org-babel-default-header-args:clojure '())
+(defvar org-babel-header-args:clojure '((package . :any)))
+
+(defcustom org-babel-clojure-sync-nrepl-timeout 10
+  "Timeout value, in seconds, of a Clojure sync call.
+If the value is nil, timeout is disabled."
+  :group 'org-babel
+  :type 'integer
+  :version "26.1"
+  :package-version '(Org . "9.1")
+  :safe #'wholenump)
+
+(defcustom org-babel-clojure-backend
+  (cond ((featurep 'cider) 'cider)
+	(t 'slime))
+  "Backend used to evaluate Clojure code blocks."
+  :group 'org-babel
+  :type '(choice
+	  (const :tag "cider" cider)
+	  (const :tag "SLIME" slime)))
+
+(defun org-babel-expand-body:clojure (body params)
+  "Expand BODY according to PARAMS, return the expanded body."
+  (let* ((vars (org-babel--get-vars params))
+	 (result-params (cdr (assq :result-params params)))
+	 (print-level nil) (print-length nil)
+	 (body (org-trim
+		(if (null vars) (org-trim body)
+		  (concat "(let ["
+			  (mapconcat
+			   (lambda (var)
+			     (format "%S (quote %S)" (car var) (cdr var)))
+			   vars "\n      ")
+			  "]\n" body ")")))))
+    (if (or (member "code" result-params)
+	    (member "pp" result-params))
+	(format "(clojure.pprint/pprint (do %s))" body)
+      body)))
+
+(defun org-babel-execute:clojure (body params)
+  "Execute a block of Clojure code with Babel.
+The underlying process performed by the code block can be output
+using the :show-process parameter."
+  (let ((expanded (org-babel-expand-body:clojure body params))
+	(response (list 'dict))
+        result)
+    (cl-case org-babel-clojure-backend
+      (cider
+       (require 'cider)
+       (let ((result-params (cdr (assq :result-params params)))
+	     (show (cdr (assq :show-process params))))
+         (if (member show '(nil "no"))
+	     ;; Run code without showing the process.
+	     (progn
+	       (setq response
+		     (let ((nrepl-sync-request-timeout
+			    org-babel-clojure-sync-nrepl-timeout))
+		       (nrepl-sync-request:eval expanded
+						(cider-current-connection)
+						(cider-current-ns))))
+	       (setq result
+		     (concat
+		      (nrepl-dict-get response
+				      (if (or (member "output" result-params)
+					      (member "pp" result-params))
+					  "out"
+					"value"))
+		      (nrepl-dict-get response "ex")
+		      (nrepl-dict-get response "root-ex")
+		      (nrepl-dict-get response "err"))))
+	   ;; Show the process in an output buffer/window.
+           (let ((process-buffer (switch-to-buffer-other-window
+				  "*Clojure Show Process Sub Buffer*"))
+		 status)
+	     ;; Run the Clojure code in nREPL.
+	     (nrepl-request:eval
+	      expanded
+	      (lambda (resp)
+		(when (member "out" resp)
+		  ;; Print the output of the nREPL in the output buffer.
+		  (princ (nrepl-dict-get resp "out") process-buffer))
+		(when (member "ex" resp)
+		  ;; In case there is an exception, then add it to the
+		  ;; output buffer as well.
+		  (princ (nrepl-dict-get resp "ex") process-buffer)
+		  (princ (nrepl-dict-get resp "root-ex") process-buffer))
+		(when (member "err" resp)
+		  ;; In case there is an error, then add it to the
+		  ;; output buffer as well.
+		  (princ (nrepl-dict-get resp "err") process-buffer))
+		(nrepl--merge response resp)
+		;; Update the status of the nREPL output session.
+		(setq status (nrepl-dict-get response "status")))
+	      (cider-current-connection)
+	      (cider-current-ns))
+
+	     ;; Wait until the nREPL code finished to be processed.
+	     (while (not (member "done" status))
+	       (nrepl-dict-put response "status" (remove "need-input" status))
+	       (accept-process-output nil 0.01)
+	       (redisplay))
+
+	     ;; Delete the show buffer & window when the processing is
+	     ;; finalized.
+	     (mapc #'delete-window
+		   (get-buffer-window-list process-buffer nil t))
+	     (kill-buffer process-buffer)
+
+	     ;; Put the output or the value in the result section of
+	     ;; the code block.
+	     (setq result
+		   (concat
+		    (nrepl-dict-get response
+				    (if (or (member "output" result-params)
+					    (member "pp" result-params))
+					"out"
+				      "value"))
+		    (nrepl-dict-get response "ex")
+		    (nrepl-dict-get response "root-ex")
+		    (nrepl-dict-get response "err")))))))
+      (slime
+       (require 'slime)
+       (with-temp-buffer
+	 (insert expanded)
+	 (setq result
+	       (slime-eval
+		`(swank:eval-and-grab-output
+		  ,(buffer-substring-no-properties (point-min) (point-max)))
+		(cdr (assq :package params)))))))
+    (org-babel-result-cond (cdr (assq :result-params params))
+      result
+      (condition-case nil (org-babel-script-escape result)
+	(error result)))))
+
+(provide 'ob-clojure)
+
+;;; ob-clojure.el ends here
diff --git a/elpa/org-plus-contrib-20150831/ob-comint.el b/elpa/org-plus-contrib-20170407/ob-comint.el
similarity index 86%
rename from elpa/org-plus-contrib-20150831/ob-comint.el
rename to elpa/org-plus-contrib-20170407/ob-comint.el
index afbbf84b..cc60f4e4 100644
--- a/elpa/org-plus-contrib-20150831/ob-comint.el
+++ b/elpa/org-plus-contrib-20170407/ob-comint.el
@@ -1,6 +1,6 @@
-;;; ob-comint.el --- org-babel functions for interaction with comint buffers
+;;; ob-comint.el --- Babel Functions for Interaction with Comint Buffers -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2009-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2017 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research, comint
@@ -33,9 +33,7 @@
 (require 'ob-core)
 (require 'org-compat)
 (require 'comint)
-(eval-when-compile (require 'cl))
-(declare-function with-parsed-tramp-file-name "tramp" (filename var &rest body))
-(declare-function tramp-flush-directory-property "tramp" (vec directory))
+(require 'tramp)
 
 (defun org-babel-comint-buffer-livep (buffer)
   "Check if BUFFER is a comint buffer with a live process."
@@ -53,8 +51,9 @@ executed inside the protection of `save-excursion' and
        (error "Buffer %s does not exist or has no process" ,buffer))
      (save-match-data
        (with-current-buffer ,buffer
-	 (let ((comint-input-filter (lambda (input) nil)))
-	   ,@body)))))
+	 (save-excursion
+	   (let ((comint-input-filter (lambda (_input) nil)))
+	     ,@body))))))
 (def-edebug-spec org-babel-comint-in-buffer (form body))
 
 (defmacro org-babel-comint-with-output (meta &rest body)
@@ -79,7 +78,7 @@ or user `keyboard-quit' during execution of body."
 	      (comint-output-filter-functions
 	       (cons (lambda (text) (setq string-buffer (concat string-buffer text)))
 		     comint-output-filter-functions))
-	      dangling-text raw)
+	      dangling-text)
 	 ;; got located, and save dangling text
 	 (goto-char (process-mark (get-buffer-process (current-buffer))))
 	 (let ((start (point))
@@ -107,12 +106,12 @@ or user `keyboard-quit' during execution of body."
 	 (insert dangling-text)
 
 	 ;; remove echo'd FULL-BODY from input
-	 (if (and ,remove-echo ,full-body
-		  (string-match
-		   (replace-regexp-in-string
-		    "\n" "[\r\n]+" (regexp-quote (or ,full-body "")))
-		   string-buffer))
-	     (setq raw (substring string-buffer (match-end 0))))
+	 (when (and ,remove-echo ,full-body
+		    (string-match
+		     (replace-regexp-in-string
+		      "\n" "[\r\n]+" (regexp-quote (or ,full-body "")))
+		     string-buffer))
+	   (setq string-buffer (substring string-buffer (match-end 0))))
 	 (split-string string-buffer comint-prompt-regexp)))))
 (def-edebug-spec org-babel-comint-with-output (sexp body))
 
@@ -145,15 +144,14 @@ Don't return until FILE exists.  Code in STRING must ensure that
 FILE exists at end of evaluation."
   (unless (org-babel-comint-buffer-livep buffer)
     (error "Buffer %s does not exist or has no process" buffer))
-  (if (file-exists-p file) (delete-file file))
+  (when (file-exists-p file) (delete-file file))
   (process-send-string
    (get-buffer-process buffer)
    (if (= (aref string (1- (length string))) ?\n) string (concat string "\n")))
   ;; From Tramp 2.1.19 the following cache flush is not necessary
-  (if (file-remote-p default-directory)
-      (let (v)
-	(with-parsed-tramp-file-name default-directory nil
-				     (tramp-flush-directory-property v ""))))
+  (when (file-remote-p default-directory)
+    (with-parsed-tramp-file-name default-directory nil
+      (tramp-flush-directory-property v "")))
   (while (not (file-exists-p file)) (sit-for (or period 0.25))))
 
 (provide 'ob-comint)
diff --git a/elpa/org-plus-contrib-20150831/ob-coq.el b/elpa/org-plus-contrib-20170407/ob-coq.el
similarity index 90%
rename from elpa/org-plus-contrib-20150831/ob-coq.el
rename to elpa/org-plus-contrib-20170407/ob-coq.el
index 0147786b..93d2b1f7 100644
--- a/elpa/org-plus-contrib-20150831/ob-coq.el
+++ b/elpa/org-plus-contrib-20170407/ob-coq.el
@@ -1,6 +1,6 @@
-;;; ob-coq.el --- org-babel functions for Coq
+;;; ob-coq.el --- Babel Functions for Coq            -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2010-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2017 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
@@ -35,11 +35,12 @@
 (declare-function run-coq "ext:coq-inferior.el" (cmd))
 (declare-function coq-proc "ext:coq-inferior.el" ())
 
+(defvar coq-program-name "coqtop"
+  "Name of the coq toplevel to run.")
+
 (defvar org-babel-coq-buffer "*coq*"
   "Buffer in which to evaluate coq code blocks.")
 
-(defvar org-babel-coq-eoe "org-babel-coq-eoe")
-
 (defun org-babel-coq-clean-prompt (string)
   (if (string-match "^[^[:space:]]+ < " string)
       (substring string 0 (match-beginning 0))
@@ -70,7 +71,7 @@ If there is not a current inferior-process-buffer in SESSION then
 create one.  Return the initialized session."
   (unless (fboundp 'run-coq)
     (error "`run-coq' not defined, load coq-inferior.el"))
-  (save-window-excursion (run-coq "coqtop"))
+  (save-window-excursion (run-coq coq-program-name))
   (sit-for 0.1)
   (get-buffer org-babel-coq-buffer))
 
diff --git a/elpa/org-plus-contrib-20150831/ob-core.el b/elpa/org-plus-contrib-20170407/ob-core.el
similarity index 64%
rename from elpa/org-plus-contrib-20150831/ob-core.el
rename to elpa/org-plus-contrib-20170407/ob-core.el
index f642b186..d64f7b1e 100644
--- a/elpa/org-plus-contrib-20150831/ob-core.el
+++ b/elpa/org-plus-contrib-20170407/ob-core.el
@@ -1,6 +1,6 @@
-;;; ob-core.el --- working with code blocks in org-mode
+;;; ob-core.el --- Working with Code Blocks          -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2009-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2017 Free Software Foundation, Inc.
 
 ;; Authors: Eric Schulte
 ;;	Dan Davison
@@ -23,8 +23,7 @@
 ;; along with GNU Emacs.  If not, see .
 
 ;;; Code:
-(eval-when-compile
-  (require 'cl))
+(require 'cl-lib)
 (require 'ob-eval)
 (require 'org-macs)
 (require 'org-compat)
@@ -33,75 +32,70 @@
   (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-every "org" (pred seq))
-(declare-function org-remove-indentation "org" (code &optional n))
-(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))
+(defvar org-edit-src-content-indentation)
+(defvar org-src-lang-modes)
+(defvar org-src-preserve-indentation)
+
+(declare-function org-at-item-p "org-list" ())
+(declare-function org-at-table-p "org" (&optional table-type))
+(declare-function org-babel-lob-execute-maybe "ob-lob" ())
+(declare-function org-babel-ref-goto-headline-id "ob-ref" (id))
+(declare-function org-babel-ref-headline-body "ob-ref" ())
+(declare-function org-babel-ref-parse "ob-ref" (assignment))
+(declare-function org-babel-ref-resolve "ob-ref" (ref))
+(declare-function org-babel-ref-split-args "ob-ref" (arg-string))
+(declare-function org-babel-tangle-comment-links "ob-tangle" (&optional info))
+(declare-function org-completing-read "org" (&rest args))
+(declare-function org-current-level "org" ())
+(declare-function org-cycle "org" (&optional arg))
+(declare-function org-do-remove-indentation "org" (&optional n))
 (declare-function org-edit-src-code "org-src" (&optional code edit-buffer-name))
 (declare-function org-edit-src-exit "org-src"  ())
-(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-element-at-point "org-element" ())
+(declare-function org-element-context "org-element" (&optional element))
+(declare-function org-element-normalize-string "org-element" (s))
+(declare-function org-element-property "org-element" (property element))
+(declare-function org-element-type "org-element" (element))
+(declare-function org-entry-get "org" (pom property &optional inherit literal-nil))
+(declare-function org-escape-code-in-region "org-src" (beg end))
+(declare-function org-get-indentation "org" (&optional line))
+(declare-function org-get-indentation "org" (&optional line))
+(declare-function org-in-regexp "org" (regexp &optional nlines visually))
+(declare-function org-indent-line "org" ())
+(declare-function org-list-get-list-end "org-list" (item struct prevs))
+(declare-function org-list-prevs-alist "org-list" (struct))
+(declare-function org-list-struct "org-list" ())
+(declare-function org-list-to-generic "org-list" (LIST PARAMS))
+(declare-function org-list-to-lisp "org-list" (&optional delete))
+(declare-function org-macro-escape-arguments "org-macro" (&rest args))
 (declare-function org-make-options-regexp "org" (kwds &optional extra))
-(declare-function org-do-remove-indentation "org" (&optional n))
+(declare-function org-mark-ring-push "org" (&optional pos buffer))
+(declare-function org-narrow-to-subtree "org" ())
 (declare-function org-next-block "org" (arg &optional backward block-regexp))
+(declare-function org-number-sequence "org-compat" (from &optional to inc))
+(declare-function org-open-at-point "org" (&optional in-emacs reference-buffer))
+(declare-function org-outline-overlay-data "org" (&optional use-markers))
 (declare-function org-previous-block "org" (arg &optional block-regexp))
+(declare-function org-remove-indentation "org" (code &optional n))
+(declare-function org-reverse-string "org" (string))
+(declare-function org-set-outline-overlay-data "org" (data))
 (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-split-string "org" (string &optional separators))
+(declare-function org-src-coderef-format "org-src" (element))
+(declare-function org-src-coderef-regexp "org-src" (fmt &optional label))
 (declare-function org-table-align "org-table" ())
 (declare-function org-table-end "org-table" (&optional table-type))
+(declare-function org-table-import "org-table" (file arg))
+(declare-function org-table-to-lisp "org-table" (&optional txt))
+(declare-function org-trim "org" (s &optional keep-lead))
+(declare-function org-unescape-code-in-string "org-src" (s))
+(declare-function org-uniquify "org" (list))
 (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))
-(declare-function org-element-type "org-element" (element))
-(declare-function org-element-at-point "org-element" ())
-(declare-function org-element-property "org-element" (property element))
-(declare-function org-every "org" (pred seq))
-(declare-function org-macro-escape-arguments "org-macro" (&rest args))
+(declare-function outline-show-all "outline" ())
+(declare-function tramp-compat-make-temp-file "tramp-compat" (filename &optional dir-flag))
 
 (defgroup org-babel nil
   "Code block evaluation and management in `org-mode' documents."
@@ -110,11 +104,12 @@
 
 (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
+blocks in Org 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
@@ -122,10 +117,11 @@ 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
+remove code block execution from `\\[org-ctrl-c-ctrl-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."
+remove code block execution from the `\\[org-ctrl-c-ctrl-c]' keybinding."
   :group 'org-babel
   :version "24.1"
   :type '(choice boolean function))
@@ -133,7 +129,8 @@ remove code block execution from the C-c C-c keybinding."
 (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."
+  "\\\
+Remove code block evaluation from the `\\[org-ctrl-c-ctrl-c]' key binding."
   :group 'org-babel
   :version "24.1"
   :type 'boolean)
@@ -174,6 +171,22 @@ This string must include a \"%s\" which will be replaced by the results."
        (and (stringp value)
 	    (string-match-p "%s" value))))
 
+(defcustom org-babel-hash-show-time nil
+  "Non-nil means show the time the code block was evaluated in the result hash."
+  :group 'org-babel
+  :type 'boolean
+  :version "26.1"
+  :package-version '(Org . "9.0")
+  :safe #'booleanp)
+
+(defcustom org-babel-uppercase-example-markers nil
+  "When non-nil, begin/end example markers will be inserted in upper case."
+  :group 'org-babel
+  :type 'boolean
+  :version "26.1"
+  :package-version '(Org . "9.1")
+  :safe #'booleanp)
+
 (defun org-babel-noweb-wrap (&optional regexp)
   (concat org-babel-noweb-wrap-start
 	  (or regexp "\\([^ \t\n].+?[^ \t]\\|[^ \t\n]\\)")
@@ -199,165 +212,100 @@ This string must include a \"%s\" which will be replaced by the results."
    "\\([^\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)
-   "\\(\\|\\[[ \t]*\\(.*?\\)\\]\\)"
-   ;; (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"
- (save-excursion
-    (let ((datum (org-element-context)))
-      (when (eq (org-element-type datum) 'inline-src-block)
-	(goto-char (org-element-property :begin datum))
-	(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
-    (let ((datum (org-element-context)))
-      (when (eq (org-element-type datum) 'inline-babel-call)
-	(goto-char (org-element-property :begin datum))))
-    (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.
+(defun org-babel--get-vars (params)
+  "Return the babel variable assignments in PARAMS.
 
-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-named-src-block-regexp-for-name))
-	    (setq name (org-match-string-no-properties 9))))
-      ;; inline source block
-      (when (org-babel-get-inline-src-block-matches)
-	(setq head (match-beginning 0))
-	(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
-      (setf (nth 2 info) (org-babel-generate-file-param name (nth 2 info))))
-    (when info (append info (list name indent head)))))
+PARAMS is a quasi-alist of header args, which may contain
+multiple entries for the key `:var'.  This function returns a
+list of the cdr of all the `:var' entries."
+  (mapcar #'cdr
+	  (cl-remove-if-not (lambda (x) (eq (car x) :var)) params)))
 
 (defvar org-babel-exp-reference-buffer nil
   "Buffer containing original contents of the exported buffer.
 This is used by Babel to resolve references in source blocks.
 Its value is dynamically bound during export.")
 
-(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 head 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))
-	    (,head           (nth 6 ,info))
-	    (,eval           (or (cdr  (assoc :eval   ,headers))
-				 (when (assoc :noeval ,headers) "no")))
-	    (,eval-no        (or (equal ,eval "no")
-				 (equal ,eval "never")))
-	    (,export         org-babel-exp-reference-buffer)
-	    (,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)
-				     (save-excursion
-				       (goto-char ,head)
-				       (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 "Evaluation of this%scode-block%sis disabled."
-                    code-block block-name)))))
+(defun org-babel-check-confirm-evaluate (info)
+  "Check whether INFO allows code block evaluation.
+
+Returns nil if evaluation is disallowed, t if it is
+unconditionally allowed, and the symbol `query' if the user
+should be asked whether to allow evaluation."
+  (let* ((headers (nth 2 info))
+	 (eval (or (cdr  (assq :eval headers))
+		   (when (assq :noeval headers) "no")))
+	 (eval-no (member eval '("no" "never")))
+	 (export org-babel-exp-reference-buffer)
+	 (eval-no-export (and export (member eval '("no-export" "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)
+			(save-excursion
+			  (goto-char (nth 5 info))
+			  (funcall org-confirm-babel-evaluate
+				   ;; language, code block body
+				   (nth 0 info) (nth 1 info)))
+		      org-confirm-babel-evaluate))))
+    (cond
+     (noeval nil)
+     (query 'query)
+     (t t))))
 
- ;; dynamically scoped for asynchronous export
+(defun org-babel-check-evaluate (info)
+  "Check if code block INFO should be evaluated.
+Do not query the user, but do display an informative message if
+evaluation is blocked.  Returns non-nil if evaluation is not blocked."
+  (let ((confirmed (org-babel-check-confirm-evaluate info)))
+    (unless confirmed
+      (message "Evaluation of this %s code block%sis disabled."
+	       (nth 0 info)
+	       (let ((name (nth 4 info)))
+		 (if name (format " (%s) " name) " "))))
+    confirmed))
+
+;; Dynamically scoped for asynchronous export.
 (defvar org-babel-confirm-evaluate-answer-no)
 
-(defsubst org-babel-confirm-evaluate (info)
+(defun 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
+of potentially harmful code.
+
+The variable `org-babel-confirm-evaluate-answer-no' is used by
+the async export process, which requires a non-interactive
+environment, to override this check."
+  (let* ((evalp (org-babel-check-confirm-evaluate info))
+	 (lang (nth 0 info))
+	 (name (nth 4 info))
+	 (name-string (if name (format " (%s) " name) " ")))
+    (pcase evalp
+      (`nil nil)
+      (`t t)
+      (`query (or
+	       (and (not (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 "Evaluation of this%scode-block%sis aborted."
-                      code-block block-name))))))
+		     (format "Evaluate this %s code block%son your system? "
+			     lang name-string)))
+	       (progn
+		(message "Evaluation of this %s code block%sis aborted."
+			 lang name-string)
+		nil)))
+      (x (error "Unexpected value `%s' from `org-babel-check-confirm-evaluate'" x)))))
 
 ;;;###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)
@@ -368,8 +316,8 @@ of potentially harmful code."
   "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))
+  `(if (memq (org-element-type (org-element-context))
+	     '(inline-src-block src-block))
        (progn
 	 ,@body
 	 t)
@@ -511,7 +459,7 @@ The list can have entries of the following forms:
   "Return a function that determines whether a list of header args are safe.
 
 Intended usage is:
-\(put 'org-babel-default-header-args 'safe-local-variable
+\(put \\='org-babel-default-header-args \\='safe-local-variable
  (org-babel-header-args-safe-p org-babel-safe-header-args)
 
 This allows org-babel languages to extend the list of safe values for
@@ -520,7 +468,7 @@ their `org-babel-default-header-args:foo' variable.
 For the format of SAFE-LIST, see `org-babel-safe-header-args'."
   `(lambda (value)
      (and (listp value)
-	  (org-every
+	  (cl-every
 	   (lambda (pair)
 	     (and (consp pair)
 		  (org-babel-one-header-arg-safe-p pair ,safe-list)))
@@ -540,22 +488,26 @@ For the format of SAFE-LIST, see `org-babel-safe-header-args'."
 (put 'org-babel-default-inline-header-args 'safe-local-variable
      (org-babel-header-args-safe-fn org-babel-safe-header-args))
 
-(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]*")
+(defconst org-babel-name-regexp
+  (format "^[ \t]*#\\+%s:[ \t]*"
+	  ;; FIXME: TBLNAME is for backward compatibility.
+	  (regexp-opt '("NAME" "TBLNAME")))
+  "Regexp matching a NAME keyword.")
+
+(defconst org-babel-result-regexp
+  (format "^[ \t]*#\\+%s\\(?:\\[\\(?:%s \\)?\\([[:alnum:]]+\\)\\]\\)?:[ \t]*"
+	  org-babel-results-keyword
+	  ;; <%Y-%m-%d %H:%M:%S>
+	  "<\\(?:[0-9]\\{4\\}-[0-1][0-9]-[0-3][0-9] \
+[0-2][0-9]\\(?::[0-5][0-9]\\)\\{2\\}\\)>")
   "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.")
+be saved in match group 1.")
 
-(defvar org-babel-result-w-name-regexp
-  (concat org-babel-result-regexp
-	  "\\([^ ()\f\t\n\r\v]+\\)\\(\(\\(.*\\)\)\\|\\)"))
+(defconst org-babel-result-w-name-regexp
+  (concat org-babel-result-regexp "\\(?9:[^ \t\n\r\v\f]+\\)")
+  "Regexp matching a RESULTS keyword with a name.
+Name is saved in match group 9.")
 
 (defvar org-babel-min-lines-for-block-output 10
   "The minimum number of lines for block output.
@@ -580,9 +532,6 @@ to raise errors for all languages.")
 (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'")
 
@@ -599,10 +548,27 @@ match group 9.  Other match groups are defined in
 
 (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]\\|$\\)"))
+  (concat org-babel-name-regexp (regexp-quote name) "[ \t]*$"))
+
+(defun org-babel--normalize-body (datum)
+  "Normalize body for element or object DATUM.
+DATUM is a source block element or an inline source block object.
+Remove final newline character and spurious indentation."
+  (let* ((value (org-element-property :value datum))
+	 (body (if (string-suffix-p "\n" value)
+		   (substring value 0 -1)
+		 value)))
+    (cond ((eq (org-element-type datum) 'inline-src-block)
+	   ;; Newline characters and indentation in an inline
+	   ;; src-block are not meaningful, since they could come from
+	   ;; some paragraph filling.  Treat them as a white space.
+	   (replace-regexp-in-string "\n[ \t]*" " " body))
+	  ((or org-src-preserve-indentation
+	       (org-element-property :preserve-indent datum))
+	   body)
+	  (t (org-remove-indentation body)))))
 
 ;;; 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
@@ -610,6 +576,58 @@ 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.")
 
+(defvar *this*)
+
+(defun org-babel-get-src-block-info (&optional light datum)
+  "Extract information from a source block or inline source block.
+
+Optional argument LIGHT does not resolve remote variable
+references; a process which could likely result in the execution
+of other code blocks.
+
+By default, consider the block at point.  However, when optional
+argument DATUM is provided, extract information from that parsed
+object instead.
+
+Return nil if point is not on a source block.  Otherwise, return
+a list with the following pattern:
+
+  (language body arguments switches name start coderef)"
+  (let* ((datum (or datum (org-element-context)))
+	 (type (org-element-type datum))
+	 (inline (eq type 'inline-src-block)))
+    (when (memq type '(inline-src-block src-block))
+      (let* ((lang (org-element-property :language datum))
+	     (lang-headers (intern
+			    (concat "org-babel-default-header-args:" lang)))
+	     (name (org-element-property :name datum))
+	     (info
+	      (list
+	       lang
+	       (org-babel--normalize-body datum)
+	       (apply #'org-babel-merge-params
+		      (if inline org-babel-default-inline-header-args
+			org-babel-default-header-args)
+		      (and (boundp lang-headers) (eval lang-headers t))
+		      (append
+		       ;; If DATUM is provided, make sure we get node
+		       ;; properties applicable to its location within
+		       ;; the document.
+		       (org-with-point-at (org-element-property :begin datum)
+			 (org-babel-params-from-properties lang))
+		       (mapcar #'org-babel-parse-header-arguments
+			       (cons (org-element-property :parameters datum)
+				     (org-element-property :header datum)))))
+	       (or (org-element-property :switches datum) "")
+	       name
+	       (org-element-property (if inline :begin :post-affiliated)
+				     datum)
+	       (and (not inline) (org-src-coderef-format datum)))))
+	(unless light
+	  (setf (nth 2 info) (org-babel-process-params (nth 2 info))))
+	(setf (nth 2 info) (org-babel-generate-file-param name (nth 2 info)))
+	info))))
+
 ;;;###autoload
 (defun org-babel-execute-src-block (&optional arg info params)
   "Execute the current source code block.
@@ -629,113 +647,91 @@ 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)
-	      ;; inline src block
-	      (and (org-babel-get-inline-src-block-matches)
-		   (match-beginning 0))))
-	 (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))))
+	      (nth 5 info)
+	      (org-babel-where-is-src-block-head)))
+	 (info (if info (copy-tree info) (org-babel-get-src-block-info))))
+    ;; Merge PARAMS with INFO before considering source block
+    ;; evaluation since both could disagree.
+    (cl-callf org-babel-merge-params (nth 2 info) params)
+    (when (org-babel-check-evaluate info)
+      (cl-callf org-babel-process-params (nth 2 info))
+      (let* ((params (nth 2 info))
+	     (cache (let ((c (cdr (assq :cache params))))
+		      (and (not arg) c (string= "yes" c))))
+	     (new-hash (and cache (org-babel-sha1-hash info)))
+	     (old-hash (and cache (org-babel-current-result-hash)))
+	     (current-cache (and new-hash (equal new-hash old-hash))))
 	(cond
-	 (cache-current-p
-	  (save-excursion ;; return cached result
+	 (current-cache
+	  (save-excursion		;Return cached result.
 	    (goto-char (org-babel-where-is-src-block-result nil info))
 	    (forward-line)
 	    (skip-chars-forward " \t")
 	    (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))
+	      (message (replace-regexp-in-string "%" "%%" (format "%S" result)))
+	      result)))
+	 ((org-babel-confirm-evaluate info)
 	  (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)))
+		 (result-params (cdr (assq :result-params params)))
+		 ;; Expand noweb references in BODY and remove any
+		 ;; coderef.
+		 (body
+		  (let ((coderef (nth 6 info))
+			(expand
+			 (if (org-babel-noweb-p params :eval)
+			     (org-babel-expand-noweb-references info)
+			   (nth 1 info))))
+		    (if (not coderef) expand
+		      (replace-regexp-in-string
+		       (org-src-coderef-regexp coderef) "" expand nil nil 1))))
+		 (dir (cdr (assq :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)))))))))
+		 (cmd (intern (concat "org-babel-execute:" lang)))
+		 result)
+	    (unless (fboundp cmd)
+	      (error "No org-babel-execute function for %s!" lang))
+	    (message "executing %s code block%s..."
+		     (capitalize lang)
+		     (let ((name (nth 4 info)))
+		       (if name (format " (%s)" name) "")))
+	    (if (member "none" result-params)
+		(progn (funcall cmd body params)
+		       (message "result silenced"))
+	      (setq result
+		    (let ((r (funcall cmd body params)))
+		      (if (and (eq (cdr (assq :result-type params)) 'value)
+			       (or (member "vector" result-params)
+				   (member "table" result-params))
+			       (not (listp r)))
+			  (list (list r))
+			r)))
+	      (let ((file (cdr (assq :file params))))
+		;; If non-empty result and :file then write to :file.
+		(when file
+		  (when result
+		    (with-temp-file file
+		      (insert (org-babel-format-result
+			       result (cdr (assq :sep params))))))
+		  (setq result file))
+		;; Possibly perform post process provided its
+		;; appropriate.  Dynamically bind "*this*" to the
+		;; actual results of the block.
+		(let ((post (cdr (assq :post params))))
+		  (when post
+		    (let ((*this* (if (not file) result
+				    (org-babel-result-to-file
+				     file
+				     (let ((desc (assq :file-desc params)))
+				       (and desc (or (cdr desc) result)))))))
+		      (setq result (org-babel-ref-resolve post))
+		      (when file
+			(setq result-params (remove "file" result-params))))))
+		(org-babel-insert-result
+		 result result-params info new-hash lang)))
+	    (run-hooks 'org-babel-after-execute-hook)
+	    result)))))))
 
 (defun org-babel-expand-body:generic (body params &optional var-lines)
   "Expand BODY with PARAMS.
@@ -743,8 +739,8 @@ 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))))
+  (let ((pro (cdr (assq :prologue params)))
+	(epi (cdr (assq :epilogue params))))
     (mapconcat #'identity
 	       (append (when pro (list pro))
 		       var-lines
@@ -753,7 +749,7 @@ org-babel-expand-body:lang function."
 	       "\n")))
 
 ;;;###autoload
-(defun org-babel-expand-src-block (&optional arg info params)
+(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."
@@ -775,7 +771,7 @@ arguments and pop open the results in a preview buffer."
 	    (org-babel-expand-body:generic
 	     body params (and (fboundp assignments-cmd)
 			      (funcall assignments-cmd params))))))
-    (if (org-called-interactively-p 'any)
+    (if (called-interactively-p 'any)
 	(org-edit-src-code
 	 expanded (concat "*Org-Babel Preview " (buffer-name) "[ " lang " ]*"))
       expanded)))
@@ -806,10 +802,9 @@ arguments and pop open the results in a preview buffer."
   (let ((results (copy-sequence original)))
     (dolist (new-list others)
       (dolist (arg-pair new-list)
-	(let ((header (car arg-pair))
-	      (args (cdr arg-pair)))
+	(let ((header (car arg-pair)))
 	  (setq results
-		(cons arg-pair (org-remove-if
+		(cons arg-pair (cl-remove-if
 				(lambda (pair) (equal header (car pair)))
 				results))))))
     results))
@@ -842,13 +837,13 @@ arguments and pop open the results in a preview buffer."
   (interactive)
   (let* ((info (org-babel-get-src-block-info 'light))
 	 (lang (car info))
-	 (begin (nth 6 info))
+	 (begin (nth 5 info))
 	 (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))))
+		   (when (boundp lang-headers) (eval lang-headers t))))
 	 (header-arg (or header-arg
-			 (org-icompleting-read
+			 (completing-read
 			  "Header Arg: "
 			  (mapcar
 			   (lambda (header-spec) (symbol-name (car header-spec)))
@@ -861,7 +856,7 @@ arguments and pop open the results in a preview buffer."
 		     ((listp vals)
 		      (mapconcat
 		       (lambda (group)
-			 (let ((arg (org-icompleting-read
+			 (let ((arg (completing-read
 				     "Value: "
 				     (cons "default"
 					   (mapcar #'symbol-name group)))))
@@ -884,7 +879,7 @@ arguments and pop open the results in a preview buffer."
 (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)))
+         (lang-headers (when (boundp lang-headers-var) (eval lang-headers-var t)))
 	 (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)))
@@ -900,7 +895,7 @@ arguments and pop open the results in a preview buffer."
 (add-hook 'org-tab-first-hook 'org-babel-header-arg-expand)
 
 ;;;###autoload
-(defun org-babel-load-in-session (&optional arg info)
+(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
@@ -915,8 +910,8 @@ session."
 		       (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)))
+         (session (cdr (assq :session params)))
+	 (dir (cdr (assq :dir params)))
 	 (default-directory
 	   (or (and dir (file-name-as-directory dir)) default-directory))
 	 (cmd (intern (concat "org-babel-load-session:" lang))))
@@ -936,17 +931,17 @@ the session.  Copy the body of the code block to the kill ring."
          (lang (nth 0 info))
          (body (nth 1 info))
          (params (nth 2 info))
-         (session (cdr (assoc :session params)))
-	 (dir (cdr (assoc :dir params)))
+         (session (cdr (assq :session params)))
+	 (dir (cdr (assq :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!"))
+    (when (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))
+    (with-temp-buffer (insert (org-trim body))
                       (copy-region-as-kill (point-min) (point-max)))
     (when arg
       (unless (fboundp prep-cmd)
@@ -969,7 +964,7 @@ with a prefix argument then this is passed on to
 (defvar org-src-window-setup)
 
 ;;;###autoload
-(defun org-babel-switch-to-session-with-code (&optional arg info)
+(defun org-babel-switch-to-session-with-code (&optional arg _info)
   "Switch to code buffer and display session."
   (interactive "P")
   (let ((swap-windows
@@ -1001,10 +996,10 @@ Return t if a code block was found at point, nil otherwise."
   "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
+Org 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
@@ -1038,7 +1033,7 @@ results already exist."
 	    ;; file results
 	    (org-open-at-point)
 	  (let ((r (org-babel-format-result
-		    (org-babel-read-result) (cdr (assoc :sep (nth 2 info))))))
+		    (org-babel-read-result) (cdr (assq :sep (nth 2 info))))))
 	    (pop-to-buffer (get-buffer-create "*Org-Babel Results*"))
 	    (delete-region (point-min) (point-max))
 	    (insert r)))
@@ -1095,7 +1090,13 @@ end-body --------- point at the end of the body"
 		   (body (match-string 5))
 		   (beg-body (match-beginning 5))
 		   (end-body (match-end 5)))
-	       ,@body
+               ;; Silence byte-compiler in case `body' doesn't use all
+               ;; those variables.
+               (ignore full-block beg-block end-block lang
+                       beg-lang end-lang switches beg-switches
+                       end-switches header-args beg-header-args
+                       end-header-args body beg-body end-body)
+               ,@body
 	       (goto-char end-block)))))
        (unless visited-p (kill-buffer to-be-removed))
        (goto-char point))))
@@ -1103,81 +1104,91 @@ end-body --------- point at the end of the body"
 
 ;;;###autoload
 (defmacro org-babel-map-inline-src-blocks (file &rest body)
-  "Evaluate BODY forms on each inline source-block in FILE.
+  "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")))
+  (declare (indent 1) (debug (form body)))
+  (org-with-gensyms (datum end point tempvar to-be-removed visitedp)
     `(let* ((case-fold-search t)
 	    (,tempvar ,file)
-	    (visited-p (or (null ,tempvar)
+	    (,visitedp (or (null ,tempvar)
 			   (get-file-buffer (expand-file-name ,tempvar))))
-	    (point (point)) to-be-removed)
+	    (,point (point))
+	    ,to-be-removed)
        (save-window-excursion
 	 (when ,tempvar (find-file ,tempvar))
-	 (setq to-be-removed (current-buffer))
+	 (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)
+	 (while (re-search-forward "src_\\S-" nil t)
+	   (let ((,datum (save-match-data (org-element-context))))
+	     (when (eq (org-element-type ,datum) 'inline-src-block)
+	       (goto-char (match-beginning 0))
+	       (let ((,end (copy-marker (org-element-property :end ,datum))))
+		 ,@body
+		 (goto-char ,end)
+		 (set-marker ,end nil))))))
+       (unless ,visitedp (kill-buffer ,to-be-removed))
+       (goto-char ,point))))
 
 ;;;###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)
+  (declare (indent 1) (debug (form body)))
+  (org-with-gensyms (datum end point tempvar to-be-removed visitedp)
+    `(let* ((case-fold-search t)
+	    (,tempvar ,file)
+	    (,visitedp (or (null ,tempvar)
 			   (get-file-buffer (expand-file-name ,tempvar))))
-	    (point (point)) to-be-removed)
+	    (,point (point))
+	    ,to-be-removed)
        (save-window-excursion
 	 (when ,tempvar (find-file ,tempvar))
-	 (setq to-be-removed (current-buffer))
+	 (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))
+	 (while (re-search-forward "call_\\S-\\|^[ \t]*#\\+CALL:" nil t)
+	   (let ((,datum (save-match-data (org-element-context))))
+	     (when (memq (org-element-type ,datum)
+			 '(babel-call inline-babel-call))
+	       (goto-char (match-beginning 0))
+	       (let ((,end (copy-marker (org-element-property :end ,datum))))
+		 ,@body
+		 (goto-char ,end)
+		 (set-marker ,end nil))))))
+       (unless ,visitedp (kill-buffer ,to-be-removed))
+       (goto-char ,point))))
 
 ;;;###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)
+  "Evaluate BODY forms on each active Babel code in FILE.
+If FILE is nil evaluate BODY forms on source blocks in current
+buffer."
+  (declare (indent 1) (debug (form body)))
+  (org-with-gensyms (datum end point tempvar to-be-removed visitedp)
+    `(let* ((case-fold-search t)
+	    (,tempvar ,file)
+	    (,visitedp (or (null ,tempvar)
 			   (get-file-buffer (expand-file-name ,tempvar))))
-	    (point (point)) to-be-removed)
+	    (,point (point))
+	    ,to-be-removed)
        (save-window-excursion
 	 (when ,tempvar (find-file ,tempvar))
-	 (setq to-be-removed (current-buffer))
+	 (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))
+	 (while (re-search-forward
+		 "\\(call\\|src\\)_\\|^[ \t]*#\\+\\(BEGIN_SRC\\|CALL:\\)" nil t)
+	   (let ((,datum (save-match-data (org-element-context))))
+	     (when (memq (org-element-type ,datum)
+			 '(babel-call inline-babel-call inline-src-block
+				      src-block))
+	       (goto-char (match-beginning 0))
+	       (let ((,end (copy-marker (org-element-property :end ,datum))))
+		 ,@body
+		 (goto-char ,end)
+		 (set-marker ,end nil))))))
+       (unless ,visitedp (kill-buffer ,to-be-removed))
+       (goto-char ,point))))
 
 ;;;###autoload
 (defun org-babel-execute-buffer (&optional arg)
@@ -1188,7 +1199,8 @@ the current buffer."
   (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)
+      (if (memq (org-element-type (org-element-context))
+		'(babel-call inline-babel-call))
           (org-babel-lob-execute-maybe)
         (org-babel-execute-src-block arg)))))
 
@@ -1257,24 +1269,30 @@ the current subtree."
                                             (nth 2 info))) ":")
                          expanded))
              (hash (sha1 it)))
-        (when (org-called-interactively-p 'interactive) (message hash))
+        (when (called-interactively-p 'interactive) (message hash))
         hash))))
 
 (defun org-babel-current-result-hash (&optional info)
   "Return the current in-buffer hash."
-  (org-babel-where-is-src-block-result nil info)
-  (org-no-properties (match-string 5)))
+  (let ((result (org-babel-where-is-src-block-result nil info)))
+    (when result
+      (org-with-wide-buffer
+       (goto-char result)
+       (looking-at org-babel-result-regexp)
+       (match-string-no-properties 1)))))
 
 (defun org-babel-set-current-result-hash (hash info)
   "Set the current in-buffer hash to HASH."
-  (org-babel-where-is-src-block-result nil info)
-  (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)))
+  (org-with-wide-buffer
+   (goto-char (org-babel-where-is-src-block-result nil info))
+   (looking-at org-babel-result-regexp)
+   (goto-char (match-beginning 1))
+   (mapc #'delete-overlay (overlays-at (point)))
+   (forward-char org-babel-hash-show)
+   (mapc #'delete-overlay (overlays-at (point)))
+   (replace-match hash nil nil nil 1)
+   (beginning-of-line)
+   (org-babel-hide-hash)))
 
 (defun org-babel-hide-hash ()
   "Hide the hash in the current results line.
@@ -1283,11 +1301,11 @@ 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))
+               (match-string 1))
+      (let* ((start (match-beginning 1))
              (hide-start (+ org-babel-hash-show start))
-             (end (match-end 5))
-             (hash (match-string 5))
+             (end (match-end 1))
+             (hash (match-string 1))
              ov1 ov2)
         (setq ov1 (make-overlay start hide-start))
         (setq ov2 (make-overlay hide-start end))
@@ -1309,14 +1327,14 @@ the `org-mode-hook'."
 
 (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."
+This can be called with `\\[org-ctrl-c-ctrl-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.
@@ -1370,15 +1388,15 @@ portions of results lines."
                                 (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)))
+              (when (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
@@ -1398,8 +1416,8 @@ portions of results lines."
 (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)))
+	  (lambda () (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)
@@ -1408,21 +1426,6 @@ 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.
-     (org-babel-parse-multiple-vars
-      (delq nil
-	    (mapcar
-	     (lambda (header)
-	       (let* ((arg (symbol-name (car header)))
-		      (val (org-entry-get (point) arg t)))
-		 (and val
-		      (cons (intern (concat ":" arg))
-			    (org-babel-read val)))))
-	     (org-babel-combine-header-arg-lists
-	      org-babel-common-header-args-w-values
-	      (let ((sym (intern (concat "org-babel-header-args:" lang))))
-		(and (boundp sym) (symbol-value sym)))))))
      ;; header arguments specified with the header-args property at
      ;; point of call.
      (org-babel-parse-header-arguments
@@ -1435,60 +1438,12 @@ specified in the properties of the current outline entry."
 			  (concat "header-args:" lang)
 			  'inherit))))))
 
-(defvar org-src-preserve-indentation) ;; declare defcustom from org-src
-(defun org-babel-parse-src-block-match ()
-  "Parse the results from a match of the `org-babel-src-block-regexp'."
-  (let* ((block-indentation (string-width (match-string 1)))
-	 (lang (org-match-string-no-properties 2))
-         (lang-headers (intern (concat "org-babel-default-header-args:" lang)))
-	 (switches (match-string 3))
-         (body (let* ((body (org-match-string-no-properties 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) ""))))))
-	  nil)))
-
 (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)."
+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)
@@ -1521,7 +1476,7 @@ instances of \"[ \t]:\" set ALTS to '((32 9) . 58)."
   (let ((last= (lambda (str) (= ch (aref str (1- (length str))))))
 	(first= (lambda (str) (= ch (aref str 0)))))
     (reverse
-     (org-reduce (lambda (acc el)
+     (cl-reduce (lambda (acc el)
 		   (let ((head (car acc)))
 		     (if (and head (or (funcall last= head) (funcall first= el)))
 			 (cons (concat head el) (cdr acc))
@@ -1554,7 +1509,7 @@ shown below.
   (let (results)
     (mapc (lambda (pair)
 	    (if (eq (car pair) :var)
-		(mapcar (lambda (v) (push (cons :var (org-babel-trim v)) results))
+		(mapcar (lambda (v) (push (cons :var (org-trim v)) results))
 			(org-babel-join-splits-near-ch
 			 61 (org-babel-balanced-split (cdr pair) 32)))
 	      (push pair results)))
@@ -1564,40 +1519,44 @@ shown below.
 (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))
+				   (if (consp el)
+				       el
+				     (org-babel-ref-parse el)))
+				 (org-babel--get-vars params)))
+	 (vars-and-names (if (and (assq :colname-names params)
+				  (assq :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)))))
+			    (cdr (assq :hlines params))
+			    (cdr (assq :colnames params))
+			    (cdr (assq :rownames params)))))
+	 (raw-result (or (cdr (assq :results params)) ""))
+	 (result-params (delete-dups
+			 (append
+			  (split-string (if (stringp raw-result)
+					    raw-result
+					  (eval raw-result t)))
+			  (cdr (assq :result-params params))))))
     (append
      (mapcar (lambda (var) (cons :var var)) (car vars-and-names))
      (list
-      (cons :colname-names (or (cdr (assoc :colname-names params))
+      (cons :colname-names (or (cdr (assq :colname-names params))
 			       (cadr  vars-and-names)))
-      (cons :rowname-names (or (cdr (assoc :rowname-names params))
-			       (caddr vars-and-names)))
+      (cons :rowname-names (or (cdr (assq :rowname-names params))
+			       (cl-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))))
+     (cl-remove-if
+      (lambda (x) (memq (car x) '(:colname-names :rowname-names :result-params
+					    :result-type :var)))
+      params))))
 
 ;; row and column names
 (defun org-babel-del-hlines (table)
-  "Remove all 'hlines from TABLE."
+  "Remove all `hline's from TABLE."
   (remq 'hline table))
 
 (defun org-babel-get-colnames (table)
@@ -1605,7 +1564,7 @@ shown below.
 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))
+  (if (eq 'hline (nth 1 table))
       (cons (cddr table) (car table))
     (cons (cdr table) (car table))))
 
@@ -1618,7 +1577,7 @@ Note: this function removes any hlines in TABLE."
 	 (rownames (funcall (lambda ()
 			      (let ((tp table))
 				(mapcar
-				 (lambda (row)
+				 (lambda (_row)
 				   (prog1
 				       (pop (car tp))
 				     (setq tp (cdr tp))))
@@ -1663,7 +1622,7 @@ of the vars, cnames and rnames."
       (lambda (var)
         (when (listp (cdr var))
           (when (and (not (equal colnames "no"))
-                     (or colnames (and (equal (nth 1 (cdr var)) 'hline)
+                     (or colnames (and (eq (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))
@@ -1692,13 +1651,17 @@ to the table for reinsertion to org-mode."
             (org-babel-put-colnames table colnames) table))
     table))
 
-(defun org-babel-where-is-src-block-head ()
+(defun org-babel-where-is-src-block-head (&optional src-block)
   "Find where the current source block begins.
+
+If optional argument SRC-BLOCK is `src-block' type element, find
+its current beginning instead.
+
 Return the point at the beginning of the current source block.
 Specifically at the beginning of the #+BEGIN_SRC line.  Also set
 match-data relatively to `org-babel-src-block-regexp', which see.
 If the point is not on a source block then return nil."
-  (let ((element (org-element-at-point)))
+  (let ((element (or src-block (org-element-at-point))))
     (when (eq (org-element-type element) 'src-block)
       (let ((end (org-element-property :end element)))
 	(org-with-wide-buffer
@@ -1722,35 +1685,32 @@ If the point is not on a source block then return nil."
   (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))
-	     (""))))))
+	 (all-block-names (org-babel-src-block-names)))
+     (list (completing-read
+	    "source-block name: " all-block-names nil t
+	    (let* ((context (org-element-context))
+		   (type (org-element-type context))
+		   (noweb-ref
+		    (and (memq type '(inline-src-block src-block))
+			 (org-in-regexp (org-babel-noweb-wrap)))))
+	      (cond
+	       (noweb-ref
+		(buffer-substring
+		 (+ (car noweb-ref) (length org-babel-noweb-wrap-start))
+		 (- (cdr noweb-ref) (length org-babel-noweb-wrap-end))))
+	       ((memq type '(babel-call inline-babel-call)) ;#+CALL:
+		(org-element-property :call context))
+	       ((car (org-element-property :results context))) ;#+RESULTS:
+	       ((let ((symbol (thing-at-point 'symbol))) ;Symbol.
+		  (and symbol
+		       (member-ignore-case symbol all-block-names)
+		       symbol)))
+	       (t "")))))))
   (let ((point (org-babel-find-named-block name)))
     (if point
-        ;; taken from `org-open-at-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))))
+      (message "source-code block `%s' not found in this buffer" name))))
 
 (defun org-babel-find-named-block (name)
   "Find a named source-code block.
@@ -1770,7 +1730,7 @@ to `org-babel-named-src-block-regexp'."
     (let ((re (org-babel-named-src-block-regexp-for-name))
 	  names)
       (while (ignore-errors (org-next-block 1 nil re))
-	(push (org-match-string-no-properties 9) names))
+	(push (match-string-no-properties 9) names))
       names)))
 
 ;;;###autoload
@@ -1778,32 +1738,31 @@ to `org-babel-named-src-block-regexp'."
   "Go to a named result."
   (interactive
    (let ((completion-ignore-case t))
-     (list (org-icompleting-read "source-block name: "
-				 (org-babel-result-names) nil t))))
+     (list (completing-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))))
+      (message "result `%s' not found in this buffer" name))))
 
-(defun org-babel-find-named-result (name &optional point)
+(defun org-babel-find-named-result (name)
   "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))))))
+    (goto-char (point-min))
+    (let ((case-fold-search t)
+	  (re (format "^[ \t]*#\\+%s.*?:[ \t]*%s[ \t]*$"
+		      org-babel-results-keyword
+		      (regexp-quote name))))
+      (catch :found
+	(while (re-search-forward re nil t)
+	  (let ((element (org-element-at-point)))
+	    (when (or (eq (org-element-type element) 'keyword)
+		      (< (point)
+			 (org-element-property :post-affiliated element)))
+	      (throw :found (line-beginning-position)))))))))
 
 (defun org-babel-result-names (&optional file)
   "Returns the names of results in FILE or the current buffer."
@@ -1811,7 +1770,7 @@ buffer or nil if no such result exists."
     (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)))
+	(setq names (cons (match-string-no-properties 9) names)))
       names)))
 
 ;;;###autoload
@@ -1856,14 +1815,14 @@ region is not active then the point is demarcated."
 	 (stars (concat (make-string (or (org-current-level) 1) ?*) " "))
 	 (lower-case-p (and block
 			    (let (case-fold-search)
-			      (org-string-match-p "#\\+begin_src" block)))))
+			      (string-match-p "#\\+begin_src" block)))))
     (if info
         (mapc
          (lambda (place)
            (save-excursion
              (goto-char place)
              (let ((lang (nth 0 info))
-                   (indent (make-string (nth 5 info) ? )))
+                   (indent (make-string (org-get-indentation) ?\s)))
 	       (when (string-match "^[[:space:]]*$"
 				   (buffer-substring (point-at-bol)
 						     (point-at-eol)))
@@ -1882,7 +1841,7 @@ region is not active then the point is demarcated."
 	   (move-end-of-line 2))
          (sort (if (org-region-active-p) (list (mark) (point)) (list (point))) #'>))
       (let ((start (point))
-	    (lang (org-icompleting-read
+	    (lang (completing-read
 		   "Lang: "
 		   (mapcar #'symbol-name
 			   (delete-dups
@@ -1897,135 +1856,218 @@ region is not active then the point is demarcated."
 			lang "\n"
 			body
 			(if (or (= (length body) 0)
-				(string-match "[\r\n]$" body)) "" "\n")
+				(string-suffix-p "\r" body)
+				(string-suffix-p "\n" body)) "" "\n")
 			(funcall (if lower-case-p 'downcase 'upcase) "#+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)
+(defun org-babel--insert-results-keyword (name hash)
+  "Insert RESULTS keyword with NAME value at point.
+If NAME is nil, results are anonymous.  HASH is a string used as
+the results hash, or nil.  Leave point before the keyword."
+  (save-excursion (insert "\n"))	;open line to indent.
+  (org-indent-line)
+  (delete-char 1)
+  (insert (concat "#+" org-babel-results-keyword
+		  (cond ((not hash) nil)
+			(org-babel-hash-show-time
+			 (format "[%s %s]"
+				 (format-time-string "<%F %T>")
+				 hash))
+			(t (format "[%s]" hash)))
+		  ":"
+		  (when name (concat " " name))
+		  "\n"))
+  ;; Make sure results are going to be followed by at least one blank
+  ;; line so they do not get merged with the next element, e.g.,
+  ;;
+  ;;   #+results:
+  ;;   : 1
+  ;;
+  ;;   : fixed-width area, unrelated to the above.
+  (unless (looking-at "^[ \t]*$") (save-excursion (insert "\n")))
+  (beginning-of-line 0)
+  (when hash (org-babel-hide-hash)))
+
+(defun org-babel--clear-results-maybe (hash)
+  "Clear results when hash doesn't match HASH.
+
+When results hash does not match HASH, remove RESULTS keyword at
+point, along with related contents.  Do nothing if HASH is nil.
+
+Return a non-nil value if results were cleared.  In this case,
+leave point where new results should be inserted."
+  (when hash
+    (looking-at org-babel-result-regexp)
+    (unless (string= (match-string 1) hash)
+      (let* ((e (org-element-at-point))
+	     (post (copy-marker (org-element-property :post-affiliated e))))
+	;; Delete contents.
+	(delete-region post
+		       (save-excursion
+			 (goto-char (org-element-property :end e))
+			 (skip-chars-backward " \t\n")
+			 (line-beginning-position 2)))
+	;; Delete RESULT keyword.  However, if RESULTS keyword is
+	;; orphaned, ignore this part.  The deletion above already
+	;; took care of it.
+	(unless (= (point) post)
+	  (delete-region (line-beginning-position)
+			 (line-beginning-position 2)))
+	(goto-char post)
+	(set-marker post nil)
+	t))))
+
+(defun org-babel-where-is-src-block-result (&optional insert _info hash)
   "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))
+source block, specifically at the beginning of the results line.
+
+If no result exists for this block return nil, unless optional
+argument INSERT is non-nil.  In this case, create a results line
+following the source block and return the position at its
+beginning.  In the case of inline code, remove the results part
+instead.
+
+If optional argument HASH is a string, remove contents related to
+RESULTS keyword if its hash is different.  Then update the latter
+to HASH."
+  (let ((context (org-element-context)))
+    (catch :found
       (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))
-		 (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))
-			 ((and (looking-at "^[ \t]*#")
-			       (not (looking-at
-				     org-babel-lob-one-liner-regexp)))
-			  (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)))
-			  (progn
-			    (setq end (point-at-bol))
-			    (forward-line 1)
-			    (delete-region end (org-babel-result-end))
-			    (setq beg 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")))
-	(when (wholenump indent) (indent-to indent))
-	(insert (concat
-		 "#+" 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)
-	(when hash (org-babel-hide-hash))
-	(point)))))
-
-(defvar org-block-regexp)
+       (pcase (org-element-type context)
+	 ((or `inline-babel-call `inline-src-block)
+	  ;; Results for inline objects are located right after them.
+	  ;; There is no RESULTS line to insert either.
+	  (let ((limit (org-element-property
+			:contents-end (org-element-property :parent context))))
+	    (goto-char (org-element-property :end context))
+	    (skip-chars-forward " \t\n" limit)
+	    (throw :found
+		   (and
+		    (< (point) limit)
+		    (let ((result (org-element-context)))
+		      (and (eq (org-element-type result) 'macro)
+			   (string= (org-element-property :key result)
+				    "results")
+			   (if (not insert) (point)
+			     (delete-region
+			      (point)
+			      (progn
+				(goto-char (org-element-property :end result))
+				(skip-chars-backward " \t")
+				(point)))
+			     (point))))))))
+	 ((or `babel-call `src-block)
+	  (let* ((name (org-element-property :name context))
+		 (named-results (and name (org-babel-find-named-result name))))
+	    (goto-char (or named-results (org-element-property :end context)))
+	    (cond
+	     ;; Existing results named after the current source.
+	     (named-results
+	      (when (org-babel--clear-results-maybe hash)
+		(org-babel--insert-results-keyword name hash))
+	      (throw :found (point)))
+	     ;; Named results expect but none to be found.
+	     (name)
+	     ;; No possible anonymous results at the very end of
+	     ;; buffer or outside CONTEXT parent.
+	     ((eq (point)
+		  (or (org-element-property
+		       :contents-end (org-element-property :parent context))
+		      (point-max))))
+	     ;; Check if next element is an anonymous result below
+	     ;; the current block.
+	     ((let* ((next (org-element-at-point))
+		     (end (save-excursion
+			    (goto-char
+			     (org-element-property :post-affiliated next))
+			    (line-end-position)))
+		     (empty-result-re (concat org-babel-result-regexp "$"))
+		     (case-fold-search t))
+		(re-search-forward empty-result-re end t))
+	      (beginning-of-line)
+	      (when (org-babel--clear-results-maybe hash)
+		(org-babel--insert-results-keyword nil hash))
+	      (throw :found (point))))))
+	 ;; Ignore other elements.
+	 (_ (throw :found nil))))
+      ;; No result found.  Insert a RESULTS keyword below element, if
+      ;; appropriate.  In this case, ensure there is an empty line
+      ;; after the previous element.
+      (when insert
+	(save-excursion
+	  (goto-char (min (org-element-property :end context) (point-max)))
+	  (skip-chars-backward " \t\n")
+	  (forward-line)
+	  (unless (bolp) (insert "\n"))
+	  (insert "\n")
+	  (org-babel--insert-results-keyword
+	   (org-element-property :name context) hash)
+	  (point))))))
+
+(defun org-babel-read-element (element)
+  "Read ELEMENT into emacs-lisp.
+Return nil if ELEMENT cannot be read."
+  (org-with-wide-buffer
+   (goto-char (org-element-property :post-affiliated element))
+   (pcase (org-element-type element)
+     (`fixed-width
+      (let ((v (org-trim (org-element-property :value element))))
+	(or (org-babel--string-to-number v) v)))
+     (`table (org-babel-read-table))
+     (`plain-list (org-babel-read-list))
+     (`example-block
+      (let ((v (org-element-property :value element)))
+	(if (or org-src-preserve-indentation
+		(org-element-property :preserve-indent element))
+	    v
+	  (org-remove-indentation v))))
+     (`export-block
+      (org-remove-indentation (org-element-property :value element)))
+     (`paragraph
+      ;; Treat paragraphs containing a single link specially.
+      (skip-chars-forward " \t")
+      (if (and (looking-at org-bracket-link-regexp)
+	       (save-excursion
+		 (goto-char (match-end 0))
+		 (skip-chars-forward " \r\t\n")
+		 (<= (org-element-property :end element)
+		     (point))))
+	  (org-babel-read-link)
+	(buffer-substring-no-properties
+	 (org-element-property :contents-begin element)
+	 (org-element-property :contents-end element))))
+     ((or `center-block `quote-block `verse-block `special-block)
+      (org-remove-indentation
+       (buffer-substring-no-properties
+	(org-element-property :contents-begin element)
+	(org-element-property :contents-end element))))
+     (_ nil))))
+
 (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-remove-indentation (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))))))
+  "Read the result at point into emacs-lisp."
+  (and (not (save-excursion
+	      (beginning-of-line)
+	      (looking-at-p "[ \t]*$")))
+       (org-babel-read-element (org-element-at-point))))
 
 (defun org-babel-read-table ()
-  "Read the table at `point' into emacs-lisp."
+  "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."
+  "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)))))
+	  (cdr (org-list-to-lisp))))
 
 (defvar org-link-types-re)
 (defun org-babel-read-link ()
-  "Read the link at `point' into emacs-lisp.
+  "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)
@@ -2050,8 +2092,7 @@ If the path of the link is a file path it is expanded using
       ;; scalar result
       (funcall echo-res result))))
 
-(defun org-babel-insert-result
-    (result &optional result-params info hash indent lang)
+(defun org-babel-insert-result (result &optional result-params info hash lang)
   "Insert RESULT into the current buffer.
 
 By default RESULT is inserted after the end of the current source
@@ -2067,21 +2108,21 @@ replace - (default option) insert results after the source block
           or inline source block replacing any previously
           inserted results.
 
-silent -- no results are inserted into the Org-mode buffer but
+silent -- no results are inserted into the Org 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.
+          inserted into the buffer using the Org file syntax.
 
-list ---- the results are interpreted as an Org-mode list.
+list ---- the results are interpreted as an Org list.
 
-raw ----- results are added directly to the Org-mode file.  This
-          is a good option if you code block will output org-mode
+raw ----- results are added directly to the Org file.  This is
+          a good option if you code block will output Org
           formatted text.
 
-drawer -- results are added directly to the Org-mode file as with
+drawer -- results are added directly to the Org file as with
           \"raw\", but are wrapped in a RESULTS drawer or results
           macro, allowing them to later be replaced or removed
           automatically.
@@ -2092,15 +2133,16 @@ org ----- results are added inside of a \"src_org{}\" or \"#+BEGIN_SRC
           but Org syntax here will be discarded when exporting the
           file.
 
-html ---- results are added inside of a #+BEGIN_HTML block or
-          html export snippet depending on whether the current
+html ---- results are added inside of a #+BEGIN_EXPORT HTML block
+          or html export snippet depending on whether the current
           source block is inline or not.  This is a good option
           if your code block will output html formatted text.
 
-latex --- results are added inside of a #+BEGIN_LATEX block or
-          latex export snippet depending on whether the current
-          source block is inline or not.  This is a good option
-          if your code block will output latex formatted text.
+latex --- results are added inside of a #+BEGIN_EXPORT LATEX
+          block or latex export snippet depending on whether the
+          current source block is inline or not.  This is a good
+          option if your 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
@@ -2124,203 +2166,201 @@ INFO may provide the values of these header arguments (in the
 :wrap --- the effect is similar to `latex' in RESULT-PARAMS but
           using the argument supplied to specify the export block
           or snippet type."
-
-  (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))))
+  (cond ((stringp result)
+	 (setq result (org-no-properties result))
+	 (when (member "file" result-params)
+	   (setq result (org-babel-result-to-file
+			 result (when (assq :file-desc (nth 2 info))
+				  (or (cdr (assq :file-desc (nth 2 info)))
+				      result))))))
+	((listp result))
+	(t (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))
-		  (org-babel-remove-inline-result)
-		  (insert " ")
-		  (point))))
-	     (existing-result
-	      (unless inlinep
-		(org-babel-where-is-src-block-result t info hash indent)))
-	     (bad-inline-p
-	      (when inlinep
-		(or
-		 (and (member "table" result-params) "`:results table'")
-		 (and (listp result) "list result")
-		 (and (org-string-match-p "\n." result) "multiline result")
-		 (and (member "list" result-params) "`:results list'"))))
-	     (results-switches
-	      (cdr (assoc :results_switches (nth 2 info))))
-	     (visible-beg (point-min-marker))
-	     (visible-end (point-max-marker))
-	     ;; 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
+      (progn (message (replace-regexp-in-string "%" "%%" (format "%S" result)))
+	     result)
+    (let ((inline (let ((context (org-element-context)))
+		    (and (memq (org-element-type context)
+			       '(inline-babel-call inline-src-block))
+			 context))))
+      (when inline
+	(let ((warning
+	       (or (and (member "table" result-params) "`:results table'")
+		   (and (listp result) "list result")
+		   (and (string-match-p "\n." result) "multiline result")
+		   (and (member "list" result-params) "`:results list'"))))
+	  (when warning
+	    (user-error "Inline error: %s cannot be used" warning))))
+      (save-excursion
+	(let* ((visible-beg (point-min-marker))
+	       (visible-end (copy-marker (point-max) t))
+	       (inline (let ((context (org-element-context)))
+			 (and (memq (org-element-type context)
+				    '(inline-babel-call inline-src-block))
+			      context)))
+	       (existing-result (org-babel-where-is-src-block-result t nil hash))
+	       (results-switches (cdr (assq :results_switches (nth 2 info))))
+	       ;; When results exist outside of the current visible
+	       ;; region of the buffer, be sure to widen buffer to
+	       ;; update them.
+	       (outside-scope (and existing-result
+				   (buffer-narrowed-p)
 				   (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)
+	       beg end indent)
+	  ;; Ensure non-inline results end in a newline.
+	  (when (and (org-string-nw-p result)
+		     (not inline)
+		     (not (string-equal (substring result -1) "\n")))
+	    (setq result (concat result "\n")))
+	  (unwind-protect
+	      (progn
+		(when outside-scope (widen))
+		(if existing-result (goto-char existing-result)
+		  (goto-char (org-element-property :end inline))
+		  (skip-chars-backward " \t"))
+		(unless inline
+		  (setq indent (org-get-indentation))
+		  (forward-line 1))
 		(setq beg (point))
 		(cond
+		 (inline
+		   ;; Make sure new results are separated from the
+		   ;; source code by one space.
+		   (unless existing-result
+		     (insert " ")
+		     (setq beg (point))))
 		 ((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 no-newlines
-				    inline-start inline-finish)
-			    (when inlinep
-			      (setq start inline-start)
-			      (setq finish inline-finish)
-			      (setq no-newlines t))
-			    (goto-char end)
-			    (insert (concat finish (unless no-newlines "\n")))
-			    (goto-char beg)
-			    (insert (concat start (unless no-newlines "\n")))
-			    (unless no-escape
-			      (org-escape-code-in-region (min (point) end) end))
-			    (goto-char end)
-			    (unless no-newlines (goto-char (point-at-eol)))
-			    (setq end (point-marker))))
-		    (tabulablep
-		     (lambda (r)
-		       ;; Non-nil when result R can be turned into
-		       ;; a table.
-		       (and (listp r)
-			    (null (cdr (last r)))
-			    (org-every
-			     (lambda (e) (or (atom e) (null (cdr (last e)))))
-			     result)))))
-		;; insert results based on type
-		(cond
-		 ;; Do nothing for an empty result.
-		 ((null result))
-		 ;; Illegal inline result or params.
-		 (bad-inline-p
-		  (error "Inline error: %s cannot be used" bad-inline-p))
-		 ;; 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"))
-		 ;; Try hard to print RESULT as a table.  Give up if
-		 ;; it contains an improper list.
-		 ((funcall tabulablep result)
-		  (goto-char beg)
-		  (insert (concat (orgtbl-to-orgtbl
-				   (if (org-every
-					(lambda (e)
-					  (or (eq e 'hline) (listp e)))
-					result)
-				       result
-				     (list result))
-				   nil)
-				  "\n"))
-		  (goto-char beg)
-		  (when (org-at-table-p) (org-table-align))
-		  (goto-char (org-table-end)))
-		 ;; Print verbatim a list that cannot be turned into
-		 ;; a table.
-		 ((listp result) (insert (format "%s\n" result)))
-		 ((member "file" result-params)
-		  (when inlinep
-		    (goto-char inlinep)
-		    (setq result (org-macro-escape-arguments result)))
-		  (insert result))
-		 ((and inlinep
-		       (not (member "raw" result-params)))
-		  (goto-char inlinep)
-		  (insert (org-macro-escape-arguments
-			   (org-babel-chomp result "\n"))))
-		 (t (goto-char beg) (insert result)))
-		(setq end (point-marker))
-		;; possibly wrap result
-		(cond
-		 (bad-inline-p)		; Do nothing.
-		 ((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)))
-			     nil nil (concat "{{{results(@@" name ":") "@@)}}}")))
-		 ((member "html" result-params)
-		  (funcall wrap "#+BEGIN_HTML" "#+END_HTML" nil nil
-			   "{{{results(@@html:" "@@)}}}"))
-		 ((member "latex" result-params)
-		  (funcall wrap "#+BEGIN_LaTeX" "#+END_LaTeX" nil nil
-			   "{{{results(@@latex:" "@@)}}}"))
-		 ((member "org" result-params)
-		  (goto-char beg) (if (org-at-table-p) (org-cycle))
-		  (funcall wrap "#+BEGIN_SRC org" "#+END_SRC" nil nil
-			   "{{{results(src_org{" "})}}}"))
-		 ((member "code" result-params)
-		  (let ((lang (or lang "none")))
-		    (funcall wrap (format "#+BEGIN_SRC %s%s" lang results-switches)
-			     "#+END_SRC" nil nil
-			     (format "{{{results(src_%s[%s]{" lang results-switches)
-			     "})}}}")))
-		 ((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 nil
-			   "{{{results(" ")}}}"))
-		 ((and inlinep (member "file" result-params))
-		  (funcall wrap nil nil nil nil "{{{results(" ")}}}"))
-		 ((and (not (funcall tabulablep result))
-		       (not (member "file" result-params)))
-		  (let ((org-babel-inline-result-wrap
-			 ;; Hard code {{{results(...)}}} on top of customization.
-			 (format "{{{results(%s)}}}" org-babel-inline-result-wrap)))
-		    (org-babel-examplify-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))))))
+		 ((member "prepend" result-params))) ; already there
+		(setq results-switches
+		      (if results-switches (concat " " results-switches) ""))
+		(let ((wrap (lambda (start finish &optional no-escape no-newlines
+				      inline-start inline-finish)
+			      (when inline
+				(setq start inline-start)
+				(setq finish inline-finish)
+				(setq no-newlines t))
+			      (goto-char end)
+			      (insert (concat finish (unless no-newlines "\n")))
+			      (goto-char beg)
+			      (insert (concat start (unless no-newlines "\n")))
+			      (unless no-escape
+				(org-escape-code-in-region (min (point) end) end))
+			      (goto-char end)
+			      (unless no-newlines (goto-char (point-at-eol)))
+			      (setq end (point-marker))))
+		      (tabulablep
+		       (lambda (r)
+			 ;; Non-nil when result R can be turned into
+			 ;; a table.
+			 (and (listp r)
+			      (null (cdr (last r)))
+			      (cl-every
+			       (lambda (e) (or (atom e) (null (cdr (last e)))))
+			       result)))))
+		  ;; 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-trim
+		      (org-list-to-generic
+		       (cons 'unordered
+			     (mapcar
+			      (lambda (e)
+				(list (if (stringp e) e (format "%S" e))))
+			      (if (listp result) result
+				(split-string result "\n" t))))
+		       '(:splicep nil :istart "- " :iend "\n")))
+		     "\n"))
+		   ;; Try hard to print RESULT as a table.  Give up if
+		   ;; it contains an improper list.
+		   ((funcall tabulablep result)
+		    (goto-char beg)
+		    (insert (concat (orgtbl-to-orgtbl
+				     (if (cl-every
+					  (lambda (e)
+					    (or (eq e 'hline) (listp e)))
+					  result)
+					 result
+				       (list result))
+				     nil)
+				    "\n"))
+		    (goto-char beg)
+		    (when (org-at-table-p) (org-table-align))
+		    (goto-char (org-table-end)))
+		   ;; Print verbatim a list that cannot be turned into
+		   ;; a table.
+		   ((listp result) (insert (format "%s\n" result)))
+		   ((member "file" result-params)
+		    (when inline
+		      (setq result (org-macro-escape-arguments result)))
+		    (insert result))
+		   ((and inline (not (member "raw" result-params)))
+		    (insert (org-macro-escape-arguments
+			     (org-babel-chomp result "\n"))))
+		   (t (goto-char beg) (insert result)))
+		  (setq end (point-marker))
+		  ;; possibly wrap result
+		  (cond
+		   ((assq :wrap (nth 2 info))
+		    (let ((name (or (cdr (assq :wrap (nth 2 info))) "RESULTS")))
+		      (funcall wrap (concat "#+BEGIN_" name)
+			       (concat "#+END_" (car (org-split-string name)))
+			       nil nil (concat "{{{results(@@" name ":") "@@)}}}")))
+		   ((member "html" result-params)
+		    (funcall wrap "#+BEGIN_EXPORT html" "#+END_EXPORT" nil nil
+			     "{{{results(@@html:" "@@)}}}"))
+		   ((member "latex" result-params)
+		    (funcall wrap "#+BEGIN_EXPORT latex" "#+END_EXPORT" nil nil
+			     "{{{results(@@latex:" "@@)}}}"))
+		   ((member "org" result-params)
+		    (goto-char beg) (when (org-at-table-p) (org-cycle))
+		    (funcall wrap "#+BEGIN_SRC org" "#+END_SRC" nil nil
+			     "{{{results(src_org{" "})}}}"))
+		   ((member "code" result-params)
+		    (let ((lang (or lang "none")))
+		      (funcall wrap (format "#+BEGIN_SRC %s%s" lang results-switches)
+			       "#+END_SRC" nil nil
+			       (format "{{{results(src_%s[%s]{" lang results-switches)
+			       "})}}}")))
+		   ((member "raw" result-params)
+		    (goto-char beg) (when (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) (when (org-at-table-p) (org-cycle))
+		    (funcall wrap ":RESULTS:" ":END:" 'no-escape nil
+			     "{{{results(" ")}}}"))
+		   ((and inline (member "file" result-params))
+		    (funcall wrap nil nil nil nil "{{{results(" ")}}}"))
+		   ((and (not (funcall tabulablep result))
+			 (not (member "file" result-params)))
+		    (let ((org-babel-inline-result-wrap
+			   ;; Hard code {{{results(...)}}} on top of customization.
+			   (format "{{{results(%s)}}}"
+				   org-babel-inline-result-wrap)))
+		      (org-babel-examplify-region beg end results-switches inline)
+		      (setq end (point))))))
+		;; Possibly indent results in par with #+results line.
+		(when (and (not inline) (numberp 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 (narrow-to-region visible-beg visible-end))
+	    (set-marker visible-beg nil)
+	    (set-marker visible-end nil)))))))
 
 (defun org-babel-remove-result (&optional info keep-keyword)
   "Remove the result of the current source block."
@@ -2334,23 +2374,29 @@ INFO may provide the values of these header arguments (in the
 	   (if keep-keyword (1+ (match-end 0)) (1- (match-beginning 0)))
 	   (progn (forward-line 1) (org-babel-result-end))))))))
 
-(defun org-babel-remove-inline-result ()
+(defun org-babel-remove-inline-result (&optional datum)
   "Remove the result of the current inline-src-block or babel call.
 The result must be wrapped in a `results' macro to be removed.
-Leading whitespace is trimmed."
+Leading white space is trimmed."
   (interactive)
-  (let* ((el (org-element-context))
-	 (post-blank (org-element-property :post-blank el)))
+  (let* ((el (or datum (org-element-context))))
     (when (memq (org-element-type el) '(inline-src-block inline-babel-call))
       (org-with-wide-buffer
-        (goto-char (org-element-property :end el))
-        (let ((el (org-element-context)))
-	  (when (and (eq (org-element-type el) 'macro)
-		     (string= (org-element-property :key el) "results"))
-	    (delete-region ; And leading whitespace.
-	     (- (org-element-property :begin el) post-blank)
-	     (- (org-element-property :end el)
-		(org-element-property :post-blank el)))))))))
+       (goto-char (org-element-property :end el))
+       (skip-chars-backward " \t")
+       (let ((result (save-excursion
+		       (skip-chars-forward
+			" \t\n"
+			(org-element-property
+			 :contents-end (org-element-property :parent el)))
+		       (org-element-context))))
+	 (when (and (eq (org-element-type result) 'macro)
+		    (string= (org-element-property :key result) "results"))
+	   (delete-region		; And leading whitespace.
+	    (point)
+	    (progn (goto-char (org-element-property :end result))
+		   (skip-chars-backward " \t\n")
+		   (point)))))))))
 
 (defun org-babel-remove-result-one-or-many (x)
   "Remove the result of the current source block.
@@ -2397,38 +2443,23 @@ file's directory then expand relative links."
 	      result)
 	    (if description (concat "[" description "]") ""))))
 
-(defvar org-babel-capitalize-example-region-markers nil
-  "Make true to capitalize begin/end example markers inserted by code blocks.")
-
-(define-obsolete-function-alias
-  'org-babel-examplize-region
-  'org-babel-examplify-region "25.1")
-
-(defun org-babel-examplify-region (beg end &optional results-switches)
-  "Comment out region using the inline '==' or ': ' org example quote."
+(defun org-babel-examplify-region (beg end &optional results-switches inline)
+  "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-example-region-markers
-				(upcase str) str)))
-	(beg-bol (save-excursion (goto-char beg) (point-at-bol)))
-	(end-bol (save-excursion (goto-char end) (point-at-bol)))
-	(end-eol (save-excursion (goto-char end) (point-at-eol))))
-    (if (and (not (= end end-bol))
-	     (or (funcall chars-between beg-bol beg)
-		 (funcall chars-between end end-eol)))
+  (let ((maybe-cap
+	 (lambda (str)
+	   (if org-babel-uppercase-example-markers (upcase str) str))))
+    (if inline
 	(save-excursion
 	  (goto-char beg)
 	  (insert (format org-babel-inline-result-wrap
-			  (prog1 (buffer-substring beg end)
-			    (delete-region beg end)))))
+			  (delete-and-extract-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)
+		 (dotimes (_ size)
 		   (beginning-of-line 1) (insert ": ") (forward-line 1)))
 		(t
 		 (goto-char beg)
@@ -2437,17 +2468,37 @@ file's directory then expand relative links."
 				     (funcall maybe-cap "#+begin_example")
 				     results-switches)
 			   (funcall maybe-cap "#+begin_example\n")))
-		 (if (markerp end) (goto-char end) (forward-char (- end beg)))
+		 (let ((p (point)))
+		   (if (markerp end) (goto-char end) (forward-char (- end beg)))
+		   (org-escape-code-in-region p (point)))
 		 (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 (org-remove-indentation new-body))
-			     "\n") nil t nil 5))
-    (indent-rigidly (match-beginning 5) (match-end 5) 2)))
+  (let ((element (org-element-at-point)))
+    (unless (eq (org-element-type element) 'src-block)
+      (error "Not in a source block"))
+    (goto-char (org-babel-where-is-src-block-head element))
+    (let* ((ind (org-get-indentation))
+	   (body-start (line-beginning-position 2))
+	   (body (org-element-normalize-string
+		  (if (or org-src-preserve-indentation
+			  (org-element-property :preserve-indent element))
+		      new-body
+		    (with-temp-buffer
+		      (insert (org-remove-indentation new-body))
+		      (indent-rigidly
+		       (point-min)
+		       (point-max)
+		       (+ ind org-edit-src-content-indentation))
+		      (buffer-string))))))
+      (delete-region body-start
+		     (org-with-wide-buffer
+		      (goto-char (org-element-property :end element))
+		      (skip-chars-backward " \t\n")
+		      (line-beginning-position)))
+      (goto-char body-start)
+      (insert body))))
 
 (defun org-babel-merge-params (&rest plists)
   "Combine all parameter association lists in PLISTS.
@@ -2456,143 +2507,103 @@ 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))))
+		  (cdr (assq '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)))))
-	    (:file-ext
-	     (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))
+		  (cdr (assq 'exports org-babel-common-header-args-w-values))))
+	 (merge
+	  (lambda (exclusive-groups &rest result-params)
+	    ;; Maintain exclusivity of mutually exclusive parameters,
+	    ;; as defined in EXCLUSIVE-GROUPS while merging lists in
+	    ;; RESULT-PARAMS.
+	    (let (output)
+	      (dolist (new-params result-params (delete-dups output))
+		(dolist (new-param new-params)
+		  (dolist (exclusive-group exclusive-groups)
+		    (when (member new-param exclusive-group)
+		      (setq output (cl-remove-if
+				    (lambda (o) (member o exclusive-group))
+				    output))))
+		  (push new-param output))))))
+	 (variable-index 0)		;Handle positional arguments.
+	 clearnames
+	 params				;Final parameters list.
+	 ;; Some keywords accept multiple values.  We need to treat
+	 ;; them specially.
+	 vars results exports)
+    (dolist (plist plists)
+      (dolist (pair plist)
+	(pcase pair
+	  (`(:var . ,value)
+	   (let ((name (cond
+			((listp value) (car value))
+			((string-match "^\\([^= \f\t\n\r\v]+\\)[ \t]*=" value)
+			 (intern (match-string 1 value)))
+			(t nil))))
+	     (cond
+	      (name
+	       (setq vars
+		     (append (if (not (assoc name vars)) vars
+			       (push name clearnames)
+			       (cl-remove-if (lambda (p) (equal name (car p)))
+					     vars))
+			     (list (cons name pair)))))
+	      ((and vars (nth variable-index vars))
+	       ;; If no name is given and we already have named
+	       ;; variables then assign to named variables in order.
+	       (let ((name (car (nth variable-index vars))))
+		 ;; Clear out colnames and rownames for replace vars.
+		 (push name clearnames)
+		 (setf (cddr (nth variable-index vars))
+		       (concat (symbol-name name) "=" value))
+		 (cl-incf variable-index)))
+	      (t (error "Variable \"%s\" must be assigned a default value"
+			(cdr pair))))))
+	  (`(:results . ,value)
+	   (setq results (funcall merge
+				  results-exclusive-groups
+				  results
+				  (split-string
+				   (if (stringp value) value (eval value t))))))
+	  (`(,(or :file :file-ext) . ,value)
+	   ;; `:file' and `:file-ext' are regular keywords but they
+	   ;; imply a "file" `:results' and a "results" `:exports'.
+	   (when value
+	     (setq results
+		   (funcall merge results-exclusive-groups results '("file")))
+	     (unless (or (member "both" exports)
+			 (member "none" exports)
+			 (member "code" exports))
+	       (setq exports
+		     (funcall merge
+			      exports-exclusive-groups exports '("results"))))
+	     (push pair params)))
+	  (`(:exports . ,value)
+	   (setq exports (funcall merge
+				  exports-exclusive-groups
+				  exports
+				  (split-string (or value "")))))
+	  ;; Regular keywords: any value overwrites the previous one.
+	  (_ (setq params (cons pair (assq-delete-all (car pair) params)))))))
+    ;; Handle `:var' and clear out colnames and rownames for replaced
+    ;; variables.
+    (setq params (nconc (mapcar (lambda (v) (cons :var (cddr v))) vars)
+			params))
+    (dolist (name clearnames)
+      (dolist (param '(:colname-names :rowname-names))
+	(when (assq param params)
+	  (setf (cdr (assq param params))
+		(cl-remove-if (lambda (pair) (equal name (car pair)))
+			      (cdr (assq param params))))
+	  (setq params
+		(cl-remove-if (lambda (pair) (and (equal (car pair) param)
+					     (null (cdr pair))))
+			      params)))))
+    ;; Handle other special keywords, which accept multiple values.
+    (setq params (nconc (list (cons :results (mapconcat #'identity results " "))
+			      (cons :exports (mapconcat #'identity exports " ")))
+			params))
+    ;; Return merged params.
     params))
 
 (defvar org-babel-use-quick-and-dirty-noweb-expansion nil
@@ -2604,23 +2615,18 @@ 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)) "")))))
+  (let ((allowed-values (cl-case context
+			  (:tangle '("yes" "tangle" "no-export" "strip-export"))
+			  (:eval   '("yes" "no-export" "strip-export" "eval"))
+			  (:export '("yes")))))
+    (cl-some (lambda (v) (member v allowed-values))
+	     (split-string (or (cdr (assq :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'.
+body of the source-code block named `example-block'.
 
 <>
 
@@ -2633,7 +2639,7 @@ 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'.
+results of evaluating the source-code block named `example-block'.
 
 <>
 
@@ -2652,7 +2658,7 @@ block but are passed literally to the \"example-block\"."
          (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)))))
+	 (comment (string= "noweb" (cdr (assq :comments (nth 2 info)))))
 	 (rx-prefix (concat "\\(" org-babel-src-name-regexp "\\|"
 			    ":noweb-ref[ \t]+" "\\)"))
          (new-body "")
@@ -2661,16 +2667,16 @@ block but are passed literally to the \"example-block\"."
 		   (with-temp-buffer
 		     (funcall (intern (concat lang "-mode")))
 		     (comment-region (point) (progn (insert text) (point)))
-		     (org-babel-trim (buffer-string)))))
+		     (org-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)
+      (setq-local org-babel-noweb-wrap-start ob-nww-start)
+      (setq-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 evaluate (string-match "(.*)" source-name)))
 	(save-match-data
 	  (setq prefix
 		(buffer-substring (match-beginning 0)
@@ -2709,7 +2715,7 @@ block but are passed literally to the \"example-block\"."
                           (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)))
+                                   (sep (or (cdr (assq :noweb-sep (nth 2 i)))
                                             "\n"))
                                    (full (if comment
                                              (let ((cs (org-babel-tangle-comment-links i)))
@@ -2720,11 +2726,11 @@ block but are passed literally to the \"example-block\"."
                               (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)))
+                            (when (equal (or (cdr (assq :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)))
+                                     (sep (or (cdr (assq :noweb-sep (nth 2 i)))
                                               "\n"))
                                      (full (if comment
                                                (let ((cs (org-babel-tangle-comment-links i)))
@@ -2781,7 +2787,7 @@ block but are passed literally to the \"example-block\"."
 	       ;; the character was (because one layer of quoting will
 	       ;; be stripped by `org-babel-read').
 	       (t (append (list ch ?\\ ?\\) out))))
-	  (case ch
+	  (cl-case ch
 	    (?\[ (if (or in-double in-single)
 		     (cons ?\[ out)
 		   (cons ?\( out)))
@@ -2844,29 +2850,28 @@ block but are passed literally to the \"example-block\"."
 (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 and evaluate it as
+\"(\", \"\\='\", \"\\=`\" or a \"[\") then read and evaluate it as
 lisp, otherwise return it unmodified as a string.  Optional
 argument INHIBIT-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)
+      (or (org-babel--string-to-number cell)
           (if (and (not inhibit-lisp-eval)
 		   (or (member (substring cell 0 1) '("(" "'" "`" "["))
 		       (string= cell "*this*")))
-              (eval (read cell))
+              (eval (read cell) t)
             (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--string-to-number (string)
+  "If STRING represents a number return its value.
+
+Otherwise return nil."
+  (when (string-match "\\`-?[0-9]*\\.?[0-9]*\\'" string)
+    (string-to-number string)))
+(define-obsolete-function-alias 'org-babel-number-p 'org-babel--string-to-number "Org 9.0")
 
 (defun org-babel-import-elisp-from-file (file-name &optional separator)
   "Read the results located at FILE-NAME into an elisp table.
@@ -2907,37 +2912,6 @@ can be specified as the REGEXP argument."
       (setq string (substring string 0 -1)))
     string))
 
-(defun org-babel-trim (string &optional regexp)
-  "Strip a leading and trailing space or carriage return from STRING.
-Like `org-babel-chomp', but run on both the first and last
-character 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."
-  (or (file-remote-p file '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
@@ -3083,15 +3057,42 @@ plus the parameter value."
 	(setq params (cons (cons :file fname) params))))
     params))
 
-;;; Used by backends: R, Maxima, Octave.
 (defun org-babel-graphical-output-file (params)
-  "File where a babel block should send graphical output, per PARAMS."
-  (unless (assq :file params)
-    (if (assq :file-ext params)
-	(user-error ":file-ext given but no :file generated; did you forget to give a block a #+NAME?")
-      (user-error "No :file header argument given; cannot create graphical result.")))
-  (and (member "graphics" (cdr (assq :result-params params)))
-       (cdr (assq :file params))))
+  "File where a babel block should send graphical output, per PARAMS.
+Return nil if no graphical output is expected.  Raise an error if
+the output file is ill-defined."
+  (let ((file (cdr (assq :file params))))
+    (cond (file (and (member "graphics" (cdr (assq :result-params params)))
+		     file))
+	  ((assq :file-ext params)
+	   (user-error ":file-ext given but no :file generated; did you forget \
+to name a block?"))
+	  (t (user-error "No :file header argument given; cannot create \
+graphical result")))))
+
+(defun org-babel-make-language-alias (new old)
+  "Make source blocks of type NEW aliases for those of type OLD.
+
+NEW and OLD should be strings.  This function should be called
+after the babel API for OLD-type source blocks is fully defined.
+
+Callers of this function will probably want to add an entry to
+`org-src-lang-modes' as well."
+  (dolist (fn '("execute" "expand-body" "prep-session"
+		"variable-assignments" "load-session"))
+    (let ((sym (intern-soft (concat "org-babel-" fn ":" old))))
+      (when (and sym (fboundp sym))
+	(defalias (intern (concat "org-babel-" fn ":" new)) sym))))
+  ;; Technically we don't need a `dolist' for just one variable, but
+  ;; we keep it for symmetry/ease of future expansion.
+  (dolist (var '("default-header-args"))
+    (let ((sym (intern-soft (concat "org-babel-" var ":" old))))
+      (when (and sym (boundp sym))
+	(defvaralias (intern (concat "org-babel-" var ":" new)) sym)))))
+
+(defun org-babel-strip-quotes (string)
+  "Strip \\\"s from around a string, if applicable."
+  (org-unbracket-string "\"" "\"" string))
 
 (provide 'ob-core)
 
diff --git a/elpa/org-plus-contrib-20170407/ob-csharp.el b/elpa/org-plus-contrib-20170407/ob-csharp.el
new file mode 100644
index 00000000..c4aa046e
--- /dev/null
+++ b/elpa/org-plus-contrib-20170407/ob-csharp.el
@@ -0,0 +1,83 @@
+;;; ob-csharp.el --- org-babel functions for csharp evaluation
+
+;; Copyright (C) 2011-2017 Free Software Foundation, Inc.
+
+;; Author: thomas "at" friendlyvillagers.com based on ob-java.el by Eric Schulte
+;; Keywords: literate programming, reproducible research
+;; Homepage: http://orgmode.org
+
+;; This file is not 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 .
+
+;;; Commentary:
+
+;; Currently this only supports the external compilation and execution
+;; of csharp code blocks (i.e., no session support).
+
+;;; Code:
+(require 'ob)
+
+(defvar org-babel-tangle-lang-exts)
+(add-to-list 'org-babel-tangle-lang-exts '("csharp" . "cs"))
+
+(defcustom org-babel-csharp-command "mono"
+  "Name of the csharp command.
+May be either a command in the path, like mono
+or an absolute path name, like /usr/local/bin/mono
+parameters may be used, like mono -verbose"
+  :group 'org-babel
+  :version "24.3"
+  :type 'string)
+
+(defcustom org-babel-csharp-compiler "mcs"
+  "Name of the csharp compiler.
+May be either a command in the path, like mcs
+or an absolute path name, like /usr/local/bin/mcs
+parameters may be used, like mcs -warnaserror+"
+  :group 'org-babel
+  :version "24.3"
+  :type 'string)
+
+(defun org-babel-execute:csharp (body params)
+  (let* ((full-body (org-babel-expand-body:generic body params))
+	 (cmpflag (or (cdr (assq :cmpflag params)) ""))
+	 (cmdline (or (cdr (assq :cmdline params)) ""))
+	 (src-file (org-babel-temp-file "csharp-src-" ".cs"))
+	 (exe-file (concat (file-name-sans-extension src-file)  ".exe"))
+	 (compile
+	  (progn (with-temp-file  src-file (insert full-body))
+		 (org-babel-eval
+		  (concat org-babel-csharp-compiler " " cmpflag " "  src-file) ""))))
+    (let ((results (org-babel-eval (concat org-babel-csharp-command " " cmdline " " exe-file) "")))
+      (org-babel-reassemble-table
+       (org-babel-result-cond (cdr (assq :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 (assq :colname-names params)) (cdr (assq :colnames params)))
+       (org-babel-pick-name
+        (cdr (assq :rowname-names params)) (cdr (assq :rownames params)))))))
+
+(defun org-babel-prep-session:csharp (session params)
+  "Return an error because csharp does not support sessions."
+  (error "Sessions are not supported for CSharp"))
+
+(provide 'ob-csharp)
+
+
+
+;;; ob-csharp.el ends here
diff --git a/elpa/org-plus-contrib-20150831/ob-css.el b/elpa/org-plus-contrib-20170407/ob-css.el
similarity index 82%
rename from elpa/org-plus-contrib-20150831/ob-css.el
rename to elpa/org-plus-contrib-20170407/ob-css.el
index a0f0ad13..4203b125 100644
--- a/elpa/org-plus-contrib-20150831/ob-css.el
+++ b/elpa/org-plus-contrib-20170407/ob-css.el
@@ -1,6 +1,6 @@
-;;; ob-css.el --- org-babel functions for css evaluation
+;;; ob-css.el --- Babel Functions for CSS            -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2009-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2017 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
@@ -24,19 +24,19 @@
 ;;; Commentary:
 
 ;; Since CSS can't be executed, this file exists solely for tangling
-;; CSS from org-mode files.
+;; CSS from Org files.
 
 ;;; Code:
 (require 'ob)
 
 (defvar org-babel-default-header-args:css '())
 
-(defun org-babel-execute:css (body params)
+(defun org-babel-execute:css (body _params)
   "Execute a block of CSS code.
 This function is called by `org-babel-execute-src-block'."
   body)
 
-(defun org-babel-prep-session:css (session params)
+(defun org-babel-prep-session:css (_session _params)
   "Return an error if the :session header argument is set.
 CSS does not support sessions."
   (error "CSS sessions are nonsensical"))
diff --git a/elpa/org-plus-contrib-20150831/ob-ditaa.el b/elpa/org-plus-contrib-20170407/ob-ditaa.el
similarity index 86%
rename from elpa/org-plus-contrib-20150831/ob-ditaa.el
rename to elpa/org-plus-contrib-20170407/ob-ditaa.el
index 081cddf4..89b5d246 100644
--- a/elpa/org-plus-contrib-20150831/ob-ditaa.el
+++ b/elpa/org-plus-contrib-20170407/ob-ditaa.el
@@ -1,6 +1,6 @@
-;;; ob-ditaa.el --- org-babel functions for ditaa evaluation
+;;; ob-ditaa.el --- Babel Functions for ditaa        -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2009-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2017 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
@@ -81,19 +81,17 @@ Do not leave leading or trailing spaces in this string."
 (defun org-babel-execute:ditaa (body params)
   "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 (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)))
+  (let* ((out-file (or (cdr (assq :file params))
+		       (error
+			"ditaa code block requires :file header argument")))
+	 (cmdline (cdr (assq :cmdline params)))
+	 (java (cdr (assq :java params)))
 	 (in-file (org-babel-temp-file "ditaa-"))
-	 (eps (cdr (assoc :eps params)))
+	 (eps (cdr (assq :eps params)))
 	 (eps-file (when eps
 		     (org-babel-process-file-name (concat in-file ".eps"))))
 	 (pdf-cmd (when (and (or (string= (file-name-extension out-file) "pdf")
-				 (cdr (assoc :pdf params))))
+				 (cdr (assq :pdf params))))
 		    (concat
 		     "epstopdf"
 		     " " eps-file
@@ -115,7 +113,7 @@ This function is called by `org-babel-execute-src-block'."
     (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)
+(defun org-babel-prep-session:ditaa (_session _params)
   "Return an error because ditaa does not support sessions."
   (error "Ditaa does not support sessions"))
 
diff --git a/elpa/org-plus-contrib-20150831/ob-dot.el b/elpa/org-plus-contrib-20170407/ob-dot.el
similarity index 84%
rename from elpa/org-plus-contrib-20150831/ob-dot.el
rename to elpa/org-plus-contrib-20170407/ob-dot.el
index 2f562087..81442bfc 100644
--- a/elpa/org-plus-contrib-20150831/ob-dot.el
+++ b/elpa/org-plus-contrib-20170407/ob-dot.el
@@ -1,6 +1,6 @@
-;;; ob-dot.el --- org-babel functions for dot evaluation
+;;; ob-dot.el --- Babel Functions for dot            -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2009-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2017 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
@@ -46,14 +46,14 @@
 
 (defun org-babel-expand-body:dot (body params)
   "Expand BODY according to PARAMS, return the expanded body."
-  (let ((vars (mapcar #'cdr (org-babel-get-header params :var))))
+  (let ((vars (org-babel--get-vars params)))
     (mapc
      (lambda (pair)
        (let ((name (symbol-name (car pair)))
 	     (value (cdr pair)))
 	 (setq body
 	       (replace-regexp-in-string
-		(concat "\$" (regexp-quote name))
+		(concat "$" (regexp-quote name))
 		(if (stringp value) value (format "%S" value))
 		body
 		t
@@ -64,12 +64,11 @@
 (defun org-babel-execute:dot (body params)
   "Execute a block of Dot code with org-babel.
 This function is called by `org-babel-execute-src-block'."
-  (let* ((result-params (cdr (assoc :result-params params)))
-	 (out-file (cdr (or (assoc :file params)
+  (let* ((out-file (cdr (or (assq :file params)
 			    (error "You need to specify a :file parameter"))))
-	 (cmdline (or (cdr (assoc :cmdline params))
+	 (cmdline (or (cdr (assq :cmdline params))
 		      (format "-T%s" (file-name-extension out-file))))
-	 (cmd (or (cdr (assoc :cmd params)) "dot"))
+	 (cmd (or (cdr (assq :cmd params)) "dot"))
 	 (in-file (org-babel-temp-file "dot-")))
     (with-temp-file in-file
       (insert (org-babel-expand-body:dot body params)))
@@ -80,7 +79,7 @@ This function is called by `org-babel-execute-src-block'."
 	     " -o " (org-babel-process-file-name out-file)) "")
     nil)) ;; signal that output has already been written to file
 
-(defun org-babel-prep-session:dot (session params)
+(defun org-babel-prep-session:dot (_session _params)
   "Return an error because Dot does not support sessions."
   (error "Dot does not support sessions"))
 
diff --git a/elpa/org-plus-contrib-20150831/ob-ebnf.el b/elpa/org-plus-contrib-20170407/ob-ebnf.el
similarity index 90%
rename from elpa/org-plus-contrib-20150831/ob-ebnf.el
rename to elpa/org-plus-contrib-20170407/ob-ebnf.el
index 8c98d305..410570bc 100644
--- a/elpa/org-plus-contrib-20150831/ob-ebnf.el
+++ b/elpa/org-plus-contrib-20170407/ob-ebnf.el
@@ -1,6 +1,6 @@
-;;; ob-ebnf.el --- org-babel functions for ebnf evaluation
+;;; ob-ebnf.el --- Babel Functions for EBNF          -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2013 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2017 Free Software Foundation, Inc.
 
 ;; Author: Michael Gauland
 ;; Keywords: literate programming, reproducible research
@@ -54,13 +54,11 @@
   "Execute a block of Ebnf code with org-babel.  This function is
 called by `org-babel-execute-src-block'"
   (save-excursion
-    (let* ((dest-file (cdr (assoc :file params)))
+    (let* ((dest-file (cdr (assq :file params)))
 	   (dest-dir (file-name-directory dest-file))
 	   (dest-root (file-name-sans-extension
 		       (file-name-nondirectory dest-file)))
-           (dest-ext  (file-name-extension dest-file))
-	   (style (cdr (assoc :style params)))
-	   (current-dir default-directory)
+	   (style (cdr (assq :style params)))
 	   (result nil))
       (with-temp-buffer
 	(when style (ebnf-push-style style))
diff --git a/elpa/org-plus-contrib-20150831/ob-emacs-lisp.el b/elpa/org-plus-contrib-20170407/ob-emacs-lisp.el
similarity index 52%
rename from elpa/org-plus-contrib-20150831/ob-emacs-lisp.el
rename to elpa/org-plus-contrib-20170407/ob-emacs-lisp.el
index 5eb70038..c0bd12a8 100644
--- a/elpa/org-plus-contrib-20150831/ob-emacs-lisp.el
+++ b/elpa/org-plus-contrib-20170407/ob-emacs-lisp.el
@@ -1,6 +1,6 @@
-;;; ob-emacs-lisp.el --- org-babel functions for emacs-lisp code evaluation
+;;; ob-emacs-lisp.el --- Babel Functions for Emacs-lisp Code -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2009-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2017 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
@@ -28,13 +28,21 @@
 ;;; Code:
 (require 'ob)
 
-(defvar org-babel-default-header-args:emacs-lisp nil
-  "Default arguments for evaluating an emacs-lisp source block.")
+(defconst org-babel-header-args:emacs-lisp '((lexical . :any))
+  "Emacs-lisp specific header arguments.")
+
+(defvar org-babel-default-header-args:emacs-lisp '((:lexical . "no"))
+  "Default arguments for evaluating an emacs-lisp source block.
+
+A value of \"yes\" or t causes src blocks to be eval'd using
+lexical scoping.  It can also be an alist mapping symbols to
+their value.  It is used as the optional LEXICAL argument to
+`eval', which see.")
 
 (defun org-babel-expand-body:emacs-lisp (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)))
+  (let* ((vars (org-babel--get-vars params))
+         (result-params (cdr (assq :result-params params)))
          (print-level nil) (print-length nil)
          (body (if (> (length vars) 0)
 		   (concat "(let ("
@@ -51,26 +59,33 @@
 (defun org-babel-execute:emacs-lisp (body params)
   "Execute a block of emacs-lisp code with Babel."
   (save-window-excursion
-    (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* ((lexical (cdr (assq :lexical params)))
+	   (result
+	    (eval (read (format (if (member "output"
+					    (cdr (assq :result-params params)))
+				    "(with-output-to-string %s)"
+				  "(progn %s)")
+				(org-babel-expand-body:emacs-lisp
+				 body params)))
+
+		  (if (listp lexical)
+		      lexical
+		    (member lexical '("yes" "t"))))))
+      (org-babel-result-cond (cdr (assq :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))))
+          (if (or (member "scalar" (cdr (assq :result-params params)))
+                  (member "verbatim" (cdr (assq :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))))))))
+         (org-babel-pick-name (cdr (assq :colname-names params))
+                              (cdr (assq :colnames params)))
+         (org-babel-pick-name (cdr (assq :rowname-names params))
+                              (cdr (assq :rownames params))))))))
+
+(org-babel-make-language-alias "elisp" "emacs-lisp")
 
 (provide 'ob-emacs-lisp)
 
diff --git a/elpa/org-plus-contrib-20150831/ob-eukleides.el b/elpa/org-plus-contrib-20170407/ob-eukleides.el
similarity index 92%
rename from elpa/org-plus-contrib-20150831/ob-eukleides.el
rename to elpa/org-plus-contrib-20170407/ob-eukleides.el
index cb5bb840..d3ad993e 100644
--- a/elpa/org-plus-contrib-20150831/ob-eukleides.el
+++ b/elpa/org-plus-contrib-20170407/ob-eukleides.el
@@ -1,6 +1,6 @@
 ;;; ob-eukleides.el --- Org-babel functions for eukleides evaluation
 
-;; Copyright (C) 2010-2014  Free Software Foundation, Inc.
+;; Copyright (C) 2010-2017  Free Software Foundation, Inc.
 
 ;; Author: Luis Anaya
 ;; Keywords: literate programming, reproducible research
@@ -58,12 +58,12 @@
 (defun org-babel-execute:eukleides (body params)
   "Execute a block of eukleides 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 (or (cdr (assoc :file params))
+  (let* ((result-params (split-string (or (cdr (assq :results params)) "")))
+	 (out-file (or (cdr (assq :file params))
 		       (error "Eukleides requires a \":file\" header argument")))
-	 (cmdline (cdr (assoc :cmdline params)))
+	 (cmdline (cdr (assq :cmdline params)))
 	 (in-file (org-babel-temp-file "eukleides-"))
-	 (java (or (cdr (assoc :java params)) ""))
+	 (java (or (cdr (assq :java params)) ""))
 	 (cmd (if (not org-eukleides-path)
 		  (error "`org-eukleides-path' is not set")
 		(concat (expand-file-name org-eukleides-path)
diff --git a/elpa/org-plus-contrib-20150831/ob-eval.el b/elpa/org-plus-contrib-20170407/ob-eval.el
similarity index 87%
rename from elpa/org-plus-contrib-20150831/ob-eval.el
rename to elpa/org-plus-contrib-20170407/ob-eval.el
index d94b6953..324cf5fb 100644
--- a/elpa/org-plus-contrib-20150831/ob-eval.el
+++ b/elpa/org-plus-contrib-20170407/ob-eval.el
@@ -1,6 +1,6 @@
-;;; ob-eval.el --- org-babel functions for external code evaluation
+;;; ob-eval.el --- Babel Functions for External Code Evaluation -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2009-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2017 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research, comint
@@ -28,7 +28,6 @@
 
 ;;; Code:
 (require 'org-macs)
-(eval-when-compile (require 'cl))
 
 (defvar org-babel-error-buffer-name "*Org-Babel Error Output*")
 (declare-function org-babel-temp-file "ob-core" (prefix &optional suffix))
@@ -121,18 +120,18 @@ function in various versions of Emacs.
       (delete-file input-file))
 
     (when (and error-file (file-exists-p error-file))
-      (if (< 0 (nth 7 (file-attributes error-file)))
-	  (with-current-buffer (get-buffer-create error-buffer)
-	    (let ((pos-from-end (- (point-max) (point))))
-	      (or (bobp)
-		  (insert "\f\n"))
-	      ;; Do no formatting while reading error file,
-	      ;; because that can run a shell command, and we
-	      ;; don't want that to cause an infinite recursion.
-	      (format-insert-file error-file nil)
-	      ;; Put point after the inserted errors.
-	      (goto-char (- (point-max) pos-from-end)))
-	    (current-buffer)))
+      (when (< 0 (nth 7 (file-attributes error-file)))
+	(with-current-buffer (get-buffer-create error-buffer)
+	  (let ((pos-from-end (- (point-max) (point))))
+	    (or (bobp)
+		(insert "\f\n"))
+	    ;; Do no formatting while reading error file,
+	    ;; because that can run a shell command, and we
+	    ;; don't want that to cause an infinite recursion.
+	    (format-insert-file error-file nil)
+	    ;; Put point after the inserted errors.
+	    (goto-char (- (point-max) pos-from-end)))
+	  (current-buffer)))
       (delete-file error-file))
     exit-status))
 
diff --git a/elpa/org-plus-contrib-20170407/ob-exp.el b/elpa/org-plus-contrib-20170407/ob-exp.el
new file mode 100644
index 00000000..d966cd91
--- /dev/null
+++ b/elpa/org-plus-contrib-20170407/ob-exp.el
@@ -0,0 +1,413 @@
+;;; ob-exp.el --- Exportation of Babel Source Blocks -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2009-2017 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 .
+
+;;; Code:
+(require 'ob-core)
+
+(declare-function org-babel-lob-get-info "ob-lob" (&optional datum))
+(declare-function org-element-at-point "org-element" ())
+(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-escape-code-in-string "org-src" (s))
+(declare-function org-export-copy-buffer "ox" ())
+(declare-function org-fill-template "org" (template alist))
+(declare-function org-get-indentation "org" (&optional line))
+(declare-function org-in-commented-heading-p "org" (&optional no-inheritance))
+
+(defvar org-src-preserve-indentation)
+
+(defcustom org-export-use-babel t
+  "Switch controlling code evaluation and header processing during export.
+When set to nil no code will be evaluated as part of the export
+process and no header arguments will be obeyed.  When set to
+`inline-only', only inline code blocks will be executed.  Users
+who wish to avoid evaluating code on export should use the header
+argument `:eval never-export'."
+  :group 'org-babel
+  :version "24.1"
+  :type '(choice (const :tag "Never" nil)
+		 (const :tag "Only inline code" inline-only)
+		 (const :tag "Always" t))
+  :safe #'null)
+
+
+(defmacro org-babel-exp--at-source (&rest body)
+  "Evaluate BODY at the source of the Babel block at point.
+Source is located in `org-babel-exp-reference-buffer'.  The value
+returned is the value of the last form in BODY.  Assume that
+point is at the beginning of the Babel block."
+  (declare (indent 1) (debug body))
+  `(let ((source (get-text-property (point) 'org-reference)))
+     (with-current-buffer org-babel-exp-reference-buffer
+       (org-with-wide-buffer
+	(goto-char source)
+	,@body))))
+
+(defun org-babel-exp-src-block ()
+  "Process source block for export.
+Depending on the \":export\" header argument, replace the source
+code block like this:
+
+both ---- display the code and the results
+
+code ---- the default, display the code inside the block but do
+          not process
+
+results - just like none only the block is run on export ensuring
+          that its results are present in the Org mode buffer
+
+none ---- do not display either code or results upon export
+
+Assume point is at block opening line."
+  (interactive)
+  (save-excursion
+    (let* ((info (org-babel-get-src-block-info 'light))
+	   (lang (nth 0 info))
+	   (raw-params (nth 2 info))
+	   hash)
+      ;; bail if we couldn't get any info from the block
+      (unless noninteractive
+	(message "org-babel-exp process %s at position %d..."
+		 lang
+		 (line-beginning-position)))
+      (when info
+	;; if we're actually going to need the parameters
+	(when (member (cdr (assq :exports (nth 2 info))) '("both" "results"))
+	  (let ((lang-headers (intern (concat "org-babel-default-header-args:"
+					      lang))))
+	    (org-babel-exp--at-source
+		(setf (nth 2 info)
+		      (org-babel-process-params
+		       (apply #'org-babel-merge-params
+			      org-babel-default-header-args
+			      (and (boundp lang-headers)
+				   (symbol-value lang-headers))
+			      (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)))))
+
+(defcustom org-babel-exp-call-line-template
+  ""
+  "Template used to export call lines.
+This template may be customized to include the call line name
+with any export markup.  The template is filled out using
+`org-fill-template', and the following %keys may be used.
+
+ line --- call line
+
+An example value would be \"\\n: call: %line\" to export the call line
+wrapped in a verbatim environment.
+
+Note: the results are inserted separately after the contents of
+this template."
+  :group 'org-babel
+  :type 'string)
+
+(defun org-babel-exp-process-buffer ()
+  "Execute all Babel blocks in current buffer."
+  (interactive)
+  (when org-export-use-babel
+    (save-window-excursion
+      (let ((case-fold-search t)
+	    (regexp (if (eq org-export-use-babel 'inline-only)
+			"\\(call\\|src\\)_"
+		      "\\(call\\|src\\)_\\|^[ \t]*#\\+\\(BEGIN_SRC\\|CALL:\\)"))
+	    ;; Get a pristine copy of current buffer so Babel
+	    ;; references are properly resolved and source block
+	    ;; context is preserved.
+	    (org-babel-exp-reference-buffer (org-export-copy-buffer)))
+	(unwind-protect
+	    (save-excursion
+	      ;; First attach to every source block their original
+	      ;; position, so that they can be retrieved within
+	      ;; `org-babel-exp-reference-buffer', even after heavy
+	      ;; modifications on current buffer.
+	      ;;
+	      ;; False positives are harmless, so we don't check if
+	      ;; we're really at some Babel object.  Moreover,
+	      ;; `line-end-position' ensures that we propertize
+	      ;; a noticeable part of the object, without affecting
+	      ;; multiple objects on the same line.
+	      (goto-char (point-min))
+	      (while (re-search-forward regexp nil t)
+		(let ((s (match-beginning 0)))
+		  (put-text-property s (line-end-position) 'org-reference s)))
+	      ;; Evaluate from top to bottom every Babel block
+	      ;; encountered.
+	      (goto-char (point-min))
+	      (while (re-search-forward regexp nil t)
+		(unless (save-match-data (org-in-commented-heading-p))
+		  (let* ((object? (match-end 1))
+			 (element (save-match-data
+				    (if object? (org-element-context)
+				      ;; No deep inspection if we're
+				      ;; just looking for an element.
+				      (org-element-at-point))))
+			 (type
+			  (pcase (org-element-type element)
+			    ;; Discard block elements if we're looking
+			    ;; for inline objects.  False results
+			    ;; happen when, e.g., "call_" syntax is
+			    ;; located within affiliated keywords:
+			    ;;
+			    ;; #+name: call_src
+			    ;; #+begin_src ...
+			    ((and (or `babel-call `src-block) (guard object?))
+			     nil)
+			    (type type)))
+			 (begin
+			  (copy-marker (org-element-property :begin element)))
+			 (end
+			  (copy-marker
+			   (save-excursion
+			     (goto-char (org-element-property :end element))
+			     (skip-chars-backward " \r\t\n")
+			     (point)))))
+		    (pcase type
+		      (`inline-src-block
+		       (let* ((info
+			       (org-babel-get-src-block-info nil element))
+			      (params (nth 2 info)))
+			 (setf (nth 1 info)
+			       (if (and (cdr (assq :noweb params))
+					(string= "yes"
+						 (cdr (assq :noweb params))))
+				   (org-babel-expand-noweb-references
+				    info org-babel-exp-reference-buffer)
+				 (nth 1 info)))
+			 (goto-char begin)
+			 (let ((replacement
+				(org-babel-exp-do-export info 'inline)))
+			   (if (equal replacement "")
+			       ;; Replacement code is empty: remove
+			       ;; inline source block, including extra
+			       ;; white space that might have been
+			       ;; created when inserting results.
+			       (delete-region begin
+					      (progn (goto-char end)
+						     (skip-chars-forward " \t")
+						     (point)))
+			     ;; Otherwise: remove inline src block but
+			     ;; preserve following white spaces.  Then
+			     ;; insert value.
+			     (delete-region begin end)
+			     (insert replacement)))))
+		      ((or `babel-call `inline-babel-call)
+		       (org-babel-exp-do-export (org-babel-lob-get-info element)
+						'lob)
+		       (let ((rep
+			      (org-fill-template
+			       org-babel-exp-call-line-template
+			       `(("line"  .
+				  ,(org-element-property :value element))))))
+			 ;; 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
+			      begin
+			      (progn (goto-char end)
+				     (if (not (eq type 'babel-call))
+					 (progn (skip-chars-forward " \t")
+						(point))
+				       (skip-chars-forward " \r\t\n")
+				       (line-beginning-position))))
+			   ;; Otherwise, preserve trailing
+			   ;; spaces/newlines and then, insert
+			   ;; replacement string.
+			   (goto-char begin)
+			   (delete-region begin end)
+			   (insert rep))))
+		      (`src-block
+		       (let ((match-start (copy-marker (match-beginning 0)))
+			     (ind (org-get-indentation)))
+			 ;; Take care of matched block: compute
+			 ;; replacement string.  In particular, a nil
+			 ;; REPLACEMENT means the block is left as-is
+			 ;; while an empty string removes the block.
+			 (let ((replacement
+				(progn (goto-char match-start)
+				       (org-babel-exp-src-block))))
+			   (cond ((not replacement) (goto-char end))
+				 ((equal replacement "")
+				  (goto-char end)
+				  (skip-chars-forward " \r\t\n")
+				  (beginning-of-line)
+				  (delete-region begin (point)))
+				 (t
+				  (goto-char match-start)
+				  (delete-region (point)
+						 (save-excursion
+						   (goto-char end)
+						   (line-end-position)))
+				  (insert replacement)
+				  (if (or org-src-preserve-indentation
+					  (org-element-property
+					   :preserve-indent element))
+				      ;; Indent only 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)))))
+			 (set-marker match-start nil))))
+		    (set-marker begin nil)
+		    (set-marker end nil)))))
+	  (kill-buffer org-babel-exp-reference-buffer)
+	  (remove-text-properties (point-min) (point-max) '(org-reference)))))))
+
+(defun org-babel-exp-do-export (info type &optional hash)
+  "Return a string with the exported content of a code block.
+The function respects the value of the :exports header argument."
+  (let ((silently (lambda () (let ((session (cdr (assq :session (nth 2 info)))))
+			  (unless (equal "none" session)
+			    (org-babel-exp-results info type 'silent)))))
+	(clean (lambda () (if (eq type 'inline)
+			 (org-babel-remove-inline-result)
+		       (org-babel-remove-result info)))))
+    (pcase (or (cdr (assq :exports (nth 2 info))) "code")
+      ("none" (funcall silently) (funcall clean) "")
+      ("code" (funcall silently) (funcall clean) (org-babel-exp-code info type))
+      ("results" (org-babel-exp-results info type nil hash) "")
+      ("both"
+       (org-babel-exp-results info type nil hash)
+       (org-babel-exp-code info type)))))
+
+(defcustom org-babel-exp-code-template
+  "#+BEGIN_SRC %lang%switches%flags\n%body\n#+END_SRC"
+  "Template used to export the body of code blocks.
+This template may be customized to include additional information
+such as the code block name, or the values of particular header
+arguments.  The template is filled out using `org-fill-template',
+and the following %keys may be used.
+
+ lang ------ the language of the code block
+ name ------ the name of the code block
+ body ------ the body of the code block
+ switches -- the switches associated to the code block
+ flags ----- the flags passed to the code block
+
+In addition to the keys mentioned above, every header argument
+defined for the code block may be used as a key and will be
+replaced with its value."
+  :group 'org-babel
+  :type 'string)
+
+(defcustom org-babel-exp-inline-code-template
+  "src_%lang[%switches%flags]{%body}"
+  "Template used to export the body of inline code blocks.
+This template may be customized to include additional information
+such as the code block name, or the values of particular header
+arguments.  The template is filled out using `org-fill-template',
+and the following %keys may be used.
+
+ lang ------ the language of the code block
+ name ------ the name of the code block
+ body ------ the body of the code block
+ switches -- the switches associated to the code block
+ flags ----- the flags passed to the code block
+
+In addition to the keys mentioned above, every header argument
+defined for the code block may be used as a key and will be
+replaced with its value."
+  :group 'org-babel
+  :type 'string
+  :version "26.1"
+  :package-version '(Org . "8.3"))
+
+(defun org-babel-exp-code (info type)
+  "Return the original code block formatted for export."
+  (setf (nth 1 info)
+	(if (string= "strip-export" (cdr (assq :noweb (nth 2 info))))
+	    (replace-regexp-in-string
+	     (org-babel-noweb-wrap) "" (nth 1 info))
+	  (if (org-babel-noweb-p (nth 2 info) :export)
+	      (org-babel-expand-noweb-references
+	       info org-babel-exp-reference-buffer)
+	    (nth 1 info))))
+  (org-fill-template
+   (if (eq type 'inline)
+       org-babel-exp-inline-code-template
+       org-babel-exp-code-template)
+   `(("lang"  . ,(nth 0 info))
+     ("body"  . ,(org-escape-code-in-string (nth 1 info)))
+     ("switches" . ,(let ((f (nth 3 info)))
+		      (and (org-string-nw-p f) (concat " " f))))
+     ("flags" . ,(let ((f (assq :flags (nth 2 info))))
+		   (and f (concat " " (cdr f)))))
+     ,@(mapcar (lambda (pair)
+		 (cons (substring (symbol-name (car pair)) 1)
+		       (format "%S" (cdr pair))))
+	       (nth 2 info))
+     ("name"  . ,(or (nth 4 info) "")))))
+
+(defun org-babel-exp-results (info type &optional silent hash)
+  "Evaluate and return the results of the current code block for export.
+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."
+  (unless (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-reference-buffer)
+		  (nth 1 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)
+	(setf (nth 1 info) body)
+	(setf (nth 2 info)
+	      (org-babel-exp--at-source
+		(org-babel-process-params
+		 (org-babel-merge-params
+		  (nth 2 info)
+		  `((:results . ,(if silent "silent" "replace")))))))
+	(pcase type
+	  (`block (org-babel-execute-src-block nil info))
+	  (`inline
+	    ;; Position the point on the inline source block
+	    ;; allowing `org-babel-insert-result' to check that the
+	    ;; block is inline.
+	    (goto-char (nth 5 info))
+	    (org-babel-execute-src-block nil info))
+	  (`lob
+	   (save-excursion
+	     (goto-char (nth 5 info))
+	     (let (org-confirm-babel-evaluate)
+	       (org-babel-execute-src-block nil info)))))))))
+
+
+(provide 'ob-exp)
+
+;;; ob-exp.el ends here
diff --git a/elpa/org-plus-contrib-20150831/ob-fomus.el b/elpa/org-plus-contrib-20170407/ob-fomus.el
similarity index 91%
rename from elpa/org-plus-contrib-20150831/ob-fomus.el
rename to elpa/org-plus-contrib-20170407/ob-fomus.el
index 1db32e47..30f292f3 100644
--- a/elpa/org-plus-contrib-20150831/ob-fomus.el
+++ b/elpa/org-plus-contrib-20170407/ob-fomus.el
@@ -48,7 +48,7 @@
 
 (defun org-babel-expand-body:fomus (body params)
   "Expand BODY according to PARAMS, return the expanded body."
-  (let ((vars (mapcar #'cdr (org-babel-get-header params :var))))
+  (let ((vars (org-babel--get-vars params)))
     (mapc
      (lambda (pair)
        (let ((name (symbol-name (car pair)))
@@ -64,10 +64,10 @@
 (defun org-babel-execute:fomus (body params)
   "Execute a block of Fomus code with org-babel.
 This function is called by `org-babel-execute-src-block'."
-  (let* ((result-params (cdr (assoc :result-params params)))
-	 (out-file (cdr (assoc :file params)))
-	 (cmdline (cdr (assoc :cmdline params)))
-	 (cmd (or (cdr (assoc :cmd params)) "fomus"))
+  (let* ((result-params (cdr (assq :result-params params)))
+	 (out-file (cdr (assq :file params)))
+	 (cmdline (cdr (assq :cmdline params)))
+	 (cmd (or (cdr (assq :cmd params)) "fomus"))
 	 (in-file (org-babel-temp-file "fomus-" ".fms")))
     (with-temp-file in-file
       (insert (org-babel-expand-body:fomus body params)))
diff --git a/elpa/org-plus-contrib-20150831/ob-forth.el b/elpa/org-plus-contrib-20170407/ob-forth.el
similarity index 85%
rename from elpa/org-plus-contrib-20150831/ob-forth.el
rename to elpa/org-plus-contrib-20170407/ob-forth.el
index cc2795a4..152cf727 100644
--- a/elpa/org-plus-contrib-20150831/ob-forth.el
+++ b/elpa/org-plus-contrib-20170407/ob-forth.el
@@ -1,6 +1,6 @@
-;;; ob-forth.el --- org-babel functions for Forth
+;;; ob-forth.el --- Babel Functions for Forth        -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2014 Free Software Foundation, Inc.
+;; Copyright (C) 2014-2017 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research, forth
@@ -35,6 +35,7 @@
 (require 'ob)
 
 (declare-function forth-proc "ext:gforth" ())
+(declare-function org-trim "org" (s &optional keep-lead))
 
 (defvar org-babel-default-header-args:forth '((:session . "yes"))
   "Default header arguments for forth code blocks.")
@@ -42,10 +43,10 @@
 (defun org-babel-execute:forth (body params)
   "Execute a block of Forth code with org-babel.
 This function is called by `org-babel-execute-src-block'"
-  (if (string= "none" (cdr (assoc :session params)))
+  (if (string= "none" (cdr (assq :session params)))
       (error "Non-session evaluation not supported for Forth code blocks")
     (let ((all-results (org-babel-forth-session-execute body params)))
-      (if (member "output" (cdr (assoc :result-params params)))
+      (if (member "output" (cdr (assq :result-params params)))
 	  (mapconcat #'identity all-results "\n")
 	(car (last all-results))))))
 
@@ -76,10 +77,10 @@ This function is called by `org-babel-execute-src-block'"
 		    (org-babel-eval-error-notify 1
 		     (buffer-substring
 		      (+ (match-beginning 0) 1) (point-max))) nil))))
-	      (split-string (org-babel-trim
-			     (org-babel-expand-body:generic
-			      body params))
-			    "\n" 'omit-nulls)))))
+	      (split-string (org-trim
+			     (org-babel-expand-body:generic body params))
+			    "\n"
+			    'omit-nulls)))))
 
 (provide 'ob-forth)
 
diff --git a/elpa/org-plus-contrib-20150831/ob-fortran.el b/elpa/org-plus-contrib-20170407/ob-fortran.el
similarity index 78%
rename from elpa/org-plus-contrib-20150831/ob-fortran.el
rename to elpa/org-plus-contrib-20170407/ob-fortran.el
index d32092a9..d059245b 100644
--- a/elpa/org-plus-contrib-20150831/ob-fortran.el
+++ b/elpa/org-plus-contrib-20170407/ob-fortran.el
@@ -1,6 +1,6 @@
-;;; ob-fortran.el --- org-babel functions for fortran
+;;; ob-fortran.el --- Babel Functions for Fortran    -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2011-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2017 Free Software Foundation, Inc.
 
 ;; Authors: Sergey Litvinov
 ;;       Eric Schulte
@@ -29,11 +29,12 @@
 ;;; Code:
 (require 'ob)
 (require 'cc-mode)
+(require 'cl-lib)
 
 (declare-function org-entry-get "org"
 		  (pom property &optional inherit literal-nil))
-(declare-function org-every "org" (pred seq))
 (declare-function org-remove-indentation "org" (code &optional n))
+(declare-function org-trim "org" (s &optional keep-lead))
 
 (defvar org-babel-tangle-lang-exts)
 (add-to-list 'org-babel-tangle-lang-exts '("fortran" . "F90"))
@@ -48,44 +49,42 @@
   "This function should only be called by `org-babel-execute:fortran'"
   (let* ((tmp-src-file (org-babel-temp-file "fortran-src-" ".F90"))
          (tmp-bin-file (org-babel-temp-file "fortran-bin-" org-babel-exeext))
-         (cmdline (cdr (assoc :cmdline params)))
-         (flags (cdr (assoc :flags params)))
-         (full-body (org-babel-expand-body:fortran body params))
-         (compile
-	  (progn
-	    (with-temp-file tmp-src-file (insert full-body))
-	    (org-babel-eval
-	     (format "%s -o %s %s %s"
-		     org-babel-fortran-compiler
-		     (org-babel-process-file-name tmp-bin-file)
-		     (mapconcat 'identity
-				(if (listp flags) flags (list flags)) " ")
-		     (org-babel-process-file-name tmp-src-file)) ""))))
+         (cmdline (cdr (assq :cmdline params)))
+         (flags (cdr (assq :flags params)))
+         (full-body (org-babel-expand-body:fortran body params)))
+    (with-temp-file tmp-src-file (insert full-body))
+    (org-babel-eval
+     (format "%s -o %s %s %s"
+	     org-babel-fortran-compiler
+	     (org-babel-process-file-name tmp-bin-file)
+	     (mapconcat 'identity
+			(if (listp flags) flags (list flags)) " ")
+	     (org-babel-process-file-name tmp-src-file)) "")
     (let ((results
-           (org-babel-trim
+           (org-trim
             (org-remove-indentation
 	     (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-result-cond (cdr (assq :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)))
+        (cdr (assq :colname-names params)) (cdr (assq :colnames params)))
        (org-babel-pick-name
-        (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params)))))))
+        (cdr (assq :rowname-names params)) (cdr (assq :rownames params)))))))
 
 (defun org-babel-expand-body:fortran (body params)
   "Expand a block of fortran or fortran code with org-babel according to
-it's header arguments."
-  (let ((vars (mapcar #'cdr (org-babel-get-header params :var)))
-        (main-p (not (string= (cdr (assoc :main params)) "no")))
-        (includes (or (cdr (assoc :includes params))
+its header arguments."
+  (let ((vars (org-babel--get-vars params))
+        (main-p (not (string= (cdr (assq :main params)) "no")))
+        (includes (or (cdr (assq :includes params))
                       (org-babel-read (org-entry-get nil "includes" t))))
         (defines (org-babel-read
-                  (or (cdr (assoc :defines params))
+                  (or (cdr (assq :defines params))
                       (org-babel-read (org-entry-get nil "defines" t))))))
     (mapconcat 'identity
 	       (list
@@ -109,17 +108,17 @@ it's header arguments."
 (defun org-babel-fortran-ensure-main-wrap (body params)
   "Wrap body in a \"program ... end program\" block if none exists."
   (if (string-match "^[ \t]*program[ \t]*.*" (capitalize body))
-      (let ((vars (mapcar #'cdr (org-babel-get-header params :var))))
-	(if vars (error "Cannot use :vars if 'program' statement is present"))
+      (let ((vars (org-babel--get-vars params)))
+	(if vars (error "Cannot use :vars if `program' statement is present"))
 	body)
     (format "program main\n%s\nend program main\n" body)))
 
-(defun org-babel-prep-session:fortran (session params)
+(defun org-babel-prep-session:fortran (_session _params)
   "This function does nothing as fortran is a compiled language with no
 support for sessions"
   (error "Fortran is a compiled languages -- no support for sessions"))
 
-(defun org-babel-load-session:fortran (session body params)
+(defun org-babel-load-session:fortran (_session _body _params)
   "This function does nothing as fortran is a compiled language with no
 support for sessions"
   (error "Fortran is a compiled languages -- no support for sessions"))
@@ -147,7 +146,7 @@ of the same value."
       (format "character(len=%d), parameter ::  %S = '%s'\n"
               (length val) var val))
      ;; val is a matrix
-     ((and (listp val) (org-every #'listp val))
+     ((and (listp val) (cl-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)
diff --git a/elpa/org-plus-contrib-20150831/ob-gnuplot.el b/elpa/org-plus-contrib-20170407/ob-gnuplot.el
similarity index 86%
rename from elpa/org-plus-contrib-20150831/ob-gnuplot.el
rename to elpa/org-plus-contrib-20170407/ob-gnuplot.el
index 8490b16d..a62303ff 100644
--- a/elpa/org-plus-contrib-20150831/ob-gnuplot.el
+++ b/elpa/org-plus-contrib-20170407/ob-gnuplot.el
@@ -1,6 +1,6 @@
-;;; ob-gnuplot.el --- org-babel functions for gnuplot evaluation
+;;; ob-gnuplot.el --- Babel Functions for Gnuplot    -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2009-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2017 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
@@ -39,9 +39,8 @@
 
 ;;; Code:
 (require 'ob)
-(eval-when-compile (require 'cl))
 
-(declare-function org-time-string-to-time "org" (s))
+(declare-function org-time-string-to-time "org" (s &optional buffer pos))
 (declare-function org-combine-plists "org" (&rest plists))
 (declare-function orgtbl-to-generic "org-table" (table params))
 (declare-function gnuplot-mode "ext:gnuplot-mode" ())
@@ -80,7 +79,7 @@
 Dumps all vectors into files and returns an association list
 of variable names and the related value to be used in the gnuplot
 code."
-  (let ((*org-babel-gnuplot-missing* (cdr (assoc :missing params))))
+  (let ((*org-babel-gnuplot-missing* (cdr (assq :missing params))))
     (mapcar
      (lambda (pair)
        (cons
@@ -94,32 +93,30 @@ code."
 		 (if tablep val (mapcar 'list val)))
 	       (org-babel-temp-file "gnuplot-") params)
 	  val))))
-     (mapcar #'cdr (org-babel-get-header params :var)))))
+     (org-babel--get-vars params))))
 
 (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)))
-	   (prologue (cdr (assoc :prologue params)))
-	   (epilogue (cdr (assoc :epilogue params)))
-	   (term (or (cdr (assoc :term params))
+           (out-file (cdr (assq :file params)))
+	   (prologue (cdr (assq :prologue params)))
+	   (epilogue (cdr (assq :epilogue params)))
+	   (term (or (cdr (assq :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 (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))
+           (title (cdr (assq :title params)))
+           (lines (cdr (assq :line params)))
+           (sets (cdr (assq :set params)))
+           (x-labels (cdr (assq :xlabels params)))
+           (y-labels (cdr (assq :ylabels params)))
+           (timefmt (cdr (assq :timefmt params)))
+           (time-ind (or (cdr (assq :timeind params))
                          (when timefmt 1)))
-	   (add-to-body (lambda (text) (setq body (concat text "\n" body))))
-           output)
+	   (add-to-body (lambda (text) (setq body (concat text "\n" body)))))
       ;; append header argument settings to body
       (when title (funcall add-to-body (format "set title '%s'" title)))
       (when lines (mapc (lambda (el) (funcall add-to-body el)) lines))
@@ -171,9 +168,8 @@ code."
   "Execute a block of Gnuplot code.
 This function is called by `org-babel-execute-src-block'."
   (require 'gnuplot)
-  (let ((session (cdr (assoc :session params)))
-        (result-type (cdr (assoc :results params)))
-        (out-file (cdr (assoc :file params)))
+  (let ((session (cdr (assq :session params)))
+        (result-type (cdr (assq :results params)))
         (body (org-babel-expand-body:gnuplot body params))
 	output)
     (save-window-excursion
@@ -206,10 +202,12 @@ This function is called by `org-babel-execute-src-block'."
          (var-lines (org-babel-variable-assignments:gnuplot params)))
     (message "%S" session)
     (org-babel-comint-in-buffer session
-      (mapc (lambda (var-line)
-              (insert var-line) (comint-send-input nil t)
-              (org-babel-comint-wait-for-output session)
-              (sit-for .1) (goto-char (point-max))) var-lines))
+      (dolist (var-line  var-lines)
+	(insert var-line)
+	(comint-send-input nil t)
+	(org-babel-comint-wait-for-output session)
+	(sit-for .1)
+	(goto-char (point-max))))
     session))
 
 (defun org-babel-load-session:gnuplot (session body params)
@@ -228,7 +226,7 @@ This function is called by `org-babel-execute-src-block'."
    (org-babel-gnuplot-process-vars params)))
 
 (defvar gnuplot-buffer)
-(defun org-babel-gnuplot-initiate-session (&optional session params)
+(defun org-babel-gnuplot-initiate-session (&optional session _params)
   "Initiate a gnuplot session.
 If there is not a current inferior-process-buffer in SESSION
 then create one.  Return the initialized session.  The current
diff --git a/elpa/org-plus-contrib-20150831/ob-groovy.el b/elpa/org-plus-contrib-20170407/ob-groovy.el
similarity index 82%
rename from elpa/org-plus-contrib-20150831/ob-groovy.el
rename to elpa/org-plus-contrib-20170407/ob-groovy.el
index 91100d2c..69993c0f 100644
--- a/elpa/org-plus-contrib-20150831/ob-groovy.el
+++ b/elpa/org-plus-contrib-20170407/ob-groovy.el
@@ -1,6 +1,6 @@
-;;; ob-groovy.el --- org-babel functions for Groovy evaluation
+;;; ob-groovy.el --- Babel Functions for Groovy      -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2013-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2017 Free Software Foundation, Inc.
 
 ;; Author: Miro Bezjak
 ;; Keywords: literate programming, reproducible research
@@ -31,7 +31,6 @@
 
 ;;; Code:
 (require 'ob)
-(eval-when-compile (require 'cl))
 
 (defvar org-babel-tangle-lang-exts) ;; Autoloaded
 (add-to-list 'org-babel-tangle-lang-exts '("groovy" . "groovy"))
@@ -51,9 +50,8 @@ called by `org-babel-execute-src-block'"
   (message "executing Groovy source code block")
   (let* ((processed-params (org-babel-process-params params))
          (session (org-babel-groovy-initiate-session (nth 0 processed-params)))
-         (vars (nth 1 processed-params))
          (result-params (nth 2 processed-params))
-         (result-type (cdr (assoc :result-type params)))
+         (result-type (cdr (assq :result-type params)))
          (full-body (org-babel-expand-body:generic
                      body params))
          (result (org-babel-groovy-evaluate
@@ -62,9 +60,9 @@ called by `org-babel-execute-src-block'"
     (org-babel-reassemble-table
      result
      (org-babel-pick-name
-      (cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
+      (cdr (assq :colname-names params)) (cdr (assq :colnames params)))
      (org-babel-pick-name
-      (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params))))))
+      (cdr (assq :rowname-names params)) (cdr (assq :rownames params))))))
 
 (defvar org-babel-groovy-wrapper-method
 
@@ -78,19 +76,19 @@ println(new Runner().run())
 
 
 (defun org-babel-groovy-evaluate
-  (session body &optional result-type result-params)
+    (session body &optional result-type result-params)
   "Evaluate BODY in external Groovy process.
-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
+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."
   (when session (error "Sessions are not (yet) supported for Groovy"))
-  (case result-type
-    (output
+  (pcase result-type
+    (`output
      (let ((src-file (org-babel-temp-file "groovy-")))
        (progn (with-temp-file src-file (insert body))
               (org-babel-eval
                (concat org-babel-groovy-command " " src-file) ""))))
-    (value
+    (`value
      (let* ((src-file (org-babel-temp-file "groovy-"))
             (wrapper (format org-babel-groovy-wrapper-method body)))
        (with-temp-file src-file (insert wrapper))
@@ -101,11 +99,11 @@ in BODY as elisp."
            (org-babel-script-escape raw)))))))
 
 
-(defun org-babel-prep-session:groovy (session params)
+(defun org-babel-prep-session:groovy (_session _params)
   "Prepare SESSION according to the header arguments specified in PARAMS."
   (error "Sessions are not (yet) supported for Groovy"))
 
-(defun org-babel-groovy-initiate-session (&optional session)
+(defun org-babel-groovy-initiate-session (&optional _session)
   "If there is not a current inferior-process-buffer in SESSION
 then create.  Return the initialized session.  Sessions are not
 supported in Groovy."
diff --git a/elpa/org-plus-contrib-20150831/ob-haskell.el b/elpa/org-plus-contrib-20170407/ob-haskell.el
similarity index 83%
rename from elpa/org-plus-contrib-20150831/ob-haskell.el
rename to elpa/org-plus-contrib-20170407/ob-haskell.el
index e7e9cb42..ecce6dcd 100644
--- a/elpa/org-plus-contrib-20150831/ob-haskell.el
+++ b/elpa/org-plus-contrib-20170407/ob-haskell.el
@@ -1,6 +1,6 @@
-;;; ob-haskell.el --- org-babel functions for haskell evaluation
+;;; ob-haskell.el --- Babel Functions for Haskell    -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2009-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2017 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
@@ -41,9 +41,9 @@
 ;;; Code:
 (require 'ob)
 (require 'comint)
-(eval-when-compile (require 'cl))
 
 (declare-function org-remove-indentation "org" (code &optional n))
+(declare-function org-trim "org" (s &optional keep-lead))
 (declare-function haskell-mode "ext:haskell-mode" ())
 (declare-function run-haskell "ext:inf-haskell" (&optional arg))
 (declare-function inferior-haskell-load-file
@@ -61,42 +61,35 @@
 
 (defun org-babel-execute:haskell (body params)
   "Execute a block of Haskell code."
-  (let* ((session (cdr (assoc :session params)))
-         (vars (mapcar #'cdr (org-babel-get-header params :var)))
-         (result-type (cdr (assoc :result-type params)))
+  (let* ((session (cdr (assq :session params)))
+         (result-type (cdr (assq :result-type params)))
          (full-body (org-babel-expand-body:generic
 		     body params
 		     (org-babel-variable-assignments:haskell params)))
          (session (org-babel-haskell-initiate-session session params))
          (raw (org-babel-comint-with-output
 		  (session org-babel-haskell-eoe t full-body)
-                (insert (org-babel-trim full-body))
+                (insert (org-trim full-body))
                 (comint-send-input nil t)
                 (insert org-babel-haskell-eoe)
                 (comint-send-input nil t)))
          (results (mapcar
-                   #'org-babel-haskell-read-string
+                   #'org-babel-strip-quotes
                    (cdr (member org-babel-haskell-eoe
-                                (reverse (mapcar #'org-babel-trim raw)))))))
+                                (reverse (mapcar #'org-trim raw)))))))
     (org-babel-reassemble-table
      (let ((result
-            (case result-type
-              (output (mapconcat #'identity (reverse (cdr results)) "\n"))
-              (value (car results)))))
-       (org-babel-result-cond (cdr (assoc :result-params params))
+            (pcase result-type
+              (`output (mapconcat #'identity (reverse (cdr results)) "\n"))
+              (`value (car results)))))
+       (org-babel-result-cond (cdr (assq :result-params params))
 	 result (org-babel-script-escape result)))
-     (org-babel-pick-name (cdr (assoc :colname-names params))
-			  (cdr (assoc :colname-names params)))
-     (org-babel-pick-name (cdr (assoc :rowname-names params))
-			  (cdr (assoc :rowname-names params))))))
-
-(defun org-babel-haskell-read-string (string)
-  "Strip \\\"s from around a haskell string."
-  (if (string-match "^\"\\([^\000]+\\)\"$" string)
-      (match-string 1 string)
-    string))
-
-(defun org-babel-haskell-initiate-session (&optional session params)
+     (org-babel-pick-name (cdr (assq :colname-names params))
+			  (cdr (assq :colname-names params)))
+     (org-babel-pick-name (cdr (assq :rowname-names params))
+			  (cdr (assq :rowname-names params))))))
+
+(defun org-babel-haskell-initiate-session (&optional _session _params)
   "Initiate a haskell session.
 If there is not a current inferior-process-buffer in SESSION
 then create one.  Return the initialized session."
@@ -131,7 +124,7 @@ then create one.  Return the initialized session."
 	    (format "let %s = %s"
 		    (car pair)
 		    (org-babel-haskell-var-to-haskell (cdr pair))))
-	  (mapcar #'cdr (org-babel-get-header params :var))))
+	  (org-babel--get-vars params)))
 
 (defun org-babel-haskell-var-to-haskell (var)
   "Convert an elisp value VAR into a haskell variable.
@@ -144,13 +137,14 @@ specifying a variable of the same value."
 (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))
+			   &optional async subtreep visible-only body-only
+			   ext-plist post-process))
 (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
 .lhs file will be exported to a .tex file.  This function will
 create two new files, base-name.lhs and base-name.tex where
-base-name is the name of the current org-mode file.
+base-name is the name of the current Org file.
 
 Note that all standard Babel literate programming
 constructs (header arguments, no-web syntax etc...) are ignored."
@@ -178,12 +172,12 @@ constructs (header arguments, no-web syntax etc...) are ignored."
         (save-match-data (setq indentation (length (match-string 1))))
         (replace-match (save-match-data
                          (concat
-                          "#+begin_latex\n\\begin{code}\n"
+                          "#+begin_export latex\n\\begin{code}\n"
                           (if (or preserve-indentp
                                   (string-match "-i" (match-string 2)))
                               (match-string 3)
                             (org-remove-indentation (match-string 3)))
-                          "\n\\end{code}\n#+end_latex\n"))
+                          "\n\\end{code}\n#+end_export\n"))
                        t t)
         (indent-code-rigidly (match-beginning 0) (match-end 0) indentation)))
     (save-excursion
diff --git a/elpa/org-plus-contrib-20170407/ob-hledger.el b/elpa/org-plus-contrib-20170407/ob-hledger.el
new file mode 100644
index 00000000..371b9c6b
--- /dev/null
+++ b/elpa/org-plus-contrib-20170407/ob-hledger.el
@@ -0,0 +1,70 @@
+;;  ob-ledger.el --- Babel Functions for hledger      -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2010-2017 Free Software Foundation, Inc.
+
+;; Author: Simon Michael
+;; Keywords: literate programming, reproducible research, plain text accounting
+;; 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 .
+
+;;; Commentary:
+
+;; Babel support for evaluating hledger entries.
+;;
+;; Based on ob-ledger.el.
+;; If the source block is empty, hledger will use a default journal file,
+;; probably ~/.hledger.journal (it may not notice your $LEDGER_FILE env var).
+;; So make ~/.hledger.journal a symbolic link to the real file if necessary.
+
+;;; Code:
+(require 'ob)
+
+(defvar org-babel-default-header-args:hledger
+  '((:results . "output") (:exports . "results") (:cmdline . "bal"))
+  "Default arguments to use when evaluating a hledger source block.")
+
+(defun org-babel-execute:hledger (body params)
+  "Execute a block of hledger entries with org-babel.
+This function is called by `org-babel-execute-src-block'."
+  (message "executing hledger source code block")
+  (letrec ( ;(result-params (split-string (or (cdr (assq :results params)) "")))
+	   (cmdline (cdr (assq :cmdline params)))
+	   (in-file (org-babel-temp-file "hledger-"))
+	   (out-file (org-babel-temp-file "hledger-output-"))
+	   (hledgercmd (concat "hledger"
+			       (if (> (length body) 0)
+				   (concat " -f " (org-babel-process-file-name in-file))
+				 "")
+			       " " cmdline)))
+    (with-temp-file in-file (insert body))
+;; TODO This is calling for some refactoring:
+;;  (concat "hledger" (if ...) " " cmdline)
+;; could be built only once and bound to a symbol.
+    (message "%s" hledgercmd)
+    (with-output-to-string
+      (shell-command (concat hledgercmd " > " (org-babel-process-file-name out-file))))
+    (with-temp-buffer (insert-file-contents out-file) (buffer-string))))
+
+(defun org-babel-prep-session:hledger (_session _params)
+  (error "hledger does not support sessions"))
+
+(provide 'ob-hledger)
+
+
+
+;;; ob-hledger.el ends here
+;; TODO Unit tests are more than welcome, too.
diff --git a/elpa/org-plus-contrib-20150831/ob-io.el b/elpa/org-plus-contrib-20170407/ob-io.el
similarity index 73%
rename from elpa/org-plus-contrib-20150831/ob-io.el
rename to elpa/org-plus-contrib-20170407/ob-io.el
index a5e5cdac..5dd61109 100644
--- a/elpa/org-plus-contrib-20150831/ob-io.el
+++ b/elpa/org-plus-contrib-20170407/ob-io.el
@@ -1,6 +1,6 @@
-;;; ob-io.el --- org-babel functions for Io evaluation
+;;; ob-io.el --- Babel Functions for Io              -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2012-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2012-2017 Free Software Foundation, Inc.
 
 ;; Author: Andrzej Lichnerowicz
 ;; Keywords: literate programming, reproducible research
@@ -33,7 +33,6 @@
 
 ;;; Code:
 (require 'ob)
-(eval-when-compile (require 'cl))
 
 (defvar org-babel-tangle-lang-exts) ;; Autoloaded
 (add-to-list 'org-babel-tangle-lang-exts '("io" . "io"))
@@ -47,9 +46,8 @@ called by `org-babel-execute-src-block'"
   (message "executing Io source code block")
   (let* ((processed-params (org-babel-process-params params))
          (session (org-babel-io-initiate-session (nth 0 processed-params)))
-         (vars (nth 1 processed-params))
          (result-params (nth 2 processed-params))
-         (result-type (cdr (assoc :result-type params)))
+         (result-type (cdr (assq :result-type params)))
          (full-body (org-babel-expand-body:generic
                      body params))
          (result (org-babel-io-evaluate
@@ -58,9 +56,9 @@ called by `org-babel-execute-src-block'"
     (org-babel-reassemble-table
      result
      (org-babel-pick-name
-      (cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
+      (cdr (assq :colname-names params)) (cdr (assq :colnames params)))
      (org-babel-pick-name
-      (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params))))))
+      (cdr (assq :rowname-names params)) (cdr (assq :rownames params))))))
 
 (defvar org-babel-io-wrapper-method
   "(
@@ -71,33 +69,33 @@ called by `org-babel-execute-src-block'"
 
 (defun org-babel-io-evaluate (session body &optional result-type result-params)
   "Evaluate BODY in external Io process.
-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
+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."
   (when session (error "Sessions are not (yet) supported for Io"))
-  (case result-type
-    (output
+  (pcase result-type
+    (`output
      (if (member "repl" result-params)
          (org-babel-eval org-babel-io-command body)
        (let ((src-file (org-babel-temp-file "io-")))
          (progn (with-temp-file src-file (insert body))
                 (org-babel-eval
                  (concat org-babel-io-command " " src-file) "")))))
-    (value (let* ((src-file (org-babel-temp-file "io-"))
-                  (wrapper (format org-babel-io-wrapper-method body)))
-             (with-temp-file src-file (insert wrapper))
-             (let ((raw (org-babel-eval
-                         (concat org-babel-io-command " " src-file) "")))
-               (org-babel-result-cond result-params
-		 raw
-                 (org-babel-script-escape raw)))))))
+    (`value (let* ((src-file (org-babel-temp-file "io-"))
+		   (wrapper (format org-babel-io-wrapper-method body)))
+	      (with-temp-file src-file (insert wrapper))
+	      (let ((raw (org-babel-eval
+			  (concat org-babel-io-command " " src-file) "")))
+		(org-babel-result-cond result-params
+		  raw
+		  (org-babel-script-escape raw)))))))
 
 
-(defun org-babel-prep-session:io (session params)
+(defun org-babel-prep-session:io (_session _params)
   "Prepare SESSION according to the header arguments specified in PARAMS."
   (error "Sessions are not (yet) supported for Io"))
 
-(defun org-babel-io-initiate-session (&optional session)
+(defun org-babel-io-initiate-session (&optional _session)
   "If there is not a current inferior-process-buffer in SESSION
 then create.  Return the initialized session.  Sessions are not
 supported in Io."
diff --git a/elpa/org-plus-contrib-20150831/ob-java.el b/elpa/org-plus-contrib-20170407/ob-java.el
similarity index 77%
rename from elpa/org-plus-contrib-20150831/ob-java.el
rename to elpa/org-plus-contrib-20170407/ob-java.el
index f8089117..7e720231 100644
--- a/elpa/org-plus-contrib-20150831/ob-java.el
+++ b/elpa/org-plus-contrib-20170407/ob-java.el
@@ -1,6 +1,6 @@
-;;; ob-java.el --- org-babel functions for java evaluation
+;;; ob-java.el --- Babel Functions for Java          -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2011-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2017 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
@@ -51,34 +51,32 @@ parameters may be used, like javac -verbose"
   :type 'string)
 
 (defun org-babel-execute:java (body params)
-  (let* ((classname (or (cdr (assoc :classname params))
+  (let* ((classname (or (cdr (assq :classname params))
 			(error
 			 "Can't compile a java block without a classname")))
 	 (packagename (file-name-directory classname))
 	 (src-file (concat classname ".java"))
-	 (cmpflag (or (cdr (assoc :cmpflag params)) ""))
-	 (cmdline (or (cdr (assoc :cmdline params)) ""))
-	 (full-body (org-babel-expand-body:generic body params))
-	 (compile
-	  (progn (with-temp-file src-file (insert full-body))
-		 (org-babel-eval
-		  (concat org-babel-java-compiler
-			  " " cmpflag " " src-file) ""))))
+	 (cmpflag (or (cdr (assq :cmpflag params)) ""))
+	 (cmdline (or (cdr (assq :cmdline params)) ""))
+	 (full-body (org-babel-expand-body:generic body params)))
+    (with-temp-file src-file (insert full-body))
+    (org-babel-eval
+     (concat org-babel-java-compiler " " cmpflag " " src-file) "")
     ;; created package-name directories if missing
     (unless (or (not packagename) (file-exists-p packagename))
       (make-directory packagename 'parents))
     (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-result-cond (cdr (assq :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)))
+        (cdr (assq :colname-names params)) (cdr (assq :colnames params)))
        (org-babel-pick-name
-        (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params)))))))
+        (cdr (assq :rowname-names params)) (cdr (assq :rownames params)))))))
 
 (provide 'ob-java)
 
diff --git a/elpa/org-plus-contrib-20150831/ob-js.el b/elpa/org-plus-contrib-20170407/ob-js.el
similarity index 89%
rename from elpa/org-plus-contrib-20150831/ob-js.el
rename to elpa/org-plus-contrib-20170407/ob-js.el
index f8ce3004..91be6b07 100644
--- a/elpa/org-plus-contrib-20150831/ob-js.el
+++ b/elpa/org-plus-contrib-20170407/ob-js.el
@@ -1,6 +1,6 @@
-;;; ob-js.el --- org-babel functions for Javascript
+;;; ob-js.el --- Babel Functions for Javascript      -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2010-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2017 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research, js
@@ -39,7 +39,6 @@
 
 ;;; Code:
 (require 'ob)
-(eval-when-compile (require 'cl))
 
 (declare-function run-mozilla "ext:moz" (arg))
 
@@ -56,20 +55,20 @@
   :type 'string)
 
 (defvar org-babel-js-function-wrapper
-  "require('sys').print(require('sys').inspect(function(){%s}()));"
+  "require('sys').print(require('sys').inspect(function(){\n%s\n}()));"
   "Javascript code to print value of body.")
 
 (defun org-babel-execute:js (body params)
   "Execute a block of Javascript code with org-babel.
 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)))
+  (let* ((org-babel-js-cmd (or (cdr (assq :cmd params)) org-babel-js-cmd))
+         (result-type (cdr (assq :result-type params)))
          (full-body (org-babel-expand-body:generic
 		     body params (org-babel-variable-assignments:js params)))
-	 (result (if (not (string= (cdr (assoc :session params)) "none"))
+	 (result (if (not (string= (cdr (assq :session params)) "none"))
 		     ;; session evaluation
 		     (let ((session (org-babel-prep-session:js
-				     (cdr (assoc :session params)) params)))
+				     (cdr (assq :session params)) params)))
 		       (nth 1
 			    (org-babel-comint-with-output
 				(session (format "%S" org-babel-js-eoe) t body)
@@ -89,7 +88,7 @@ This function is called by `org-babel-execute-src-block'"
 		     (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))
+    (org-babel-result-cond (cdr (assq :result-params params))
       result (org-babel-js-read result))))
 
 (defun org-babel-js-read (results)
@@ -97,7 +96,9 @@ This function is called by `org-babel-execute-src-block'"
 If RESULTS look like a table, then convert them into an
 Emacs-lisp table, otherwise return the results as a string."
   (org-babel-read
-   (if (and (stringp results) (string-match "^\\[[^\000]+\\]$" results))
+   (if (and (stringp results)
+	    (string-prefix-p "[" results)
+	    (string-suffix-p "]" results))
        (org-babel-read
         (concat "'"
                 (replace-regexp-in-string
@@ -134,7 +135,7 @@ specifying a variable of the same value."
   (mapcar
    (lambda (pair) (format "var %s=%s;"
 			  (car pair) (org-babel-js-var-to-js (cdr pair))))
-   (mapcar #'cdr (org-babel-get-header params :var))))
+   (org-babel--get-vars params)))
 
 (defun org-babel-js-initiate-session (&optional session)
   "If there is not a current inferior-process-buffer in SESSION
diff --git a/elpa/org-plus-contrib-20150831/ob-julia.el b/elpa/org-plus-contrib-20170407/ob-julia.el
similarity index 91%
rename from elpa/org-plus-contrib-20150831/ob-julia.el
rename to elpa/org-plus-contrib-20170407/ob-julia.el
index 4d8deb28..41c8b5a9 100644
--- a/elpa/org-plus-contrib-20150831/ob-julia.el
+++ b/elpa/org-plus-contrib-20170407/ob-julia.el
@@ -30,7 +30,7 @@
 
 ;;; Code:
 (require 'ob)
-(eval-when-compile (require 'cl))
+(require 'cl-lib)
 
 (declare-function orgtbl-to-csv "org-table" (table params))
 (declare-function julia "ext:ess-julia" (&optional start-args))
@@ -38,7 +38,6 @@
 (declare-function ess-make-buffer-current "ext:ess-inf" ())
 (declare-function ess-eval-buffer "ext:ess-inf" (vis))
 (declare-function org-number-sequence "org-compat" (from &optional to inc))
-(declare-function org-remove-if-not "org" (predicate seq))
 
 (defconst org-babel-header-args:julia
   '((width		 . :any)
@@ -62,7 +61,7 @@
 
 (defvar ess-local-process-name) ; dynamically scoped
 (defun org-babel-edit-prep:julia (info)
-  (let ((session (cdr (assoc :session (nth 2 info)))))
+  (let ((session (cdr (assq :session (nth 2 info)))))
     (when (and session (string-match "^\\*\\(.+?\\)\\*$" session))
       (save-match-data (org-babel-julia-initiate-session session nil)))))
 
@@ -83,12 +82,12 @@
   "Execute a block of julia code.
 This function is called by `org-babel-execute-src-block'."
   (save-excursion
-    (let* ((result-params (cdr (assoc :result-params params)))
-	   (result-type (cdr (assoc :result-type params)))
+    (let* ((result-params (cdr (assq :result-params params)))
+	   (result-type (cdr (assq :result-type params)))
            (session (org-babel-julia-initiate-session
-		     (cdr (assoc :session params)) params))
-	   (colnames-p (cdr (assoc :colnames params)))
-	   (rownames-p (cdr (assoc :rownames params)))
+		     (cdr (assq :session params)) params))
+	   (colnames-p (cdr (assq :colnames params)))
+	   (rownames-p (cdr (assq :rownames params)))
 	   (graphics-file (org-babel-julia-graphical-output-file params))
 	   (full-body (org-babel-expand-body:julia body params graphics-file))
 	   (result
@@ -96,10 +95,10 @@ This function is called by `org-babel-execute-src-block'."
 	     session full-body result-type result-params
 	     (or (equal "yes" colnames-p)
 		 (org-babel-pick-name
-		  (cdr (assoc :colname-names params)) colnames-p))
+		  (cdr (assq :colname-names params)) colnames-p))
 	     (or (equal "yes" rownames-p)
 		 (org-babel-pick-name
-		  (cdr (assoc :rowname-names params)) rownames-p)))))
+		  (cdr (assq :rowname-names params)) rownames-p)))))
       (if graphics-file nil result))))
 
 (defun org-babel-prep-session:julia (session params)
@@ -125,20 +124,20 @@ This function is called by `org-babel-execute-src-block'."
 
 (defun org-babel-variable-assignments:julia (params)
   "Return list of julia statements assigning the block's variables."
-  (let ((vars (mapcar #'cdr (org-babel-get-header params :var))))
+  (let ((vars (org-babel--get-vars params)))
     (mapcar
      (lambda (pair)
        (org-babel-julia-assign-elisp
 	(car pair) (cdr pair)
-	(equal "yes" (cdr (assoc :colnames params)))
-	(equal "yes" (cdr (assoc :rownames params)))))
+	(equal "yes" (cdr (assq :colnames params)))
+	(equal "yes" (cdr (assq :rownames params)))))
      (mapcar
       (lambda (i)
 	(cons (car (nth i vars))
 	      (org-babel-reassemble-table
 	       (cdr (nth i vars))
-	       (cdr (nth i (cdr (assoc :colname-names params))))
-	       (cdr (nth i (cdr (assoc :rowname-names params)))))))
+	       (cdr (nth i (cdr (assq :colname-names params))))
+	       (cdr (nth i (cdr (assq :rowname-names params)))))))
       (org-number-sequence 0 (1- (length vars)))))))
 
 (defun org-babel-julia-quote-csv-field (s)
@@ -150,9 +149,9 @@ This function is called by `org-babel-execute-src-block'."
 (defun org-babel-julia-assign-elisp (name value colnames-p rownames-p)
   "Construct julia code assigning the elisp VALUE to a variable named NAME."
   (if (listp value)
-      (let ((max (apply #'max (mapcar #'length (org-remove-if-not
+      (let ((max (apply #'max (mapcar #'length (cl-remove-if-not
 						#'sequencep value))))
-	    (min (apply #'min (mapcar #'length (org-remove-if-not
+	    (min (apply #'min (mapcar #'length (cl-remove-if-not
 						#'sequencep value))))
 	    (transition-file (org-babel-temp-file "julia-import-")))
         ;; ensure VALUE has an orgtbl structure (depth of at least 2)
@@ -179,7 +178,7 @@ This function is called by `org-babel-execute-src-block'."
     (let ((session (or session "*julia*"))
 	  (ess-ask-for-ess-directory
 	   (and (and (boundp 'ess-ask-for-ess-directory) ess-ask-for-ess-directory)
-		(not (cdr (assoc :dir params))))))
+		(not (cdr (assq :dir params))))))
       (if (org-babel-comint-buffer-livep session)
 	  session
 	(save-window-excursion
@@ -229,7 +228,7 @@ current code buffer."
 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."
-  (case result-type
+  (cl-case result-type
     (value
      (let ((tmp-file (org-babel-temp-file "julia-")))
        (org-babel-eval org-babel-julia-command
@@ -251,7 +250,7 @@ last statement in BODY, as elisp."
 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."
-  (case result-type
+  (cl-case result-type
     (value
      (with-temp-buffer
        (insert (org-babel-chomp body))
diff --git a/elpa/org-plus-contrib-20150831/ob-keys.el b/elpa/org-plus-contrib-20170407/ob-keys.el
similarity index 93%
rename from elpa/org-plus-contrib-20150831/ob-keys.el
rename to elpa/org-plus-contrib-20170407/ob-keys.el
index 7b709984..f5fb9101 100644
--- a/elpa/org-plus-contrib-20150831/ob-keys.el
+++ b/elpa/org-plus-contrib-20170407/ob-keys.el
@@ -1,6 +1,6 @@
-;;; ob-keys.el --- key bindings for org-babel
+;;; ob-keys.el --- Key Bindings for Babel            -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2009-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2017 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
@@ -23,8 +23,8 @@
 
 ;;; Commentary:
 
-;; Add org-babel keybindings to the org-mode keymap for exposing
-;; org-babel functions.  These will all share a common prefix.  See
+;; Add Org Babel keybindings to the Org mode keymap for exposing
+;; Org Babel functions.  These will all share a common prefix.  See
 ;; the value of `org-babel-key-bindings' for a list of interactive
 ;; functions and their associated keys.
 
diff --git a/elpa/org-plus-contrib-20150831/ob-latex.el b/elpa/org-plus-contrib-20170407/ob-latex.el
similarity index 77%
rename from elpa/org-plus-contrib-20150831/ob-latex.el
rename to elpa/org-plus-contrib-20170407/ob-latex.el
index 17e1803b..763ffb16 100644
--- a/elpa/org-plus-contrib-20150831/ob-latex.el
+++ b/elpa/org-plus-contrib-20170407/ob-latex.el
@@ -1,6 +1,6 @@
-;;; ob-latex.el --- org-babel functions for latex "evaluation"
+;;; ob-latex.el --- Babel Functions for LaTeX        -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2009-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2017 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
@@ -32,11 +32,11 @@
 ;;; Code:
 (require 'ob)
 
-(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-create-formula-image "org" (string tofile options buffer &optional type))
+(declare-function org-latex-compile "ox-latex" (texfile &optional snippet))
 (declare-function org-latex-guess-inputenc "ox-latex" (header))
-(declare-function org-latex-compile "ox-latex" (file))
+(declare-function org-splice-latex-header "org" (tpl def-pkg pkg snippets-p &optional extra))
+(declare-function org-trim "org" (s &optional keep-lead))
 
 (defvar org-babel-tangle-lang-exts)
 (add-to-list 'org-babel-tangle-lang-exts '("latex" . "tex"))
@@ -53,12 +53,16 @@
 (defconst org-babel-header-args:latex
   '((border	  . :any)
     (fit          . :any)
+    (imagemagick  . ((nil t)))
     (iminoptions  . :any)
     (imoutoptions . :any)
     (packages     . :any)
     (pdfheight    . :any)
     (pdfpng       . :any)
-    (pdfwidth     . :any))
+    (pdfwidth     . :any)
+    (headers      . :any)
+    (packages     . :any)
+    (buffer       . ((yes no))))
   "LaTeX-specific header arguments.")
 
 (defcustom org-babel-latex-htlatex "htlatex"
@@ -80,38 +84,38 @@
                  (regexp-quote (format "%S" (car pair)))
                  (if (stringp (cdr pair))
                      (cdr pair) (format "%S" (cdr pair)))
-                 body))) (mapcar #'cdr (org-babel-get-header params :var)))
-  (org-babel-trim body))
+                 body))) (org-babel--get-vars params))
+  (org-trim body))
 
 (defun org-babel-execute:latex (body params)
   "Execute a block of Latex code with Babel.
 This function is called by `org-babel-execute-src-block'."
   (setq body (org-babel-expand-body:latex body params))
-  (if (cdr (assoc :file params))
-      (let* ((out-file (cdr (assoc :file params)))
+  (if (cdr (assq :file params))
+      (let* ((out-file (cdr (assq :file params)))
+	     (extension (file-name-extension out-file))
 	     (tex-file (org-babel-temp-file "latex-" ".tex"))
-	     (border (cdr (assoc :border params)))
-	     (imagemagick (cdr (assoc :imagemagick params)))
-	     (im-in-options (cdr (assoc :iminoptions params)))
-	     (im-out-options (cdr (assoc :imoutoptions params)))
-	     (pdfpng (cdr (assoc :pdfpng params)))
-	     (fit (or (cdr (assoc :fit params)) border))
-	     (height (and fit (cdr (assoc :pdfheight params))))
-	     (width (and fit (cdr (assoc :pdfwidth params))))
-	     (headers (cdr (assoc :headers params)))
-	     (in-buffer (not (string= "no" (cdr (assoc :buffer params)))))
+	     (border (cdr (assq :border params)))
+	     (imagemagick (cdr (assq :imagemagick params)))
+	     (im-in-options (cdr (assq :iminoptions params)))
+	     (im-out-options (cdr (assq :imoutoptions params)))
+	     (fit (or (cdr (assq :fit params)) border))
+	     (height (and fit (cdr (assq :pdfheight params))))
+	     (width (and fit (cdr (assq :pdfwidth params))))
+	     (headers (cdr (assq :headers params)))
+	     (in-buffer (not (string= "no" (cdr (assq :buffer params)))))
 	     (org-latex-packages-alist
-	      (append (cdr (assoc :packages params)) org-latex-packages-alist)))
+	      (append (cdr (assq :packages params)) org-latex-packages-alist)))
         (cond
-         ((and (string-match "\\.png$" out-file) (not imagemagick))
+         ((and (string-suffix-p ".png" out-file) (not imagemagick))
           (org-create-formula-image
            body out-file org-format-latex-options in-buffer))
-         ((string-match "\\.tikz$" out-file)
+         ((string-suffix-p ".tikz" out-file)
 	  (when (file-exists-p out-file) (delete-file out-file))
 	  (with-temp-file out-file
 	    (insert body)))
-	 ((and (or (string-match "\\.svg$" out-file)
-		   (string-match "\\.html$" out-file))
+	 ((and (or (string= "svg" extension)
+		   (string= "html" extension))
 	       (executable-find org-babel-latex-htlatex))
 	  ;; TODO: this is a very different way of generating the
 	  ;; frame latex document than in the pdf case.  Ideally, both
@@ -141,7 +145,7 @@ This function is called by `org-babel-execute-src-block'."
 	    (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)
+	    (if (string-suffix-p ".svg" out-file)
 		(progn
 		  (shell-command "pwd")
 		  (shell-command (format "mv %s %s"
@@ -149,13 +153,13 @@ This function is called by `org-babel-execute-src-block'."
 					 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)
+	    (if (string-suffix-p ".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")))))
-	 ((or (string-match "\\.pdf$" out-file) imagemagick)
+	 ((or (string= "pdf" extension) imagemagick)
 	  (with-temp-file tex-file
 	    (require 'ox-latex)
 	    (insert
@@ -188,16 +192,16 @@ This function is called by `org-babel-execute-src-block'."
           (when (file-exists-p out-file) (delete-file out-file))
 	  (let ((transient-pdf-file (org-babel-latex-tex-to-pdf tex-file)))
 	    (cond
-	     ((string-match "\\.pdf$" out-file)
+	     ((string= "pdf" extension)
 	      (rename-file transient-pdf-file out-file))
 	     (imagemagick
 	      (org-babel-latex-convert-pdf
 	       transient-pdf-file out-file im-in-options im-out-options)
 	      (when (file-exists-p transient-pdf-file)
-		(delete-file transient-pdf-file))))))
-         ((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))))
+		(delete-file transient-pdf-file)))
+	     (t
+	      (error "Can not create %s files, please specify a .png or .pdf file or try the :imagemagick header argument"
+		     extension))))))
         nil) ;; signal that output has already been written to file
     body))
 
@@ -205,7 +209,7 @@ This function is called by `org-babel-execute-src-block'."
   "Generate a file from a pdf file using imagemagick."
   (let ((cmd (concat "convert " im-in-options " " pdffile " "
 		     im-out-options " " out-file)))
-    (message (concat "Converting pdffile file " cmd  "..."))
+    (message "Converting pdffile file %s..." cmd)
     (shell-command cmd)))
 
 (defun org-babel-latex-tex-to-pdf (file)
@@ -213,7 +217,7 @@ This function is called by `org-babel-execute-src-block'."
   (require 'ox-latex)
   (org-latex-compile file))
 
-(defun org-babel-prep-session:latex (session params)
+(defun org-babel-prep-session:latex (_session _params)
   "Return an error because LaTeX doesn't support sessions."
   (error "LaTeX does not support sessions"))
 
diff --git a/elpa/org-plus-contrib-20150831/ob-ledger.el b/elpa/org-plus-contrib-20170407/ob-ledger.el
similarity index 88%
rename from elpa/org-plus-contrib-20150831/ob-ledger.el
rename to elpa/org-plus-contrib-20170407/ob-ledger.el
index cda2d329..c02069e2 100644
--- a/elpa/org-plus-contrib-20150831/ob-ledger.el
+++ b/elpa/org-plus-contrib-20170407/ob-ledger.el
@@ -1,6 +1,6 @@
-;;; ob-ledger.el --- org-babel functions for ledger evaluation
+;;; ob-ledger.el --- Babel Functions for Ledger      -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2010-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2017 Free Software Foundation, Inc.
 
 ;; Author: Eric S Fraga
 ;; Keywords: literate programming, reproducible research, accounting
@@ -46,8 +46,7 @@
   "Execute a block of Ledger entries with org-babel.  This function is
 called by `org-babel-execute-src-block'."
   (message "executing Ledger source code block")
-  (let ((result-params (split-string (or (cdr (assoc :results params)) "")))
-	(cmdline (cdr (assoc :cmdline params)))
+  (let ((cmdline (cdr (assq :cmdline params)))
         (in-file (org-babel-temp-file "ledger-"))
 	(out-file (org-babel-temp-file "ledger-output-")))
     (with-temp-file in-file (insert body))
@@ -61,7 +60,7 @@ called by `org-babel-execute-src-block'."
 			     " > " (org-babel-process-file-name out-file))))
     (with-temp-buffer (insert-file-contents out-file) (buffer-string))))
 
-(defun org-babel-prep-session:ledger (session params)
+(defun org-babel-prep-session:ledger (_session _params)
   (error "Ledger does not support sessions"))
 
 (provide 'ob-ledger)
diff --git a/elpa/org-plus-contrib-20150831/ob-lilypond.el b/elpa/org-plus-contrib-20170407/ob-lilypond.el
similarity index 94%
rename from elpa/org-plus-contrib-20150831/ob-lilypond.el
rename to elpa/org-plus-contrib-20170407/ob-lilypond.el
index fe0416ef..37a7a6b5 100644
--- a/elpa/org-plus-contrib-20150831/ob-lilypond.el
+++ b/elpa/org-plus-contrib-20170407/ob-lilypond.el
@@ -1,6 +1,6 @@
-;;; ob-lilypond.el --- org-babel functions for lilypond evaluation
+;;; ob-lilypond.el --- Babel Functions for Lilypond  -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2010-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2017 Free Software Foundation, Inc.
 
 ;; Author: Martyn Jago
 ;; Keywords: babel language, literate programming
@@ -92,7 +92,7 @@ you can leave the string empty on this case."
   :version "24.3"
   :package-version '(Org . "8.2.7")
   :set
-  (lambda (symbol value)
+  (lambda (_symbol value)
     (setq
      org-babel-lilypond-ly-command   (nth 0 value)
      org-babel-lilypond-pdf-command  (nth 1 value)
@@ -123,14 +123,14 @@ blocks.")
 
 (defun org-babel-expand-body:lilypond (body params)
   "Expand BODY according to PARAMS, return the expanded body."
-  (let ((vars (mapcar #'cdr (org-babel-get-header params :var))))
+  (let ((vars (org-babel--get-vars params)))
     (mapc
      (lambda (pair)
        (let ((name (symbol-name (car pair)))
 	     (value (cdr pair)))
 	 (setq body
 	       (replace-regexp-in-string
-		(concat "\$" (regexp-quote name))
+		(concat "$" (regexp-quote name))
 		(if (stringp value) value (format "%S" value))
 		body))))
      vars)
@@ -157,9 +157,8 @@ specific arguments to =org-babel-tangle="
 
 (defun org-babel-lilypond-process-basic (body params)
   "Execute a lilypond block in basic mode."
-  (let* ((result-params (cdr (assoc :result-params params)))
-	 (out-file (cdr (assoc :file params)))
-	 (cmdline (or (cdr (assoc :cmdline params))
+  (let* ((out-file (cdr (assq :file params)))
+	 (cmdline (or (cdr (assq :cmdline params))
 		      ""))
 	 (in-file (org-babel-temp-file "lilypond-")))
 
@@ -182,7 +181,7 @@ specific arguments to =org-babel-tangle="
       cmdline
       in-file) "")) nil)
 
-(defun org-babel-prep-session:lilypond (session params)
+(defun org-babel-prep-session:lilypond (_session _params)
   "Return an error because LilyPond exporter does not support sessions."
   (error "Sorry, LilyPond does not currently support sessions!"))
 
@@ -265,32 +264,26 @@ LINE is the erroneous line"
     (setq case-fold-search nil)
     (if (search-forward line nil t)
         (progn
-          (show-all)
+          (outline-show-all)
           (set-mark (point))
           (goto-char (- (point) (length line))))
       (goto-char temp))))
 
 (defun org-babel-lilypond-parse-line-num (&optional buffer)
   "Extract error line number."
-  (when buffer
-    (set-buffer buffer))
+  (when buffer (set-buffer buffer))
   (let ((start
          (and (search-backward ":" nil t)
               (search-backward ":" nil t)
               (search-backward ":" nil t)
-              (search-backward ":" nil t)))
-        (num nil))
-    (if start
-        (progn
-          (forward-char)
-          (let ((num (buffer-substring
-                      (+ 1 start)
-                      (- (search-forward ":" nil t) 1))))
-            (setq num (string-to-number num))
-            (if (numberp num)
-                num
-              nil)))
-      nil)))
+              (search-backward ":" nil t))))
+    (when start
+      (forward-char)
+      (let ((num (string-to-number
+		  (buffer-substring
+		   (+ 1 start)
+		   (- (search-forward ":" nil t) 1)))))
+	(and (numberp num) num)))))
 
 (defun org-babel-lilypond-parse-error-line (file-name lineNo)
   "Extract the erroneous line from the tangled .ly file
diff --git a/elpa/org-plus-contrib-20170407/ob-lisp.el b/elpa/org-plus-contrib-20170407/ob-lisp.el
new file mode 100644
index 00000000..1e381d0c
--- /dev/null
+++ b/elpa/org-plus-contrib-20170407/ob-lisp.el
@@ -0,0 +1,127 @@
+;;; ob-lisp.el --- Babel Functions for Common Lisp   -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2009-2017 Free Software Foundation, Inc.
+
+;; Authors: Joel Boehland
+;;	 Eric Schulte
+;;	 David T. O'Toole 
+;; 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 .
+
+;;; Commentary:
+
+;;; Support for evaluating Common Lisp code, relies on SLY or SLIME
+;;; for all eval.
+
+;;; Requirements:
+
+;; Requires SLY (Sylvester the Cat's Common Lisp IDE) or SLIME
+;; (Superior Lisp Interaction Mode for Emacs).  See:
+;; - https://github.com/capitaomorte/sly
+;; - http://common-lisp.net/project/slime/
+
+;;; Code:
+(require 'ob)
+
+(declare-function sly-eval "ext:sly" (sexp &optional package))
+(declare-function slime-eval "ext:slime" (sexp &optional package))
+(declare-function org-trim "org" (s &optional keep-lead))
+
+(defvar org-babel-tangle-lang-exts)
+(add-to-list 'org-babel-tangle-lang-exts '("lisp" . "lisp"))
+
+(defvar org-babel-default-header-args:lisp '())
+(defvar org-babel-header-args:lisp '((package . :any)))
+
+(defcustom org-babel-lisp-eval-fn #'slime-eval
+  "The function to be called to evaluate code on the Lisp side.
+Valid values include `slime-eval' and `sly-eval'."
+  :group 'org-babel
+  :version "26.1"
+  :package-version '(Org . "9.0")
+  :type 'function)
+
+(defcustom org-babel-lisp-dir-fmt
+  "(let ((*default-pathname-defaults* #P%S\n)) %%s\n)"
+  "Format string used to wrap code bodies to set the current directory.
+For example a value of \"(progn ;; %s\\n   %%s)\" would ignore the
+current directory string."
+  :group 'org-babel
+  :version "24.1"
+  :type 'string)
+
+(defun org-babel-expand-body:lisp (body params)
+  "Expand BODY according to PARAMS, return the expanded body."
+  (let* ((vars (org-babel--get-vars params))
+	 (result-params (cdr (assq :result-params params)))
+	 (print-level nil) (print-length nil)
+	 (body (if (null vars) (org-trim body)
+		 (concat "(let ("
+			 (mapconcat
+			  (lambda (var)
+			    (format "(%S (quote %S))" (car var) (cdr var)))
+			  vars "\n      ")
+			 ")\n" body ")"))))
+    (if (or (member "code" result-params)
+	    (member "pp" result-params))
+	(format "(pprint %s)" body)
+      body)))
+
+(defun org-babel-execute:lisp (body params)
+  "Execute a block of Common Lisp code with Babel.
+BODY is the contents of the block, as a string.  PARAMS is
+a property list containing the parameters of the block."
+  (require (pcase org-babel-lisp-eval-fn
+	     (`slime-eval 'slime)
+	     (`sly-eval 'sly)))
+  (org-babel-reassemble-table
+   (let ((result
+          (funcall (if (member "output" (cdr (assq :result-params params)))
+                       #'car #'cadr)
+                   (with-temp-buffer
+                     (insert (org-babel-expand-body:lisp body params))
+                     (funcall org-babel-lisp-eval-fn
+                              `(swank:eval-and-grab-output
+                                ,(let ((dir (if (assq :dir params)
+                                                (cdr (assq :dir params))
+                                              default-directory)))
+                                   (format
+                                    (if dir (format org-babel-lisp-dir-fmt dir)
+                                      "(progn %s\n)")
+                                    (buffer-substring-no-properties
+                                     (point-min) (point-max)))))
+                              (cdr (assq :package params)))))))
+     (org-babel-result-cond (cdr (assq :result-params params))
+       result
+       (condition-case nil
+           (read (org-babel-lisp-vector-to-list result))
+         (error result))))
+   (org-babel-pick-name (cdr (assq :colname-names params))
+			(cdr (assq :colnames params)))
+   (org-babel-pick-name (cdr (assq :rowname-names params))
+			(cdr (assq :rownames params)))))
+
+(defun org-babel-lisp-vector-to-list (results)
+  ;; TODO: better would be to replace #(...) with [...]
+  (replace-regexp-in-string "#(" "(" results))
+
+(provide 'ob-lisp)
+
+
+
+;;; ob-lisp.el ends here
diff --git a/elpa/org-plus-contrib-20170407/ob-lob.el b/elpa/org-plus-contrib-20170407/ob-lob.el
new file mode 100644
index 00000000..b6f50d33
--- /dev/null
+++ b/elpa/org-plus-contrib-20170407/ob-lob.el
@@ -0,0 +1,151 @@
+;;; ob-lob.el --- Functions Supporting the Library of Babel -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2009-2017 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 .
+
+;;; Code:
+(require 'cl-lib)
+(require 'ob-core)
+(require 'ob-table)
+
+(declare-function org-babel-ref-split-args "ob-ref" (arg-string))
+(declare-function org-element-at-point "org-element" ())
+(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))
+
+(defvar org-babel-library-of-babel nil
+  "Library of source-code blocks.
+This is an association list.  Populate the library by calling
+`org-babel-lob-ingest' on files containing source blocks.")
+
+(defvar org-babel-default-lob-header-args '((:exports . "results"))
+  "Default header arguments to use when exporting Babel calls.
+By default, a Babel call inherits its arguments from the source
+block being called.  Header arguments defined in this variable
+take precedence over these.  It is useful for properties that
+should not be inherited from a source block.")
+
+(defun org-babel-lob-ingest (&optional file)
+  "Add all named source blocks defined in FILE to `org-babel-library-of-babel'."
+  (interactive "fFile: ")
+  (let ((lob-ingest-count 0))
+    (org-babel-map-src-blocks file
+      (let* ((info (org-babel-get-src-block-info 'light))
+	     (source-name (nth 4 info)))
+	(when source-name
+	  (setq source-name (intern source-name)
+		org-babel-library-of-babel
+		(cons (cons source-name info)
+		      (assq-delete-all source-name org-babel-library-of-babel))
+		lob-ingest-count (1+ lob-ingest-count)))))
+    (message "%d src block%s added to Library of Babel"
+	     lob-ingest-count (if (> lob-ingest-count 1) "s" ""))
+    lob-ingest-count))
+
+;; Functions for executing lob one-liners.
+
+;;;###autoload
+(defun org-babel-lob-execute-maybe ()
+  "Execute a Library of Babel source block, if appropriate.
+Detect if this is context for a Library Of Babel source block and
+if so then run the appropriate source block from the Library."
+  (interactive)
+  (let ((info (org-babel-lob-get-info)))
+    (when info
+      (org-babel-execute-src-block nil info)
+      t)))
+
+(defun org-babel-lob--src-info (name)
+  "Return internal representation for Babel data named NAME.
+NAME is a string.  This function looks into the current document
+for a Babel call or source block.  If none is found, it looks
+after NAME in the Library of Babel.  Eventually, if that also
+fails, it returns nil."
+  ;; During export, look into the pristine copy of the document being
+  ;; exported instead of the current one, which could miss some data.
+  (with-current-buffer (or org-babel-exp-reference-buffer (current-buffer))
+    (org-with-wide-buffer
+     (goto-char (point-min))
+     (catch :found
+       (let ((case-fold-search t)
+	     (regexp (org-babel-named-data-regexp-for-name name)))
+	 (while (re-search-forward regexp nil t)
+	   (let ((element (org-element-at-point)))
+	     (when (equal name (org-element-property :name element))
+	       (throw :found
+		      (pcase (org-element-type element)
+			(`src-block (org-babel-get-src-block-info t element))
+			(`babel-call (org-babel-lob-get-info element))
+			;; Non-executable data found.  Since names are
+			;; supposed to be unique throughout a document,
+			;; bail out.
+			(_ nil))))))
+	 ;; No element named NAME in buffer.  Try Library of Babel.
+	 (cdr (assoc-string name org-babel-library-of-babel)))))))
+
+;;;###autoload
+(defun org-babel-lob-get-info (&optional datum)
+  "Return internal representation for Library of Babel function call.
+Consider DATUM, when provided, or element at point.  Return nil
+when not on an appropriate location.  Otherwise return a list
+compatible with `org-babel-get-src-block-info', which see."
+  (let* ((context (or datum (org-element-context)))
+	 (type (org-element-type context)))
+    (when (memq type '(babel-call inline-babel-call))
+      (pcase (org-babel-lob--src-info (org-element-property :call context))
+	(`(,language ,body ,header ,_ ,_ ,_ ,coderef)
+	 (let ((begin (org-element-property (if (eq type 'inline-babel-call)
+						:begin
+					      :post-affiliated)
+					    context)))
+	   (list language
+		 body
+		 (apply #'org-babel-merge-params
+			header
+			org-babel-default-lob-header-args
+			(append
+			 (org-with-wide-buffer
+			  (goto-char begin)
+			  (org-babel-params-from-properties language))
+			 (list
+			  (org-babel-parse-header-arguments
+			   (org-element-property :inside-header context))
+			  (let ((args (org-element-property :arguments context)))
+			    (and args
+				 (mapcar (lambda (ref) (cons :var ref))
+					 (org-babel-ref-split-args args))))
+			  (org-babel-parse-header-arguments
+			   (org-element-property :end-header context)))))
+		 nil
+		 (org-element-property :name context)
+		 begin
+		 coderef)))
+	(_ nil)))))
+
+(provide 'ob-lob)
+
+;; Local variables:
+;; generated-autoload-file: "org-loaddefs.el"
+;; End:
+
+;;; ob-lob.el ends here
diff --git a/elpa/org-plus-contrib-20170407/ob-lua.el b/elpa/org-plus-contrib-20170407/ob-lua.el
new file mode 100644
index 00000000..fa60b0ee
--- /dev/null
+++ b/elpa/org-plus-contrib-20170407/ob-lua.el
@@ -0,0 +1,403 @@
+;;; ob-lua.el --- Org Babel functions for Lua evaluation -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2014, 2016, 2017 Free Software Foundation, Inc.
+
+;; Authors: Dieter Schoen
+;; 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 .
+
+;; Requirements:
+;; for session support, lua-mode is needed.
+;; lua-mode is not part of GNU Emacs/orgmode, but can be obtained
+;; from marmalade or melpa.
+;; The source respository is here:
+;; https://github.com/immerrr/lua-mode
+
+;; However, sessions are not yet working.
+
+;; Org-Babel support for evaluating lua source code.
+
+;;; Code:
+(require 'ob)
+(require 'cl-lib)
+
+(declare-function org-remove-indentation "org" (code &optional n))
+(declare-function org-trim "org" (s &optional keep-lead))
+(declare-function lua-shell "ext:lua-mode" (&optional argprompt))
+(declare-function lua-toggle-shells "ext:lua-mode" (arg))
+(declare-function run-lua "ext:lua" (cmd &optional dedicated show))
+
+(defvar org-babel-tangle-lang-exts)
+(add-to-list 'org-babel-tangle-lang-exts '("lua" . "lua"))
+
+(defvar org-babel-default-header-args:lua '())
+
+(defcustom org-babel-lua-command "lua"
+  "Name of the command for executing Lua code."
+  :version "24.5"
+  :package-version '(Org . "8.3")
+  :group 'org-babel
+  :type 'string)
+
+(defcustom org-babel-lua-mode 'lua-mode
+  "Preferred lua mode for use in running lua interactively.
+This will typically be 'lua-mode."
+  :group 'org-babel
+  :version "24.5"
+  :package-version '(Org . "8.3")
+  :type 'symbol)
+
+(defcustom org-babel-lua-hline-to "None"
+  "Replace hlines in incoming tables with this when translating to lua."
+  :group 'org-babel
+  :version "24.5"
+  :package-version '(Org . "8.3")
+  :type 'string)
+
+(defcustom org-babel-lua-None-to 'hline
+  "Replace 'None' in lua tables with this before returning."
+  :group 'org-babel
+  :version "24.5"
+  :package-version '(Org . "8.3")
+  :type 'symbol)
+
+(defun org-babel-execute:lua (body params)
+  "Execute a block of Lua code with Babel.
+This function is called by `org-babel-execute-src-block'."
+  (let* ((session (org-babel-lua-initiate-session
+		   (cdr (assq :session params))))
+         (result-params (cdr (assq :result-params params)))
+         (result-type (cdr (assq :result-type params)))
+	 (return-val (when (and (eq result-type 'value) (not session))
+		       (cdr (assq :return params))))
+	 (preamble (cdr (assq :preamble params)))
+         (full-body
+	  (org-babel-expand-body:generic
+	   (concat body (if return-val (format "\nreturn %s" return-val) ""))
+	   params (org-babel-variable-assignments:lua params)))
+         (result (org-babel-lua-evaluate
+		  session full-body result-type result-params preamble)))
+    (org-babel-reassemble-table
+     result
+     (org-babel-pick-name (cdr (assq :colname-names params))
+			  (cdr (assq :colnames params)))
+     (org-babel-pick-name (cdr (assq :rowname-names params))
+			  (cdr (assq :rownames params))))))
+
+(defun org-babel-prep-session:lua (session params)
+  "Prepare SESSION according to the header arguments in PARAMS.
+VARS contains resolved variable references"
+  (let* ((session (org-babel-lua-initiate-session session))
+	 (var-lines
+	  (org-babel-variable-assignments:lua params)))
+    (org-babel-comint-in-buffer session
+      (mapc (lambda (var)
+              (end-of-line 1) (insert var) (comint-send-input)
+              (org-babel-comint-wait-for-output session)) var-lines))
+    session))
+
+(defun org-babel-load-session:lua (session body params)
+  "Load BODY into SESSION."
+  (save-window-excursion
+    (let ((buffer (org-babel-prep-session:lua session params)))
+      (with-current-buffer buffer
+        (goto-char (process-mark (get-buffer-process (current-buffer))))
+        (insert (org-babel-chomp body)))
+      buffer)))
+
+;; helper functions
+
+(defun org-babel-variable-assignments:lua (params)
+  "Return a list of Lua statements assigning the block's variables."
+  (mapcar
+   (lambda (pair)
+     (format "%s=%s"
+	     (car pair)
+	     (org-babel-lua-var-to-lua (cdr pair))))
+   (org-babel--get-vars params)))
+
+(defun org-babel-lua-var-to-lua (var)
+  "Convert an elisp value to a lua variable.
+Convert an elisp value, VAR, into a string of lua source code
+specifying a variable of the same value."
+  (if (listp var)
+      (if (and (= 1 (length var)) (not (listp (car var))))
+          (org-babel-lua-var-to-lua (car var))
+        (if (and
+             (= 2 (length var))
+             (not (listp (car var))))
+            (concat
+             (substring-no-properties (car var))
+             "="
+             (org-babel-lua-var-to-lua (cdr var)))
+          (concat "{" (mapconcat #'org-babel-lua-var-to-lua var ", ") "}")))
+    (if (eq var 'hline)
+        org-babel-lua-hline-to
+      (format
+       (if (and (stringp var) (string-match "[\n\r]" var)) "\"\"%S\"\"" "%S")
+       (if (stringp var) (substring-no-properties var) var)))))
+
+(defun org-babel-lua-table-or-string (results)
+  "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."
+  (let ((res (org-babel-script-escape results)))
+    (if (listp res)
+        (mapcar (lambda (el) (if (eq el 'None)
+				 org-babel-lua-None-to el))
+                res)
+      res)))
+
+(defvar org-babel-lua-buffers '((:default . "*Lua*")))
+
+(defun org-babel-lua-session-buffer (session)
+  "Return the buffer associated with SESSION."
+  (cdr (assoc session org-babel-lua-buffers)))
+
+(defun org-babel-lua-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-lua-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 lua-default-interpreter)
+(defvar lua-which-bufname)
+(defvar lua-shell-buffer-name)
+(defun org-babel-lua-initiate-session-by-key (&optional session)
+  "Initiate a lua session.
+If there is not a current inferior-process-buffer in SESSION
+then create.  Return the initialized session."
+  ;; (require org-babel-lua-mode)
+  (save-window-excursion
+    (let* ((session (if session (intern session) :default))
+           (lua-buffer (org-babel-lua-session-buffer session))
+	   ;; (cmd (if (member system-type '(cygwin windows-nt ms-dos))
+	   ;; 	    (concat org-babel-lua-command " -i")
+	   ;; 	  org-babel-lua-command))
+	   )
+      (cond
+       ((and (eq 'lua-mode org-babel-lua-mode)
+             (fboundp 'lua-start-process)) ; lua-mode.el
+        ;; Make sure that lua-which-bufname is initialized, as otherwise
+        ;; it will be overwritten the first time a Lua buffer is
+        ;; created.
+        ;;(lua-toggle-shells lua-default-interpreter)
+        ;; `lua-shell' creates a buffer whose name is the value of
+        ;; `lua-which-bufname' with '*'s at the beginning and end
+        (let* ((bufname (if (and lua-buffer (buffer-live-p lua-buffer))
+                            (replace-regexp-in-string ;; zap surrounding *
+                             "^\\*\\([^*]+\\)\\*$" "\\1" (buffer-name lua-buffer))
+                          (concat "Lua-" (symbol-name session))))
+               (lua-which-bufname bufname))
+          (lua-start-process)
+          (setq lua-buffer (org-babel-lua-with-earmuffs bufname))))
+       (t
+	(error "No function available for running an inferior Lua")))
+      (setq org-babel-lua-buffers
+            (cons (cons session lua-buffer)
+                  (assq-delete-all session org-babel-lua-buffers)))
+      session)))
+
+(defun org-babel-lua-initiate-session (&optional session _params)
+  "Create a session named SESSION according to PARAMS."
+  (unless (string= session "none")
+    (error "Sessions currently not supported, work in progress")
+    (org-babel-lua-session-buffer
+     (org-babel-lua-initiate-session-by-key session))))
+
+(defvar org-babel-lua-eoe-indicator "--eoe"
+  "A string to indicate that evaluation has completed.")
+
+(defvar org-babel-lua-wrapper-method
+  "
+function main()
+%s
+end
+
+fd=io.open(\"%s\", \"w\")
+fd:write( main() )
+fd:close()")
+(defvar org-babel-lua-pp-wrapper-method
+  "
+-- table to string
+function t2s(t, indent)
+   if indent == nil then
+      indent = \"\"
+   end
+   if type(t) == \"table\" then
+      ts = \"\"
+      for k,v in pairs(t) do
+         if type(v) == \"table\" then
+            ts = ts .. indent .. t2s(k,indent .. \"  \") .. \" = \\n\" ..
+               t2s(v, indent .. \"  \")
+         else
+            ts = ts .. indent .. t2s(k,indent .. \"  \") .. \" = \" ..
+               t2s(v, indent .. \"  \") .. \"\\n\"
+         end
+      end
+      return ts
+   else
+      return tostring(t)
+   end
+end
+
+
+function main()
+%s
+end
+
+fd=io.open(\"%s\", \"w\")
+fd:write(t2s(main()))
+fd:close()")
+
+(defun org-babel-lua-evaluate
+    (session body &optional result-type result-params preamble)
+  "Evaluate BODY as Lua code."
+  (if session
+      (org-babel-lua-evaluate-session
+       session body result-type result-params)
+    (org-babel-lua-evaluate-external-process
+     body result-type result-params preamble)))
+
+(defun org-babel-lua-evaluate-external-process
+    (body &optional result-type result-params preamble)
+  "Evaluate BODY in external lua process.
+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."
+  (let ((raw
+         (pcase result-type
+           (`output (org-babel-eval org-babel-lua-command
+				    (concat (if preamble (concat preamble "\n"))
+					    body)))
+           (`value (let ((tmp-file (org-babel-temp-file "lua-")))
+		     (org-babel-eval
+		      org-babel-lua-command
+		      (concat
+		       (if preamble (concat preamble "\n") "")
+		       (format
+			(if (member "pp" result-params)
+			    org-babel-lua-pp-wrapper-method
+			  org-babel-lua-wrapper-method)
+			(mapconcat
+			 (lambda (line) (format "\t%s" line))
+			 (split-string
+			  (org-remove-indentation
+			   (org-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-lua-table-or-string (org-trim raw)))))
+
+(defun org-babel-lua-evaluate-session
+    (session body &optional result-type result-params)
+  "Pass BODY to the Lua 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
+last statement in BODY, as elisp."
+  (let* ((send-wait (lambda () (comint-send-input nil t) (sleep-for 0 5)))
+	 (dump-last-value
+	  (lambda
+	    (tmp-file pp)
+	    (mapc
+	     (lambda (statement) (insert statement) (funcall send-wait))
+	     (if pp
+		 (list
+		  "-- table to string
+function t2s(t, indent)
+   if indent == nil then
+      indent = \"\"
+   end
+   if type(t) == \"table\" then
+      ts = \"\"
+      for k,v in pairs(t) do
+         if type(v) == \"table\" then
+            ts = ts .. indent .. t2s(k,indent .. \"  \") .. \" = \\n\" ..
+               t2s(v, indent .. \"  \")
+         else
+            ts = ts .. indent .. t2s(k,indent .. \"  \") .. \" = \" ..
+               t2s(v, indent .. \"  \") .. \"\\n\"
+         end
+      end
+      return ts
+   else
+      return tostring(t)
+   end
+end
+"
+		  (concat "fd:write(_))
+fd:close()"
+			  (org-babel-process-file-name tmp-file 'noquote)))
+	       (list (format "fd=io.open(\"%s\", \"w\")
+fd:write( _ )
+fd:close()"
+			     (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)))
+         (results
+          (pcase result-type
+            (`output
+             (mapconcat
+              #'org-trim
+              (butlast
+               (org-babel-comint-with-output
+                   (session org-babel-lua-eoe-indicator t body)
+                 (funcall input-body body)
+                 (funcall send-wait) (funcall send-wait)
+                 (insert org-babel-lua-eoe-indicator)
+                 (funcall send-wait))
+               2) "\n"))
+            (`value
+             (let ((tmp-file (org-babel-temp-file "lua-")))
+               (org-babel-comint-with-output
+                   (session org-babel-lua-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-lua-eoe-indicator)
+                   (funcall send-wait)))
+               (org-babel-eval-read-file tmp-file))))))
+    (unless (string= (substring org-babel-lua-eoe-indicator 1 -1) results)
+      (org-babel-result-cond result-params
+	results
+        (org-babel-lua-table-or-string results)))))
+
+(defun org-babel-lua-read-string (string)
+  "Strip 's from around Lua string."
+  (org-unbracket-string "'" "'" string))
+
+(provide 'ob-lua)
+
+
+
+;;; ob-lua.el ends here
diff --git a/elpa/org-plus-contrib-20150831/ob-makefile.el b/elpa/org-plus-contrib-20170407/ob-makefile.el
similarity index 79%
rename from elpa/org-plus-contrib-20150831/ob-makefile.el
rename to elpa/org-plus-contrib-20170407/ob-makefile.el
index b43a9b39..2aa04fd2 100644
--- a/elpa/org-plus-contrib-20150831/ob-makefile.el
+++ b/elpa/org-plus-contrib-20170407/ob-makefile.el
@@ -1,6 +1,6 @@
-;;; ob-makefile.el --- org-babel functions for makefile evaluation
+;;; ob-makefile.el --- Babel Functions for Makefile  -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2009-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2017 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; 	   Thomas S. Dye
@@ -24,19 +24,19 @@
 
 ;;; Commentary:
 
-;; This file exists solely for tangling a Makefile from org-mode files.
+;; This file exists solely for tangling a Makefile from Org files.
 
 ;;; Code:
 (require 'ob)
 
 (defvar org-babel-default-header-args:makefile '())
 
-(defun org-babel-execute:makefile (body params)
+(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)
+(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"))
diff --git a/elpa/org-plus-contrib-20150831/ob-mathematica.el b/elpa/org-plus-contrib-20170407/ob-mathematica.el
similarity index 91%
rename from elpa/org-plus-contrib-20150831/ob-mathematica.el
rename to elpa/org-plus-contrib-20170407/ob-mathematica.el
index a7967415..cb35dec0 100644
--- a/elpa/org-plus-contrib-20150831/ob-mathematica.el
+++ b/elpa/org-plus-contrib-20170407/ob-mathematica.el
@@ -14,6 +14,9 @@
 (require 'ob-ref)
 (require 'ob-comint)
 (require 'ob-eval)
+
+(declare-function org-trim "org" (s &optional keep-lead))
+
 ;; Optionally require mma.el for font lock, etc
 (require 'mma nil 'noerror)
 (add-to-list 'org-src-lang-modes '("mathematica" . "mma"))
@@ -31,7 +34,7 @@
 
 (defun org-babel-expand-body:mathematica (body params)
   "Expand BODY according to PARAMS, return the expanded body."
-  (let ((vars (mapcar #'cdr (org-babel-get-header params :var))))
+  (let ((vars (org-babel--get-vars params)))
     (concat
      (mapconcat ;; define any variables
       (lambda (pair)
@@ -43,11 +46,11 @@
 (defun org-babel-execute:mathematica (body params)
   "Execute a block of Mathematica code with org-babel.  This function is
 called by `org-babel-execute-src-block'"
-  (let* ((result-params (cdr (assoc :result-params params)))
+  (let* ((result-params (cdr (assq :result-params params)))
 	 (full-body (org-babel-expand-body:mathematica body params))
 	 (tmp-script-file (org-babel-temp-file "mathematica-"))
 	 (cmd org-babel-mathematica-command))
-    ;; actually execute the source-code block 
+    ;; actually execute the source-code block
     (with-temp-file tmp-script-file (insert full-body))
     ;; (with-temp-file "/tmp/dbg" (insert full-body))
     ((lambda (raw)
@@ -56,7 +59,7 @@ called by `org-babel-execute-src-block'"
 	       (and (member "output" result-params)
 		    (not (member "table" result-params))))
 	   raw
-	 (org-babel-script-escape (org-babel-trim raw))))
+	 (org-babel-script-escape (org-trim raw))))
     (org-babel-eval (concat cmd " " tmp-script-file) ""))))
 
 (defun org-babel-prep-session:mathematica (session params)
@@ -76,4 +79,3 @@ specifying a variable of the same value."
     (format "%S" var)))
 
 (provide 'ob-mathematica)
-
diff --git a/elpa/org-plus-contrib-20150831/ob-mathomatic.el b/elpa/org-plus-contrib-20170407/ob-mathomatic.el
similarity index 76%
rename from elpa/org-plus-contrib-20150831/ob-mathomatic.el
rename to elpa/org-plus-contrib-20170407/ob-mathomatic.el
index bfd8ecf2..c62e1818 100644
--- a/elpa/org-plus-contrib-20150831/ob-mathomatic.el
+++ b/elpa/org-plus-contrib-20170407/ob-mathomatic.el
@@ -1,6 +1,6 @@
 ;;; ob-mathomatic.el --- Org-babel functions for mathomatic evaluation
 
-;; Copyright (C) 2009-2014  Free Software Foundation, Inc.
+;; Copyright (C) 2009-2017  Free Software Foundation, Inc.
 
 ;; Author: Eric S Fraga
 ;;	Eric Schulte
@@ -49,45 +49,45 @@
 
 (defun org-babel-mathomatic-expand (body params)
   "Expand a block of Mathomatic code according to its header arguments."
-  (let ((vars (mapcar #'cdr (org-babel-get-header params :var))))
-     (mapconcat 'identity
-		(list
-		 ;; graphic output
-		 (let ((graphic-file (org-babel-mathomatic-graphical-output-file params)))
-		   (if graphic-file
-		       (cond
-			((string-match ".\.eps$" graphic-file)
-			 (format ;; Need to add command to send to file.
-			  "set plot set terminal postscript eps\\;set output %S "
-			  graphic-file))
-			((string-match ".\.ps$" graphic-file)
-			 (format ;; Need to add command to send to file.
-			  "set plot set terminal postscript\\;set output %S "
-			  graphic-file))
-
-			((string-match ".\.pic$" graphic-file)
-			 (format ;; Need to add command to send to file.
-			  "set plot set terminal gpic\\;set output %S "
-			  graphic-file))
-			(t
-			 (format ;; Need to add command to send to file.
-			  "set plot set terminal png\\;set output %S "
-			  graphic-file)))
-		     ""))
-		 ;; variables
-		 (mapconcat 'org-babel-mathomatic-var-to-mathomatic vars "\n")
-		 ;; body
-		 body
-		 "")
-		"\n")))
+  (let ((vars (org-babel--get-vars params)))
+    (mapconcat 'identity
+	       (list
+		;; graphic output
+		(let ((graphic-file (org-babel-mathomatic-graphical-output-file params)))
+		  (if graphic-file
+		      (cond
+		       ((string-match ".\.eps$" graphic-file)
+			(format ;; Need to add command to send to file.
+			 "set plot set terminal postscript eps\\;set output %S "
+			 graphic-file))
+		       ((string-match ".\.ps$" graphic-file)
+			(format ;; Need to add command to send to file.
+			 "set plot set terminal postscript\\;set output %S "
+			 graphic-file))
+
+		       ((string-match ".\.pic$" graphic-file)
+			(format ;; Need to add command to send to file.
+			 "set plot set terminal gpic\\;set output %S "
+			 graphic-file))
+		       (t
+			(format ;; Need to add command to send to file.
+			 "set plot set terminal png\\;set output %S "
+			 graphic-file)))
+		    ""))
+		;; variables
+		(mapconcat 'org-babel-mathomatic-var-to-mathomatic vars "\n")
+		;; body
+		body
+		"")
+	       "\n")))
 
 (defun org-babel-execute:mathomatic (body params)
   "Execute a block of Mathomatic entries with org-babel.  This function is
 called by `org-babel-execute-src-block'."
   (message "executing Mathomatic source code block")
-  (let ((result-params (split-string (or (cdr (assoc :results params)) "")))
+  (let ((result-params (split-string (or (cdr (assq :results params)) "")))
 	(result
-	 (let* ((cmdline (or (cdr (assoc :cmdline params)) ""))
+	 (let* ((cmdline (or (cdr (assq :cmdline params)) ""))
 		(in-file (org-babel-temp-file "mathomatic-" ".math"))
 		(cmd (format "%s -t -c -q  %s %s"
 			     org-babel-mathomatic-command in-file cmdline)))
diff --git a/elpa/org-plus-contrib-20150831/ob-matlab.el b/elpa/org-plus-contrib-20170407/ob-matlab.el
similarity index 89%
rename from elpa/org-plus-contrib-20150831/ob-matlab.el
rename to elpa/org-plus-contrib-20170407/ob-matlab.el
index 31464f9e..23cfa36d 100644
--- a/elpa/org-plus-contrib-20150831/ob-matlab.el
+++ b/elpa/org-plus-contrib-20170407/ob-matlab.el
@@ -1,6 +1,6 @@
-;;; ob-matlab.el --- org-babel support for matlab evaluation
+;;; ob-matlab.el --- Babel support for Matlab        -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2010-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2017 Free Software Foundation, Inc.
 
 ;; Author: Dan Davison
 ;; Keywords: literate programming, reproducible research
diff --git a/elpa/org-plus-contrib-20150831/ob-maxima.el b/elpa/org-plus-contrib-20170407/ob-maxima.el
similarity index 87%
rename from elpa/org-plus-contrib-20150831/ob-maxima.el
rename to elpa/org-plus-contrib-20170407/ob-maxima.el
index 02e96b8f..350f66b7 100644
--- a/elpa/org-plus-contrib-20150831/ob-maxima.el
+++ b/elpa/org-plus-contrib-20170407/ob-maxima.el
@@ -1,6 +1,6 @@
-;;; ob-maxima.el --- org-babel functions for maxima evaluation
+;;; ob-maxima.el --- Babel Functions for Maxima      -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2009-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2017 Free Software Foundation, Inc.
 
 ;; Author: Eric S Fraga
 ;;	Eric Schulte
@@ -48,9 +48,13 @@
 
 (defun org-babel-maxima-expand (body params)
   "Expand a block of Maxima code according to its header arguments."
-  (let ((vars (mapcar #'cdr (org-babel-get-header params :var))))
+  (let ((vars (org-babel--get-vars params))
+	(epilogue (cdr (assq :epilogue params)))
+	(prologue (cdr (assq :prologue params))))
     (mapconcat 'identity
 	       (list
+		;; Any code from the specified prologue at the start.
+		prologue
 		;; graphic output
 		(let ((graphic-file (ignore-errors (org-babel-graphical-output-file params))))
 		  (if graphic-file
@@ -62,6 +66,8 @@
 		(mapconcat 'org-babel-maxima-var-to-maxima vars "\n")
 		;; body
 		body
+		;; Any code from the specified epilogue at the end.
+		epilogue
 		"gnuplot_close ()$")
 	       "\n")))
 
@@ -69,9 +75,9 @@
   "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)) "")))
+  (let ((result-params (split-string (or (cdr (assq :results params)) "")))
 	(result
-	 (let* ((cmdline (or (cdr (assoc :cmdline params)) ""))
+	 (let* ((cmdline (or (cdr (assq :cmdline params)) ""))
 		(in-file (org-babel-temp-file "maxima-" ".max"))
 		(cmd (format "%s --very-quiet -r 'batchload(%S)$' %s"
 			     org-babel-maxima-command in-file cmdline)))
@@ -98,7 +104,7 @@ This function is called by `org-babel-execute-src-block'."
 	  (org-babel-import-elisp-from-file tmp-file))))))
 
 
-(defun org-babel-prep-session:maxima (session params)
+(defun org-babel-prep-session:maxima (_session _params)
   (error "Maxima does not support sessions"))
 
 (defun org-babel-maxima-var-to-maxima (pair)
diff --git a/elpa/org-plus-contrib-20150831/ob-mscgen.el b/elpa/org-plus-contrib-20170407/ob-mscgen.el
similarity index 87%
rename from elpa/org-plus-contrib-20150831/ob-mscgen.el
rename to elpa/org-plus-contrib-20170407/ob-mscgen.el
index 6d57210c..5c9dccc6 100644
--- a/elpa/org-plus-contrib-20150831/ob-mscgen.el
+++ b/elpa/org-plus-contrib-20170407/ob-mscgen.el
@@ -1,6 +1,6 @@
-;;; ob-msc.el --- org-babel functions for mscgen evaluation
+;;; ob-msc.el --- Babel Functions for Mscgen         -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2010-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2017 Free Software Foundation, Inc.
 
 ;; Author: Juan Pechiar
 ;; Keywords: literate programming, reproducible research
@@ -65,15 +65,15 @@
 This function is called by `org-babel-execute-src-block'.
 Default filetype is png.  Modify by setting :filetype parameter to
 mscgen supported formats."
-  (let* ((out-file (or (cdr (assoc :file params)) "output.png" ))
-         (filetype (or (cdr (assoc :filetype params)) "png" )))
-    (unless (cdr (assoc :file params))
+  (let* ((out-file (or (cdr (assq :file params)) "output.png" ))
+         (filetype (or (cdr (assq :filetype params)) "png" )))
+    (unless (cdr (assq :file params))
       (error "
 ERROR: no output file specified.  Add \":file name.png\" to the src header"))
     (org-babel-eval (concat "mscgen -T " filetype " -o " out-file) body)
     nil)) ;; signal that output has already been written to file
 
-(defun org-babel-prep-session:mscgen (session params)
+(defun org-babel-prep-session:mscgen (_session _params)
   "Raise an error because Mscgen doesn't support sessions."
   (error "Mscgen does not support sessions"))
 
diff --git a/elpa/org-plus-contrib-20150831/ob-ocaml.el b/elpa/org-plus-contrib-20170407/ob-ocaml.el
similarity index 79%
rename from elpa/org-plus-contrib-20150831/ob-ocaml.el
rename to elpa/org-plus-contrib-20170407/ob-ocaml.el
index 9cd72b37..7997ff03 100644
--- a/elpa/org-plus-contrib-20150831/ob-ocaml.el
+++ b/elpa/org-plus-contrib-20170407/ob-ocaml.el
@@ -1,6 +1,6 @@
-;;; ob-ocaml.el --- org-babel functions for ocaml evaluation
+;;; ob-ocaml.el --- Babel Functions for Ocaml        -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2009-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2017 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
@@ -37,11 +37,11 @@
 ;;; Code:
 (require 'ob)
 (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" ())
+(declare-function org-trim "org" (s &optional keep-lead))
 
 (defvar org-babel-tangle-lang-exts)
 (add-to-list 'org-babel-tangle-lang-exts '("ocaml" . "ml"))
@@ -60,14 +60,13 @@
 
 (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)))
-         (full-body (org-babel-expand-body:generic
+  (let* ((full-body (org-babel-expand-body:generic
 		     body params
 		     (org-babel-variable-assignments:ocaml params)))
          (session (org-babel-prep-session:ocaml
-		   (cdr (assoc :session params)) params))
+		   (cdr (assq :session params)) params))
          (raw (org-babel-comint-with-output
-		  (session org-babel-ocaml-eoe-output t full-body)
+		  (session org-babel-ocaml-eoe-output nil full-body)
 		(insert
 		 (concat
 		  (org-babel-chomp full-body) ";;\n"
@@ -80,32 +79,31 @@
 					 (progn (setq out nil) line)
 				       (when (string-match re line)
 					 (progn (setq out t) nil))))
-				   (mapcar #'org-babel-trim (reverse raw)))))))
-	 (raw (org-babel-trim clean))
-	 (result-params (cdr (assoc :result-params params)))
-	 (parsed 
-	  (string-match 
-	   "\\(\\(.*\n\\)*\\)[^:\n]+ : \\([^=\n]+\\) =\\(\n\\| \\)\\(.+\\)$" 
+				   (mapcar #'org-trim (reverse raw)))))))
+	 (raw (org-trim clean))
+	 (result-params (cdr (assq :result-params params))))
+    (string-match
+     "\\(\\(.*\n\\)*\\)[^:\n]+ : \\([^=\n]+\\) =\\(\n\\| \\)\\(.+\\)$"
+     raw)
+    (let ((output (match-string 1 raw))
+	  (type (match-string 3 raw))
+	  (value (match-string 5 raw)))
+      (org-babel-reassemble-table
+       (org-babel-result-cond result-params
+	 (cond
+	  ((member "verbatim" result-params) raw)
+	  ((member "output" result-params) output)
+	  (t raw))
+	 (if (and value type)
+	     (org-babel-ocaml-parse-output value type)
 	   raw))
-	 (output (match-string 1 raw))
-	 (type (match-string 3 raw))
-	 (value (match-string 5 raw)))
-    (org-babel-reassemble-table
-     (org-babel-result-cond result-params
-       (cond
-	((member "verbatim" result-params) raw)
-	((member "output" result-params) output)
-	(t raw))
-       (if (and value type)
-	   (org-babel-ocaml-parse-output value type)
-	 raw))
-     (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-pick-name
+	(cdr (assq :colname-names params)) (cdr (assq :colnames params)))
+       (org-babel-pick-name
+	(cdr (assq :rowname-names params)) (cdr (assq :rownames params)))))))
 
 (defvar tuareg-interactive-buffer-name)
-(defun org-babel-prep-session:ocaml (session params)
+(defun org-babel-prep-session:ocaml (session _params)
   "Prepare SESSION according to the header arguments in PARAMS."
   (require 'tuareg)
   (let ((tuareg-interactive-buffer-name (if (and (not (string= session "none"))
@@ -123,7 +121,7 @@
   (mapcar
    (lambda (pair) (format "let %s = %s;;" (car pair)
 			  (org-babel-ocaml-elisp-to-ocaml (cdr pair))))
-   (mapcar #'cdr (org-babel-get-header params :var))))
+   (org-babel--get-vars params)))
 
 (defun org-babel-ocaml-elisp-to-ocaml (val)
   "Return a string of ocaml code which evaluates to VAL."
diff --git a/elpa/org-plus-contrib-20150831/ob-octave.el b/elpa/org-plus-contrib-20170407/ob-octave.el
similarity index 82%
rename from elpa/org-plus-contrib-20150831/ob-octave.el
rename to elpa/org-plus-contrib-20170407/ob-octave.el
index 094b32c9..90735b11 100644
--- a/elpa/org-plus-contrib-20150831/ob-octave.el
+++ b/elpa/org-plus-contrib-20170407/ob-octave.el
@@ -1,6 +1,6 @@
-;;; ob-octave.el --- org-babel functions for octave and matlab evaluation
+;;; ob-octave.el --- Babel Functions for Octave and Matlab -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2010-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2017 Free Software Foundation, Inc.
 
 ;; Author: Dan Davison
 ;; Keywords: literate programming, reproducible research
@@ -30,10 +30,10 @@
 
 ;;; Code:
 (require 'ob)
-(eval-when-compile (require 'cl))
 
 (declare-function matlab-shell "ext:matlab-mode")
 (declare-function matlab-shell-run-region "ext:matlab-mode")
+(declare-function org-trim "org" (s &optional keep-lead))
 
 (defvar org-babel-default-header-args:matlab '())
 (defvar org-babel-default-header-args:octave '())
@@ -61,7 +61,7 @@ if ischar(ans), fid = fopen('%s', 'w'); fprintf(fid, '%%s\\n', ans); fclose(fid)
 else, dlmwrite('%s', ans, '\\t')
 end")
 
-(defvar org-babel-octave-eoe-indicator "\'org_babel_eoe\'")
+(defvar org-babel-octave-eoe-indicator "'org_babel_eoe'")
 
 (defvar org-babel-octave-eoe-output "ans = org_babel_eoe")
 
@@ -74,11 +74,8 @@ end")
   (let* ((session
 	  (funcall (intern (format "org-babel-%s-initiate-session"
 				   (if matlabp "matlab" "octave")))
-		   (cdr (assoc :session params)) params))
-         (vars (mapcar #'cdr (org-babel-get-header params :var)))
-         (result-params (cdr (assoc :result-params params)))
-         (result-type (cdr (assoc :result-type params)))
-	 (out-file (cdr (assoc :file params)))
+		   (cdr (assq :session params)) params))
+         (result-type (cdr (assq :result-type params)))
 	 (full-body
 	  (org-babel-expand-body:generic
 	   body params (org-babel-variable-assignments:octave params)))
@@ -99,9 +96,9 @@ end")
       (org-babel-reassemble-table
        result
        (org-babel-pick-name
-	(cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
+	(cdr (assq :colname-names params)) (cdr (assq :colnames params)))
        (org-babel-pick-name
-	(cdr (assoc :rowname-names params)) (cdr (assoc :rownames params)))))))
+	(cdr (assq :rowname-names params)) (cdr (assq :rownames params)))))))
 
 (defun org-babel-prep-session:matlab (session params)
   "Prepare SESSION according to PARAMS."
@@ -114,7 +111,7 @@ end")
      (format "%s=%s;"
 	     (car pair)
 	     (org-babel-octave-var-to-octave (cdr pair))))
-   (mapcar #'cdr (org-babel-get-header params :var))))
+   (org-babel--get-vars params)))
 
 (defalias 'org-babel-variable-assignments:matlab
   'org-babel-variable-assignments:octave)
@@ -128,7 +125,7 @@ specifying a variable of the same value."
 			     (if (listp (car var)) "; " ",")) "]")
     (cond
      ((stringp var)
-      (format "\'%s\'" var))
+      (format "'%s'" var))
      (t
       (format "%s" var)))))
 
@@ -148,7 +145,7 @@ If there is not a current inferior-process-buffer in SESSION then
 create.  Return the initialized session."
   (org-babel-octave-initiate-session session params 'matlab))
 
-(defun org-babel-octave-initiate-session (&optional session params matlabp)
+(defun org-babel-octave-initiate-session (&optional session _params matlabp)
   "Create an octave inferior process buffer.
 If there is not a current inferior-process-buffer in SESSION then
 create.  Return the initialized session."
@@ -168,8 +165,8 @@ create.  Return the initialized session."
 (defun org-babel-octave-evaluate
   (session body result-type &optional matlabp)
   "Pass BODY to the octave process in SESSION.
-If RESULT-TYPE equals 'output then return the outputs of the
-statements in BODY, if RESULT-TYPE equals 'value then return the
+If RESULT-TYPE equals `output' then return the outputs of the
+statements in BODY, if RESULT-TYPE equals `value' then return the
 value of the last statement in BODY, as elisp."
   (if session
       (org-babel-octave-evaluate-session session body result-type matlabp)
@@ -180,9 +177,9 @@ value of the last statement in BODY, as elisp."
   (let ((cmd (if matlabp
 		 org-babel-matlab-shell-command
 	       org-babel-octave-shell-command)))
-    (case result-type
-      (output (org-babel-eval cmd body))
-      (value (let ((tmp-file (org-babel-temp-file "octave-")))
+    (pcase result-type
+      (`output (org-babel-eval cmd body))
+      (`value (let ((tmp-file (org-babel-temp-file "octave-")))
 	       (org-babel-eval
 		cmd
 		(format org-babel-octave-wrapper-method body
@@ -191,17 +188,17 @@ value of the last statement in BODY, as elisp."
 	       (org-babel-octave-import-elisp-from-file tmp-file))))))
 
 (defun org-babel-octave-evaluate-session
-  (session body result-type &optional matlabp)
+    (session body result-type &optional matlabp)
   "Evaluate BODY in SESSION."
   (let* ((tmp-file (org-babel-temp-file (if matlabp "matlab-" "octave-")))
 	 (wait-file (org-babel-temp-file "matlab-emacs-link-wait-signal-"))
 	 (full-body
-	  (case result-type
-	    (output
+	  (pcase result-type
+	    (`output
 	     (mapconcat
 	      #'org-babel-chomp
 	      (list body org-babel-octave-eoe-indicator) "\n"))
-	    (value
+	    (`value
 	     (if (and matlabp org-babel-matlab-with-emacs-link)
 		 (concat
 		  (format org-babel-matlab-emacs-link-wrapper-method
@@ -234,21 +231,20 @@ value of the last statement in BODY, as elisp."
 		       org-babel-octave-eoe-output)
 		     t full-body)
 		  (insert full-body) (comint-send-input nil t)))) results)
-    (case result-type
-      (value
+    (pcase result-type
+      (`value
        (org-babel-octave-import-elisp-from-file tmp-file))
-      (output
-       (progn
-	 (setq results
-	       (if matlabp
-		   (cdr (reverse (delq "" (mapcar
-					   #'org-babel-octave-read-string
-					   (mapcar #'org-babel-trim raw)))))
-		 (cdr (member org-babel-octave-eoe-output
-			      (reverse (mapcar
-					#'org-babel-octave-read-string
-					(mapcar #'org-babel-trim raw)))))))
-	 (mapconcat #'identity (reverse results) "\n"))))))
+      (`output
+       (setq results
+	     (if matlabp
+		 (cdr (reverse (delq "" (mapcar
+					 #'org-babel-strip-quotes
+					 (mapcar #'org-trim raw)))))
+	       (cdr (member org-babel-octave-eoe-output
+			    (reverse (mapcar
+				      #'org-babel-strip-quotes
+				      (mapcar #'org-trim raw)))))))
+       (mapconcat #'identity (reverse results) "\n")))))
 
 (defun org-babel-octave-import-elisp-from-file (file-name)
   "Import data from FILE-NAME.
@@ -263,12 +259,6 @@ This removes initial blank and comment lines and then calls
 	  (delete-region beg end)))
     (org-babel-import-elisp-from-file temp-file '(16))))
 
-(defun org-babel-octave-read-string (string)
-  "Strip \\\"s from around octave string."
-  (if (string-match "^\"\\([^\000]+\\)\"$" string)
-      (match-string 1 string)
-    string))
-
 (provide 'ob-octave)
 
 
diff --git a/elpa/org-plus-contrib-20150831/ob-org.el b/elpa/org-plus-contrib-20170407/ob-org.el
similarity index 87%
rename from elpa/org-plus-contrib-20150831/ob-org.el
rename to elpa/org-plus-contrib-20170407/ob-org.el
index ab0db676..5683b96f 100644
--- a/elpa/org-plus-contrib-20150831/ob-org.el
+++ b/elpa/org-plus-contrib-20170407/ob-org.el
@@ -1,6 +1,6 @@
-;;; ob-org.el --- org-babel functions for org code block evaluation
+;;; ob-org.el --- Babel Functions for Org Code Blocks -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2010-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2017 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
@@ -41,7 +41,7 @@
   "Default header inserted during export of org blocks.")
 
 (defun org-babel-expand-body:org (body params)
-  (dolist (var (mapcar #'cdr (org-babel-get-header params :var)))
+  (dolist (var (org-babel--get-vars params))
     (setq body (replace-regexp-in-string
 		(regexp-quote (format "$%s" (car var)))
 		(format "%s" (cdr var))
@@ -51,7 +51,7 @@
 (defun org-babel-execute:org (body params)
   "Execute a block of Org code with.
 This function is called by `org-babel-execute-src-block'."
-  (let ((result-params (split-string (or (cdr (assoc :results params)) "")))
+  (let ((result-params (split-string (or (cdr (assq :results params)) "")))
 	(body (org-babel-expand-body:org
 	       (replace-regexp-in-string "^," "" body) params)))
     (cond
@@ -61,7 +61,7 @@ This function is called by `org-babel-execute-src-block'."
      ((member "ascii" result-params) (org-export-string-as body 'ascii t))
      (t body))))
 
-(defun org-babel-prep-session:org (session params)
+(defun org-babel-prep-session:org (_session _params)
   "Return an error because org does not support sessions."
   (error "Org does not support sessions"))
 
diff --git a/elpa/org-plus-contrib-20150831/ob-oz.el b/elpa/org-plus-contrib-20170407/ob-oz.el
similarity index 97%
rename from elpa/org-plus-contrib-20150831/ob-oz.el
rename to elpa/org-plus-contrib-20170407/ob-oz.el
index fc778f5c..9beadeb0 100644
--- a/elpa/org-plus-contrib-20150831/ob-oz.el
+++ b/elpa/org-plus-contrib-20170407/ob-oz.el
@@ -197,7 +197,7 @@ StartOzServer.oz is located.")
     result))
 
 (defun org-babel-expand-body:oz (body params)
-  (let ((vars (mapcar #'cdr (org-babel-get-header params :var))))
+  (let ((vars (org-babel--get-vars params)))
     (if vars
 	;; prepend code to define all arguments passed to the code block
 	(let ((var-string (mapcar (lambda (pair)
@@ -214,7 +214,7 @@ StartOzServer.oz is located.")
 (defun org-babel-execute:oz (body params)
   "Execute a block of Oz code with org-babel.  This function is
 called by `org-babel-execute-src-block' via multiple-value-bind."
-  (let* ((result-params (cdr (assoc :result-params params)))
+  (let* ((result-params (cdr (assq :result-params params)))
 	 (full-body (org-babel-expand-body:oz body params))
 	 (wait-time (plist-get params :wait-time)))
     ;; actually execute the source-code block
@@ -227,10 +227,10 @@ called by `org-babel-execute-src-block' via multiple-value-bind."
        (message "Org-babel: executing Oz expression")
        (oz-send-string-expression full-body (or wait-time 1)))
       (t (error "either 'output' or 'results' must be members of :results")))
-     (org-babel-pick-name (cdr (assoc :colname-names params))
-			  (cdr (assoc :colnames params)))
-     (org-babel-pick-name (cdr (assoc :roname-names params))
-			  (cdr (assoc :rownames params))))))
+     (org-babel-pick-name (cdr (assq :colname-names params))
+			  (cdr (assq :colnames params)))
+     (org-babel-pick-name (cdr (assq :roname-names params))
+			  (cdr (assq :rownames params))))))
 
 ;; This function should be used to assign any variables in params in
 ;; the context of the session environment.
diff --git a/elpa/org-plus-contrib-20150831/ob-perl.el b/elpa/org-plus-contrib-20170407/ob-perl.el
similarity index 83%
rename from elpa/org-plus-contrib-20150831/ob-perl.el
rename to elpa/org-plus-contrib-20170407/ob-perl.el
index d27c18ee..62df8c55 100644
--- a/elpa/org-plus-contrib-20150831/ob-perl.el
+++ b/elpa/org-plus-contrib-20170407/ob-perl.el
@@ -1,6 +1,6 @@
-;;; ob-perl.el --- org-babel functions for perl evaluation
+;;; ob-perl.el --- Babel Functions for Perl          -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2009-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2017 Free Software Foundation, Inc.
 
 ;; Authors: Dan Davison
 ;;	 Eric Schulte
@@ -28,7 +28,6 @@
 
 ;;; Code:
 (require 'ob)
-(eval-when-compile (require 'cl))
 
 (defvar org-babel-tangle-lang-exts)
 (add-to-list 'org-babel-tangle-lang-exts '("perl" . "pl"))
@@ -41,20 +40,20 @@
 (defun org-babel-execute:perl (body params)
   "Execute a block of Perl code with Babel.
 This function is called by `org-babel-execute-src-block'."
-  (let* ((session (cdr (assoc :session params)))
-         (result-params (cdr (assoc :result-params params)))
-         (result-type (cdr (assoc :result-type params)))
+  (let* ((session (cdr (assq :session params)))
+         (result-params (cdr (assq :result-params params)))
+         (result-type (cdr (assq :result-type params)))
          (full-body (org-babel-expand-body:generic
 		     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 result-params)
      (org-babel-pick-name
-      (cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
+      (cdr (assq :colname-names params)) (cdr (assq :colnames params)))
      (org-babel-pick-name
-      (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params))))))
+      (cdr (assq :rowname-names params)) (cdr (assq :rownames params))))))
 
-(defun org-babel-prep-session:perl (session params)
+(defun org-babel-prep-session:perl (_session _params)
   "Prepare SESSION according to the header arguments in PARAMS."
   (error "Sessions are not supported for Perl"))
 
@@ -63,7 +62,7 @@ This function is called by `org-babel-execute-src-block'."
   (mapcar
    (lambda (pair)
      (org-babel-perl--var-to-perl (cdr pair) (car pair)))
-   (mapcar #'cdr (org-babel-get-header params :var))))
+   (org-babel--get-vars params)))
 
 ;; helper functions
 
@@ -76,7 +75,7 @@ This function is called by `org-babel-execute-src-block'."
 The elisp value, VAR, is converted to a string of perl source code
 specifying a var of the same value."
   (if varn
-      (let ((org-babel-perl--lvl 0) (lvar (listp var)) prefix)
+      (let ((org-babel-perl--lvl 0) (lvar (listp var)))
 	(concat "my $" (symbol-name varn) "=" (when lvar "\n")
 		(org-babel-perl--var-to-perl var)
 		";\n"))
@@ -92,7 +91,7 @@ specifying a var of the same value."
 
 (defvar org-babel-perl-buffers '(:default . nil))
 
-(defun org-babel-perl-initiate-session (&optional session params)
+(defun org-babel-perl-initiate-session (&optional _session _params)
   "Return nil because sessions are not supported by perl."
   nil)
 
@@ -127,8 +126,8 @@ specifying a var of the same value."
 
 (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
+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"))
   (let* ((body (concat org-babel-perl-preface ibody))
@@ -136,13 +135,13 @@ return the value of the last statement in BODY, as elisp."
 	 (tmp-babel-file (org-babel-process-file-name
 			  tmp-file 'noquote)))
     (let ((results
-           (case result-type
-             (output
+           (pcase result-type
+             (`output
               (with-temp-file tmp-file
                 (insert
                  (org-babel-eval org-babel-perl-command body))
                 (buffer-string)))
-             (value
+             (`value
               (org-babel-eval org-babel-perl-command
                               (format org-babel-perl-wrapper-method
                                       body tmp-babel-file))))))
diff --git a/elpa/org-plus-contrib-20150831/ob-picolisp.el b/elpa/org-plus-contrib-20170407/ob-picolisp.el
similarity index 94%
rename from elpa/org-plus-contrib-20150831/ob-picolisp.el
rename to elpa/org-plus-contrib-20170407/ob-picolisp.el
index 5b696f1b..f5773815 100644
--- a/elpa/org-plus-contrib-20150831/ob-picolisp.el
+++ b/elpa/org-plus-contrib-20170407/ob-picolisp.el
@@ -1,6 +1,6 @@
-;;; ob-picolisp.el --- org-babel functions for picolisp evaluation
+;;; ob-picolisp.el --- Babel Functions for Picolisp  -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2010-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2017 Free Software Foundation, Inc.
 
 ;; Authors: Thorsten Jolitz
 ;;	 Eric Schulte
@@ -55,7 +55,6 @@
 ;;; Code:
 (require 'ob)
 (require 'comint)
-(eval-when-compile (require 'cl))
 
 (declare-function run-picolisp "ext:inferior-picolisp" (cmd))
 (defvar org-babel-tangle-lang-exts) ;; Autoloaded
@@ -80,9 +79,9 @@
 
 (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)))
-        (print-level nil) (print-length nil))
+  (let ((vars (org-babel--get-vars params))
+        (print-level nil)
+	(print-length nil))
     (if (> (length vars) 0)
         (concat "(prog (let ("
                 (mapconcat
@@ -100,12 +99,11 @@
   (message "executing Picolisp source code block")
   (let* (
 	 ;; Name of the session or "none".
-	 (session-name (cdr (assoc :session params)))
+	 (session-name (cdr (assq :session params)))
 	 ;; 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.
-	 (result-type (cdr (assoc :result-type params)))
-	 (result-params (cdr (assoc :result-params params)))
+	 (result-params (cdr (assq :result-params params)))
 	 ;; 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.
diff --git a/elpa/org-plus-contrib-20150831/ob-plantuml.el b/elpa/org-plus-contrib-20170407/ob-plantuml.el
similarity index 55%
rename from elpa/org-plus-contrib-20150831/ob-plantuml.el
rename to elpa/org-plus-contrib-20170407/ob-plantuml.el
index f0f72209..70c8d787 100644
--- a/elpa/org-plus-contrib-20150831/ob-plantuml.el
+++ b/elpa/org-plus-contrib-20170407/ob-plantuml.el
@@ -1,6 +1,6 @@
-;;; ob-plantuml.el --- org-babel functions for plantuml evaluation
+;;; ob-plantuml.el --- Babel Functions for Plantuml  -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2010-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2017 Free Software Foundation, Inc.
 
 ;; Author: Zhang Weize
 ;; Keywords: literate programming, reproducible research
@@ -46,35 +46,76 @@
   :version "24.1"
   :type 'string)
 
+(defun org-babel-variable-assignments:plantuml (params)
+  "Return a list of PlantUML statements assigning the block's variables.
+PARAMS is a property list of source block parameters, which may
+contain multiple entries for the key `:var'.  `:var' entries in PARAMS
+are expected to be scalar variables."
+  (mapcar
+   (lambda (pair)
+       (format "!define %s %s"
+	       (car pair)
+	       (replace-regexp-in-string "\"" "" (cdr pair))))
+   (org-babel--get-vars params)))
+
+(defun org-babel-plantuml-make-body (body params)
+  "Return PlantUML input string.
+BODY is the content of the source block and PARAMS is a property list
+of source block parameters.  This function relies on the
+`org-babel-expand-body:generic' function to extract `:var' entries
+from PARAMS and on the `org-babel-variable-assignments:plantuml'
+function to convert variables to PlantUML assignments."
+  (concat
+   "@startuml\n"
+   (org-babel-expand-body:generic
+    body params (org-babel-variable-assignments:plantuml params))
+   "\n@enduml"))
+
 (defun org-babel-execute:plantuml (body params)
   "Execute a block of plantuml 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 (or (cdr (assoc :file params))
+  (let* ((out-file (or (cdr (assq :file params))
 		       (error "PlantUML requires a \":file\" header argument")))
-	 (cmdline (cdr (assoc :cmdline params)))
+	 (cmdline (cdr (assq :cmdline params)))
 	 (in-file (org-babel-temp-file "plantuml-"))
-	 (java (or (cdr (assoc :java params)) ""))
+	 (java (or (cdr (assq :java params)) ""))
+	 (full-body (org-babel-plantuml-make-body body params))
 	 (cmd (if (string= "" org-plantuml-jar-path)
 		  (error "`org-plantuml-jar-path' is not set")
 		(concat "java " java " -jar "
 			(shell-quote-argument
 			 (expand-file-name org-plantuml-jar-path))
+			(if (string= (file-name-extension out-file) "png")
+			    " -tpng" "")
 			(if (string= (file-name-extension out-file) "svg")
 			    " -tsvg" "")
 			(if (string= (file-name-extension out-file) "eps")
 			    " -teps" "")
+			(if (string= (file-name-extension out-file) "pdf")
+			    " -tpdf" "")
+			(if (string= (file-name-extension out-file) "vdx")
+			    " -tvdx" "")
+			(if (string= (file-name-extension out-file) "xmi")
+			    " -txmi" "")
+			(if (string= (file-name-extension out-file) "scxml")
+			    " -tscxml" "")
+			(if (string= (file-name-extension out-file) "html")
+			    " -thtml" "")
+			(if (string= (file-name-extension out-file) "txt")
+			    " -ttxt" "")
+			(if (string= (file-name-extension out-file) "utxt")
+			    " -utxt" "")
 			" -p " cmdline " < "
 			(org-babel-process-file-name in-file)
 			" > "
 			(org-babel-process-file-name out-file)))))
     (unless (file-exists-p org-plantuml-jar-path)
       (error "Could not find plantuml.jar at %s" org-plantuml-jar-path))
-    (with-temp-file in-file (insert (concat "@startuml\n" body "\n@enduml")))
+    (with-temp-file in-file (insert full-body))
     (message "%s" cmd) (org-babel-eval cmd "")
     nil)) ;; signal that output has already been written to file
 
-(defun org-babel-prep-session:plantuml (session params)
+(defun org-babel-prep-session:plantuml (_session _params)
   "Return an error because plantuml does not support sessions."
   (error "Plantuml does not support sessions"))
 
diff --git a/elpa/org-plus-contrib-20150831/ob-processing.el b/elpa/org-plus-contrib-20170407/ob-processing.el
similarity index 90%
rename from elpa/org-plus-contrib-20150831/ob-processing.el
rename to elpa/org-plus-contrib-20170407/ob-processing.el
index d983afea..a18a53cb 100644
--- a/elpa/org-plus-contrib-20150831/ob-processing.el
+++ b/elpa/org-plus-contrib-20170407/ob-processing.el
@@ -1,6 +1,6 @@
-;;; ob-processing.el --- Babel functions for evaluation of processing
+;;; ob-processing.el --- Babel functions for processing -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2015 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2017 Free Software Foundation, Inc.
 
 ;; Author: Jarmo Hurri (adapted from ob-asymptote.el written by Eric Schulte)
 ;; Keywords: literate programming, reproducible research
@@ -52,7 +52,6 @@
 ;;; Code:
 (require 'ob)
 (require 'sha1)
-(eval-when-compile (require 'cl))
 
 (declare-function processing-sketch-run "ext:processing-mode" ())
 
@@ -96,7 +95,7 @@
 			(progn
 			  (setq sketch-dir-candidate
 				(make-temp-file "processing" t))
-			  (when (org-string-match-p
+			  (when (string-match-p
 				 "-"
 				 (file-name-nondirectory sketch-dir-candidate))
 			    (delete-directory sketch-dir-candidate)
@@ -134,7 +133,7 @@ This function is called by `org-babel-execute-src-block'."
 	      sketch-canvas-id
 	      "\">"))))
 
-(defun org-babel-prep-session:processing (session params)
+(defun org-babel-prep-session:processing (_session _params)
   "Return an error if the :session header argument is set.
 Processing does not support sessions"
   (error "Processing does not support sessions"))
@@ -142,7 +141,7 @@ Processing does not support sessions"
 (defun org-babel-variable-assignments:processing (params)
   "Return list of processing statements assigning the block's variables."
   (mapcar #'org-babel-processing-var-to-processing
-	  (mapcar #'cdr (org-babel-get-header params :var))))
+	  (org-babel--get-vars params)))
 
 (defun org-babel-processing-var-to-processing (pair)
   "Convert an elisp value into a Processing variable.
@@ -179,17 +178,16 @@ a variable of the same value."
 
 DATA is a list.  Return type as a symbol.
 
-The type is `String' if any element in DATA is
-a string.  Otherwise, it is either `float', if some elements are
-floats, or `int'."
-  (let* ((type 'int)
-	 find-type			; For byte-compiler.
-	 (find-type
-	  (lambda (row)
-	    (dolist (e row type)
-	      (cond ((listp e) (setq type (funcall find-type e)))
-		    ((stringp e) (throw 'exit 'String))
-		    ((floatp e) (setq type 'float)))))))
+The type is `String' if any element in DATA is a string.
+Otherwise, it is either `float', if some elements are floats, or
+`int'."
+  (letrec ((type 'int)
+	   (find-type
+	    (lambda (row)
+	      (dolist (e row type)
+		(cond ((listp e) (setq type (funcall find-type e)))
+		      ((stringp e) (throw 'exit 'String))
+		      ((floatp e) (setq type 'float)))))))
     (catch 'exit (funcall find-type data))))
 
 (provide 'ob-processing)
diff --git a/elpa/org-plus-contrib-20150831/ob-python.el b/elpa/org-plus-contrib-20170407/ob-python.el
similarity index 79%
rename from elpa/org-plus-contrib-20150831/ob-python.el
rename to elpa/org-plus-contrib-20170407/ob-python.el
index dd3cc663..b838a48b 100644
--- a/elpa/org-plus-contrib-20150831/ob-python.el
+++ b/elpa/org-plus-contrib-20170407/ob-python.el
@@ -1,6 +1,6 @@
-;;; ob-python.el --- org-babel functions for python evaluation
+;;; ob-python.el --- Babel Functions for Python      -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2009-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2017 Free Software Foundation, Inc.
 
 ;; Authors: Eric Schulte
 ;;	 Dan Davison
@@ -28,12 +28,12 @@
 
 ;;; Code:
 (require 'ob)
-(eval-when-compile (require 'cl))
 
 (declare-function org-remove-indentation "org" )
+(declare-function org-trim "org" (s &optional keep-lead))
 (declare-function py-shell "ext:python-mode" (&optional argprompt))
 (declare-function py-toggle-shells "ext:python-mode" (arg))
-(declare-function run-python "ext:python" (cmd &optional dedicated show))
+(declare-function run-python "ext:python" (&optional cmd dedicated show))
 
 (defvar org-babel-tangle-lang-exts)
 (add-to-list 'org-babel-tangle-lang-exts '("python" . "py"))
@@ -48,9 +48,9 @@
   :type 'string)
 
 (defcustom org-babel-python-mode
-  (if (or (featurep 'xemacs) (featurep 'python-mode)) 'python-mode 'python)
+  (if (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")
@@ -64,7 +64,7 @@ This will typically be either 'python or 'python-mode."
   :type 'string)
 
 (defcustom org-babel-python-None-to 'hline
-  "Replace 'None' in python tables with this before returning."
+  "Replace `None' in python tables with this before returning."
   :group 'org-babel
   :version "24.4"
   :package-version '(Org . "8.0")
@@ -74,14 +74,14 @@ This will typically be either 'python or 'python-mode."
   "Execute a block of Python code with Babel.
 This function is called by `org-babel-execute-src-block'."
   (let* ((session (org-babel-python-initiate-session
-		   (cdr (assoc :session params))))
-         (result-params (cdr (assoc :result-params params)))
-         (result-type (cdr (assoc :result-type params)))
+		   (cdr (assq :session params))))
+         (result-params (cdr (assq :result-params params)))
+         (result-type (cdr (assq :result-type params)))
 	 (return-val (when (and (eq result-type 'value) (not session))
-		       (cdr (assoc :return params))))
-	 (preamble (cdr (assoc :preamble params)))
+		       (cdr (assq :return params))))
+	 (preamble (cdr (assq :preamble params)))
 	 (org-babel-python-command
-	  (or (cdr (assoc :python params)) org-babel-python-command))
+	  (or (cdr (assq :python params)) org-babel-python-command))
          (full-body
 	  (org-babel-expand-body:generic
 	   (concat body (if return-val (format "\nreturn %s" return-val) ""))
@@ -90,10 +90,10 @@ This function is called by `org-babel-execute-src-block'."
 		  session full-body result-type result-params preamble)))
     (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))))))
+     (org-babel-pick-name (cdr (assq :colname-names params))
+			  (cdr (assq :colnames params)))
+     (org-babel-pick-name (cdr (assq :rowname-names params))
+			  (cdr (assq :rownames params))))))
 
 (defun org-babel-prep-session:python (session params)
   "Prepare SESSION according to the header arguments in PARAMS.
@@ -125,7 +125,7 @@ VARS contains resolved variable references"
      (format "%s=%s"
 	     (car pair)
 	     (org-babel-python-var-to-python (cdr pair))))
-   (mapcar #'cdr (org-babel-get-header params :var))))
+   (org-babel--get-vars params)))
 
 (defun org-babel-python-var-to-python (var)
   "Convert an elisp value to a python variable.
@@ -133,7 +133,7 @@ Convert an elisp value, VAR, into a string of python source code
 specifying a variable of the same value."
   (if (listp var)
       (concat "[" (mapconcat #'org-babel-python-var-to-python var ", ") "]")
-    (if (equal var 'hline)
+    (if (eq var 'hline)
 	org-babel-python-hline-to
       (format
        (if (and (stringp var) (string-match "[\n\r]" var)) "\"\"%S\"\"" "%S")
@@ -145,7 +145,7 @@ If the results look like a list or tuple, then convert them into an
 Emacs-lisp table, otherwise return the results as a string."
   (let ((res (org-babel-script-escape results)))
     (if (listp res)
-        (mapcar (lambda (el) (if (equal el 'None)
+        (mapcar (lambda (el) (if (eq el 'None)
                             org-babel-python-None-to el))
                 res)
       res)))
@@ -216,7 +216,7 @@ then create.  Return the initialized session."
 		  (assq-delete-all session org-babel-python-buffers)))
       session)))
 
-(defun org-babel-python-initiate-session (&optional session params)
+(defun org-babel-python-initiate-session (&optional session _params)
   "Create a session named SESSION according to PARAMS."
   (unless (string= session "none")
     (org-babel-python-session-buffer
@@ -248,42 +248,41 @@ open('%s', 'w').write( pprint.pformat(main()) )")
      body result-type result-params preamble)))
 
 (defun org-babel-python-evaluate-external-process
-  (body &optional result-type result-params preamble)
+    (body &optional result-type result-params preamble)
   "Evaluate BODY in external python process.
-If RESULT-TYPE equals 'output then return standard output as a
-string.  If RESULT-TYPE equals 'value then return the value of the
+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."
   (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))))))
+         (pcase 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-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)))))
+      (org-babel-python-table-or-string (org-trim raw)))))
 
 (defun org-babel-python-evaluate-session
     (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
+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."
   (let* ((send-wait (lambda () (comint-send-input nil t) (sleep-for 0 5)))
 	 (dump-last-value
@@ -304,10 +303,10 @@ last statement in BODY, as elisp."
 			     (split-string body "[\r\n]"))
 		       (funcall send-wait)))
          (results
-          (case result-type
-            (output
+          (pcase result-type
+            (`output
              (mapconcat
-              #'org-babel-trim
+              #'org-trim
               (butlast
                (org-babel-comint-with-output
                    (session org-babel-python-eoe-indicator t body)
@@ -316,7 +315,7 @@ last statement in BODY, as elisp."
                  (insert org-babel-python-eoe-indicator)
                  (funcall send-wait))
                2) "\n"))
-            (value
+            (`value
              (let ((tmp-file (org-babel-temp-file "python-")))
                (org-babel-comint-with-output
                    (session org-babel-python-eoe-indicator nil body)
@@ -334,9 +333,10 @@ last statement in BODY, as elisp."
         (org-babel-python-table-or-string results)))))
 
 (defun org-babel-python-read-string (string)
-  "Strip 's from around Python string."
-  (if (string-match "^'\\([^\000]+\\)'$" string)
-      (match-string 1 string)
+  "Strip \\='s from around Python string."
+  (if (and (string-prefix-p "'" string)
+	   (string-suffix-p "'" string))
+      (substring string 1 -1)
     string))
 
 (provide 'ob-python)
diff --git a/elpa/org-plus-contrib-20150831/ob-ref.el b/elpa/org-plus-contrib-20170407/ob-ref.el
similarity index 62%
rename from elpa/org-plus-contrib-20150831/ob-ref.el
rename to elpa/org-plus-contrib-20170407/ob-ref.el
index b8a921e5..f30f49bf 100644
--- a/elpa/org-plus-contrib-20150831/ob-ref.el
+++ b/elpa/org-plus-contrib-20170407/ob-ref.el
@@ -1,6 +1,6 @@
-;;; ob-ref.el --- org-babel functions for referencing external data
+;;; ob-ref.el --- Babel Functions for Referencing External Data -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2009-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2017 Free Software Foundation, Inc.
 
 ;; Authors: Eric Schulte
 ;;	 Dan Davison
@@ -50,23 +50,20 @@
 
 ;;; Code:
 (require 'ob-core)
-(eval-when-compile
-  (require 'cl))
+(require 'cl-lib)
 
+(declare-function org-babel-lob-get-info "ob-lob" (&optional datum))
+(declare-function org-element-at-point "org-element" ())
+(declare-function org-element-property "org-element" (property element))
+(declare-function org-element-type "org-element" (element))
 (declare-function org-end-of-meta-data "org" (&optional full))
 (declare-function org-find-property "org" (property &optional value))
-(declare-function org-remove-if-not "org" (predicate seq))
-(declare-function org-at-table-p "org" (&optional table-type))
-(declare-function org-count "org" (CL-ITEM CL-SEQ))
-(declare-function org-at-item-p "org-list" ())
-(declare-function org-narrow-to-subtree "org" ())
-(declare-function org-id-find-id-in-file "org-id" (id file &optional markerp))
 (declare-function org-id-find-id-file "org-id" (id))
+(declare-function org-id-find-id-in-file "org-id" (id file &optional markerp))
+(declare-function org-in-commented-heading-p "org" (&optional no-inheritance))
+(declare-function org-narrow-to-subtree "org" ())
 (declare-function org-show-context "org" (&optional key))
-(declare-function org-pop-to-buffer-same-window
-		  "org-compat" (&optional buffer-or-name norecord label))
-(declare-function org-babel-lob-execute "ob-lob" (info))
-(declare-function org-babel-lob-get-info "ob-lob" nil)
+(declare-function org-trim "org" (s &optional keep-lead))
 
 (defvar org-babel-ref-split-regexp
   "[ \f\t\n\r\v]*\\(.+?\\)[ \f\t\n\r\v]*=[ \f\t\n\r\v]*\\(.+\\)[ \f\t\n\r\v]*")
@@ -94,7 +91,8 @@ the variable."
 					org-babel-current-src-block-location)))
 			 (org-babel-read ref))))
 	      (if (equal out ref)
-		  (if (string-match "^\".*\"$" ref)
+		  (if (and (string-prefix-p "\"" ref)
+			   (string-suffix-p "\"" ref))
 		      (read ref)
 		    (org-babel-ref-resolve ref))
 		out))))))
@@ -106,7 +104,7 @@ the variable."
 	     (m (when file (org-id-find-id-in-file id file 'marker))))
 	(when (and file m)
 	  (message "file:%S" file)
-	  (org-pop-to-buffer-same-window (marker-buffer m))
+	  (pop-to-buffer-same-window (marker-buffer m))
 	  (goto-char m)
 	  (move-marker m nil)
 	  (org-show-context)
@@ -121,7 +119,6 @@ the variable."
 		     (point))
      (point-max))))
 
-(defvar org-babel-lob-one-liner-regexp)
 (defvar org-babel-library-of-babel)
 (defun org-babel-ref-resolve (ref)
   "Resolve the reference REF and return its value."
@@ -129,17 +126,17 @@ the variable."
     (with-current-buffer (or org-babel-exp-reference-buffer (current-buffer))
       (save-excursion
 	(let ((case-fold-search t)
-	      type args new-refere new-header-args new-referent result
-	      lob-info split-file split-ref index index-row index-col id)
+	      args new-refere new-header-args new-referent split-file split-ref
+	      index)
 	  ;; if ref is indexed grab the indices -- beware nested indices
 	  (when (and (string-match "\\[\\([^\\[]+\\)\\]$" ref)
 		     (let ((str (substring ref 0 (match-beginning 0))))
-		       (= (org-count ?( str) (org-count ?) str))))
+		       (= (cl-count ?( str) (cl-count ?) str))))
 	    (setq index (match-string 1 ref))
 	    (setq ref (substring ref 0 (match-beginning 0))))
 	  ;; assign any arguments to pass to source block
 	  (when (string-match
-		 "^\\(.+?\\)\\(\\[\\(.*\\)\\]\\|\\(\\)\\)\(\\(.*\\)\)$" ref)
+		 "^\\(.+?\\)\\(\\[\\(.*\\)\\]\\|\\(\\)\\)(\\(.*\\))$" ref)
 	    (setq new-refere      (match-string 1 ref))
 	    (setq new-header-args (match-string 3 ref))
 	    (setq new-referent    (match-string 5 ref))
@@ -154,71 +151,54 @@ the variable."
 	  (when (string-match "^\\(.+\\):\\(.+\\)$" ref)
 	    (setq split-file (match-string 1 ref))
 	    (setq split-ref (match-string 2 ref))
-	    (find-file split-file) (setq ref split-ref))
-	  (save-restriction
-	    (widen)
-	    (goto-char (point-min))
-	    (if (let ((src-rx (org-babel-named-src-block-regexp-for-name ref))
-		      (res-rx (org-babel-named-data-regexp-for-name ref)))
-		  ;; goto ref in the current buffer
-		  (or
-		   ;; check for code blocks
-		   (re-search-forward src-rx nil t)
-		   ;; check for named data
-		   (re-search-forward res-rx nil t)
-		   ;; check for local or global headlines by id
-		   (setq id (org-babel-ref-goto-headline-id ref))
-		   ;; check the Library of Babel
-		   (setq lob-info (cdr (assoc (intern ref)
-					      org-babel-library-of-babel)))))
-		(unless (or lob-info id) (goto-char (match-beginning 0)))
-	      ;; ;; TODO: allow searching for names in other buffers
-	      ;; (setq id-loc (org-id-find ref 'marker)
-	      ;;       buffer (marker-buffer id-loc)
-	      ;;       loc (marker-position id-loc))
-	      ;; (move-marker id-loc nil)
-	      (error "Reference '%s' not found in this buffer" ref))
-	    (cond
-	     (lob-info (setq type 'lob))
-	     (id (setq type 'id))
-	     ((and (looking-at org-babel-src-name-regexp)
-		   (save-excursion
-		     (forward-line 1)
-		     (or (looking-at org-babel-src-block-regexp)
-			 (looking-at org-babel-multi-line-header-regexp))))
-	      (setq type 'source-block))
-	     ((and (looking-at org-babel-src-name-regexp)
-		   (save-excursion
-		     (forward-line 1)
-		     (looking-at org-babel-lob-one-liner-regexp)))
-	      (setq type 'call-line))
-	     (t (while (not (setq type (org-babel-ref-at-ref-p)))
-		  (forward-line 1)
-		  (beginning-of-line)
-		  (if (or (= (point) (point-min)) (= (point) (point-max)))
-		      (error "Reference not found")))))
-	    (let ((params (append args '((:results . "silent")))))
-	      (setq result
-		    (case type
-		      (results-line (org-babel-read-result))
-		      (table        (org-babel-read-table))
-		      (list         (org-babel-read-list))
-		      (file         (org-babel-read-link))
-		      (source-block (org-babel-execute-src-block
-				     nil nil (if org-babel-update-intermediate
-						 nil params)))
-		      (call-line (save-excursion
-				   (forward-line 1)
-				   (org-babel-lob-execute
-				    (org-babel-lob-get-info))))
-		      (lob          (org-babel-execute-src-block
-				     nil lob-info params))
-		      (id           (org-babel-ref-headline-body)))))
-	    (if (symbolp result)
-		(format "%S" result)
-	      (if (and index (listp result))
-		  (org-babel-ref-index-list index result)
-		result))))))))
+	    (find-file split-file)
+	    (setq ref split-ref))
+	  (org-with-wide-buffer
+	   (goto-char (point-min))
+	   (let* ((params (append args '((:results . "silent"))))
+		  (regexp (org-babel-named-data-regexp-for-name ref))
+		  (result
+		   (catch :found
+		     ;; Check for code blocks or named data.
+		     (while (re-search-forward regexp nil t)
+		       ;; Ignore COMMENTed headings and orphaned
+		       ;; affiliated keywords.
+		       (unless (org-in-commented-heading-p)
+			 (let ((e (org-element-at-point)))
+			   (when (equal (org-element-property :name e) ref)
+			     (goto-char
+			      (org-element-property :post-affiliated e))
+			     (pcase (org-element-type e)
+			       (`babel-call
+				(throw :found
+				       (org-babel-execute-src-block
+					nil (org-babel-lob-get-info e) params)))
+			       (`src-block
+				(throw :found
+				       (org-babel-execute-src-block
+					nil nil
+					(and
+					 (not org-babel-update-intermediate)
+					 params))))
+			       ((and (let v (org-babel-read-element e))
+				     (guard v))
+				(throw :found v))
+			       (_ (error "Reference not found")))))))
+		     ;; Check for local or global headlines by ID.
+		     (when (org-babel-ref-goto-headline-id ref)
+		       (throw :found (org-babel-ref-headline-body)))
+		     ;; Check the Library of Babel.
+		     (let ((info (cdr (assq (intern ref)
+					    org-babel-library-of-babel))))
+		       (when info
+			 (throw :found
+				(org-babel-execute-src-block nil info params))))
+		     (error "Reference `%s' not found in this buffer" ref))))
+	     (cond
+	      ((symbolp result) (format "%S" result))
+	      ((and index (listp result))
+	       (org-babel-ref-index-list index result))
+	      (t result)))))))))
 
 (defun org-babel-ref-index-list (index lis)
   "Return the subset of LIS indexed by INDEX.
@@ -234,7 +214,7 @@ returned, or an empty string or \"*\" both of which are
 interpreted to mean the entire range and as such are equivalent
 to \"0:-1\"."
   (if (and (> (length index) 0) (string-match "^\\([^,]*\\),?" index))
-      (let* ((ind-re "\\(\\([-[:digit:]]+\\):\\([-[:digit:]]+\\)\\|\*\\)")
+      (let* ((ind-re "\\(\\([-[:digit:]]+\\):\\([-[:digit:]]+\\)\\|\\*\\)")
 	     (lgth (length lis))
 	     (portion (match-string 1 index))
 	     (remainder (substring index (match-end 0)))
@@ -261,21 +241,9 @@ to \"0:-1\"."
 
 (defun org-babel-ref-split-args (arg-string)
   "Split ARG-STRING into top-level arguments of balanced parenthesis."
-  (mapcar #'org-babel-trim (org-babel-balanced-split arg-string 44)))
+  (mapcar #'org-trim (org-babel-balanced-split arg-string 44)))
 
-(defvar org-bracket-link-regexp)
-(defun org-babel-ref-at-ref-p ()
-  "Return the type of reference located at point.
-Return nil if none of the supported reference types are found.
-Supported reference types are tables and source blocks."
-  (cond ((org-at-table-p) 'table)
-	((org-at-item-p) 'list)
-        ((looking-at "^[ \t]*#\\+BEGIN_SRC") 'source-block)
-        ((looking-at org-bracket-link-regexp) 'file)
-        ((looking-at org-babel-result-regexp) 'results-line)))
 
 (provide 'ob-ref)
 
-
-
 ;;; ob-ref.el ends here
diff --git a/elpa/org-plus-contrib-20150831/ob-ruby.el b/elpa/org-plus-contrib-20170407/ob-ruby.el
similarity index 80%
rename from elpa/org-plus-contrib-20150831/ob-ruby.el
rename to elpa/org-plus-contrib-20170407/ob-ruby.el
index 0ff460ed..d0557835 100644
--- a/elpa/org-plus-contrib-20150831/ob-ruby.el
+++ b/elpa/org-plus-contrib-20170407/ob-ruby.el
@@ -1,6 +1,6 @@
-;;; ob-ruby.el --- org-babel functions for ruby evaluation
+;;; ob-ruby.el --- Babel Functions for Ruby          -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2009-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2017 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
@@ -37,11 +37,14 @@
 
 ;;; Code:
 (require 'ob)
-(eval-when-compile (require 'cl))
 
+(declare-function org-trim "org" (s &optional keep-lead))
 (declare-function run-ruby "ext:inf-ruby" (&optional command name))
 (declare-function xmp "ext:rcodetools" (&optional option))
 
+(defvar inf-ruby-default-implementation)
+(defvar inf-ruby-implementations)
+
 (defvar org-babel-tangle-lang-exts)
 (add-to-list 'org-babel-tangle-lang-exts '("ruby" . "rb"))
 
@@ -68,16 +71,16 @@
   "Execute a block of Ruby code with Babel.
 This function is called by `org-babel-execute-src-block'."
   (let* ((session (org-babel-ruby-initiate-session
-		   (cdr (assoc :session params))))
-         (result-params (cdr (assoc :result-params params)))
-         (result-type (cdr (assoc :result-type params)))
+		   (cdr (assq :session params))))
+         (result-params (cdr (assq :result-params params)))
+         (result-type (cdr (assq :result-type params)))
          (full-body (org-babel-expand-body:generic
 		     body params (org-babel-variable-assignments:ruby params)))
          (result (if (member "xmp" result-params)
 		     (with-temp-buffer
 		       (require 'rcodetools)
 		       (insert full-body)
-		       (xmp (cdr (assoc :xmp-option params)))
+		       (xmp (cdr (assq :xmp-option params)))
 		       (buffer-string))
 		   (org-babel-ruby-evaluate
 		    session full-body result-type result-params))))
@@ -85,10 +88,10 @@ This function is called by `org-babel-execute-src-block'."
      (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))
-			  (cdr (assoc :rownames params))))))
+     (org-babel-pick-name (cdr (assq :colname-names params))
+			  (cdr (assq :colnames params)))
+     (org-babel-pick-name (cdr (assq :rowname-names params))
+			  (cdr (assq :rownames params))))))
 
 (defun org-babel-prep-session:ruby (session params)
   "Prepare SESSION according to the header arguments specified in PARAMS."
@@ -121,7 +124,7 @@ This function is called by `org-babel-execute-src-block'."
      (format "%s=%s"
 	     (car pair)
 	     (org-babel-ruby-var-to-ruby (cdr pair))))
-   (mapcar #'cdr (org-babel-get-header params :var))))
+   (org-babel--get-vars params)))
 
 (defun org-babel-ruby-var-to-ruby (var)
   "Convert VAR into a ruby variable.
@@ -129,7 +132,7 @@ 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 ", ") "]")
-    (if (equal var 'hline)
+    (if (eq var 'hline)
 	org-babel-ruby-hline-to
       (format "%S" var))))
 
@@ -139,23 +142,27 @@ If RESULTS look like a table, then convert them into an
 Emacs-lisp table, otherwise return the results as a string."
   (let ((res (org-babel-script-escape results)))
     (if (listp res)
-        (mapcar (lambda (el) (if (equal el 'nil)
-                            org-babel-ruby-nil-to el))
+        (mapcar (lambda (el) (if (not el)
+				 org-babel-ruby-nil-to el))
                 res)
       res)))
 
-(defun org-babel-ruby-initiate-session (&optional session params)
+(defun org-babel-ruby-initiate-session (&optional session _params)
   "Initiate a ruby session.
 If there is not a current inferior-process-buffer in SESSION
 then create one.  Return the initialized session."
   (unless (string= session "none")
     (require 'inf-ruby)
-    (let ((session-buffer (save-window-excursion
-			    (run-ruby nil session) (current-buffer))))
+    (let* ((cmd (cdr (assoc inf-ruby-default-implementation
+			    inf-ruby-implementations)))
+	   (buffer (get-buffer (format "*%s*" session)))
+	   (session-buffer (or buffer (save-window-excursion
+					(run-ruby cmd session)
+					(current-buffer)))))
       (if (org-babel-comint-buffer-livep session-buffer)
 	  (progn (sit-for .25) session-buffer)
-        (sit-for .5)
-        (org-babel-ruby-initiate-session session)))))
+	(sit-for .5)
+	(org-babel-ruby-initiate-session session)))))
 
 (defvar org-babel-ruby-eoe-indicator ":org_babel_ruby_eoe"
   "String to indicate that evaluation has completed.")
@@ -185,26 +192,26 @@ end
 ")
 
 (defun org-babel-ruby-evaluate
-  (buffer body &optional result-type result-params)
+    (buffer body &optional result-type result-params)
   "Pass BODY to the Ruby process in BUFFER.
-If RESULT-TYPE equals 'output then return a list of the outputs
-of the statements in BODY, if RESULT-TYPE equals 'value then
+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."
   (if (not buffer)
       ;; external process evaluation
-      (case result-type
-	(output (org-babel-eval org-babel-ruby-command body))
-	(value (let ((tmp-file (org-babel-temp-file "ruby-")))
-		 (org-babel-eval
-		  org-babel-ruby-command
-		  (format (if (member "pp" result-params)
-			      org-babel-ruby-pp-wrapper-method
-			    org-babel-ruby-wrapper-method)
-			  body (org-babel-process-file-name tmp-file 'noquote)))
-		 (org-babel-eval-read-file tmp-file))))
+      (pcase result-type
+	(`output (org-babel-eval org-babel-ruby-command body))
+	(`value (let ((tmp-file (org-babel-temp-file "ruby-")))
+		  (org-babel-eval
+		   org-babel-ruby-command
+		   (format (if (member "pp" result-params)
+			       org-babel-ruby-pp-wrapper-method
+			     org-babel-ruby-wrapper-method)
+			   body (org-babel-process-file-name tmp-file 'noquote)))
+		  (org-babel-eval-read-file tmp-file))))
     ;; comint session evaluation
-    (case result-type
-      (output
+    (pcase result-type
+      (`output
        (let ((eoe-string (format "puts \"%s\"" org-babel-ruby-eoe-indicator)))
 	 ;; Force the session to be ready before the actual session
 	 ;; code is run.  There is some problem in comint that will
@@ -220,7 +227,7 @@ return the value of the last statement in BODY, as elisp."
 	  (butlast
 	   (split-string
 	    (mapconcat
-	     #'org-babel-trim
+	     #'org-trim
 	     (org-babel-comint-with-output
 		 (buffer org-babel-ruby-eoe-indicator t body)
 	       (mapc
@@ -231,7 +238,7 @@ return the value of the last statement in BODY, as elisp."
 		      "conf.prompt_mode=_org_prompt_mode;conf.echo=true"
 		      eoe-string)))
 	     "\n") "[\r\n]") 4) "\n")))
-      (value
+      (`value
        (let* ((tmp-file (org-babel-temp-file "ruby-"))
 	      (ppp (or (member "code" result-params)
 		       (member "pp" result-params))))
@@ -254,12 +261,6 @@ return the value of the last statement in BODY, as elisp."
 	   (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."
-  (if (string-match "^\"\\([^\000]+\\)\"$" string)
-      (match-string 1 string)
-    string))
-
 (provide 'ob-ruby)
 
 
diff --git a/elpa/org-plus-contrib-20150831/ob-sass.el b/elpa/org-plus-contrib-20170407/ob-sass.el
similarity index 86%
rename from elpa/org-plus-contrib-20150831/ob-sass.el
rename to elpa/org-plus-contrib-20170407/ob-sass.el
index a39248d7..a9a2a9f0 100644
--- a/elpa/org-plus-contrib-20150831/ob-sass.el
+++ b/elpa/org-plus-contrib-20170407/ob-sass.el
@@ -1,6 +1,6 @@
-;;; ob-sass.el --- org-babel functions for the sass css generation language
+;;; ob-sass.el --- Babel Functions for the Sass CSS generation language -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2009-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2017 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
@@ -45,10 +45,9 @@
 (defun org-babel-execute:sass (body params)
   "Execute a block of Sass code with Babel.
 This function is called by `org-babel-execute-src-block'."
-  (let* ((result-params (split-string (or (cdr (assoc :results params)) "")))
-         (file (cdr (assoc :file params)))
+  (let* ((file (cdr (assq :file params)))
          (out-file (or file (org-babel-temp-file "sass-out-")))
-         (cmdline (cdr (assoc :cmdline params)))
+         (cmdline (cdr (assq :cmdline params)))
          (in-file (org-babel-temp-file "sass-in-"))
          (cmd (concat "sass " (or cmdline "")
 		      " " (org-babel-process-file-name in-file)
@@ -60,7 +59,7 @@ This function is called by `org-babel-execute-src-block'."
 	nil ;; signal that output has already been written to file
       (with-temp-buffer (insert-file-contents out-file) (buffer-string)))))
 
-(defun org-babel-prep-session:sass (session params)
+(defun org-babel-prep-session:sass (_session _params)
   "Raise an error because sass does not support sessions."
   (error "Sass does not support sessions"))
 
diff --git a/elpa/org-plus-contrib-20150831/ob-scala.el b/elpa/org-plus-contrib-20170407/ob-scala.el
similarity index 77%
rename from elpa/org-plus-contrib-20150831/ob-scala.el
rename to elpa/org-plus-contrib-20170407/ob-scala.el
index 656667a7..7d5f299e 100644
--- a/elpa/org-plus-contrib-20150831/ob-scala.el
+++ b/elpa/org-plus-contrib-20170407/ob-scala.el
@@ -1,6 +1,6 @@
-;;; ob-scala.el --- org-babel functions for Scala evaluation
+;;; ob-scala.el --- Babel Functions for Scala        -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2012-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2012-2017 Free Software Foundation, Inc.
 
 ;; Author: Andrzej Lichnerowicz
 ;; Keywords: literate programming, reproducible research
@@ -31,7 +31,6 @@
 
 ;;; Code:
 (require 'ob)
-(eval-when-compile (require 'cl))
 
 (defvar org-babel-tangle-lang-exts) ;; Autoloaded
 (add-to-list 'org-babel-tangle-lang-exts '("scala" . "scala"))
@@ -45,9 +44,8 @@ called by `org-babel-execute-src-block'"
   (message "executing Scala source code block")
   (let* ((processed-params (org-babel-process-params params))
          (session (org-babel-scala-initiate-session (nth 0 processed-params)))
-         (vars (nth 1 processed-params))
          (result-params (nth 2 processed-params))
-         (result-type (cdr (assoc :result-type params)))
+         (result-type (cdr (assq :result-type params)))
          (full-body (org-babel-expand-body:generic
                      body params))
          (result (org-babel-scala-evaluate
@@ -56,9 +54,9 @@ called by `org-babel-execute-src-block'"
     (org-babel-reassemble-table
      result
      (org-babel-pick-name
-      (cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
+      (cdr (assq :colname-names params)) (cdr (assq :colnames params)))
      (org-babel-pick-name
-      (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params))))))
+      (cdr (assq :rowname-names params)) (cdr (assq :rownames params))))))
 
 (defvar org-babel-scala-wrapper-method
 
@@ -76,19 +74,19 @@ print(str_result)
 
 
 (defun org-babel-scala-evaluate
-  (session body &optional result-type result-params)
+    (session body &optional result-type result-params)
   "Evaluate BODY in external Scala process.
-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
+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."
   (when session (error "Sessions are not (yet) supported for Scala"))
-  (case result-type
-    (output
+  (pcase result-type
+    (`output
      (let ((src-file (org-babel-temp-file "scala-")))
-       (progn (with-temp-file src-file (insert body))
-              (org-babel-eval
-               (concat org-babel-scala-command " " src-file) ""))))
-    (value
+       (with-temp-file src-file (insert body))
+       (org-babel-eval
+	(concat org-babel-scala-command " " src-file) "")))
+    (`value
      (let* ((src-file (org-babel-temp-file "scala-"))
             (wrapper (format org-babel-scala-wrapper-method body)))
        (with-temp-file src-file (insert wrapper))
@@ -99,11 +97,11 @@ in BODY as elisp."
            (org-babel-script-escape raw)))))))
 
 
-(defun org-babel-prep-session:scala (session params)
+(defun org-babel-prep-session:scala (_session _params)
   "Prepare SESSION according to the header arguments specified in PARAMS."
   (error "Sessions are not (yet) supported for Scala"))
 
-(defun org-babel-scala-initiate-session (&optional session)
+(defun org-babel-scala-initiate-session (&optional _session)
   "If there is not a current inferior-process-buffer in SESSION
 then create.  Return the initialized session.  Sessions are not
 supported in Scala."
diff --git a/elpa/org-plus-contrib-20150831/ob-scheme.el b/elpa/org-plus-contrib-20170407/ob-scheme.el
similarity index 87%
rename from elpa/org-plus-contrib-20150831/ob-scheme.el
rename to elpa/org-plus-contrib-20170407/ob-scheme.el
index b10dfc34..cd8c3860 100644
--- a/elpa/org-plus-contrib-20150831/ob-scheme.el
+++ b/elpa/org-plus-contrib-20170407/ob-scheme.el
@@ -1,6 +1,6 @@
-;;; ob-scheme.el --- org-babel functions for Scheme
+;;; ob-scheme.el --- Babel Functions for Scheme      -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2010-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2017 Free Software Foundation, Inc.
 
 ;; Authors: Eric Schulte
 ;;	    Michael Gauland
@@ -45,17 +45,18 @@
 (defvar geiser-default-implementation) ; Defined in geiser-impl.el
 (defvar geiser-active-implementations) ; Defined in geiser-impl.el
 
-(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))
+(declare-function run-geiser "ext:geiser-repl" (impl))
+(declare-function geiser-mode "ext:geiser-mode" ())
+(declare-function geiser-eval-region "ext:geiser-mode"
+                  (start end &optional and-go raw nomsg))
+(declare-function geiser-repl-exit "ext:geiser-repl" (&optional arg))
 
 (defvar org-babel-default-header-args:scheme '()
   "Default header arguments for scheme code blocks.")
 
 (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))))
+  (let ((vars (org-babel--get-vars params)))
     (if (> (length vars) 0)
         (concat "(let ("
                 (mapconcat
@@ -109,7 +110,7 @@ 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
+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)
@@ -172,7 +173,7 @@ is true; otherwise returns the last value."
 	(setq result (if (or (string= result "#")
 			     (string= result "#"))
 			 nil
-		       (read result)))))
+		       result))))
     result))
 
 (defun org-babel-execute:scheme (body params)
@@ -184,23 +185,23 @@ This function is called by `org-babel-execute-src-block'"
 			      (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))))
+       (let* ((result-type (cdr (assq :result-type params)))
+	      (impl (or (when (cdr (assq :scheme params))
+			  (intern (cdr (assq :scheme params))))
 			geiser-default-implementation
 			(car geiser-active-implementations)))
 	      (session (org-babel-scheme-make-session-name
-			source-buffer-name (cdr (assoc :session params)) impl))
+			source-buffer-name (cdr (assq :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)))))))
+       (org-babel-pick-name (cdr (assq :colname-names params))
+			    (cdr (assq :colnames params)))
+       (org-babel-pick-name (cdr (assq :rowname-names params))
+			    (cdr (assq :rownames params)))))))
 
 (provide 'ob-scheme)
 
diff --git a/elpa/org-plus-contrib-20150831/ob-screen.el b/elpa/org-plus-contrib-20170407/ob-screen.el
similarity index 88%
rename from elpa/org-plus-contrib-20150831/ob-screen.el
rename to elpa/org-plus-contrib-20170407/ob-screen.el
index 54ae5e1e..554f8c43 100644
--- a/elpa/org-plus-contrib-20150831/ob-screen.el
+++ b/elpa/org-plus-contrib-20170407/ob-screen.el
@@ -1,6 +1,6 @@
-;;; ob-screen.el --- org-babel support for interactive terminal
+;;; ob-screen.el --- Babel Support for Interactive Terminal -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2009-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2017 Free Software Foundation, Inc.
 
 ;; Author: Benjamin Andresen
 ;; Keywords: literate programming, interactive shell
@@ -48,18 +48,17 @@ In case you want to use a different screen than one selected by your $PATH")
 \"default\" session is used when none is specified."
   (message "Sending source code block to interactive terminal session...")
   (save-window-excursion
-    (let* ((session (cdr (assoc :session params)))
+    (let* ((session (cdr (assq :session params)))
            (socket (org-babel-screen-session-socketname session)))
       (unless socket (org-babel-prep-session:screen session params))
       (org-babel-screen-session-execute-string
        session (org-babel-expand-body:generic body params)))))
 
-(defun org-babel-prep-session:screen (session params)
+(defun org-babel-prep-session:screen (_session params)
   "Prepare SESSION according to the header arguments specified in PARAMS."
-  (let* ((session (cdr (assoc :session params)))
-         (socket (org-babel-screen-session-socketname session))
-         (cmd (cdr (assoc :cmd params)))
-         (terminal (cdr (assoc :terminal params)))
+  (let* ((session (cdr (assq :session params)))
+         (cmd (cdr (assq :cmd params)))
+         (terminal (cdr (assq :terminal params)))
          (process-name (concat "org-babel: terminal (" session ")")))
     (apply 'start-process process-name "*Messages*"
            terminal `("-T" ,(concat "org-babel: " session) "-e" ,org-babel-screen-location
@@ -104,7 +103,7 @@ In case you want to use a different screen than one selected by your $PATH")
 			  sockets)))))
     (when match-socket (car (split-string match-socket)))))
 
-(defun org-babel-screen-session-write-temp-file (session body)
+(defun org-babel-screen-session-write-temp-file (_session body)
   "Save BODY in a temp file that is named after SESSION."
   (let ((tmpfile (org-babel-temp-file "screen-")))
     (with-temp-file tmpfile
@@ -119,11 +118,10 @@ In case you want to use a different screen than one selected by your $PATH")
   "Test if the default setup works.
 The terminal should shortly flicker."
   (interactive)
-  (let* ((session "org-babel-testing")
-         (random-string (format "%s" (random 99999)))
+  (let* ((random-string (format "%s" (random 99999)))
          (tmpfile (org-babel-temp-file "ob-screen-test-"))
          (body (concat "echo '" random-string "' > " tmpfile "\nexit\n"))
-         process tmp-string)
+         tmp-string)
     (org-babel-execute:screen body org-babel-default-header-args:screen)
     ;; XXX: need to find a better way to do the following
     (while (not (file-readable-p tmpfile))
diff --git a/elpa/org-plus-contrib-20150831/ob-sed.el b/elpa/org-plus-contrib-20170407/ob-sed.el
similarity index 96%
rename from elpa/org-plus-contrib-20150831/ob-sed.el
rename to elpa/org-plus-contrib-20170407/ob-sed.el
index 9e3db372..733c7e19 100644
--- a/elpa/org-plus-contrib-20150831/ob-sed.el
+++ b/elpa/org-plus-contrib-20170407/ob-sed.el
@@ -1,6 +1,6 @@
-;;; ob-sed.el --- org-babel functions for sed scripts
+;;; ob-sed.el --- Babel Functions for Sed Scripts    -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2015 Free Software Foundation
+;; Copyright (C) 2015-2017 Free Software Foundation, Inc.
 
 ;; Author: Bjarte Johansen
 ;; Keywords: literate programming, reproducible research
diff --git a/elpa/org-plus-contrib-20150831/ob-shell.el b/elpa/org-plus-contrib-20170407/ob-shell.el
similarity index 71%
rename from elpa/org-plus-contrib-20150831/ob-shell.el
rename to elpa/org-plus-contrib-20170407/ob-shell.el
index efa992f2..9c22af83 100644
--- a/elpa/org-plus-contrib-20150831/ob-shell.el
+++ b/elpa/org-plus-contrib-20170407/ob-shell.el
@@ -1,6 +1,6 @@
-;;; ob-shell.el --- org-babel functions for shell evaluation
+;;; ob-shell.el --- Babel Functions for Shell Evaluation -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2009-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2017 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
@@ -28,49 +28,65 @@
 ;;; Code:
 (require 'ob)
 (require 'shell)
-(eval-when-compile (require 'cl))
+(require 'cl-lib)
 
-(declare-function org-babel-comint-in-buffer "ob-comint" (buffer &rest body))
+(declare-function org-babel-comint-in-buffer "ob-comint" (buffer &rest body)
+		  t)
 (declare-function org-babel-comint-wait-for-output "ob-comint" (buffer))
 (declare-function org-babel-comint-buffer-livep "ob-comint" (buffer))
-(declare-function org-babel-comint-with-output "ob-comint" (meta &rest body))
+(declare-function org-babel-comint-with-output "ob-comint" (meta &rest body)
+		  t)
+(declare-function org-trim "org" (s &optional keep-lead))
 (declare-function orgtbl-to-generic "org-table" (table params))
 
 (defvar org-babel-default-header-args:shell '())
+(defvar org-babel-shell-names)
+
+(defun org-babel-shell-initialize ()
+  "Define execution functions associated to shell names.
+This function has to be called whenever `org-babel-shell-names'
+is modified outside the Customize interface."
+  (interactive)
+  (dolist (name org-babel-shell-names)
+    (eval `(defun ,(intern (concat "org-babel-execute:" name))
+	       (body params)
+	     ,(format "Execute a block of %s commands with Babel." name)
+	     (let ((shell-file-name ,name))
+	       (org-babel-execute:shell body params))))
+    (eval `(defalias ',(intern (concat "org-babel-variable-assignments:" name))
+	     'org-babel-variable-assignments:shell
+	     ,(format "Return list of %s statements assigning to the block's \
+variables."
+		      name)))))
 
 (defcustom org-babel-shell-names
   '("sh" "bash" "csh" "ash" "dash" "ksh" "mksh" "posh")
-  "List of names of shell supported by babel shell code blocks."
+  "List of names of shell supported by babel shell code blocks.
+Call `org-babel-shell-initialize' when modifying this variable
+outside the Customize interface."
   :group 'org-babel
-  :type 'string
-  :initialize
-  (lambda (symbol value)
-    (set-default symbol (second value))
-    (mapc
-     (lambda (name)
-       (eval `(defun ,(intern (concat "org-babel-execute:" name)) (body params)
-		,(format "Execute a block of %s commands with Babel." name)
-		(let ((shell-file-name ,name))
-		  (org-babel-execute:shell body params)))))
-     (second value))))
+  :type '(repeat (string :tag "Shell name: "))
+  :set (lambda (symbol value)
+	 (set-default symbol value)
+	 (org-babel-shell-initialize)))
 
 (defun org-babel-execute:shell (body params)
   "Execute a block of Shell commands with Babel.
 This function is called by `org-babel-execute-src-block'."
   (let* ((session (org-babel-sh-initiate-session
-		   (cdr (assoc :session params))))
-	 (stdin (let ((stdin (cdr (assoc :stdin params))))
+		   (cdr (assq :session params))))
+	 (stdin (let ((stdin (cdr (assq :stdin params))))
                   (when stdin (org-babel-sh-var-to-string
                                (org-babel-ref-resolve stdin)))))
-	 (cmdline (cdr (assoc :cmdline params)))
+	 (cmdline (cdr (assq :cmdline params)))
          (full-body (org-babel-expand-body:generic
 		     body params (org-babel-variable-assignments:shell params))))
     (org-babel-reassemble-table
      (org-babel-sh-evaluate session full-body params stdin cmdline)
      (org-babel-pick-name
-      (cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
+      (cdr (assq :colname-names params)) (cdr (assq :colnames params)))
      (org-babel-pick-name
-      (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params))))))
+      (cdr (assq :rowname-names params)) (cdr (assq :rownames params))))))
 
 (defun org-babel-prep-session:shell (session params)
   "Prepare SESSION according to the header arguments specified in PARAMS."
@@ -91,13 +107,14 @@ This function is called by `org-babel-execute-src-block'."
         (insert (org-babel-chomp body)))
       buffer)))
 
-;; helper functions
-(defun org-babel-variable-assignments:sh-generic
+
+;;; Helper functions
+(defun org-babel--variable-assignments:sh-generic
     (varname values &optional sep hline)
   "Returns a list of statements declaring the values as a generic variable."
   (format "%s=%s" varname (org-babel-sh-var-to-sh values sep hline)))
 
-(defun org-babel-variable-assignments:bash_array
+(defun org-babel--variable-assignments:bash_array
     (varname values &optional sep hline)
   "Returns a list of statements declaring the values as a bash array."
   (format "unset %s\ndeclare -a %s=( %s )"
@@ -107,7 +124,7 @@ This function is called by `org-babel-execute-src-block'."
 	   values
 	   " ")))
 
-(defun org-babel-variable-assignments:bash_assoc
+(defun org-babel--variable-assignments:bash_assoc
     (varname values &optional sep hline)
   "Returns a list of statements declaring the values as bash associative array."
   (format "unset %s\ndeclare -A %s\n%s"
@@ -121,28 +138,28 @@ This function is called by `org-babel-execute-src-block'."
      values
      "\n")))
 
-(defun org-babel-variable-assignments:bash (varname values &optional sep hline)
+(defun org-babel--variable-assignments:bash (varname values &optional sep hline)
   "Represents the parameters as useful Bash shell variables."
   (if (listp values)
       (if (and (listp (car values)) (= 1 (length (car values))))
-	  (org-babel-variable-assignments:bash_array varname values sep hline)
-	(org-babel-variable-assignments:bash_assoc varname values sep hline))
-    (org-babel-variable-assignments:sh-generic varname values sep hline)))
+	  (org-babel--variable-assignments:bash_array varname values sep hline)
+	(org-babel--variable-assignments:bash_assoc varname values sep hline))
+    (org-babel--variable-assignments:sh-generic varname values sep hline)))
 
 (defun org-babel-variable-assignments:shell (params)
   "Return list of shell statements assigning the block's variables."
-  (let ((sep (cdr (assoc :separator params)))
-	(hline (when (string= "yes" (cdr (assoc :hlines params)))
-		 (or (cdr (assoc :hline-string params))
+  (let ((sep (cdr (assq :separator params)))
+	(hline (when (string= "yes" (cdr (assq :hlines params)))
+		 (or (cdr (assq :hline-string params))
 		     "hline"))))
     (mapcar
      (lambda (pair)
-       (if (string-match "bash$" shell-file-name)
-	   (org-babel-variable-assignments:bash
+       (if (string-suffix-p "bash" shell-file-name)
+	   (org-babel--variable-assignments:bash
             (car pair) (cdr pair) sep hline)
-         (org-babel-variable-assignments:sh-generic
+         (org-babel--variable-assignments:sh-generic
 	  (car pair) (cdr pair) sep hline)))
-     (mapcar #'cdr (org-babel-get-header params :var)))))
+     (org-babel--get-vars params))))
 
 (defun org-babel-sh-var-to-sh (var &optional sep hline)
   "Convert an elisp value to a shell variable.
@@ -157,14 +174,14 @@ 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) (or (listp (car var)) (equal (car var) 'hline)))
+     ((and (listp var) (or (listp (car var)) (eq (car var) 'hline)))
       (orgtbl-to-generic var  (list :sep (or sep "\t") :fmt echo-var
 				    :hline hline)))
      ((listp var)
       (mapconcat echo-var var "\n"))
      (t (funcall echo-var var)))))
 
-(defun org-babel-sh-initiate-session (&optional session params)
+(defun org-babel-sh-initiate-session (&optional session _params)
   "Initiate a session named SESSION according to PARAMS."
   (when (and session (not (string= session "none")))
     (save-window-excursion
@@ -184,16 +201,16 @@ var of the same value."
 
 (defun org-babel-sh-evaluate (session body &optional params stdin cmdline)
   "Pass BODY to the Shell process in BUFFER.
-If RESULT-TYPE equals 'output then return a list of the outputs
-of the statements in BODY, if RESULT-TYPE equals 'value then
+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."
   (let ((results
          (cond
           ((or stdin cmdline)	       ; 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))))))
+                 (shebang (cdr (assq :shebang params)))
+                 (padline (not (string= "no" (cdr (assq :padline params))))))
              (with-temp-file script-file
                (when shebang (insert (concat shebang "\n")))
                (when padline (insert "\n"))
@@ -212,7 +229,7 @@ return the value of the last statement in BODY."
            (mapconcat
             #'org-babel-sh-strip-weird-long-prompt
             (mapcar
-             #'org-babel-trim
+             #'org-trim
              (butlast
               (org-babel-comint-with-output
                   (session org-babel-sh-eoe-output t body)
@@ -227,24 +244,24 @@ return the value of the last statement in BODY."
                      (accept-process-output
                       (get-buffer-process (current-buffer)))))
                  (append
-                  (split-string (org-babel-trim body) "\n")
+                  (split-string (org-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))
+           (if (and (cdr (assq :shebang params))
+                    (> (length (cdr (assq :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))))))
+                     (shebang (cdr (assq :shebang params)))
+                     (padline (not (equal "no" (cdr (assq :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 shell-file-name (org-babel-trim body)))))))
+             (org-babel-eval shell-file-name (org-trim body)))))))
     (when results
-      (let ((result-params (cdr (assoc :result-params params))))
+      (let ((result-params (cdr (assq :result-params params))))
         (org-babel-result-cond result-params
           results
           (let ((tmp-file (org-babel-temp-file "sh-")))
diff --git a/elpa/org-plus-contrib-20150831/ob-shen.el b/elpa/org-plus-contrib-20170407/ob-shen.el
similarity index 88%
rename from elpa/org-plus-contrib-20150831/ob-shen.el
rename to elpa/org-plus-contrib-20170407/ob-shen.el
index 190d69b7..6bf36c64 100644
--- a/elpa/org-plus-contrib-20150831/ob-shen.el
+++ b/elpa/org-plus-contrib-20170407/ob-shen.el
@@ -1,6 +1,6 @@
-;;; ob-shen.el --- org-babel functions for Shen
+;;; ob-shen.el --- Babel Functions for Shen          -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2010-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2017 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research, shen
@@ -43,7 +43,7 @@
 
 (defun org-babel-expand-body:shen (body params)
   "Expand BODY according to PARAMS, return the expanded body."
-  (let ((vars (mapcar #'cdr (org-babel-get-header params :var))))
+  (let ((vars (org-babel--get-vars params)))
     (if (> (length vars) 0)
         (concat "(let "
                 (mapconcat (lambda (var)
@@ -63,14 +63,13 @@
   "Execute a block of Shen code with org-babel.
 This function is called by `org-babel-execute-src-block'"
   (require 'inf-shen)
-  (let* ((result-type (cdr (assoc :result-type params)))
-	 (result-params (cdr (assoc :result-params params)))
+  (let* ((result-params (cdr (assq :result-params params)))
          (full-body (org-babel-expand-body:shen body params)))
     (let ((results
            (with-temp-buffer
              (insert full-body)
              (call-interactively #'shen-eval-defun))))
-      (org-babel-result-cond result-params 
+      (org-babel-result-cond result-params
         results
         (condition-case nil (org-babel-script-escape results)
           (error results))))))
diff --git a/elpa/org-plus-contrib-20170407/ob-sql.el b/elpa/org-plus-contrib-20170407/ob-sql.el
new file mode 100644
index 00000000..ec0427f4
--- /dev/null
+++ b/elpa/org-plus-contrib-20170407/ob-sql.el
@@ -0,0 +1,332 @@
+;;; ob-sql.el --- Babel Functions for SQL            -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2009-2017 Free Software Foundation, Inc.
+
+;; Author: Eric Schulte
+;; 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 .
+
+;;; Commentary:
+
+;; Org-Babel support for evaluating sql source code.
+;; (see also ob-sqlite.el)
+;;
+;; SQL is somewhat unique in that there are many different engines for
+;; the evaluation of sql (Mysql, PostgreSQL, etc...), so much of this
+;; file will have to be implemented engine by engine.
+;;
+;; Also SQL evaluation generally takes place inside of a database.
+;;
+;; Header args used:
+;; - engine
+;; - cmdline
+;; - dbhost
+;; - dbport
+;; - 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
+;;
+;; Engines supported:
+;; - mysql
+;; - dbi
+;; - mssql
+;; - sqsh
+;; - postgresql
+;; - oracle
+;; - vertica
+;;
+;; TODO:
+;;
+;; - support for sessions
+;; - support for more engines
+;; - what's a reasonable way to drop table data into SQL?
+;;
+
+;;; Code:
+(require 'ob)
+
+(declare-function org-table-import "org-table" (file arg))
+(declare-function orgtbl-to-csv "org-table" (table params))
+(declare-function org-table-to-lisp "org-table" (&optional txt))
+(declare-function cygwin-convert-file-name-to-windows "cygw32.c" (file &optional absolute-p))
+
+(defvar org-babel-default-header-args:sql '())
+
+(defconst org-babel-header-args:sql
+  '((engine	       . :any)
+    (out-file	       . :any)
+    (dbhost	       . :any)
+    (dbport	       . :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 (org-babel--get-vars params)))
+
+(defun org-babel-sql-dbstring-mysql (host port user password database)
+  "Make MySQL cmd line args for database connection.  Pass nil to omit that arg."
+  (combine-and-quote-strings
+   (delq nil
+	 (list (when host     (concat "-h" host))
+	       (when port     (format "-P%d" port))
+	       (when user     (concat "-u" user))
+	       (when password (concat "-p" password))
+	       (when database (concat "-D" database))))))
+
+(defun org-babel-sql-dbstring-postgresql (host port user database)
+  "Make PostgreSQL command line args for database connection.
+Pass nil to omit that arg."
+  (combine-and-quote-strings
+   (delq nil
+	 (list (when host (concat "-h" host))
+	       (when port (format "-p%d" port))
+	       (when user (concat "-U" user))
+	       (when database (concat "-d" database))))))
+
+(defun org-babel-sql-dbstring-oracle (host port user password database)
+  "Make Oracle command line args for database connection."
+  (format "%s/%s@%s:%s/%s" user password host port database))
+
+(defun org-babel-sql-dbstring-mssql (host user password database)
+  "Make sqlcmd commmand line args for database connection.
+`sqlcmd' is the preferred command line tool to access Microsoft
+SQL Server on Windows and Linux platform."
+  (mapconcat #'identity
+	     (delq nil
+		   (list (when host (format "-S \"%s\"" host))
+			 (when user (format "-U \"%s\"" user))
+			 (when password (format "-P \"%s\"" password))
+			 (when database (format "-d \"%s\"" database))))
+	     " "))
+
+(defun org-babel-sql-dbstring-sqsh (host user password database)
+  "Make sqsh commmand line args for database connection.
+\"sqsh\" is one method to access Sybase or MS SQL via Linux platform"
+  (mapconcat #'identity
+             (delq nil
+                   (list  (when host     (format "-S \"%s\"" host))
+                          (when user     (format "-U \"%s\"" user))
+                          (when password (format "-P \"%s\"" password))
+                          (when database (format "-D \"%s\"" database))))
+             " "))
+
+(defun org-babel-sql-dbstring-vertica (host port user password database)
+  "Make Vertica command line args for database connection. Pass nil to omit that arg."
+  (mapconcat #'identity
+	      (delq nil
+		    (list (when host     (format "-h %s" host))
+			  (when port     (format "-p %d" port))
+			  (when user     (format "-U %s" user))
+			  (when password (format "-w %s" (shell-quote-argument password) ))
+			  (when database (format "-d %s" database))))
+	      " "))
+
+(defun org-babel-sql-convert-standard-filename (file)
+  "Convert the file name to OS standard.
+If in Cygwin environment, uses Cygwin specific function to
+convert the file name. Otherwise, uses Emacs' standard conversion
+function."
+  (format "\"%s\""
+	  (if (fboundp 'cygwin-convert-file-name-to-windows)
+	      (cygwin-convert-file-name-to-windows file)
+	    (convert-standard-filename file))))
+
+(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 (assq :result-params params)))
+         (cmdline (cdr (assq :cmdline params)))
+         (dbhost (cdr (assq :dbhost params)))
+         (dbport (cdr (assq :dbport params)))
+         (dbuser (cdr (assq :dbuser params)))
+         (dbpassword (cdr (assq :dbpassword params)))
+         (database (cdr (assq :database params)))
+         (engine (cdr (assq :engine params)))
+         (colnames-p (not (equal "no" (cdr (assq :colnames params)))))
+         (in-file (org-babel-temp-file "sql-in-"))
+         (out-file (or (cdr (assq :out-file params))
+                       (org-babel-temp-file "sql-out-")))
+	 (header-delim "")
+         (command (pcase (intern engine)
+                    (`dbi (format "dbish --batch %s < %s | sed '%s' > %s"
+				  (or cmdline "")
+				  (org-babel-process-file-name in-file)
+				  "/^+/d;s/^|//;s/(NULL)/ /g;$d"
+				  (org-babel-process-file-name out-file)))
+                    (`monetdb (format "mclient -f tab %s < %s > %s"
+				      (or cmdline "")
+				      (org-babel-process-file-name in-file)
+				      (org-babel-process-file-name out-file)))
+		    (`mssql (format "sqlcmd %s -s \"\t\" %s -i %s -o %s"
+				    (or cmdline "")
+				    (org-babel-sql-dbstring-mssql
+				     dbhost dbuser dbpassword database)
+				    (org-babel-sql-convert-standard-filename
+				     (org-babel-process-file-name in-file))
+				    (org-babel-sql-convert-standard-filename
+				     (org-babel-process-file-name out-file))))
+                    (`mysql (format "mysql %s %s %s < %s > %s"
+				    (org-babel-sql-dbstring-mysql
+				     dbhost dbport dbuser dbpassword database)
+				    (if colnames-p "" "-N")
+				    (or cmdline "")
+				    (org-babel-process-file-name in-file)
+				    (org-babel-process-file-name out-file)))
+		    (`postgresql (format
+				  "%spsql --set=\"ON_ERROR_STOP=1\" %s -A -P \
+footer=off -F \"\t\"  %s -f %s -o %s %s"
+				  (if dbpassword
+				      (format "PGPASSWORD=%s " dbpassword)
+				    "")
+				  (if colnames-p "" "-t")
+				  (org-babel-sql-dbstring-postgresql
+				   dbhost dbport dbuser database)
+				  (org-babel-process-file-name in-file)
+				  (org-babel-process-file-name out-file)
+				  (or cmdline "")))
+		    (`sqsh (format "sqsh %s %s -i %s -o %s -m csv"
+				   (or cmdline "")
+				   (org-babel-sql-dbstring-sqsh
+				    dbhost dbuser dbpassword database)
+				   (org-babel-sql-convert-standard-filename
+				    (org-babel-process-file-name in-file))
+				   (org-babel-sql-convert-standard-filename
+				    (org-babel-process-file-name out-file))))
+		    (`vertica (format "vsql %s -f %s -o %s %s"
+				    (org-babel-sql-dbstring-vertica
+				     dbhost dbport dbuser dbpassword database)
+				    (org-babel-process-file-name in-file)
+				    (org-babel-process-file-name out-file)
+				    (or cmdline "")))
+                    (`oracle (format
+			      "sqlplus -s %s < %s > %s"
+			      (org-babel-sql-dbstring-oracle
+			       dbhost dbport dbuser dbpassword database)
+			      (org-babel-process-file-name in-file)
+			      (org-babel-process-file-name out-file)))
+                    (_ (error "No support for the %s SQL engine" engine)))))
+    (with-temp-file in-file
+      (insert
+       (pcase (intern engine)
+	 (`dbi "/format partbox\n")
+         (`oracle "SET PAGESIZE 50000
+SET NEWPAGE 0
+SET TAB OFF
+SET SPACE 0
+SET LINESIZE 9999
+SET ECHO OFF
+SET FEEDBACK OFF
+SET VERIFY OFF
+SET HEADING ON
+SET MARKUP HTML OFF SPOOL OFF
+SET COLSEP '|'
+
+")
+	 ((or `mssql `sqsh) "SET NOCOUNT ON
+
+")
+	 (`vertica "\\a\n")
+	 (_ ""))
+       (org-babel-expand-body:sql body params)
+       ;; "sqsh" requires "go" inserted at EOF.
+       (if (string= engine "sqsh") "\ngo" "")))
+    (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
+	(cond
+	 ((memq (intern engine) '(dbi mysql postgresql sqsh vertica))
+	  ;; 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 (if (string= engine "sqsh") '(4) '(16)))
+	(org-babel-reassemble-table
+	 (mapcar (lambda (x)
+		   (if (string= (car x) header-delim)
+		       'hline
+		     x))
+		 (org-table-to-lisp))
+	 (org-babel-pick-name (cdr (assq :colname-names params))
+			      (cdr (assq :colnames params)))
+	 (org-babel-pick-name (cdr (assq :rowname-names params))
+			      (cdr (assq :rownames params))))))))
+
+(defun org-babel-sql-expand-vars (body vars)
+  "Expand the variables held in VARS in BODY."
+  (mapc
+   (lambda (pair)
+     (setq body
+	   (replace-regexp-in-string
+	    (format "$%s" (car pair))
+	    (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)
+
+(defun org-babel-prep-session:sql (_session _params)
+  "Raise an error because Sql sessions aren't implemented."
+  (error "SQL sessions not yet implemented"))
+
+(provide 'ob-sql)
+
+
+
+;;; ob-sql.el ends here
diff --git a/elpa/org-plus-contrib-20150831/ob-sqlite.el b/elpa/org-plus-contrib-20170407/ob-sqlite.el
similarity index 87%
rename from elpa/org-plus-contrib-20150831/ob-sqlite.el
rename to elpa/org-plus-contrib-20170407/ob-sqlite.el
index 33c8d9b5..8094019d 100644
--- a/elpa/org-plus-contrib-20150831/ob-sqlite.el
+++ b/elpa/org-plus-contrib-20170407/ob-sqlite.el
@@ -1,6 +1,6 @@
-;;; ob-sqlite.el --- org-babel functions for sqlite database interaction
+;;; ob-sqlite.el --- Babel Functions for SQLite Databases -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2010-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2017 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
@@ -53,23 +53,22 @@
 (defun org-babel-expand-body:sqlite (body params)
   "Expand BODY according to the values of PARAMS."
   (org-babel-sqlite-expand-vars
-   body (mapcar #'cdr (org-babel-get-header params :var))))
+   body (org-babel--get-vars params)))
 
 (defvar org-babel-sqlite3-command "sqlite3")
 
 (defun org-babel-execute:sqlite (body params)
   "Execute a block of Sqlite code with Babel.
 This function is called by `org-babel-execute-src-block'."
-  (let ((result-params (split-string (or (cdr (assoc :results params)) "")))
-	(db (cdr (assoc :db params)))
-	(separator (cdr (assoc :separator params)))
-	(nullvalue (cdr (assoc :nullvalue params)))
-	(headers-p (equal "yes" (cdr (assoc :colnames params))))
+  (let ((result-params (split-string (or (cdr (assq :results params)) "")))
+	(db (cdr (assq :db params)))
+	(separator (cdr (assq :separator params)))
+	(nullvalue (cdr (assq :nullvalue params)))
+	(headers-p (equal "yes" (cdr (assq :colnames params))))
 	(others (delq nil (mapcar
-			   (lambda (arg) (car (assoc arg params)))
+			   (lambda (arg) (car (assq arg params)))
 			   (list :header :echo :bail :column
-				 :csv :html :line :list))))
-	exit-code)
+				 :csv :html :line :list)))))
     (unless db (error "ob-sqlite: can't evaluate without a database"))
     (with-temp-buffer
       (insert
@@ -119,7 +118,7 @@ This function is called by `org-babel-execute-src-block'."
    (lambda (pair)
      (setq body
 	   (replace-regexp-in-string
-	    (format "\$%s" (car pair))  ;FIXME: "\$" == "$"!
+	    (format "$%s" (car pair))
 	    (let ((val (cdr pair)))
               (if (listp val)
                   (let ((data-file (org-babel-temp-file "sqlite-data-")))
@@ -140,7 +139,7 @@ This function is called by `org-babel-execute-src-block'."
 	   (equal 1 (length (car result))))
       (org-babel-read (caar result))
     (mapcar (lambda (row)
-	      (if (equal 'hline row)
+	      (if (eq 'hline row)
 		  'hline
 		(mapcar #'org-babel-string-read row))) result)))
 
@@ -150,7 +149,7 @@ This function is called by `org-babel-execute-src-block'."
       (cons (car table) (cons 'hline (cdr table)))
     table))
 
-(defun org-babel-prep-session:sqlite (session params)
+(defun org-babel-prep-session:sqlite (_session _params)
   "Raise an error because support for SQLite sessions isn't implemented.
 Prepare SESSION according to the header arguments specified in PARAMS."
   (error "SQLite sessions not yet implemented"))
diff --git a/elpa/org-plus-contrib-20170407/ob-stan.el b/elpa/org-plus-contrib-20170407/ob-stan.el
new file mode 100644
index 00000000..40dd0efa
--- /dev/null
+++ b/elpa/org-plus-contrib-20170407/ob-stan.el
@@ -0,0 +1,84 @@
+;;; ob-stan.el --- Babel Functions for Stan          -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2015-2017 Free Software Foundation, Inc.
+
+;; Author: Kyle Meyer
+;; 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 .
+
+;;; Commentary:
+
+;; Org-Babel support for evaluating Stan [1] source code.
+;;
+;; Evaluating a Stan block can produce two different results.
+;;
+;; 1) Dump the source code contents to a file.
+;;
+;;    This file can then be used as a variable in other blocks, which
+;;    allows interfaces like RStan to use the model.
+;;
+;; 2) Compile the contents to a model file.
+;;
+;;    This provides access to the CmdStan interface.  To use this, set
+;;    `org-babel-stan-cmdstan-directory' and provide a :file argument
+;;    that does not end in ".stan".
+;;
+;; For more information and usage examples, visit
+;; http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-stan.html
+;;
+;; [1] http://mc-stan.org/
+
+;;; Code:
+(require 'ob)
+(require 'org-compat)
+
+(defcustom org-babel-stan-cmdstan-directory nil
+  "CmdStan source directory.
+'make' will be called from this directory to compile the Stan
+block.  When nil, executing Stan blocks dumps the content to a
+plain text file."
+  :group 'org-babel
+  :type 'string)
+
+(defvar org-babel-default-header-args:stan
+  '((:results . "file")))
+
+(defun org-babel-execute:stan (body params)
+  "Generate Stan file from BODY according to PARAMS.
+A :file header argument must be given.  If
+`org-babel-stan-cmdstan-directory' is non-nil and the file name
+does not have a \".stan\" extension, save an intermediate
+\".stan\" file and compile the block to the named file.
+Otherwise, write the Stan code directly to the named file."
+  (let ((file (expand-file-name
+	       (or (cdr (assq :file params))
+		   (user-error "Set :file argument to execute Stan blocks")))))
+    (if (or (not org-babel-stan-cmdstan-directory)
+	    (string-match-p "\\.stan\\'" file))
+	(with-temp-file file (insert body))
+      (with-temp-file (concat file ".stan") (insert body))
+      (let ((default-directory org-babel-stan-cmdstan-directory))
+	(call-process-shell-command (concat "make " file))))
+    nil))		; Signal that output has been written to file.
+
+(defun org-babel-prep-session:stan (_session _params)
+  "Return an error because Stan does not support sessions."
+  (user-error "Stan does not support sessions"))
+
+(provide 'ob-stan)
+;;; ob-stan.el ends here
diff --git a/elpa/org-plus-contrib-20150831/ob-stata.el b/elpa/org-plus-contrib-20170407/ob-stata.el
similarity index 91%
rename from elpa/org-plus-contrib-20150831/ob-stata.el
rename to elpa/org-plus-contrib-20170407/ob-stata.el
index 29aa88d0..d8cf52a3 100644
--- a/elpa/org-plus-contrib-20150831/ob-stata.el
+++ b/elpa/org-plus-contrib-20170407/ob-stata.el
@@ -42,7 +42,7 @@
 
 ;;; Code:
 (require 'ob)
-(eval-when-compile (require 'cl))
+(require 'cl-lib)
 
 (declare-function orgtbl-to-csv "org-table" (table params))
 (declare-function stata "ext:ess-stata" (&optional start-args))
@@ -50,7 +50,6 @@
 (declare-function ess-make-buffer-current "ext:ess-inf" ())
 (declare-function ess-eval-buffer "ext:ess-inf" (vis))
 (declare-function org-number-sequence "org-compat" (from &optional to inc))
-(declare-function org-remove-if-not "org" (predicate seq))
 
 (defconst org-babel-header-args:stata
   '((width		 . :any)
@@ -77,7 +76,7 @@
 
 (defvar ess-local-process-name) ; dynamically scoped
 (defun org-babel-edit-prep:stata (info)
-  (let ((session (cdr (assoc :session (nth 2 info)))))
+  (let ((session (cdr (assq :session (nth 2 info)))))
     (when (and session (string-match "^\\*\\(.+?\\)\\*$" session))
       (save-match-data (org-babel-stata-initiate-session session nil)))))
 
@@ -98,12 +97,12 @@
   "Execute a block of stata code.
 This function is called by `org-babel-execute-src-block'."
   (save-excursion
-    (let* ((result-params (cdr (assoc :result-params params)))
-	   (result-type (cdr (assoc :result-type params)))
+    (let* ((result-params (cdr (assq :result-params params)))
+	   (result-type (cdr (assq :result-type params)))
            (session (org-babel-stata-initiate-session
-		     (cdr (assoc :session params)) params))
-	   (colnames-p (cdr (assoc :colnames params)))
-	   (rownames-p (cdr (assoc :rownames params)))
+		     (cdr (assq :session params)) params))
+	   (colnames-p (cdr (assq :colnames params)))
+	   (rownames-p (cdr (assq :rownames params)))
 	   (graphics-file (org-babel-stata-graphical-output-file params))
 	   (full-body (org-babel-expand-body:stata body params graphics-file))
 	   (result
@@ -111,10 +110,10 @@ This function is called by `org-babel-execute-src-block'."
 	     session full-body result-type result-params
 	     (or (equal "yes" colnames-p)
 		 (org-babel-pick-name
-		  (cdr (assoc :colname-names params)) colnames-p))
+		  (cdr (assq :colname-names params)) colnames-p))
 	     (or (equal "yes" rownames-p)
 		 (org-babel-pick-name
-		  (cdr (assoc :rowname-names params)) rownames-p)))))
+		  (cdr (assq :rowname-names params)) rownames-p)))))
       (if graphics-file nil result))))
 
 (defun org-babel-prep-session:stata (session params)
@@ -140,20 +139,20 @@ This function is called by `org-babel-execute-src-block'."
 
 (defun org-babel-variable-assignments:stata (params)
   "Return list of stata statements assigning the block's variables."
-  (let ((vars (mapcar #'cdr (org-babel-get-header params :var))))
+  (let ((vars (org-babel--get-vars params)))
     (mapcar
      (lambda (pair)
        (org-babel-stata-assign-elisp
 	(car pair) (cdr pair)
-	(equal "yes" (cdr (assoc :colnames params)))
-	(equal "yes" (cdr (assoc :rownames params)))))
+	(equal "yes" (cdr (assq :colnames params)))
+	(equal "yes" (cdr (assq :rownames params)))))
      (mapcar
       (lambda (i)
 	(cons (car (nth i vars))
 	      (org-babel-reassemble-table
 	       (cdr (nth i vars))
-	       (cdr (nth i (cdr (assoc :colname-names params))))
-	       (cdr (nth i (cdr (assoc :rowname-names params)))))))
+	       (cdr (nth i (cdr (assq :colname-names params))))
+	       (cdr (nth i (cdr (assq :rowname-names params)))))))
       (org-number-sequence 0 (1- (length vars)))))))
 
 (defun org-babel-stata-quote-csv-field (s)
@@ -165,9 +164,9 @@ This function is called by `org-babel-execute-src-block'."
 (defun org-babel-stata-assign-elisp (name value colnames-p rownames-p)
   "Construct stata code assigning the elisp VALUE to a variable named NAME."
   (if (listp value)
-      (let ((max (apply #'max (mapcar #'length (org-remove-if-not
+      (let ((max (apply #'max (mapcar #'length (cl-remove-if-not
 						#'sequencep value))))
-	    (min (apply #'min (mapcar #'length (org-remove-if-not
+	    (min (apply #'min (mapcar #'length (cl-remove-if-not
 						#'sequencep value))))
 	    (transition-file (org-babel-temp-file "stata-import-")))
         ;; ensure VALUE has an orgtbl structure (depth of at least 2)
@@ -194,7 +193,7 @@ This function is called by `org-babel-execute-src-block'."
     (let ((session (or session "*stata*"))
 	  (ess-ask-for-ess-directory
 	   (and (and (boundp 'ess-ask-for-ess-directory) ess-ask-for-ess-directory)
-		(not (cdr (assoc :dir params))))))
+		(not (cdr (assq :dir params))))))
       (if (org-babel-comint-buffer-livep session)
 	  session
 	(save-window-excursion
@@ -240,7 +239,7 @@ current code buffer."
 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."
-  (case result-type
+  (cl-case result-type
     (value
      (let ((tmp-file (org-babel-temp-file "stata-")))
        (org-babel-eval org-babel-stata-command
@@ -262,7 +261,7 @@ last statement in BODY, as elisp."
 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."
-  (case result-type
+  (cl-case result-type
     (value
      (with-temp-buffer
        (insert (org-babel-chomp body))
diff --git a/elpa/org-plus-contrib-20150831/ob-table.el b/elpa/org-plus-contrib-20170407/ob-table.el
similarity index 90%
rename from elpa/org-plus-contrib-20150831/ob-table.el
rename to elpa/org-plus-contrib-20170407/ob-table.el
index 3dccc712..4de8936d 100644
--- a/elpa/org-plus-contrib-20150831/ob-table.el
+++ b/elpa/org-plus-contrib-20170407/ob-table.el
@@ -1,6 +1,6 @@
-;;; ob-table.el --- support for calling org-babel functions from tables
+;;; ob-table.el --- Support for Calling Babel Functions from Tables -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2009-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2017 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
@@ -23,8 +23,8 @@
 
 ;;; Commentary:
 
-;; Should allow calling functions from org-mode tables using the
-;; function `org-sbe' as so...
+;; Should allow calling functions from Org tables using the function
+;; `org-sbe' as so...
 
 ;; #+begin_src emacs-lisp :results silent
 ;;   (defun fibbd (n) (if (< n 2) 1 (+ (fibbd (- n 1)) (fibbd (- n 2)))))
@@ -55,13 +55,15 @@
 ;;; Code:
 (require 'ob-core)
 
+(declare-function org-trim "org" (s &optional keep-lead))
+
 (defun org-babel-table-truncate-at-newline (string)
   "Replace newline character with ellipses.
 If STRING ends in a newline character, then remove the newline
 character and replace it with ellipses."
   (if (and (stringp string) (string-match "[\n\r]\\(.\\)?" string))
       (concat (substring string 0 (match-beginning 0))
-	      (if (match-string 1 string) "...")) string))
+	      (when (match-string 1 string) "...")) string))
 
 (defmacro org-sbe (source-block &rest variables)
   "Return the results of calling SOURCE-BLOCK with VARIABLES.
@@ -94,7 +96,7 @@ the header argument which can then be passed before all variables
 as shown in the example below.
 
 | 1 | 2 | :file nothing.png | nothing.png |
-#+TBLFM: @1$4='(org-sbe test-sbe $3 (x $1) (y $2))"
+#+TBLFM: @1$4=\\='(org-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)))
@@ -142,7 +144,7 @@ as shown in the example below.
                     nil (list "emacs-lisp" "results" params)
                     '((:results . "silent"))))
                "")))
-        (org-babel-trim (if (stringp result) result (format "%S" result)))))))
+        (org-trim (if (stringp result) result (format "%S" result)))))))
 
 (provide 'ob-table)
 
diff --git a/elpa/org-plus-contrib-20150831/ob-tangle.el b/elpa/org-plus-contrib-20170407/ob-tangle.el
similarity index 71%
rename from elpa/org-plus-contrib-20150831/ob-tangle.el
rename to elpa/org-plus-contrib-20170407/ob-tangle.el
index d20c2b38..b33fcaee 100644
--- a/elpa/org-plus-contrib-20150831/ob-tangle.el
+++ b/elpa/org-plus-contrib-20170407/ob-tangle.el
@@ -1,6 +1,6 @@
-;;; ob-tangle.el --- extract source code from org-mode files
+;;; ob-tangle.el --- Extract Source Code From Org Files -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2009-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2017 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
@@ -26,21 +26,30 @@
 ;; Extract the code from source blocks out into raw source-code files.
 
 ;;; Code:
+
+(require 'cl-lib)
 (require 'org-src)
+(require 'org-macs)
 
 (declare-function make-directory "files" (dir &optional parents))
-(declare-function org-babel-update-block-body "org" (new-body))
-(declare-function org-back-to-heading "org" (invisible-ok))
+(declare-function org-at-heading-p "org" (&optional ignored))
+(declare-function org-babel-update-block-body "ob-core" (new-body))
+(declare-function org-back-to-heading "org" (&optional invisible-ok))
 (declare-function org-before-first-heading-p "org" ())
-(declare-function org-edit-special "org" (&optional arg))
+(declare-function org-element-at-point "org-element" ())
+(declare-function org-element-type "org-element" (element))
 (declare-function org-fill-template "org" (template alist))
 (declare-function org-heading-components "org" ())
 (declare-function org-in-commented-heading-p "org" (&optional no-inheritance))
-(declare-function org-link-escape "org" (text &optional table))
+(declare-function org-link-escape "org" (text &optional table merge))
 (declare-function org-open-link-from-string "org" (s &optional arg reference-buffer))
+(declare-function org-remove-indentation "org" (code &optional n))
 (declare-function org-store-link "org" (arg))
-(declare-function org-up-heading-safe "org" ())
+(declare-function org-trim "org" (s &optional keep-lead))
 (declare-function outline-previous-heading "outline" ())
+(declare-function org-id-find "org-id" (id &optional markerp))
+
+(defvar org-link-types-re)
 
 (defcustom org-babel-tangle-lang-exts
   '(("emacs-lisp" . "el")
@@ -58,7 +67,7 @@ then the name of the language is used."
 	   (string "File Extension"))))
 
 (defcustom org-babel-tangle-use-relative-file-links t
-  "Use relative path names in links from tangled source back the Org-mode file."
+  "Use relative path names in links from tangled source back the Org file."
   :group 'org-babel-tangle
   :type 'boolean)
 
@@ -86,7 +95,7 @@ The following format strings can be used to insert special
 information into the output using `org-fill-template'.
 %start-line --- the line number at the start of the code block
 %file --------- the file from which the code block was tangled
-%link --------- Org-mode style link to the code block
+%link --------- Org style link to the code block
 %source-name -- name of the code block
 
 Upon insertion the formatted comment will be commented out, and
@@ -106,7 +115,7 @@ The following format strings can be used to insert special
 information into the output using `org-fill-template'.
 %start-line --- the line number at the start of the code block
 %file --------- the file from which the code block was tangled
-%link --------- Org-mode style link to the code block
+%link --------- Org style link to the code block
 %source-name -- name of the code block
 
 Upon insertion the formatted comment will be commented out, and
@@ -128,8 +137,8 @@ of tangled comments."
   :group 'org-babel
   :type 'boolean)
 
-(defcustom org-babel-process-comment-text #'org-remove-indentation
-  "Function called to process raw Org-mode text collected to be
+(defcustom org-babel-process-comment-text 'org-remove-indentation
+  "Function called to process raw Org text collected to be
 inserted as comments in tangled source-code files.  The function
 should take a single string argument and return a string
 result.  The default value is `org-remove-indentation'."
@@ -179,12 +188,14 @@ Return a list whose CAR is the tangled file name."
 	(save-window-excursion
 	  (find-file file)
 	  (setq to-be-removed (current-buffer))
-	  (org-babel-tangle nil target-file lang))
+	  (mapcar #'expand-file-name (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."
+  (unless (file-exists-p pub-dir)
+    (make-directory pub-dir t))
   (mapc (lambda (el) (copy-file el pub-dir t)) (org-babel-tangle-file filename)))
 
 ;;;###autoload
@@ -216,7 +227,7 @@ used to limit the exported source code blocks by language."
 	       org-babel-default-header-args))
 	    (tangle-file
 	     (when (equal arg '(16))
-	       (or (cdr (assoc :tangle (nth 2 (org-babel-get-src-block-info 'light))))
+	       (or (cdr (assq :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
@@ -242,7 +253,7 @@ used to limit the exported source code blocks by language."
 			 (base-name (cond
 				     ((string= "yes" tangle)
 				      (file-name-sans-extension
-				       (buffer-file-name)))
+				       (nth 1 spec)))
 				     ((string= "no" tangle) nil)
 				     ((> (length tangle) 0) tangle)))
 			 (file-name (when base-name
@@ -269,11 +280,11 @@ used to limit the exported source code blocks by language."
 			;; We avoid append-to-file as it does not work with tramp.
 			(let ((content (buffer-string)))
 			  (with-temp-buffer
-			    (if (file-exists-p file-name)
-				(insert-file-contents file-name))
+			    (when (file-exists-p file-name)
+			      (insert-file-contents file-name))
 			    (goto-char (point-max))
 			    ;; Handle :padlines unless first line in file
-			    (unless (or (string= "no" (cdr (assoc :padline (nth 4 spec))))
+			    (unless (or (string= "no" (cdr (assq :padline (nth 4 spec))))
 					(= (point) (point-min)))
 			      (insert "\n"))
 			    (insert content)
@@ -283,10 +294,8 @@ used to limit the exported source code blocks by language."
 			(unless tangle-mode (setq tangle-mode #o755)))
 		      ;; update counter
 		      (setq block-counter (+ 1 block-counter))
-		      (add-to-list 'path-collector
-				   (cons file-name tangle-mode)
-				   nil
-				   (lambda (a b) (equal (car a) (car b))))))))
+		      (unless (assoc file-name path-collector)
+			(push (cons file-name tangle-mode) path-collector))))))
 	      specs)))
 	 (if (equal arg '(4))
 	     (org-babel-tangle-single-block 1 t)
@@ -314,7 +323,7 @@ used to limit the exported source code blocks by language."
 Call this function inside of a source-code file generated by
 `org-babel-tangle' to remove all comments inserted automatically
 by `org-babel-tangle'.  Warning, this comment removes any lines
-containing constructs which resemble org-mode file links or noweb
+containing constructs which resemble Org file links or noweb
 references."
   (interactive)
   (goto-char (point-min))
@@ -332,58 +341,43 @@ 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 (if org-babel-tangle-use-relative-file-links
-		   (file-relative-name (nth 1 spec))
-		 (nth 1 spec)))
-	 (link (let ((link (nth 2 spec)))
-		 (if org-babel-tangle-use-relative-file-links
-		     (when (string-match "^\\(file:\\|docview:\\)\\(.*\\)" link)
-		       (let* ((type (match-string 1 link))
-			      (path (match-string 2 link))
-			      (origpath path)
-			      (case-fold-search nil))
-			 (setq path (file-relative-name path))
-			 (concat type path)))
-		   link)))
-	 (source-name (nth 3 spec))
-	 (body (nth 5 spec))
-	 (comment (nth 6 spec))
-	 (comments (cdr (assoc :comments (nth 4 spec))))
-	 (link-p (or (string= comments "both") (string= comments "link")
-		     (string= comments "yes") (string= comments "noweb")))
-	 (link-data (mapcar (lambda (el)
-			      (cons (symbol-name 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"))
-				      (> (length text) 0))
-			     (if org-babel-tangle-uncomment-comments
-				 ;; just plain comments with no processing
-				 (insert text)
-			       ;; ensure comments are made to be
-			       ;; comments, and add a trailing newline
-			       (comment-region
-				(point) (progn (insert text) (point)))
-			       (end-of-line nil)
-			       (insert "\n"))))))
+  (start-line file link source-name params body comment)"
+  (pcase-let*
+      ((`(,start ,file ,link ,source ,info ,body ,comment) spec)
+       (comments (cdr (assq :comments info)))
+       (link? (or (string= comments "both") (string= comments "link")
+		  (string= comments "yes") (string= comments "noweb")))
+       (link-data `(("start-line" . ,(number-to-string start))
+		    ("file" . ,file)
+		    ("link" . ,link)
+		    ("source-name" . ,source)))
+       (insert-comment (lambda (text)
+			 (when (and comments
+				    (not (string= comments "no"))
+				    (org-string-nw-p text))
+			   (if org-babel-tangle-uncomment-comments
+			       ;; Plain comments: no processing.
+			       (insert text)
+			     ;; Ensure comments are made to be
+			     ;; comments, and add a trailing newline.
+			     ;; Also ignore invisible characters when
+			     ;; commenting.
+			     (comment-region
+			      (point)
+			      (progn (insert (org-no-properties text))
+				     (point)))
+			     (end-of-line)
+			     (insert "\n"))))))
     (when comment (funcall insert-comment comment))
-    (when link-p
-      (funcall
-       insert-comment
-       (org-fill-template org-babel-tangle-comment-format-beg link-data)))
-    (insert
-     (format
-      "%s\n"
-      (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)))))
+    (when link?
+      (funcall insert-comment
+	       (org-fill-template
+		org-babel-tangle-comment-format-beg link-data)))
+    (insert body "\n")
+    (when link?
+      (funcall insert-comment
+	       (org-fill-template
+		org-babel-tangle-comment-format-end link-data)))))
 
 (defun org-babel-tangle-collect-blocks (&optional language tangle-file)
   "Collect source blocks in the current Org file.
@@ -397,14 +391,14 @@ can be used to limit the collected code blocks by target file."
       (let ((current-heading-pos
 	     (org-with-wide-buffer
 	      (org-with-limited-levels (outline-previous-heading)))))
-	(cond ((eq last-heading-pos current-heading-pos) (incf counter))
-	      ((= counter 1))
-	      (t (setq counter 1))))
+	(if (eq last-heading-pos current-heading-pos) (cl-incf counter)
+	  (setq counter 1)
+	  (setq last-heading-pos current-heading-pos)))
       (unless (org-in-commented-heading-p)
 	(let* ((info (org-babel-get-src-block-info 'light))
 	       (src-lang (nth 0 info))
 	       (src-tfile (cdr (assq :tangle (nth 2 info)))))
-	  (unless (or (string= (cdr (assq :tangle (nth 2 info))) "no")
+	  (unless (or (string= src-tfile "no")
 		      (and tangle-file (not (equal tangle-file src-tfile)))
 		      (and language (not (string= language src-lang))))
 	    ;; Add the spec for this block to blocks under its
@@ -416,72 +410,66 @@ can be used to limit the collected code blocks by target file."
     ;; Ensure blocks are in the correct order.
     (mapcar (lambda (b) (cons (car b) (nreverse (cdr b)))) blocks)))
 
-(defun org-babel-tangle-single-block
-  (block-counter &optional only-this-block)
+(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."
+`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))
+	 (file (buffer-file-name (buffer-base-buffer)))
 	 (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))))
+	 (link (let ((l (org-no-properties (org-store-link nil))))
+                 (and (string-match org-bracket-link-regexp l)
+                      (match-string 1 l))))
 	 (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)))
+	  (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))))
+          (let ((body (if (org-babel-noweb-p params :tangle)
+			  (org-babel-expand-noweb-references info)
+			(nth 1 info))))
+	    (with-temp-buffer
+	      (insert
+	       ;; Expand body in language specific manner.
+	       (cond ((assq :no-expand params) body)
+		     ((fboundp expand-cmd) (funcall expand-cmd body params))
+		     (t
+		      (org-babel-expand-body:generic
+		       body params (and (fboundp assignments-cmd)
+					(funcall assignments-cmd params))))))
+	      (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))))
+	  (when (or (string= "both" (cdr (assq :comments params)))
+		    (string= "org" (cdr (assq :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
+			 (org-back-to-heading t) ; Sets match data
 			 (match-end 0))
 		     (error (point-min)))
 		   (save-excursion
@@ -491,31 +479,48 @@ list to be used by `org-babel-tangle' directly."
 		       (point-min))))
 	      (point)))))
 	 (result
-	  (list start-line file link source-name params body comment)))
+	  (list start-line
+		(if org-babel-tangle-use-relative-file-links
+		    (file-relative-name file)
+		  file)
+		(if (and org-babel-tangle-use-relative-file-links
+			 (string-match org-link-types-re link)
+			 (string= (match-string 0 link) "file"))
+		    (concat "file:"
+			    (file-relative-name (match-string 1 link)
+						(file-name-directory
+						 (cdr (assq :tangle params)))))
+		  link)
+		source-name
+		params
+		(org-unescape-code-in-string
+		 (if org-src-preserve-indentation
+		     (org-trim body t)
+		   (org-trim (org-remove-indentation body))))
+		comment)))
     (if only-this-block
 	(list (cons src-lang (list result)))
       result)))
 
-(defun org-babel-tangle-comment-links ( &optional info)
+(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))
-	 (file (buffer-file-name))
-	 (link (org-link-escape (progn (call-interactively 'org-store-link)
-				       (org-no-properties
-					(car (pop org-stored-links))))))
-	 (source-name (nth 4 (or info (org-babel-get-src-block-info 'light))))
-	 (link-data (mapcar (lambda (el)
-			      (cons (symbol-name el)
-				    (let ((le (eval el)))
-                                      (if (stringp le) le (format "%S" le)))))
-			    '(start-line file link source-name))))
+  (let ((link-data
+	 `(("start-line" . ,(number-to-string
+			     (org-babel-where-is-src-block-head)))
+	   ("file" . ,(buffer-file-name))
+	   ("link" . ,(org-link-escape
+		       (progn
+			 (call-interactively #'org-store-link)
+			 (org-no-properties (car (pop org-stored-links))))))
+	   ("source-name" .
+	    ,(nth 4 (or info (org-babel-get-src-block-info 'light)))))))
     (list (org-fill-template org-babel-tangle-comment-format-beg link-data)
 	  (org-fill-template org-babel-tangle-comment-format-end link-data))))
 
 ;; de-tangling functions
 (defvar org-bracket-link-analytic-regexp)
 (defun org-babel-detangle (&optional source-code-file)
-  "Propagate changes in source file back original to Org-mode file.
+  "Propagate changes in source file back original to Org file.
 This requires that code blocks were tangled with link comments
 which enable the original code blocks to be found."
   (interactive)
@@ -536,18 +541,17 @@ which enable the original code blocks to be found."
       (prog1 counter (message "Detangled %d code blocks" counter)))))
 
 (defun org-babel-tangle-jump-to-org ()
-  "Jump from a tangled code file to the related Org-mode file."
+  "Jump from a tangled code file to the related Org mode file."
   (interactive)
   (let ((mid (point))
-	start body-start end done
+	start body-start end
         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)))
+		     (and (setq start (line-beginning-position))
+			  (setq body-start (line-beginning-position 2))
 			  (setq link (match-string 0))
 			  (setq path (match-string 3))
 			  (setq block-name (match-string 5))
@@ -556,32 +560,37 @@ which enable the original code blocks to be found."
 			      (re-search-forward
 			       (concat " " (regexp-quote block-name)
 				       " ends here") nil t)
-			      (setq end (point-at-bol))))))))
+			      (setq end (line-beginning-position))))))))
 	(unless (and start (< start mid) (< mid end))
 	  (error "Not in tangled code"))
-        (setq body (org-babel-trim (buffer-substring start end))))
+        (setq body (buffer-substring body-start end)))
       (when (string-match "::" path)
         (setq path (substring path 0 (match-beginning 0))))
-      (find-file path) (setq target-buffer (current-buffer))
-      (goto-char start) (org-open-link-from-string link)
+      (find-file (or (car (org-id-find path)) path))
+      (setq target-buffer (current-buffer))
+      ;; Go to the beginning of the relative block in Org file.
+      (org-open-link-from-string link)
       (if (string-match "[^ \t\n\r]:\\([[:digit:]]+\\)" block-name)
-          (org-babel-next-src-block
-           (string-to-number (match-string 1 block-name)))
+          (let ((n (string-to-number (match-string 1 block-name))))
+	    (if (org-before-first-heading-p) (goto-char (point-min))
+	      (org-back-to-heading t))
+	    ;; Do not skip the first block if it begins at point min.
+	    (cond ((or (org-at-heading-p)
+		       (not (eq (org-element-type (org-element-at-point))
+				'src-block)))
+		   (org-babel-next-src-block n))
+		  ((= n 1))
+		  (t (org-babel-next-src-block (1- n)))))
         (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))
+      ;; Preserve location of point within the source code in tangled
+      ;; code file.
       (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)))
     (org-src-switch-to-buffer target-buffer t)
-    (prog1 body (goto-char target-char))))
+    (goto-char target-char)
+    body))
 
 (provide 'ob-tangle)
 
diff --git a/elpa/org-plus-contrib-20150831/ob-tcl.el b/elpa/org-plus-contrib-20170407/ob-tcl.el
similarity index 89%
rename from elpa/org-plus-contrib-20150831/ob-tcl.el
rename to elpa/org-plus-contrib-20170407/ob-tcl.el
index d66357de..c76b138c 100644
--- a/elpa/org-plus-contrib-20150831/ob-tcl.el
+++ b/elpa/org-plus-contrib-20170407/ob-tcl.el
@@ -1,6 +1,6 @@
 ;;; ob-tcl.el --- Org-babel functions for tcl evaluation
 
-;; Copyright (C) 2009-2014  Free Software Foundation, Inc.
+;; Copyright (C) 2009-2017  Free Software Foundation, Inc.
 
 ;; Authors: Dan Davison
 ;;	 Eric Schulte
@@ -47,18 +47,18 @@
 (defun org-babel-execute:tcl (body params)
   "Execute a block of Tcl code with Babel.
 This function is called by `org-babel-execute-src-block'."
-  (let* ((session (cdr (assoc :session params)))
-         (result-params (cdr (assoc :result-params params)))
-         (result-type (cdr (assoc :result-type params)))
+  (let* ((session (cdr (assq :session params)))
+         (result-params (cdr (assq :result-params params)))
+         (result-type (cdr (assq :result-type params)))
          (full-body (org-babel-expand-body:generic
 		     body params (org-babel-variable-assignments:tcl params)))
 	(session (org-babel-tcl-initiate-session session)))
     (org-babel-reassemble-table
      (org-babel-tcl-evaluate session full-body result-type)
      (org-babel-pick-name
-      (cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
+      (cdr (assq :colname-names params)) (cdr (assq :colnames params)))
      (org-babel-pick-name
-      (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params))))))
+      (cdr (assq :rowname-names params)) (cdr (assq :rownames params))))))
 
 (defun org-babel-prep-session:tcl (session params)
   "Prepare SESSION according to the header arguments in PARAMS."
@@ -71,7 +71,7 @@ This function is called by `org-babel-execute-src-block'."
      (format "set %s %s"
 	     (car pair)
 	     (org-babel-tcl-var-to-tcl (cdr pair))))
-   (mapcar #'cdr (org-babel-get-header params :var))))
+   (org-babel--get-vars params)))
 
 ;; helper functions
 
diff --git a/elpa/org-plus-contrib-20170407/ob-vbnet.el b/elpa/org-plus-contrib-20170407/ob-vbnet.el
new file mode 100644
index 00000000..b0f26880
--- /dev/null
+++ b/elpa/org-plus-contrib-20170407/ob-vbnet.el
@@ -0,0 +1,84 @@
+;;; ob-vbnet.el --- org-babel functions for VB.Net evaluation
+
+;; Copyright (C) 2011-2017 Free Software Foundation, Inc.
+
+;; Author: thomas "at" friendlyvillagers.com based on ob-java.el by Eric Schulte
+;; Keywords: literate programming, reproducible research
+;; Homepage: http://orgmode.org
+
+;; This file is not 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 .
+
+;;; Commentary:
+
+;; Currently this only supports the external compilation and execution
+;; of VB.Net code blocks (i.e., no session support).
+
+;;; Code:
+(require 'ob)
+
+(defvar org-babel-tangle-lang-exts)
+(add-to-list 'org-babel-tangle-lang-exts '("vbnet" . "vb"))
+
+(defcustom org-babel-vbnet-command "mono"
+  "Name of the mono command.
+May be either a command in the path, like mono
+or an absolute path name, like /usr/local/bin/mono
+parameters may be used, like mono -verbose"
+  :group 'org-babel
+  :version "24.3"
+  :type 'string)
+
+(defcustom org-babel-vbnet-compiler "vbnc"
+  "Name of the VB.Net compiler.
+May be either a command in the path, like vbnc
+or an absolute path name, like /usr/local/bin/vbnc
+parameters may be used, like vbnc /warnaserror+"
+  :group 'org-babel
+  :version "24.3"
+  :type 'string)
+
+(defun org-babel-execute:vbnet (body params)
+  (let* ((full-body (org-babel-expand-body:generic body params))
+	 (cmpflag (or (cdr (assq :cmpflag params)) ""))
+	 (cmdline (or (cdr (assq :cmdline params)) ""))
+	 (src-file (org-babel-temp-file "vbnet-src-" ".vb"))
+	 (exe-file (concat (file-name-sans-extension src-file)  ".exe"))
+	 (compile
+	  (progn (with-temp-file  src-file (insert full-body))
+		 (org-babel-eval
+		  (concat org-babel-vbnet-compiler " " cmpflag " " src-file)
+		  ""))))
+    (let ((results (org-babel-eval (concat org-babel-vbnet-command " " cmdline " " exe-file) "")))
+      (org-babel-reassemble-table
+       (org-babel-result-cond (cdr (assq :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 (assq :colname-names params)) (cdr (assq :colnames params)))
+       (org-babel-pick-name
+        (cdr (assq :rowname-names params)) (cdr (assq :rownames params)))))))
+
+(defun org-babel-prep-session:vbnet (session params)
+  "Return an error because vbnet does not support sessions."
+  (error "Sessions are not supported for VB.Net"))
+
+(provide 'ob-vbnet)
+
+
+
+;;; ob-vbnet.el ends here
diff --git a/elpa/org-plus-contrib-20150831/ob.el b/elpa/org-plus-contrib-20170407/ob.el
similarity index 88%
rename from elpa/org-plus-contrib-20150831/ob.el
rename to elpa/org-plus-contrib-20170407/ob.el
index 42137c29..736f5887 100644
--- a/elpa/org-plus-contrib-20150831/ob.el
+++ b/elpa/org-plus-contrib-20170407/ob.el
@@ -1,6 +1,6 @@
-;;; ob.el --- working with code blocks in org-mode
+;;; ob.el --- Working with Code Blocks in Org        -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2009-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2017 Free Software Foundation, Inc.
 
 ;; Authors: Eric Schulte
 ;; Keywords: literate programming, reproducible research
diff --git a/elpa/org-plus-contrib-20150831/org b/elpa/org-plus-contrib-20170407/org
similarity index 83%
rename from elpa/org-plus-contrib-20150831/org
rename to elpa/org-plus-contrib-20170407/org
index 0e1911a3..f7a3d605 100644
--- a/elpa/org-plus-contrib-20150831/org
+++ b/elpa/org-plus-contrib-20170407/org
@@ -1,8 +1,8 @@
 This is org, produced by makeinfo version 4.13 from org.texi.
 
-This manual is for Org version 8.3.1 (release_8.3.1-95-g1dbb25).
+This manual is for Org version 9.0.5 (release_9.0.5-436-g8ba336.dirty).
 
-   Copyright (C) 2004-2015 Free Software Foundation, Inc.
+   Copyright (C) 2004-2017 Free Software Foundation, Inc.
 
      Permission is granted to copy, distribute and/or modify this
      document under the terms of the GNU Free Documentation License,
@@ -26,9 +26,9 @@ File: org,  Node: Top,  Next: Introduction,  Prev: (dir),  Up: (dir)
 Org Mode Manual
 ***************
 
-This manual is for Org version 8.3.1 (release_8.3.1-95-g1dbb25).
+This manual is for Org version 9.0.5 (release_9.0.5-436-g8ba336.dirty).
 
-   Copyright (C) 2004-2015 Free Software Foundation, Inc.
+   Copyright (C) 2004-2017 Free Software Foundation, Inc.
 
      Permission is granted to copy, distribute and/or modify this
      document under the terms of the GNU Free Documentation License,
@@ -254,7 +254,6 @@ The built-in agenda views
 * Weekly/daily agenda::         The calendar page with current tasks
 * Global TODO list::            All unfinished action items
 * Matching tags and properties::  Structured information with fine-tuned search
-* Timeline::                    Time-sorted view for single file
 * Search view::                 Find entries by searching for text
 * Stuck projects::              Find projects you need to review
 
@@ -273,31 +272,17 @@ Custom agenda views
 
 Markup for rich export
 
-* Structural markup elements::  The basic structure as seen by the exporter
+* Paragraphs::                  The basic unit of text
+* Emphasis and monospace::      Bold, italic, etc.
+* Horizontal rules::            Make a line
 * 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 templates
+* Special symbols::             Greek letters and other symbols
+* Subscripts and superscripts::  Simple syntax for raising/lowering text
 * 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
-* Lists::                       Lists
-* Paragraphs::                  Paragraphs
-* Footnote markup::             Footnotes
-* Emphasis and monospace::      Bold, italic, etc.
-* Horizontal rules::            Make a line
-* Comment lines::               What will *not* be exported
 
 Embedded LaTeX
 
-* Special symbols::             Greek letters and other symbols
-* Subscripts and superscripts::  Simple syntax for raising/lowering text
 * LaTeX fragments::          Complex formulas made easy
 * Previewing LaTeX fragments::  What will this snippet look like?
 * CDLaTeX mode::                Speed up entering of formulas
@@ -305,24 +290,37 @@ Embedded LaTeX
 Exporting
 
 * The export dispatcher::       The main exporter interface
-* Export back-ends::            Built-in export formats
 * Export settings::             Generic export settings
+* Table of contents::           The if and where of the table of contents
+* Include files::               Include additional files into a document
+* Macro replacement::           Use macros to create templates
+* Comment lines::               What will not be exported
 * 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
+* LaTeX export::             Exporting to LaTeX, and processing to PDF
 * Markdown export::             Exporting to Markdown
 * OpenDocument Text export::    Exporting to OpenDocument Text
 * Org export::                  Exporting to Org
 * Texinfo export::              Exporting to Texinfo
 * iCalendar export::            Exporting to iCalendar
 * Other built-in back-ends::    Exporting to a man page
-* Export in foreign buffers::   Author tables and lists in Org syntax
 * Advanced configuration::      Fine-tuning the export output
+* Export in foreign buffers::   Author tables and lists in Org syntax
+
+Beamer export
+
+* Beamer export commands::      How to export Beamer documents.
+* Beamer specific export settings::  Export settings for Beamer export.
+* Sectioning Frames and Blocks in Beamer::  Blocks and sections in Beamer.
+* Beamer specific syntax::      Syntax specific to Beamer.
+* Editing support::             Helper functions for Org Beamer export.
+* A Beamer Example::            An complete Beamer example.
 
 HTML export
 
 * HTML Export commands::        How to invoke HTML export
+* HTML Specific export settings::  Export settings for 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
@@ -334,17 +332,25 @@ HTML export
 * CSS support::                 Changing the appearance of the output
 * JavaScript support::          Info and Folding in a web browser
 
-LaTeX and PDF export
+LaTeX export
 
 * LaTeX export commands::    How to export to LaTeX and PDF
-* Header and sectioning::       Setting up the export file structure
+* LaTeX specific export settings::  Export settings for LaTeX
+* LaTeX header and sectioning::  Setting up the export file structure
 * Quoting LaTeX code::       Incorporating literal LaTeX code
-* LaTeX specific attributes::  Controlling LaTeX output
+* Tables in LaTeX export::   Specific attributes for tables
+* Images in LaTeX export::   Specific attributes for images
+* Plain lists in LaTeX export::  Specific attributes for plain lists
+* Source blocks in LaTeX export::  Specific attributes for source blocks
+* Example blocks in LaTeX export::  Specific attributes for example blocks
+* Special blocks in LaTeX export::  Specific attributes for special blocks
+* Horizontal rules in LaTeX export::  Specific attributes for horizontal rules
 
-OpenDocument text export
+OpenDocument Text export
 
 * Pre-requisites for ODT export::  What packages ODT exporter relies on
 * ODT export commands::         How to invoke ODT export
+* ODT specific export settings::  Export settings for ODT
 * Extending ODT export::        How to produce `doc', `pdf' files
 * Applying custom styles::      How to apply custom styles to the output
 * Links in ODT export::         How links will be interpreted and formatted
@@ -371,12 +377,18 @@ Advanced topics in ODT export
 Texinfo export
 
 * Texinfo export commands::     How to invoke Texinfo export
-* Document preamble::           File header, title and copyright page
-* Headings and sectioning structure:: Building document structure
+* Texinfo specific export settings::  Export settings for Texinfo
+* Texinfo file header::         Generating the begining of a Texinfo file
+* Texinfo title and copyright page::  Creating title and copyright pages
+* Texinfo `Top' node::     Installing a manual in Info Top node
+* Headings and sectioning structure::  Building document structure
 * Indices::                     Creating indices
 * Quoting Texinfo code::        Incorporating literal Texinfo code
-* Texinfo specific attributes:: Controlling Texinfo output
-* An example::
+* Plain lists in Texinfo export::  Specific attributes for plain lists
+* Tables in Texinfo export::    Specific attributes for tables
+* Images in Texinfo export::    Specific attributes for images
+* Special blocks in Texinfo export::  Specific attributes for special blocks
+* A Texinfo example::           Illustrating Org to Texinfo process
 
 Publishing
 
@@ -423,36 +435,32 @@ Header arguments
 
 Using header arguments
 
-* System-wide header arguments::  Set global default values
-* Language-specific header arguments::  Set default values by language
-* 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
+* System-wide header arguments::  Set globally, language-specific
+* Language-specific header arguments::  Set in the Org file's headers
+* Header arguments in Org mode properties::  Set in the Org file
+* Language-specific mode properties::
+* Code block specific header arguments::  The most commonly used method
+* Arguments in function calls::  The most specific level, takes highest priority
 
 Specific header arguments
 
-* var::                         Pass arguments to code blocks
-* results::                     Specify the type of results and how they will
-                                be collected and handled
-* file::                        Specify a path for file output
+* var::                         Pass arguments to `src' code blocks
+* results::                     Specify results type; how to collect
+* file::                        Specify a path for output file
 * file-desc::                   Specify a description for file results
-* dir::                         Specify the default (possibly remote)
-                                directory for code block execution
-* exports::                     Export code and/or results
-* tangle::                      Toggle tangling and specify file name
-* mkdirp::                      Toggle creation of parent directories of target
-                                files during tangling
-* comments::                    Toggle insertion of comments in tangled
-                                code files
-* padline::                     Control insertion of padding lines in tangled
-                                code files
-* no-expand::                   Turn off variable assignment and noweb
-                                expansion during tangling
+* file-ext::                    Specify an extension for file output
+* output-dir::                  Specify a directory for output file
+* dir::                         Specify the default directory for code block execution
+* exports::                     Specify exporting code, results, both, none
+* tangle::                      Toggle tangling; or specify file name
+* mkdirp::                      Toggle for parent directory creation for target files during tangling
+* comments::                    Toggle insertion of comments in tangled code files
+* padline::                     Control insertion of padding lines in tangled code files
+* no-expand::                   Turn off variable assignment and noweb expansion during tangling
 * session::                     Preserve the state of code evaluation
 * noweb::                       Toggle expansion of noweb references
 * noweb-ref::                   Specify block's noweb reference resolution target
-* noweb-sep::                   String used to separate noweb references
+* noweb-sep::                   String to separate noweb references
 * cache::                       Avoid re-evaluating unchanged code blocks
 * sep::                         Delimiter for writing tabular results outside Org
 * hlines::                      Handle horizontal lines in tables
@@ -462,22 +470,22 @@ Specific header arguments
 * 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
+* post::                        Post processing of results of code block evaluation
+* prologue::                    Text to prepend to body of code block
+* epilogue::                    Text to append to body of code block
 
 Miscellaneous
 
-* Completion::                  M-TAB knows what you need
+* Completion::                  M-TAB guesses completions
 * Easy templates::              Quick insertion of structural elements
 * Speed keys::                  Electric commands at the beginning of a headline
 * Code evaluation security::    Org mode files evaluate inline code
-* Customization::               Adapting Org to your taste
+* Customization::               Adapting Org to changing tastes
 * In-buffer settings::          Overview of the #+KEYWORDS
 * The very busy C-c C-c key::   When in doubt, press C-c C-c
 * Clean view::                  Getting rid of leading stars in the outline
 * TTY keys::                    Using Org on a tty
-* Interaction::                 Other Emacs packages
+* Interaction::                 With other Emacs packages
 * org-crypt::                   Encrypting Org files
 
 Interaction with other packages
@@ -509,7 +517,7 @@ Tables and lists in arbitrary syntax
 
 MobileOrg
 
-* Setting up the staging area::  Where to interact with the mobile device
+* Setting up the staging area::  For the mobile device
 * Pushing to MobileOrg::        Uploading Org files and agendas
 * Pulling from MobileOrg::      Integrating captured and flagged items
 
@@ -615,8 +623,8 @@ been visited, i.e., where no Org built-in function have been loaded.
 Otherwise autoload Org functions will mess up the installation.
 
    Then, to make sure your Org configuration is taken into account,
-initialize the package system with `(package-initialize)' in your
-`.emacs' before setting any Org option.  If you want to use Org's
+initialize the package system with `(package-initialize)' in your Emacs
+init file before setting any Org option.  If you want to use Org's
 package repository, check out the Org ELPA page
 (http://orgmode.org/elpa.html).
 
@@ -625,7 +633,7 @@ Downloading Org as an archive
 
 You can download Org latest release from Org's website
 (http://orgmode.org/).  In this case, make sure you set the load-path
-correctly in your `.emacs':
+correctly in your Emacs init file:
 
      (add-to-list 'load-path "~/path/to/orgdir/lisp")
 
@@ -669,14 +677,8 @@ File: org,  Node: Activation,  Next: Feedback,  Prev: Installation,  Up: Introdu
 1.3 Activation
 ==============
 
-Since Emacs 22.2, files with the `.org' extension use Org mode by
-default.  If you are using an earlier version of Emacs, add this line
-to your `.emacs' file:
-
-     (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
-
-   Org mode buffers need font-lock to be turned on: this is the default
-in Emacs(1).
+Org mode buffers need font-lock to be turned on: this is the default in
+Emacs(1).
 
    There are compatibility issues between Org mode and some other Elisp
 packages, please take the time to check the list (*note Conflicts::).
@@ -690,8 +692,9 @@ bindings for these keys, please modify the keys to your own liking.
      (global-set-key "\C-cc" 'org-capture)
      (global-set-key "\C-cb" 'org-iswitchb)
 
-   To turn on Org mode in a file that does not have the extension
-`.org', make the first line of a file look like this:
+   Files with the `.org' extension use Org mode by default.  To turn on
+Org mode in a file that does not have the extension `.org', make the
+first line of a file look like this:
 
      MY PROJECTS    -*- mode: org; -*-
 
@@ -699,13 +702,10 @@ which will select Org mode for this buffer no matter what the file's
 name is.  See also the variable `org-insert-mode-line-in-empty-file'.
 
    Many commands in Org work on the region if the region is active.  To
-make use of this, you need to have `transient-mark-mode'
-(`zmacs-regions' in XEmacs) turned on.  In Emacs 23 this is the default,
-in Emacs 22 you need to do this yourself with
-     (transient-mark-mode 1)
-   If you do not like `transient-mark-mode', you can create an active
-region by using the mouse to select a region, or pressing `C-'
-twice before moving the cursor.
+make use of this, you need to have `transient-mark-mode' turned on,
+which is the default.  If you do not like `transient-mark-mode', you
+can create an active region by using the mouse to select a region, or
+pressing `C-' twice before moving the cursor.
 
    ---------- Footnotes ----------
 
@@ -731,8 +731,8 @@ 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 (`M-x
 emacs-version ') and Org (`M-x org-version RET'), as well as the
-Org related setup in `.emacs'.  The easiest way to do this is to use
-the command
+Org related setup in the Emacs init file.  The easiest way to do this
+is to use the command
      M-x org-submit-bug-report RET
    which will put all this information into an Emacs mail buffer so
 that you only need to add your description.  If you are not sending the
@@ -791,8 +791,7 @@ error occurred.  Here is how to produce a useful backtrace:
      or select `Org -> Refresh/Reload -> Reload Org uncompiled' from the
      menu.
 
-  2. Go to the `Options' menu and select `Enter Debugger on Error'
-     (XEmacs has this option in the `Troubleshooting' sub-menu).
+  2. Go to the `Options' menu and select `Enter Debugger on Error'.
 
   3. Do whatever you have to do to hit the error.  Don't forget to
      document the steps you take.
@@ -834,16 +833,16 @@ property names.  In this manual we use the following conventions:
      special meaning are written with all capitals.
 
    Moreover, Org uses option keywords (like `#+TITLE' to set the title)
-and environment keywords (like `#+BEGIN_HTML' to start a `HTML'
+and environment keywords (like `#+BEGIN_EXPORT html' to start a `HTML'
 environment).  They are written in uppercase in the manual to enhance
-its readability, but you can use lowercase in your Org files(1).
+its readability, but you can use lowercase in your Org file.
 
-Keybindings and commands
-........................
+Key bindings and commands
+.........................
 
-The manual suggests a few global keybindings, in particular `C-c a' for
+The manual suggests a few global key bindings, in particular `C-c a' for
 `org-agenda' and `C-c c' for `org-capture'.  These are only
-suggestions, but the rest of the manual assumes that these keybindings
+suggestions, but the rest of the manual assumes that these key bindings
 are in place in order to list commands by key access.
 
    Also, the manual lists both the keys and the corresponding commands
@@ -858,11 +857,6 @@ the chapter on tables, it will be listed to call
 manual without the command names by unsetting the flag `cmdnames' in
 `org.texi'.
 
-   ---------- Footnotes ----------
-
-   (1) Easy templates insert lowercase keywords and Babel dynamically
-inserts `#+results'.
-
 
 File: org,  Node: Document structure,  Next: Tables,  Prev: Introduction,  Up: Top
 
@@ -991,7 +985,7 @@ C-u 
      Switch back to the startup visibility of the buffer (*note Initial
      visibility::).  
 
-`C-u C-u C-u '     (`show-all')
+`C-u C-u C-u '     (`outline-show-all')
      Show all, including drawers.  
 
 `C-c C-r'     (`org-reveal')
@@ -1003,11 +997,11 @@ C-u 
      sibling headings.  With a double prefix argument, also show the
      entire subtree of the parent.  
 
-`C-c C-k'     (`show-branches')
+`C-c C-k'     (`outline-show-branches')
      Expose all the headings of the subtree, CONTENT view for just one
      subtree.  
 
-`C-c '     (`show-children')
+`C-c '     (`outline-show-children')
      Expose all direct children of the subtree.  With a numeric prefix
      argument N, expose all children down to level N.  
 
@@ -1048,10 +1042,6 @@ buffer:
      #+STARTUP: showall
      #+STARTUP: showeverything
 
-   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 `org-agenda-inhibit-startup' to `nil'.
-
 Furthermore, any entries with a `VISIBILITY' property (*note Properties
 and columns::) will get their visibility adapted accordingly.  Allowed
 values for this property are `folded', `children', `content', and `all'.
@@ -1087,10 +1077,10 @@ File: org,  Node: Motion,  Next: Structure editing,  Prev: Visibility cycling,
 
 The following commands jump to other headlines in the buffer.
 
-`C-c C-n'     (`outline-next-visible-heading')
+`C-c C-n'     (`org-next-visible-heading')
      Next heading.  
 
-`C-c C-p'     (`outline-previous-visible-heading')
+`C-c C-p'     (`org-previous-visible-heading')
      Previous heading.  
 
 `C-c C-f'     (`org-forward-same-level')
@@ -1124,34 +1114,27 @@ File: org,  Node: Structure editing,  Next: Sparse trees,  Prev: Motion,  Up: Do
 2.5 Structure editing
 =====================
 
-`M-'     (`org-insert-heading')
-     Insert a new heading/item with the same level as the one at point.
-
-     If the cursor is in a plain list item, a new item is created
-     (*note Plain lists::).  To prevent this behavior in lists, call
-     the command with one 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.  If you do not want the
-     line to be split, customize `org-M-RET-may-split-line'.
+`M-'     (`org-meta-return')
+     Insert a new heading, item or row.
 
      If the command is used at the _beginning_ of a line, and if there
-     is a heading or an item at point, the new heading/item is created
-     _before_ the current line.  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 will be inserted after the end of the
-     subtree.
+     is a heading or a plain list item (*note Plain lists::) at point,
+     the new heading/item is created _before_ the current line.  When
+     used at the beginning of a regular line of text, turn that line
+     into a heading.
 
-     Calling this command with `C-u C-u' will unconditionally respect
-     the headline's content and create a new item at the end of the
-     parent subtree.
+     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.
+     If you do not want the line to be split, customize
+     `org-M-RET-may-split-line'.
 
-     If point is at the beginning of a normal line, turn this line into
-     a heading.  
+     Calling the command with a `C-u' prefix unconditionally inserts a
+     new heading at the end of the current subtree, thus preserving its
+     contents.  With a double `C-u C-u' prefix, the new heading is
+     created at the end of the parent subtree instead.  
 
 `C-'     (`org-insert-heading-respect-content')
-     Just like `M-', except when adding a new heading below the
-     current heading, the new heading is placed after the body instead
-     of before it.  This command works from anywhere in the entry.  
+     Insert a new heading at the end of the current subtree.  
 
 `M-S-'     (`org-insert-todo-heading')
      Insert new TODO entry with same level as current heading.  See
@@ -1291,7 +1274,7 @@ commands can be accessed through a dispatcher:
      This prompts for an extra key to select a sparse-tree creating
      command.  
 
-`C-c / r'     (`org-occur')
+`C-c / r'  or  `C-c / /'     (`org-occur')
      Prompts for a regexp and shows a sparse tree with all matches.  If
      the match is in a headline, the headline is made visible.  If the
      match is in the body of an entry, headline and body are made
@@ -1326,9 +1309,9 @@ keywords, tags, or properties and will be discussed later in this
 manual.
 
    To print a sparse tree, you can use the Emacs command
-`ps-print-buffer-with-faces' which does not print invisible parts of
-the document (3).  Or you can use `C-c C-e C-v' to export only the
-visible part of the document and print the resulting file.
+`ps-print-buffer-with-faces' which does not print invisible parts of the
+document.  Or you can use `C-c C-e C-v' to export only the visible part
+of the document and print the resulting file.
 
    ---------- Footnotes ----------
 
@@ -1337,9 +1320,6 @@ much context is shown around each match.
 
    (2) This depends on the option `org-remove-highlights-with-change'
 
-   (3) This does not work under XEmacs, because XEmacs uses selective
-display for outlining, not text properties.
-
 
 File: org,  Node: Plain lists,  Next: Drawers,  Prev: Sparse trees,  Up: Document structure
 
@@ -1387,11 +1367,11 @@ is an example:
         But in the end, no individual scenes matter but the film as a whole.
         Important actors in this film are:
         - Elijah Wood :: He plays Frodo
-        - Sean Austin :: He plays Sam, Frodo's friend.  I still remember
+        - Sean Astin :: He plays Sam, Frodo's friend.  I still remember
           him very well from his role as Mikey Walsh in The Goonies.
 
    Org supports these lists by tuning filling and wrapping commands to
-deal with them correctly(6), and by exporting them properly (*note
+deal with them correctly, and by exporting them properly (*note
 Exporting::).  Since indentation is what governs the structure of these
 lists, many structural constructs like `#+BEGIN_...' blocks can be
 indented to signal that they belong to a particular item.
@@ -1425,7 +1405,7 @@ If some of these actions get in your way, configure
      Insert new item at current level.  With a prefix argument, force a
      new heading (*note Structure editing::).  If this command is used
      in the middle of an item, that item is _split_ in two, and the
-     second part becomes the new item(7).  If this command is executed
+     second part becomes the new item(6).  If this command is executed
      _before item's body_, the new item is created _before_ the current
      one.
 
@@ -1434,14 +1414,14 @@ If some of these actions get in your way, configure
 
 `S-up'
 `S-down'
-     Jump to the previous/next item in the current list(8), but only if
+     Jump to the previous/next item in the current list(7), but only if
      `org-support-shift-select' is off.  If not, you can still use
      paragraph jumping commands like `C-' and `C-' to quite
      similar effect.  
 
 `M-up'
 `M-down'
-     Move the item including subitems up/down(9) (swap with
+     Move the item including subitems up/down(8) (swap with
      previous/next item of same indentation).  If the list is ordered,
      renumbering is automatic.  
 
@@ -1475,11 +1455,11 @@ If some of these actions get in your way, configure
      of them, depending on `org-plain-list-ordered-item-terminator',
      the type of list, and its indentation.  With a numeric prefix
      argument N, select the Nth bullet from this list.  If there is an
-     active region when calling this, selected text will be changed
-     into an item.  With a prefix argument, all lines will be converted
-     to list items.  If the first line already was a list item, any item
-     marker will be removed from the list.  Finally, even without an
-     active region, a normal line will be converted into a list item.  
+     active region when calling this, all selected lines are converted
+     to list items.  With a prefix argument, selected text is changed
+     into a single item.  If the first line already was a list item, any
+     item marker will be removed from the list.  Finally, even without
+     an active region, a normal line will be converted into a list item.  
 
 `C-c *'
      Turn a plain list item into a headline (so that it becomes a
@@ -1524,17 +1504,13 @@ can also use counters like `[@b]'.
 
    (5) See also `org-list-empty-line-terminates-plain-lists'.
 
-   (6) Org only changes the filling settings for Emacs.  For XEmacs,
-you should use Kyle E. Jones' `filladapt.el'.  To turn this on, put
-into `.emacs': `(require 'filladapt)'
-
-   (7) If you do not want the item to be split, customize the variable
+   (6) If you do not want the item to be split, customize the variable
 `org-M-RET-may-split-line'.
 
-   (8) If you want to cycle around items that way, you may customize
+   (7) If you want to cycle around items that way, you may customize
 `org-list-use-circular-motion'.
 
-   (9) See `org-list-use-circular-motion' for a cyclic behavior.
+   (8) See `org-list-use-circular-motion' for a cyclic behavior.
 
 
 File: org,  Node: Drawers,  Next: Blocks,  Prev: Plain lists,  Up: Document structure
@@ -1557,9 +1533,9 @@ like this:
    You can interactively insert drawers at point by calling
 `org-insert-drawer', which is bound to .  With an active
 region, this command will put the region inside the drawer.  With a
-prefix argument, this command calls `org-insert-property-drawer' and
-add a property drawer right below the current headline.  Completion
-over drawer keywords is also possible using .
+prefix argument, this command calls `org-insert-property-drawer' and add
+a property drawer right below the current headline.  Completion over
+drawer keywords is also possible using `M-'(1).
 
    Visibility cycling (*note Visibility cycling::) on the headline will
 hide and show the entry, but keep the drawer collapsed to a single
@@ -1579,6 +1555,11 @@ quick note in the LOGBOOK drawer, in a similar way to state changes, use
 export output.  Property drawers are not affected by this variable:
 configure `org-export-with-properties' instead.
 
+   ---------- Footnotes ----------
+
+   (1) Many desktops intercept `M-' to switch windows.  Use
+`C-M-i' or ` ' instead for completion (*note Completion::).
+
 
 File: org,  Node: Blocks,  Next: Footnotes,  Prev: Drawers,  Up: Document structure
 
@@ -1601,40 +1582,30 @@ File: org,  Node: Footnotes,  Next: Orgstruct mode,  Prev: Blocks,  Up: Document
 2.10 Footnotes
 ==============
 
-Org mode supports the creation of footnotes.  In contrast to the
-`footnote.el' package, Org mode's footnotes are designed for work on a
-larger document, not only for one-off documents like emails.
+Org mode supports the creation of footnotes.
 
    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:
+text.  Markers always start with `fn:'.  For example:
 
      The Org homepage[fn:1] now looks a lot better than it used to.
      ...
      [fn:1] The link is: http://orgmode.org
 
    Org mode extends the number-based syntax to _named_ footnotes and
-optional inline definition.  Using plain numbers as markers (as
-`footnote.el' does) is supported for backward compatibility, but not
-encouraged because of possible conflicts with LaTeX snippets (*note
-Embedded LaTeX::).  Here are the valid references:
-
-`[1]'
-     A plain numeric footnote marker.  Compatible with `footnote.el',
-     but not recommended because something like `[1]' could easily be
-     part of a code snippet.
+optional inline definition.  Here are the valid references:
 
 `[fn:name]'
      A named footnote reference, where `name' is a unique label word,
      or, for simplicity of automatic creation, a number.
 
-`[fn:: This is the inline definition of this footnote]'
+`[fn::This is the inline definition of this footnote]'
      A LaTeX-like anonymous footnote where the definition is given
      directly at the reference point.
 
-`[fn:name: a definition]'
+`[fn:name:a definition]'
      An inline definition of a footnote, which also specifies a name
      for the note.  Since Org allows multiple references to the same
      note, you can then use `[fn:name]' to create additional references.
@@ -1672,9 +1643,7 @@ The following command handles footnotes:
           S   Short for first `r', then `s' action.
           n   Normalize the footnotes by collecting all definitions (including
               inline definitions) into a special section, and then numbering them
-              in sequence.  The references will then also be numbers.  This is
-              meant to be the final step before finishing a document (e.g., sending
-              off an email).
+              in sequence.  The references will then also be numbers.
           d   Delete the footnote at point, and all definitions of and references
               to it.
      Depending on the variable `org-footnote-auto-adjust'(2),
@@ -1696,9 +1665,8 @@ The following command handles footnotes:
 
 `C-c ''
      Edit the footnote definition corresponding to the reference at
-     point in a seperate window.  This may be useful if editing
-     footnotes in a narrowed buffer.  The window can be closed by
-     pressing `C-c ''.
+     point in a seperate window.  The window can be closed by pressing
+     `C-c ''.
 
 
    ---------- Footnotes ----------
@@ -1767,6 +1735,8 @@ 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.
 
+   You can check syntax in your documents using `org-lint' command.
+
 
 File: org,  Node: Tables,  Next: Hyperlinks,  Prev: Document structure,  Up: Top
 
@@ -1850,7 +1820,7 @@ Re-aligning and field motion
 `C-c SPC     (`org-table-blank-field')'
      Blank the field at point.  
 
-`     (`org-table-next-field')'
+`TAB     (`org-table-next-field')'
      Re-align the table, move to the next field.  Creates a new row if
      necessary.  
 
@@ -2028,7 +1998,7 @@ fraction of number-like versus non-number fields in the column.
    Sometimes a single field or a few fields need to carry more text,
 leading to inconveniently wide columns.  Or maybe you want to make a
 table with several columns having a fixed width, regardless of content.
-To set(1) the width of a column, one field anywhere in the column may
+To set the width of a column, one field anywhere in the column may
 contain just the string `' where `N' is an integer specifying the
 width of the column in characters.  The next re-align will then set the
 width of this column to this value.
@@ -2059,18 +2029,16 @@ a per-file basis with:
      #+STARTUP: noalign
 
    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
-`', `'(2) or `' in a similar fashion.  You may also combine
-alignment and field width like this: `'.
+columns to the right and of string-rich columns to the left, you can
+use `', `'(1) or `' in a similar fashion.  You may also
+combine alignment and field width like this: `'.
 
    Lines which only contain these formatting cookies will be removed
 automatically when exporting the document.
 
    ---------- Footnotes ----------
 
-   (1) This feature does not work on XEmacs.
-
-   (2) Centering does not work inside Emacs, but it does have an effect
+   (1) Centering does not work inside Emacs, but it does have an effect
 when exporting to HTML.
 
 
@@ -2086,7 +2054,7 @@ of columns, much like horizontal lines can do for groups of rows.  In
 order to specify column groups, you can use a special row where the
 first field contains only `/'.  The further fields can either contain
 `<' to indicate that this column should start a group, `>' to indicate
-the end of a column, or `<>' (no space between `<' and `>') to make a
+the end of a group, or `<>' (no space between `<' and `>') to make a
 column a group of its own.  Boundaries between column groups will upon
 export be marked with vertical lines.  Here is an example:
 
@@ -2715,7 +2683,7 @@ configure the option `org-table-use-standard-references'.
           Emacs Lisp mode.  
 
     `M-     (`lisp-complete-symbol')'
-          Complete Lisp symbols, just like in Emacs Lisp mode.  
+          Complete Lisp symbols, just like in Emacs Lisp mode.(1) 
 
     `S-///'
           Shift the reference at point.  For example, if the reference
@@ -2787,6 +2755,11 @@ turn on formula debugging in the `Tbl' menu and repeat the calculation,
 for example by pressing `C-u C-u C-c = ' in a field.  Detailed
 information will be displayed.
 
+   ---------- Footnotes ----------
+
+   (1) Many desktops intercept `M-' to switch windows.  Use
+`C-M-i' or ` ' instead for completion (*note Completion::).
+
 
 File: org,  Node: Updating the table,  Next: Advanced features,  Prev: Editing and debugging formulas,  Up: The spreadsheet
 
@@ -3207,8 +3180,6 @@ the colon.  The following list shows examples for each link type.
      file:projects.org::some words             text search in Org file(1)
      file:projects.org::*task title heading search in Org
      file(2)
-     file+sys:/path/to/file                    open via OS, like double-click
-     file+emacs:/path/to/file                  force opening by Emacs
      docview:papers/last.pdf::NNN              open in doc-view mode at page
      id:B7423F4D-2E8A-471B-8810-C40F074717E9   Link to heading by ID
      news:comp.emacs                           Usenet link
@@ -3268,7 +3239,7 @@ the value is `query-to-create', then an exact headline will be
 searched; if it is not found, then the user will be queried to create
 it.
 
-   (2)  Headline searches always match the exact headline, ignoring
+   (2) Headline searches always match the exact headline, ignoring
 spaces and cookies.  If the headline is not found and the value of the
 option `org-link-search-must-match-exact-headline' is `query-to-create',
 then the user will be queried to create it.
@@ -3297,7 +3268,7 @@ it into an Org file, and to follow the link.
      If the headline has a `CUSTOM_ID' property, a link to this custom
      ID will be stored.  In addition or alternatively (depending on the
      value of `org-id-link-to-org-use-id'), a globally unique `ID'
-     property will be created and/or used to construct a link(2). So
+     property will be created and/or used to construct a link(2).  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
@@ -3310,7 +3281,7 @@ it into an Org file, and to follow the link.
      group.  The description is constructed from the author and the
      subject.
 
-     Web browsers: W3 and W3M
+     Web browsers: Eww, W3 and W3M
      Here the link will be the current URL, with the page title as
      description.
 
@@ -3401,8 +3372,8 @@ it into an Org file, and to follow the link.
 
 `mouse-2'
 `mouse-1'
-     On links, `mouse-2' will open the link just as `C-c C-o' would.
-     Under Emacs 22 and later, `mouse-1' will also follow a link.  
+     On links, `mouse-1' and `mouse-2' will open the link just as `C-c
+     C-o' would.  
 
 `mouse-3'
      Like `mouse-2', but force file links to be opened with Emacs, and
@@ -3446,7 +3417,7 @@ in the headline.
 
    (2) The library `org-id.el' must first be loaded, either through
 `org-customize' by enabling `org-id' in `org-modules', or by adding
-`(require 'org-id)' in your `.emacs'.
+`(require 'org-id)' in your Emacs init file.
 
    (3) Note that you don't have to use this command to insert a link.
 Links in Org are plain text, and you can type or paste them straight
@@ -3459,8 +3430,8 @@ the list of stored links.  To keep it in the list later use, use a
 triple `C-u' prefix argument to `C-c C-l', or configure the option
 `org-keep-stored-link-after-insertion'.
 
-   (5) This works by calling a special function
-`org-PREFIX-complete-link'.
+   (5) This works if a completion function is defined in the
+`:complete' property of a link in `org-link-parameters'.
 
    (6) See the option `org-display-internal-link-with-indirect-buffer'
 
@@ -3512,8 +3483,8 @@ tag (see the example above, where we need to encode the URL parameter.)
 Using `%(my-function)' will pass the tag to a custom function, and
 replace it by the resulting string.
 
-   If the replacement text doesn't contain any specifier, it will simply
-be appended to the string in order to create the link.
+   If the replacement text doesn't contain any specifier, the tag will
+simply be appended in order to create the link.
 
    Instead of a string, you may also specify a function that will be
 called with the tag as the only argument to create the link.
@@ -3533,10 +3504,13 @@ can define them in the file with
      #+LINK: google    http://www.google.com/search?q=%s
 
 In-buffer completion (*note Completion::) can be used after `[' to
-complete link abbreviations.  You may also define a function
-`org-PREFIX-complete-link' that implements special (e.g., completion)
-support for inserting such a link with `C-c C-l'.  Such a function
-should not accept any arguments, and return the full link with prefix.
+complete link abbreviations.  You may also define a function that
+implements special (e.g., completion) support for inserting such a link
+with `C-c C-l'.  Such a function should not accept any arguments, and
+return the full link with prefix.  You can add a completion function to
+a link like this:
+
+     (org-link-set-parameters ``type'' :complete #'some-function)
 
 
 File: org,  Node: Search options,  Next: Custom searches,  Prev: Link abbreviations,  Up: Hyperlinks
@@ -3669,9 +3643,8 @@ The most important commands to work with TODO entries are:
      the fast selection interface; this is the default behavior when
      `org-use-fast-todo-selection' is non-`nil'.
 
-     The same rotation can also be done "remotely" from the timeline
-     and agenda buffers with the `t' command key (*note Agenda
-     commands::).
+     The same rotation can also be done "remotely" from agenda buffers
+     with the `t' command key (*note Agenda commands::).
 
 `C-u C-c C-t'
      When TODO keywords have no selection keys, select a specific
@@ -3798,8 +3771,7 @@ the global TODO list: `C-3 C-c a t'.
 
    ---------- Footnotes ----------
 
-   (1) This is also true for the `t' command in the timeline and agenda
-buffers.
+   (1) This is also true for the `t' command in the agenda buffers.
 
 
 File: org,  Node: Multiple sets in one file,  Next: Fast access to TODO states,  Prev: TODO types,  Up: TODO extensions
@@ -4039,11 +4011,6 @@ note along with the timestamp, use(2)
 You will then be prompted for a note, and that note will be stored below
 the entry with a `Closing Note' heading.
 
-   In the timeline (*note Timeline::) and in the agenda (*note
-Weekly/daily agenda::), you can then use the `l' key to display the
-TODO items with a `CLOSED' timestamp on each day, giving you an
-overview of what has been done.
-
    ---------- Footnotes ----------
 
    (1) The corresponding in-buffer setting is: `#+STARTUP: logdone'
@@ -4260,8 +4227,7 @@ be TODO items.
      command prompts for a priority character `A', `B' or `C'.  When
      you press  instead, the priority cookie is removed from the
      headline.  The priorities can also be changed "remotely" from the
-     timeline and agenda buffer with the `,' command (*note Agenda
-     commands::).  
+     agenda buffer with the `,' command (*note Agenda commands::).  
 
 `S-     (`org-priority-up')'
 `S-     (`org-priority-down')'
@@ -4403,9 +4369,10 @@ The following commands work with checkboxes:
           the first.  With a prefix arg, add or remove the checkbox for
           all items in the region.
 
-        - If the cursor is in a headline, toggle checkboxes in the
-          region between this headline and the next (so _not_ the
-          entire subtree).
+        - If the cursor is in a headline, toggle the state of the first
+          checkbox in the region between this headline and the next--so
+          _not_ the entire subtree--and propagate this new state to all
+          other checkboxes in the same area.
 
         - If there is no active region, just toggle the checkbox at
           point.
@@ -4440,8 +4407,8 @@ by modifying `org-list-automatic-rules' accordingly.
 want such cookies to count all checkboxes below the cookie, not just
 those belonging to direct children.
 
-   (3) `C-u C-c C-c' on the _first_ item of a list with no checkbox
-will add checkboxes to the rest of the list.
+   (3) `C-u C-c C-c' before the _first_ bullet in a list with no
+checkbox will add checkboxes to the rest of the list.
 
 
 File: org,  Node: Tags,  Next: Properties and columns,  Prev: TODO items,  Up: Top
@@ -4485,9 +4452,9 @@ well.  For example, in the list
 
 the final heading will have the tags `:work:', `:boss:', `:notes:', and
 `:action:' even though the final heading is not explicitly marked with
-those tags.  You can also set tags that all entries in a file should
-inherit just as if these tags were defined in a hypothetical level zero
-that surrounds the entire file.  Use a line like this(1):
+all those tags.  You can also set tags that all entries in a file
+should inherit just as if these tags were defined in a hypothetical
+level zero that surrounds the entire file.  Use a line like this(1):
 
      #+FILETAGS: :Peter:Boss:Secret:
 
@@ -4567,11 +4534,11 @@ by adding a STARTUP option line to that file:
 facilities for entering tags.  However, it also implements another,
 quicker, tag selection method called _fast tag selection_.  This allows
 you to select and deselect tags with just a single key press.  For this
-to work well you should assign unique letters to most of your commonly
-used tags.  You can do this globally by configuring the variable
-`org-tag-alist' in your `.emacs' file.  For example, you may find the
-need to tag many items in different files with `:@home:'.  In this case
-you can set something like:
+to work well you should assign unique, case-sensitive, letters to most
+of your commonly used tags.  You can do this globally by configuring
+the variable `org-tag-alist' in your Emacs init file.  For example, you
+may find the need to tag many items in different files with `:@home:'.
+In this case you can set something like:
 
      (setq org-tag-alist '(("@work" . ?w) ("@home" . ?h) ("laptop" . ?l)))
 
@@ -4617,14 +4584,13 @@ configuration:
    If at least one tag has a selection key then pressing `C-c C-c' will
 automatically present you with a special interface, listing inherited
 tags, the tags of the current headline, and a list of all valid tags
-with corresponding keys(1).  In this interface, you can use the
-following keys:
+with corresponding keys(1).
+
+   Pressing keys assigned to tags will add or remove them from the list
+of tags in the current line.  Selecting a tag in a group of mutually
+exclusive tags will turn off any other tags from that group.
 
-`a-z...'
-     Pressing keys assigned to tags will add or remove them from the
-     list of tags in the current line.  Selecting a tag in a group of
-     mutually exclusive tags will turn off any other tags from that
-     group.  
+   In this interface, you can also use the following special keys:
 
 `'
      Enter a tag in the minibuffer, even if the tag is not in the
@@ -4633,7 +4599,7 @@ following keys:
      with a comma.
 
 `'
-     Clear all tags for this line.  
+     Clear all tags for this line.
 
 `'
      Accept the modified set.
@@ -4691,9 +4657,9 @@ them creates a tag hierarchy.
 used to classify nodes in a document or set of documents.
 
    When you search for a group tag, it will return matches for all
-members in the group and its subgroup.  In an agenda view, filtering by
-a group tag will display or hide headlines tagged with at least one of
-the members of the group or any of its subgroups.  This makes tag
+members in the group and its subgroups.  In an agenda view, filtering
+by a group tag will display or hide headlines tagged with at least one
+of the members of the group or any of its subgroups.  This makes tag
 searches and filters even more flexible.
 
    You can set group tags by using brackets and inserting a colon
@@ -4747,21 +4713,20 @@ using curly brackets.
 instead of `:startgrouptag' & `:endgrouptag' to make the tags mutually
 exclusive.
 
-   Furthermore; The members of a _group tag_ can also be regular
-expression, creating the possibility of more dynamic and rule-based
-tag-structure.  The regular expressions in the group must be marked up
-within { }.  Example use, to expand on the example given above:
+   Furthermore, the members of a _group tag_ can also be regular
+expressions, creating the possibility of a more dynamic and rule-based
+tag structure.  The regular expressions in the group must be specified
+within { }.  Here is an expanded example:
 
-     #+TAGS: [ Vision : {V.+} ]
-     #+TAGS: [ Goal : {G.+} ]
-     #+TAGS: [ AOF : {AOF.+} ]
-     #+TAGS: [ Project : {P.+} ]
+     #+TAGS: [ Vision : {V@.+} ]
+     #+TAGS: [ Goal : {G@.+} ]
+     #+TAGS: [ AOF : {AOF@.+} ]
+     #+TAGS: [ Project : {P@.+} ]
 
    Searching for the tag `Project' will now list all tags also including
-regular expression matches for `P@.+'.  Similar for tag-searches on
-`Vision', `Goal' and `AOF'.  This can be good for example if tags for a
-certain project is tagged with a common project-identifier, i.e.
-`P@2014_OrgTags'.
+regular expression matches for `P@.+', and similarly for tag searches on
+`Vision', `Goal' and `AOF'.  For example, this would work well for a
+project tagged with a common project-identifier, e.g. `P@2014_OrgTags'.
 
    If you want to ignore group tags temporarily, toggle group tags
 support with `org-toggle-tags-groups', bound to `C-c C-x q'.  If you
@@ -4794,10 +4759,10 @@ information into special lists.
    These commands all prompt for a match string which allows basic
 Boolean logic like `+boss+urgent-project1', to find entries with tags
 `boss' and `urgent', but not `project1', or `Kathy|Sally' to find
-entries which are tagged, like `Kathy' or `Sally'.  The full syntax of
-the search string is rich and allows also matching against TODO
-keywords, entry levels and properties.  For a complete description with
-many examples, see *note Matching tags and properties::.
+entries tagged as `Kathy' or `Sally'.  The full syntax of the search
+string is rich and allows also matching against TODO keywords, entry
+levels and properties.  For a complete description with many examples,
+see *note Matching tags and properties::.
 
 
 File: org,  Node: Properties and columns,  Next: Dates and times,  Prev: Tags,  Up: Top
@@ -4970,7 +4935,7 @@ used as keys in the properties drawer:
      CLOSED       When was this entry closed?
      DEADLINE     The deadline time string, without the angular brackets.
      FILE         The filename the entry is located in.
-     ITEM         The headline of the entry, with stars.
+     ITEM         The headline of the entry.
      PRIORITY     The priority of the entry, a string with a single letter.
      SCHEDULED    The scheduling timestamp, without the angular brackets.
      TAGS         The tags defined directly in the headline.
@@ -5143,30 +5108,28 @@ optional.  The individual parts have the following meaning:
      TITLE           The header text for the column.  If omitted, the property
                      name is used.
      {SUMMARY-TYPE}  The summary type.  If specified, the column values for
-                     parent nodes are computed from the children.
+                     parent nodes are computed from the children(1).
                      Supported summary types are:
                      {+}       Sum numbers in this column.
                      {+;%.1f}  Like `+', but format result with `%.1f'.
                      {$}       Currency, short for `+;%.2f'.
-                     {:}       Sum times, HH:MM, plain numbers are hours.
-                     {X}       Checkbox status, `[X]' if all children are `[X]'.
-                     {X/}      Checkbox status, `[n/m]'.
-                     {X%}      Checkbox status, `[n%]'.
                      {min}     Smallest number in column.
                      {max}     Largest number.
                      {mean}    Arithmetic mean of numbers.
+                     {X}       Checkbox status, `[X]' if all children are `[X]'.
+                     {X/}      Checkbox status, `[n/m]'.
+                     {X%}      Checkbox status, `[n%]'.
+                     {:}       Sum times, HH:MM, plain numbers are
+                     hours(2).
                      {:min}    Smallest time value in column.
                      {:max}    Largest time value.
                      {:mean}   Arithmetic mean of time values.
-                     {@min}    Minimum age (in days/hours/mins/seconds).
+                     {@min}    Minimum age(3) (in
+                     days/hours/mins/seconds).
                      {@max}    Maximum age (in days/hours/mins/seconds).
                      {@mean}   Arithmetic mean of ages (in days/hours/mins/seconds).
                      {est+}    Add `low-high' estimates.
 
-Be aware that you can only have one summary type for any property you
-include.  Subsequent columns referencing the same property will all
-display the same summary information.
-
    The `est+' summary type requires further explanation.  It is used for
 combining estimates, expressed as `low-high' ranges or plain numbers.
 For example, instead of estimating a particular task will take 5 days,
@@ -5188,10 +5151,13 @@ days.
    Numbers are right-aligned when a format specifier with an explicit
 width like `%5d' or `%5.1f' is used.
 
+   You can also define custom summary types by setting
+`org-columns-summary-types', which see.
+
    Here is an example for a complete columns definition, along with
 allowed values.
 
-     :COLUMNS:  %25ITEM %9Approved(Approved?){X} %Owner %11Status \(1)
+     :COLUMNS:  %25ITEM %9Approved(Approved?){X} %Owner %11Status \(4)
                         %10Time_Estimate{:} %CLOCKSUM %CLOCKSUM_T
      :Owner_ALL:    Tammy Mark Karl Lisa Don
      :Status_ALL:   "In progress" "Not started yet" "Finished" ""
@@ -5214,7 +5180,22 @@ either for all clocks or just for today.
 
    ---------- Footnotes ----------
 
-   (1) Please note that the COLUMNS definition must be on a single
+   (1) If                 more than one summary type apply to the
+property, the parent                 values are computed according to
+the first of them.
+
+   (2) A time can also be a duration, using effort
+modifiers defined in `org-effort-durations', e.g.,                 `3d
+1h'.  If any value in the column is as such, the
+summary will also be an effort duration.
+
+   (3) An age is defined as                 a duration since a given
+time-stamp (*note Timestamps::).  It                 can  also be
+expressed as days, hours, minutes and seconds,
+identified by `d', `h', `m' and `s'                 suffixes, all
+mandatory, e.g., `0d 13h 0m 10s'.
+
+   (4) Please note that the COLUMNS definition must be on a single
 line--it is wrapped here only because of formatting constraints.
 
 
@@ -5228,14 +5209,15 @@ Turning column view on and off
 
 `C-c C-x C-c     (`org-columns')'
      Turn on column view.  If the cursor is before the first headline
-     in the file, column view is turned on for the entire file, using
-     the `#+COLUMNS' definition.  If the cursor is somewhere inside the
+     in the file, or the function called with the universal prefix
+     argument, column view is turned on for the entire file, using the
+     `#+COLUMNS' definition.  If the cursor is somewhere inside the
      outline, this command searches the hierarchy, up from point, for a
      `:COLUMNS:' property that defines a format.  When one is found,
      the column view table is established for the tree starting at the
      entry that contains the `:COLUMNS:' property.  If no such property
-     is found, the format is taken from the `#+COLUMNS' line or from
-     the variable `org-columns-default-format', and column view is
+     is found, the format is taken from the `#+COLUMNS' line or from the
+     variable `org-columns-default-format', and column view is
      established for the current entry and its subtree.  
 
 `r     (`org-columns-redo')'
@@ -5343,6 +5325,9 @@ This dynamic block has the following parameters:
      When set to `t', skip rows where the only non-empty specifier of
      the column view is `ITEM'.
 
+`:indent'
+     When non-`nil', indent each `ITEM' field according to its level.
+
 
 The following commands insert or update the dynamic block:
 
@@ -5425,9 +5410,8 @@ agenda (*note Weekly/daily agenda::).  We distinguish:
 PLAIN TIMESTAMP; EVENT; APPOINTMENT
      A simple timestamp just assigns a date/time to an item.  This is
      just like writing down an appointment or event in a paper agenda.
-     In the timeline and agenda displays, the headline of an entry
-     associated with a plain timestamp will be shown exactly on that
-     date.
+     In the agenda display, the headline of an entry associated with a
+     plain timestamp will be shown exactly on that date.
 
           * Meet Peter at the movies
             <2006-11-01 Wed 19:15>
@@ -5597,7 +5581,7 @@ in bold.
      sep 12 9      => 2009-09-12
      12:45         => 2006-06-13 12:45
      22 sept 0:34  => 2006-09-22 00:34
-     w4            => ISO week for of the current year 2006
+     w4            => ISO week four of the current year 2006
      2012 w4 fri   => Friday of ISO week 4 in 2012
      2012-w04-5    => Same as above
 
@@ -5715,7 +5699,9 @@ File: org,  Node: Deadlines and scheduling,  Next: Clocking work time,  Prev: Cr
 8.3 Deadlines and scheduling
 ============================
 
-A timestamp may be preceded by special keywords to facilitate planning:
+A timestamp may be preceded by special keywords to facilitate planning.
+Both the timestamp and the keyword have to be positioned immediatly
+after the task they refer to.
 
 DEADLINE
      Meaning: the task (most likely a TODO item, though not
@@ -5793,23 +5779,21 @@ File: org,  Node: Inserting deadline/schedule,  Next: Repeated tasks,  Up: Deadl
 8.3.1 Inserting deadlines or schedules
 --------------------------------------
 
-The following commands allow you to quickly insert(1) a deadline or to
+The following commands allow you to quickly insert a deadline or to
 schedule an item:
 
 `C-c C-d     (`org-deadline')'
-     Insert `DEADLINE' keyword along with a stamp.  The insertion will
-     happen in the line directly following the headline.  Any CLOSED
+     Insert `DEADLINE' keyword along with a stamp.  Any CLOSED
      timestamp will be removed.  When called with a prefix arg, an
      existing deadline will be removed from the entry.  Depending on
-     the variable `org-log-redeadline'(2), a note will be taken when
+     the variable `org-log-redeadline'(1), a note will be taken when
      changing an existing deadline.
 
 `C-c C-s     (`org-schedule')'
-     Insert `SCHEDULED' keyword along with a stamp.  The insertion will
-     happen in the line directly following the headline.  Any CLOSED
+     Insert `SCHEDULED' keyword along with a stamp.  Any CLOSED
      timestamp will be removed.  When called with a prefix argument,
      remove the scheduling date from the entry.  Depending on the
-     variable `org-log-reschedule'(3), a note will be taken when
+     variable `org-log-reschedule'(2), a note will be taken when
      changing an existing scheduling time.  
 
 `C-c / d     (`org-check-deadlines')'
@@ -5832,14 +5816,10 @@ before any current timestamp.
 
    ---------- Footnotes ----------
 
-   (1) The `SCHEDULED' and `DEADLINE' dates are inserted on the line
-right below the headline.  Don't put any text between this line and the
-headline.
-
-   (2) with corresponding `#+STARTUP' keywords `logredeadline',
+   (1) with corresponding `#+STARTUP' keywords `logredeadline',
 `lognoteredeadline', and `nologredeadline'
 
-   (3) with corresponding `#+STARTUP' keywords `logreschedule',
+   (2) with corresponding `#+STARTUP' keywords `logreschedule',
 `lognotereschedule', and `nologreschedule'
 
 
@@ -5902,6 +5882,13 @@ repeaters  `++' and `.+'.  For example:
         but also by as many weeks as it takes to get this date into
         the future.  However, it stays on a Sunday, even if you called
         and marked it done on Saturday.
+     ** TODO Empty kitchen trash
+        DEADLINE: <2008-02-08 Fri 20:00 ++1d>
+        Marking this DONE will shift the date by at least one day, and
+        also by as many days as it takes to get the timestamp into the
+        future.  Since there is a time in the timestamp, the next
+        deadline in the future will be on today's date if you
+        complete the task before 20:00.
      ** TODO Check the batteries in the smoke detectors
         DEADLINE: <2005-11-01 Tue .+1m>
         Marking this DONE will shift the date to one month after
@@ -5911,9 +5898,11 @@ repeaters  `++' and `.+'.  For example:
 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 `org-agenda-skip-scheduled-if-deadline-is-shown' to
-`repeated-after-deadline'.  If you want both scheduling and deadline
-information to repeat after the same interval, set the same repeater
-for both timestamps.
+`repeated-after-deadline'.  However, any scheduling information without
+a repeater is no longer relevant once the task is done, and thus,
+removed upon repeating the task.  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 `C-c
@@ -6056,12 +6045,12 @@ File: org,  Node: Clocking commands,  Next: The clock table,  Up: Clocking work
      but the overlays disappear when you change the buffer (see
      variable `org-remove-highlights-with-change') or press `C-c C-c'.
 
-   The `l' key may be used in the timeline (*note Timeline::) and in
-the agenda (*note Weekly/daily agenda::) to show which tasks have been
-worked on or closed during a day.
+   The `l' key may be used the agenda (*note Weekly/daily agenda::) to
+show which tasks have been worked on or closed during a day.
 
    *Important:* note that both `org-clock-out' and `org-clock-in-last'
-can have a global keybinding and will not modify the window disposition.
+can have a global key binding and will not modify the window
+disposition.
 
    ---------- Footnotes ----------
 
@@ -6129,6 +6118,7 @@ selected:
                   tree       the surrounding level 1 tree
                   agenda     all agenda files
                   ("file"..) scan these files
+                  function   the list of files returned by a function of no argument
                   file-with-archives    current file and its archives
                   agenda-with-archives  all agenda files, including archives
      :block       The time block to consider.  This block is specified either
@@ -6380,9 +6370,9 @@ File: org,  Node: Timers,  Prev: Effort estimates,  Up: Dates and times
 8.6 Taking notes with a timer
 =============================
 
-Org provides provides two types of timers.  There is a relative timer
-that counts up, which can be useful when taking notes during, for
-example, a meeting or a video viewing.  There is also a countdown timer.
+Org provides two types of timers.  There is a relative timer that
+counts up, which can be useful when taking notes during, for example, a
+meeting or a video viewing.  There is also a countdown timer.
 
    The relative and countdown are started with separate commands.
 
@@ -6398,9 +6388,9 @@ example, a meeting or a video viewing.  There is also a countdown timer.
 
 `C-c C-x ;     (`org-timer-set-timer')'
      Start a countdown timer.  The user is prompted for a duration.
-     `org-timer-default-timer' sets the default countdown value.
-     Giving a prefix numeric argument overrides this default value.
-     This command is available as `;' in agenda buffers.
+     `org-timer-default-timer' sets the default countdown value.  Giving
+     a numeric prefix argument overrides this default value.  This
+     command is available as `;' in agenda buffers.
 
    Once started, relative and countdown timers are controlled with the
 same commands.
@@ -6420,7 +6410,7 @@ same commands.
      Once the timer list is started, you can also use `M-' to
      insert new timer items.  
 
-`C-c C-x \     (`org-timer-pause-or-continue')'
+`C-c C-x ,     (`org-timer-pause-or-continue')'
      Pause the timer, or continue it if it is already paused.  
 
 `C-c C-x _     (`org-timer-stop')'
@@ -6500,7 +6490,7 @@ File: org,  Node: Using capture,  Next: Capture templates,  Prev: Setting up cap
 -------------------
 
 `C-c c     (`org-capture')'
-     Call the command `org-capture'.  Note that this keybinding is
+     Call the command `org-capture'.  Note that this key binding is
      global and not active by default: you need to install it.  If you
      have templates defined *note Capture templates::, it will offer
      these templates for selection or use a new Org outline node as the
@@ -6573,7 +6563,7 @@ configuration would look like:
      (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")
+        ("j" "Journal" entry (file+olp+datetree "~/org/journal.org")
              "* %?\nEntered on %U\n  %i\n  %a")))
 
 If you then press `C-c c t', Org will prepare the template for you like
@@ -6655,7 +6645,9 @@ TARGET
      list in the body of this node.  Most target specifications contain
      a file name.  If that file name is the empty string, it defaults
      to `org-default-notes-file'.  A file can also be given as a
-     variable, function, or Emacs Lisp form.
+     variable or as a function called with no argument.  When an
+     absolute path is not specified for a target, it is taken as
+     relative to `org-directory'.
 
      Valid values are:
 
@@ -6675,12 +6667,12 @@ TARGET
     `(file+regexp  "path/to/file" "regexp to find location")'
           Use a regular expression to position the cursor.
 
-    `(file+datetree "path/to/file")'
-          Will create a heading in a date tree for today's date(1).
-
-    `(file+datetree+prompt "path/to/file")'
-          Will create a heading in a date tree, but will prompt for the
-          date.
+    `(file+olp+datetree "path/to/file" [ "Level 1 heading" ....])'
+          This target(1) will create a heading in a date tree(2) for
+          today's date.  If the optional outline path is given, the
+          tree will be built under the node it is pointing to, instead
+          of at top level.  Check out the `:time-prompt' and
+          `:tree-type' properties below for additional options.
 
     `(file+function "path/to/file" function-finding-location)'
           A function to find the right location in the file.
@@ -6689,8 +6681,8 @@ TARGET
           File to the entry that is currently being clocked.
 
     `(function function-finding-location)'
-          Most general way, write your own function to find both file
-          and location.
+          Most general way: write your own function which both visits
+          the file and moves point to the right location.
 
 TEMPLATE
      The template for creating the capture item.  If you leave this
@@ -6731,6 +6723,18 @@ PROPERTIES
           setting both to `t', the current clock will run and the
           previous one will not be resumed.
 
+    `:time-prompt'
+          Prompt for a date/time to be used for date/week trees and
+          when filling the template.  Without this property, capture
+          uses the current date and time.  Even if this property has
+          not been set, you can force the same behavior by calling
+          `org-capture' with a `C-1' prefix argument.
+
+    `:tree-type'
+          When `week', make a week tree instead of the month tree, i.e.
+          place the headings for each day under a heading with the
+          current iso week.
+
     `:unnarrowed'
           Do not narrow the target buffer, simply show the full buffer.
           Default is to narrow it so that you only see the new material.
@@ -6748,9 +6752,15 @@ PROPERTIES
 
    ---------- Footnotes ----------
 
-   (1) Datetree headlines for years accept tags, so if you use both `*
-2013 :noexport:' and `* 2013' in your file, the capture will refile the
-note to the first one matched.
+   (1) Org used to offer four different targets for date/week tree
+capture.  Now, Org automatically translates these to use
+`file+olp+datetree', applying the `:time-prompt' and `:tree-type'
+properties.  Please rewrite your date/week-tree targets using
+`file+olp+datetree' since the older targets are now deprecated.
+
+   (2) A date tree is an outline structure with years on the highest
+level, months or ISO-weeks as sublevels and then dates on the lowest
+level.  Tags are allowed in the tree structure.
 
 
 File: org,  Node: Template expansion,  Next: Templates in contexts,  Prev: Template elements,  Up: Capture templates
@@ -6795,7 +6805,7 @@ of content.  The templates are expanded in the order given here:
                  You may specify a default value and a completion table with
                  %^{prompt|default|completion2|completion3...}.
                  The arrow keys access a prompt-specific history.
-     %\\n        Insert the text entered at the nth %^{PROMPT}, where `n' is
+     %\1 ... %\N Insert the text entered at the Nth %^{PROMPT}, where `N' is
                  a number, starting from 1.
      %?          After completing the template, position cursor here.
 
@@ -6805,15 +6815,15 @@ For specific link types, the following keywords will be defined(2):
      ---------------------------------+----------------------------------------------
      bbdb                             |  %:name %:company
      irc                              |  %:server %:port %:nick
-     vm, vm-imap, wl, mh, mew, rmail  |  %:type %:subject %:message-id
-                                      |  %:from %:fromname %:fromaddress
+     vm, vm-imap, wl, mh, mew, rmail, |  %:type %:subject %:message-id
+     gnus, notmuch                    |  %:from %:fromname %:fromaddress
                                       |  %:to   %:toname   %:toaddress
                                       |  %:date (message date header field)
                                       |  %:date-timestamp (date as active timestamp)
                                       |  %:date-timestamp-inactive (date as inactive timestamp)
                                       |  %:fromto (either "to NAME" or "from NAME")(3)
      gnus                             |  %:group, for messages also all email fields
-     w3, w3m                          |  %:url
+     eww, w3, w3m                     |  %:url
      info                             |  %:file %:node
      calendar                         |  %:date
 
@@ -6897,6 +6907,9 @@ The following commands deal with attachments:
           Attach a file using the copy/move/link method.  Note that
           hard links are not supported on all systems.
 
+    `u     (`org-attach-url')'
+          Attach a file from URL
+
     `n     (`org-attach-new')'
           Create a new attachment as an Emacs buffer.
 
@@ -7129,11 +7142,12 @@ File: org,  Node: Internal archiving,  Prev: Moving subtrees,  Up: Archiving
 9.6.2 Internal archiving
 ------------------------
 
-If you want to just switch off (for agenda views) certain subtrees
-without moving them to a different file, you can use the `ARCHIVE tag'.
+If you want to just switch off--for agenda views--certain subtrees
+without moving them to a different file, you can use the archive tag.
 
-   A headline that is marked with the ARCHIVE tag (*note Tags::) stays
-at its location in the outline tree, but behaves in the following way:
+   A headline that is marked with the `:ARCHIVE:' tag (*note Tags::)
+stays at its location in the outline tree, but behaves in the following
+way:
    - It does not open when you attempt to do so with a visibility
      cycling command (*note Visibility cycling::).  You can force
      cycling archived subtrees with `C-', or by setting the option
@@ -7194,7 +7208,7 @@ important for a particular date, this information must be collected,
 sorted and displayed in an organized way.
 
    Org can select items based on various criteria and display them in a
-separate buffer.  Seven different view types are provided:
+separate buffer.  Six different view types are provided:
 
    * an _agenda_ that is like a calendar and shows information for
      specific dates,
@@ -7204,9 +7218,6 @@ separate buffer.  Seven different view types are provided:
    * a _match view_, showings headlines based on the tags, properties,
      and TODO state associated with them,
 
-   * a _timeline view_ that shows all events in a single Org file, in
-     time-sorted view,
-
    * a _text search view_ that shows all entries from multiple files
      that contain specified keywords,
 
@@ -7221,6 +7232,11 @@ This buffer is read-only, but provides commands to visit the
 corresponding locations in the original Org files, and even to edit
 these files remotely.
 
+   By default, the report ignores commented (*note Comment lines::) and
+archived (*note Internal archiving::) entries.  You can override this
+by setting `org-agenda-skip-comment-trees' and
+`org-agenda-skip-archived-trees' to `nil'.
+
    Two variables control how the agenda buffer is displayed and whether
 the window configuration is restored when the agenda exits:
 `org-agenda-window-setup' and `org-agenda-restore-windows-after-quit'.
@@ -7335,9 +7351,6 @@ dispatcher offers the following default commands:
      Create a list of headlines matching a TAGS expression (*note
      Matching tags and properties::).
 
-`L'
-     Create the timeline view for the current buffer (*note Timeline::).
-
 `s'
      Create a list of entries selected by a boolean expression of
      keywords and/or regular expressions that must or must not occur in
@@ -7403,7 +7416,6 @@ In this section we describe the built-in views.
 * Weekly/daily agenda::         The calendar page with current tasks
 * Global TODO list::            All unfinished action items
 * Matching tags and properties::  Structured information with fine-tuned search
-* Timeline::                    Time-sorted view for single file
 * Search view::                 Find entries by searching for text
 * Stuck projects::              Find projects you need to review
 
@@ -7517,6 +7529,19 @@ updates its hash with anniversaries.  However, from then on things will
 be very fast--much faster in fact than a long list of
 `%%(diary-anniversary)' entries in an Org or Diary file.
 
+   If you would like to see upcoming anniversaries with a bit of
+forewarning, you can use the following instead:
+
+     * Anniversaries
+       :PROPERTIES:
+       :CATEGORY: Anniv
+       :END:
+     %%(org-bbdb-anniversaries-future 3)
+
+   That will give you three days' warning: on the anniversary date
+itself and the two days prior. The argument is optional: if omitted, it
+defaults to 7.
+
 Appointment reminders
 .....................
 
@@ -7593,7 +7618,7 @@ it more compact:
      the variable `org-agenda-todo-list-sublevels' to get this behavior.
 
 
-File: org,  Node: Matching tags and properties,  Next: Timeline,  Prev: Global TODO list,  Up: Built-in agenda views
+File: org,  Node: Matching tags and properties,  Next: Search view,  Prev: Global TODO list,  Up: Built-in agenda views
 
 10.3.3 Matching tags and properties
 -----------------------------------
@@ -7671,12 +7696,12 @@ properties::).  For example, the "property" `TODO' represents the TODO
 keyword of the entry and the "property" `PRIORITY' represents the
 PRIORITY keyword of the entry.
 
-   In addition to the *note Special properties::, one other "property"
-can also be used. `LEVEL' represents the level of an entry.  So a search
-`+LEVEL=3+boss-TODO="DONE"' lists all level three headlines that have
-the tag `boss' and are _not_ marked with the TODO keyword DONE.  In
-buffers with `org-odd-levels-only' set, `LEVEL' does not count the
-number of stars, but `LEVEL=2' will correspond to 3 stars etc.
+   In addition to the properties mentioned above, `LEVEL' represents the
+level of an entry.  So a search `+LEVEL=3+boss-TODO="DONE"' lists all
+level three headlines that have the tag `boss' and are _not_ marked
+with the TODO keyword DONE.  In buffers with `org-odd-levels-only' set,
+`LEVEL' does not count the number of stars, but `LEVEL=2' will
+correspond to 3 stars etc.
 
    Here are more examples:
 
@@ -7752,27 +7777,9 @@ a M' or `/!' will not match TODO keywords in a DONE state.  Examples:
      `NEXT'.
 
 
-File: org,  Node: Timeline,  Next: Search view,  Prev: Matching tags and properties,  Up: Built-in agenda views
-
-10.3.4 Timeline for a single file
----------------------------------
-
-The timeline summarizes all time-stamped items from a single Org mode
-file in a _time-sorted view_.  The main purpose of this command is to
-give an overview over events in a project.
-
-`C-c a L     (`org-timeline')'
-     Show a time-sorted view of the Org file, with all time-stamped
-     items.  When called with a `C-u' prefix, all unfinished TODO
-     entries (scheduled or not) are also listed under the current date.
-
-The commands available in the timeline buffer are listed in *note
-Agenda commands::.
-
-
-File: org,  Node: Search view,  Next: Stuck projects,  Prev: Timeline,  Up: Built-in agenda views
+File: org,  Node: Search view,  Next: Stuck projects,  Prev: Matching tags and properties,  Up: Built-in agenda views
 
-10.3.5 Search view
+10.3.4 Search view
 ------------------
 
 This agenda view is a general text search facility for Org mode entries.
@@ -7799,7 +7806,7 @@ search the files listed in `org-agenda-text-search-extra-files'.
 
 File: org,  Node: Stuck projects,  Prev: Search view,  Up: Built-in agenda views
 
-10.3.6 Stuck projects
+10.3.5 Stuck projects
 ---------------------
 
 If you are following a system like David Allen's GTD to organize your
@@ -7994,11 +8001,9 @@ Filtering in the agenda
      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 _do_ have the tag.  A second `/' at the
-     prompt will turn off the filter and unhide any hidden entries.  If
-     the first key you press is either `+' or `-', the previous filter
-     will be narrowed by requiring or forbidding the selected
-     additional tag.  Instead of pressing `+' or `-' after `/', you can
-     also immediately use the `\' command.
+     prompt will turn off the filter and unhide any hidden entries.
+     Pressing `+' or `-' switches between filtering and excluding the
+     next tag.
 
      Org also supports automatic, context-aware tag filtering.  If the
      variable `org-agenda-auto-exclude-function' is set to a
@@ -8023,13 +8028,6 @@ Filtering in the agenda
 
           (setq org-agenda-auto-exclude-function 'org-my-auto-exclude-function)
 
-`\     (`org-agenda-filter-by-tag-refine')'
-     Narrow the current agenda filter by an additional condition.  When
-     called with prefix arg, remove the entries that _do_ have the tag,
-     or that do match the effort criterion.  You can achieve the same
-     effect by pressing `+' or `-' as the first key after the `/'
-     command.
-
 `[ ] { }'
 
     in search view
@@ -8043,8 +8041,12 @@ Filtering in the agenda
 `<     (`org-agenda-filter-by-category')'
      Filter the current agenda view with respect to the category of the
      item at point.  Pressing `<' another time will remove this filter.
-     You can add a filter preset through the option
-     `org-agenda-category-filter-preset' (see below.)
+     When called with a prefix argument exclude the category of the
+     item at point from the agenda.
+
+     You can add a filter preset in custom agenda commands through the
+     option `org-agenda-category-filter-preset'.  *Note Setting
+     options::.
 
 `^     (`org-agenda-filter-by-top-headline')'
      Filter the current agenda view and only display the siblings and
@@ -8055,9 +8057,10 @@ Filtering in the agenda
      entries matching the regular expression the user entered.  When
      called with a prefix argument, it will filter _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
-     `org-agenda-category-filter-preset' (see below.)
+     remove all the regexp filters, which can be accumulated.
+
+     You can add a filter preset in custom agenda commands through the
+     option `org-agenda-regexp-filter-preset'.  *Note Setting options::.
 
 `_     (`org-agenda-filter-by-effort')'
      Filter the agenda view with respect to effort estimates.  You
@@ -8073,6 +8076,13 @@ Filtering in the agenda
      effort will be treated according to the value of
      `org-sort-agenda-noeffort-is-high'.
 
+     When called with a prefix argument, it will remove entries
+     matching the condition.  With two universal prefix arguments, it
+     will clear effort filters, which can be accumulated.
+
+     You can add a filter preset in custom agenda commands through the
+     option `org-agenda-effort-filter-preset'.  *Note Setting options::.
+
 `|     (`org-agenda-filter-remove-all')'
      Remove all filters in the current agenda view.
 
@@ -8163,8 +8173,7 @@ View/Go to Org file
 
 `  or  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.  
+     prefix arg, make sure that drawers stay folded.  
 
 `L     (`org-agenda-recenter')'
      Display original location and recenter that window.  
@@ -8258,7 +8267,7 @@ Change display
 
 `v [  or short  [     (`org-agenda-manipulate-query-add')'
      Include inactive timestamps into the current view.  Only for
-     weekly/daily agenda and timeline views.  
+     weekly/daily agenda.  
 
 `v a     (`org-agenda-archives-mode')'
 `v A     (`org-agenda-archives-mode 'files')'
@@ -8328,32 +8337,26 @@ Change display
 Secondary filtering and query editing
 .....................................
 
-     For a detailed description of these commands, see *note
+     For a detailed description of these commands, *note
      Filtering/limiting agenda items::.
 
 `/     (`org-agenda-filter-by-tag')'
      Filter the agenda view with respect to a tag and/or effort
      estimates.
 
-`\     (`org-agenda-filter-by-tag-refine')'
-     Narrow the current agenda filter by an additional condition.
-
 `<     (`org-agenda-filter-by-category')'
      Filter the current agenda view with respect to the category of the
-     item at point.  Pressing `<' another time will remove this filter.
+     item at point.
 
 `^     (`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.
 
 `=     (`org-agenda-filter-by-regexp')'
-     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 _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
-     `org-agenda-category-filter-preset' (see below.)
+     Filter the agenda view by a regular expression.
+
+`_     (`org-agenda-filter-by-effort')'
+     Filter the agenda view with respect to effort estimates.
 
 `|     (`org-agenda-filter-remove-all')'
      Remove all filters in the current agenda view.
@@ -8705,8 +8708,8 @@ buffer).
    Custom commands are configured in the variable
 `org-agenda-custom-commands'.  You can customize this variable, for
 example by pressing `C-c a C'.  You can also directly set it with Emacs
-Lisp in `.emacs'.  The following example contains all valid agenda
-views:
+Lisp in the Emacs init file.  The following example contains all valid
+agenda views:
 
      (setq org-agenda-custom-commands
            '(("x" agenda)
@@ -9035,8 +9038,8 @@ environment.  This causes the following issues:
      `org-agenda-overriding-columns-format' is currently set, and if
      so, takes the format from there.  Otherwise it takes the format
      associated with the first item in the agenda, or, if that item
-     does not have a specific format (defined in a property, or in its
-     file), it uses `org-columns-default-format'.
+     does not have a specific format--defined in a property, or in its
+     file--it uses `org-columns-default-format'.
 
   2. If any of the columns has a summary type defined (*note Column
      attributes::), turning on column view in the agenda will visit all
@@ -9045,11 +9048,11 @@ environment.  This causes the following issues:
      `CLOCKSUM' property.  Org will then sum the values displayed in
      the agenda.  In the daily/weekly agenda, the sums will cover a
      single day; in all other views they cover the entire block.  It is
-     vital to realize that the agenda may show the same entry _twice_
-     (for example as scheduled and as a deadline), and it may show two
-     entries from the same hierarchy (for example a _parent_ and its
-     _child_).  In these cases, the summation in the agenda will lead
-     to incorrect results because some values will count double.
+     vital to realize that the agenda may show the same entry
+     _twice_--for example as scheduled and as a deadline--and it may
+     show two entries from the same hierarchy--for example a _parent_
+     and its _child_.  In these cases, the summation in the agenda will
+     lead to incorrect results because some values will count double.
 
   3. When the column view in the agenda shows the `CLOCKSUM', that is
      always the entire clocked time for this item.  So even in the
@@ -9065,7 +9068,7 @@ environment.  This causes the following issues:
      always today's clocked time for this item.  So even in the weekly
      agenda, the clocksum listed in column view only originates from
      today.  This lets you compare the time you spent on a task for
-     today, with the time already spent (via `CLOCKSUM') and with the
+     today, with the time already spent --via `CLOCKSUM'--and with the
      planned total effort for it.
 
 
@@ -9082,133 +9085,27 @@ section summarizes the markup rules used in an Org mode buffer.
 
 * Menu:
 
-* Structural markup elements::  The basic structure as seen by the exporter
+* Paragraphs::                  The basic unit of text
+* Emphasis and monospace::      Bold, italic, etc.
+* Horizontal rules::            Make a line
 * 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 templates
+* Special symbols::             Greek letters and other symbols
+* Subscripts and superscripts::  Simple syntax for raising/lowering text
 * Embedded LaTeX::           LaTeX can be freely used inside Org documents
-* Special blocks::              Containers targeted at export back-ends
-
-
-File: org,  Node: Structural markup elements,  Next: Images and tables,  Up: Markup
-
-11.1 Structural markup elements
-===============================
-
-* Menu:
-
-* 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
-* Lists::                       Lists
-* Paragraphs::                  Paragraphs
-* Footnote markup::             Footnotes
-* Emphasis and monospace::      Bold, italic, etc.
-* Horizontal rules::            Make a line
-* Comment lines::               What will *not* be exported
-
-
-File: org,  Node: Document title,  Next: Headings and sections,  Up: Structural markup elements
-
-Document title
---------------
-
-The title of the exported document is taken from the special line
-
-     #+TITLE: This is the title of the document
-
-   If you are exporting only a subtree, its heading will become the
-title of the document.  If the subtree has a property `EXPORT_TITLE',
-that will take precedence.
-
-
-File: org,  Node: Headings and sections,  Next: Table of contents,  Prev: Document title,  Up: Structural markup elements
-
-Headings and sections
----------------------
-
-The outline structure of the document as described in *note Document
-structure::, forms the basis for defining sections of the exported
-document.  However, since the outline structure is also used for (for
-example) lists of tasks, only the first three outline levels will be
-used as headings.  Deeper levels will become itemized lists.  You can
-change the location of this switch globally by setting the variable
-`org-export-headline-levels', or on a per-file basis with a line
-
-     #+OPTIONS: H:4
-
-
-File: org,  Node: Table of contents,  Next: Lists,  Prev: Headings and sections,  Up: Structural markup elements
-
-Table of contents
------------------
-
-The table of contents is normally inserted directly before the first
-headline 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
-`org-export-with-toc', or on a per-file basis with a line like
-
-     #+OPTIONS: toc:2          only inlcude two levels in TOC
-     #+OPTIONS: toc:nil        no default TOC at all
-
-   If you would like to move the table of contents to a different
-location, you should turn off the default table using
-`org-export-with-toc' or `#+OPTIONS' and insert `#+TOC: headlines N' at
-the desired location(s).
-
-     #+OPTIONS: toc:nil        no default TOC
-     ...
-     #+TOC: headlines 2        insert TOC here, with two headline levels
-
-   Moreover, if you append `local' parameter, the table contains only
-entries for the children of the current section(1).  In this case, any
-depth parameter becomes relative to the current level.
-
-     * Section
-     #+TOC: headlines 1 local  insert local TOC, with direct children only
-
-   The same `TOC' keyword can also generate a list of all tables (resp.
-all listings) with a caption in the document.
-
-     #+TOC: listings           build a list of listings
-     #+TOC: tables             build a list of tables
-
-   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 `ALT_TITLE' property accordingly.  It will then be
-used when building the table.
-
-   ---------- Footnotes ----------
-
-   (1) For LaTeX export, this feature requires the `titletoc' package.
-Note that `titletoc' must be loaded _before_ `hyperref'.  Thus, you may
-have to customize `org-latex-default-packages-alist'.
-
-
-File: org,  Node: Lists,  Next: Paragraphs,  Prev: Table of contents,  Up: Structural markup elements
-
-Lists
------
-
-Plain lists as described in *note Plain lists::, are translated to the
-back-end's syntax for such lists.  Most back-ends support unordered,
-ordered, and description lists.
 
 
-File: org,  Node: Paragraphs,  Next: Footnote markup,  Prev: Lists,  Up: Structural markup elements
+File: org,  Node: Paragraphs,  Next: Emphasis and monospace,  Up: Markup
 
-Paragraphs, line breaks, and quoting
-------------------------------------
+11.1 Paragraphs, line breaks, and quoting
+=========================================
 
 Paragraphs are separated by at least one empty line.  If you need to
 enforce a line break within a paragraph, use `\\' at the end of a line.
 
-   To keep the line breaks in a region, but otherwise use normal
-formatting, you can use this construct, which can also be used to
-format poetry.
+   To preserve the line breaks, indentation and blank lines in a
+region, but otherwise use normal formatting, you can use this
+construct, which can also be used to format poetry.
 
      #+BEGIN_VERSE
       Great clouds overhead
@@ -9235,20 +9132,10 @@ this:
      #+END_CENTER
 
 
-File: org,  Node: Footnote markup,  Next: Emphasis and monospace,  Prev: Paragraphs,  Up: Structural markup elements
-
-Footnote markup
----------------
-
-Footnotes defined in the way described in *note Footnotes::, will be
-exported by all back-ends.  Org allows multiple references to the same
-note, and multiple footnotes side by side.
-
-
-File: org,  Node: Emphasis and monospace,  Next: Horizontal rules,  Prev: Footnote markup,  Up: Structural markup elements
+File: org,  Node: Emphasis and monospace,  Next: Horizontal rules,  Prev: Paragraphs,  Up: Markup
 
-Emphasis and monospace
-----------------------
+11.2 Emphasis and monospace
+===========================
 
 You can make words *bold*, /italic/, _underlined_, `=verbatim=' and
 `~code~', and, if you must, `+strike-through+'.  Text in the code and
@@ -9264,45 +9151,18 @@ that changing one of the above variables will no take effect until you
 reload Org, for which you may need to restart Emacs.
 
 
-File: org,  Node: Horizontal rules,  Next: Comment lines,  Prev: Emphasis and monospace,  Up: Structural markup elements
+File: org,  Node: Horizontal rules,  Next: Images and tables,  Prev: Emphasis and monospace,  Up: Markup
 
-Horizontal rules
-----------------
+11.3 Horizontal rules
+=====================
 
 A line consisting of only dashes, and at least 5 of them, will be
 exported as a horizontal line.
 
 
-File: org,  Node: Comment lines,  Prev: Horizontal rules,  Up: Structural markup elements
-
-Comment lines
--------------
-
-Lines starting with zero or more whitespace characters followed by one
-`#' and a whitespace are treated as comments and, as such, are not
-exported.
-
-   Likewise, regions surrounded by `#+BEGIN_COMMENT' ...
-`#+END_COMMENT' are not exported.
-
-   Finally, a `COMMENT' keyword at the beginning of an entry, but after
-any other keyword or priority cookie, comments out the entire subtree.
-In this case, the subtree is not exported and no code block within it
-is executed either(1).  The command below helps changing the comment
-status of a headline.
-
-`C-c ;'
-     Toggle the `COMMENT' keyword at the beginning of an entry.
-
-   ---------- Footnotes ----------
-
-   (1) For a less drastic behavior, consider using a select tag (*note
-Export settings::) instead.
-
-
-File: org,  Node: Images and tables,  Next: Literal examples,  Prev: Structural markup elements,  Up: Markup
+File: org,  Node: Images and tables,  Next: Literal examples,  Prev: Horizontal rules,  Up: Markup
 
-11.2 Images and Tables
+11.4 Images and Tables
 ======================
 
 Both the native Org mode tables (*note Tables::) and tables formatted
@@ -9341,9 +9201,9 @@ LaTeX equations, source code blocks).  Depending on the export
 back-end, those may or may not be handled.
 
 
-File: org,  Node: Literal examples,  Next: Include files,  Prev: Images and tables,  Up: Markup
+File: org,  Node: Literal examples,  Next: Special symbols,  Prev: Images and tables,  Up: Markup
 
-11.3 Literal examples
+11.5 Literal examples
 =====================
 
 You can include literal examples that should not be subjected to
@@ -9378,13 +9238,27 @@ Easy templates:: for shortcuts to easily insert code blocks.
 
    Both in `example' and in `src' snippets, you can add a `-n' switch
 to the end of the `BEGIN' line, to get the lines of the example
-numbered.  If you use a `+n' switch, the numbering from the previous
-numbered snippet will be continued in the current one.  In literal
-examples, Org will interpret strings like `(ref:name)' as labels, and
-use them as targets for special hyperlinks like `[[(name)]]' (i.e., the
-reference name enclosed in single parenthesis).  In HTML, hovering the
-mouse over such a link will remote-highlight the corresponding code
-line, which is kind of cool.
+numbered.  The `-n' takes an optional numeric argument specifying the
+starting line number of the block.  If you use a `+n' switch, the
+numbering from the previous numbered snippet will be continued in the
+current one.  The `+n' can also take a numeric argument.  The value of
+the argument will be added to the last line of the previous block to
+determine the starting line number.
+
+     #+BEGIN_SRC emacs-lisp -n 20
+      ;; this will export with line number 20
+      (message "This is line 21")
+     #+END_SRC
+     #+BEGIN_SRC emacs-lisp +n 10
+      ;; This will be listed as line 31
+      (message "This is line 32")
+     #+END_SRC
+
+   In literal examples, Org will interpret strings like `(ref:name)' as
+labels, and use them as targets for special hyperlinks like `[[(name)]]'
+(i.e., the reference name enclosed in single parenthesis).  In HTML,
+hovering the mouse over such a link will remote-highlight the
+corresponding code line, which is kind of cool.
 
    You can also add a `-r' switch which removes the labels from the
 source code(3).  With the `-n' switch, links to these references will
@@ -9444,8 +9318,8 @@ adding the desired package to `org-latex-packages-alist'.  Refer to
 `org-latex-listings' for details.
 
    (2) Code in `src' blocks may also be evaluated either interactively
-or on export.  See *note Working with source code:: for more
-information on evaluating code blocks.
+or on export.  *Note Working with source code::, for more information
+on evaluating code blocks.
 
    (3) Adding `-k' to `-n -r' will keep the labels in the source code
 while using line numbers for the links, which might be useful to
@@ -9460,157 +9334,86 @@ editing with `C-c '', and also for export.
 `org-edit-fixed-width-region-mode'.
 
 
-File: org,  Node: Include files,  Next: Index entries,  Prev: Literal examples,  Up: Markup
+File: org,  Node: Special symbols,  Next: Subscripts and superscripts,  Prev: Literal examples,  Up: Markup
 
-11.4 Include files
-==================
+11.6 Special symbols
+====================
 
-During export, you can include the content of another file.  For
-example, to include your `.emacs' file, you could use: 
+You can use LaTeX-like syntax to insert special symbols--named
+entities--like `\alpha' to indicate the Greek letter, or `\to' to
+indicate an arrow.  Completion for these symbols is available, just type
+`\' and maybe a few letters, and press `M-' to see possible
+completions.  If you need such a symbol inside a word, terminate it with
+a pair of curly brackets.  For example
 
-     #+INCLUDE: "~/.emacs" src emacs-lisp
+     Protip: Given a circle \Gamma of diameter d, the length of its circumference
+     is \pi{}d.
 
-The first parameter names the the file to include.  The optional second
-and third parameter specify the markup (i.e., `example' or `src'), and,
-if the markup is `src', the language for formatting the contents.
+   A large number of entities is provided, with names taken from both
+HTML and LaTeX; you can comfortably browse the complete list from a
+dedicated buffer using the command `org-entities-help'.  It is also
+possible to provide your own special symbols in the variable
+`org-entities-user'.
 
-   If markup is requested, the included content will be placed within an
-appropriate block(1).  No changes to the included content are made and
-it is the responsibility of the user to ensure that the result is valid
-Org syntax.  For markup `example' and `src', which is requesting a
-literal example, the content will be code-escaped before inclusion.
+   During export, these symbols are transformed into the native format
+of the exporter back-end.  Strings like `\alpha' are exported as
+`α' in the HTML output, and as `\(\alpha\)' in the LaTeX output.
+Similarly, `\nbsp' becomes ` ' in HTML and `~' in LaTeX.
 
-   If no markup is requested, the text will be assumed to be in Org
-mode format and will be processed normally.  However, footnote labels
-(*note Footnotes::) in the file will be made local to that file.
-Contents of the included file will belong to the same structure
-(headline, item) containing the `INCLUDE' keyword.  In particular,
-headlines within the file will become children of the current section.
-That behavior can be changed by providing an additional keyword
-parameter, `: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
+   Entities may also be used as a may to escape markup in an Org
+document, e.g., `\under{}not underlined\under' exports as `_not
+underlined_'.
 
-     #+INCLUDE: "~/my-book/chapter2.org" :minlevel 1
+   If you would like to see entities displayed as UTF-8 characters, use
+the following command(1):
 
-   You can also include a portion of a file by specifying a lines range
-using the `:lines' keyword parameter.  The line at the upper end of the
-range will not be included.  The start and/or the end of the range may
-be omitted to use the obvious defaults.
+`C-c C-x \'
+     Toggle display of entities as UTF-8 characters.  This does not
+     change the buffer content which remains plain ASCII, but it
+     overlays the UTF-8 character for display purposes only.
 
-     #+INCLUDE: "~/.emacs" :lines "5-10"   Include lines 5 to 10, 10 excluded
-     #+INCLUDE: "~/.emacs" :lines "-10"    Include lines 1 to 10, 10 excluded
-     #+INCLUDE: "~/.emacs" :lines "10-"    Include lines from 10 to EOF
-
-   Finally, you may use a file-link to extract an object as matched by
-`org-link-search'(2) (*note Search options::).  If the `:only-contents'
-property is non-`nil', only the contents of the requested element will
-be included, omitting properties drawer and planning-line if present.
-The `:lines' keyword operates locally with respect to the requested
-element.  Some examples:
-
-     #+INCLUDE: "./paper.org::#theory" :only-contents t
-        Include the body of the heading with the custom id `theory'
-     #+INCLUDE: "./paper.org::mytable"  Include named element.
-     #+INCLUDE: "./paper.org::*conclusion" :lines 1-20
-        Include the first 20 lines of the headline named conclusion.
-
-`C-c ''
-     Visit the include file at point.
+   In addition to regular entities defined above, Org exports in a
+special way(2) the following commonly used character combinations: `\-'
+is treated as a shy hyphen, `--' and `---' are converted into dashes,
+and `...' becomes a compact set of dots.
 
    ---------- Footnotes ----------
 
-   (1) While you can request paragraphs (`verse', `quote', `center'),
-but this places severe restrictions on the type of content that is
-permissible
-
-   (2) Note that `org-link-search-must-match-exact-headline' is locally
-bound to non-`nil'.  Therefore, `org-link-search' only matches
-headlines and named elements.
-
-
-File: org,  Node: Index entries,  Next: Macro replacement,  Prev: Include files,  Up: Markup
-
-11.5 Index entries
-==================
-
-You can specify entries that will be used for generating an index during
-publishing.  This is done by lines starting with `#+INDEX'.  An entry
-the contains an exclamation mark will create a sub item.  See *note
-Generating an index:: for more information.
+   (1) You can turn this on by default by setting the variable
+`org-pretty-entities', or on a per-file base with the `#+STARTUP'
+option `entitiespretty'.
 
-     * Curriculum Vitae
-     #+INDEX: CV
-     #+INDEX: Application!CV
+   (2) This behaviour can be disabled with `-' export setting (*note
+Export settings::).
 
 
-File: org,  Node: Macro replacement,  Next: Embedded LaTeX,  Prev: Index entries,  Up: Markup
-
-11.6 Macro replacement
-======================
-
-You can define text snippets with
-
-     #+MACRO: name   replacement text $1, $2 are arguments
-
-which can be referenced `{{{name(arg1, arg2)}}}'(1).
-
-   These references, called macros, can be inserted anywhere Org markup
-is recognized: paragraphs, headlines, verse blocks, tables cells and
-lists.  They can also be used in keywords accepting Org syntax, e.g.,
-`#+CAPTION', `#+TITLE', `#+AUTHOR', `#+DATE' and some others, export
-back-end specific, ones.
-
-   In addition to user-defined macros, a set of predefined macros can
-be used:
-
-`{{{title}}}'
-`{{{author}}}'
-`{{{email}}}'
-     These macros are replaced with the information available at the
-     time of export.
-
-`{{{date}}}'
-`{{{date(FORMAT)}}}'
-     This macro refers to the `#+DATE' keyword. FORMAT is an optional
-     argument to the `{{{date}}}' macro that will be used only if
-     `#+DATE' is a single timestamp.  FORMAT should be a format string
-     understood by `format-time-string'.
-
-`{{{time(FORMAT)}}}'
-`{{{modification-time(FORMAT)}}}'
-     These macros refer to the date and time when the document is
-     exported and to the modification date and time of the file being
-     exported, respectively.  FORMAT should be a format string
-     understood by `format-time-string'.
-
-`{{{input-file}}}'
-     This macro refers to the filename of the exported file, if any.
+File: org,  Node: Subscripts and superscripts,  Next: Embedded LaTeX,  Prev: Special symbols,  Up: Markup
 
-`{{{property(PROPERTY-NAME)}}}'
-`{{{property(PROPERTY-NAME,SEARCH-OPTION)}}}'
-     This macro returns the value of property PROPERTY-NAME in current
-     entry.  If SEARCH-OPTION (*note Search options::) refers to a
-     remote entry, it will be used instead.
+11.7 Subscripts and superscripts
+================================
 
-   The surrounding brackets can be made invisible by setting
-`org-hide-macro-markers' non-`nil'.
+`^' and `_' are used to indicate super- and subscripts.  To increase
+the readability of ASCII text, it is not necessary--but OK--to surround
+multi-character sub- and superscripts with curly braces.  Those are,
+however, mandatory, when more than one word is involved.  For example
 
-   Macro expansion takes place during the very beginning of the export
-process.
+     The radius of the sun is R_sun = 6.96 x 10^8 m.  On the other hand, the
+     radius of Alpha Centauri is R_{Alpha Centauri} = 1.28 x R_{sun}.
 
-   ---------- Footnotes ----------
+   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 `org-use-sub-superscripts' to
+change this convention.  For example, when setting this variable to
+`{}', `a_b' will not be interpreted as a subscript, but `a_{b}' will.
 
-   (1) 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.
+`C-c C-x \'
+     In addition to showing entities as UTF-8 characters, this command
+     will also format sub- and superscripts in a WYSIWYM way.
 
 
-File: org,  Node: Embedded LaTeX,  Next: Special blocks,  Prev: Macro replacement,  Up: Markup
+File: org,  Node: Embedded LaTeX,  Prev: Subscripts and superscripts,  Up: Markup
 
-11.7 Embedded LaTeX
+11.8 Embedded LaTeX
 ===================
 
 Plain ASCII is normally sufficient for almost all note taking.
@@ -9623,8 +9426,6 @@ pretty output for a number of export back-ends.
 
 * Menu:
 
-* Special symbols::             Greek letters and other symbols
-* Subscripts and superscripts::  Simple syntax for raising/lowering text
 * LaTeX fragments::          Complex formulas made easy
 * Previewing LaTeX fragments::  What will this snippet look like?
 * CDLaTeX mode::                Speed up entering of formulas
@@ -9636,83 +9437,15 @@ Many of the features described here as "LaTeX" are really from TeX, but
 for simplicity I am blurring this distinction.
 
 
-File: org,  Node: Special symbols,  Next: Subscripts and superscripts,  Up: Embedded LaTeX
-
-11.7.1 Special symbols
-----------------------
-
-You can use LaTeX-like syntax to insert special symbols like `\alpha'
-to indicate the Greek letter, or `\to' to indicate an arrow.  Completion
-for these symbols is available, just type `\' and maybe a few letters,
-and press `M-' to see possible completions.  Unlike LaTeX code,
-Org mode allows these symbols to be present without surrounding math
-delimiters, for example:
-
-     Angles are written as Greek letters \alpha, \beta and \gamma.
-
-   During export, these symbols will be transformed into the native
-format of the exporter back-end.  Strings like `\alpha' will be
-exported as `α' in the HTML output, and as `\(\alpha\)' in the
-LaTeX output.  Similarly, `\nbsp' will become ` ' in HTML and `~'
-in LaTeX.  If you need such a symbol inside a word, terminate it like
-this: `\Aacute{}stor'.
-
-   A large number of entities is provided, with names taken from both
-HTML and LaTeX; see the variable `org-entities' for the complete list.
-`\-' is treated as a shy hyphen, and `--', `---', and `...' 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 UTF-8 characters, use
-the following command(1):
-
-`C-c C-x \'
-     Toggle display of entities as UTF-8 characters.  This does not
-     change the buffer content which remains plain ASCII, but it
-     overlays the UTF-8 character for display purposes only.
-
-   ---------- Footnotes ----------
-
-   (1) You can turn this on by default by setting the variable
-`org-pretty-entities', or on a per-file base with the `#+STARTUP'
-option `entitiespretty'.
-
-
-File: org,  Node: Subscripts and superscripts,  Next: LaTeX fragments,  Prev: Special symbols,  Up: Embedded LaTeX
-
-11.7.2 Subscripts and superscripts
-----------------------------------
-
-Just like in LaTeX, `^' and `_' 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
-
-     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.
-
-   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 `org-use-sub-superscripts' to
-change this convention.  For example, when setting this variable to
-`{}', `a_b' will not be interpreted as a subscript, but `a_{b}' will.
-
-`C-c C-x \'
-     In addition to showing entities as UTF-8 characters, this command
-     will also format sub- and superscripts in a WYSIWYM way.
-
-
-File: org,  Node: LaTeX fragments,  Next: Previewing LaTeX fragments,  Prev: Subscripts and superscripts,  Up: Embedded LaTeX
+File: org,  Node: LaTeX fragments,  Next: Previewing LaTeX fragments,  Up: Embedded LaTeX
 
-11.7.3 LaTeX fragments
+11.8.1 LaTeX fragments
 ----------------------
 
-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 back-ends.  When exporting to
-LaTeX, the code is left as it is.  When exporting to HTML, Org can use
-either MathJax (http://www.mathjax.org) (*note Math formatting in HTML
+Org mode can contain LaTeX math fragments, and it supports ways to
+process these for several export back-ends.  When exporting to LaTeX,
+the code is left as it is.  When exporting to HTML, Org can use either
+MathJax (http://www.mathjax.org) (*note Math formatting in HTML
 export::) or transcode the math into images (see *note Previewing LaTeX
 fragments::).
 
@@ -9753,16 +9486,17 @@ can also set this variable on a per-file basis using one of these lines:
    ---------- Footnotes ----------
 
    (1) When MathJax is used, only the environments recognized by
-MathJax will be processed.  When `dvipng' program or `imagemagick'
-suite is used to create images, any LaTeX environment will be handled.
+MathJax will be processed.  When `dvipng' program, `dvisvgm' program or
+`imagemagick' suite is used to create images, any LaTeX environment
+will be handled.
 
 
 File: org,  Node: Previewing LaTeX fragments,  Next: CDLaTeX mode,  Prev: LaTeX fragments,  Up: Embedded LaTeX
 
-11.7.4 Previewing LaTeX fragments
+11.8.2 Previewing LaTeX fragments
 ---------------------------------
 
-If you have a working LaTeX installation and either `dvipng' or
+If you have a working LaTeX installation and `dvipng', `dvisvgm' or
 `convert' installed(1), LaTeX fragments can be processed to produce
 images of the typeset expressions to be used for inclusion while
 exporting to HTML (see *note LaTeX fragments::), or for inline
@@ -9795,14 +9529,14 @@ of the former can be used to adjust the size of the preview images.
    ---------- Footnotes ----------
 
    (1) These are respectively available at
-`http://sourceforge.net/projects/dvipng/' and from the `imagemagick'
-suite. Choose the converter by setting the variable
-`org-latex-create-formula-image-program' accordingly.
+`http://sourceforge.net/projects/dvipng/', `http://dvisvgm.bplaced.net/'
+and from the `imagemagick' suite.  Choose the converter by setting the
+variable `org-preview-latex-default-process' accordingly.
 
 
 File: org,  Node: CDLaTeX mode,  Prev: Previewing LaTeX fragments,  Up: Embedded LaTeX
 
-11.7.5 Using CDLaTeX to enter math
+11.8.3 Using CDLaTeX to enter math
 ----------------------------------
 
 CDLaTeX mode is a minor mode that is normally used in combination with a
@@ -9810,7 +9544,7 @@ major LaTeX mode like AUCTeX in order to speed-up insertion of
 environments and math templates.  Inside Org mode, you can make use of
 some of the features of CDLaTeX mode.  You need to install `cdlatex.el'
 and `texmathp.el' (the latter comes also with AUCTeX) from
-`http://www.astro.uva.nl/~dominik/Tools/cdlatex'.  Don't use CDLaTeX
+`https://staff.fnwi.uva.nl/c.dominik/Tools/cdlatex'.  Don't use CDLaTeX
 mode itself under Org mode, but use the light version
 `org-cdlatex-mode' that comes as part of Org mode.  Turn it on for the
 current buffer with `M-x org-cdlatex-mode RET', or for all Org files
@@ -9855,80 +9589,89 @@ fragment, see the documentation of the function
 `org-inside-LaTeX-fragment-p'.
 
 
-File: org,  Node: Special blocks,  Prev: Embedded LaTeX,  Up: Markup
+File: org,  Node: Exporting,  Next: Publishing,  Prev: Markup,  Up: Top
 
-11.8 Special blocks
-===================
+12 Exporting
+************
 
-Org syntax includes pre-defined blocks (*note Paragraphs:: and *note
-Literal examples::).  It is also possible to create blocks containing
-raw code targeted at a specific back-end (e.g., `#+BEGIN_LATEX').
+Sometimes, you may want to pretty print your notes, publish them on the
+web or even share them with people not using Org.  In these cases, the
+Org export facilities can be used to convert your documents to a
+variety of other formats, while retaining as much structure (*note
+Document structure::) and markup (*note Markup::) as possible.
 
-   Any other block is a _special block_.  Its name is case-sensitive.
+   Libraries responsible for such translation are called back-ends.
+Org ships with the following ones
 
-   For example, `#+BEGIN_abstract' and `#+BEGIN_video' are special
-blocks.  The first one is useful when exporting to LaTeX, the second one
-when exporting to HTML5.
+   * ascii (ASCII format)
 
-   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
-opening and closing block lines were not there.  For example, when
-exporting a `#+BEGIN_test' block, HTML back-end wraps its contents
-within a `
' tag. + * beamer (LaTeX Beamer format) - Refer to back-end specific documentation for more information. + * html (HTML format) - -File: org, Node: Exporting, Next: Publishing, Prev: Markup, Up: Top + * icalendar (iCalendar format) -12 Exporting -************ + * latex (LaTeX format) + + * md (Markdown format) + + * odt (OpenDocument Text format) + + * org (Org format) + + * texinfo (Texinfo format) + + * man (Man page format) + +More of them can be found in the `contrib/' directory (*note +Installation::) or through the Emacs packaging system(1). + + By default, the following five back-ends are loaded: `ascii', +`html', `icalendar', `latex' and `odt'. Others need to be specifically +loaded, either by customizing `org-export-backends', or by requiring +the associated library, e.g., -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 `orgtbl-mode' and/or `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. + (require 'ox-md) + + Eventually, you can these facilities can be used with `orgtbl-mode' +or `orgstruct-mode' in foreign buffers so you can author tables and +lists in Org syntax and convert them in place to the target language. * Menu: * The export dispatcher:: The main exporter interface -* Export back-ends:: Built-in export formats * Export settings:: Generic export settings +* Table of contents:: The if and where of the table of contents +* Include files:: Include additional files into a document +* Macro replacement:: Use macros to create templates +* Comment lines:: What will not be exported * 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 +* LaTeX export:: Exporting to LaTeX, and processing to PDF * Markdown export:: Exporting to Markdown * OpenDocument Text export:: Exporting to OpenDocument Text * Org export:: Exporting to Org * Texinfo export:: Exporting to Texinfo * iCalendar export:: Exporting to iCalendar * Other built-in back-ends:: Exporting to a man page -* Export in foreign buffers:: Author tables and lists in Org syntax * Advanced configuration:: Fine-tuning the export output +* Export in foreign buffers:: Author tables and lists in Org syntax + + ---------- Footnotes ---------- + + (1) These libraries traditionnaly appear as `ox-NAME', e.g., +`ox-koma-letter' for `koma-letter' back-end.  -File: org, Node: The export dispatcher, Next: Export back-ends, Up: Exporting +File: org, Node: The export dispatcher, Next: Export settings, Up: Exporting 12.1 The 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(1) from which it is possible to select an -export format and to toggle export options. +and toggle export options(1). `C-c C-e' (`org-export-dispatch') Dispatch for export and publishing commands. When called with a @@ -9980,48 +9723,9 @@ case, only a prompt is visible from the minibuffer. From there one can still switch back to regular menu by pressing .  -File: org, Node: Export back-ends, Next: Export settings, Prev: The export dispatcher, Up: Exporting - -12.2 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. - - By default, the following four back-ends are loaded: `ascii', -`html', `icalendar' and `latex'. It is possible to add more (or remove -some) by customizing `org-export-backends'. - - Built-in back-ends include: - - * ascii (ASCII format) - - * beamer (LaTeX Beamer format) - - * html (HTML format) - - * icalendar (iCalendar format) - - * latex (LaTeX format) - - * man (Man page format) - - * md (Markdown format) - - * odt (OpenDocument Text format) - - * org (Org format) - - * texinfo (Texinfo format) - - Other back-ends might be found in the `contrib/' directory (*note -Installation::). - - -File: org, Node: Export settings, Next: ASCII/Latin-1/UTF-8 export, Prev: Export back-ends, Up: Exporting +File: org, Node: Export settings, Next: Table of contents, Prev: The export dispatcher, Up: Exporting -12.3 Export settings +12.2 Export settings ==================== Export options can be set: globally with variables; for an individual @@ -10037,7 +9741,7 @@ syntax. Option keyword sets tailored to a particular back-end can be inserted from the export dispatcher (*note The export dispatcher::) using the `Insert template' command by pressing <#>. To insert keywords individually, a good way to make sure the keyword is correct -is to type `#+' and then to use `M-' for completion. +is to type `#+' and then to use `M-'(1) for completion. The export keywords available for every back-end, and their equivalent global variables, include: @@ -10050,7 +9754,7 @@ equivalent global variables, include: (`org-export-creator-string'). `DATE' - A date or a time-stamp(1). + A date or a time-stamp(2). `EMAIL' The email address (`user-mail-address'). @@ -10080,11 +9784,21 @@ equivalent global variables, include: The title to be shown. You can use several such keywords for long titles. - The `#+OPTIONS' keyword is a compact(2) form that recognizes the +`EXPORT_FILE_NAME' + The name of the output file to be generated. By default, it is + taken from the file associated to the buffer, when possible, or + asked to you otherwise. In all cases, the extension is ignored, + and a back-end specific one is added. + + + The `#+OPTIONS' keyword is a compact(3) form that recognizes the following arguments: `':' - Toggle smart quotes (`org-export-with-smart-quotes'). + Toggle smart quotes (`org-export-with-smart-quotes'). When + activated, pairs of double quotes become primary quotes according + to the language used. Inside, pairs of single quotes become + secondary quotes. Other single quotes are treated as apostrophes. `*:' Toggle emphasized text (`org-export-with-emphasize'). @@ -10117,6 +9831,11 @@ following arguments: Toggle inclusion of author name into exported file (`org-export-with-author'). +`broken-links:' + Decide whether to raise an error or not when encountering a broken + internal link. When set to `mark', signal the problem clearly in + the output (`org-export-with-broken-links'). + `c:' Toggle inclusion of CLOCK keywords (`org-export-with-clocks'). @@ -10170,73 +9889,285 @@ following arguments: Toggle inclusion of property drawers, or list properties to include (`org-export-with-properties'). -`stat:' - Toggle inclusion of statistics cookies - (`org-export-with-statistics-cookies'). +`stat:' + Toggle inclusion of statistics cookies + (`org-export-with-statistics-cookies'). + +`tags:' + Toggle inclusion of tags, may also be `not-in-toc' + (`org-export-with-tags'). + +`tasks:' + Toggle inclusion of tasks (TODO items), can be `nil' to remove all + tasks, `todo' to remove DONE tasks, or a list of keywords to keep + (`org-export-with-tasks'). + +`tex:' + Configure export of LaTeX fragments and environments. It may be + set to `verbatim' (`org-export-with-latex'). + +`timestamp:' + Toggle inclusion of the creation time into exported file + (`org-export-time-stamp-file'). + +`title:' + Toggle inclusion of title (`org-export-with-title'). + +`toc:' + Toggle inclusion of the table of contents, or set the level limit + (`org-export-with-toc'). + +`todo:' + Toggle inclusion of TODO keywords into exported text + (`org-export-with-todo-keywords'). + +`|:' + Toggle inclusion of tables (`org-export-with-tables'). + + + When exporting only a subtree, each of the previous keywords(4) can +be overridden locally by special node properties. These begin with +`EXPORT_', followed by the name of the keyword they supplant, unless +the keyword already beging with `EXPORT_'. For example, `DATE' and +`EXPORT_FILE_NAME' keywords become, respectively, `EXPORT_DATE' and +`EXPORT_FILE_NAME' properties. + + If `org-export-allow-bind-keywords' is non-`nil', Emacs variables +can become buffer-local during export by using the BIND keyword. Its +syntax is `#+BIND: variable value'. This is particularly useful for +in-buffer settings that cannot be changed using specific keywords. + + ---------- Footnotes ---------- + + (1) Many desktops intercept `M-TAB' to switch windows. Use `C-M-i' +or ` ' instead. + + (2) The variable `org-export-date-timestamp-format' defines how this +time-stamp will be exported. + + (3) If you want to configure many options this way, you can use +several `#+OPTIONS' lines. + + (4) With the exception of `SETUPFILE'. + + +File: org, Node: Table of contents, Next: Include files, Prev: Export settings, Up: Exporting + +12.3 Table of contents +====================== + +The table of contents is normally inserted directly before the first +headline 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 +`org-export-with-toc', or on a per-file basis with a line like + + #+OPTIONS: toc:2 only inlcude two levels in TOC + #+OPTIONS: toc:nil no default TOC at all + + If you would like to move the table of contents to a different +location, you should turn off the default table using +`org-export-with-toc' or `#+OPTIONS' and insert `#+TOC: headlines N' at +the desired location(s). + + #+OPTIONS: toc:nil no default TOC + ... + #+TOC: headlines 2 insert TOC here, with two headline levels + + Moreover, if you append `local' parameter, the table contains only +entries for the children of the current section(1). In this case, any +depth parameter becomes relative to the current level. + + * Section + #+TOC: headlines 1 local insert local TOC, with direct children only + + The same `TOC' keyword can also generate a list of all tables (resp. +all listings) with a caption in the document. + + #+TOC: listings build a list of listings + #+TOC: tables build a list of tables + + 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 `ALT_TITLE' property accordingly. It will then be +used when building the table. + + ---------- Footnotes ---------- + + (1) For LaTeX export, this feature requires the `titletoc' package. +Note that `titletoc' must be loaded _before_ `hyperref'. Thus, you may +have to customize `org-latex-default-packages-alist'. + + +File: org, Node: Include files, Next: Macro replacement, Prev: Table of contents, Up: Exporting + +12.4 Include files +================== + +During export, you can include the content of another file. For +example, to include your `.emacs' file, you could use: + + #+INCLUDE: "~/.emacs" src emacs-lisp + +The first parameter names the the file to include. The optional second +and third parameter specify the markup (i.e., `example', `export' or +`src'), and, if the markup is either `export' or `src', the language +for formatting the contents. + + If markup is requested, the included content will be placed within an +appropriate block(1). No changes to the included content are made and +it is the responsibility of the user to ensure that the result is valid +Org syntax. For markup `example' and `src', which is requesting a +literal example, the content will be code-escaped before inclusion. + + If no markup is requested, the text will be assumed to be in Org +mode format and will be processed normally. However, footnote labels +(*note Footnotes::) in the file will be made local to that file. +Contents of the included file will belong to the same structure +(headline, item) containing the `INCLUDE' keyword. In particular, +headlines within the file will become children of the current section. +That behavior can be changed by providing an additional keyword +parameter, `: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 + + #+INCLUDE: "~/my-book/chapter2.org" :minlevel 1 + + You can also include a portion of a file by specifying a lines range +using the `:lines' keyword parameter. The line at the upper end of the +range will not be included. The start and/or the end of the range may +be omitted to use the obvious defaults. + + #+INCLUDE: "~/.emacs" :lines "5-10" Include lines 5 to 10, 10 excluded + #+INCLUDE: "~/.emacs" :lines "-10" Include lines 1 to 10, 10 excluded + #+INCLUDE: "~/.emacs" :lines "10-" Include lines from 10 to EOF + + Finally, you may use a file-link to extract an object as matched by +`org-link-search'(2) (*note Search options::). If the `:only-contents' +property is non-`nil', only the contents of the requested element will +be included, omitting properties drawer and planning-line if present. +The `:lines' keyword operates locally with respect to the requested +element. Some examples: + + #+INCLUDE: "./paper.org::#theory" :only-contents t + Include the body of the heading with the custom id `theory' + #+INCLUDE: "./paper.org::mytable" Include named element. + #+INCLUDE: "./paper.org::*conclusion" :lines 1-20 + Include the first 20 lines of the headline named `conclusion'. + +`C-c '' + Visit the include file at point. + + ---------- Footnotes ---------- + + (1) While you can request paragraphs (`verse', `quote', `center'), +but this places severe restrictions on the type of content that is +permissible + + (2) Note that `org-link-search-must-match-exact-headline' is locally +bound to non-`nil'. Therefore, `org-link-search' only matches +headlines and named elements. + + +File: org, Node: Macro replacement, Next: Comment lines, Prev: Include files, Up: Exporting + +12.5 Macro replacement +====================== + +Macros replace text snippets during export. Macros are defined +globally in `org-export-global-macros', or document-wise with the +following syntax: + + #+MACRO: name replacement text $1, $2 are arguments + +which can be referenced using `{{{name(arg1, arg2)}}}'(1). + + These references, called macros, can be inserted anywhere Org markup +is recognized: paragraphs, headlines, verse blocks, tables cells and +lists. They can also be used in keywords accepting Org syntax, e.g., +`#+CAPTION', `#+TITLE', `#+AUTHOR', `#+DATE' and some others, export +back-end specific, ones. + + In addition to user-defined macros, a set of predefined macros can +be used: + +`{{{title}}}' +`{{{author}}}' +`{{{email}}}' + These macros are replaced with the information available at the + time of export. + +`{{{date}}}' +`{{{date(FORMAT)}}}' + This macro refers to the `#+DATE' keyword. FORMAT is an optional + argument to the `{{{date}}}' macro that will be used only if + `#+DATE' is a single timestamp. FORMAT should be a format string + understood by `format-time-string'. + +`{{{time(FORMAT)}}}' +`{{{modification-time(FORMAT, VC)}}}' + These macros refer to the date and time when the document is + exported and to the modification date and time, respectively. + FORMAT should be a format string understood by + `format-time-string'. If the second argument to the + `modification-time' macro is non-`nil', Org retrieves the + information from the version control system, using `vc.el', + instead of the file attributes. -`tags:' - Toggle inclusion of tags, may also be `not-in-toc' - (`org-export-with-tags'). +`{{{input-file}}}' + This macro refers to the filename of the exported file, if any. -`tasks:' - Toggle inclusion of tasks (TODO items), can be `nil' to remove all - tasks, `todo' to remove DONE tasks, or a list of keywords to keep - (`org-export-with-tasks'). +`{{{property(PROPERTY-NAME)}}}' +`{{{property(PROPERTY-NAME,SEARCH-OPTION)}}}' + This macro returns the value of property PROPERTY-NAME in current + entry. If SEARCH-OPTION (*note Search options::) refers to a + remote entry, it will be used instead. -`tex:' - Configure export of LaTeX fragments and environments. It may be - set to `verbatim' (`org-export-with-latex'). + The surrounding brackets can be made invisible by setting +`org-hide-macro-markers' non-`nil'. -`timestamp:' - Toggle inclusion of the creation time into exported file - (`org-export-time-stamp-file'). + Macro expansion takes place during the very beginning of the export +process. -`title:' - Toggle inclusion of title (`org-export-with-title'). + ---------- Footnotes ---------- -`toc:' - Toggle inclusion of the table of contents, or set the level limit - (`org-export-with-toc'). + (1) 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. -`todo:' - Toggle inclusion of TODO keywords into exported text - (`org-export-with-todo-keywords'). + +File: org, Node: Comment lines, Next: ASCII/Latin-1/UTF-8 export, Prev: Macro replacement, Up: Exporting -`|:' - Toggle inclusion of tables (`org-export-with-tables'). +12.6 Comment lines +================== +Lines starting with zero or more whitespace characters followed by one +`#' and a whitespace are treated as comments and, as such, are not +exported. - When exporting only a subtree, each of the previous keywords(3) can -be overridden locally by special node properties. These begin with -`EXPORT_', followed by the name of the keyword they supplant. For -example, `DATE' and `OPTIONS' keywords become, respectively, -`EXPORT_DATE' and `EXPORT_OPTIONS' properties. + Likewise, regions surrounded by `#+BEGIN_COMMENT' ... +`#+END_COMMENT' are not exported. - If `org-export-allow-bind-keywords' is non-`nil', Emacs variables -can become buffer-local during export by using the BIND keyword. Its -syntax is `#+BIND: variable value'. This is particularly useful for -in-buffer settings that cannot be changed using specific keywords. + Finally, a `COMMENT' keyword at the beginning of an entry, but after +any other keyword or priority cookie, comments out the entire subtree. +In this case, the subtree is not exported and no code block within it +is executed either(1). The command below helps changing the comment +status of a headline. - The name of the output file to be generated is taken from the file -associated to the buffer, when possible, or asked to you otherwise. -For subtree export, you can also set `EXPORT_FILE_NAME' property. In -all cases, only the base name of the file is retained, and a back-end -specific extension is added. +`C-c ;' + Toggle the `COMMENT' keyword at the beginning of an entry. ---------- Footnotes ---------- - (1) The variable `org-export-date-timestamp-format' defines how this -time-stamp will be exported. - - (2) If you want to configure many options this way, you can use -several `#+OPTIONS' lines. - - (3) With the exception of `SETUPFILE'. + (1) For a less drastic behavior, consider using a select tag (*note +Export settings::) instead.  -File: org, Node: ASCII/Latin-1/UTF-8 export, Next: Beamer export, Prev: Export settings, Up: Exporting +File: org, Node: ASCII/Latin-1/UTF-8 export, Next: Beamer export, Prev: Comment lines, Up: Exporting -12.4 ASCII/Latin-1/UTF-8 export +12.7 ASCII/Latin-1/UTF-8 export =============================== ASCII export produces a simple and very readable version of an Org mode @@ -10290,9 +10221,9 @@ with the following constructs: #+ASCII: Some text - #+BEGIN_ASCII + #+BEGIN_EXPORT ascii All lines in this block will appear only when using this back-end. - #+END_ASCII + #+END_EXPORT ASCII specific attributes ------------------------- @@ -10323,26 +10254,26 @@ the following dedicated blocks.  File: org, Node: Beamer export, Next: HTML export, Prev: ASCII/Latin-1/UTF-8 export, Up: Exporting -12.5 Beamer export +12.8 Beamer export ================== The LaTeX class _Beamer_ allows production of high quality -presentations using LaTeX and pdf processing. Org mode has special +presentations using LaTeX and PDF processing. Org mode has special support for turning an Org mode file or tree into a Beamer presentation. * Menu: -* Beamer export commands:: How to export Beamer documents. -* Beamer specific export settings:: Export settings for Beamer export. -* Sectioning Frames and Blocks in Beamer:: Blocks and sections in Beamer. -* Beamer specific syntax:: Syntax specific to Beamer. -* Editing support:: Helper functions for Org Beamer export. -* A Beamer Example:: An complete Beamer example. +* Beamer export commands:: How to export Beamer documents. +* Beamer specific export settings:: Export settings for Beamer export. +* Sectioning Frames and Blocks in Beamer:: Blocks and sections in Beamer. +* Beamer specific syntax:: Syntax specific to Beamer. +* Editing support:: Helper functions for Org Beamer export. +* A Beamer Example:: An complete Beamer example.  File: org, Node: Beamer export commands, Next: Beamer specific export settings, Up: Beamer export -12.5.1 Beamer export commands +12.8.1 Beamer export commands ----------------------------- `C-c C-e l b (`org-beamer-export-to-latex')' @@ -10363,7 +10294,7 @@ File: org, Node: Beamer export commands, Next: Beamer specific export settings  File: org, Node: Beamer specific export settings, Next: Sectioning Frames and Blocks in Beamer, Prev: Beamer export commands, Up: Beamer export -12.5.2 Beamer specific export settings +12.8.2 Beamer specific export settings -------------------------------------- Beamer export introduces a number of keywords, similar to the general @@ -10411,7 +10342,7 @@ options settings described in *note Export settings::.  File: org, Node: Sectioning Frames and Blocks in Beamer, Next: Beamer specific syntax, Prev: Beamer specific export settings, Up: Beamer export -12.5.3 Sectioning, Frames and Blocks in Beamer +12.8.3 Sectioning, Frames and Blocks in Beamer ---------------------------------------------- Any tree with not-too-deep level nesting should in principle be @@ -10477,12 +10408,12 @@ that requires a verbatim environment, though.  File: org, Node: Beamer specific syntax, Next: Editing support, Prev: Sectioning Frames and Blocks in Beamer, Up: Beamer export -12.5.4 Beamer specific syntax +12.8.4 Beamer specific syntax ----------------------------- -The Beamer back-end is an extension of the LaTeX back-end. As such, -all LaTeX specific syntax (e.g., `#+LATEX:' or `#+ATTR_LATEX:') is -recognized. See *note LaTeX and PDF export:: for more information. +The Beamer back-end is an extension of the LaTeX back-end. As such, all +LaTeX specific syntax (e.g., `#+LATEX:' or `#+ATTR_LATEX:') is +recognized. See *note LaTeX export:: for more information. Table of contents generated from `toc:t' `OPTION' keyword are wrapped within a `frame' environment. Those generated from a `TOC' @@ -10495,7 +10426,7 @@ possible to specify options, enclosed within square brackets. #+BEAMER: \pause - #+BEGIN_BEAMER + #+BEGIN_EXPORT beamer All lines in this block will appear only when using this back-end. #+END_BEAMER @@ -10521,7 +10452,7 @@ arguments in current list environment.  File: org, Node: Editing support, Next: A Beamer Example, Prev: Beamer specific syntax, Up: Beamer export -12.5.5 Editing support +12.8.5 Editing support ---------------------- You can turn on a special minor mode `org-beamer-mode' for faster @@ -10536,7 +10467,7 @@ editing with:  File: org, Node: A Beamer Example, Prev: Editing support, Up: Beamer export -12.5.6 A Beamer example +12.8.6 A Beamer example ----------------------- Here is a simple example Org document that is intended for Beamer @@ -10575,9 +10506,9 @@ export. Please test this stuff!  -File: org, Node: HTML export, Next: LaTeX and PDF export, Prev: Beamer export, Up: Exporting +File: org, Node: HTML export, Next: LaTeX export, Prev: Beamer export, Up: Exporting -12.6 HTML export +12.9 HTML export ================ Org mode contains an HTML (XHTML 1.0 strict) exporter with extensive @@ -10587,7 +10518,7 @@ but with additional support for tables. * Menu: * HTML Export commands:: How to invoke HTML export -* HTML Specific export settings:: Export settings for HTML export. +* HTML Specific export settings:: Export settings for 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 @@ -10602,7 +10533,7 @@ but with additional support for tables.  File: org, Node: HTML Export commands, Next: HTML Specific export settings, Up: HTML export -12.6.1 HTML export commands +12.9.1 HTML export commands --------------------------- `C-c C-e h h (`org-html-export-to-html')' @@ -10617,7 +10548,7 @@ File: org, Node: HTML Export commands, Next: HTML Specific export settings, U  File: org, Node: HTML Specific export settings, Next: HTML doctypes, Prev: HTML Export commands, Up: HTML export -12.6.2 HTML Specific export settings +12.9.2 HTML Specific export settings ------------------------------------ HTML export introduces a number of keywords, similar to the general @@ -10672,7 +10603,7 @@ options settings described in *note Export settings::.  File: org, Node: HTML doctypes, Next: HTML preamble and postamble, Prev: HTML Specific export settings, Up: HTML export -12.6.3 HTML doctypes +12.9.3 HTML doctypes -------------------- Org can export to various (X)HTML flavors. @@ -10702,21 +10633,18 @@ ready-made doctype. The ready-made options are: * "xhtml5" - See the variable `org-html-doctype-alist' for details. The default -is "xhtml-strict". - -Fancy HTML5 export -.................. +See the variable `org-html-doctype-alist' for details. The default is +"xhtml-strict". -HTML5 introduces several new element types. By default, Org will not -make use of these element types, but you can set `org-html-html5-fancy' -to `t' (or set `html5-fancy' item in an `OPTIONS' line), to enable a -few new block-level elements. These are created using arbitrary -#+BEGIN and #+END blocks. For instance: + HTML5 introduces several new element types. By default, Org will +not make use of these element types, but you can set +`org-html-html5-fancy' to non-`nil' (or set `html5-fancy' item in an +`OPTIONS' line), to enable a few new block-level elements. These are +created using arbitrary #+BEGIN and #+END blocks. For instance: - #+BEGIN_ASIDE + #+BEGIN_aside Lorem ipsum - #+END_ASIDE + #+END_aside Will export to: @@ -10727,11 +10655,11 @@ few new block-level elements. These are created using arbitrary While this: #+ATTR_HTML: :controls controls :width 350 - #+BEGIN_VIDEO + #+BEGIN_video #+HTML: #+HTML: Your browser does not support the video tag. - #+END_VIDEO + #+END_video Becomes: @@ -10752,7 +10680,7 @@ and its contents in e.g., `
' or `
' tags, set the  File: org, Node: HTML preamble and postamble, Next: Quoting HTML tags, Prev: HTML doctypes, Up: HTML export -12.6.4 HTML preamble and postamble +12.9.4 HTML preamble and postamble ---------------------------------- The HTML exporter lets you define a preamble and a postamble. @@ -10776,7 +10704,7 @@ Setting it to `nil' will not insert any postamble.  File: org, Node: Quoting HTML tags, Next: Links in HTML export, Prev: HTML preamble and postamble, Up: HTML export -12.6.5 Quoting HTML tags +12.9.5 Quoting HTML tags ------------------------ Plain `<' and `>' are always transformed to `<' and `>' in HTML @@ -10789,14 +10717,14 @@ verbatim to the exported file use either or - #+BEGIN_HTML + #+BEGIN_EXPORT html All lines between these markers are exported literally - #+END_HTML + #+END_EXPORT  File: org, Node: Links in HTML export, Next: Tables in HTML export, Prev: Quoting HTML tags, Up: HTML export -12.6.6 Links in HTML export +12.9.6 Links in HTML export --------------------------- Internal links (*note Internal links::) will continue to work in HTML. @@ -10822,7 +10750,7 @@ the `' or `' tags. Here is an example that sets `title' and  File: org, Node: Tables in HTML export, Next: Images in HTML export, Prev: Links in HTML export, Up: HTML export -12.6.7 Tables in HTML export +12.9.7 Tables in HTML export ---------------------------- Org mode tables are exported to HTML using the table attributes defined @@ -10864,7 +10792,7 @@ groups::).  File: org, Node: Images in HTML export, Next: Math formatting in HTML export, Prev: Tables in HTML export, Up: HTML export -12.6.8 Images in HTML export +12.9.8 Images in HTML export ---------------------------- HTML export can inline images given as links in the Org file, and it @@ -10898,7 +10826,7 @@ You could use `http' addresses just as well.  File: org, Node: Math formatting in HTML export, Next: Text areas in HTML export, Prev: Images in HTML export, Up: HTML export -12.6.9 Math formatting in HTML export +12.9.9 Math formatting in HTML export ------------------------------------- LaTeX math snippets (*note LaTeX fragments::) can be displayed in two @@ -10918,12 +10846,14 @@ variables. The MathJax template can be configure via 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 `dvipng' program or -`imagemagick' suite is available on your system. You can still get -this processing with +for Org files. This method requires that the `dvipng' program, +`dvisvgm' or `imagemagick' suite is available on your system. You can +still get this processing with #+OPTIONS: tex:dvipng + #+OPTIONS: tex:dvisvgm + or: #+OPTIONS: tex:imagemagick @@ -10938,7 +10868,7 @@ docstring of `org-html-mathjax-options'.  File: org, Node: Text areas in HTML export, Next: CSS support, Prev: Math formatting in HTML export, Up: HTML export -12.6.10 Text areas in HTML export +12.9.10 Text areas in HTML export --------------------------------- An alternative way to publish literal code examples in HTML is to use @@ -10960,7 +10890,7 @@ in the example, and 80, respectively. For example  File: org, Node: CSS support, Next: JavaScript support, Prev: Text areas in HTML export, Up: HTML export -12.6.11 CSS support +12.9.11 CSS support ------------------- You can modify the CSS style definitions for the exported file. The @@ -10998,6 +10928,7 @@ tables, etc. p.footnote footnote definition paragraph, containing a footnote .footref a footnote reference number (always a ) .footnum footnote number in footnote definition (always ) + .org-svg default class for a linked `.svg' image Each exported file contains a compact default style that defines these classes in a basic way(2). You may overwrite these settings, or @@ -11031,7 +10962,7 @@ customize `org-html-head-include-default-style' or set `html-style' to  File: org, Node: JavaScript support, Prev: CSS support, Up: HTML export -12.6.12 JavaScript supported display of web pages +12.9.12 JavaScript supported display of web pages ------------------------------------------------- Sebastian Rose has written a JavaScript program especially designed to @@ -11087,46 +11018,45 @@ variable `org-html-infojs-options'. If you always want to apply the script to your pages, configure the variable `org-html-use-infojs'.  -File: org, Node: LaTeX and PDF export, Next: Markdown export, Prev: HTML export, Up: Exporting +File: org, Node: LaTeX export, Next: Markdown export, Prev: HTML export, Up: Exporting -12.7 LaTeX and PDF export -========================= +12.10 LaTeX export +================== -LaTeX export can produce an arbitrarily complex LaTeX document of any -standard or custom document class. With further processing(1), 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 -`hyperref' package, the default setup produces fully-linked PDF output. +The LaTeX exporter can produce an arbitrarily complex LaTeX document of +any standard or custom document class(1). The Org LaTeX exporter is +geared towards producing 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 export commands:: How to export to LaTeX and PDF * LaTeX specific export settings:: Export settings for LaTeX -* Header and sectioning:: Setting up the export file structure +* LaTeX header and sectioning:: Setting up the export file structure * Quoting LaTeX code:: Incorporating literal LaTeX code -* LaTeX specific attributes:: Controlling LaTeX output +* Tables in LaTeX export:: Specific attributes for tables +* Images in LaTeX export:: Specific attributes for images +* Plain lists in LaTeX export:: Specific attributes for plain lists +* Source blocks in LaTeX export:: Specific attributes for source blocks +* Example blocks in LaTeX export:: Specific attributes for example blocks +* Special blocks in LaTeX export:: Specific attributes for special blocks +* Horizontal rules in LaTeX export:: Specific attributes for horizontal rules ---------- Footnotes ---------- - (1) The default LaTeX output is designed for processing with -`pdftex' or `latex'. The LaTeX exporter can be configured to support -alternative TeX engines, see see `org-latex-pdf-process', and -alternative packages, see `org-latex-default-packages-alist' and -`org-latex-packages-alist'. + (1) The LaTeX exporter can be configured to support alternative +LaTeX engines (see `org-latex-compiler'), build sequences (see +`org-latex-pdf-process'), and packages, (see +`org-latex-default-packages-alist' and `org-latex-packages-alist').  -File: org, Node: LaTeX export commands, Next: LaTeX specific export settings, Up: LaTeX and PDF export +File: org, Node: LaTeX export commands, Next: LaTeX specific export settings, Up: LaTeX export -12.7.1 LaTeX export commands ----------------------------- +12.10.1 LaTeX export commands +----------------------------- `C-c C-e l l (`org-latex-export-to-latex')' Export as a LaTeX file. For an Org file `myfile.org', the LaTeX @@ -11143,11 +11073,24 @@ File: org, Node: LaTeX export commands, Next: LaTeX specific export settings, Export as LaTeX and then process to PDF, then open the resulting PDF file. + The exporter supports several LaTeX engines, namely `pdflatex', +`xelatex' and `lualatex'. The default LaTeX compiler can be set via +`org-latex-compiler' or the `#+LATEX_COMPILER' keyword. It is possible +to only load some packages with certain compilers (see the docstring of +`org-latex-default-packages-alist'). The bibliography compiler may +also be set via `org-latex-bibtex-compiler'(1). + + ---------- Footnotes ---------- + + (1) You cannot set the bibliography compiler on a file basis via a +keyword. However, "smart" LaTeX compilation systems, such as +`latexmk', are usually able to select the correct bibliography compiler. +  -File: org, Node: LaTeX specific export settings, Next: Header and sectioning, Prev: LaTeX export commands, Up: LaTeX and PDF export +File: org, Node: LaTeX specific export settings, Next: LaTeX header and sectioning, Prev: LaTeX export commands, Up: LaTeX export -12.7.2 LaTeX specific export settings -------------------------------------- +12.10.2 LaTeX specific export settings +-------------------------------------- The LaTeX exporter introduces a number of keywords, similar to the general options settings described in *note Export settings::. @@ -11167,6 +11110,9 @@ general options settings described in *note Export settings::. `LATEX_CLASS_OPTIONS' Options given to the LaTeX document class. +`LATEX_COMPILER' + The compiler used to produce the PDF (`org-latex-compiler'). + `LATEX_HEADER' Arbitrary lines added to the preamble of the document, before the `hyperref' settings. The location can be controlled via @@ -11195,10 +11141,10 @@ general options settings described in *note Export settings::. These keywords are treated in details in the following sections.  -File: org, Node: Header and sectioning, Next: Quoting LaTeX code, Prev: LaTeX specific export settings, Up: LaTeX and PDF export +File: org, Node: LaTeX header and sectioning, Next: Quoting LaTeX code, Prev: LaTeX specific export settings, Up: LaTeX export -12.7.3 Header and sectioning structure --------------------------------------- +12.10.3 LaTeX header and sectioning structure +--------------------------------------------- By default, the first three outline levels become headlines, defining a general document structure. Additional levels are exported as `itemize' @@ -11244,10 +11190,10 @@ keywords will not be loaded when previewing LaTeX snippets (*note Previewing LaTeX fragments::).  -File: org, Node: Quoting LaTeX code, Next: LaTeX specific attributes, Prev: Header and sectioning, Up: LaTeX and PDF export +File: org, Node: Quoting LaTeX code, Next: Tables in LaTeX export, Prev: LaTeX header and sectioning, Up: LaTeX export -12.7.4 Quoting LaTeX code -------------------------- +12.10.4 Quoting LaTeX code +-------------------------- Embedded LaTeX as described in *note Embedded LaTeX::, will be correctly inserted into the LaTeX file. Furthermore, you can add special code @@ -11258,22 +11204,15 @@ constructs: #+LATEX: Literal LaTeX code for export - #+BEGIN_LATEX + #+BEGIN_EXPORT latex All lines between these markers are exported literally - #+END_LATEX + #+END_EXPORT  -File: org, Node: LaTeX specific attributes, Prev: Quoting LaTeX code, Up: LaTeX and PDF export - -12.7.5 LaTeX specific attributes --------------------------------- +File: org, Node: Tables in LaTeX export, Next: Images in LaTeX export, Prev: Quoting LaTeX code, Up: LaTeX export -LaTeX understands attributes specified in an `ATTR_LATEX' line. They -affect tables, images, plain lists, source blocks, example blocks and -special blocks. - -Tables in LaTeX export -...................... +12.10.5 Tables in LaTeX export +------------------------------ For LaTeX export of a table, you can specify a label and a caption (*note Images and tables::). You can also use attributes to control @@ -11282,11 +11221,10 @@ table layout and contents. Valid LaTeX attributes include: `:mode' Nature of table's contents. It can be set to `table', `math', `inline-math' or `verbatim'. In particular, when in `math' or - `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 - `org-latex-default-table-mode'. + `inline-math' mode, every cell is exported as-is and the table is + wrapped within a math environment. Also, contiguous tables + sharing the same math mode are merged within the same environment. + Default mode is determined in `org-latex-default-table-mode'. `:environment' Environment used for the table. It can be set to any LaTeX table @@ -11362,18 +11300,30 @@ will set the caption. | ..... | ..... | | ..... | ..... | -Images in LaTeX export -...................... + ---------- Footnotes ---------- + + (1) Requires adding the `tabularx' package to +`org-latex-packages-alist'. + + (2) Requires adding the `tabu' package to `org-latex-packages-alist'. + + (3) Formerly, the value was `sidewaystable'. This is deprecated +since Org 8.3. + + +File: org, Node: Images in LaTeX export, Next: Plain lists in LaTeX export, Prev: Tables in LaTeX export, Up: LaTeX export + +12.10.6 Images in LaTeX export +------------------------------ Images that are linked to without a description part in the link, like `[[file:img.jpg]]' or `[[./img.jpg]]' will be inserted into the PDF output file resulting from LaTeX processing. Org will use an -`\includegraphics' macro to insert the image(4). +`\includegraphics' macro to insert the image(1). - You can specify specify image width or height with, respectively, -`:width' and `:height' attributes. It is also possible to add any -other option with the `:options' attribute, as shown in the following -example: + You can specify image width or height with, respectively, `:width' +and `:height' attributes. It is also possible to add any other option +with the `:options' attribute, as shown in the following example: #+ATTR_LATEX: :width 5cm :options angle=90 [[./img/sed-hr4049.pdf]] @@ -11412,22 +11362,58 @@ attribute. You may also set it to: #+ATTR_LATEX: :float wrap :width 0.38\textwidth :placement {r}{0.4\textwidth} [[./img/hst.png]] - If the `:comment-include' attribute is set to a non-`nil' value, the -LaTeX `\includegraphics' macro will be commented out. + Images are centered by default. However, one can disable this +behavior by setting `:center' attribute to `nil'. To prevent any image +from being centered throughout a document, set +`org-latex-images-centered' instead. -Plain lists in LaTeX export -........................... + Eventually, if the `:comment-include' attribute is set to a +non-`nil' value, the LaTeX `\includegraphics' macro will be commented +out. -Plain lists accept two optional attributes: `:environment' and -`:options'. The first one allows the use of a non-standard environment -(e.g., `inparaenum'). The second one specifies additional arguments for -that environment. + ---------- Footnotes ---------- - #+ATTR_LATEX: :environment compactitem :options [$\circ$] - - you need ``paralist'' package to reproduce this example. + (1) In the case of TikZ (`http://sourceforge.net/projects/pgf/') +images, it will become an `\input' macro wrapped within a `tikzpicture' +environment. -Source blocks in LaTeX export -............................. + +File: org, Node: Plain lists in LaTeX export, Next: Source blocks in LaTeX export, Prev: Images in LaTeX export, Up: LaTeX export + +12.10.7 Plain lists in LaTeX export +----------------------------------- + +Plain lists accept two optional attributes: `:environment' and +`:options'. The first can be used to specify the environment. The +second can be used to specifies additional arguments to the environment. +Both attributes are illustrated in the following example: + + #+LATEX_HEADER: \usepackage[inline]{enumitem} + Some ways to say "Hello": + #+ATTR_LATEX: :environment itemize* + #+ATTR_LATEX: :options [label={}, itemjoin={,}, itemjoin*={, and}] + - Hola + - Bonjour + - Guten Tag. + + By default, LaTeX only supports four levels of nesting for lists. If +deeper nesting is needed, the `enumitem' LaTeX package can be employed, +as shown in this example: + + #+LATEX_HEADER: \usepackage{enumitem} + #+LATEX_HEADER: \renewlist{itemize}{itemize}{9} + #+LATEX_HEADER: \setlist[itemize]{label=$\circ$} + - One + - Two + - Three + - Four + - Five + + +File: org, Node: Source blocks in LaTeX export, Next: Example blocks in LaTeX export, Prev: Plain lists in LaTeX export, Up: LaTeX export + +12.10.8 Source blocks in LaTeX export +------------------------------------- In addition to syntax defined in *note Literal examples::, names and captions (*note Images and tables::), source blocks also accept two @@ -11460,8 +11446,11 @@ counterpart to `org-latex-listings-options' and (if (< n 2) n (+ (Fib (- n 1)) (Fib (- n 2))))) #+END_SRC -Example blocks in LaTeX export -.............................. + +File: org, Node: Example blocks in LaTeX export, Next: Special blocks in LaTeX export, Prev: Source blocks in LaTeX export, Up: LaTeX export + +12.10.9 Example blocks in LaTeX export +-------------------------------------- By default, when exporting to LaTeX, example blocks contents are wrapped in a `verbatim' environment. It is possible to use a different @@ -11474,8 +11463,11 @@ configuration::). You can also change this per block using This sentence is false. #+END_EXAMPLE -Special blocks in LaTeX export -.............................. + +File: org, Node: Special blocks in LaTeX export, Next: Horizontal rules in LaTeX export, Prev: Example blocks in LaTeX export, Up: LaTeX export + +12.10.10 Special blocks in LaTeX export +--------------------------------------- In LaTeX back-end, special blocks become environments of the same name. Value of `:options' attribute will be appended as-is to that @@ -11511,8 +11503,11 @@ example: ... #+END_proof -Horizontal rules -................ + +File: org, Node: Horizontal rules in LaTeX export, Prev: Special blocks in LaTeX export, Up: LaTeX export + +12.10.11 Horizontal rules in LaTeX export +----------------------------------------- Width and thickness of a given horizontal rule can be controlled with, respectively, `:width' and `:thickness' attributes: @@ -11520,25 +11515,11 @@ respectively, `:width' and `:thickness' attributes: #+ATTR_LATEX: :width .6\textwidth :thickness 0.8pt ----- - ---------- Footnotes ---------- - - (1) Requires adding the `tabularx' package to -`org-latex-packages-alist'. - - (2) Requires adding the `tabu' package to `org-latex-packages-alist'. - - (3) Formerly, the value was `sidewaystable'. This is deprecated -since Org 8.3. - - (4) In the case of TikZ (`http://sourceforge.net/projects/pgf/') -images, it will become an `\input' macro wrapped within a `tikzpicture' -environment. -  -File: org, Node: Markdown export, Next: OpenDocument Text export, Prev: LaTeX and PDF export, Up: Exporting +File: org, Node: Markdown export, Next: OpenDocument Text export, Prev: LaTeX export, Up: Exporting -12.8 Markdown export -==================== +12.11 Markdown export +===================== `md' export back-end generates Markdown syntax(1) for an Org mode buffer. @@ -11578,18 +11559,18 @@ soft limit before that one (*note Export settings::).  File: org, Node: OpenDocument Text export, Next: Org export, Prev: Markdown export, Up: Exporting -12.9 OpenDocument Text export -============================= +12.12 OpenDocument Text export +============================== -Org mode(1) supports export to OpenDocument Text (ODT) format. -Documents created by this exporter use the `OpenDocument-v1.2 -specification'(2) and are compatible with LibreOffice 3.4. +Org mode supports export to OpenDocument Text (ODT) format. Documents +created by this exporter use the `OpenDocument-v1.2 specification'(1) +and are compatible with LibreOffice 3.4. * Menu: * Pre-requisites for ODT export:: What packages ODT exporter relies on * ODT export commands:: How to invoke ODT export -* ODT specific export settings:: Export settings for ODT +* ODT specific export settings:: Export settings for ODT * Extending ODT export:: How to produce `doc', `pdf' files * Applying custom styles:: How to apply custom styles to the output * Links in ODT export:: How links will be interpreted and formatted @@ -11602,17 +11583,15 @@ specification'(2) and are compatible with LibreOffice 3.4. ---------- Footnotes ---------- - (1) Versions 7.8 or later - - (2) Open Document Format for Office Applications (OpenDocument) + (1) Open Document Format for Office Applications (OpenDocument) Version 1.2 (http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2.html)  File: org, Node: Pre-requisites for ODT export, Next: ODT export commands, Up: OpenDocument Text export -12.9.1 Pre-requisites for ODT export ------------------------------------- +12.12.1 Pre-requisites for ODT export +------------------------------------- The ODT exporter relies on the `zip' program to create the final output. Check the availability of this program before proceeding @@ -11621,8 +11600,8 @@ further.  File: org, Node: ODT export commands, Next: ODT specific export settings, Prev: Pre-requisites for ODT export, Up: OpenDocument Text export -12.9.2 ODT export commands --------------------------- +12.12.2 ODT export commands +--------------------------- `C-c C-e o o (`org-odt-export-to-odt')' Export as OpenDocument Text file. @@ -11654,8 +11633,8 @@ File: org, Node: ODT export commands, Next: ODT specific export settings, Pre  File: org, Node: ODT specific export settings, Next: Extending ODT export, Prev: ODT export commands, Up: OpenDocument Text export -12.9.3 ODT specific export settings ------------------------------------ +12.12.3 ODT specific export settings +------------------------------------ The ODT exporter introduces a number of keywords, similar to the general options settings described in *note Export settings::. @@ -11679,8 +11658,8 @@ options settings described in *note Export settings::.  File: org, Node: Extending ODT export, Next: Applying custom styles, Prev: ODT specific export settings, Up: OpenDocument Text export -12.9.4 Extending ODT export ---------------------------- +12.12.4 Extending ODT export +---------------------------- The ODT exporter can interface with a variety of document converters and supports popular converters out of the box. As a result, you can @@ -11722,8 +11701,8 @@ following command.  File: org, Node: Applying custom styles, Next: Links in ODT export, Prev: Extending ODT export, Up: OpenDocument Text export -12.9.5 Applying custom styles ------------------------------ +12.12.5 Applying custom styles +------------------------------ The ODT exporter ships with a set of OpenDocument styles (*note Working with OpenDocument style files::) that ensure a well-formatted output. @@ -11775,8 +11754,8 @@ templates that are directly derived from the factory settings.  File: org, Node: Links in ODT export, Next: Tables in ODT export, Prev: Applying custom styles, Up: OpenDocument Text export -12.9.6 Links in ODT export --------------------------- +12.12.6 Links in ODT export +--------------------------- ODT exporter creates native cross-references for internal links. It creates Internet-style links for all other links. @@ -11792,8 +11771,8 @@ with a cross-reference and sequence number of the labeled entity.  File: org, Node: Tables in ODT export, Next: Images in ODT export, Prev: Links in ODT export, Up: OpenDocument Text export -12.9.7 Tables in ODT export ---------------------------- +12.12.7 Tables in ODT export +---------------------------- Export of native Org mode tables (*note Tables::) and simple `table.el' tables is supported. However, export of complex `table.el' @@ -11842,8 +11821,8 @@ default weight being 1  File: org, Node: Images in ODT export, Next: Math formatting in ODT export, Prev: Tables in ODT export, Up: OpenDocument Text export -12.9.8 Images in ODT export ---------------------------- +12.12.8 Images in ODT export +---------------------------- Embedding images ................ @@ -11913,7 +11892,7 @@ Anchoring of images ................... You can control the manner in which an image is anchored by setting the -`:anchor' property of it's `#+ATTR_ODT' line. You can specify one of +`:anchor' property of its `#+ATTR_ODT' line. You can specify one of the following three values for the `:anchor' property: `"as-char"', `"paragraph"' and `"page"'. @@ -11931,8 +11910,8 @@ Org files that has images using a Emacs batch script, then the use of  File: org, Node: Math formatting in ODT export, Next: Labels and captions in ODT export, Prev: Images in ODT export, Up: OpenDocument Text export -12.9.9 Math formatting in ODT export ------------------------------------- +12.12.9 Math formatting in ODT export +------------------------------------- The ODT exporter has special support for handling math. @@ -11994,14 +11973,16 @@ document in one of the following ways: #+OPTIONS: tex:dvipng + #+OPTIONS: tex:dvisvgm + or: #+OPTIONS: tex:imagemagick - 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 `dvipng' program or `imagemagick' - suite be available on your system. + With this option, LaTeX fragments are processed into PNG or SVG + images and the resulting images are embedded in the exported + document. This method requires that the `dvipng' program, + `dvisvgm' or `imagemagick' suite be available on your system. ---------- Footnotes ---------- @@ -12030,15 +12011,15 @@ formula (`.odf') file as shown below:  File: org, Node: Labels and captions in ODT export, Next: Literal examples in ODT export, Prev: Math formatting in ODT export, Up: OpenDocument Text export -12.9.10 Labels and captions in ODT export ------------------------------------------ +12.12.10 Labels and captions in ODT export +------------------------------------------ You can label and caption various category of objects--an inline image, a table, a LaTeX fragment or a Math formula--using `#+LABEL' and `#+CAPTION' lines. *Note Images and tables::. ODT exporter enumerates each labeled or captioned object of a given category separately. As a result, each such object is assigned a sequence number based on order -of it's appearance in the Org file. +of its appearance in the Org file. In the exported document, a user-provided caption is augmented with the category and sequence number. Consider the following inline image @@ -12068,15 +12049,15 @@ document.  File: org, Node: Literal examples in ODT export, Next: Advanced topics in ODT export, Prev: Labels and captions in ODT export, Up: OpenDocument Text export -12.9.11 Literal examples in ODT export --------------------------------------- +12.12.11 Literal examples in ODT export +--------------------------------------- Export of literal examples (*note Literal examples::) with full fontification is supported. Internally, the exporter relies on `htmlfontify.el' to generate all style definitions needed for a fancy -listing.(1) The auto-generated styles have `OrgSrc' as prefix and -inherit their color from the faces used by Emacs `font-lock' library -for the source language. +listing. The auto-generated styles have `OrgSrc' as prefix and inherit +their color from the faces used by Emacs `font-lock' library for the +source language. If you prefer to use your own custom styles for fontification, you can do so by customizing the option @@ -12085,16 +12066,11 @@ can do so by customizing the option You can turn off fontification of literal examples by customizing the option `org-odt-fontify-srcblocks'. - ---------- Footnotes ---------- - - (1) Your `htmlfontify.el' library must at least be at Emacs 24.1 -levels for fontification to be turned on. -  File: org, Node: Advanced topics in ODT export, Prev: Literal examples in ODT export, Up: OpenDocument Text export -12.9.12 Advanced topics in ODT export -------------------------------------- +12.12.12 Advanced topics in ODT export +-------------------------------------- If you rely heavily on ODT export, you may want to exploit the full set of features that the exporter offers. This section describes features @@ -12271,16 +12247,16 @@ couple of examples. 3. Embedding a block of OpenDocument XML You can add a large block of OpenDocument XML using the - `#+BEGIN_ODT'...`#+END_ODT' construct. + `#+BEGIN_EXPORT odt'...`#+END_EXPORT' construct. For example, to create a one-off paragraph that uses bold text, do the following: - #+BEGIN_ODT + #+BEGIN_EXPORT odt This paragraph is specially formatted and uses bold text. - #+END_ODT + #+END_EXPORT  @@ -12450,7 +12426,7 @@ take care of updating the `rng-schema-locating-files' for you.  File: org, Node: Org export, Next: Texinfo export, Prev: OpenDocument Text export, Up: Exporting -12.10 Org export +12.13 Org export ================ `org' export back-end creates a normalized version of the Org document @@ -12474,7 +12450,7 @@ Org export commands  File: org, Node: Texinfo export, Next: iCalendar export, Prev: Org export, Up: Exporting -12.11 Texinfo export +12.14 Texinfo export ==================== `texinfo' export back-end generates Texinfo code and can compile it into @@ -12483,18 +12459,23 @@ an Info file. * Menu: * Texinfo export commands:: How to invoke Texinfo export -* Texinfo specific export settings:: Export settings for Texinfo -* Document preamble:: File header, title and copyright page -* Headings and sectioning structure:: Building document structure +* Texinfo specific export settings:: Export settings for Texinfo +* Texinfo file header:: Generating the begining of a Texinfo file +* Texinfo title and copyright page:: Creating title and copyright pages +* Texinfo `Top' node:: Installing a manual in Info Top node +* Headings and sectioning structure:: Building document structure * Indices:: Creating indices * Quoting Texinfo code:: Incorporating literal Texinfo code -* Texinfo specific attributes:: Controlling Texinfo output -* An example:: +* Plain lists in Texinfo export:: Specific attributes for plain lists +* Tables in Texinfo export:: Specific attributes for tables +* Images in Texinfo export:: Specific attributes for images +* Special blocks in Texinfo export:: Specific attributes for special blocks +* A Texinfo example:: Illustrating Org to Texinfo process  File: org, Node: Texinfo export commands, Next: Texinfo specific export settings, Up: Texinfo export -12.11.1 Texinfo export commands +12.14.1 Texinfo export commands ------------------------------- `C-c C-e i t (`org-texinfo-export-to-texinfo')' @@ -12511,9 +12492,9 @@ File: org, Node: Texinfo export commands, Next: Texinfo specific export settin generate other formats, including DocBook.  -File: org, Node: Texinfo specific export settings, Next: Document preamble, Prev: Texinfo export commands, Up: Texinfo export +File: org, Node: Texinfo specific export settings, Next: Texinfo file header, Prev: Texinfo export commands, Up: Texinfo export -12.11.2 Texinfo specific export settings +12.14.2 Texinfo specific export settings ---------------------------------------- The Texinfo exporter introduces a number of keywords, similar to the @@ -12533,10 +12514,10 @@ general options settings described in *note Export settings::. must be a member of `org-texinfo-classes'. `TEXINFO_HEADER' - Arbitrary lines inserted at the end of the preamble. + Arbitrary lines inserted at the end of the header. `TEXINFO_POST_HEADER' - Arbitrary lines inserted at the end of the preamble. + Arbitrary lines inserted after the end of the header. `TEXINFO_DIR_CATEGORY' The directory category of the document. @@ -12550,23 +12531,11 @@ general options settings described in *note Export settings::. `TEXINFO_PRINTED_TITLE' The printed title of the document. - These keywords are treated in details in the following sections. -  -File: org, Node: Document preamble, Next: Headings and sectioning structure, Prev: Texinfo specific export settings, Up: Texinfo export - -12.11.3 Document preamble -------------------------- +File: org, Node: Texinfo file header, Next: Texinfo title and copyright page, Prev: Texinfo specific export settings, Up: Texinfo export -When processing a document, `texinfo' back-end generates a minimal file -header along with a title page, a copyright page, and a menu. You -control the latter through the structure of the document (*note -Headings and sectioning structure::). Various keywords allow to tweak -the other parts. It is also possible to give directions to install the -document in the `Top' node. - -File header -........... +12.14.3 Texinfo file header +--------------------------- Upon creating the header of a Texinfo file, the back-end guesses a name for the Info file to be compiled. This may not be a sensible choice, @@ -12580,12 +12549,18 @@ used(1). Insert a `#+TEXINFO_HEADER' keyword for each additional command needed, e.g., @code{@synindex}. If you happen to regularly install the same set of commands, it may -be easier to define your own class in `org-texinfo-classes', which see. -Set `#+TEXINFO_CLASS' keyword accordingly in your document to activate -it. +be easier to define your own class in `org-texinfo-classes'. Set +`#+TEXINFO_CLASS' keyword accordingly in your document to activate it. -Title and copyright page -........................ + ---------- Footnotes ---------- + + (1) See `org-texinfo-coding-system' for more information. + + +File: org, Node: Texinfo title and copyright page, Next: Texinfo `Top' node, Prev: Texinfo file header, Up: Texinfo export + +12.14.4 Texinfo title and copyright page +---------------------------------------- The default template includes a title page for hard copy output. The title and author displayed on this page are extracted from, @@ -12616,10 +12591,13 @@ does not appear in the structure of the document. This is a short example of a complete Texinfo file, version 1.0. - Copyright \copy 2015 Free Software Foundation, Inc. + Copyright \copy 2016 Free Software Foundation, Inc. -The Top node -............ + +File: org, Node: Texinfo `Top' node, Next: Headings and sectioning structure, Prev: Texinfo title and copyright page, Up: Texinfo export + +12.14.5 Texinfo `Top' node +-------------------------- You may ultimately want to install your new Info file in your system. You can write an appropriate entry in the top level directory @@ -12632,14 +12610,10 @@ example would write an entry similar to Org's in the `Top' node. #+TEXINFO_DIR_TITLE: Org Mode: (org) #+TEXINFO_DIR_DESC: Outline-based notes management and organizer - ---------- Footnotes ---------- - - (1) See `org-texinfo-coding-system' for more information. -  -File: org, Node: Headings and sectioning structure, Next: Indices, Prev: Document preamble, Up: Texinfo export +File: org, Node: Headings and sectioning structure, Next: Indices, Prev: Texinfo `Top' node, Up: Texinfo export -12.11.4 Headings and sectioning structure +12.14.6 Headings and sectioning structure ----------------------------------------- `texinfo' uses a pre-defined scheme, or class, to convert headlines into @@ -12672,7 +12646,7 @@ specify a description for the item in `:DESCRIPTION:' property. E.g.,  File: org, Node: Indices, Next: Quoting Texinfo code, Prev: Headings and sectioning structure, Up: Texinfo export -12.11.5 Indices +12.14.7 Indices --------------- Index entries are created using dedicated keywords. `texinfo' back-end @@ -12693,9 +12667,9 @@ and the index is inserted after its contents. :END:  -File: org, Node: Quoting Texinfo code, Next: Texinfo specific attributes, Prev: Indices, Up: Texinfo export +File: org, Node: Quoting Texinfo code, Next: Plain lists in Texinfo export, Prev: Indices, Up: Texinfo export -12.11.6 Quoting Texinfo code +12.14.8 Quoting Texinfo code ---------------------------- It is possible to insert raw Texinfo code using any of the following @@ -12706,23 +12680,16 @@ constructs #+TEXINFO: @need800 This paragraph is preceded by... - #+BEGIN_TEXINFO + #+BEGIN_EXPORT texinfo @auindex Johnson, Mark @auindex Lakoff, George - #+END_TEXINFO + #+END_EXPORT  -File: org, Node: Texinfo specific attributes, Next: An example, Prev: Quoting Texinfo code, Up: Texinfo export - -12.11.7 Texinfo specific attributes ------------------------------------ - -`texinfo' back-end understands several attributes in plain lists, tables -and images. They must be specified using an `#+ATTR_TEXINFO' keyword, -written just above the list, table or image. +File: org, Node: Plain lists in Texinfo export, Next: Tables in Texinfo export, Prev: Quoting Texinfo code, Up: Texinfo export -Plain lists -........... +12.14.9 Plain lists in Texinfo export +------------------------------------- In Texinfo output, description lists appear as two-column tables, using the default command `@table'. You can use `@ftable' or `@vtable'(1) @@ -12736,8 +12703,15 @@ you do not, it defaults to the value stored in #+ATTR_TEXINFO: :indic @asis - foo :: This is the text for /foo/, with no highlighting. -Tables -...... + ---------- Footnotes ---------- + + (1) For more information, *note (texinfo)Two-column Tables::. + + +File: org, Node: Tables in Texinfo export, Next: Images in Texinfo export, Prev: Plain lists in Texinfo export, Up: Texinfo export + +12.14.10 Tables in Texinfo export +--------------------------------- When exporting a table, column widths are deduced from the longest cell in each column. You can also define them explicitly as fractions of @@ -12746,8 +12720,11 @@ the line length, using `:columns' attribute. #+ATTR_TEXINFO: :columns .5 .5 | a cell | another cell | -Images -...... + +File: org, Node: Images in Texinfo export, Next: Special blocks in Texinfo export, Prev: Tables in Texinfo export, Up: Texinfo export + +12.14.11 Images in Texinfo export +--------------------------------- Images are links to files with a supported image extension and no description. Image scaling is set with `:width' and `:height' @@ -12757,15 +12734,32 @@ Texinfo code. #+ATTR_TEXINFO: :width 1in :alt Alternate @i{text} [[ridt.pdf]] - ---------- Footnotes ---------- + +File: org, Node: Special blocks in Texinfo export, Next: A Texinfo example, Prev: Images in Texinfo export, Up: Texinfo export - (1) For more information, *note (texinfo)Two-column Tables::. +12.14.12 Special blocks +----------------------- + +In Texinfo output, special blocks become commands of the same name. +Value of `:options' attribute is added right after the beginning of the +command. For example: + + #+attr_texinfo: :options org-org-export-to-org ... + #+begin_defun + A somewhat obsessive function. + #+end_defun + +becomes + + @defun org-org-export-to-org ... + A somewhat obsessive function. + @end defun  -File: org, Node: An example, Prev: Texinfo specific attributes, Up: Texinfo export +File: org, Node: A Texinfo example, Prev: Special blocks in Texinfo export, Up: Texinfo export -12.11.8 An example ------------------- +12.14.13 A Texinfo example +-------------------------- Here is a thorough example. *note (texinfo)GNU Sample Texts:: for an equivalent Texinfo code. @@ -12833,7 +12827,7 @@ equivalent Texinfo code.  File: org, Node: iCalendar export, Next: Other built-in back-ends, Prev: Texinfo export, Up: Exporting -12.12 iCalendar export +12.15 iCalendar export ====================== Some people use Org mode for keeping track of projects, but still @@ -12896,55 +12890,27 @@ application you are using. The FAQ covers this issue. hierarchy if you configure `org-use-property-inheritance' accordingly.  -File: org, Node: Other built-in back-ends, Next: Export in foreign buffers, Prev: iCalendar export, Up: Exporting +File: org, Node: Other built-in back-ends, Next: Advanced configuration, Prev: iCalendar export, Up: Exporting -12.13 Other built-in back-ends +12.16 Other built-in back-ends ============================== -On top of the aforementioned back-ends, Org comes with other built-in -ones: - - * `ox-man.el': export to a man page. - - To activate these export back-end, customize `org-export-backends' or -load them directly with e.g., `(require 'ox-man)'. This will add new -keys in the export dispatcher (*note The export dispatcher::). - - See the comment section of these files for more information on how -to use them. - - -File: org, Node: Export in foreign buffers, Next: Advanced configuration, Prev: Other built-in back-ends, Up: Exporting - -12.14 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: - -`org-html-convert-region-to-html' - Convert the selected region into HTML. - -`org-latex-convert-region-to-latex' - Convert the selected region into LaTeX. +On top of the aforementioned back-ends, Org comes with other built-in +ones: -`org-texinfo-convert-region-to-texinfo' - Convert the selected region into `Texinfo'. + * `ox-man.el': export to a man page. -`org-md-convert-region-to-md' - Convert the selected region into `MarkDown'. + To activate these export back-end, customize `org-export-backends' or +load them directly with e.g., `(require 'ox-man)'. This will add new +keys in the export dispatcher (*note The export dispatcher::). - This is particularly useful for converting tables and lists in -foreign buffers. E.g., in an HTML buffer, you can turn on -`orgstruct-mode', then use Org commands for editing a list, and finally -select and convert the list with `M-x org-html-convert-region-to-html -RET'. + See the comment section of these files for more information on how +to use them.  -File: org, Node: Advanced configuration, Prev: Export in foreign buffers, Up: Exporting +File: org, Node: Advanced configuration, Next: Export in foreign buffers, Prev: Other built-in back-ends, Up: Exporting -12.15 Advanced configuration +12.17 Advanced configuration ============================ Hooks @@ -13093,6 +13059,34 @@ to use the new back-end is calling the following from an Org buffer: It is obviously possible to write an interactive function for this, install it in the export dispatcher menu, and so on. + +File: org, Node: Export in foreign buffers, Prev: Advanced configuration, Up: Exporting + +12.18 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: + +`org-html-convert-region-to-html' + Convert the selected region into HTML. + +`org-latex-convert-region-to-latex' + Convert the selected region into LaTeX. + +`org-texinfo-convert-region-to-texinfo' + Convert the selected region into `Texinfo'. + +`org-md-convert-region-to-md' + Convert the selected region into `MarkDown'. + + This is particularly useful for converting tables and lists in +foreign buffers. E.g., in an HTML buffer, you can turn on +`orgstruct-mode', then use Org commands for editing a list, and finally +select and convert the list with `M-x org-html-convert-region-to-html +RET'. +  File: org, Node: Publishing, Next: Working with source code, Prev: Exporting, Up: Top @@ -13183,13 +13177,13 @@ to put published files. `:preparation-function'Function or list of functions to be called before starting the publishing process, for example, to run `make' for updating files to be published. - The project property list is scoped into this - call as the variable `project-plist'. + Each preparation function is called with a single + argument, the project property list. `:completion-function' Function or list of functions called after finishing the publishing process, for example, to - change permissions of the resulting files. The - project property list is scoped into this call as - the variable `project-plist'. + change permissions of the resulting files. Each + completion function is called with a single + argument, the project property list.  File: org, Node: Selecting files, Next: Publishing action, Prev: Sources and destinations, Up: Configuration @@ -13283,6 +13277,8 @@ Generic properties `:section-numbers' `org-export-with-section-numbers' `:select-tags' `org-export-select-tags' `:with-author' `org-export-with-author' +`:with-broken-links' `org-export-with-broken-links' +`:with-clocks' `org-export-with-clocks' `:with-creator' `org-export-with-creator' `:with-date' `org-export-with-date' `:with-drawers' `org-export-with-drawers' @@ -13399,10 +13395,12 @@ LaTeX specific properties `:latex-caption-above' `org-latex-caption-above' `:latex-classes' `org-latex-classes' `:latex-class' `org-latex-default-class' +`:latex-compiler' `org-latex-compiler' `:latex-default-figure-position' `org-latex-default-figure-position' `:latex-default-table-environment' `org-latex-default-table-environment' `:latex-default-table-mode' `org-latex-default-table-mode' `:latex-diary-timestamp-format' `org-latex-diary-timestamp-format' +`:latex-footnote-defined-format' `org-latex-footnote-defined-format' `:latex-footnote-separator' `org-latex-footnote-separator' `:latex-format-drawer-function' `org-latex-format-drawer-function' `:latex-format-headline-function' `org-latex-format-headline-function' @@ -13411,6 +13409,7 @@ LaTeX specific properties `:latex-image-default-height' `org-latex-image-default-height' `:latex-image-default-option' `org-latex-image-default-option' `:latex-image-default-width' `org-latex-image-default-width' +`:latex-images-centered' `org-latex-images-centered' `:latex-inactive-timestamp-format' `org-latex-inactive-timestamp-format' `:latex-inline-image-rules' `org-latex-inline-image-rules' `:latex-link-with-unknown-path-format' `org-latex-link-with-unknown-path-format' @@ -13432,7 +13431,9 @@ LaTeX specific properties Markdown specific properties ............................ -`:md-headline-style' `org-md-headline-style' +`:md-footnote-format' `org-md-footnote-format' +`:md-footnotes-section' `org-md-footnotes-section' +`:md-headline-style' `org-md-headline-style' ODT specific properties ....................... @@ -13476,19 +13477,29 @@ File: org, Node: Publishing links, Next: Sitemap, Prev: Publishing options, ------------------------------------ To create a link from one Org file to another, you would use something -like `[[file:foo.org][The foo]]' or simply `file:foo.org.' (*note -Hyperlinks::). When published, this link becomes a link to `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 `http:' link -instead of a `file:' link, because `file:' links are converted to link -to the corresponding `html' file. +like `[[file:foo.org][The foo]]' or simply `file:foo.org' (*note +External links::). When published, this link becomes a link to +`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 +`http:' link instead of a `file:' link, because `file:' links are +converted to link to the corresponding `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 *note Complex example::, for an example of this usage. + Eventually, links between published documents can contain some +search options (*note Search options::), which will be resolved to the +appropriate location in the linked file. For example, once published +to HTML, the following links all point to a dedicated anchor in +`foo.html'. + + [[file:foo.org::*heading]] + [[file:foo.org::#custom-id]] + [[file:foo.org::target]] +  File: org, Node: Sitemap, Next: Generating an index, Prev: Publishing links, Up: Configuration @@ -13505,15 +13516,36 @@ files for a given project. `sitemap.org' (which becomes `sitemap.html'). `:sitemap-title' Title of sitemap page. Defaults to name of file. +`:sitemap-format-entry' With this option one can tell how a site-map + entry is formatted in the site-map. It is a + function called with three arguments: the file + or directory name relative to base directory + of the project, the site-map style and the + current project. It is expected to return a + string. Default value turns file names into + links and use document titles as descriptions. + For specific formatting needs, one can use + `org-publish-find-date', + `org-publish-find-title' and + `org-publish-find-property', to retrieve + additional information about published + documents. `:sitemap-function' Plug-in function to use for generation of the - sitemap. Defaults to - `org-publish-org-sitemap', which generates a - plain list of links to all files in the - project. + sitemap. It is called with two arguments: the + title of the site-map and a representation of + the files and directories involved in the + project as a radio list (*note Radio lists::). + The latter can further be transformed using + `org-list-to-generic', `org-list-to-subtree' + and alike. Default value generates a plain + list of links to all files in the project. `: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. + When set to `ignore', folders are ignored + altogether. Any other value will mix files + and folders. This variable has no effect when + site-map style is `tree'. `:sitemap-sort-files' How the files are sorted in the site map. Set this to `alphabetically' (default), `chronologically' or `anti-chronologically'. @@ -13525,26 +13557,11 @@ files for a given project. retrieved with `org-publish-find-date'. `:sitemap-ignore-case' Should sorting be case-sensitive? Default `nil'. -`:sitemap-file-entry-format'With this option one can tell how a sitemap's - entry is formatted in the sitemap. This is a - format string with some escape sequences: `%t' - stands for the title of the file, `%a' stands - for the author of the file and `%d' stands for - the date of the file. The date is retrieved - with the `org-publish-find-date' function and - formatted with - `org-publish-sitemap-date-format'. Default - `%t'. `:sitemap-date-format' Format string for the `format-time-string' function that tells how a sitemap entry's date is to be formatted. This property bypasses `org-publish-sitemap-date-format' which defaults to `%Y-%m-%d'. -`:sitemap-sans-extension' When non-`nil', remove filenames' extensions - from the generated sitemap. Useful to have - cool URIs (see - `http://www.w3.org/Provider/Style/URI'). - Defaults to `nil'.  File: org, Node: Generating an index, Prev: Sitemap, Up: Configuration @@ -13562,6 +13579,13 @@ Org mode can generate an index across the files of a publishing project. "theindex.inc"'. You can then build around this include statement by adding a title, style information, etc. + Index entries are specified with `#+INDEX' keyword. An entry that +contains an exclamation mark will create a sub item. + + * Curriculum Vitae + #+INDEX: CV + #+INDEX: Application!CV +  File: org, Node: Uploading files, Next: Sample configuration, Prev: Configuration, Up: Publishing @@ -13713,8 +13737,13 @@ File: org, Node: Working with source code, Next: Miscellaneous, Prev: Publish 14 Working with source code *************************** -Source code can be included in Org mode documents using a `src' block, -e.g.: +Source code here refers to any code typed in Org mode documents. Org +can manage source code in any Org file once such code is tagged with +begin and end markers. Working with source code begins with tagging +source code blocks. Tagged `src' code blocks are not restricted to the +preamble or the end of an Org document; they can go anywhere--with a +few exceptions, such as not inside comments and fixed width areas. +Here's a sample `src' code block in emacs-lisp: #+BEGIN_SRC emacs-lisp (defun org-xor (a b) @@ -13722,16 +13751,62 @@ e.g.: (if a (not b) b)) #+END_SRC - Org mode provides a number of features for working with live source -code, including editing of code blocks in their native major-mode, -evaluation of code blocks, converting code blocks into source files -(known as "tangling" in literate programming), and exporting code -blocks and their results in several formats. This functionality was -contributed by Eric Schulte and Dan Davison, and was originally named -Org-babel. - - The following sections describe Org mode's code block handling -facilities. + Org can take the code in the block between the `#+BEGIN_SRC' and +`#+END_SRC' tags, and format, compile, execute, and show the results. +Org can simplify many housekeeping tasks essential to modern code +maintenance. That's why these blocks in Org mode literature are +sometimes referred to as `live code' blocks (as compared to the static +text and documentation around it). Users can control how `live' they +want each block by tweaking the headers for compiling, execution, +extraction. + + Org's `src' code block type is one of many block types, such as +quote, export, verse, latex, example, and verbatim. This section +pertains to `src' code blocks between `#+BEGIN_SRC' and `#+END_SRC' + + For editing `src' code blocks, Org provides native Emacs major-modes. +That leverages the latest Emacs features for that source code language +mode. + + For exporting, Org can then extract `src' code blocks into compilable +source files (in a conversion process known as "tangling" in literate +programming terminology). + + For publishing, Org's back-ends can handle the `src' code blocks and +the text for output to a variety of formats with native syntax +highlighting. + + For executing the source code in the `src' code blocks, Org provides +facilities that glue the tasks of compiling, collecting the results of +the execution, and inserting them back to the Org file. Besides text +output, results may include links to other data types that Emacs can +handle: audio, video, and graphics. + + An important feature of Org's execution of the `src' code blocks is +passing variables, functions, and results between `src' blocks. Such +interoperability uses a common syntax even if these `src' blocks are in +different source code languages. The integration extends to linking the +debugger's error messages to the line in the `src' code block in the Org +file. That should partly explain why this functionality by the original +contributors, Eric Schulte and Dan Davison, was called `Org Babel'. + + In literate programming, the main appeal is code and documentation +co-existing in one file. Org mode takes this several steps further. +First by enabling execution, and then by inserting results of that +execution back into the Org file. Along the way, Org provides +extensive formatting features, including handling tables. Org handles +multiple source code languages in one file, and provides a common +syntax for passing variables, functions, and results between `src' code +blocks. + + Org mode fulfills the promise of easy verification and maintenance of +publishing reproducible research by keeping all these in the same file: +text, data, code, configuration settings of the execution environment, +the results of the execution, and associated narratives, claims, +references, and internal and external links. + + Details of Org's facilities for working with source code are shown +next. * Menu: @@ -13754,19 +13829,25 @@ File: org, Node: Structure of code blocks, Next: Editing source code, Up: Wor 14.1 Structure of code blocks ============================= -Live code blocks can be specified with a `src' block or inline.(1) The -structure of a `src' block is +Org offers two ways to structure source code in Org documents: in a +`src' block, and directly inline. Both specifications are shown below. + + A `src' block conforms to this structure: #+NAME: #+BEGIN_SRC
#+END_SRC - The `#+NAME:' line is optional, and can be used to name the code -block. Live code blocks require that a language be specified on the -`#+BEGIN_SRC' line. Switches and header arguments are optional. + Org mode's templates system (*note Easy templates::) speeds up +creating `src' code blocks with just three keystrokes. Do not be +put-off by having to remember the source block syntax. Org also works +with other completion systems in Emacs, some of which predate Org and +have custom domain-specific languages for defining templates. Regular +use of templates reduces errors, increases accuracy, and maintains +consistency. - Live code blocks can also be specified inline using + An inline code block conforms to this structure: src_{} @@ -13774,38 +13855,43 @@ block. Live code blocks require that a language be specified on the src_[
]{} -`<#+NAME: name>' - This line associates a name with the code block. This is similar - to the `#+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 *note The - spreadsheet::). Names are assumed to be unique and the behavior - of Org mode when two or more blocks share the same name is - undefined. +`#+NAME: ' + Optional. Names the `src' block so it can be called, like a + function, from other `src' blocks or inline blocks to evaluate or + to capture the results. Code from other blocks, other files, and + from table formulas (*note The spreadsheet::) can use the name to + reference a `src' block. This naming serves the same purpose as + naming Org tables. Org mode requires unique names. For duplicate + names, Org mode's behavior is undefined. + +`#+BEGIN_SRC' + +`#+END_SRC' + Mandatory. They mark the start and end of a block that Org + requires. The `#+BEGIN_SRC' line takes additional arguments, as + described next. `' - The language of the code in the block (see *note Languages::). + Mandatory for live code blocks. It is the identifier of the + source code language in the block. *Note Languages::, for + identifiers of supported languages. `' - Optional switches control code block export (see the discussion of - switches in *note Literal examples::) + Optional. Switches provide finer control of the code execution, + export, and format (see the discussion of switches in *note + Literal examples::) `
' - Optional header arguments control many aspects of evaluation, - export and tangling of code blocks (see *note Header arguments::). - Header arguments can also be set on a per-buffer or per-subtree - basis using properties. + Optional. Heading arguments control many aspects of evaluation, + export and tangling of code blocks (*note Header arguments::). + Using Org's properties feature, header arguments can be + selectively applied to the entire buffer or specific sub-trees of + the Org document. `source code, header arguments' `' - Source code in the specified language. - - ---------- Footnotes ---------- - - (1) Note that `src' blocks may be inserted using Org mode's *note -Easy templates:: system + Source code in the dialect of the specified language identifier.  File: org, Node: Editing source code, Next: Exporting code blocks, Prev: Structure of code blocks, Up: Working with source code @@ -13813,45 +13899,63 @@ File: org, Node: Editing source code, Next: Exporting code blocks, Prev: Stru 14.2 Editing source code ======================== -Use `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 will write the contents back to the -Org buffer. You can also set `org-edit-src-auto-save-idle-delay' to -save the base buffer after some idle delay, or -`org-edit-src-turn-on-auto-save' to auto-save this buffer into a -separate file using `auto-save-mode'. Use `C-c '' again to exit. +`C-c '' for editing the current code block. It opens a new major-mode +edit buffer containing the body of the `src' code block, ready for any +edits. `C-c '' again to close the buffer and return to the Org buffer. + + saves the buffer and updates the contents of the Org +buffer. + + Set `org-edit-src-auto-save-idle-delay' to save the base buffer after +a certain idle delay time. - The `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 -buffer. See also the customization group `org-edit-structure' for -further configuration options. + Set `org-edit-src-turn-on-auto-save' to auto-save this buffer into a +separate file using `auto-save-mode'. + + `C-c '' to close the major-mode buffer and return back to the Org +buffer. + + While editing the source code in the major-mode, the `org-src-mode' +minor mode remains active. It provides these customization variables as +described below. For even more variables, look in the customization +group `org-edit-structure'. `org-src-lang-modes' If an Emacs major-mode named `-mode' exists, where `' - is the language named in the header line of the code block, then - the edit buffer will be placed in that major-mode. This variable - can be used to map arbitrary language names to existing major - modes. + is the language identifier from code block's header line, then the + edit buffer uses that major-mode. Use this variable to + arbitrarily map language identifiers to major modes. `org-src-window-setup' - Controls the way Emacs windows are rearranged when the edit buffer + For specifying Emacs window arrangement when the new edit buffer is created. `org-src-preserve-indentation' - By default, the value is `nil', which means that when code blocks - are evaluated during export or tangled, they are re-inserted into - the code block, which may replace sequences of spaces with tab - characters. When non-`nil', whitespace in code blocks will be - preserved during export or tangling, exactly as it appears. This - variable is especially useful for tangling languages such as - Python, in which whitespace indentation in the output is critical. + Default is `nil'. Source code is indented. This indentation + applies during export or tangling, and depending on the context, + may alter leading spaces and tabs. When non-`nil', source code is + aligned with the leftmost column. No lines are modified during + export or tangling, which is very useful for white-space sensitive + languages, such as Python. `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. + When `nil', Org returns to the edit buffer without further + prompts. The default prompts for a confirmation. + + Set `org-src-fontify-natively' to non-`nil' to turn on native code +fontification in the _Org_ buffer. Fontification of `src' code blocks +can give visual separation of text and code on the display page. To +further customize the appearance of `org-block' for specific languages, +customize `org-src-block-faces'. The following example shades the +background of regular blocks, and colors source blocks only for Python +and Emacs-Lisp languages. + (require 'color) + (set-face-attribute 'org-block nil :background + (color-darken-name + (face-attribute 'default :background) 3)) - To turn on native code fontification in the _Org_ buffer, configure -the variable `org-src-fontify-natively'. + (setq org-src-block-faces '(("emacs-lisp" (:background "#EEE2FF")) + ("python" (:background "#E5FFB8"))))  File: org, Node: Exporting code blocks, Next: Extracting source code, Prev: Editing source code, Up: Working with source code @@ -13859,53 +13963,59 @@ File: org, Node: Exporting code blocks, Next: Extracting source code, Prev: E 14.3 Exporting code blocks ========================== -It is possible to export the _code_ of code blocks, the _results_ of -code block evaluation, _both_ the code and the results of code block -evaluation, or _none_. For most languages, the default exports code. -However, for some languages (e.g., `ditaa') the default exports the -results of code block evaluation. For information on exporting code -block bodies, see *note Literal examples::. +Org can flexibly export just the _code_ from the code blocks, just the +_results_ of evaluation of the code block, _both_ the code and the +results of the code block evaluation, or _none_. Org defaults to +exporting _code_ for most languages. For some languages, such as +`ditaa', Org defaults to _results_. To export just the body of code +blocks, *note Literal examples::. To selectively export sub-trees of +an Org document, *note Exporting::. - The `:exports' header argument can be used to specify export -behavior (note that these arguments are only relevant for code blocks, -not inline code): + The `:exports' header arguments control exporting code blocks only +and not inline code: Header arguments: ................. `:exports code' - The default in most languages. The body of the code block is - exported, as described in *note Literal examples::. + This is the default for most languages where the body of the code + block is exported. See *note Literal examples:: for more. `:exports results' - The code block will be evaluated each time to buffer is exported, - and the results will be placed in the Org mode buffer for export, - either updating previous results of the code block located - anywhere in the buffer or, if no previous results exist, placing - the results immediately after the code block. The body of the - code block will not be exported. + On export, Org includes only the results and not the code block. + After each evaluation, Org inserts the results after the end of + code block in the Org buffer. By default, Org replaces any + previous results. Org can also append results. `:exports both' - Both the code block and its results will be exported. + Org exports both the code block and the results. `:exports none' - Neither the code block nor its results will be exported. + Org does not export the code block nor the results. - It is possible to inhibit the evaluation of code blocks during -export. Setting the `org-export-babel-evaluate' variable to `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. It is also possible to set -this variable to `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. + To stop Org from evaluating code blocks to speed exports, use the +header argument `:eval never-export' (*note eval::). To stop Org from +evaluating code blocks for greater security, set the +`org-export-use-babel' variable to `nil', but understand that header +arguments will have no effect. - Code blocks in commented subtrees (*note Comment lines::) are never -evaluated on export. However, code blocks in subtrees excluded from -export (*note Export settings::) may be evaluated on export. + Turning off evaluation comes in handy when batch processing. For +example, markup languages for wikis, which have a high risk of +untrusted code. Stopping code block evaluation also stops evaluation +of all header arguments of the code block. This may not be desirable +in some circumstances. So during export, to allow evaluation of just +the header arguments but not any code evaluation in the source block, +set `:eval never-export' (*note eval::). + + To evaluate just the inline code blocks, set +`org-export-babel-evaluate' to `inline-only'. Isolating the option to +allow inline evaluations separate from `src' code block evaluations +during exports is not for security but for avoiding any delays due to +recalculations, such as calls to a remote database. + + Org never evaluates code blocks in commented sub-trees when exporting +(*note Comment lines::). On the other hand, Org does evaluate code +blocks in sub-trees excluded from export (*note Export settings::).  File: org, Node: Extracting source code, Next: Evaluating code blocks, Prev: Exporting code blocks, Up: Working with source code @@ -13913,25 +14023,35 @@ File: org, Node: Extracting source code, Next: Evaluating code blocks, Prev: 14.4 Extracting source code =========================== -Creating pure source code files by extracting code from source blocks is -referred to as "tangling"--a term adopted from the literate programming -community. During "tangling" of code blocks their bodies are expanded -using `org-babel-expand-src-block' which can expand both variable and -"noweb" style references (see *note Noweb reference syntax::). +Extracting source code from code blocks is a basic task in literate +programming. Org has features to make this easy. In literate +programming parlance, documents on creation are _woven_ with code and +documentation, and on export, the code is _tangled_ for execution by a +computer. Org facilitates weaving and tangling for producing, +maintaining, sharing, and exporting literate programming documents. +Org provides extensive customization options for extracting source code. + + When Org tangles `src' code blocks, it expands, merges, and +transforms them. Then Org recomposes them into one or more separate +files, as configured through the options. During this _tangling_ +process, Org expands variables in the source code, and resolves any +"noweb" style references (*note Noweb reference syntax::). Header arguments ................ `:tangle no' - The default. The code block is not included in the tangled output. + By default, Org does not tangle the `src' code block on export. `:tangle yes' - Include the code block in the tangled output. The output file - name is the name of the org file with the extension `.org' - replaced by the extension for the block language. + Org extracts the contents of the code block for the tangled + output. By default, the output file name is the same as the Org + file but with a file extension derived from the language + identifier of the `src' code block. `:tangle filename' - Include the code block in the tangled output to file `filename'. + Override the default file name with this one for the tangled + output. Functions ......... @@ -13939,7 +14059,7 @@ Functions `org-babel-tangle' Tangle the current file. Bound to `C-c C-v t'. - With prefix argument only tangle the current code block. + With prefix argument only tangle the current `src' code block. `org-babel-tangle-file' Choose a file to tangle. Bound to `C-c C-v f'. @@ -13948,26 +14068,20 @@ Hooks ..... `org-babel-post-tangle-hook' - This hook is run from within code files tangled by - `org-babel-tangle'. Example applications could include - post-processing, compilation or evaluation of tangled code files. + This hook runs from within code tangled by `org-babel-tangle', + making it suitable for post-processing, compilation, and + evaluation of code in the tangled files. 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 `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 `padline' (*note padline::) option must -be set to true (the default setting), second the `comments' (*note -comments::) header argument must be set to `link', which will insert -comments into the source code buffer which point back to the original -Org-mode file. +Debuggers normally link errors and messages back to the source code. +But for tangled files, we want to link back to the Org file, not to the +tangled source file. To make this extra jump, Org uses +`org-babel-tangle-jump-to-org' function with two additional source code +block header arguments: One, set `padline' (*note padline::) to true +(the default setting). Two, set `comments' (*note comments::) to +`link', which makes Org insert links to the Org file.  File: org, Node: Evaluating code blocks, Next: Library of Babel, Prev: Extracting source code, Up: Working with source code @@ -13975,107 +14089,95 @@ File: org, Node: Evaluating code blocks, Next: Library of Babel, Prev: Extrac 14.5 Evaluating code blocks =========================== -Code blocks can be evaluated(1) and the results of evaluation -optionally placed in the Org mode buffer. The results of evaluation -are placed following a line that begins by default with `#+RESULTS' and -optionally a cache identifier and/or the name of the evaluated code -block. The default value of `#+RESULTS' can be changed with the -customizable variable `org-babel-results-keyword'. - - By default, the evaluation facility is only enabled for Lisp code -blocks specified as `emacs-lisp'. However, source code blocks in many -languages can be evaluated within Org mode (see *note Languages:: for a -list of supported languages and *note Structure of code blocks:: for -information on the syntax used to define a code block). - - There are a number of ways to evaluate code blocks. The simplest is -to press `C-c C-c' or `C-c C-v e' with the point on a code block(2). -This will call the `org-babel-execute-src-block' function to evaluate -the block and insert its results into the Org mode buffer. - - It is also possible to evaluate named code blocks from anywhere in -an Org mode buffer or an Org mode table. These named code blocks can -be located in the current Org mode buffer or in the "Library of Babel" -(*note Library of Babel::). Named code blocks can be evaluated with a -separate `#+CALL:' line or inline within a block of text. In both -cases the result is wrapped according to the value of -`org-babel-inline-result-wrap', which by default is `"=%s="' for markup -that produces verbatim text. - - The syntax of the `#+CALL:' line is +A note about security: With code evaluation comes the risk of harm. Org +safeguards by prompting for user's permission before executing any code +in the source block. To customize this safeguard (or disable it) see +*note Code evaluation security::. + + Org captures the results of the `src' code block evaluation and +inserts them in the Org file, right after the `src' code block. The +insertion point is after a newline and the `#+RESULTS' label. Org +creates the `#+RESULTS' label if one is not already there. + + By default, Org enables only `emacs-lisp' `src' code blocks for +execution. See *note Languages:: for identifiers to enable other +languages. + + Org provides many ways to execute `src' code blocks. `C-c C-c' or +`C-c C-v e' with the point on a `src' code block(1) calls the +`org-babel-execute-src-block' function, which executes the code in the +block, collects the results, and inserts them in the buffer. + + By calling a named code block(2) from an Org mode buffer or a table. +Org can call the named `src' code blocks from the current Org mode +buffer or from the "Library of Babel" (*note Library of Babel::). +Whether inline syntax or the `#+CALL:' syntax is used, the result is +wrapped based on the variable `org-babel-inline-result-wrap', which by +default is set to `"=%s="' to produce verbatim text suitable for markup. + + The syntax for `#+CALL:' is #+CALL: () #+CALL: []() - The syntax for inline evaluation of named code blocks is + The syntax for inline named code block is ... call_() ... ... call_[]()[] ... `' - The name of the code block to be evaluated (see *note Structure of - code blocks::). + This is the name of the code block to be evaluated (*note + Structure of code blocks::). `' - Arguments specified in this section will be passed to the code - block. These arguments use standard function call syntax, rather - than header argument syntax. For example, a `#+CALL:' line that - passes the number four to a code block named `double', which - declares the header argument `:var n=2', would be written as - `#+CALL: double(n=4)'. + Org passes arguments to the code block using standard function + call syntax. For example, a `#+CALL:' line that passes `4' to a + code block named `double', which declares the header argument + `:var n=2', would be written as `#+CALL: double(n=4)'. Note how + this function call syntax is different from the header argument + syntax. `' - Inside header arguments are passed through and applied to the - named code block. These arguments use header argument syntax - rather than standard function call syntax. Inside header - arguments affect how the code block is evaluated. For example, - `[:results output]' will collect the results of everything printed - to `STDOUT' during execution of the code block. + Org passes inside header arguments to the named `src' code block + using the header argument syntax. Inside header arguments apply + to code block evaluation. For example, `[:results output]' + collects results printed to `STDOUT' during code execution of that + block. Note how this header argument syntax is different from the + function call syntax. `' - End header arguments are applied to the calling instance and do - not affect evaluation of the named code block. They affect how - the results are incorporated into the Org mode buffer and how the - call line is exported. For example, `:results html' will insert - the results of the call line evaluation in the Org buffer, wrapped - in a `BEGIN_HTML:' block. + End header arguments affect the results returned by the code + block. For example, `:results html' wraps the results in a + `BEGIN_EXPORT html' block before inserting the results in the Org + buffer. - For more examples of passing header arguments to `#+CALL:' lines - see *note Header arguments in function calls::. + For more examples of header arguments for `#+CALL:' lines, *note + Arguments in function calls::. ---------- Footnotes ---------- - (1) Whenever code is evaluated there is a potential for that code to -do harm. Org mode provides safeguards to ensure that code is only -evaluated after explicit confirmation from the user. For information -on these safeguards (and on how to disable them) see *note Code -evaluation security::. - - (2) The option `org-babel-no-eval-on-ctrl-c-ctrl-c' can be used to + (1) The option `org-babel-no-eval-on-ctrl-c-ctrl-c' can be used to remove code evaluation from the `C-c C-c' key binding. + (2) Actually, the constructs call_() and src_{} are not +evaluated when they appear in a keyword line (i.e. lines starting with +`#+KEYWORD:', *note In-buffer settings::). +  File: org, Node: Library of Babel, Next: Languages, Prev: Evaluating code blocks, Up: Working with source code 14.6 Library of Babel ===================== -The "Library of Babel" consists of code blocks that can be called from -any Org mode file. Code blocks defined in the "Library of Babel" can -be called remotely as if they were in the current Org mode buffer (see -*note Evaluating code blocks:: for information on the syntax of remote -code block evaluation). +The "Library of Babel" is a collection of code blocks. Like a function +library, these code blocks can be called from other Org files. This +collection is in a repository file in Org mode format in the `doc' +directory of Org mode installation. For remote code block evaluation +syntax, *note Evaluating code blocks::. - The central repository of code blocks in the "Library of Babel" is -housed in an Org mode file located in the `doc' directory of Org mode. - - Users can add code blocks they believe to be generally useful to -their "Library of Babel." The code blocks can be stored in any Org -mode file and then loaded into the library with `org-babel-lob-ingest'. - - Code blocks located in any Org mode file can be loaded into the -"Library of Babel" with the `org-babel-lob-ingest' function, bound to -`C-c C-v i'. + For any user to add code to the library, first save the code in +regular `src' code blocks of an Org file, and then load the Org file +with `org-babel-lob-ingest', which is bound to `C-c C-v i'.  File: org, Node: Languages, Next: Header arguments, Prev: Library of Babel, Up: Working with source code @@ -14083,7 +14185,7 @@ File: org, Node: Languages, Next: Header arguments, Prev: Library of Babel, 14.7 Languages ============== -Code blocks in the following languages are supported. +Org supports the following languages for the `src' code blocks: Language Identifier Language Identifier ---------------------------------------------------------------------------- @@ -14097,38 +14199,36 @@ gnuplot gnuplot Haskell haskell Java java Javascript js LaTeX latex Ledger ledger Lisp lisp Lilypond lilypond -MATLAB matlab Mscgen mscgen -Objective Caml ocaml Octave octave -Org mode org Oz oz -Perl perl Plantuml plantuml -Processing.js processing Python python -R R Ruby ruby -Sass sass Scheme scheme -GNU Screen screen Sed sed -shell sh SQL sql -SQLite sqlite - - Language-specific documentation is available for some languages. If -available, it can be found at +Lua lua MATLAB matlab +Mscgen mscgen Objective Caml ocaml +Octave octave Org mode org +Oz oz Perl perl +Plantuml plantuml Processing.js processing +Python python R R +Ruby ruby Sass sass +Scheme scheme GNU Screen screen +Sed sed shell sh +SQL sql SQLite sqlite + + Additional documentation for some languages are at `http://orgmode.org/worg/org-contrib/babel/languages.html'. - The option `org-babel-load-languages' controls which languages are -enabled for evaluation (by default only `emacs-lisp' is enabled). This -variable can be set using the customization interface or by adding code -like the following to your emacs configuration. + By default, only `emacs-lisp' is enabled for evaluation. To enable +or disable other languages, customize the `org-babel-load-languages' +variable either through the Emacs customization interface, or by adding +code to the init file as shown next: - The following disables `emacs-lisp' evaluation and enables -evaluation of `R' code blocks. + In this example, evaluation is disabled for `emacs-lisp', and enabled +for `R'. (org-babel-do-load-languages 'org-babel-load-languages '((emacs-lisp . nil) (R . t))) - It is also possible to enable support for a language by loading the -related elisp file with `require'. - - The following adds support for evaluating `clojure' code blocks. + Note that this is not the only way to enable a language. Org also +enables languages when loaded with `require' statement. For example, +the following enables execution of `clojure' code blocks: (require 'ob-clojure) @@ -14138,9 +14238,7 @@ File: org, Node: Header arguments, Next: Results of evaluation, Prev: Languag 14.8 Header arguments ===================== -Code block functionality can be configured with header arguments. This -section provides an overview of the use of header arguments, and then -describes each header argument in detail. +Details of configuring header arguments are shown here. * Menu: @@ -14153,21 +14251,19 @@ File: org, Node: Using header arguments, Next: Specific header arguments, Up: 14.8.1 Using header arguments ----------------------------- -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. +Since header arguments can be set in several ways, Org prioritizes them +in case of overlaps or conflicts by giving local settings a higher +priority. Header values in function calls, for example, override +header values from global defaults. * Menu: -* System-wide header arguments:: Set global default values -* Language-specific header arguments:: Set default values by language -* 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 +* System-wide header arguments:: Set globally, language-specific +* Language-specific header arguments:: Set in the Org file's headers +* Header arguments in Org mode properties:: Set in the Org file +* Language-specific mode properties:: +* Code block specific header arguments:: The most commonly used method +* Arguments in function calls:: The most specific level, takes highest priority  File: org, Node: System-wide header arguments, Next: Language-specific header arguments, Up: Using header arguments @@ -14184,10 +14280,8 @@ System-wide values of header arguments can be specified by adapting the :cache => "no" :noweb => "no" - For example, the following example could be used to set the default -value of `:noweb' header arguments to `yes'. This would have the -effect of expanding `:noweb' references by default when evaluating -source code blocks. + This example sets `:noweb' header arguments to `yes', which makes +Org expand `:noweb' references by default. (setq org-babel-default-header-args (cons '(:noweb . "yes") @@ -14199,66 +14293,55 @@ File: org, Node: Language-specific header arguments, Next: Header arguments in Language-specific header arguments .................................. -Each language can define its own set of default header arguments in -variable `org-babel-default-header-args:', where `' is the -name of the language. See the language-specific documentation -available online at `http://orgmode.org/worg/org-contrib/babel'. +Each language can have separate default header arguments by customizing +the variable `org-babel-default-header-args:', where `' is +the name of the language. For details, see the language-specific online +documentation at `http://orgmode.org/worg/org-contrib/babel'.  -File: org, Node: Header arguments in Org mode properties, Next: Language-specific header arguments in Org mode properties, Prev: Language-specific header arguments, Up: Using header arguments +File: org, Node: Header arguments in Org mode properties, Next: Language-specific mode properties, Prev: Language-specific header arguments, Up: Using header arguments Header arguments in Org mode properties ....................................... -Buffer-wide header arguments may be specified as properties through the -use of `#+PROPERTY:' lines placed anywhere in an Org mode file (see -*note Property syntax::). +For header arguments applicable to the buffer, use `#+PROPERTY:' lines +anywhere in the Org mode file (*note Property syntax::). - For example the following would set `session' to `*R*' (only for R -code blocks), and `results' to `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. + The following example sets only for `R' code blocks to `session', +making all the `R' code blocks execute in the same session. Setting +`results' to `silent' ignores the results of executions for all blocks, +not just `R' code blocks; no results inserted for any block. #+PROPERTY: header-args:R :session *R* #+PROPERTY: header-args :results silent - Header arguments read from Org mode properties can also be set on a -per-subtree basis using property drawers (see *note Property syntax::). When -properties are used to set default header arguments, they are always -looked up with inheritance, regardless of the value of -`org-use-property-inheritance'. Properties are evaluated as seen by the -outermost call or source block.(1) + Header arguments set through Org's property drawers (*note Property +syntax::) apply at the sub-tree level on down. Since these property +drawers can appear anywhere in the file hierarchy, Org uses outermost +call or source block to resolve the values. Org ignores +`org-use-property-inheritance' setting. - In the following example the value of the `:cache' header argument -will default to `yes' in all code blocks in the subtree rooted at the -following heading: + In this example, `:cache' defaults to `yes' for all code blocks in +the sub-tree starting with `sample header'. - * outline header + * sample header :PROPERTIES: :header-args: :cache yes :END: - Properties defined in this way override the properties set in -`org-babel-default-header-args' and are applied for all activated -languages. It is convenient to use the `org-set-property' function -bound to `C-c C-x p' to set properties in Org mode documents. - - ---------- Footnotes ---------- - - (1) 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 behavior has been kept for backwards compatibility. + Properties defined through `org-set-property' function, bound to +`C-c C-x p', apply to all active languages. They override properties +set in `org-babel-default-header-args'.  -File: org, Node: Language-specific header arguments in Org mode properties, Next: Code block specific header arguments, Prev: Header arguments in Org mode properties, Up: Using header arguments +File: org, Node: Language-specific mode properties, Next: Code block specific header arguments, Prev: Header arguments in Org mode properties, Up: Using header arguments -Language-specific header arguments in Org mode properties -......................................................... +Language-specific mode properties +................................. Language-specific header arguments are also read from properties -`header-args:' where `' is the name of the language -targeted. As an example +`header-args:' where `' is the language identifier. For +example, * Heading :PROPERTIES: @@ -14270,83 +14353,79 @@ targeted. As an example :header-args:clojure: :session *clojure-2* :END: - 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. + would force separate sessions for clojure blocks in Heading and +Subheading, but use the same session for all `R' blocks. Blocks in +Subheading inherit settings from Heading.  -File: org, Node: Code block specific header arguments, Next: Header arguments in function calls, Prev: Language-specific header arguments in Org mode properties, Up: Using header arguments +File: org, Node: Code block specific header arguments, Next: Arguments in function calls, Prev: Language-specific mode properties, Up: Using header arguments Code block specific header arguments .................................... -The most common way to assign values to header arguments is at the code -block level. This can be done by listing a sequence of header -arguments and their values as part of the `#+BEGIN_SRC' line. -Properties set in this way override both the values of -`org-babel-default-header-args' and header arguments specified as -properties. In the following example, the `:results' header argument -is set to `silent', meaning the results of execution will not be -inserted in the buffer, and the `:exports' header argument is set to -`code', meaning only the body of the code block will be preserved on -export to HTML or LaTeX. +Header arguments are most commonly set at the `src' code block level, on +the `#+BEGIN_SRC' line. Arguments set at this level take precedence +over those set in the `org-babel-default-header-args' variable, and also +those set as header properties. + + In the following example, setting `results' to `silent' makes it +ignore results of the code execution. Setting `:exports' to `code' +exports only the body of the `src' code block to HTML or LaTeX.: #+NAME: factorial #+BEGIN_SRC haskell :results silent :exports code :var n=0 fac 0 = 1 fac n = n * fac (n-1) #+END_SRC - Similarly, it is possible to set header arguments for inline code -blocks + + The same header arguments in an inline `src' code block: src_haskell[:exports both]{fac 5} Code block header arguments can span multiple lines using -`#+HEADER:' or `#+HEADERS:' lines preceding a code block or nested -between the `#+NAME:' line and the `#+BEGIN_SRC' line of a named code -block. +`#+HEADER:' on each line. Note that Org currently accepts the plural +spelling of `#+HEADER:' only as a convenience for +backward-compatibility. It may be removed at some point. - Multi-line header arguments on an un-named code block: + Multi-line header arguments on an unnamed `src' code block: - #+HEADERS: :var data1=1 - #+BEGIN_SRC emacs-lisp :var data2=2 + #+HEADER: :var data1=1 + #+BEGIN_SRC emacs-lisp :var data2=2 (message "data1:%S, data2:%S" data1 data2) - #+END_SRC + #+END_SRC - #+RESULTS: - : data1:1, data2:2 + #+RESULTS: + : data1:1, data2:2 - Multi-line header arguments on a named code block: + Multi-line header arguments on a named `src' code block: - #+NAME: named-block - #+HEADER: :var data=2 - #+BEGIN_SRC emacs-lisp - (message "data:%S" data) - #+END_SRC + #+NAME: named-block + #+HEADER: :var data=2 + #+BEGIN_SRC emacs-lisp + (message "data:%S" data) + #+END_SRC - #+RESULTS: named-block - : data:2 + #+RESULTS: named-block + : data:2  -File: org, Node: Header arguments in function calls, Prev: Code block specific header arguments, Up: Using header arguments +File: org, Node: Arguments in function calls, Prev: Code block specific header arguments, Up: Using header arguments -Header arguments in function calls -.................................. +Arguments in function calls +........................... -At the most specific level, header arguments for "Library of Babel" or -`#+CALL:' lines can be set as shown in the two examples below. For more -information on the structure of `#+CALL:' lines see *note Evaluating -code blocks::. +Header arguments in function calls are the most specific and override +all other settings in case of an overlap. They get the highest +priority. Two `#+CALL:' examples are shown below. For the complete +syntax of `#+CALL:' lines, see *note Evaluating code blocks::. - The following will apply the `:exports results' header argument to -the evaluation of the `#+CALL:' line. + In this example, `:exports results' header argument is applied to the +evaluation of the `#+CALL:' line. #+CALL: factorial(n=5) :exports results - The following will apply the `:session special' header argument to -the evaluation of the `factorial' code block. + In this example, `:session special' header argument is applied to the +evaluation of `factorial' code block. #+CALL: factorial[:session special](n=5) @@ -14356,35 +14435,31 @@ File: org, Node: Specific header arguments, Prev: Using header arguments, Up: 14.8.2 Specific header arguments -------------------------------- -Header arguments consist of an initial colon followed by the name of the -argument in lowercase letters. The following header arguments are -defined: +Org comes with many header arguments common to all languages. New +header arguments are added for specific languages as they become +available for use in `src' code blocks. A header argument is specified +with an initial colon followed by the argument's name in lowercase. +Common header arguments are: * Menu: -* var:: Pass arguments to code blocks -* results:: Specify the type of results and how they will - be collected and handled -* file:: Specify a path for file output +* var:: Pass arguments to `src' code blocks +* results:: Specify results type; how to collect +* file:: Specify a path for output file * file-desc:: Specify a description for file results * file-ext:: Specify an extension for file output -* output-dir:: Specify a directory to write file output to -* dir:: Specify the default (possibly remote) - directory for code block execution -* exports:: Export code and/or results -* tangle:: Toggle tangling and specify file name -* mkdirp:: Toggle creation of parent directories of target - files during tangling -* comments:: Toggle insertion of comments in tangled - code files -* padline:: Control insertion of padding lines in tangled - code files -* no-expand:: Turn off variable assignment and noweb - expansion during tangling +* output-dir:: Specify a directory for output file +* dir:: Specify the default directory for code block execution +* exports:: Specify exporting code, results, both, none +* tangle:: Toggle tangling; or specify file name +* mkdirp:: Toggle for parent directory creation for target files during tangling +* comments:: Toggle insertion of comments in tangled code files +* padline:: Control insertion of padding lines in tangled code files +* no-expand:: Turn off variable assignment and noweb expansion during tangling * session:: Preserve the state of code evaluation * noweb:: Toggle expansion of noweb references * noweb-ref:: Specify block's noweb reference resolution target -* noweb-sep:: String used to separate noweb references +* noweb-sep:: String to separate noweb references * cache:: Avoid re-evaluating unchanged code blocks * sep:: Delimiter for writing tabular results outside Org * hlines:: Handle horizontal lines in tables @@ -14394,12 +14469,11 @@ defined: * 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 +* post:: Post processing of results of code block evaluation +* prologue:: Text to prepend to body of code block +* epilogue:: Text to append to body of code block - Additional header arguments are defined on a language-specific -basis, see *note Languages::. + For language-specific header arguments, see *note Languages::.  File: org, Node: var, Next: results, Up: Specific header arguments @@ -14407,36 +14481,34 @@ File: org, Node: var, Next: results, Up: Specific header arguments 14.8.2.1 `:var' ............... -The `:var' header argument is used to pass arguments to code blocks. -The specifics of how arguments are included in a code block vary by -language; these are addressed in the language-specific documentation. -However, the syntax used to specify arguments is the same across all -languages. In every case, variables require a default value when they -are declared. +Use `:var' for passing arguments to `src' code blocks. The specifics +of variables in `src' code blocks vary by the source language and are +covered in the language-specific documentation. The syntax for `:var', +however, is the same for all languages. This includes declaring a +variable, and assigning a default value. - The values passed to arguments can either be literal values, -references, or Emacs Lisp code (see *note Emacs Lisp evaluation of -variables: var.). References include anything in the Org mode file -that takes a `#+NAME:' or `#+RESULTS:' line: tables, lists, -`#+BEGIN_EXAMPLE' blocks, other code blocks and the results of other -code blocks. + Arguments can take values as literals, or as references, or even as +Emacs Lisp code (*note Emacs Lisp evaluation of variables: var.). +References are names from the Org file from the lines `#+NAME:' or +`#+RESULTS:'. References can also refer to tables, lists, +`#+BEGIN_EXAMPLE' blocks, other types of `src' code blocks, or the +results of execution of `src' 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 *note -cache::). + For better performance, Org can cache results of evaluations. But +caching comes with severe limitations (*note cache::). - Argument values can be indexed in a manner similar to arrays (see -*note Indexable variable values: var.). + Argument values are indexed like arrays (*note Indexable variable +values: var.). - The following syntax is used to pass arguments to code blocks using -the `:var' header argument. + The following syntax is used to pass arguments to `src' code blocks +using the `:var' header argument. :var name=assign - The argument, `assign', can either be a literal value, such as a -string `"string"' or a number `9', or a reference to a table, a list, a -literal example, another code block (with or without arguments), or the -results of evaluating another code block. + The `assign' is a literal value, such as a string `"string"', a +number `9', a reference to a table, a list, a literal example, another +code block (with or without arguments), or the results from evaluating +a code block. Here are examples of passing values by reference: @@ -14458,8 +14530,8 @@ results of evaluating another code block. : 4 "list" - a simple list named with a `#+NAME:' line (note that nesting is not - carried through to the source code block) + a simple list named with a `#+NAME:' line. Note that only the top + level list items are passed along. Nested list items are ignored. #+NAME: example-list - simple @@ -14486,9 +14558,10 @@ results of evaluating another code block. : 8 "code block with arguments" - a code block name, as assigned by `#+NAME:', followed by + a `src' code block name, as assigned by `#+NAME:', followed by parentheses and optional arguments passed within the parentheses - following the code block name using standard function call syntax + following the `src' code block name using standard function call + syntax #+NAME: double #+BEGIN_SRC emacs-lisp :var input=8 @@ -14499,7 +14572,7 @@ results of evaluating another code block. : 16 #+NAME: squared - #+BEGIN_SRC emacs-lisp :var input=double(input=1) + #+BEGIN_SRC emacs-lisp :var input=double(input=2) (* input input) #+END_SRC @@ -14528,14 +14601,14 @@ results of evaluating another code block. 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 the end. If an index is separated by `,'s then each -subsequent section will index into the next deepest nesting or -dimension of the value. Note that this indexing occurs _before_ other -table related header arguments like `:hlines', `:colnames' and -`:rownames' are applied. The following example assigns the last cell -of the first row the table `example-table' to the variable `data': +Indexing variable values enables referencing portions of a variable. +Indexes are 0 based with negative values counting backwards from the +end. If an index is separated by `,'s then each subsequent section +will index as the next dimension. Note that this indexing occurs +_before_ other table-related header arguments are applied, such as +`:hlines', `:colnames' and `:rownames'. The following example assigns +the last cell of the first row the table `example-table' to the variable +`data': #+NAME: example-table | 1 | a | @@ -14571,10 +14644,9 @@ referenced. For example the following assigns the middle three rows of | 3 | c | | 4 | d | - Additionally, an empty index, or the single character `*', are both -interpreted to mean the entire range and as such are equivalent to -`0:-1', as shown in the following example in which the entire first -column is referenced. + To pick the entire range, use an empty index, or the single character +`*'. `0:-1' does the same thing. Example below shows how to reference +the first column only. #+NAME: example-table | 1 | a | @@ -14589,9 +14661,9 @@ column is referenced. #+RESULTS: | 1 | 2 | 3 | 4 | - It is possible to index into the results of code blocks as well as -tables. Any number of dimensions can be indexed. Dimensions are -separated from one another by commas, as shown in the following example. + Index referencing can be used for tables and code blocks. Index +referencing can handle any number of dimensions. Commas delimit +multiple dimensions, as shown below. #+NAME: 3D #+BEGIN_SRC emacs-lisp @@ -14610,26 +14682,25 @@ separated from one another by commas, as shown in the following example. Emacs Lisp evaluation of variables .................................. -Emacs lisp code can be used to initialize variable values. When a -variable value starts with `(', `[', `'' or ``' it will be evaluated as -Emacs Lisp and the result of the evaluation will be assigned as the -variable value. The following example demonstrates use of this -evaluation to reliably pass the file-name of the Org mode buffer to a -code block--note that evaluation of header arguments is guaranteed to -take place in the original Org mode file, while there is no such -guarantee for evaluation of the code block body. +Emacs lisp code can set the values for variables. To differentiate a +value from lisp code, Org interprets any value starting with `(', `[', +`'' or ``' as Emacs Lisp code. The result of evaluating that code is +then assigned to the value of that variable. The following example +shows how to reliably query and pass file name of the Org mode buffer +to a code block using headers. We need reliability here because the +file's name could change once the code in the block starts executing. #+BEGIN_SRC sh :var filename=(buffer-file-name) :exports both wc -w $filename #+END_SRC - Note that values read from tables and lists will not be evaluated as -Emacs Lisp, as shown in the following example. + Note that values read from tables and lists will not be mistakenly +evaluated as Emacs Lisp code, as illustrated in the following example. #+NAME: table | (a b c) | - #+HEADERS: :var data=table[0,0] + #+HEADER: :var data=table[0,0] #+BEGIN_SRC perl $data #+END_SRC @@ -14643,121 +14714,107 @@ File: org, Node: results, Next: file, Prev: var, Up: Specific header argumen 14.8.2.2 `:results' ................... -There are four classes of `:results' header argument. Only one option -per class may be supplied per code block. +There are four classes of `:results' header arguments. Each `src' code +block can take only one option per class. - * collection header arguments specify how the results should be - collected from the code block + * collection for how the results should be collected from the `src' + code block - * 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 + * type for which type of result the code block will return; affects + how Org processes and inserts results in the Org buffer - * 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 + * format for the result; affects how Org processes and inserts + results in the Org buffer - * handling header arguments specify how the results of evaluating - the code block should be handled. + * handling for processing results after evaluation of the `src' code + block Collection .......... -The following options are mutually exclusive, and specify how the -results should be collected from the code block. +Collection options specify the results. Choose one of the options; +they are mutually exclusive. - * `value' This is the default. The result is the value of the last - statement in the code block. This header argument places the - evaluation in functional mode. Note that in some languages, e.g., - Python, use of this result type requires that a `return' statement - be included in the body of the source code block. E.g., `:results - value'. + * `value' Default. Functional mode. Result is the value returned + by the last statement in the `src' code block. Languages like + Python may require an explicit `return' statement in the `src' + code block. Usage example: `:results value'. - * `output' The result is the collection of everything printed to - STDOUT during the execution of the code block. This header - argument places the evaluation in scripting mode. E.g., `:results - output'. + * `output' Scripting mode. Result is collected from STDOUT during + execution of the code in the `src' code block. Usage example: + `:results output'. Type .... -The following options are mutually exclusive and specify what type of -results the code block will return. By default, results are inserted -as either a table or scalar depending on their value. +Type tells what result types to expect from the execution of the code +block. Choose one of the options; they are mutually exclusive. The +default behavior is to automatically determine the result type. - * `table', `vector' The results should be interpreted as an Org mode - table. If a single value is returned, it will be converted into a - table with one row and one column. E.g., `:results value table'. + * `table', `vector' Interpret the results as an Org table. If the + result is a single value, create a table with one row and one + column. Usage example: `:results value table'. - * `list' The results should be interpreted as an Org mode list. If - a single scalar value is returned it will be converted into a list - with only one element. + * `list' Interpret the results as an Org list. If the result is a + single value, create a list of one element. - * `scalar', `verbatim' The results should be interpreted - literally--they will not be converted into a table. The results - will be inserted into the Org mode buffer as quoted text. E.g., - `:results value verbatim'. + * `scalar', `verbatim' Interpret literally and insert as quoted + text. Do not create a table. Usage example: `:results value + verbatim'. - * `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., - `:results value file'. + * `file' Interpret as path to a file. Inserts a link to the file. + Usage example: `:results value file'. 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. +Format pertains to the type of the result returned by the `src' code +block. Choose one of the options; they are mutually exclusive. The +default follows from the type specified above. - * `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 such by Org mode. E.g., `:results - value raw'. + * `raw' Interpreted as raw Org mode. Inserted directly into the + buffer. Aligned if it is a table. Usage example: `:results value + raw'. - * `org' The results are will be enclosed in a `BEGIN_SRC org' block. - They are not comma-escaped by default but they will be if you hit - `TAB' in the block and/or if you export the file. E.g., `:results - value org'. + * `org' Results enclosed in a `BEGIN_SRC org' block. For + comma-escape, either `TAB' in the block, or export the file. + Usage example: `:results value org'. - * `html' Results are assumed to be HTML and will be enclosed in a - `BEGIN_HTML' block. E.g., `:results value html'. + * `html' Results enclosed in a `BEGIN_EXPORT html' block. Usage + example: `:results value html'. - * `latex' Results assumed to be LaTeX and are enclosed in a - `BEGIN_LaTeX' block. E.g., `:results value latex'. + * `latex' Results enclosed in a `BEGIN_EXPORT latex' block. Usage + example: `:results value latex'. - * `code' Result are assumed to be parsable code and are enclosed in - a code block. E.g., `:results value code'. + * `code' Result enclosed in a `src' code block. Useful for parsing. + Usage example: `:results value code'. - * `pp' The result is converted to pretty-printed code and is - enclosed in a code block. This option currently supports Emacs - Lisp, Python, and Ruby. E.g., `:results value pp'. + * `pp' Result converted to pretty-print source code. Enclosed in a + `src' code block. Languages supported: Emacs Lisp, Python, and + Ruby. Usage example: `:results value pp'. - * `drawer' The result is wrapped in a RESULTS drawer. This can be - useful for inserting `raw' or `org' syntax results in such a way - that their extent is known and they can be automatically removed - or replaced. + * `drawer' Result wrapped in a RESULTS drawer. Useful for + containing `raw' or `org' results for later scripting and + automated processing. Usage example: `:results value drawer'. Handling ........ -The following results options indicate what happens with the results -once they are collected. +Handling options after collecting the results. - * `silent' The results will be echoed in the minibuffer but will not - be inserted into the Org mode buffer. E.g., `:results output - silent'. + * `silent' Do not insert results in the Org mode buffer, but echo + them in the minibuffer. Usage example: `:results output silent'. - * `replace' The default value. Any existing results will be - removed, and the new results will be inserted into the Org mode - buffer in their place. E.g., `:results output replace'. + * `replace' Default. Insert results in the Org buffer. Remove + previous results. Usage example: `:results output replace'. - * `append' If there are pre-existing results of the code block then - the new results will be appended to the existing results. - Otherwise the new results will be inserted as with `replace'. + * `append' Append results to the Org buffer. Latest results are at + the bottom. Does not remove previous results. Usage example: + `:results output append'. - * `prepend' If there are pre-existing results of the code block then - the new results will be prepended to the existing results. - Otherwise the new results will be inserted as with `replace'. + * `prepend' Prepend results to the Org buffer. Latest results are + at the top. Does not remove previous results. Usage example: + `:results output prepend'.  File: org, Node: file, Next: file-desc, Prev: results, Up: Specific header arguments @@ -14765,20 +14822,14 @@ File: org, Node: file, Next: file-desc, Prev: results, Up: Specific header a 14.8.2.3 `:file' ................ -The header argument `:file' is used to specify an external file in which -to save code block results. After code block evaluation an Org mode -style `[[file:]]' link (see *note Link format::) to the file will be -inserted into the Org mode buffer. Some languages including R, -gnuplot, dot, and ditaa provide special handling of the `:file' header -argument automatically wrapping the code block body in the boilerplate -code required to save output to the specified file. This is often -useful for saving graphical output of a code block to the specified -file. - - The argument to `:file' should be either a string specifying the -path to a file, or a list of two strings in which case the first -element of the list should be the path to a file and the second a -description for the link. +An external `:file' that saves the results of execution of the code +block. The `:file' is either a file name or two strings, where the +first is the file name and the second is the description. A link to +the file is inserted. It uses an Org mode style `[[file:]]' link +(*note Link format::). Some languages, such as `R', `dot', `ditaa', and +`gnuplot', automatically wrap the source code in additional boilerplate +code. Such code wrapping helps recreate the output, especially graphics +output, by executing just the `:file' contents.  File: org, Node: file-desc, Next: file-ext, Prev: file, Up: Specific header arguments @@ -14786,10 +14837,9 @@ File: org, Node: file-desc, Next: file-ext, Prev: file, Up: Specific header 14.8.2.4 `:file-desc' ..................... -The value of the `:file-desc' header argument is used to provide a -description for file code block results which are inserted as Org mode -links (see *note Link format::). If the `:file-desc' header argument -is given with no value the link path will be placed in both the "link" +A description of the results file. Org uses this description for the +link (see *note Link format::) it inserts in the Org file. If the +`:file-desc' has no value, Org will use file name for both the "link" and the "description" portion of the Org mode link.  @@ -14798,13 +14848,10 @@ File: org, Node: file-ext, Next: output-dir, Prev: file-desc, Up: Specific h 14.8.2.5 `:file-ext' .................... -The value of the `:file-ext' header argument is used to provide an -extension to write the file output to. It is combined with the -`#+NAME:' of the source block and the value of the *note output-dir:: -header argument to generate a complete file name. - - This header arg will be overridden by `:file', and thus has no effect -when the latter is specified. +File name extension for the output file. Org generates the file's +complete name, and extension by combining `:file-ext', `#+NAME:' of the +source block, and the *note output-dir:: header argument. To override +this auto generated file name, use the `:file' header argument.  File: org, Node: output-dir, Next: dir, Prev: file-ext, Up: Specific header arguments @@ -14812,12 +14859,10 @@ File: org, Node: output-dir, Next: dir, Prev: file-ext, Up: Specific header 14.8.2.6 `:output-dir' ...................... -The value of the `:output-dir' header argument is used to provide a -directory to write the file output to. It may specify an absolute -directory (beginning with `/') or a relative directory (without `/'). -It can be combined with the `#+NAME:' of the source block and the value -of the *note file-ext:: header argument to generate a complete file -name, or used along with a *note file:: header arg. +Specifies the `:output-dir' for the results file. Org accepts an +absolute path (beginning with `/') or a relative directory (without +`/'). The value can be combined with `#+NAME:' of the source block and +*note file:: or *note file-ext:: header arguments.  File: org, Node: dir, Next: exports, Prev: output-dir, Up: Specific header arguments @@ -14826,19 +14871,18 @@ File: org, Node: dir, Next: exports, Prev: output-dir, Up: Specific header a .................................... While the `:file' header argument can be used to specify the path to the -output file, `: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 `:dir path' +output file, `:dir' specifies the default directory during `src' code +block execution. If it is absent, then the directory associated with +the current buffer is used. In other words, supplying `:dir path' temporarily has the same effect as changing the current directory with `M-x cd path RET', and then not supplying `:dir'. Under the surface, `:dir' simply sets the value of the Emacs variable `default-directory'. - When using `:dir', you should supply a relative path for file output -(e.g., `:file myfile.jpg' or `:file results/myfile.jpg') in which case -that path will be interpreted relative to the default directory. + When using `:dir', relative paths (for example, `:file myfile.jpg' +or `:file results/myfile.jpg') become relative to the default directory. - In other words, if you want your plot to go into a folder called -`Work' in your home directory, you could use + For example, to save the plot file in the `Work' folder of the home +directory (notice tilde is expanded): #+BEGIN_SRC R :file myplot.png :dir ~/Work matplot(matrix(rnorm(100), 10), type="l") @@ -14847,47 +14891,31 @@ that path will be interpreted relative to the default directory. Remote execution ................ -A directory on a remote machine can be specified using tramp file -syntax, in which case the code will be evaluated on the remote machine. -An example is +To evaluate the `src' code block on a remote machine, supply a remote s +directory name using `Tramp' syntax. For example: - #+BEGIN_SRC R :file plot.png :dir /dand@yakuba.princeton.edu: + #+BEGIN_SRC R :file plot.png :dir /scp:dand@yakuba.princeton.edu: plot(1:10, main=system("hostname", intern=TRUE)) #+END_SRC - Text results will be returned to the local Org mode buffer as usual, -and file output will be created on the remote machine with relative -paths interpreted relative to the remote directory. An Org mode link -to the remote file will be created. - - So, in the above example a plot will be created on the remote -machine, and a link of the following form will be inserted in the org -buffer: + Org first captures the text results as usual for insertion in the +Org file. Then Org also inserts a link to the remote file, thanks to +Emacs `Tramp'. Org constructs the remote path to the file name from +`:dir' and `default-directory', as illustrated here: [[file:/scp:dand@yakuba.princeton.edu:/home/dand/plot.png][plot.png]] - Most of this functionality follows immediately from the fact that -`:dir' sets the value of the Emacs variable `default-directory', thanks -to tramp. Those using XEmacs, or GNU Emacs prior to version 23 may -need to install tramp separately in order for these features to work -correctly. - -Further points -.............. +Some more warnings +.................. - * If `:dir' is used in conjunction with `:session', although it will - determine the starting directory for a new session as expected, no - attempt is currently made to alter the directory associated with - an existing session. + * When `:dir' is used with `:session', Org sets the starting + directory for a new session. But Org will not alter the directory + of an already existing session. - * `:dir' should typically not be used to create files during export - with `:exports results' or `:exports both'. The reason is that, - in order to retain portability of exported material between - machines, during export links inserted into the buffer will _not_ - be expanded against `default directory'. Therefore, if - `default-directory' is altered using `:dir', it is probable that - the file will be created in a location to which the link does not - point. + * Do not use `:dir' with `:exports results' or with `:exports both' + to avoid Org inserting incorrect links to remote files. That is + because Org does not expand `default directory' to avoid some + underlying portability issues.  File: org, Node: exports, Next: tangle, Prev: dir, Up: Specific header arguments @@ -14895,21 +14923,22 @@ File: org, Node: exports, Next: tangle, Prev: dir, Up: Specific header argum 14.8.2.8 `:exports' ................... -The `:exports' header argument specifies what should be included in HTML -or LaTeX exports of the Org mode file. Note that the `:exports' option -is only relevant for code blocks, not inline code. +The `:exports' header argument is to specify if that part of the Org +file is exported to, say, HTML or LaTeX formats. Note that `:exports' +affects only `src' code blocks and not inline code. * `code' The default. The body of code is included into the - exported file. E.g., `:exports code'. + exported file. Example: `:exports code'. - * `results' The result of evaluating the code is included in the - exported file. E.g., `:exports results'. + * `results' The results of evaluation of the code is included in the + exported file. Example: `:exports results'. - * `both' Both the code and results are included in the exported - file. E.g., `:exports both'. + * `both' Both the code and results of evaluation are included in the + exported file. Example: `:exports both'. - * `none' Nothing is included in the exported file. E.g., `:exports - none'. + * `none' Neither the code nor the results of evaluation is included + in the exported file. Whether the code is evaluated at all + depends on other options. Example: `:exports none'.  File: org, Node: tangle, Next: mkdirp, Prev: exports, Up: Specific header arguments @@ -14917,20 +14946,21 @@ File: org, Node: tangle, Next: mkdirp, Prev: exports, Up: Specific header ar 14.8.2.9 `:tangle' .................. -The `:tangle' header argument specifies whether or not the code block -should be included in tangled extraction of source code files. +The `:tangle' header argument specifies if the `src' code block is +exported to source file(s). - * `tangle' The code block is exported to a source code file named - after the full path (including the directory) and file name (w/o - extension) of the Org mode file. E.g., `:tangle yes'. + * `tangle' Export the `src' code block to source file. The file + name for the source file is derived from the name of the Org file, + and the file extension is derived from the source code language + identifier. Example: `:tangle yes'. - * `no' The default. The code block is not exported to a source code - file. E.g., `:tangle no'. + * `no' The default. Do not extract the code a source code file. + Example: `:tangle no'. - * other Any other string passed to the `:tangle' header argument is - interpreted as a path (directory and file name relative to the - directory of the Org mode file) to which the block will be - exported. E.g., `:tangle path'. + * other Export the `src' code block to source file whose file name + is derived from any string passed to the `:tangle' header + argument. Org derives the file name as being relative to the + directory of the Org file's location. Example: `:tangle path'.  File: org, Node: mkdirp, Next: comments, Prev: tangle, Up: Specific header arguments @@ -14938,9 +14968,9 @@ File: org, Node: mkdirp, Next: comments, Prev: tangle, Up: Specific header a 14.8.2.10 `:mkdirp' ................... -The `:mkdirp' header argument can be used to create parent directories -of tangled files when missing. This can be set to `yes' to enable -directory creation or to `no' to inhibit directory creation. +The `:mkdirp' header argument creates parent directories for tangled +files if the directory does not exist. `yes' enables directory creation +and `no' inhibits directory creation.  File: org, Node: comments, Next: padline, Prev: mkdirp, Up: Specific header arguments @@ -14948,28 +14978,27 @@ File: org, Node: comments, Next: padline, Prev: mkdirp, Up: Specific header 14.8.2.11 `:comments' ..................... -By default code blocks are tangled to source-code files without any -insertion of comments beyond those which may already exist in the body -of the code block. The `:comments' header argument can be set as -follows to control the insertion of extra comments into the tangled -code file. +Controls inserting comments into tangled files. These are above and +beyond whatever comments may already exist in the `src' code block. - * `no' The default. No extra comments are inserted during tangling. + * `no' The default. Do not insert any extra comments during + tangling. - * `link' The code block is wrapped in comments which contain - pointers back to the original Org file from which the code was + * `link' Wrap the `src' code block in comments. Include links + pointing back to the place in the Org file from where the code was tangled. - * `yes' A synonym for "link" to maintain backwards compatibility. + * `yes' Kept for backward compatibility; same as "link". - * `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. + * `org' Nearest headline text from Org file is inserted as comment. + The exact text that is inserted is picked from the leading context + of the source block. - * `both' Turns on both the "link" and "org" comment options. + * `both' Includes both "link" and "org" comment options. - * `noweb' Turns on the "link" comment option, and additionally wraps - expanded noweb references in the code block body in link comments. + * `noweb' Includes "link" comment option, expands noweb references, + and wraps them in link comments inside the body of the `src' code + block.  File: org, Node: padline, Next: no-expand, Prev: comments, Up: Specific header arguments @@ -14977,15 +15006,12 @@ File: org, Node: padline, Next: no-expand, Prev: comments, Up: Specific head 14.8.2.12 `:padline' .................... -Control in insertion of padding lines around code block bodies in -tangled code files. The default value is `yes' which results in -insertion of newlines before and after each tangled code block. The -following arguments are accepted. - - * `yes' Insert newlines before and after each code block body in - tangled code files. +Control insertion of newlines to pad `src' code blocks in the tangled +file. + * `yes' Default. Insert a newline before and after each `src' code + block in the tangled file. - * `no' Do not insert any newline padding in tangled output. + * `no' Do not insert newlines to pad the tangled `src' code blocks.  File: org, Node: no-expand, Next: session, Prev: padline, Up: Specific header arguments @@ -14993,14 +15019,15 @@ File: org, Node: no-expand, Next: session, Prev: padline, Up: Specific heade 14.8.2.13 `:no-expand' ...................... -By default, code blocks are expanded with `org-babel-expand-src-block' -during tangling. This has the effect of assigning values to variables -specified with `:var' (see *note var::), and of replacing "noweb" -references (see *note Noweb reference syntax::) with their targets. The -`:no-expand' header argument can be used to turn off this behavior. -Note: The `:no-expand' header argument has no impact on export, i.e. -code blocks will irrespective of this header argument expanded for -execution. +By default Org expands `src' code blocks during tangling. The +`:no-expand' header argument turns off such expansions. Note that one +side-effect of expansion by `org-babel-expand-src-block' also assigns +values to `:var' (*note var::) variables. Expansions also replace +"noweb" references with their targets (*note Noweb reference syntax::). +Some of these expansions may cause premature assignment, hence this +option. This option makes a difference only for tangling. It has no +effect when exporting since `src' code blocks for execution have to be +expanded anyway.  File: org, Node: session, Next: noweb, Prev: no-expand, Up: Specific header arguments @@ -15008,23 +15035,23 @@ File: org, Node: session, Next: noweb, Prev: no-expand, Up: Specific header 14.8.2.14 `:session' .................... -The `:session' header argument starts a (possibly named) session for an -interpreted language where the interpreter’s state is preserved. All -code blocks sharing the same name are exectuted by the same interpreter -process. By default, a session is not started. - - * `none' The default. Each block is evaluated in its own - interpreter process, which is terminated after the evaluation. +The `:session' header argument is for running multiple source code +blocks under one session. Org runs `src' code blocks with the same +session name in the same interpreter process. - * `other' Any other string passed to the `:session' header argument - will give the session a name. For example, `:session mysession'. - If `:session' is given but no name string is specified, the - session is named according to the language used in the block. All - blocks with the same session name share the same session. Using - different session names enables concurrent sessions (even for the - same interpreted language, if the language supports multiple - sessions). + * `none' Default. Each `src' code block gets a new interpreter + process to execute. The process terminates once the block is + evaluated. + * `other' Any string besides `none' turns that string into the name + of that session. For example, `:session mysession' names it + `mysession'. If `:session' has no argument, then the session name + is derived from the source language identifier. Subsequent blocks + with the same source code language use the same session. + Depending on the language, state variables, code from other + blocks, and the overall interpreted environment may be shared. + Some interpreted languages support concurrent sessions when + subsequent source code language blocks change session names.  File: org, Node: noweb, Next: noweb-ref, Prev: session, Up: Specific header arguments @@ -15033,47 +15060,39 @@ File: org, Node: noweb, Next: noweb-ref, Prev: session, Up: Specific header .................. The `:noweb' header argument controls expansion of "noweb" syntax -references (see *note Noweb reference syntax::) when the code block is -evaluated, tangled, or exported. The `:noweb' header argument can have -one of the five values: `no', `yes', `tangle', or `no-export' -`strip-export'. +references (*note Noweb reference syntax::). Expansions occur when +source code blocks are evaluated, tangled, or exported. - * `no' The default. "Noweb" syntax references in the body of the - code block will not be expanded before the code block is - evaluated, tangled or exported. + * `no' Default. No expansion of "Noweb" syntax references in the + body of the code when evaluating, tangling, or exporting. - * `yes' "Noweb" syntax references in the body of the code block will - be expanded before the code block is evaluated, tangled or - exported. + * `yes' Expansion of "Noweb" syntax references in the body of the + `src' code block when evaluating, tangling, or exporting. - * `tangle' "Noweb" syntax references in the body of the code block - will be expanded before the code block is tangled. However, - "noweb" syntax references will not be expanded when the code block - is evaluated or exported. + * `tangle' Expansion of "Noweb" syntax references in the body of the + `src' code block when tangling. No expansion when evaluating or + exporting. - * `no-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 expanded when the - code block is exported. + * `no-export' Expansion of "Noweb" syntax references in the body of + the `src' code block when evaluating or tangling. No expansion + when exporting. - * `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 be removed when the code - block is exported. + * `strip-export' Expansion of "Noweb" syntax references in the body + of the `src' code block when expanding prior to evaluating or + tangling. Removes "noweb" syntax references when exporting. - * `eval' "Noweb" syntax references in the body of the code block - will only be expanded before the block is evaluated. + * `eval' Expansion of "Noweb" syntax references in the body of the + `src' code block only before evaluating. Noweb prefix lines .................. -Noweb insertions are now placed behind the line prefix of the -`<>'. This behavior is illustrated in the following -example. Because the `<>' noweb reference appears behind the -SQL comment syntax, each line of the expanded noweb reference will be -commented. +Noweb insertions now honor prefix characters that appear before +`<>'. This behavior is illustrated in the following example. +Because the `<>' noweb reference appears behind the SQL comment +syntax, each line of the expanded noweb reference will be commented. - This code block: + This `src' code block: -- <> @@ -15082,9 +15101,8 @@ commented. -- this is the -- multi-line body of example - Note that noweb replacement text that does not contain any newlines -will not be affected by this change, so it is still possible to use -inline noweb references. + Since this change will not affect noweb replacement text without +newlines in them, inline noweb references are acceptable.  File: org, Node: noweb-ref, Next: noweb-sep, Prev: noweb, Up: Specific header arguments @@ -15092,22 +15110,21 @@ File: org, Node: noweb-ref, Next: noweb-sep, Prev: noweb, Up: Specific heade 14.8.2.16 `:noweb-ref' ...................... -When expanding "noweb" style references, the bodies of all code block -with _either_ a block name matching the reference name _or_ a -`:noweb-ref' header argument matching the reference name will be -concatenated together to form the replacement text. +When expanding "noweb" style references, Org concatenates `src' code +blocks by matching the reference name to either the block name or the +`:noweb-ref' header argument. - By setting this header argument at the subtree or file level, simple -code block concatenation may be achieved. For example, when tangling -the following Org mode file, the bodies of code blocks will be -concatenated into the resulting pure code file(1). + For simple concatenation, set this `:noweb-ref' header argument at +the sub-tree or file level. In the example Org file shown next, the +body of the source code in each block is extracted for concatenation to +a pure code file. #+BEGIN_SRC sh :tangle yes :noweb yes :shebang #!/bin/sh <> #+END_SRC * the mount point of the fullest disk :PROPERTIES: - :noweb-ref: fullest-disk + :header-args: :noweb-ref fullest-disk :END: ** query all mounted disks @@ -15120,34 +15137,20 @@ concatenated into the resulting pure code file(1). |sed '1d' \ #+END_SRC - ** sort by the percent full - #+BEGIN_SRC sh - |awk '{print $5 " " $6}'|sort -n |tail -1 \ - #+END_SRC - - ** extract the mount point + ** output mount point of fullest disk #+BEGIN_SRC sh - |awk '{print $2}' + |awk '{if (u < +$5) {u = +$5; m = $6}} END {print m}' #+END_SRC - The `:noweb-sep' (see *note noweb-sep::) header argument holds the -string used to separate accumulate noweb references like those above. -By default a newline is used. - - ---------- Footnotes ---------- - - (1) (The example needs property inheritance to be turned on for the -`noweb-ref' property, see *note Property inheritance::). -  File: org, Node: noweb-sep, Next: cache, Prev: noweb-ref, Up: Specific header arguments 14.8.2.17 `:noweb-sep' ...................... -The `:noweb-sep' header argument holds the string used to separate -accumulate noweb references (see *note noweb-ref::). By default a -newline is used. +By default a newline separates each noweb reference concatenation. To +change this newline separator, edit the `:noweb-sep' (*note +noweb-sep::) header argument.  File: org, Node: cache, Next: sep, Prev: noweb-sep, Up: Specific header arguments @@ -15155,28 +15158,48 @@ File: org, Node: cache, Next: sep, Prev: noweb-sep, Up: Specific header argu 14.8.2.18 `:cache' .................. -The `:cache' header argument controls the use of in-buffer caching of -the results of evaluating code blocks. It can be used to avoid -re-evaluating unchanged code blocks. Note that the `:cache' header -argument will not attempt to cache results when the `:session' header -argument is used, because the results of the code block execution may -be stored in the session outside of the Org mode buffer. The `:cache' -header argument can have one of two values: `yes' or `no'. - - * `no' The default. No caching takes place, and the code block will - be evaluated every time it is called. - - * `yes' Every time the code block is run a SHA1 hash of the code and - arguments passed to the block will be generated. This hash is - packed into the `#+RESULTS:' line and will be checked on subsequent - executions of the code block. If the code block has not changed - since the last time it was evaluated, it will not be re-evaluated. - - Code block caches notice if the value of a variable argument to the -code block has changed. If this is the case, the cache is invalidated -and the code block is re-run. In the following example, `caller' will -not be re-run unless the results of `random' have changed since it was -last run. +The `:cache' header argument is for caching results of evaluating code +blocks. Caching results can avoid re-evaluating `src' code blocks that +have not changed since the previous run. To benefit from the cache and +avoid redundant evaluations, the source block must have a result +already present in the buffer, and neither the header arguments +(including the value of `:var' references) nor the text of the block +itself has changed since the result was last computed. This feature +greatly helps avoid long-running calculations. For some edge cases, +however, the cached results may not be reliable. + + The caching feature is best for when `src' blocks are pure functions, +that is functions that return the same value for the same input +arguments (*note var::), and that do not have side effects, and do not +rely on external variables other than the input arguments. Functions +that depend on a timer, file system objects, and random number +generators are clearly unsuitable for caching. + + A note of warning: when `:cache' is used for a `:session', caching +may cause unexpected results. + + When the caching mechanism tests for any source code changes, it +will not expand "noweb" style references (*note Noweb reference +syntax::). For reasons why, see +`http://thread.gmane.org/gmane.emacs.orgmode/79046'. + + The `:cache' header argument can have one of two values: `yes' or +`no'. + + * `no' Default. No caching of results; `src' code block evaluated + every time. + + * `yes' Whether to run the code or return the cached results is + determined by comparing the SHA1 hash value of the combined `src' + code block and arguments passed to it. This hash value is packed + on the `#+RESULTS:' line from previous evaluation. When hash + values match, Org does not evaluate the `src' code block. When + hash values mismatch, Org evaluates the `src' code block, inserts + the results, recalculates the hash value, and updates `#+RESULTS:' + line. + + In this example, both functions are cached. But `caller' runs only +if the result from `random' has changed since the last run. #+NAME: random #+BEGIN_SRC R :cache yes @@ -15200,15 +15223,10 @@ File: org, Node: sep, Next: hlines, Prev: cache, Up: Specific header argumen 14.8.2.19 `:sep' ................ -The `:sep' header argument can be used to control the delimiter used -when writing tabular results out to files external to Org mode. This -is used either when opening tabular results of a code block by calling -the `org-open-at-point' function bound to `C-c C-o' on the code block, -or when writing code block results to an external file (see *note -file::) header argument. - - By default, when `:sep' is not specified output tables are tab -delimited. +The `:sep' header argument is the delimiter for saving results as tables +to files (*note file::) external to Org mode. Org defaults to tab +delimited output. The function, `org-open-at-point', which is bound to +`C-c C-o', also uses `:sep' for opening tabular results.  File: org, Node: hlines, Next: colnames, Prev: sep, Up: Specific header arguments @@ -15216,15 +15234,17 @@ File: org, Node: hlines, Next: colnames, Prev: sep, Up: Specific header argu 14.8.2.20 `:hlines' ................... -Tables are frequently represented with one or more horizontal lines, or -hlines. The `:hlines' argument to a code block accepts the values -`yes' or `no', with a default value of `no'. +In-between each table row or below the table headings, sometimes +results have horizontal lines, which are also known as hlines. The +`:hlines' argument with the value `yes' accepts such lines. The +default is `no'. - * `no' Strips horizontal lines from the input table. In most - languages this is the desired effect because an `hline' symbol is - interpreted as an unbound variable and raises an error. Setting - `:hlines no' or relying on the default value yields the following - results. + * `no' Strips horizontal lines from the input table. For most code, + this is desirable, or else those `hline' symbols raise unbound + variable errors. + + The default is `:hlines no'. The example shows hlines removed + from the input table. #+NAME: many-cols | a | b | c | @@ -15243,8 +15263,7 @@ hlines. The `:hlines' argument to a code block accepts the values | d | e | f | | g | h | i | - * `yes' Leaves hlines in the table. Setting `:hlines yes' has this - effect. + * `yes' For `:hlines yes', the example shows hlines unchanged. #+NAME: many-cols | a | b | c | @@ -15271,13 +15290,14 @@ File: org, Node: colnames, Next: rownames, Prev: hlines, Up: Specific header 14.8.2.21 `:colnames' ..................... -The `:colnames' header argument accepts the values `yes', `no', or -`nil' for unassigned. The default value is `nil'. Note that the -behavior of the `:colnames' header argument may differ across languages. +The `:colnames' header argument accepts `yes', `no', or `nil' values. +The default value is `nil', which is unassigned. But this header +argument behaves differently depending on the source code language. - * `nil' If an input table looks like it has column names (because - its second row is an hline), then the column names will be removed - from the table before processing, then reapplied to the results. + * `nil' If an input table has column names (because the second row + is an hline), then Org removes the column names, processes the + table, puts back the column names, and then writes the table to + the results block. #+NAME: less-cols | a | @@ -15296,15 +15316,16 @@ behavior of the `:colnames' header argument may differ across languages. | b* | | c* | - Please note that column names are not removed before the table is - indexed using variable indexing *Note Indexable variable values: - var. + Note that column names have to accounted for when using variable + indexing (*note Indexable variable values: var.) because column + names are not removed for indexing. - * `no' No column name pre-processing takes place + * `no' Do not pre-process column names. - * `yes' Column names are removed and reapplied as with `nil' even if - the table does not "look like" it has column names (i.e., the - second row is not an hline) + * `yes' For an input table that has no hlines, process it like the + `nil' value. That is, Org removes the column names, processes the + table, puts back the column names, and then writes the table to + the results block.  File: org, Node: rownames, Next: shebang, Prev: colnames, Up: Specific header arguments @@ -15312,15 +15333,16 @@ File: org, Node: rownames, Next: shebang, Prev: colnames, Up: Specific heade 14.8.2.22 `:rownames' ..................... -The `:rownames' header argument can take on the values `yes' or `no', -with a default value of `no'. Note that Emacs Lisp code blocks ignore -the `:rownames' header argument entirely given the ease with which -tables with row names may be handled directly in Emacs Lisp. +The `:rownames' header argument can take on values `yes' or `no' +values. The default is `no'. Note that `emacs-lisp' code blocks +ignore `:rownames' header argument because of the ease of +table-handling in Emacs. - * `no' No row name pre-processing will take place. + * `no' Org will not pre-process row names. - * `yes' The first column of the table is removed from the table - before processing, and is then reapplied to the results. + * `yes' If an input table has row names, then Org removes the row + names, processes the table, puts back the row names, and then + writes the table to the results block. #+NAME: with-rownames | one | 1 | 2 | 3 | 4 | 5 | @@ -15335,9 +15357,9 @@ tables with row names may be handled directly in Emacs Lisp. | one | 11 | 12 | 13 | 14 | 15 | | two | 16 | 17 | 18 | 19 | 20 | - Please note that row names are not removed before the table is - indexed using variable indexing *Note Indexable variable values: - var. + Note that row names have to accounted for when using variable + indexing (*note Indexable variable values: var.) because row names + are not removed for indexing.  @@ -15346,10 +15368,11 @@ File: org, Node: shebang, Next: tangle-mode, Prev: rownames, Up: Specific he 14.8.2.23 `:shebang' .................... -Setting the `:shebang' header argument to a string value (e.g., -`:shebang "#!/bin/bash"') causes the string to be inserted as the first -line of any tangled file holding the code block, and the file -permissions of the tangled file are set to make it executable. +This header argument can turn results into executable script files. By +setting the `:shebang' header argument to a string value (for example, +`:shebang "#!/bin/bash"'), Org inserts that string as the first line of +the tangled file that the `src' code block is extracted to. Org then +turns on the tangled file's executable permission.  File: org, Node: tangle-mode, Next: eval, Prev: shebang, Up: Specific header arguments @@ -15357,15 +15380,19 @@ File: org, Node: tangle-mode, Next: eval, Prev: shebang, Up: Specific header 14.8.2.24 `:tangle-mode' ........................ -The `tangle-mode' header argument controls the permission set on tangled -files. The value of this header argument will be passed to -`set-file-modes'. For example, to set a tangled file as read only use -`:tangle-mode (identity #o444)', or to set a tangled file as executable -use `:tangle-mode (identity #o755)'. Blocks with `shebang' (*note -shebang::) header arguments will automatically be made executable unless -the `tangle-mode' header argument is also used. The behavior is -undefined if multiple code blocks with different values for the -`tangle-mode' header argument are tangled to the same file. +The `tangle-mode' header argument specifies what permissions to set for +tangled files by `set-file-modes'. For example, to make read-only +tangled file, use `:tangle-mode (identity #o444)'. To make it +executable, use `:tangle-mode (identity #o755)'. + + On `src' code blocks with `shebang' (*note shebang::) header +argument, Org will automatically set the tangled file to executable +permissions. But this can be overridden with custom permissions using +`tangle-mode' header argument. + + When multiple `src' code blocks tangle to a single file with +different and conflicting `tangle-mode' header arguments, Org's +behavior is undefined.  File: org, Node: eval, Next: wrap, Prev: tangle-mode, Up: Specific header arguments @@ -15373,29 +15400,29 @@ File: org, Node: eval, Next: wrap, Prev: tangle-mode, Up: Specific header ar 14.8.2.25 `:eval' ................. -The `:eval' header argument can be used to limit the evaluation of -specific code blocks. The `:eval' header argument can be useful for -protecting against the evaluation of dangerous code blocks or to ensure -that evaluation will require a query regardless of the value of the -`org-confirm-babel-evaluate' variable. The possible values of `:eval' -and their effects are shown below. +The `:eval' header argument can limit evaluation of specific code +blocks. It is useful for protection against evaluating untrusted `src' +code blocks by prompting for a confirmation. This protection is +independent of the `org-confirm-babel-evaluate' setting. `never or no' - The code block will not be evaluated under any circumstances. + Org will never evaluate this `src' code block. `query' - Evaluation of the code block will require a query. + Org prompts the user for permission to evaluate this `src' code + block. `never-export or no-export' - The code block will not be evaluated during export but may still - be called interactively. + Org will not evaluate this `src' code block when exporting, yet + the user can evaluate this source block interactively. `query-export' - Evaluation of the code block during export will require a query. + Org prompts the user for permission to export this `src' code + block. - If this header argument is not set then evaluation is determined by -the value of the `org-confirm-babel-evaluate' variable see *note Code -evaluation security::. + If `:eval' header argument is not set for a source block, then Org +determines whether to evaluate from the `org-confirm-babel-evaluate' +variable (*note Code evaluation security::).  File: org, Node: wrap, Next: post, Prev: eval, Up: Specific header arguments @@ -15403,11 +15430,9 @@ File: org, Node: wrap, Next: post, Prev: eval, Up: Specific header arguments 14.8.2.26 `:wrap' ................. -The `: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 to `#+BEGIN_' and `#+END_', which will then be used to wrap the -results. If not string is specified then the results will be wrapped -in a `#+BEGIN/END_RESULTS' block. +The `:wrap' header argument marks the results block by appending strings +to `#+BEGIN_' and `#+END_'. If no string is specified, Org wraps the +results in a `#+BEGIN/END_RESULTS' block.  File: org, Node: post, Next: prologue, Prev: wrap, Up: Specific header arguments @@ -15415,17 +15440,14 @@ File: org, Node: post, Next: prologue, Prev: wrap, Up: Specific header argum 14.8.2.27 `:post' ................. -The `: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 `*this*' variable. -This variable may then be included in header argument forms such as -those used in *note var:: header argument specifications allowing -passing of results to other code blocks, or direct execution via Emacs -Lisp. Additional header arguments may be passed to the -`:post'-function. - - The following two examples illustrate the usage of the `:post' header -argument. The first example shows how to attach a attribute-line via +The `:post' header argument is for post-processing results from `src' +block evaluation. When `:post' has any value, Org binds the results to +`*this*' variable for easy passing to *note var:: header argument +specifications. That makes results available to other `src' code +blocks, or for even direct Emacs Lisp code execution. + + The following two examples illustrate `:post' header argument in +action. The first one shows how to attach `#+ATTR_LATEX:' line using `:post'. #+name: attr_wrap @@ -15449,8 +15471,9 @@ argument. The first example shows how to attach a attribute-line via [[file:/tmp/it.png]] :END: - The second examples shows how to use `:post' together with the -`:colnames' header argument. + The second example shows use of `:colnames' in `:post' to pass data +between `src' code blocks. + #+name: round-tbl #+begin_src emacs-lisp :var tbl="" fmt="%.3f" (mapcar (lambda (row) @@ -15478,11 +15501,10 @@ File: org, Node: prologue, Next: epilogue, Prev: post, Up: Specific header a 14.8.2.28 `:prologue' ..................... -The value of the `prologue' header argument will be prepended to the -code block body before execution. For example, `: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 *note epilogue::. +The `prologue' header argument is for appending to the top of the code +block for execution. For example, a clear or reset code at the start +of new execution of a `src' code block. A `reset' for `gnuplot': +`:prologue "reset"'. See also *note epilogue::. (add-to-list 'org-babel-default-header-args:gnuplot '((:prologue . "reset"))) @@ -15493,8 +15515,8 @@ File: org, Node: epilogue, Prev: prologue, Up: Specific header arguments 14.8.2.29 `:epilogue' ..................... -The value of the `epilogue' header argument will be appended to the code -block body before execution. Also see *note prologue::. +The value of the `epilogue' header argument is for appending to the end +of the code block for execution. See also *note prologue::.  File: org, Node: Results of evaluation, Next: Noweb reference syntax, Prev: Header arguments, Up: Working with source code @@ -15502,10 +15524,15 @@ File: org, Node: Results of evaluation, Next: Noweb reference syntax, Prev: H 14.9 Results of evaluation ========================== -The way in which results are handled depends on whether a session is -invoked, as well as on whether `:results value' or `:results output' is -used. The following table shows the table possibilities. For a full -listing of the possible results header arguments see *note results::. +How Org handles results of a code block execution depends on many header +arguments working together. Here is only a summary of these. For an +enumeration of all the header arguments that affect results, see *note +results::. + + The primary determinant is the execution context. Is it in a +`:session' or not? Orthogonal to that is if the expected result is a +`:results value' or `:results output', which is a concatenation of +output from start to finish of the `src' code block's evaluation. Non-session Session `:results value' value of last value of last expression @@ -15513,9 +15540,10 @@ listing of the possible results header arguments see *note results::. `:results output' contents of STDOUT concatenation of interpreter output - Note: With `:results value', the result in both `:session' and -non-session is returned to Org mode as a table (a one- or -two-dimensional vector of strings or numbers) when appropriate. + For `:session' and non-session, the `:results value' turns the +results into an Org mode table format. Single values are wrapped in a +one dimensional vector. Rows and columns of a table are wrapped in a +two-dimensional vector. 14.9.1 Non-session ------------------ @@ -15523,24 +15551,21 @@ two-dimensional vector of strings or numbers) when appropriate. 14.9.1.1 `:results value' ......................... -This is the default. Internally, the value is obtained by wrapping the -code in a function definition in the external language, and evaluating -that function. Therefore, code should be written as if it were the -body of such a function. In particular, note that Python does not -automatically return a value from a function unless a `return' -statement is present, and so a `return' statement will usually be -required in Python. +Default. Org gets the value by wrapping the code in a function +definition in the language of the `src' block. That is why when using +`:results value', code should execute like a function and return a +value. For languages like Python, an explicit `return' statement is +mandatory when using `:results value'. - This is the only one of the four evaluation contexts in which the -code is automatically wrapped in a function definition. + This is one of four evaluation contexts where Org automatically +wraps the code in a function definition. 14.9.1.2 `:results output' .......................... -The code is passed to the interpreter as an external process, and the -contents of the standard output stream are returned as text. (In -certain languages this also contains the error output stream; this is -an area for future work.) +For `:results output', the code is passed to an external process running +the interpreter. Org returns the contents of the standard output +stream as as text results. 14.9.2 Session -------------- @@ -15548,29 +15573,29 @@ an area for future work.) 14.9.2.1 `:results value' ......................... -The code is passed to an interpreter running as an interactive Emacs -inferior process. Only languages which provide tools for interactive -evaluation of code have session support, so some language (e.g., C and -ditaa) do not support the `:session' header argument, and in other -languages (e.g., Python and Haskell) which have limitations on the code -which may be entered into interactive sessions, those limitations apply -to the code in code blocks using the `:session' header argument as well. +For `:results value' from a `:session', Org passes the code to an +interpreter running as an interactive Emacs inferior process. So only +languages that provide interactive evaluation can have session support. +Not all languages provide this support, such as `C' and `ditaa'. Even +those that do support, such as `Python' and `Haskell', they impose +limitations on allowable language constructs that can run +interactively. Org inherits those limitations for those `src' code +blocks running in a `:session'. - Unless the `:results output' option is supplied (see below) the -result returned is the result of the last evaluation performed by the -interpreter. (This is obtained in a language-specific manner: the -value of the variable `_' in Python and Ruby, and the value of -`.Last.value' in R). + Org gets the value from the source code interpreter's last statement +output. Org has to use language-specific methods to obtain the value. +For example, from the variable `_' in `Python' and `Ruby', and the +value of `.Last.value' in `R'). 14.9.2.2 `:results output' .......................... -The code is passed to the interpreter running as an interactive Emacs -inferior process. The result returned is the concatenation of the -sequence of (text) output from the interactive interpreter. Notice -that this is not necessarily the same as what would be sent to `STDOUT' -if the same code were passed to a non-interactive interpreter running -as an external process. For example, compare the following two blocks: +For `:results output', Org passes the code to the interpreter running as +an interactive Emacs inferior process. Org concatenates whatever text +output emitted by the interpreter to return the collection as a result. +Note that this collection is not the same as collected from `STDOUT' of +a non-interactive interpreter running as an external process. Compare +for example these two blocks: #+BEGIN_SRC python :results output print "hello" @@ -15582,7 +15607,8 @@ as an external process. For example, compare the following two blocks: : hello : bye - In non-session mode, the "2" is not printed and does not appear. + In the above non-session mode, the "2" is not printed; so does not +appear in results. #+BEGIN_SRC python :results output :session print "hello" @@ -15595,9 +15621,8 @@ as an external process. For example, compare the following two blocks: : 2 : bye - But in `:session' mode, the interactive interpreter receives input -"2" and prints out its value, "2". (Indeed, the other print statements -are unnecessary here). + In the above `:session' mode, the interactive interpreter receives +and prints "2". Results show that.  File: org, Node: Noweb reference syntax, Next: Key bindings and useful functions, Prev: Results of evaluation, Up: Working with source code @@ -15605,36 +15630,39 @@ File: org, Node: Noweb reference syntax, Next: Key bindings and useful functio 14.10 Noweb reference syntax ============================ -The "noweb" (see `http://www.cs.tufts.edu/~nr/noweb/') Literate -Programming system allows named blocks of code to be referenced by -using the familiar Noweb syntax: +Org supports named blocks in "noweb" style syntax. For "noweb" literate +programming details, see `http://www.cs.tufts.edu/~nr/noweb/'). <> - When a code block is tangled or evaluated, whether or not "noweb" -references are expanded depends upon the value of the `:noweb' header -argument. If `:noweb yes', then a Noweb reference is expanded before -evaluation. If `:noweb no', the default, then the reference is not -expanded before evaluation. See the *note noweb-ref:: header argument -for a more flexible way to resolve noweb references. + For the header argument `:noweb yes', Org expands "noweb" style +references in the `src' code block before evaluation. + + For the header argument `:noweb no', Org does not expand "noweb" +style references in the `src' code block before evaluation. + + The default is `:noweb no'. - It is possible to include the _results_ of a code block rather than -the body. This is done by appending parenthesis to the code block name -which may optionally contain arguments to the code block as shown below. + Org offers a more flexible way to resolve "noweb" style references +(*note noweb-ref::). + + Org can handle naming of _results_ block, rather than the body of the +`src' code block, using "noweb" style references. + + For "noweb" style reference, append parenthesis to the code block +name for arguments, as shown in this example: <> - Note: the default value, `:noweb no', was chosen to ensure that -correct code is not broken in a language, such as Ruby, where `<>' -is a syntactically valid construct. If `<>' is not syntactically -valid in languages that you use, then please consider setting the -default value. + Note: Org defaults to `:noweb no' so as not to cause errors in +languages such as `Ruby' where "noweb" syntax is equally valid +characters. For example, `<>'. Change Org's default to `:noweb +yes' for languages where there is no risk of confusion. - Note: if noweb tangling is slow in large Org mode files consider -setting the `org-babel-use-quick-and-dirty-noweb-expansion' variable to -`t'. This will result in faster noweb reference resolution at the -expense of not correctly resolving inherited values of the `:noweb-ref' -header argument. + For faster tangling of large Org mode files, set +`org-babel-use-quick-and-dirty-noweb-expansion' variable to `t'. The +speedup comes at the expense of not correctly resolving inherited values +of the `:noweb-ref' header argument.  File: org, Node: Key bindings and useful functions, Next: Batch execution, Prev: Noweb reference syntax, Up: Working with source code @@ -15645,59 +15673,37 @@ File: org, Node: Key bindings and useful functions, Next: Batch execution, Pr Many common Org mode key sequences are re-bound depending on the context. - Within a code block, the following key bindings are active: + Active key bindings in code blocks: `C-c C-c' `org-babel-execute-src-block' `C-c C-o' `org-babel-open-src-block-result' `M-' `org-babel-load-in-session' `M-' `org-babel-switch-to-session' - In an Org mode buffer, the following key bindings are active: - -`C-c C-v p' or `C-c C-v `org-babel-previous-src-block' -C-p' -`C-c C-v n' or `C-c C-v `org-babel-next-src-block' -C-n' -`C-c C-v e' or `C-c C-v `org-babel-execute-maybe' -C-e' -`C-c C-v o' or `C-c C-v `org-babel-open-src-block-result' -C-o' -`C-c C-v v' or `C-c C-v `org-babel-expand-src-block' -C-v' -`C-c C-v u' or `C-c C-v `org-babel-goto-src-block-head' -C-u' -`C-c C-v g' or `C-c C-v `org-babel-goto-named-src-block' -C-g' -`C-c C-v r' or `C-c C-v `org-babel-goto-named-result' -C-r' -`C-c C-v b' or `C-c C-v `org-babel-execute-buffer' -C-b' -`C-c C-v s' or `C-c C-v `org-babel-execute-subtree' -C-s' -`C-c C-v d' or `C-c C-v `org-babel-demarcate-block' -C-d' -`C-c C-v t' or `C-c C-v `org-babel-tangle' -C-t' -`C-c C-v f' or `C-c C-v `org-babel-tangle-file' -C-f' -`C-c C-v c' or `C-c C-v `org-babel-check-src-block' -C-c' -`C-c C-v j' or `C-c C-v `org-babel-insert-header-arg' -C-j' -`C-c C-v l' or `C-c C-v `org-babel-load-in-session' -C-l' -`C-c C-v i' or `C-c C-v `org-babel-lob-ingest' -C-i' -`C-c C-v I' or `C-c C-v `org-babel-view-src-block-info' -C-I' -`C-c C-v z' or `C-c C-v `org-babel-switch-to-session-with-code' -C-z' -`C-c C-v a' or `C-c C-v `org-babel-sha1-hash' -C-a' -`C-c C-v h' or `C-c C-v `org-babel-describe-bindings' -C-h' -`C-c C-v x' or `C-c C-v `org-babel-do-key-sequence-in-edit-buffer' -C-x' + Active key bindings in Org mode buffer: + +`C-c C-v p' or `C-c C-v C-p' `org-babel-previous-src-block' +`C-c C-v n' or `C-c C-v C-n' `org-babel-next-src-block' +`C-c C-v e' or `C-c C-v C-e' `org-babel-execute-maybe' +`C-c C-v o' or `C-c C-v C-o' `org-babel-open-src-block-result' +`C-c C-v v' or `C-c C-v C-v' `org-babel-expand-src-block' +`C-c C-v u' or `C-c C-v C-u' `org-babel-goto-src-block-head' +`C-c C-v g' or `C-c C-v C-g' `org-babel-goto-named-src-block' +`C-c C-v r' or `C-c C-v C-r' `org-babel-goto-named-result' +`C-c C-v b' or `C-c C-v C-b' `org-babel-execute-buffer' +`C-c C-v s' or `C-c C-v C-s' `org-babel-execute-subtree' +`C-c C-v d' or `C-c C-v C-d' `org-babel-demarcate-block' +`C-c C-v t' or `C-c C-v C-t' `org-babel-tangle' +`C-c C-v f' or `C-c C-v C-f' `org-babel-tangle-file' +`C-c C-v c' or `C-c C-v C-c' `org-babel-check-src-block' +`C-c C-v j' or `C-c C-v C-j' `org-babel-insert-header-arg' +`C-c C-v l' or `C-c C-v C-l' `org-babel-load-in-session' +`C-c C-v i' or `C-c C-v C-i' `org-babel-lob-ingest' +`C-c C-v I' or `C-c C-v C-I' `org-babel-view-src-block-info' +`C-c C-v z' or `C-c C-v C-z' `org-babel-switch-to-session-with-code' +`C-c C-v a' or `C-c C-v C-a' `org-babel-sha1-hash' +`C-c C-v h' or `C-c C-v C-h' `org-babel-describe-bindings' +`C-c C-v x' or `C-c C-v C-x' `org-babel-do-key-sequence-in-edit-buffer'  File: org, Node: Batch execution, Prev: Key bindings and useful functions, Up: Working with source code @@ -15705,10 +15711,13 @@ File: org, Node: Batch execution, Prev: Key bindings and useful functions, Up 14.12 Batch execution ===================== -It is possible to call functions from the command line. This shell -script calls `org-babel-tangle' on every one of its arguments. +Org mode features, including working with source code facilities can be +invoked from the command line. This enables building shell scripts for +batch processing, running automated system tasks, and expanding Org +mode's usefulness. - Be sure to adjust the paths to fit your system. + The sample script shows batch processing of multiple files using +`org-babel-tangle'. #!/bin/sh # -*- mode: shell-script -*- @@ -15724,14 +15733,12 @@ script calls `org-babel-tangle' on every one of its arguments. done emacs -Q --batch \ - --eval "(progn - (add-to-list 'load-path (expand-file-name \"~/src/org/lisp/\")) - (add-to-list 'load-path (expand-file-name \"~/src/org/contrib/lisp/\" t)) - (require 'org)(require 'org-exp)(require 'ob)(require 'ob-tangle) - (mapc (lambda (file) - (find-file (expand-file-name file \"$DIR\")) - (org-babel-tangle) - (kill-buffer)) '($FILES)))" 2>&1 |grep tangled + --eval "(progn + (require 'org)(require 'ob)(require 'ob-tangle) + (mapc (lambda (file) + (find-file (expand-file-name file \"$DIR\")) + (org-babel-tangle) + (kill-buffer)) '($FILES)))" 2>&1 |grep -i tangled  File: org, Node: Miscellaneous, Next: Hacking, Prev: Working with source code, Up: Top @@ -15741,16 +15748,16 @@ File: org, Node: Miscellaneous, Next: Hacking, Prev: Working with source code * Menu: -* Completion:: M-TAB knows what you need +* Completion:: M-TAB guesses completions * Easy templates:: Quick insertion of structural elements * Speed keys:: Electric commands at the beginning of a headline * Code evaluation security:: Org mode files evaluate inline code -* Customization:: Adapting Org to your taste +* Customization:: Adapting Org to changing tastes * In-buffer settings:: Overview of the #+KEYWORDS * The very busy C-c C-c key:: When in doubt, press C-c C-c * Clean view:: Getting rid of leading stars in the outline * TTY keys:: Using Org on a tty -* Interaction:: Other Emacs packages +* Interaction:: With other Emacs packages * org-crypt:: Encrypting Org files  @@ -15759,15 +15766,14 @@ File: org, Node: Completion, Next: Easy templates, Up: Miscellaneous 15.1 Completion =============== -Emacs would not be Emacs without completion, and Org mode uses it -whenever it makes sense. If you prefer an iswitchb- or ido-like -interface for some of the completion prompts, you can specify your -preference by setting at most one of the variables -`org-completion-use-iswitchb' `org-completion-use-ido'. - - Org supports in-buffer completion. This type of completion does not -make use of the minibuffer. You simply type a few letters into the -buffer and use the key to complete text right there. +Org has in-buffer completions. Unlike minibuffer completions, which are +useful for quick command interactions, Org's in-buffer completions are +more suitable for content creation in Org documents. Type one or more +letters and invoke the hot key to complete the text in-place. +Depending on the context and the keys, Org will offer different types +of completions. No minibuffer is involved. Such mode-specific hot +keys have become an integral part of Emacs and Org provides several +shortcuts. `M-' Complete word at point @@ -15793,14 +15799,17 @@ buffer and use the key to complete text right there. abbreviations::). * After `#+', complete the special keywords like `TYP_TODO' or - `OPTIONS' which set file-specific options for Org mode. When - the option keyword is already complete, pressing `M-' - again will insert example settings for this keyword. + file-specific `OPTIONS'. After option keyword is complete, + pressing `M-' again will insert example settings for + that option. - * In the line after `#+STARTUP: ', complete startup keywords, - i.e., valid keys for this line. + * After `#+STARTUP: ', complete startup keywords. - * Elsewhere, complete dictionary words using Ispell. + * When the point is anywhere else, complete dictionary words + using Ispell. + If your desktop intercepts the combo `M-' to switch windows, + use `C-M-i' or ` ' as an alternative or customize your + environment.  File: org, Node: Easy templates, Next: Speed keys, Prev: Completion, Up: Miscellaneous @@ -15808,38 +15817,40 @@ File: org, Node: Easy templates, Next: Speed keys, Prev: Completion, Up: Mis 15.2 Easy templates =================== -Org mode supports insertion of empty structural elements (like -`#+BEGIN_SRC' and `#+END_SRC' pairs) with just a few key strokes. This -is achieved through a native template expansion mechanism. Note that -Emacs has several other template mechanisms which could be used in a -similar way, for example `yasnippet'. +With just a few keystrokes, Org's easy templates inserts empty pairs of +structural elements, such as `#+BEGIN_SRC' and `#+END_SRC'. Easy +templates use an expansion mechanism, which is native to Org, in a +process similar to `yasnippet' and other Emacs template expansion +packages. + + `<<>' `' `' completes the `src' code block. + + `<' `l' `' + + expands to: + + #+BEGIN_EXPORT latex - To insert a structural element, type a `<', followed by a template -selector and `'. Completion takes effect only when the above -keystrokes are typed on a line by itself. + #+END_EXPORT - The following template selectors are currently supported. + Org comes with these pre-defined easy templates: -`s' `#+BEGIN_SRC ... #+END_SRC' +`s' `#+BEGIN_SRC ... #+END_SRC' `e' `#+BEGIN_EXAMPLE ... #+END_EXAMPLE' -`q' `#+BEGIN_QUOTE ... #+END_QUOTE' -`v' `#+BEGIN_VERSE ... #+END_VERSE' -`c' `#+BEGIN_CENTER ... #+END_CENTER' -`l' `#+BEGIN_LaTeX ... #+END_LaTeX' -`L' `#+LaTeX:' -`h' `#+BEGIN_HTML ... #+END_HTML' +`q' `#+BEGIN_QUOTE ... #+END_QUOTE' +`v' `#+BEGIN_VERSE ... #+END_VERSE' +`c' `#+BEGIN_CENTER ... #+END_CENTER' +`l' `#+BEGIN_EXPORT latex ... #+END_EXPORT' +`L' `#+LATEX:' +`h' `#+BEGIN_EXPORT html ... #+END_EXPORT' `H' `#+HTML:' -`a' `#+BEGIN_ASCII ... #+END_ASCII' +`a' `#+BEGIN_EXPORT ascii ... #+END_EXPORT' `A' `#+ASCII:' `i' `#+INDEX:' line `I' `#+INCLUDE:' line - For example, on an empty line, typing "Customization' menu. Many settings can also be -activated on a per-file basis, by putting special lines into the buffer -(*note In-buffer settings::). +Org has more than 500 variables for customization. They can be accessed +through the usual `M-x org-customize RET' command. Or through the Org +menu, `Org->Customization->Browse Org Group'. Org also has per-file +settings for some variables (*note In-buffer settings::).  File: org, Node: In-buffer settings, Next: The very busy C-c C-c key, Prev: Customization, Up: Miscellaneous @@ -15942,46 +15953,43 @@ File: org, Node: In-buffer settings, Next: The very busy C-c C-c key, Prev: C 15.6 Summary of in-buffer settings ================================== -Org mode uses special lines in the buffer to define settings on a -per-file basis. These lines start with a `#+' followed by a keyword, a -colon, and then individual words defining a setting. Several setting -words can be in the same line, but you can also have multiple lines for -the keyword. While these settings are described throughout the manual, -here is a summary. After changing any of these lines in the buffer, -press `C-c C-c' with the cursor still in the line to activate the -changes immediately. Otherwise they become effective only when the -file is visited again in a new Emacs session. +In-buffer settings start with `#+', followed by a keyword, a colon, and +then a word for each setting. Org accepts multiple settings on the same +line. Org also accepts multiple lines for a keyword. This manual +describes these settings throughout. A summary follows here. + + `C-c C-c' activates any changes to the in-buffer settings. Closing +and reopening the Org file in Emacs also activates the changes. `#+ARCHIVE: %s_done::' - This line sets the archive location for the agenda file. It - applies for all subsequent lines until the next `#+ARCHIVE' line, - or the end of the file. The first such line also applies to any - entries before it. The corresponding variable is + Sets the archive location of the agenda file. This location + applies to the lines until the next `#+ARCHIVE' line, if any, in + the Org file. The first archive location in the Org file also + applies to any entries before it. The corresponding variable is `org-archive-location'. `#+CATEGORY:' - This line sets the category for the agenda file. The category - applies to the whole document. + Sets the category of the agenda file, which applies to the entire + document. `#+COLUMNS: %25ITEM ...' - Set the default format for columns view. This format applies when - columns view is invoked in locations where no `COLUMNS' property - applies. + Sets the default format for columns view. Org uses this format + for column views where there is no `COLUMNS' property. `#+CONSTANTS: name1=value1 ...' - Set file-local values for constants to be used in table formulas. + Set file-local values for constants that table formulas can use. This line sets the local variable `org-table-formula-constants-local'. The global version of this variable is `org-table-formula-constants'. `#+FILETAGS: :tag1:tag2:tag3:' - Set tags that can be inherited by any entry in the file, including - the top-level entries. + Set tags that all entries in the file will inherit from here, + including the top-level entries. `#+LINK: linkword replace' - These lines (several are allowed) specify link abbreviations. - *Note Link abbreviations::. The corresponding variable is - `org-link-abbrev-alist'. + Each line specifies one abbreviation for one link. Use multiple + `#+LINK:' lines for more, *note Link abbreviations::. The + corresponding variable is `org-link-abbrev-alist'. `#+PRIORITIES: highest lowest default' This line sets the limits and the default for the priorities. All @@ -15994,51 +16002,49 @@ file is visited again in a new Emacs session. property. `#+SETUPFILE: file' - This line defines a file that holds more in-buffer setup. - Normally this is entirely ignored. Only when the buffer is parsed - for option-setting lines (i.e., when starting Org mode for a file, - when pressing `C-c C-c' in a settings line, or when exporting), - then the contents of this file are parsed 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 `C-c ''. + The setup file is for additional in-buffer settings. Org loads + this file and parses it for any settings in it only when Org opens + the main file. `C-c C-c' on the settings line will also parse and + load. Org also parses and loads the file during normal exporting + process. Org parses the contents of this file as if it was + included in the buffer. It can be another Org file. To visit the + file, `C-c '' while the cursor is on the line with the file name. `#+STARTUP:' - This line sets options to be used at startup of Org mode, when an - Org file is being visited. + Startup options Org uses when first visiting a file. The first set of options deals with the initial visibility of the outline tree. The corresponding variable for global default - settings is `org-startup-folded', with a default value `t', which - means `overview'. + settings is `org-startup-folded' with a default value of `t', + which is the same as `overview'. + overview top-level headlines only content all headlines showall no folding of any entries showeverything show even drawer contents Dynamic virtual indentation is controlled by the variable - `org-startup-indented'(1) + `org-startup-indented' indent start with `org-indent-mode' turned on noindent start with `org-indent-mode' turned off - Then there are options for aligning tables upon visiting a file. - This is useful in files containing narrowed table columns. The - corresponding variable is `org-startup-align-all-tables', with a - default value `nil'. + Aligns tables consistently upon visiting a file; useful for + restoring narrowed table columns. The corresponding variable is + `org-startup-align-all-tables' with `nil' as default value. + align align all tables noalign don't align tables on startup - When visiting a file, inline images can be automatically - displayed. The corresponding variable is - `org-startup-with-inline-images', with a default value `nil' to - avoid delays when visiting a file. + Whether Org should automatically display inline images. The + corresponding variable is `org-startup-with-inline-images', with a + default value `nil' to avoid delays when visiting a file. inlineimages show inline images noinlineimages don't show inline images on startup - When visiting a file, LaTeX fragments can be converted to images - automatically. The variable `org-startup-with-latex-preview' which - controls this behavior, is set to `nil' by default to avoid delays - on startup. + Whether Org should automatically convert LaTeX fragments to + images. The variable `org-startup-with-latex-preview', which + controls this setting, is set to `nil' by default to avoid startup + delays. latexpreview preview LaTeX fragments nolatexpreview don't preview LaTeX fragments @@ -16067,16 +16073,16 @@ file is visited again in a new Emacs session. logstatesreversed reverse the order of states notes nologstatesreversed do not reverse the order of states notes - Here are the options for hiding leading stars in outline headings, - and for indenting outlines. The corresponding variables are + These options hide leading stars in outline headings, and indent + outlines. The corresponding variables are `org-hide-leading-stars' and `org-odd-levels-only', both with a - default setting `nil' (meaning `showstars' and `oddeven'). - hidestars make all but one of the stars starting a headline invisible. - showstars show all stars starting a headline - indent virtual indentation according to outline level - noindent no virtual indentation according to outline level - odd allow only odd outline levels (1,3,...) - oddeven allow all outline levels + default setting of `nil' (meaning `showstars' and `oddeven'). + hidestars hide all stars on the headline except one. + showstars show all stars on the headline + indent virtual indents according to the outline level + noindent no virtual indents + odd show odd outline levels only (1,3,...) + oddeven show all outline levels To turn on custom format overlays over timestamps (variables `org-put-time-stamp-overlays' and @@ -16088,7 +16094,7 @@ file is visited again in a new Emacs session. constcgs `constants.el' should use the c-g-s unit system constSI `constants.el' should use the SI unit system - To influence footnote settings, use the following keywords. The + For footnote settings, use the following keywords. The corresponding variables are `org-footnote-define-inline', `org-footnote-auto-label', and `org-footnote-auto-adjust'. fninline define footnotes inline @@ -16112,18 +16118,16 @@ file is visited again in a new Emacs session. entitiesplain Leave entities plain `#+TAGS: TAG1(c1) TAG2(c2)' - These lines (several such lines are allowed) specify the valid - tags in this file, and (potentially) the corresponding _fast tag + These lines specify valid tags for this file. Org accepts + multiple tags lines. Tags could correspond to the _fast tag selection_ keys. The corresponding variable is `org-tag-alist'. `#+TBLFM:' - This line contains the formulas for the table directly above the - line. - - Table can have multiple lines containing `#+TBLFM:'. Note that - only the first line of `#+TBLFM:' will be applied when you - recalculate the table. For more details see *note Using multiple - #+TBLFM lines:: in *note Editing and debugging formulas::. + This line is for formulas for the table directly above. A table + can have multiple `#+TBLFM:' lines. On table recalculation, Org + applies only the first `#+TBLFM:' line. For details see *note + Using multiple #+TBLFM lines:: in *note Editing and debugging + formulas::. `#+TITLE:, #+AUTHOR:, #+EMAIL:, #+LANGUAGE:, #+DATE:,' `#+OPTIONS:, #+BIND:,' @@ -16132,47 +16136,40 @@ file is visited again in a new Emacs session. details see *note Export settings::. `#+TODO: #+SEQ_TODO: #+TYP_TODO:' - These lines set the TODO keywords and their interpretation in the + These lines set the TODO keywords and their significance to the current file. The corresponding variable is `org-todo-keywords'. - ---------- Footnotes ---------- - - (1) Emacs 23 and Org mode 6.29 are required -  File: org, Node: The very busy C-c C-c key, Next: Clean view, Prev: In-buffer settings, Up: Miscellaneous 15.7 The very busy C-c C-c key ============================== -The key `C-c C-c' has many purposes in Org, which are all mentioned -scattered throughout this manual. One specific function of this key is -to add _tags_ to a headline (*note Tags::). In many other -circumstances it means something like _"Hey Org, look here and update -according to what you see here"_. Here is a summary of what this means -in different contexts. +The `C-c C-c' key in Org serves many purposes depending on the context. +It is probably the most over-worked, multi-purpose key combination in +Org. Its uses are well-documented through out this manual, but here is +a consolidated list for easy reference. - - If there are highlights in the buffer from the creation of a sparse - tree, or from clock display, remove these highlights. + - If any highlights shown in the buffer from the creation of a + sparse tree, or from clock display, remove such highlights. - - If the cursor is in one of the special `#+KEYWORD' lines, this - triggers scanning the buffer for these lines and updating the - information. + - If the cursor is in one of the special `#+KEYWORD' lines, scan the + buffer for these lines and update the information. - - If the cursor is inside a table, realign the table. This command - works even if the automatic table editor has been turned off. + - If the cursor is inside a table, realign the table. The table + realigns even if automatic table editor is turned off. - If the cursor is on a `#+TBLFM' line, re-apply the formulas to the entire table. - If the current buffer is a capture buffer, close the note and file - it. With a prefix argument, file it, without further interaction, - to the default location. + it. With a prefix argument, also jump to the target location + after saving the note. - If the cursor is on a `<<>>', update radio targets and corresponding links in this buffer. - - If the cursor is in a property line or at the start or end of a + - If the cursor is on a property line or at the start or end of a property drawer, offer property commands. - If the cursor is at a footnote reference, go to the corresponding @@ -16197,12 +16194,11 @@ File: org, Node: Clean view, Next: TTY keys, Prev: The very busy C-c C-c key, 15.8 A cleaner outline view =========================== -Some people find it noisy and distracting that the Org headlines start -with a potentially large number of stars, and that text below the -headlines is not indented. While this is no problem when writing a -_book-like_ document where the outline headings are really section -headings, in a more _list-oriented_ outline, indented structure is a -lot cleaner: +Org's default outline with stars and no indents can become too +cluttered for short documents. For _book-like_ long documents, the +effect is not as noticeable. Org provides an alternate stars and +indentation scheme, as shown on the right in the following table. It +uses only one star and indents text to line with the heading: * Top level headline | * Top level headline ** Second level | * Second level @@ -16212,93 +16208,84 @@ lot cleaner: more text | more text * Another top level headline | * Another top level headline -If you are using at least Emacs 23.2(1) and version 6.29 of Org, this -kind of view can be achieved dynamically at display time using -`org-indent-mode'. In this minor mode, all lines are prefixed for -display with the necessary amount of space(2). Also headlines are -prefixed with additional stars, so that the amount of indentation -shifts by two(3) spaces per level. All headline stars but the last -one are made invisible using the `org-hide' face(4); see below under -`2.' for more information on how this works. You can turn on -`org-indent-mode' for all files by customizing the variable -`org-startup-indented', or you can turn it on for individual files using +To turn this mode on, use the minor mode, `org-indent-mode'. Text lines +that are not headlines are prefixed with spaces to vertically align +with the headline text(1). + + To make more horizontal space, the headlines are shifted by two +stars. This can be configured by the +`org-indent-indentation-per-level' variable. Only one star on each +headline is visible, the rest are masked with the same font color as +the background. This font face can be configured with the `org-hide' +variable. + + Note that turning on `org-indent-mode' sets `org-hide-leading-stars' +to `t' and `org-adapt-indentation' to `nil'; `2.' below shows how this +works. + + To globally turn on `org-indent-mode' for all files, customize the +variable `org-startup-indented'. + + To turn on indenting for individual files, use `#+STARTUP' option as +follows: #+STARTUP: indent - If you want a similar effect in an earlier version of Emacs and/or -Org, or if you want the indentation to be hard space characters so that -the plain text file looks as similar as possible to the Emacs display, -Org supports you in the following way: + Indent on startup makes Org use hard spaces to align text with +headings as shown in examples below. 1. _Indentation of text below headlines_ - You may indent text below each headline to make the left boundary - line up with the headline, like + Indent text to align with the headline. *** 3rd level more text, now indented - Org supports this with paragraph filling, line wrapping, and - structure editing(5), preserving or adapting the indentation as - appropriate. + Org adapts indentations with paragraph filling, line wrapping, and + structure editing(2). 2. _Hiding leading stars_ - You can modify the display in such a way that all leading stars - become invisible. To do this in a global way, configure the - variable `org-hide-leading-stars' or change this on a per-file - basis with + Org can make leading stars invisible. For global preference, + configure the variable `org-hide-leading-stars'. For per-file + preference, use these file `#+STARTUP' options: #+STARTUP: hidestars #+STARTUP: showstars - With hidden stars, the tree becomes: + With stars hidden, the tree is shown as: * Top level headline * Second level * 3rd level ... - The leading stars are not truly replaced by whitespace, they are - only fontified with the face `org-hide' that uses the background - color as font color. If you are not using either white or black - background, you may have to customize this face to get the wanted - effect. Another possibility is to set this font such that the - extra stars are almost invisible, for example using the color - `grey90' on a white background. - - 3. Things become cleaner still if you skip all the even levels and - use only odd levels 1, 3, 5..., effectively adding two stars to go - from one outline level to the next(6). In this way we get the - outline view shown at the beginning of this section. In order to - make the structure editing and export commands handle this - convention correctly, configure the variable - `org-odd-levels-only', or set this on a per-file basis with one of - the following lines: + Because Org makes the font color same as the background color to + hide to stars, sometimes `org-hide' face may need tweaking to get + the effect right. For some black and white combinations, `grey90' + on a white background might mask the stars better. + + 3. Using stars for only odd levels, 1, 3, 5, ..., can also clean up + the clutter. This removes two stars from each level(3). For Org + to properly handle this cleaner structure during edits and + exports, configure the variable `org-odd-levels-only'. To set + this per-file, use either one of the following lines: #+STARTUP: odd #+STARTUP: oddeven - You can convert an Org file from single-star-per-level to the - double-star-per-level convention with `M-x - org-convert-to-odd-levels RET' in that file. The reverse - operation is `M-x org-convert-to-oddeven-levels'. + To switch between single and double stars layouts, use `M-x + org-convert-to-odd-levels RET' and `M-x + org-convert-to-oddeven-levels'. ---------- Footnotes ---------- - (1) Emacs 23.1 can actually crash with `org-indent-mode' - - (2) `org-indent-mode' also sets the `wrap-prefix' property, such -that `visual-line-mode' (or purely setting `word-wrap') wraps long -lines (including headlines) correctly indented. + (1) The `org-indent-mode' also sets the `wrap-prefix' correctly for +indenting and wrapping long lines of headlines or text. This minor +mode handles `visual-line-mode' and directly applied settings through +`word-wrap'. - (3) See the variable `org-indent-indentation-per-level'. + (2) Also see the variable `org-adapt-indentation'. - (4) Turning on `org-indent-mode' sets `org-hide-leading-stars' to -`t' and `org-adapt-indentation' to `nil'. - - (5) See also the variable `org-adapt-indentation'. - - (6) When you need to specify a level for a property search or refile -targets, `LEVEL=2' will correspond to 3 stars, etc. + (3) Because `LEVEL=2' has 3 stars, `LEVEL=3' has 4 stars, and so on  File: org, Node: TTY keys, Next: Interaction, Prev: Clean view, Up: Miscellaneous @@ -16306,17 +16293,12 @@ File: org, Node: TTY keys, Next: Interaction, Prev: Clean view, Up: Miscella 15.9 Using Org on a tty ======================= -Because Org contains a large number of commands, by default many of -Org's core commands are bound to keys that are generally not accessible -on a tty, such as the cursor keys (, , , ), - and , in particular when used together with modifiers like - and/or . To access these commands on a tty when special -keys are unavailable, the following alternative bindings can be used. -The tty bindings below will likely be more cumbersome; you may find for -some of the bindings below that a customized workaround suits you -better. For example, changing a timestamp is really only fun with -`S-' keys, whereas on a tty you would rather use `C-c .' to -re-insert the timestamp. +Org provides alternative key bindings for TTY and modern mobile devices +that cannot handle cursor keys and complex modifier key chords. Some +of these workarounds may be more cumbersome than necessary. Users +should look into customizing these further based on their usage needs. +For example, the normal `S-' for editing timestamp might be +better with `C-c .' chord. Default Alternative 1 Speed Alternative 2 key @@ -16348,8 +16330,8 @@ File: org, Node: Interaction, Next: org-crypt, Prev: TTY keys, Up: Miscellan 15.10 Interaction with other packages ===================================== -Org lives in the world of GNU Emacs and interacts in various ways with -other code out there. +Org's compatibility and the level of interaction with other Emacs +packages are documented here. * Menu: @@ -16363,60 +16345,47 @@ File: org, Node: Cooperation, Next: Conflicts, Up: Interaction ----------------------------------------- `calc.el' by Dave Gillespie - Org uses the Calc package for implementing spreadsheet - functionality in its tables (*note The spreadsheet::). Org checks - for the availability of Calc by looking for the function - `calc-eval' which will have been autoloaded during setup if Calc - has been installed properly. As of Emacs 22, Calc is part of the - Emacs distribution. Another possibility for interaction between - the two packages is using Calc for embedded calculations. *Note - Embedded Mode: (calc)Embedded Mode. + Org uses the Calc package for tables to implement spreadsheet + functionality (*note The spreadsheet::). Org also uses Calc for + embedded calculations. *Note Embedded Mode: (calc)Embedded Mode. `constants.el' by Carsten Dominik - In a table formula (*note The spreadsheet::), it is possible to use - names for natural constants or units. Instead of defining your own - constants in the variable `org-table-formula-constants', install - the `constants' package which defines a large number of constants - and units, and lets you use unit prefixes like `M' for `Mega', - etc. You will need version 2.0 of this package, available at - `http://www.astro.uva.nl/~dominik/Tools'. Org checks for the - function `constants-get', which has to be autoloaded in your - setup. See the installation instructions in the file - `constants.el'. + Org can use names for constants in formulas in tables. Org can + also use calculation suffixes for units, such as `M' for `Mega'. + For a standard collection of such constants, install the + `constants' package. Install version 2.0 of this package, + available at `https://staff.fnwi.uva.nl/c.dominik/Tools/'. Org + checks if the function `constants-get' has been autoloaded. + Installation instructions are in the file, `constants.el'. `cdlatex.el' by Carsten Dominik - Org mode can make use of the CDLaTeX package to efficiently enter - LaTeX fragments into Org files. See *note CDLaTeX mode::. + Org mode can use CDLaTeX package to efficiently enter LaTeX + fragments into Org files (*note CDLaTeX mode::). `imenu.el' by Ake Stenhoff and Lars Lindberg - Imenu allows menu access to an index of items in a file. Org mode - supports Imenu--all you need to do to get the index is the - following: + Imenu creates dynamic menus based on an index of items in a file. + Org mode supports Imenu menus. Enable it with a mode hook as + follows: (add-hook 'org-mode-hook (lambda () (imenu-add-to-menubar "Imenu"))) - By default the index is two levels deep--you can modify the depth - using the option `org-imenu-depth'. - -`remember.el' by John Wiegley - Org used to use this package for capture, but no longer does. + By default the Imenu index is two levels deep. Change the index + depth using thes variable, `org-imenu-depth'. `speedbar.el' by Eric M. Ludlam - Speedbar is a package that creates a special frame displaying - files and index items in files. Org mode supports Speedbar and - allows you to drill into Org files directly from the Speedbar. It - also allows you to restrict the scope of agenda commands to a file - or a subtree by using the command `<' in the Speedbar frame. + Speedbar package creates a special Emacs frame for displaying + files and index items in files. Org mode supports Speedbar; users + can drill into Org files directly from the Speedbar. The `<' in + the Speedbar frame tweeks the agenda commands to that file or to a + subtree. `table.el' by Takaaki Ota Complex ASCII tables with automatic line wrapping, column- and row-spanning, and alignment can be created using the Emacs table - package by Takaaki Ota (`http://sourceforge.net/projects/table', - and also part of Emacs 22). Org mode will recognize these tables - and export them properly. Because of interference with other Org - mode functionality, you unfortunately cannot edit these tables - directly in the buffer. Instead, you need to use the command `C-c - '' to edit them, similar to source code snippets. - + package by Takaaki Ota. Org mode recognizes such tables and + export them properly. `C-c '' to edit these tables in a special + buffer, much like Org's `src' code blocks. Because of + interference with other Org mode functionality, Takaaki Ota tables + cannot be edited directly in the Org buffer. `C-c ' (`org-edit-special')' Edit a `table.el' table. Works when the cursor is in a table.el table. @@ -16425,51 +16394,38 @@ File: org, Node: Cooperation, Next: Conflicts, Up: Interaction Insert a `table.el' table. If there is already a table at point, this command converts it between the `table.el' format and the Org mode format. See the documentation string of the - command `org-convert-table' for the restrictions under which - this is possible. - `table.el' is part of Emacs since Emacs 22. - -`footnote.el' by Steven L. Baur - Org mode recognizes numerical footnotes as provided by this - package. However, Org mode also has its own footnote support - (*note Footnotes::), which makes using `footnote.el' unnecessary. + command `org-convert-table' for details.  File: org, Node: Conflicts, Prev: Cooperation, Up: Interaction -15.10.2 Packages that lead to conflicts with Org mode ------------------------------------------------------ - - In Emacs 23, `shift-selection-mode' is on by default, meaning that - cursor motions combined with the shift key should start or enlarge - regions. This conflicts with the use of `S-' commands in - Org to change timestamps, TODO keywords, priorities, and item - bullet types if the cursor is at such a location. By default, - `S-' commands outside special contexts don't do anything, - but you can customize the variable `org-support-shift-select'. - Org mode then tries to accommodate shift selection by (i) using it - outside of the special contexts where special commands apply, and - by (ii) extending an existing active region even if the cursor - moves across a special context. +15.10.2 Packages that conflict with Org mode +-------------------------------------------- + + In Emacs, `shift-selection-mode' combines cursor motions with + shift key to enlarge regions. Emacs sets this mode by default. + This conflicts with Org's use of `S-' commands to change + timestamps, TODO keywords, priorities, and item bullet types, etc. + Since `S-' commands outside of specific contexts don't do + anything, Org offers the variable `org-support-shift-select' for + customization. Org mode accommodates shift selection by (i) + making it available outside of the special contexts where special + commands apply, and (ii) extending an existing active region even + if the cursor moves across a special context. `CUA.el' by Kim. F. Storm - Key bindings in Org conflict with the `S-' keys used by - CUA mode (as well as `pc-select-mode' and `s-region-mode') to - select and extend the region. In fact, Emacs 23 has this built-in - in the form of `shift-selection-mode', see previous paragraph. If - you are using Emacs 23, you probably don't want to use another - package for this purpose. However, if you prefer to leave these - keys to a different package while working in Org mode, configure - the variable `org-replace-disputed-keys'. When set, Org will move - the following key bindings in Org files, and in the agenda buffer - (but not during date selection). + Org key bindings conflict with `S-' keys used by CUA mode. + For Org to relinquish these bindings to CUA mode, configure the + variable `org-replace-disputed-keys'. When set, Org moves the + following key bindings in Org files, and in the agenda buffer (but + not during date selection). S-UP => M-p S-DOWN => M-n S-LEFT => M-- S-RIGHT => M-+ C-S-LEFT => M-S-- C-S-RIGHT => M-S-+ - Yes, these are unfortunately more difficult to remember. If you - want to have other replacement keys, look at the variable + Yes, these are unfortunately more difficult to remember. To + define a different replacement keys, look at the variable `org-disputed-keys'. `ecomplete.el' by Lars Magne Ingebrigtsen @@ -16485,9 +16441,9 @@ File: org, Node: Conflicts, Prev: Cooperation, Up: Interaction `filladapt.el' by Kyle Jones Org mode tries to do the right thing when filling paragraphs, list - items and other elements. Many users reported they had problems - using both `filladapt.el' and Org mode, so a safe thing to do is - to disable it like this: + items and other elements. Many users reported problems using both + `filladapt.el' and Org mode, so a safe thing to do is to disable + filladapt like this: (add-hook 'org-mode-hook 'turn-off-filladapt-mode) @@ -16498,17 +16454,17 @@ File: org, Node: Conflicts, Prev: Cooperation, Up: Interaction (add-hook 'org-mode-hook (lambda () - (org-set-local 'yas/trigger-key [tab]) + (setq-local yas/trigger-key [tab]) (define-key yas/keymap [tab] 'yas/next-field-or-maybe-expand))) The latest version of yasnippet doesn't play well with Org mode. - If the above code does not fix the conflict, start by defining the + If the above code does not fix the conflict, first define the following function: (defun yas/org-very-safe-expand () (let ((yas/fallback-behavior 'return-nil)) (yas/expand))) - Then, tell Org mode what to do with the new function: + Then tell Org mode to use that function: (add-hook 'org-mode-hook (lambda () @@ -16545,16 +16501,15 @@ File: org, Node: org-crypt, Prev: Interaction, Up: Miscellaneous 15.11 org-crypt.el ================== -Org-crypt will encrypt the text of an entry, but not the headline, or -properties. Org-crypt uses the Emacs EasyPG library to encrypt and -decrypt files. +Org crypt encrypts the text of an Org entry, but not the headline, or +properties. Org crypt uses the Emacs EasyPG library to encrypt and +decrypt. Any text below a headline that has a `:crypt:' tag will be -automatically be encrypted when the file is saved. If you want to use -a different tag just customize the `org-crypt-tag-matcher' setting. +automatically be encrypted when the file is saved. To use a different +tag, customize the `org-crypt-tag-matcher' variable. - To use org-crypt it is suggested that you have the following in your -`.emacs': + Suggested Org crypt settings in Emacs init file: (require 'org-crypt) (org-crypt-use-before-save-magic) @@ -16574,8 +16529,8 @@ a different tag just customize the `org-crypt-tag-matcher' setting. ;; ;; # -*- buffer-auto-save-file-name: nil; -*- - Excluding the crypt tag from inheritance prevents already encrypted -text being encrypted again. + Excluding the crypt tag from inheritance prevents encrypting +previously encrypted text.  File: org, Node: Hacking, Next: MobileOrg, Prev: Miscellaneous, Up: Top @@ -16607,11 +16562,10 @@ File: org, Node: Hooks, Next: Add-on packages, Up: Hacking A.1 Hooks ========= -Org has a large number of hook variables that can be used to add -functionality. This appendix about hacking is going to illustrate the -use of some of them. A complete list of all hooks with documentation is -maintained by the Worg project and can be found at -`http://orgmode.org/worg/org-configs/org-hooks.php'. +Org has a large number of hook variables for adding functionality. This +appendix illustrates using a few. A complete list of hooks with +documentation is maintained by the Worg project at +`http://orgmode.org/worg/doc.html#hooks'.  File: org, Node: Add-on packages, Next: Adding hyperlink types, Prev: Hooks, Up: Hacking @@ -16619,13 +16573,13 @@ File: org, Node: Add-on packages, Next: Adding hyperlink types, Prev: Hooks, A.2 Add-on packages =================== -A large number of add-on packages have been written by various authors. +Various authors wrote a large number of add-on packages for Org. These packages are not part of Emacs, but they are distributed as contributed packages with the separate release available at `http://orgmode.org'. See the `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: `http://orgmode.org/worg/org-contrib/'. +directory for a list of contributed files. Worg page with more +information is at: `http://orgmode.org/worg/org-contrib/'.  File: org, Node: Adding hyperlink types, Next: Adding export back-ends, Prev: Add-on packages, Up: Hacking @@ -16633,12 +16587,10 @@ File: org, Node: Adding hyperlink types, Next: Adding export back-ends, Prev: A.3 Adding hyperlink types ========================== -Org has a large number of hyperlink types built-in (*note -Hyperlinks::). If you would like to add new link types, Org provides -an interface for doing so. Let's look at an example file, -`org-man.el', that will add support for creating links like -`[[man:printf][The printf manpage]]' to show Unix manual pages inside -Emacs: +Org has many built-in hyperlink types (*note Hyperlinks::), and an +interface for adding new link types. The example file, `org-man.el', +shows the process of adding Org links to Unix man pages, which look +like this: `[[man:printf][The printf manpage]]': ;;; org-man.el - Support for links to manpages in Org @@ -16680,47 +16632,42 @@ Emacs: ;;; org-man.el ends here -You would activate this new link type in `.emacs' with +To activate links to man pages in Org, enter this in the init file: (require 'org-man) -Let's go through the file and see what it does. - 1. It does `(require 'org)' to make sure that `org.el' has been - loaded. - - 2. The next line calls `org-add-link-type' to define a new link type - with prefix `man'. The call also contains the name of a function - that will be called to follow such a link. - - 3. The next line adds a function to `org-store-link-functions', in - order to allow the command `C-c l' to record a useful link in a - buffer displaying a man page. - - The rest of the file defines the necessary variables and functions. -First there is a customization variable that determines which Emacs -command should be used to display man pages. There are two options, -`man' and `woman'. Then the function to follow a link is defined. It -gets the link path as an argument--in this case the link path is just a -topic for the manual command. The function calls the value of -`org-man-command' to display the man page. - - Finally the function `org-man-store-link' is defined. When you try -to store a link with `C-c l', this function will be called to try to -make a link. The function must first decide if it is supposed to -create the link for this buffer type; we do this by checking the value -of the variable `major-mode'. If not, the function must exit and -return the value `nil'. If yes, the link is created by getting the -manual topic from the buffer name and prefixing it with the string -`man:'. Then it must call the command `org-store-link-props' and set -the `:type' and `:link' properties. Optionally you can also set the -`:description' property to provide a default for the link description -when the link is later inserted into an Org buffer with `C-c C-l'. - - When it makes sense for your new link type, you may also define a -function `org-PREFIX-complete-link' that implements special (e.g., -completion) support for inserting such a link with `C-c C-l'. Such a -function should not accept any arguments, and return the full link with -prefix. +A review of `org-man.el': + 1. First, `(require 'org)' ensures `org.el' is loaded. + + 2. The `org-add-link-type' defines a new link type with `man' prefix. + The call contains the function to call that follows the link type. + + 3. The next line adds a function to `org-store-link-functions' that + records a useful link with the command `C-c l' in a buffer + displaying a man page. + + The rest of the file defines necessary variables and functions. +First is the customization variable `org-man-command'. It has two +options, `man' and `woman'. Next is a function whose argument is the +link path, which for man pages is the topic of the man command. To +follow the link, the function calls the `org-man-command' to display +the man page. + + `C-c l' constructs and stores the link. + + `C-c l' calls the function `org-man-store-link', which first checks +if the `major-mode' is appropriate. If check fails, the function +returns `nil'. Otherwise the function makes a link string by combining +the `man:' prefix with the man topic. The function then calls +`org-store-link-props' with `:type' and `:link' properties. A +`:description' property is an optional string that is displayed when the +function inserts the link in the Org buffer. + + `C-c C-l' inserts the stored link. + + To define new link types, define a function that implements +completion support with `C-c C-l'. This function should not accept any +arguments but return the appropriate prefix and complete link string.  File: org, Node: Adding export back-ends, Next: Context-sensitive commands, Prev: Adding hyperlink types, Up: Hacking @@ -16728,30 +16675,28 @@ File: org, Node: Adding export back-ends, Next: Context-sensitive commands, P A.4 Adding export 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 by deriving -them from existing ones. +Org's export engine makes it easy for writing new back-ends. The +framework on which the engine was built makes it easy to derive new +back-ends from existing ones. - Your two entry points are respectively `org-export-define-backend' -and `org-export-define-derived-backend'. To grok these functions, you -should first have a look at `ox-latex.el' (for how to define a new -back-end from scratch) and `ox-beamer.el' (for how to derive a new -back-end from an existing one. + The two main entry points to the export engine are: +`org-export-define-backend' and `org-export-define-derived-backend'. +To grok these functions, see `ox-latex.el' for an example of defining a +new back-end from scratch, and `ox-beamer.el' for an example of +deriving from an existing engine. - 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 alist of elements and -export functions. On top of this, you will need to set additional -keywords like `:menu-entry' (to display the back-end in the export -dispatcher), `:export-block' (to specify what blocks should not be -exported by this back-end), and `:options-alist' (to let the user set -export options that are specific to this back-end.) + For creating a new back-end from scratch, first set its name as a +symbol in an alist consisting of elements and export functions. To +make the back-end visible to the export dispatcher, set `:menu-entry' +keyword. For export options specific to this back-end, set the +`:options-alist'. - Deriving a new back-end is similar, except that you need to set -`:translate-alist' to an alist of export functions that should be used -instead of the parent back-end functions. + For creating a new back-end from an existing one, set +`:translate-alist' to an alist of export functions. This alist +replaces the parent back-end functions. - For a complete reference documentation, see the Org Export Reference -on Worg (http://orgmode.org/worg/dev/org-export-reference.html). + For complete documentation, see the Org Export Reference on Worg +(http://orgmode.org/worg/dev/org-export-reference.html).  File: org, Node: Context-sensitive commands, Next: Tables in arbitrary syntax, Prev: Adding export back-ends, Up: Hacking @@ -16759,39 +16704,16 @@ File: org, Node: Context-sensitive commands, Next: Tables in arbitrary syntax, A.5 Context-sensitive commands ============================== -Org has several commands that act differently depending on context. -The most important example is the `C-c C-c' (*note The very busy C-c -C-c key::). Also the `M-cursor' and `M-S-cursor' keys have this -property. - - Add-ons can tap into this functionality by providing a function that -detects special context for that add-on and executes functionality -appropriate for the context. Here is an example from Dan Davison's -`org-R.el' which allows you to evaluate commands based on the `R' -programming language (1). For this package, special contexts are lines -that start with `#+R:' or `#+RR:'. - - (defun org-R-apply-maybe () - "Detect if this is context for org-R and execute R commands." - (if (save-excursion - (beginning-of-line 1) - (looking-at "#\\+RR?:")) - (progn (call-interactively 'org-R-apply) - t) ;; to signal that we took action - nil)) ;; to signal that we did not - - (add-hook 'org-ctrl-c-ctrl-c-hook 'org-R-apply-maybe) - - The function first checks if the cursor is in such a line. If that -is the case, `org-R-apply' is called and the function returns `t' to -signal that action was taken, and `C-c C-c' will stop looking for other -contexts. If the function finds it should do nothing locally, it -returns `nil' so that other, similar functions can have a try. +Org has facilities for building context sensitive commands. Authors of +Org add-ons can tap into this functionality. - ---------- Footnotes ---------- + Some Org commands change depending on the context. The most +important example of this behavior is the `C-c C-c' (*note The very +busy C-c C-c key::). Other examples are `M-cursor' and `M-S-cursor'. - (1) `org-R.el' has been replaced by the Org mode functionality -described in *note Working with source code:: and is now obsolete. + These context sensitive commands work by providing a function that +detects special context for that add-on and executes functionality +appropriate for that context.  File: org, Node: Tables in arbitrary syntax, Next: Dynamic blocks, Prev: Context-sensitive commands, Up: Hacking @@ -16799,23 +16721,28 @@ File: org, Node: Tables in arbitrary syntax, Next: Dynamic blocks, Prev: Cont A.6 Tables and lists in arbitrary syntax ======================================== -Since Orgtbl mode can be used as a minor mode in arbitrary buffers, a -frequent feature request has been to make it work with native tables in -specific languages, for example LaTeX. However, this is extremely hard -to do in a general way, would lead to a customization nightmare, and -would take away much of the simplicity of the Orgtbl mode table editor. - - This appendix describes a different approach. We keep the Orgtbl -mode table in its native format (the source table), and use a custom -function to translate the table to the correct syntax, and to install -it in the right location (the target table). This puts the burden of -writing conversion functions on the user, but it allows for a very -flexible system. - - Bastien added the ability to do the same with lists, in Orgstruct -mode. You can use Org's facilities to edit and structure lists by -turning `orgstruct-mode' on, then locally exporting such lists in -another format (HTML, LaTeX or Texinfo.) +Because of Org's success in handling tables with Orgtbl, a frequently +asked feature is to Org's usability functions to other table formats +native to other modem's, such as LaTeX. This would be hard to do in a +general way without complicated customization nightmares. Moreover, +that would take Org away from its simplicity roots that Orgtbl has +proven. There is, however, an alternate approach to accomplishing the +same. + + This approach involves implementing a custom _translate_ function +that operates on a native Org _source table_ to produce a table in +another format. This strategy would keep the excellently working +Orgtbl simple and isolate complications, if any, confined to the +translate function. To add more alien table formats, we just add more +translate functions. Also the burden of developing custom translate +functions for new table formats will be in the hands of those who know +those formats best. + + For an example of how this strategy works, see Orgstruct mode. In +that mode, Bastien added the ability to use Org's facilities to edit +and re-structure lists. He did by turning `orgstruct-mode' on, and +then exporting the list locally to another format, such as HTML, LaTeX +or Texinfo. * Menu: @@ -16830,56 +16757,51 @@ File: org, Node: Radio tables, Next: A LaTeX example, Up: Tables in arbitrary A.6.1 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 -`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 `/* ... -*/': +Radio tables are target locations for translated tables that are not +near their source. Org finds the target location and inserts the +translated table. + + The key to finding the target location are the magic words `BEGIN/END +RECEIVE ORGTBL'. They have to appear as comments in the current mode. +If the mode is C, then: /* BEGIN RECEIVE ORGTBL table_name */ /* END RECEIVE ORGTBL table_name */ -Just above the source table, we put a special line that tells Orgtbl -mode how to translate this table and where to install it. For example: +At the location of source, Org needs a special line to direct Orgtbl to +translate and to find the target for inserting the translated table. +For example: #+ORGTBL: SEND table_name translation_function arguments... -`table_name' is the reference name for the table that is also used in -the receiver lines. `translation_function' is the Lisp function that -does the translation. Furthermore, the line can contain a list of -arguments (alternating key and value) at the end. The arguments will be -passed as a property list to the translation function for -interpretation. A few standard parameters are already recognized and -acted upon before the translation function is called: +`table_name' is the table's reference name, which is also used in the +receiver lines, and the `translation_function' is the Lisp function that +translates. This line, in addition, may also contain alternating key +and value arguments at the end. The translation function gets these +values as a property list. A few standard parameters are already +recognized and acted upon before the translation function is called: `:skip N' - Skip the first N lines of the table. Hlines do count as separate - lines for this parameter! + Skip the first N lines of the table. Hlines do count; include + them if they are to be skipped. `:skipcols (n1 n2 ...)' - List of columns that should be skipped. If the table has a column - with calculation marks, that column is automatically discarded as - well. Please note that the translator function sees the table - _after_ the removal of these columns, the function never knows - that there have been additional columns. + List of columns to be skipped. First Org automatically discards + columns with calculation marks and then sends the table to the + translator function, which then skips columns as specified in + `skipcols'. -The one problem remaining is how to keep the source table in the buffer -without disturbing the normal workings of the file, for example during -compilation of a C file or processing of a LaTeX file. There are a -number of different solutions: +To keep the source table intact in the buffer without being disturbed +when the source file is compiled or otherwise being worked on, use one +of these strategies: - * The table could be placed in a block comment if that is supported - by the language. For example, in C mode you could wrap the table - between `/*' and `*/' lines. + * Place the table in a block comment. For example, in C mode you + could wrap the table between `/*' and `*/' lines. - * Sometimes it is possible to put the table after some kind of END - statement, for example `\bye' in TeX and `\end{document}' in LaTeX. + * Put the table after an `END' statement. For example `\bye' in TeX + and `\end{document}' in LaTeX. - * 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 `M-x - orgtbl-toggle-comment RET' makes this comment-toggling very easy, - in particular if you bind it to a key. + * Comment and uncomment each line of the table during edits. The + `M-x orgtbl-toggle-comment RET' command makes toggling easy.  File: org, Node: A LaTeX example, Next: Translator functions, Prev: Radio tables, Up: Tables in arbitrary syntax @@ -16887,13 +16809,12 @@ File: org, Node: A LaTeX example, Next: Translator functions, Prev: Radio tab A.6.2 A LaTeX example of radio tables ------------------------------------- -The best way to wrap the source table in LaTeX is to use the `comment' -environment provided by `comment.sty'. It has to be activated by -placing `\usepackage{comment}' into the document header. Orgtbl mode -can insert a radio table skeleton(1) with the command `M-x -orgtbl-insert-radio-table RET'. You will be prompted for a table name, -let's say we use `salesfigures'. You will then get the following -template: +To wrap a source table in LaTeX, use the `comment' environment provided +by `comment.sty'. To activate it, put `\usepackage{comment}' in the +document header. Orgtbl mode inserts a radio table skeleton(1) with +the command `M-x orgtbl-insert-radio-table RET', which prompts for a +table name. For example, if `salesfigures' is the name, the template +inserts: % BEGIN RECEIVE ORGTBL salesfigures % END RECEIVE ORGTBL salesfigures @@ -16902,10 +16823,10 @@ template: | | | \end{comment} -The `#+ORGTBL: SEND' line tells Orgtbl mode to use the function -`orgtbl-to-latex' to convert the table into LaTeX and to put it into -the receiver location with name `salesfigures'. You may now fill in -the table--feel free to use the spreadsheet features(2): +The line `#+ORGTBL: SEND' tells Orgtbl mode to use the function +`orgtbl-to-latex' to convert the table to LaTeX format, then insert the +table at the target (receive) location named `salesfigures'. Now the +table is ready for data entry. It can even use spreadsheet features(2): % BEGIN RECEIVE ORGTBL salesfigures % END RECEIVE ORGTBL salesfigures @@ -16920,14 +16841,12 @@ the table--feel free to use the spreadsheet features(2): % $ (optional extra dollar to keep font-lock happy, see footnote) \end{comment} -When you are done, press `C-c C-c' in the table to get the converted -table inserted between the two marker lines. +After editing, `C-c C-c' inserts translated table at the target +location, between the two marker lines. - Now let's assume you want to make the table header by hand, because -you want to control how columns are aligned, etc. In this case we make -sure that the table translator skips the first 2 lines of the source -table, and tell the command to work as a splice, i.e., to not produce -header and footer commands of the target table: + For hand-made custom tables, note that the translator needs to skip +the first two lines of the source table. Also the command has to +_splice_ out the target table without the header and footer. \begin{tabular}{lrrr} Month & \multicolumn{1}{c}{Days} & Nr.\ sold & per day\\ @@ -16946,38 +16865,37 @@ header and footer commands of the target table: \end{comment} The LaTeX translator function `orgtbl-to-latex' is already part of -Orgtbl mode. By default, it uses a `tabular' environment to typeset the -table and marks horizontal lines with `\hline'. You can control the -output through several parameters (see also *note Translator -functions::), including the following ones : +Orgtbl mode and uses `tabular' environment by default to typeset the +table and mark the horizontal lines with `\hline'. For additional +parameters to control output, *note Translator functions::: `:splice nil/t' - When non-`nil', return only table body lines, don't wrap them into - a tabular environment. Default is `nil'. + When non-`nil', returns only table body lines; not wrapped in + tabular environment. Default is `nil'. `:fmt fmt' - A format to be used to wrap each field, it should contain `%s' for - the original field value. For example, to wrap each field value - in dollars, you could use `:fmt "$%s$"'. This may also be a + Format to warp each field. It should contain `%s' for the original + field value. For example, to wrap each field value in dollar + symbol, you could use `:fmt "$%s$"'. Format can also wrap a property list with column numbers and formats, for example `:fmt - (2 "$%s$" 4 "%s\\%%")'. A function of one argument can be used in - place of the strings; the function must return a formatted string. + (2 "$%s$" 4 "%s\\%%")'. In place of a string, a function of one + argument can be used; the function must return a formatted string. `:efmt efmt' - Use this format to print numbers with exponentials. The format - should have `%s' twice for inserting mantissa and exponent, for - example `"%s\\times10^{%s}"'. This may also be a property list - with column numbers and formats, for example `:efmt (2 + Format numbers as exponentials. The spec should have `%s' twice + for inserting mantissa and exponent, for example + `"%s\\times10^{%s}"'. This may also be a property list with + column numbers and formats, for example `:efmt (2 "$%s\\times10^{%s}$" 4 "$%s\\cdot10^{%s}$")'. After `efmt' has - been applied to a value, `fmt' will also be applied. Similar to - `fmt', functions of two arguments can be supplied instead of - strings. By default, no special formatting is applied. + been applied to a value, `fmt' will also be applied. Functions + with two arguments can be supplied instead of strings. By default, + no special formatting is applied. ---------- Footnotes ---------- (1) By default this works only for LaTeX, HTML, and Texinfo. Configure the variable `orgtbl-radio-table-templates' to install -templates for other modes. +templates for other export formats. (2) If the `#+TBLFM' line contains an odd number of dollar characters, this may cause problems with font-lock in LaTeX mode. As @@ -16993,26 +16911,24 @@ File: org, Node: Translator functions, Next: Radio lists, Prev: A LaTeX examp A.6.3 Translator functions -------------------------- -Orgtbl mode has several translator functions built-in: `orgtbl-to-csv' +Orgtbl mode has built-in translator functions: `orgtbl-to-csv' (comma-separated values), `orgtbl-to-tsv' (TAB-separated values) `orgtbl-to-latex', `orgtbl-to-html', `orgtbl-to-texinfo', -`orgtbl-to-unicode' and `orgtbl-to-orgtbl'. These all use a generic -translator, `orgtbl-to-generic', which, in turn, can delegate -translations to various export back-ends (*note Export back-ends::). +`orgtbl-to-unicode' and `orgtbl-to-orgtbl'. They use the generic +translator, `orgtbl-to-generic', which delegates translations to various +export back-ends. - In particular, properties passed into the function (i.e., the ones -set by the `ORGTBL SEND' line) take precedence over translations -defined in the function. So if you would like to use the LaTeX -translator, but wanted the line endings to be `\\[2mm]' instead of the -default `\\', you could just overrule the default with + Properties passed to the function through the `ORGTBL SEND' line take +precedence over properties defined inside the function. For example, +this overrides the default LaTeX line endings, `\\', with `\\[2mm]': #+ORGTBL: SEND test orgtbl-to-latex :lend " \\\\[2mm]" - For a new language, you can use the generic function to write your -own converter function. For example, if you have a language where a -table is started with `!BTBL!', ended with `!ETBL!', and where table -lines are started with `!BL!', ended with `!EL!', and where the field -separator is a TAB, you could define your generic translator like this: + For a new language translator, define a converter function. It can +be a generic function, such as shown in this example. It marks a +beginning and ending of a table with `!BTBL!' and `!ETBL!'; a beginning +and ending of lines with `!BL!' and `!EL!'; and uses a TAB for a field +separator: (defun orgtbl-to-language (table params) "Convert the orgtbl-mode TABLE to language." @@ -17022,21 +16938,19 @@ separator is a TAB, you could define your generic translator like this: '(:tstart "!BTBL!" :tend "!ETBL!" :lstart "!BL!" :lend "!EL!" :sep "\t") params))) -Please check the documentation string of the function -`orgtbl-to-generic' for a full list of parameters understood by that -function, and remember that you can pass each of them into +The documentation for the `orgtbl-to-generic' function shows a complete +list of parameters, each of which can be passed through to `orgtbl-to-latex', `orgtbl-to-texinfo', and any other function using -the generic function. +that generic function. - Of course you can also write a completely new function doing -complicated things the generic translator cannot do. A translator -function takes two arguments. The first argument is the table, a list -of lines, each line either the symbol `hline' or a list of fields. The -second argument is the property list containing all parameters -specified in the `#+ORGTBL: SEND' line. The function must return a -single string containing the formatted table. If you write a generally -useful translator, please post it on so that -others can benefit from your work. + For complicated translations the generic translator function could be +replaced by a custom translator function. Such a custom function must +take two arguments and return a single string containing the formatted +table. The first argument is the table whose lines are a list of +fields or the symbol `hline'. The second argument is the property list +consisting of parameters specified in the `#+ORGTBL: SEND' line. +Please share your translator functions by posting them to the Org users +mailing list, .  File: org, Node: Radio lists, Prev: Translator functions, Up: Tables in arbitrary syntax @@ -17044,24 +16958,22 @@ File: org, Node: Radio lists, Prev: Translator functions, Up: Tables in arbit A.6.4 Radio lists ----------------- -Sending and receiving radio lists works exactly the same way as sending -and receiving radio tables (*note Radio tables::). As for radio -tables, you can insert radio list templates in HTML, LaTeX and Texinfo -modes by calling `org-list-insert-radio-list'. - - Here are the differences with radio tables: +Call the `org-list-insert-radio-list' function to insert a radio list +template in HTML, LaTeX, and Texinfo mode documents. Sending and +receiving radio lists works is the same as for radio tables (*note +Radio tables::) except for these differences: - Orgstruct mode must be active. - - Use the `ORGLST' keyword instead of `ORGTBL'. - - - The available translation functions for radio lists don't take - parameters. + - Use `ORGLST' keyword instead of `ORGTBL'. - - `C-c C-c' will work when pressed on the first item of the list. + - `C-c C-c' works only on the first list item. - Here is a LaTeX example. Let's say that you have this in your LaTeX -file: + Built-in translators functions are: `org-list-to-latex', +`org-list-to-html' and `org-list-to-texinfo'. They use the +`org-list-to-generic' translator function. See its documentation for +parameters for accurate customizations of lists. Here is a LaTeX +example: % BEGIN RECEIVE ORGLST to-buy % END RECEIVE ORGLST to-buy @@ -17074,8 +16986,8 @@ file: - a new life \end{comment} - Pressing `C-c C-c' on `a new house' and will insert the converted -LaTeX list between the two marker lines. + `C-c C-c' on `a new house' inserts the translated LaTeX list +in-between the BEGIN and END marker lines.  File: org, Node: Dynamic blocks, Next: Special agenda views, Prev: Tables in arbitrary syntax, Up: Hacking @@ -17083,20 +16995,20 @@ File: org, Node: Dynamic blocks, Next: Special agenda views, Prev: Tables in A.7 Dynamic blocks ================== -Org documents can contain _dynamic blocks_. These are specially marked -regions that are updated by some user-written function. A good example -for such a block is the clock table inserted by the command `C-c C-x -C-r' (*note Clocking work time::). +Org supports _dynamic blocks_ in Org documents. They are inserted with +begin and end markers like any other `src' code block, but the contents +are updated automatically by a user function. For example, `C-c C-x +C-r' inserts a dynamic table that updates the work time (*note Clocking +work time::). - Dynamic blocks are enclosed by a BEGIN-END structure that assigns a -name to the block and can also specify parameters for the function -producing the content of the block. + Dynamic blocks can have names and function parameters. The syntax +is similar to `src' code block specifications: #+BEGIN: myblock :parameter1 value1 :parameter2 value2 ... #+END: - Dynamic blocks are updated with the following commands + These command update dynamic blocks: `C-c C-x C-u (`org-dblock-update')' Update dynamic block at point. @@ -17104,36 +17016,36 @@ producing the content of the block. `C-u C-c C-x C-u' Update all dynamic blocks in the current file. - Updating a dynamic block means to remove all the text between BEGIN -and END, parse the BEGIN line for parameters and then call the specific -writer function for this block to insert the new content. If you want -to use the original content in the writer function, you can use the -extra parameter `:content'. + Before updating a dynamic block, Org removes content between the +BEGIN and END markers. Org then reads the parameters on the BEGIN line +for passing to the writer function. If the function expects to access +the removed content, then Org expects an extra parameter, `:content', +on the BEGIN line. + + To syntax for calling a writer function with a named block, `myblock' +is: `org-dblock-write:myblock'. Parameters come from the BEGIN line. - For a block with name `myblock', the writer function is -`org-dblock-write:myblock' with as only parameter a property list with -the parameters given in the begin line. Here is a trivial example of a -block that keeps track of when the block update function was last run: + The following is an example of a dynamic block and a block writer +function that updates the time when the function was last run: #+BEGIN: block-update-time :format "on %m/%d/%Y at %H:%M" #+END: -The corresponding block writer function could look like this: +The dynamic block's writer function: (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)))) - If you want to make sure that all dynamic blocks are always -up-to-date, you could add the function `org-update-all-dblocks' to a -hook, for example `before-save-hook'. `org-update-all-dblocks' is -written in a way such that it does nothing in buffers that are not in -`org-mode'. + To keep dynamic blocks up-to-date in an Org file, use the function, +`org-update-all-dblocks' in hook, such as `before-save-hook'. The +`org-update-all-dblocks' function does not run if the file is not in +Org mode. - You can narrow the current buffer to the current dynamic block (like -any other block) with `org-narrow-to-block'. + Dynamic blocks, like any other block, can be narrowed with +`org-narrow-to-block'.  File: org, Node: Special agenda views, Next: Speeding up your agendas, Prev: Dynamic blocks, Up: Hacking @@ -17141,29 +17053,23 @@ File: org, Node: Special agenda views, Next: Speeding up your agendas, Prev: A.8 Special agenda views ======================== -Org provides a special hook that can be used to narrow down the -selection made by these agenda views: `agenda', `agenda*'(1), `todo', -`alltodo', `tags', `tags-todo', `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 -`org-agenda-skip-function-global'. More commonly, such a definition is -applied only to specific custom searches, using -`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 marked all tree headings that define a project with the TODO -keyword PROJECT. In this case you would run a TODO search for the -keyword PROJECT, but skip the match unless there is a WAITING tag -anywhere in the subtree belonging to the project line. - - To achieve this, you must write a function that searches the subtree -for the tag. If the tag is found, the function must return `nil' to -indicate that this match should not be skipped. If there is no such -tag, return the location of the end of the subtree, to indicate that -search should continue from there. +Org provides a special hook to further limit items in agenda views: +`agenda', `agenda*'(1), `todo', `alltodo', `tags', `tags-todo', +`tags-tree'. Specify a custom function that tests inclusion of every +matched item in the view. This function can also skip as much as is +needed. + + For a global condition applicable to agenda views, use the +`org-agenda-skip-function-global' variable. Org uses a global condition +with `org-agenda-skip-function' for custom searching. + + This example defines a function for a custom view showing TODO items +with WAITING status. Manually this is a multi step search process, but +with a custom view, this can be automated as follows: + + The custom function searches the subtree for the WAITING tag and +returns `nil' on match. Otherwise it gives the location from where the +search continues. (defun my-skip-unless-waiting () "Skip trees that are not waiting" @@ -17172,26 +17078,22 @@ search should continue from there. nil ; tag found, do not skip subtree-end))) ; tag not found, continue after end of subtree - Now you may use this function in an agenda custom command, for -example like this: + To use this custom function in a custom agenda command: (org-add-agenda-custom-command '("b" todo "PROJECT" ((org-agenda-skip-function 'my-skip-unless-waiting) (org-agenda-overriding-header "Projects waiting for something: ")))) - Note that this also binds `org-agenda-overriding-header' to get a -meaningful header in the agenda view. - - A general way to create custom searches is to base them on a search -for entries with a certain level limit. If you want to study all -entries with your custom search function, simply do a search for -`LEVEL>0'(2), and then use `org-agenda-skip-function' to select the -entries you really want to have. + Note that this also binds `org-agenda-overriding-header' to a more +meaningful string suitable for the agenda view. - You may also put a Lisp form into `org-agenda-skip-function'. In -particular, you may use the functions `org-agenda-skip-entry-if' and -`org-agenda-skip-subtree-if' in this form, for example: + Search for entries with a limit set on levels for the custom search. +This is a general appraoch to creating custom searches in Org. To +include all levels, use `LEVEL>0'(2). Then to selectively pick the +matched entries, use `org-agenda-skip-function', which also accepts Lisp +forms, such as `org-agenda-skip-entry-if' and +`org-agenda-skip-subtree-if'. For example: `(org-agenda-skip-entry-if 'scheduled)' Skip current entry if it has been scheduled. @@ -17224,8 +17126,8 @@ particular, you may use the functions `org-agenda-skip-entry-if' and `(org-agenda-skip-subtree-if 'regexp "regular expression")' Same as above, but check and skip the entire subtree. - Therefore we could also have written the search for WAITING projects -like this, even without defining a special function: + The following is an example of a search for `WAITING' without the +special function: (org-add-agenda-custom-command '("b" todo "PROJECT" @@ -17236,11 +17138,11 @@ like this, even without defining a special function: ---------- Footnotes ---------- (1) The `agenda*' view is the same as `agenda' except that it only -considers _appointments_, i.e., scheduled and deadline items that have a -time specification `[h]h:mm' in their time-stamps. +considers _appointments_, i.e., scheduled and deadline items that have +a time specification `[h]h:mm' in their time-stamps. - (2) Note that, when using `org-odd-levels-only', a level number -corresponds to order in the hierarchy, not to the number of stars. + (2) Note that, for `org-odd-levels-only', a level number corresponds +to order in the hierarchy, not to the number of stars.  File: org, Node: Speeding up your agendas, Next: Extracting agenda information, Prev: Special agenda views, Up: Hacking @@ -17248,30 +17150,29 @@ File: org, Node: Speeding up your agendas, Next: Extracting agenda information A.9 Speeding up your agendas ============================ -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. +Some agenda commands slow down when the Org files grow in size or +number. Here are tips to speed up: - 1. Reduce the number of Org agenda files: this will reduce the - slowdown caused by accessing a hard drive. + 1. Reduce the number of Org agenda files to avoid slowdowns due to + hard drive accesses. - 2. Reduce the number of DONE and archived headlines: this way the - agenda does not need to skip them. + 2. Reduce the number of `DONE' and archived headlines so agenda + operations that skip over these can finish faster. - 3. Inhibit the dimming of blocked tasks: + 3. Do not dim blocked tasks: (setq org-agenda-dim-blocked-tasks nil) - 4. Inhibit agenda files startup options: + 4. Stop preparing agenda buffers on startup: (setq org-agenda-inhibit-startup nil) - 5. Disable tag inheritance in agenda: + 5. Disable tag inheritance for agendas: (setq org-agenda-use-tag-inheritance nil) - 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 dedicated Worg page -(http://orgmode.org/worg/agenda-optimization.html) for further -explanations. + These options can be applied to selected agenda views. For more +details about generation of agenda views, see the docstrings for the +relevant variables, and this dedicated Worg page +(http://orgmode.org/worg/agenda-optimization.html) for agenda +optimization.  File: org, Node: Extracting agenda information, Next: Using the property API, Prev: Speeding up your agendas, Up: Hacking @@ -17279,28 +17180,29 @@ File: org, Node: Extracting agenda information, Next: Using the property API, A.10 Extracting agenda information ================================== -Org provides commands to access agenda information for the command line -in Emacs batch mode. This extracted information can be sent directly -to a printer, or it can be read by a program that does further -processing of the data. The first of these commands is the function -`org-batch-agenda', that produces an agenda view and sends it as ASCII -text to STDOUT. The command takes a single string as parameter. If -the string has length 1, it is used as a key to one of the commands you -have configured in `org-agenda-custom-commands', basically any key you -can use after `C-c a'. For example, to directly print the current TODO -list, you could use +Org provides commands to access agendas through Emacs batch mode. +Through this command-line interface, agendas are automated for further +processing or printing. + + `org-batch-agenda' creates an agenda view in ASCII and outputs to +STDOUT. This command takes one string parameter. When string +length=1, Org uses it as a key to `org-agenda-custom-commands'. These +are the same ones available through `C-c a'. + + This example command line directly prints the TODO list to the +printer: emacs -batch -l ~/.emacs -eval '(org-batch-agenda "t")' | lpr - If the parameter is a string with 2 or more characters, it is used -as a tags/TODO match string. For example, to print your local shopping -list (all items with the tag `shop', but excluding the tag `NewYork'), -you could use + When the string parameter length is two or more characters, Org +matches it with tags/TODO strings. For example, this example command +line prints items tagged with `shop', but excludes items tagged with +`NewYork': emacs -batch -l ~/.emacs \ -eval '(org-batch-agenda "+shop-NewYork")' | lpr -You may also modify parameters on the fly like this: +An example showing on-the-fly parameter modifications: emacs -batch -l ~/.emacs \ -eval '(org-batch-agenda "a" \ @@ -17309,14 +17211,11 @@ You may also modify parameters on the fly like this: org-agenda-files (quote ("~/org/project.org")))' \ | lpr -which will produce a 30-day agenda, fully restricted to the Org file -`~/org/projects.org', not even including the diary. +which will produce an agenda for the next 30 days from just the +`~/org/projects.org' file. - If you want to process the agenda data in more sophisticated ways, -you can use the command `org-batch-agenda-csv' to get a comma-separated -list of values for each agenda item. Each line in the output will -contain a number of fields separated by commas. The fields in a line -are: + For structured processing of agenda output, use +`org-batch-agenda-csv' with the following fields: category The category of the item head The headline, without TODO keyword, TAGS and PRIORITY @@ -17339,12 +17238,15 @@ are: priority-l The priority letter if any was given priority-n The computed numerical priority -Time and date will only be given if a timestamp (or deadline/scheduled) -led to the selection of the item. +If the selection of the agenda item was based on a timestamp, including +those items with `DEADLINE' and `SCHEDULED' keywords, then Org includes +date and time in the output. + + If the selection of the agenda item was based on a timestamp (or +deadline/scheduled), then Org includes date and time in the output. - A CSV list like this is very easy to use in a post-processing script. -For example, here is a Perl program that gets the TODO list from -Emacs/Org and prints all the items, preceded by a checkbox: + Here is an example of a post-processing script in Perl. It takes +the CSV output from Emacs and prints with a checkbox: #!/usr/bin/perl @@ -17369,8 +17271,7 @@ File: org, Node: Using the property API, Next: Using the mapping API, Prev: E A.11 Using the property API =========================== -Here is a description of the functions that can be used to work with -properties. +Functions for working with properties. -- Function: org-entry-properties &optional pom which Get all properties of the entry at point-or-marker POM. @@ -17381,7 +17282,7 @@ properties. 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 `special' or `standard', only get that subclass. - + -- Function: 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 @@ -17445,35 +17346,32 @@ File: org, Node: Using the mapping API, Prev: Using the property API, Up: Hac A.12 Using the mapping API ========================== -Org has sophisticated mapping capabilities to find all entries -satisfying certain criteria. Internally, this functionality is used to -produce agenda views, but there is also an API that can be used to -execute arbitrary functions for each or selected entries. The main -entry point for this API is: +Org has sophisticated mapping capabilities for finding entries. Org +uses this functionality internally for generating agenda views. Org +also exposes an API for executing arbitrary functions for each selected +entry. The API's main entry point is: -- Function: org-map-entries func &optional match scope &rest skip Call `FUNC' at each headline selected by `MATCH' in `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. - - 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. - - `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. + `FUNC' is a function or a Lisp form. With the cursor positioned + at the beginning of the headline, call the function without + arguments. Org returns an alist of return values of calls to the + function. + + To avoid preserving point, Org wraps the call to `FUNC' in + save-excursion form. After evaluation, Org moves the cursor to + the end of the line that was just processed. Search continues + from that point forward. This may not always work as expected + under some conditions, such as if the current sub-tree was removed + by a previous archiving operation. In such rare circumstances, + Org skips the next entry entirely when it should not. To stop Org + from such skips, make `FUNC' set the variable + `org-map-continue-from' to a specific buffer position. + + `MATCH' is a tags/property/TODO match. Org iterates only matched + headlines. Org iterates over all headlines when `MATCH' is `nil' + or `t'. `SCOPE' determines the scope of this command. It can be any of: @@ -17488,8 +17386,8 @@ entry point for this API is: all agenda files with any archive files associated with them (file1 file2 ...) if this is a list, all files in the list will be scanned - The remaining args are treated as settings for the skipping - facilities of the scanner. The following items can be given here: + The remaining args are treated as settings for the scanner's + skipping facilities. Valid args are: archive skip trees with the archive tag comment skip trees with the COMMENT keyword @@ -17499,11 +17397,9 @@ entry point for this API is: will not be called for that entry and search will continue from the point where the function leaves it - The function given to that mapping routine can really do anything -you like. It can use the property API (*note Using the property API::) -to gather more information about the entry, or in order to change -metadata in the entry. Here are a couple of functions that might be -handy: + The mapping routine can call any arbitrary function, even functions +that change meta data or query the property API (*note Using the +property API::). Here are some handy functions: -- Function: org-todo &optional arg Change the TODO state of the entry. See the docstring of the @@ -17524,10 +17420,9 @@ handy: -- Function: org-demote Demote the current entry. - Here is a simple example that will turn all entries in the current -file with a tag `TOMORROW' into TODO entries with the keyword -`UPCOMING'. Entries in comment trees and in archive trees will be -ignored. + This example turns all entries tagged with `TOMORROW' into TODO +entries with keyword `UPCOMING'. Org ignores entries in comment trees +and archive trees. (org-map-entries '(org-todo "UPCOMING") @@ -17544,33 +17439,33 @@ File: org, Node: MobileOrg, Next: History and acknowledgments, Prev: Hacking, Appendix B MobileOrg ******************** -MobileOrg is the name of the mobile companion app for Org mode, -currently available for iOS and for Android. MobileOrg offers offline -viewing and capture support for an Org mode system rooted on a "real" -computer. It also allows you to record changes to existing entries. -The iOS implementation (https://github.com/MobileOrg/) for the -iPhone/iPod Touch/iPad series of devices, was started by Richard +MobileOrg is a companion mobile app that runs on iOS and Android +devices. MobileOrg enables offline-views and capture support for an +Org mode system that is rooted on a "real" computer. MobileOrg can +record changes to existing entries. + + The iOS implementation (https://github.com/MobileOrg/) for the +_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 MobileOrg Android -(http://wiki.github.com/matburt/mobileorg-android/) by Matt Jones. The -two implementations are not identical but offer similar features. - - This appendix describes the support Org has for creating agenda -views in a format that can be displayed by MobileOrg, and for -integrating notes captured and changes made by MobileOrg into the main -system. - - For changing tags and TODO states in MobileOrg, you should have set -up the customization variables `org-todo-keywords' and `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 sets (*note Per-file keywords::) and mutually exclusive tags -(*note Setting tags::) only for those set in these variables. +(http://wiki.github.com/matburt/mobileorg-android/) by Matt Jones. +Though the two implementations are not identical, they offer similar +features. + + This appendix describes Org's support for agenda view formats +compatible with MobileOrg. It also describes synchronizing changes, +such as to notes, between MobileOrg and the computer. + + To change tags and TODO states in MobileOrg, first customize the +variables `org-todo-keywords' and `org-tag-alist'. These should cover +all the important tags and TODO keywords, even if Org files use only +some of them. Though MobileOrg has in-buffer settings, it understands +TODO states _sets_ (*note Per-file keywords::) and _mutually exclusive_ +tags (*note Setting tags::) only for those set in these variables. * Menu: -* Setting up the staging area:: Where to interact with the mobile device +* Setting up the staging area:: For the mobile device * Pushing to MobileOrg:: Uploading Org files and agendas * Pulling from MobileOrg:: Integrating captured and flagged items @@ -17580,36 +17475,35 @@ File: org, Node: Setting up the staging area, Next: Pushing to MobileOrg, Up: B.1 Setting up the staging area =============================== -MobileOrg needs to interact with Emacs through a directory on a server. -If you are using a public server, you should consider encrypting the -files that are uploaded to the server. This can be done with Org mode -7.02 and with MobileOrg 1.5 (iPhone version), and you need an `openssl' -installation on your system. To turn on encryption, set a password in -MobileOrg and, on the Emacs side, configure the variable -`org-mobile-use-encryption'(1). - - The easiest way to create that directory is to use a free -Dropbox.com (http://dropbox.com) account(2). When MobileOrg first -connects to your Dropbox, it will create a directory MobileOrg inside -the Dropbox. After the directory has been created, tell Emacs about it: +MobileOrg needs access to a file directory on a server to interact with +Emacs. With a public server, consider encrypting the files. MobileOrg +version 1.5 supports encryption for the iPhone. Org also requires +`openssl' installed on the local computer. To turn on encryption, set +the same password in MobileOrg and in Emacs. Set the password in the +variable `org-mobile-use-encryption'(1). Note that even after +MobileOrg encrypts the file contents, the file names will remain +visible on the file systems of the local computer, the server, and the +mobile device. + + For a server to host files, consider options like Dropbox.com +(http://dropbox.com) account(2). On first connection, MobileOrg +creates a directory `MobileOrg/' on Dropbox. Pass its location to +Emacs through an init file variable as follows: (setq org-mobile-directory "~/Dropbox/MobileOrg") - Org mode has commands to put files for MobileOrg into that directory, -and to read captured notes from there. + Org copies files to the above directory for MobileOrg. Org also +uses the same directory for sharing notes between Org and MobileOrg. ---------- Footnotes ---------- - (1) If you can safely store the password in your Emacs setup, you -might also want to configure `org-mobile-encryption-password'. Please -read the docstring of that variable. Note that encryption will apply -only to the contents of the `.org' files. The file names themselves -will remain visible. + (1) If Emacs is configured for safe storing of passwords, then +configure the variable, `org-mobile-encryption-password'; please read +the docstring of that variable. - (2) If you cannot use Dropbox, or if your version of MobileOrg does -not support it, you can use a webdav server. For more information, -check out the documentation of MobileOrg and also this FAQ entry -(http://orgmode.org/worg/org-faq.html#mobileorg_webdav). + (2) An alternative is to use webdav server. MobileOrg documentation +has details of webdav server configuration. Additional help is at FAQ +entry (http://orgmode.org/worg/org-faq.html#mobileorg_webdav).  File: org, Node: Pushing to MobileOrg, Next: Pulling from MobileOrg, Prev: Setting up the staging area, Up: MobileOrg @@ -17617,36 +17511,33 @@ File: org, Node: Pushing to MobileOrg, Next: Pulling from MobileOrg, Prev: Se B.2 Pushing to MobileOrg ======================== -This operation copies all files currently listed in `org-mobile-files' -to the directory `org-mobile-directory'. By default this list contains -all agenda files (as listed in `org-agenda-files'), but additional files -can be included by customizing `org-mobile-files'. File names will be -staged with paths relative to `org-directory', so all files should be -inside this directory(1). +Org pushes files listed in `org-mobile-files' to +`org-mobile-directory'. Files include agenda files (as listed in +`org-agenda-files'). Customize `org-mobile-files' to add other files. +File names will be staged with paths relative to `org-directory', so +all files should be inside this directory(1). - The push operation also creates a special Org file `agendas.org' with -all custom agenda view defined by the user(2). + Push creates a special Org file `agendas.org' with custom agenda +views defined by the user(2). - Finally, Org writes the file `index.org', containing links to all -other files. MobileOrg first reads this file from the server, and then -downloads all agendas and Org files listed in it. To speed up the -download, MobileOrg will only read files whose checksums(3) have -changed. + Org writes the file `index.org', containing links to other files. +MobileOrg reads this file first from the server to determine what other +files to download for agendas. For faster downloads, MobileOrg will +read only those files whose checksums(3) have changed. ---------- Footnotes ---------- - (1) Symbolic links in `org-directory' need to have the same name as + (1) Symbolic links in `org-directory' should have the same name as their targets. (2) While creating the agendas, Org mode will force ID properties on all referenced entries, so that these entries can be uniquely -identified if MobileOrg flags them for further action. If you do not -want to get these properties in so many entries, you can set the -variable `org-mobile-force-id-on-agenda-items' to `nil'. Org mode will -then rely on outline paths, in the hope that these will be unique -enough. +identified if MobileOrg flags them for further action. To avoid +setting properties configure the variable +`org-mobile-force-id-on-agenda-items' to `nil'. Org mode will then +rely on outline paths, assuming they are unique. - (3) Checksums are stored automatically in the file `checksums.dat' + (3) Checksums are stored automatically in the file `checksums.dat'.  File: org, Node: Pulling from MobileOrg, Prev: Pushing to MobileOrg, Up: MobileOrg @@ -17654,58 +17545,46 @@ File: org, Node: Pulling from MobileOrg, Prev: Pushing to MobileOrg, Up: Mobi B.3 Pulling from MobileOrg ========================== -When MobileOrg synchronizes with the server, it not only pulls the Org -files for viewing. It also appends captured entries and pointers to -flagged and changed entries to the file `mobileorg.org' on the server. -Org has a _pull_ operation that integrates this information into an -inbox file and operates on the pointers to flagged entries. Here is -how it works: +When MobileOrg synchronizes with the server, it pulls the Org files for +viewing. It then appends to the file `mobileorg.org' on the server the +captured entries, pointers to flagged and changed entries. Org +integrates its data in an inbox file format. 1. Org moves all entries found in `mobileorg.org'(1) and appends them to the file pointed to by the variable `org-mobile-inbox-for-pull'. Each captured entry and each editing - event will be a top-level entry in the inbox file. - - 2. After moving the entries, Org will attempt to implement the - changes made in MobileOrg. Some changes are applied directly and - without user interaction. Examples are all changes to tags, TODO - state, headline and body text that can be cleanly applied. - Entries that have been flagged for further action will receive a - tag `:FLAGGED:', so that they can be easily found again. When - there is a problem finding an entry or applying the change, the - pointer entry will remain in the inbox and will be marked with an - error message. You need to later resolve these issues by hand. - - 3. Org will then generate an agenda view with all flagged entries. - The user should then go through these entries and do whatever - actions are necessary. If a note has been stored while flagging - an entry in MobileOrg, that note will be displayed in the echo - area when the cursor is on the corresponding agenda line. + event is a top-level entry in the inbox file. + + 2. After moving the entries, Org attempts changes to MobileOrg. Some + changes are applied directly and without user interaction. + Examples include changes to tags, TODO state, headline and body + text. Entries for further action are tagged as `:FLAGGED:'. Org + marks entries with problems with an error message in the inbox. + They have to be resolved manually. + + 3. Org generates an agenda view for flagged entries for user + intervention to clean up. For notes stored in flagged entries, + MobileOrg displays them in the echo area when the cursor is on the + corresponding agenda item. `?' - Pressing `?' in that special agenda will display the full - flagging note in another window and also push it onto the - kill ring. So you could use `? z C-y C-c C-c' to store that - flagging note as a normal note in the entry. Pressing `?' - twice in succession will offer to remove the `:FLAGGED:' tag - along with the recorded flagging note (which is stored in a - property). In this way you indicate that the intended - processing for this flagged entry is finished. - - If you are not able to process all flagged entries directly, you can -always return to this agenda view(2) using `C-c a ?'. + Pressing `?' displays the entire flagged note in another + window. Org also pushes it to the kill ring. To store + flagged note as a normal note, use `? z C-y C-c C-c'. + Pressing `?' twice does these things: first it removes the + `:FLAGGED:' tag; second, it removes the flagged note from the + property drawer; third, it signals that manual editing of the + flagged entry is now finished. + + `C-c a ?' returns to the agenda view to finish processing flagged +entries. Note that these entries may not be the most recent since +MobileOrg searches files that were last pulled. To get an updated +agenda view with changes since the last pull, pull again. ---------- Footnotes ---------- (1) `mobileorg.org' will be empty after this operation. - (2) Note, however, that there is a subtle difference. The view -created automatically by `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 `C-c a ?' to regenerate the view, only the current agenda -files will be searched. -  File: org, Node: History and acknowledgments, Next: GNU Free Documentation License, Prev: MobileOrg, Up: Top @@ -17720,9 +17599,9 @@ Emacs Outline mode. I was trying to organize my notes and projects, and using Emacs seemed to be the natural way to go. However, having to remember eleven different commands with two or three keys per command, only to hide and show parts of the outline tree, that seemed entirely -unacceptable to me. Also, when using outlines to take notes, I -constantly wanted to restructure the tree, organizing it parallel to my -thoughts and plans. _Visibility cycling_ and _structure editing_ were +unacceptable. Also, when using outlines to take notes, I constantly +wanted to restructure the tree, organizing it paralleling my thoughts +and plans. _Visibility cycling_ and _structure editing_ were originally implemented in the package `outline-magic.el', but quickly moved to the more general `org.el'. As this environment became comfortable for project planning, the next step was adding _TODO @@ -17750,7 +17629,7 @@ Bastien Guerry invented Worg, helped establishing the Web presence of Org, and sponsored hosting costs for the orgmode.org website. Bastien stepped in as maintainer of Org between 2011 and 2013, at a time - when I desparately needed a break. + when I desperately needed a break. Eric Schulte and Dan Davison Eric and Dan are jointly responsible for the Org-babel system, @@ -17783,7 +17662,7 @@ C.2 From Bastien I (Bastien) have been maintaining Org between 2011 and 2013. This appendix would not be complete without adding a few more -acknowledgements and thanks. +acknowledgments and thanks. I am first grateful to Carsten for his trust while handing me over the maintainership of Org. His unremitting support is what really @@ -18095,6 +17974,8 @@ C.3 List of contributions * Piotr Zielinski wrote `org-mouse.el', proposed agenda blocks and contributed various ideas and code snippets. + * Marco Wahl wrote `org-eww.el'. +  File: org, Node: GNU Free Documentation License, Next: Main Index, Prev: History and acknowledgments, Up: Top @@ -18603,7 +18484,19 @@ Concept index (line 12) * #+ATTR_HTML: Links in HTML export. (line 23) -* #+ATTR_LATEX: LaTeX specific attributes. +* #+ATTR_LATEX, in example blocks: Example blocks in LaTeX export. + (line 6) +* #+ATTR_LATEX, in horizontal rules: Horizontal rules in LaTeX export. + (line 6) +* #+ATTR_LATEX, in images: Images in LaTeX export. + (line 6) +* #+ATTR_LATEX, in plain lists: Plain lists in LaTeX export. + (line 6) +* #+ATTR_LATEX, in source blocks: Source blocks in LaTeX export. + (line 6) +* #+ATTR_LATEX, in special blocks: Special blocks in LaTeX export. + (line 6) +* #+ATTR_LATEX, in tables: Tables in LaTeX export. (line 6) * #+ATTR_ODT <1>: Customizing tables in ODT export. (line 6) @@ -18611,7 +18504,13 @@ Concept index (line 30) * #+ATTR_ODT: Tables in ODT export. (line 17) -* #+ATTR_TEXINFO: Texinfo specific attributes. +* #+ATTR_TEXINFO, in images: Images in Texinfo export. + (line 6) +* #+ATTR_TEXINFO, in plain lists: Plain lists in Texinfo export. + (line 6) +* #+ATTR_TEXINFO, in special blocks: Special blocks in Texinfo export. + (line 6) +* #+ATTR_TEXINFO, in tables: Tables in Texinfo export. (line 6) * #+AUTHOR: Export settings. (line 25) * #+BEAMER: Beamer specific syntax. @@ -18630,29 +18529,29 @@ Concept index * #+BEGIN, columnview: Capturing column view. (line 11) * #+BEGIN:dynamic block: Dynamic blocks. (line 15) -* #+BEGIN_ASCII: ASCII/Latin-1/UTF-8 export. - (line 53) -* #+BEGIN_BEAMER: Beamer specific syntax. - (line 19) * #+BEGIN_CENTER: Paragraphs. (line 31) -* #+BEGIN_COMMENT: Comment lines. (line 6) +* #+BEGIN_COMMENT: Comment lines. (line 10) * #+BEGIN_EXAMPLE: Literal examples. (line 8) -* #+BEGIN_HTML: Quoting HTML tags. (line 12) +* #+BEGIN_EXPORT ascii: ASCII/Latin-1/UTF-8 export. + (line 53) +* #+BEGIN_EXPORT beamer: Beamer specific syntax. + (line 19) +* #+BEGIN_EXPORT html: Quoting HTML tags. (line 12) +* #+BEGIN_EXPORT latex: Quoting LaTeX code. (line 11) +* #+BEGIN_EXPORT texinfo: Quoting Texinfo code. + (line 9) * #+BEGIN_JUSTIFYLEFT: ASCII/Latin-1/UTF-8 export. (line 75) * #+BEGIN_JUSTIFYRIGHT: ASCII/Latin-1/UTF-8 export. (line 75) -* #+BEGIN_LATEX: Quoting LaTeX code. (line 11) * #+BEGIN_QUOTE: Paragraphs. (line 26) * #+BEGIN_SRC <1>: Structure of code blocks. (line 6) * #+BEGIN_SRC: Literal examples. (line 28) -* #+BEGIN_TEXINFO: Quoting Texinfo code. - (line 9) * #+BEGIN_VERSE: Paragraphs. (line 13) -* #+BIND: Export settings. (line 194) +* #+BIND: Export settings. (line 210) * #+CALL: Evaluating code blocks. - (line 24) + (line 25) * #+CAPTION <1>: Images in HTML export. (line 24) * #+CAPTION <2>: Tables in HTML export. @@ -18675,24 +18574,23 @@ Concept index (line 10) * #+EMAIL: Export settings. (line 35) * #+EXCLUDE_TAGS: Export settings. (line 51) +* #+EXPORT_FILE_NAME: Export settings. (line 63) * #+FILETAGS: Tag inheritance. (line 20) * #+FINDEX: Indices. (line 6) * #+HEADER:: Code block specific header arguments. (line 30) -* #+HEADERS:: Code block specific header arguments. - (line 30) * #+HTML: Quoting HTML tags. (line 12) * #+HTML_CONTAINER: HTML Specific export settings. (line 17) * #+HTML_DOCTYPE: HTML Specific export settings. (line 14) -* #+HTML_HEAD <1>: CSS support. (line 48) +* #+HTML_HEAD <1>: CSS support. (line 49) * #+HTML_HEAD: HTML Specific export settings. (line 32) -* #+HTML_HEAD_EXTRA <1>: CSS support. (line 48) +* #+HTML_HEAD_EXTRA <1>: CSS support. (line 49) * #+HTML_HEAD_EXTRA: HTML Specific export settings. (line 36) -* #+HTML_INCLUDE_STYLE: CSS support. (line 42) +* #+HTML_INCLUDE_STYLE: CSS support. (line 43) * #+HTML_LINK_HOME: HTML Specific export settings. (line 21) * #+HTML_LINK_UP: HTML Specific export settings. @@ -18700,36 +18598,39 @@ Concept index * #+HTML_MATHJAX: HTML Specific export settings. (line 27) * #+INCLUDE: Include files. (line 7) +* #+INDEX: Generating an index. (line 16) * #+INFOJS_OPT: JavaScript support. (line 23) * #+KEYWORDS (Beamer): Beamer specific export settings. (line 35) * #+KEYWORDS (HTML): HTML Specific export settings. (line 40) * #+KEYWORDS (LaTeX): LaTeX specific export settings. - (line 35) + (line 38) * #+KEYWORDS (ODT): ODT specific export settings. (line 14) * #+KINDEX: Indices. (line 6) * #+LANGUAGE: Export settings. (line 38) * #+LATEX: Quoting LaTeX code. (line 11) -* #+LATEX_CLASS <1>: Header and sectioning. +* #+LATEX_CLASS <1>: LaTeX header and sectioning. (line 22) * #+LATEX_CLASS: LaTeX specific export settings. (line 17) -* #+LATEX_CLASS_OPTIONS <1>: Header and sectioning. +* #+LATEX_CLASS_OPTIONS <1>: LaTeX header and sectioning. (line 22) * #+LATEX_CLASS_OPTIONS: LaTeX specific export settings. (line 22) -* #+LATEX_HEADER <1>: Header and sectioning. +* #+LATEX_COMPILER: LaTeX specific export settings. + (line 25) +* #+LATEX_HEADER <1>: LaTeX header and sectioning. (line 27) * #+LATEX_HEADER: LaTeX specific export settings. - (line 25) + (line 28) * #+LATEX_HEADER (HTML): HTML Specific export settings. (line 45) -* #+LATEX_HEADER_EXTRA <1>: Header and sectioning. +* #+LATEX_HEADER_EXTRA <1>: LaTeX header and sectioning. (line 27) * #+LATEX_HEADER_EXTRA: LaTeX specific export settings. - (line 30) + (line 33) * #+LINK: Link abbreviations. (line 49) * #+MACRO: Macro replacement. (line 6) * #+NAME <1>: Structure of code blocks. @@ -18739,24 +18640,23 @@ Concept index * #+NAME, for table: References. (line 131) * #+ODT_STYLES_FILE: Applying custom styles. (line 28) -* #+OPTIONS <1>: Export settings. (line 6) -* #+OPTIONS: Headings and sections. - (line 14) -* #+ORGLST: Radio lists. (line 25) -* #+ORGTBL: Radio tables. (line 17) -* #+ORGTBL, SEND: A LaTeX example. (line 14) +* #+OPTIONS: Export settings. (line 6) +* #+ORGLST: Radio lists. (line 11) +* #+ORGTBL: Radio tables. (line 19) +* #+ORGTBL, SEND: A LaTeX example. (line 13) * #+PINDEX: Indices. (line 6) * #+PLOT: Org-Plot. (line 6) -* #+PRIORITIES: Priorities. (line 44) +* #+PRIORITIES: Priorities. (line 43) * #+PROPERTY: Property syntax. (line 44) * #+RESULTS: Evaluating code blocks. (line 6) * #+SELECT_TAGS: Export settings. (line 44) * #+SEQ_TODO: Per-file keywords. (line 6) -* #+SETUPFILE <1>: In-buffer settings. (line 55) +* #+SETUPFILE <1>: In-buffer settings. (line 52) * #+SETUPFILE: Export settings. (line 13) -* #+STARTUP: In-buffer settings. (line 68) -* #+SUBAUTHOR <1>: Document preamble. (line 42) +* #+STARTUP: In-buffer settings. (line 64) +* #+SUBAUTHOR <1>: Texinfo title and copyright page. + (line 13) * #+SUBAUTHOR: Texinfo specific export settings. (line 13) * #+SUBTILE (HTML): HTML Specific export settings. @@ -18766,11 +18666,11 @@ Concept index * #+SUBTITLE (Beamer): Beamer specific export settings. (line 43) * #+SUBTITLE (LaTeX): LaTeX specific export settings. - (line 43) + (line 46) * #+SUBTITLE (Texinfo): Texinfo specific export settings. (line 10) * #+TAGS: Setting tags. (line 29) -* #+TBLFM <1>: In-buffer settings. (line 178) +* #+TBLFM <1>: In-buffer settings. (line 173) * #+TBLFM <2>: Editing and debugging formulas. (line 99) * #+TBLFM: Field and range formulas. @@ -18783,32 +18683,32 @@ Concept index (line 9) * #+TEXINFO_CLASS <1>: Headings and sectioning structure. (line 6) -* #+TEXINFO_CLASS <2>: Document preamble. (line 22) +* #+TEXINFO_CLASS <2>: Texinfo file header. (line 12) * #+TEXINFO_CLASS: Texinfo specific export settings. (line 19) -* #+TEXINFO_DIR_CATEGORY <1>: Document preamble. (line 69) +* #+TEXINFO_DIR_CATEGORY <1>: Texinfo Top node. (line 6) * #+TEXINFO_DIR_CATEGORY: Texinfo specific export settings. (line 29) -* #+TEXINFO_DIR_DESC <1>: Document preamble. (line 69) +* #+TEXINFO_DIR_DESC <1>: Texinfo Top node. (line 6) * #+TEXINFO_DIR_DESC: Texinfo specific export settings. (line 35) -* #+TEXINFO_DIR_TITLE <1>: Document preamble. (line 69) +* #+TEXINFO_DIR_TITLE <1>: Texinfo Top node. (line 6) * #+TEXINFO_DIR_TITLE: Texinfo specific export settings. (line 32) -* #+TEXINFO_FILENAME <1>: Document preamble. (line 16) +* #+TEXINFO_FILENAME <1>: Texinfo file header. (line 6) * #+TEXINFO_FILENAME: Texinfo specific export settings. (line 16) -* #+TEXINFO_HEADER <1>: Document preamble. (line 22) +* #+TEXINFO_HEADER <1>: Texinfo file header. (line 12) * #+TEXINFO_HEADER: Texinfo specific export settings. (line 23) * #+TEXINFO_POST_HEADER: Texinfo specific export settings. (line 26) -* #+TEXINFO_PRINTED_TITLE <1>: Document preamble. (line 35) +* #+TEXINFO_PRINTED_TITLE <1>: Texinfo title and copyright page. + (line 6) * #+TEXINFO_PRINTED_TITLE: Texinfo specific export settings. (line 38) * #+TINDEX: Indices. (line 6) -* #+TITLE <1>: Export settings. (line 59) -* #+TITLE: Document title. (line 8) +* #+TITLE: Export settings. (line 59) * #+TOC: Table of contents. (line 6) * #+TODO: Per-file keywords. (line 6) * #+TYP_TODO: Per-file keywords. (line 6) @@ -18841,7 +18741,7 @@ Concept index * :post, src header argument: post. (line 6) * :prologue, src header argument: prologue. (line 6) * :results, src header argument <1>: Results of evaluation. - (line 27) + (line 33) * :results, src header argument <2>: results. (line 6) * :results, src header argument: System-wide header arguments. (line 9) @@ -18853,13 +18753,13 @@ Concept index * :shebang, src header argument: shebang. (line 6) * :tangle, src header argument <1>: tangle. (line 6) * :tangle, src header argument: Extracting source code. - (line 15) + (line 23) * :tangle-mode, src header argument: tangle-mode. (line 6) * :var, src header argument: var. (line 6) * :wrap, src header argument: wrap. (line 6) * abbreviation, links: Link abbreviations. (line 6) -* abstract, in LaTeX export: LaTeX specific attributes. - (line 215) +* abstract, in LaTeX export: Special blocks in LaTeX export. + (line 6) * acknowledgments: History and acknowledgments. (line 6) * action, for publishing: Publishing action. (line 6) @@ -18867,19 +18767,19 @@ Concept index * active region <1>: ODT export commands. (line 6) * active region <2>: Built-in table editor. (line 162) -* active region: Structure editing. (line 146) +* active region: Structure editing. (line 139) * add-on packages: Add-on packages. (line 6) * add-ons, context-sensitive commands: Context-sensitive commands. (line 6) * agenda: Weekly/daily agenda. (line 6) * agenda dispatcher: Agenda dispatcher. (line 6) * agenda files: Agenda files. (line 6) -* agenda files, removing buffers: Agenda commands. (line 526) +* agenda files, removing buffers: Agenda commands. (line 519) * agenda views: Agenda views. (line 6) * agenda views, custom: Custom agenda views. (line 6) * agenda views, exporting <1>: Exporting agenda views. (line 6) -* agenda views, exporting: Agenda commands. (line 512) +* agenda views, exporting: Agenda commands. (line 505) * agenda views, main example: Storing searches. (line 9) * agenda views, optimization: Speeding up your agendas. (line 6) @@ -18890,9 +18790,9 @@ Concept index * agenda, column view: Agenda column view. (line 6) * agenda, pipe: Extracting agenda information. (line 6) -* agenda, sticky: Agenda dispatcher. (line 53) +* agenda, sticky: Agenda dispatcher. (line 50) * agenda, with block views: Block agenda. (line 6) -* align, STARTUP keyword: In-buffer settings. (line 88) +* align, STARTUP keyword: In-buffer settings. (line 85) * alignment in tables: Column width and alignment. (line 6) * anniversaries, from BBDB: Weekly/daily agenda. (line 79) @@ -18901,26 +18801,30 @@ Concept index * API, for properties <1>: Using the property API. (line 6) * API, for properties: Property API. (line 6) -* appointment <1>: Weekly/daily agenda. (line 113) +* appointment <1>: Weekly/daily agenda. (line 126) * appointment: Timestamps. (line 14) -* appointment reminders: Weekly/daily agenda. (line 113) -* appt.el: Weekly/daily agenda. (line 113) +* appointment reminders: Weekly/daily agenda. (line 126) +* appt.el: Weekly/daily agenda. (line 126) * archive locations: Moving subtrees. (line 25) +* archive tag: Internal archiving. (line 6) +* archived entries, in agenda views: Agenda views. (line 37) +* Archives mode: Agenda commands. (line 134) * archiving: Archiving. (line 6) * ASCII export: ASCII/Latin-1/UTF-8 export. (line 6) * Atom feeds: RSS feeds. (line 6) * attachments: Attachments. (line 6) * author: Feedback. (line 6) -* author, macro: Macro replacement. (line 24) +* author, macro: Macro replacement. (line 26) * autoload: Activation. (line 6) * babel, languages: Languages. (line 6) * babel, library of: Library of Babel. (line 6) * backtrace of an error: Feedback. (line 66) -* Baur, Steven L.: Cooperation. (line 74) * BBDB links: External links. (line 6) * BBDB, anniversaries: Weekly/daily agenda. (line 79) * Beamer export: Beamer export. (line 6) +* begin block, end block: Structure of code blocks. + (line 46) * block agenda: Block agenda. (line 6) * blocking, of checkboxes: Checkboxes. (line 46) * blocks, folding: Blocks. (line 6) @@ -18936,21 +18840,24 @@ Concept index * calculations, in tables <1>: The spreadsheet. (line 6) * calculations, in tables: Built-in table editor. (line 162) -* calendar commands, from agenda: Agenda commands. (line 461) +* calendar commands, from agenda: Agenda commands. (line 454) * calendar integration: Weekly/daily agenda. (line 32) * calendar, for selecting date: The date/time prompt. (line 76) * capture <1>: Capture. (line 6) * capture: Capture - Refile - Archive. (line 6) -* capturing, from agenda: Agenda commands. (line 355) +* capturing, from agenda: Agenda commands. (line 348) * category: Categories. (line 6) * category filtering, in agenda: Filtering/limiting agenda items. (line 17) * category, require for tags/property match: Matching tags and properties. (line 72) * CDLaTeX: CDLaTeX mode. (line 6) -* cdlatex.el: Cooperation. (line 29) +* cdlatex.el: Cooperation. (line 21) +* center blocks: Paragraphs. (line 31) +* center image (LaTeX export): Images in LaTeX export. + (line 52) * checkbox blocking: Checkboxes. (line 46) * checkbox statistics: Checkboxes. (line 30) * checkboxes: Checkboxes. (line 6) @@ -18988,6 +18895,8 @@ Concept index * column, of field coordinates: References. (line 86) * commands, in agenda buffer: Agenda commands. (line 6) * comment lines: Comment lines. (line 6) +* comment trees: Comment lines. (line 13) +* commented entries, in agenda views: Agenda views. (line 37) * completion, of dictionary words: Completion. (line 6) * completion, of file names: Handling links. (line 89) * completion, of link abbreviations: Completion. (line 6) @@ -19001,10 +18910,10 @@ Concept index * completion, of TODO keywords <1>: Completion. (line 6) * completion, of TODO keywords: Workflow states. (line 15) * constants, in calculations: References. (line 110) -* constants.el: Cooperation. (line 17) -* constcgs, STARTUP keyword: In-buffer settings. (line 148) -* constSI, STARTUP keyword: In-buffer settings. (line 148) -* content, STARTUP keyword <1>: In-buffer settings. (line 74) +* constants.el: Cooperation. (line 12) +* constcgs, STARTUP keyword: In-buffer settings. (line 143) +* constSI, STARTUP keyword: In-buffer settings. (line 143) +* content, STARTUP keyword <1>: In-buffer settings. (line 71) * content, STARTUP keyword: Initial visibility. (line 6) * contents, global visibility state: Global and local cycling. (line 22) @@ -19021,50 +18930,51 @@ Concept index * countdown timer: Timers. (line 6) * creating timestamps: Creating timestamps. (line 6) * CSS, for HTML export: CSS support. (line 6) -* CUA.el: Conflicts. (line 19) +* CUA.el: Conflicts. (line 18) * custom agenda views: Custom agenda views. (line 6) * custom date/time format: Custom time format. (line 6) * custom search strings: Custom searches. (line 6) * customization: Customization. (line 6) -* customtime, STARTUP keyword: In-buffer settings. (line 144) +* customtime, STARTUP keyword: In-buffer settings. (line 139) * cutting, of subtrees: Structure editing. (line 6) * cycling, in plain lists: Plain lists. (line 69) * cycling, of agenda files: Agenda files. (line 22) * cycling, of TODO states: TODO basics. (line 14) * cycling, visibility: Visibility cycling. (line 6) * daily agenda: Weekly/daily agenda. (line 6) +* dash, special symbol: Special symbols. (line 39) * date format, custom: Custom time format. (line 6) -* date range: Timestamps. (line 43) +* date range: Timestamps. (line 42) * date stamp: Dates and times. (line 6) * date stamps: Timestamps. (line 6) * date tree: Using capture. (line 9) -* date, macro: Macro replacement. (line 29) +* date, macro: Macro replacement. (line 31) * date, reading in minibuffer: The date/time prompt. (line 6) * dates: Dates and times. (line 6) * Davison, Dan: Working with source code. (line 6) * DEADLINE keyword: Deadlines and scheduling. - (line 9) + (line 11) * deadlines: Timestamps. (line 6) * debugging, of table formulas: Editing and debugging formulas. (line 132) * demotion, of subtrees: Structure editing. (line 6) * dependencies, of TODO states: TODO dependencies. (line 6) -* diary entries, creating from agenda: Agenda commands. (line 466) +* diary entries, creating from agenda: Agenda commands. (line 459) * diary integration: Weekly/daily agenda. (line 32) * dictionary word completion: Completion. (line 6) * directories, for publishing: Sources and destinations. (line 6) * dispatching agenda commands: Agenda dispatcher. (line 6) -* display changing, in agenda: Agenda commands. (line 70) +* display changing, in agenda: Agenda commands. (line 69) * doc, docx, rtf: Configuring a document converter. (line 6) * document structure: Document structure. (line 6) -* document title, markup rules: Document title. (line 6) -* Dominik, Carsten: Cooperation. (line 17) +* document title: Export settings. (line 59) +* Dominik, Carsten: Cooperation. (line 12) * DONE, final TODO keyword: Per-file keywords. (line 26) -* dragging, agenda lines: Agenda commands. (line 360) +* dragging, agenda lines: Agenda commands. (line 353) * drawer, for properties: Property syntax. (line 6) * drawer, for state change recording: Tracking TODO state changes. (line 6) @@ -19075,9 +18985,13 @@ Concept index (line 47) * dvipng: Math formatting in HTML export. (line 6) +* dvisvgm <1>: Working with LaTeX math snippets. + (line 47) +* dvisvgm: Math formatting in HTML export. + (line 6) * dynamic blocks: Dynamic blocks. (line 6) * dynamic indentation: Clean view. (line 6) -* ecomplete.el: Conflicts. (line 39) +* ecomplete.el: Conflicts. (line 33) * editing tables: Tables. (line 6) * editing, of table formulas: Editing and debugging formulas. (line 6) @@ -19087,21 +19001,23 @@ Concept index * effort filtering, in agenda: Filtering/limiting agenda items. (line 17) * Elisp links: External links. (line 6) +* ellipsis, special symbol: Special symbols. (line 39) * ELPA: Activation. (line 6) * emacsserver: Protocols. (line 6) -* email, macro: Macro replacement. (line 24) +* email, macro: Macro replacement. (line 26) * embedding images in ODT: Images in ODT export. (line 6) -* entitiesplain, STARTUP keyword: In-buffer settings. (line 171) -* entitiespretty, STARTUP keyword <1>: In-buffer settings. (line 171) -* entitiespretty, STARTUP keyword: Special symbols. (line 31) +* entitiesplain, STARTUP keyword: In-buffer settings. (line 166) +* entitiespretty, STARTUP keyword <1>: In-buffer settings. (line 166) +* entitiespretty, STARTUP keyword: Special symbols. (line 34) +* escaping characters: Special symbols. (line 27) * evaluate time range: Creating timestamps. (line 62) -* even, STARTUP keyword: In-buffer settings. (line 134) -* example blocks, in LaTeX export: LaTeX specific attributes. - (line 201) +* even, STARTUP keyword: In-buffer settings. (line 129) +* example blocks, in LaTeX export: Example blocks in LaTeX export. + (line 6) +* export back-end: Exporting. (line 12) * export back-ends, built-in: Other built-in back-ends. (line 6) -* Export, back-ends: Export back-ends. (line 6) * Export, dispatcher: The export dispatcher. (line 6) * export, OpenDocument: OpenDocument Text export. @@ -19112,7 +19028,7 @@ Concept index * exporting: Exporting. (line 6) * exporting agenda views <1>: Exporting agenda views. (line 13) -* exporting agenda views: Agenda commands. (line 512) +* exporting agenda views: Agenda commands. (line 505) * exporting, not: Comment lines. (line 6) * extended TODO keywords: TODO extensions. (line 6) * external archiving: Moving subtrees. (line 6) @@ -19133,26 +19049,23 @@ Concept index * files for agenda: Agenda files. (line 6) * files, adding to agenda list: Agenda files. (line 15) * files, selecting for publishing: Selecting files. (line 6) -* filladapt.el: Conflicts. (line 50) +* filladapt.el: Conflicts. (line 44) * filtering, by tag, category, top headline and effort, in agenda: Filtering/limiting agenda items. (line 17) * Filters, exporting: Advanced configuration. (line 32) -* fnadjust, STARTUP keyword: In-buffer settings. (line 154) -* fnauto, STARTUP keyword: In-buffer settings. (line 154) -* fnconfirm, STARTUP keyword: In-buffer settings. (line 154) -* fninline, STARTUP keyword: In-buffer settings. (line 154) -* fnlocal, STARTUP keyword: In-buffer settings. (line 154) -* fnplain, STARTUP keyword: In-buffer settings. (line 154) -* fnprompt, STARTUP keyword: In-buffer settings. (line 154) +* fnadjust, STARTUP keyword: In-buffer settings. (line 149) +* fnauto, STARTUP keyword: In-buffer settings. (line 149) +* fnconfirm, STARTUP keyword: In-buffer settings. (line 149) +* fninline, STARTUP keyword: In-buffer settings. (line 149) +* fnlocal, STARTUP keyword: In-buffer settings. (line 149) +* fnplain, STARTUP keyword: In-buffer settings. (line 149) +* fnprompt, STARTUP keyword: In-buffer settings. (line 149) * folded, subtree visibility state: Global and local cycling. (line 10) * folding, sparse trees: Sparse trees. (line 6) * following links: Handling links. (line 101) -* footnote.el <1>: Cooperation. (line 74) -* footnote.el: Footnote markup. (line 6) * footnotes: Footnotes. (line 6) -* footnotes, markup rules: Footnote markup. (line 6) * format specifier: Formula syntax for Calc. (line 14) * format, of links: Link format. (line 6) @@ -19186,32 +19099,31 @@ Concept index * habits: Tracking your habits. (line 6) * hacking: Hacking. (line 6) -* header, for LaTeX files: Header and sectioning. - (line 6) -* headings and sections, markup rules: Headings and sections. +* header, for LaTeX files: LaTeX header and sectioning. (line 6) * headline navigation: Motion. (line 6) * headline tagging: Tags. (line 6) * headline, promotion and demotion: Structure editing. (line 6) * headlines: Headlines. (line 6) * hide text: Visibility cycling. (line 6) -* hideblocks, STARTUP keyword <1>: In-buffer settings. (line 166) +* hideblocks, STARTUP keyword <1>: In-buffer settings. (line 161) * hideblocks, STARTUP keyword: Blocks. (line 13) -* hidestars, STARTUP keyword: In-buffer settings. (line 134) +* hidestars, STARTUP keyword: In-buffer settings. (line 129) * hiding leading stars: Clean view. (line 6) * history: History and acknowledgments. (line 6) * hooks: Hooks. (line 6) * horizontal rules, in ASCII export: ASCII/Latin-1/UTF-8 export. (line 64) -* horizontal rules, in LaTeX export: LaTeX specific attributes. - (line 252) +* horizontal rules, in LaTeX export: Horizontal rules in LaTeX export. + (line 6) * horizontal rules, markup rules: Horizontal rules. (line 6) * HTML entities: Special symbols. (line 6) * HTML export: HTML export. (line 6) * HTML export, CSS: CSS support. (line 6) * HTML, and Orgtbl mode: Translator functions. (line 6) +* HTML5, export new elements: HTML doctypes. (line 36) * hyperlinks: Hyperlinks. (line 6) * hyperlinks, adding new types: Adding hyperlink types. (line 6) @@ -19219,6 +19131,8 @@ Concept index * identify, ImageMagick: Images in ODT export. (line 33) * idle, resolve, dangling: Resolving idle time. (line 9) +* image, centering (LaTeX export): Images in LaTeX export. + (line 52) * imagemagick <1>: Working with LaTeX math snippets. (line 47) * imagemagick: Math formatting in HTML export. @@ -19227,31 +19141,30 @@ Concept index (line 6) * images, inline in HTML: Images in HTML export. (line 6) -* images, inline in LaTeX: LaTeX specific attributes. - (line 103) +* images, inline in LaTeX: Images in LaTeX export. + (line 6) * images, inlining: Handling links. (line 136) -* imenu.el: Cooperation. (line 33) +* imenu.el: Cooperation. (line 25) * in-buffer settings: In-buffer settings. (line 6) -* inactive timestamp: Timestamps. (line 52) -* include files, markup rules: Include files. (line 6) -* indent, STARTUP keyword: In-buffer settings. (line 80) -* indentation, in source blocks <1>: Editing source code. (line 31) -* indentation, in source blocks: Literal examples. (line 58) -* index entries, for publishing: Index entries. (line 6) +* inactive timestamp: Timestamps. (line 51) +* include files, during export: Include files. (line 6) +* indent, STARTUP keyword: In-buffer settings. (line 76) +* indentation, in source blocks <1>: Editing source code. (line 38) +* indentation, in source blocks: Literal examples. (line 72) * index, in a publishing project: Generating an index. (line 6) * Info links: External links. (line 6) * inheritance, of properties: Property inheritance. (line 6) * inheritance, of tags: Tag inheritance. (line 6) * inlined images, markup rules: Images and tables. (line 22) -* inlineimages, STARTUP keyword <1>: In-buffer settings. (line 95) +* inlineimages, STARTUP keyword <1>: In-buffer settings. (line 90) * inlineimages, STARTUP keyword: Handling links. (line 136) * inlining images: Handling links. (line 136) * inlining images in HTML: Images in HTML export. (line 6) -* inlining images in LaTeX: LaTeX specific attributes. - (line 103) -* input file, macro: Macro replacement. (line 42) +* inlining images in LaTeX: Images in LaTeX export. + (line 6) +* input file, macro: Macro replacement. (line 47) * inserting links: Handling links. (line 66) * insertion, of templates: Easy templates. (line 6) * installation: Installation. (line 6) @@ -19266,22 +19179,20 @@ Concept index * jumping, to headlines: Motion. (line 6) * key bindings, global: Activation. (line 6) * keyword options: Per-file keywords. (line 6) -* LaTeX class: Header and sectioning. +* LaTeX class: LaTeX header and sectioning. (line 6) * LaTeX entities: Special symbols. (line 6) -* LaTeX export: LaTeX and PDF export. - (line 6) +* LaTeX export: LaTeX export. (line 6) * LaTeX fragments: LaTeX fragments. (line 6) -* LaTeX fragments, markup rules: Special symbols. (line 6) * LaTeX fragments, preview: Previewing LaTeX fragments. (line 6) -* LaTeX header: Header and sectioning. +* LaTeX header: LaTeX header and sectioning. (line 6) * LaTeX interpretation: Embedded LaTeX. (line 6) -* LaTeX sectioning structure: Header and sectioning. +* LaTeX sectioning structure: LaTeX header and sectioning. (line 6) * LaTeX, and Orgtbl mode: A LaTeX example. (line 6) -* latexpreview, STARTUP keyword: In-buffer settings. (line 102) +* latexpreview, STARTUP keyword: In-buffer settings. (line 97) * Latin-1 export: ASCII/Latin-1/UTF-8 export. (line 6) * level, require for tags/property match: Matching tags and properties. @@ -19291,7 +19202,7 @@ Concept index * LibreOffice: OpenDocument Text export. (line 6) * limits, in agenda: Filtering/limiting agenda items. - (line 115) + (line 118) * link abbreviations: Link abbreviations. (line 6) * link abbreviations, completion of: Completion. (line 6) * link completion: Handling links. (line 66) @@ -19306,30 +19217,32 @@ Concept index * links, publishing: Publishing links. (line 6) * links, radio targets: Radio targets. (line 6) * links, returning to: Handling links. (line 149) +* linter: Org syntax. (line 24) * Lisp forms, as table formulas: Formula syntax for Lisp. (line 6) +* list of listings: Table of contents. (line 6) +* list of tables: Table of contents. (line 6) * lists, in other modes: Tables in arbitrary syntax. (line 6) -* lists, markup rules: Lists. (line 6) * lists, ordered: Plain lists. (line 6) * lists, plain: Plain lists. (line 6) * literal examples, markup rules: Literal examples. (line 6) -* logdone, STARTUP keyword: In-buffer settings. (line 108) -* logdrawer, STARTUP keyword: In-buffer settings. (line 108) +* logdone, STARTUP keyword: In-buffer settings. (line 103) +* logdrawer, STARTUP keyword: In-buffer settings. (line 103) * logging, of progress: Progress logging. (line 6) -* lognoteclock-out, STARTUP keyword: In-buffer settings. (line 108) -* lognotedone, STARTUP keyword: In-buffer settings. (line 108) -* lognoteredeadline, STARTUP keyword: In-buffer settings. (line 108) -* lognoterefile, STARTUP keyword: In-buffer settings. (line 108) -* lognoterepeat, STARTUP keyword: In-buffer settings. (line 108) -* lognotereschedule, STARTUP keyword: In-buffer settings. (line 108) -* logredeadline, STARTUP keyword: In-buffer settings. (line 108) -* logrefile, STARTUP keyword: In-buffer settings. (line 108) -* logrepeat, STARTUP keyword: In-buffer settings. (line 108) -* logreschedule, STARTUP keyword: In-buffer settings. (line 108) -* logstatesreversed, STARTUP keyword: In-buffer settings. (line 108) +* lognoteclock-out, STARTUP keyword: In-buffer settings. (line 103) +* lognotedone, STARTUP keyword: In-buffer settings. (line 103) +* lognoteredeadline, STARTUP keyword: In-buffer settings. (line 103) +* lognoterefile, STARTUP keyword: In-buffer settings. (line 103) +* lognoterepeat, STARTUP keyword: In-buffer settings. (line 103) +* lognotereschedule, STARTUP keyword: In-buffer settings. (line 103) +* logredeadline, STARTUP keyword: In-buffer settings. (line 103) +* logrefile, STARTUP keyword: In-buffer settings. (line 103) +* logrepeat, STARTUP keyword: In-buffer settings. (line 103) +* logreschedule, STARTUP keyword: In-buffer settings. (line 103) +* logstatesreversed, STARTUP keyword: In-buffer settings. (line 103) * lookup functions in tables: Lookup functions. (line 6) -* Ludlam, Eric M.: Cooperation. (line 45) +* Ludlam, Eric M.: Cooperation. (line 34) * macro replacement, during export: Macro replacement. (line 6) * maintainer: Feedback. (line 6) * mapping entries, API: Using the mapping API. @@ -19355,7 +19268,7 @@ Concept index * MobileOrg: MobileOrg. (line 6) * mode, for calc: Formula syntax for Calc. (line 14) -* modification time, macro: Macro replacement. (line 36) +* modification time, macro: Macro replacement. (line 38) * motion commands in agenda: Agenda commands. (line 19) * motion, between headlines: Motion. (line 6) * name, of column or field: References. (line 110) @@ -19363,26 +19276,26 @@ Concept index * names as TODO keywords: TODO types. (line 6) * narrow columns in tables: Column width and alignment. (line 6) -* noalign, STARTUP keyword: In-buffer settings. (line 88) -* nofnadjust, STARTUP keyword: In-buffer settings. (line 154) -* nofninline, STARTUP keyword: In-buffer settings. (line 154) -* nohideblocks, STARTUP keyword <1>: In-buffer settings. (line 166) +* noalign, STARTUP keyword: In-buffer settings. (line 85) +* nofnadjust, STARTUP keyword: In-buffer settings. (line 149) +* nofninline, STARTUP keyword: In-buffer settings. (line 149) +* nohideblocks, STARTUP keyword <1>: In-buffer settings. (line 161) * nohideblocks, STARTUP keyword: Blocks. (line 13) -* noindent, STARTUP keyword: In-buffer settings. (line 80) -* noinlineimages, STARTUP keyword <1>: In-buffer settings. (line 95) +* noindent, STARTUP keyword: In-buffer settings. (line 76) +* noinlineimages, STARTUP keyword <1>: In-buffer settings. (line 90) * noinlineimages, STARTUP keyword: Handling links. (line 136) -* nolatexpreview, STARTUP keyword: In-buffer settings. (line 102) -* nologdone, STARTUP keyword: In-buffer settings. (line 108) -* nologdrawer, STARTUP keyword: In-buffer settings. (line 108) -* nolognoteclock-out, STARTUP keyword: In-buffer settings. (line 108) -* nologredeadline, STARTUP keyword: In-buffer settings. (line 108) -* nologrefile, STARTUP keyword: In-buffer settings. (line 108) -* nologrepeat, STARTUP keyword: In-buffer settings. (line 108) -* nologreschedule, STARTUP keyword: In-buffer settings. (line 108) -* nologstatesreversed, STARTUP keyword: In-buffer settings. (line 108) +* nolatexpreview, STARTUP keyword: In-buffer settings. (line 97) +* nologdone, STARTUP keyword: In-buffer settings. (line 103) +* nologdrawer, STARTUP keyword: In-buffer settings. (line 103) +* nolognoteclock-out, STARTUP keyword: In-buffer settings. (line 103) +* nologredeadline, STARTUP keyword: In-buffer settings. (line 103) +* nologrefile, STARTUP keyword: In-buffer settings. (line 103) +* nologrepeat, STARTUP keyword: In-buffer settings. (line 103) +* nologreschedule, STARTUP keyword: In-buffer settings. (line 103) +* nologstatesreversed, STARTUP keyword: In-buffer settings. (line 103) * occur, command: Sparse trees. (line 6) * occur-tree: Storing searches. (line 9) -* odd, STARTUP keyword: In-buffer settings. (line 134) +* odd, STARTUP keyword: In-buffer settings. (line 129) * odd-levels-only outlines: Clean view. (line 6) * ODT: OpenDocument Text export. (line 6) @@ -19395,41 +19308,41 @@ Concept index * options, for customization: Customization. (line 6) * options, for publishing: Publishing options. (line 6) * ordered lists: Plain lists. (line 6) +* Org entities: Special symbols. (line 6) * Org export: Org export. (line 6) -* Org mode, turning on: Activation. (line 27) +* Org mode, turning on: Activation. (line 21) * Org syntax: Org syntax. (line 6) * org-agenda, command: Weekly/daily agenda. (line 9) * org-capture-last-stored: Using capture. (line 50) * org-crypt.el: org-crypt. (line 6) * org-decrypt-entry: org-crypt. (line 6) -* org-hide-block-startup: In-buffer settings. (line 165) +* org-hide-block-startup: In-buffer settings. (line 160) * org-insert-drawer <1>: Property syntax. (line 90) * org-insert-drawer: Drawers. (line 6) * org-list-insert-radio-list: Radio lists. (line 6) -* org-pretty-entities: In-buffer settings. (line 170) +* org-pretty-entities: In-buffer settings. (line 165) * org-publish-project-alist: Project alist. (line 6) * Orgstruct mode: Orgstruct mode. (line 6) * Orgtbl mode <1>: Tables in arbitrary syntax. (line 6) * Orgtbl mode: Orgtbl mode. (line 6) -* Ota, Takaaki: Cooperation. (line 52) +* Ota, Takaaki: Cooperation. (line 41) * Outline mode: Outlines. (line 6) * outline tree: Headlines. (line 6) * outlines: Outlines. (line 6) * overview, global visibility state: Global and local cycling. (line 22) -* overview, STARTUP keyword <1>: In-buffer settings. (line 74) +* overview, STARTUP keyword <1>: In-buffer settings. (line 71) * overview, STARTUP keyword: Initial visibility. (line 6) * packages, interaction with other: Interaction. (line 6) * paragraphs, markup rules: Paragraphs. (line 6) * pasting, of subtrees: Structure editing. (line 6) -* PDF export: LaTeX and PDF export. - (line 6) +* PDF export: LaTeX export. (line 6) * per-file keywords: Per-file keywords. (line 6) * plain lists: Plain lists. (line 6) -* plain lists, in LaTeX export: LaTeX specific attributes. - (line 156) -* plain text external links: External links. (line 71) +* plain lists, in LaTeX export: Plain lists in LaTeX export. + (line 6) +* plain text external links: External links. (line 69) * plot tables using Gnuplot: Org-Plot. (line 6) * presentation, of agenda items: Presentation and sorting. (line 6) @@ -19441,8 +19354,8 @@ Concept index * progress logging: Progress logging. (line 6) * projects, for publishing: Project alist. (line 6) * promotion, of subtrees: Structure editing. (line 6) -* proof, in LaTeX export: LaTeX specific attributes. - (line 215) +* proof, in LaTeX export: Special blocks in LaTeX export. + (line 6) * properties: Properties and columns. (line 6) * properties, API <1>: Using the property API. @@ -19463,8 +19376,8 @@ Concept index * property, ARCHIVE <1>: Moving subtrees. (line 37) * property, ARCHIVE: Property inheritance. (line 34) -* property, ATTACH_DIR: Attachments. (line 71) -* property, ATTACH_DIR_INHERIT: Attachments. (line 76) +* property, ATTACH_DIR: Attachments. (line 74) +* property, ATTACH_DIR_INHERIT: Attachments. (line 79) * property, BEAMER_ACT: Sectioning Frames and Blocks in Beamer. (line 38) * property, BEAMER_COL: Sectioning Frames and Blocks in Beamer. @@ -19478,24 +19391,23 @@ Concept index * property, CATEGORY <1>: Categories. (line 12) * property, CATEGORY: Property inheritance. (line 30) -* property, COLUMNS <1>: In-buffer settings. (line 28) +* property, COLUMNS <1>: In-buffer settings. (line 26) * property, COLUMNS: Property inheritance. (line 22) * property, COOKIE_DATA <1>: Checkboxes. (line 30) * property, COOKIE_DATA: Breaking down tasks. (line 21) -* property, COPYING: Document preamble. (line 50) +* property, COPYING: Texinfo title and copyright page. + (line 21) * property, CUSTOM_ID <1>: Handling links. (line 21) * property, CUSTOM_ID: Internal links. (line 6) * property, DESCRIPTION <1>: iCalendar export. (line 46) * property, DESCRIPTION: Headings and sectioning structure. (line 22) * property, Effort: Effort estimates. (line 6) -* property, EXPORT_FILE_NAME: Export settings. (line 199) -* property, EXPORT_LATEX_CLASS: Header and sectioning. +* property, EXPORT_LATEX_CLASS: LaTeX header and sectioning. (line 22) -* property, EXPORT_LATEX_CLASS_OPTIONS: Header and sectioning. +* property, EXPORT_LATEX_CLASS_OPTIONS: LaTeX header and sectioning. (line 22) -* property, EXPORT_TITLE: Document title. (line 10) * property, ID <1>: iCalendar export. (line 21) * property, ID <2>: Capturing column view. (line 22) @@ -19509,7 +19421,7 @@ Concept index (line 38) * property, LOGGING: Tracking TODO state changes. (line 45) -* property, macro: Macro replacement. (line 46) +* property, macro: Macro replacement. (line 51) * property, ORDERED <1>: Checkboxes. (line 46) * property, ORDERED: TODO dependencies. (line 6) * property, special, ALLTAGS: Special properties. (line 13) @@ -19529,14 +19441,15 @@ Concept index * property, special, TIMESTAMP_IA: Special properties. (line 13) * property, special, TODO: Special properties. (line 13) * property, SUMMARY: iCalendar export. (line 46) -* property, UNNUMBERED: Export settings. (line 133) -* property, VISIBILITY: Initial visibility. (line 21) +* property, UNNUMBERED: Export settings. (line 148) +* property, VISIBILITY: Initial visibility. (line 17) * property: CLOCK_MODELINE_TOTAL: Clocking commands. (line 20) * property: LAST_REPEAT: Clocking commands. (line 20) * protocols, for external access: Protocols. (line 6) * publishing: Publishing. (line 6) * query editing, in agenda: Filtering/limiting agenda items. (line 17) +* quote blocks: Paragraphs. (line 26) * radio lists: Radio lists. (line 6) * radio tables: Radio tables. (line 6) * radio targets: Radio targets. (line 6) @@ -19555,15 +19468,14 @@ Concept index * region, active <1>: ODT export commands. (line 6) * region, active <2>: Built-in table editor. (line 162) -* region, active: Structure editing. (line 146) +* region, active: Structure editing. (line 139) * regular expressions, with tags search: Matching tags and properties. (line 61) * relative timer: Timers. (line 6) -* remember.el: Cooperation. (line 42) -* reminders: Weekly/daily agenda. (line 113) -* remote editing, bulk, from agenda: Agenda commands. (line 371) -* remote editing, from agenda: Agenda commands. (line 234) -* remote editing, undo: Agenda commands. (line 235) +* reminders: Weekly/daily agenda. (line 126) +* remote editing, bulk, from agenda: Agenda commands. (line 364) +* remote editing, from agenda: Agenda commands. (line 227) +* remote editing, undo: Agenda commands. (line 228) * remote references: References. (line 131) * repeated tasks: Repeated tasks. (line 6) * report, of clocked time: The clock table. (line 6) @@ -19576,7 +19488,7 @@ Concept index * RSS feeds: RSS feeds. (line 6) * rsync: Uploading files. (line 6) * SCHEDULED keyword: Deadlines and scheduling. - (line 29) + (line 31) * scheduling: Timestamps. (line 6) * Schulte, Eric: Working with source code. (line 6) @@ -19588,7 +19500,7 @@ Concept index * searching for tags: Tag searches. (line 6) * searching, for text: Search view. (line 6) * searching, of properties: Property searches. (line 6) -* sectioning structure, for LaTeX export: Header and sectioning. +* sectioning structure, for LaTeX export: LaTeX header and sectioning. (line 6) * set startup visibility, command: Global and local cycling. (line 33) @@ -19605,18 +19517,19 @@ Concept index * show children, command: Global and local cycling. (line 51) * show hidden text: Visibility cycling. (line 6) -* showall, STARTUP keyword <1>: In-buffer settings. (line 74) +* showall, STARTUP keyword <1>: In-buffer settings. (line 71) * showall, STARTUP keyword: Initial visibility. (line 6) -* showeverything, STARTUP keyword <1>: In-buffer settings. (line 74) +* showeverything, STARTUP keyword <1>: In-buffer settings. (line 71) * showeverything, STARTUP keyword: Initial visibility. (line 6) -* showstars, STARTUP keyword: In-buffer settings. (line 134) +* showstars, STARTUP keyword: In-buffer settings. (line 129) +* shy hyphen, special symbol: Special symbols. (line 39) * sitemap, of published pages: Sitemap. (line 6) * sorting, of agenda items: Sorting agenda items. (line 6) * sorting, of plain list: Plain lists. (line 154) * sorting, of subtrees: Structure editing. (line 6) -* source blocks, in LaTeX export: LaTeX specific attributes. - (line 167) +* source blocks, in LaTeX export: Source blocks in LaTeX export. + (line 6) * source code, batch execution: Batch execution. (line 6) * source code, block header arguments: Header arguments. (line 6) * source code, block structure: Structure of code blocks. @@ -19629,9 +19542,9 @@ Concept index * source code, extracting: Extracting source code. (line 6) * source code, inline: Structure of code blocks. - (line 16) + (line 24) * source code, language: Structure of code blocks. - (line 37) + (line 51) * source code, languages: Languages. (line 6) * source code, library: Library of Babel. (line 6) * source code, noweb reference: Noweb reference syntax. @@ -19639,29 +19552,29 @@ Concept index * source code, results of evaluation: Results of evaluation. (line 6) * source code, switches: Structure of code blocks. - (line 41) + (line 56) * source code, working with: Working with source code. (line 6) * sparse tree, for deadlines: Inserting deadline/schedule. - (line 26) -* sparse tree, for TODO: TODO basics. (line 42) + (line 24) +* sparse tree, for TODO: TODO basics. (line 41) * sparse tree, tag based: Tags. (line 6) * sparse trees: Sparse trees. (line 6) -* Special blocks: Special blocks. (line 6) * special blocks, in ASCII export: ASCII/Latin-1/UTF-8 export. (line 75) -* special blocks, in LaTeX export: LaTeX specific attributes. - (line 215) +* special blocks, in LaTeX export: Special blocks in LaTeX export. + (line 6) * special keywords: In-buffer settings. (line 6) * special symbols: Special symbols. (line 6) +* special symbols, in-buffer display: Special symbols. (line 31) * speed keys: Speed keys. (line 6) -* speedbar.el: Cooperation. (line 45) +* speedbar.el: Cooperation. (line 34) * spreadsheet capabilities: The spreadsheet. (line 6) -* square brackets, around links: External links. (line 71) +* square brackets, around links: External links. (line 69) * statistics, for checkboxes: Checkboxes. (line 30) * statistics, for TODO items: Breaking down tasks. (line 6) * storing links: Handling links. (line 10) -* Storm, Kim. F.: Conflicts. (line 19) +* Storm, Kim. F.: Conflicts. (line 18) * strike-through text, markup rules: Emphasis and monospace. (line 6) * structure editing: Structure editing. (line 6) @@ -19687,21 +19600,22 @@ Concept index * summary: Summary. (line 6) * superscript: Subscripts and superscripts. (line 6) +* syntax checker: Org syntax. (line 24) * syntax, noweb: Noweb reference syntax. (line 6) * syntax, of formulas: Formula syntax for Calc. (line 6) * table editor, built-in: Built-in table editor. (line 6) -* table editor, table.el: Cooperation. (line 52) +* table editor, table.el: Cooperation. (line 41) * table lookup functions: Lookup functions. (line 6) -* table of contents, markup rules: Table of contents. (line 6) -* table.el: Cooperation. (line 49) +* table of contents: Table of contents. (line 6) +* table.el: Cooperation. (line 38) * tables: Tables. (line 6) * tables, in HTML: Tables in HTML export. (line 6) -* tables, in LaTeX export: LaTeX specific attributes. - (line 13) +* tables, in LaTeX export: Tables in LaTeX export. + (line 6) * tables, in ODT export <1>: Customizing tables in ODT export. (line 6) * tables, in ODT export: Tables in ODT export. @@ -19736,7 +19650,6 @@ Concept index (line 6) * templates, for Capture: Capture templates. (line 6) * TeX interpretation: Embedded LaTeX. (line 6) -* TeX macros: Special symbols. (line 6) * TeX symbol completion: Completion. (line 6) * Texinfo export: Texinfo export. (line 6) * text areas, in HTML: Text areas in HTML export. @@ -19750,22 +19663,20 @@ Concept index (line 26) * Time, computing: Durations and time values. (line 6) -* time, macro: Macro replacement. (line 36) +* time, macro: Macro replacement. (line 38) * time, reading in minibuffer: The date/time prompt. (line 6) * time-of-day specification: Time-of-day specifications. (line 6) -* time-sorted view: Timeline. (line 6) -* timeline, single file: Timeline. (line 6) -* timerange: Timestamps. (line 43) +* timerange: Timestamps. (line 42) * times: Dates and times. (line 6) * timestamp <1>: Timestamps. (line 14) * timestamp: Dates and times. (line 6) -* timestamp, inactive: Timestamps. (line 52) -* timestamp, with repeater interval: Timestamps. (line 26) +* timestamp, inactive: Timestamps. (line 51) +* timestamp, with repeater interval: Timestamps. (line 25) * timestamps: Timestamps. (line 6) * timestamps, creating: Creating timestamps. (line 6) -* title, macro: Macro replacement. (line 24) +* title, macro: Macro replacement. (line 26) * TODO dependencies: TODO dependencies. (line 6) * TODO dependencies, NOBLOCKING: TODO dependencies. (line 6) * TODO items: TODO items. (line 6) @@ -19784,7 +19695,7 @@ Concept index (line 17) * transient mark mode <1>: Built-in table editor. (line 162) -* transient mark mode: Structure editing. (line 146) +* transient mark mode: Structure editing. (line 139) * transient-mark-mode: ODT export commands. (line 6) * translator function: Translator functions. (line 6) @@ -19794,7 +19705,7 @@ Concept index * types as TODO keywords: TODO types. (line 6) * underlined text, markup rules: Emphasis and monospace. (line 6) -* undoing remote-editing events: Agenda commands. (line 235) +* undoing remote-editing events: Agenda commands. (line 228) * unison: Uploading files. (line 6) * unoconv: Extending ODT export. (line 11) @@ -19806,23 +19717,22 @@ Concept index * variables, for customization: Customization. (line 6) * vectors, in table calculations: Formula syntax for Calc. (line 11) -* verbatim blocks, in LaTeX export: LaTeX specific attributes. - (line 201) +* verbatim blocks, in LaTeX export: Example blocks in LaTeX export. + (line 6) * verbatim text, markup rules: Emphasis and monospace. (line 6) -* viper.el: Conflicts. (line 97) +* verse blocks: Paragraphs. (line 13) +* viper.el: Conflicts. (line 91) * visibility cycling: Visibility cycling. (line 6) * visibility cycling, drawers: Drawers. (line 6) * visibility, initialize: Initial visibility. (line 6) * visible text, printing: Sparse trees. (line 53) -* VM links: External links. (line 44) -* WANDERLUST links: External links. (line 44) +* VM links: External links. (line 42) +* WANDERLUST links: External links. (line 42) * weekly agenda: Weekly/daily agenda. (line 6) -* Wiegley, John: Cooperation. (line 42) -* windmove.el: Conflicts. (line 84) +* windmove.el: Conflicts. (line 78) * workflow states as TODO keywords: Workflow states. (line 6) -* XEmacs: Installation. (line 6) -* yasnippet.el: Conflicts. (line 58) +* yasnippet.el: Conflicts. (line 52) * zip: Pre-requisites for ODT export. (line 6) @@ -19835,100 +19745,96 @@ Key index [index] * Menu: -* $: Agenda commands. (line 269) -* %: Agenda commands. (line 388) +* $: Agenda commands. (line 262) +* %: Agenda commands. (line 381) * ': CDLaTeX mode. (line 43) -* *: Agenda commands. (line 373) -* +: Agenda commands. (line 291) -* ,: Agenda commands. (line 283) -* -: Agenda commands. (line 296) -* .: Agenda commands. (line 103) -* / <1>: Agenda commands. (line 204) +* *: Agenda commands. (line 366) +* +: Agenda commands. (line 284) +* ,: Agenda commands. (line 276) +* -: Agenda commands. (line 289) +* .: Agenda commands. (line 102) +* / <1>: Agenda commands. (line 203) * /: Filtering/limiting agenda items. (line 17) -* :: Agenda commands. (line 279) +* :: Agenda commands. (line 272) * ;: Timers. (line 6) -* < <1>: Agenda commands. (line 211) +* < <1>: Agenda commands. (line 207) * < <2>: Filtering/limiting agenda items. - (line 76) + (line 67) * < <3>: Agenda files. (line 57) * < <4>: The date/time prompt. (line 82) -* <: Using column view. (line 70) -* <1>: Agenda commands. (line 43) +* <: Using column view. (line 71) +* <1>: Agenda commands. (line 42) * <2>: The date/time prompt. (line 82) -* <3>: Setting tags. (line 116) +* <3>: Setting tags. (line 117) * <4>: Handling links. (line 122) * : Built-in table editor. (line 69) * <1>: Agenda commands. (line 34) -* : Setting tags. (line 115) +* : Setting tags. (line 114) * <1>: CDLaTeX mode. (line 23) -* <2>: Agenda commands. (line 40) -* <3>: Setting tags. (line 107) +* <2>: Agenda commands. (line 39) +* <3>: Setting tags. (line 108) * <4>: Editing and debugging formulas. (line 57) -* <5>: Built-in table editor. - (line 62) -* <6>: Plain lists. (line 68) -* <7>: Structure editing. (line 42) +* <5>: Plain lists. (line 68) +* <6>: Structure editing. (line 35) * : Global and local cycling. (line 10) -* = <1>: Agenda commands. (line 219) +* = <1>: Agenda commands. (line 215) * =: Filtering/limiting agenda items. - (line 86) -* > <1>: Agenda commands. (line 332) + (line 81) +* > <1>: Agenda commands. (line 325) * > <2>: Agenda files. (line 61) * > <3>: The date/time prompt. (line 82) -* >: Using column view. (line 70) +* >: Using column view. (line 71) * ?: Pulling from MobileOrg. - (line 34) -* [ <1>: Agenda commands. (line 127) + (line 28) +* [ <1>: Agenda commands. (line 126) * [: Filtering/limiting agenda items. - (line 66) -* \ <1>: Agenda commands. (line 208) -* \: Filtering/limiting agenda items. - (line 59) + (line 57) * ]: Filtering/limiting agenda items. - (line 66) + (line 57) * ^ <1>: CDLaTeX mode. (line 33) -* ^ <2>: Agenda commands. (line 215) +* ^ <2>: Agenda commands. (line 211) * ^: Filtering/limiting agenda items. - (line 82) + (line 77) * _ <1>: CDLaTeX mode. (line 33) +* _ <2>: Agenda commands. (line 218) * _: Filtering/limiting agenda items. - (line 95) + (line 91) * `: CDLaTeX mode. (line 39) -* a: Agenda commands. (line 257) -* A: Agenda commands. (line 70) -* a: Using column view. (line 59) -* B: Agenda commands. (line 391) -* b: Agenda commands. (line 100) -* C: Agenda commands. (line 494) -* c: Agenda commands. (line 461) +* a: Agenda commands. (line 250) +* A: Agenda commands. (line 69) +* a: Using column view. (line 60) +* B: Agenda commands. (line 384) +* b: Agenda commands. (line 99) +* C: Agenda commands. (line 487) +* c: Agenda commands. (line 454) * C-#: Advanced features. (line 10) * C-': Agenda files. (line 22) * C-,: Agenda files. (line 22) * C-0 C-c C-w: Refile and copy. (line 47) -* C-: Structure editing. (line 28) -* C-_: Agenda commands. (line 235) +* C-: Structure editing. (line 23) +* C-_: Agenda commands. (line 228) * C-c !: Creating timestamps. (line 15) -* C-c #: Checkboxes. (line 84) +* C-c #: Checkboxes. (line 85) * C-c $: Moving subtrees. (line 9) * C-c %: Handling links. (line 142) * C-c &: Handling links. (line 146) -* C-c ' <1>: Cooperation. (line 61) +* C-c ' <1>: Cooperation. (line 48) * C-c ' <2>: Editing source code. (line 6) -* C-c ' <3>: Include files. (line 57) -* C-c ' <4>: Literal examples. (line 73) +* C-c ' <3>: Include files. (line 58) +* C-c ' <4>: Literal examples. (line 87) * C-c ' <5>: Editing and debugging formulas. (line 36) -* C-c ': Footnotes. (line 97) +* C-c ': Footnotes. (line 85) * C-c * <1>: Updating the table. (line 13) * C-c * <2>: Plain lists. (line 139) -* C-c *: Structure editing. (line 135) +* C-c *: Structure editing. (line 128) * C-c +: Built-in table editor. (line 162) * C-c ,: Priorities. (line 24) @@ -19936,19 +19842,20 @@ Key index (line 105) * C-c -: Plain lists. (line 127) * C-c .: Creating timestamps. (line 10) -* C-c / <1>: Conflicts. (line 97) +* C-c / <1>: Conflicts. (line 91) * C-c /: Sparse trees. (line 15) +* C-c / /: Sparse trees. (line 17) * C-c / a: Inserting deadline/schedule. - (line 33) + (line 31) * C-c / b: Inserting deadline/schedule. - (line 30) + (line 28) * C-c / d: Inserting deadline/schedule. - (line 23) + (line 21) * C-c / m <1>: Property searches. (line 10) * C-c / m: Tag searches. (line 9) * C-c / p: Property searches. (line 29) * C-c / r: Sparse trees. (line 17) -* C-c / t: TODO basics. (line 39) +* C-c / t: TODO basics. (line 38) * C-c ;: Comment lines. (line 19) * C-c <: Creating timestamps. (line 29) * C-c : Built-in table editor. @@ -19961,7 +19868,7 @@ Key index * C-c >: Creating timestamps. (line 33) * C-c ?: Editing and debugging formulas. (line 22) -* C-c @: Structure editing. (line 72) +* C-c @: Structure editing. (line 65) * C-c [: Agenda files. (line 15) * C-c \ <1>: Property searches. (line 10) * C-c \: Tag searches. (line 9) @@ -19969,19 +19876,18 @@ Key index * C-c ^ <1>: Built-in table editor. (line 113) * C-c ^ <2>: Plain lists. (line 154) -* C-c ^: Structure editing. (line 114) +* C-c ^: Structure editing. (line 107) * C-c `: Built-in table editor. (line 180) * C-c a: Conventions. (line 35) * C-c a !: Stuck projects. (line 14) * C-c a #: Stuck projects. (line 13) * C-c a ?: Pulling from MobileOrg. - (line 44) + (line 37) * C-c a a: Weekly/daily agenda. (line 9) * C-c a C: Storing searches. (line 9) * C-c a e: Exporting agenda views. (line 64) -* C-c a L: Timeline. (line 10) * C-c a M: Matching tags and properties. (line 17) * C-c a m: Matching tags and properties. @@ -19993,36 +19899,37 @@ Key index * C-c a s: Search view. (line 9) * C-c a T: Global TODO list. (line 15) * C-c a t <1>: Global TODO list. (line 9) -* C-c a t: TODO basics. (line 50) +* C-c a t: TODO basics. (line 49) * C-c c <1>: Using capture. (line 6) * C-c c: Conventions. (line 35) * C-c c C: Capture templates. (line 10) * C-c C-*: Plain lists. (line 144) -* C-c C-a <1>: Agenda commands. (line 304) +* C-c C-a <1>: Agenda commands. (line 297) * C-c C-a: Attachments. (line 26) * C-c C-a a: Attachments. (line 31) * C-c C-a c: Attachments. (line 37) -* C-c C-a D: Attachments. (line 66) -* C-c C-a d: Attachments. (line 63) -* C-c C-a F: Attachments. (line 60) -* C-c C-a f: Attachments. (line 57) -* C-c C-a i: Attachments. (line 75) +* C-c C-a D: Attachments. (line 69) +* C-c C-a d: Attachments. (line 66) +* C-c C-a F: Attachments. (line 63) +* C-c C-a f: Attachments. (line 60) +* C-c C-a i: Attachments. (line 78) * C-c C-a l: Attachments. (line 37) * C-c C-a m: Attachments. (line 37) -* C-c C-a n: Attachments. (line 41) -* C-c C-a O: Attachments. (line 54) -* C-c C-a o: Attachments. (line 48) -* C-c C-a s: Attachments. (line 70) -* C-c C-a z: Attachments. (line 44) +* C-c C-a n: Attachments. (line 44) +* C-c C-a O: Attachments. (line 57) +* C-c C-a o: Attachments. (line 51) +* C-c C-a s: Attachments. (line 73) +* C-c C-a u: Attachments. (line 41) +* C-c C-a z: Attachments. (line 47) * C-c C-b <1>: Editing support. (line 11) * C-c C-b: Motion. (line 15) -* C-c C-c <1>: Cooperation. (line 52) +* C-c C-c <1>: Cooperation. (line 41) * C-c C-c <2>: The very busy C-c C-c key. (line 6) * C-c C-c <3>: Key bindings and useful functions. (line 11) * C-c C-c <4>: Evaluating code blocks. - (line 19) + (line 20) * C-c C-c <5>: Previewing LaTeX fragments. (line 23) * C-c C-c <6>: Using capture. (line 15) @@ -20030,8 +19937,8 @@ Key index * C-c C-c <8>: Clocking commands. (line 51) * C-c C-c <9>: Creating timestamps. (line 26) * C-c C-c <10>: Capturing column view. - (line 51) -* C-c C-c <11>: Using column view. (line 52) + (line 54) +* C-c C-c <11>: Using column view. (line 53) * C-c C-c <12>: Property syntax. (line 92) * C-c C-c <13>: Setting tags. (line 20) * C-c C-c <14>: Checkboxes. (line 52) @@ -20039,17 +19946,17 @@ Key index (line 47) * C-c C-c <16>: Built-in table editor. (line 58) -* C-c C-c <17>: Footnotes. (line 86) +* C-c C-c <17>: Footnotes. (line 74) * C-c C-c: Plain lists. (line 122) * C-c C-c c: Property syntax. (line 110) * C-c C-c D: Property syntax. (line 107) * C-c C-c d: Property syntax. (line 104) * C-c C-c s: Property syntax. (line 96) -* C-c C-d <1>: Agenda commands. (line 311) +* C-c C-d <1>: Agenda commands. (line 304) * C-c C-d: Inserting deadline/schedule. (line 9) * C-c C-e: The export dispatcher. - (line 11) + (line 10) * C-c C-e c a: iCalendar export. (line 34) * C-c C-e c c: iCalendar export. (line 39) * C-c C-e c f: iCalendar export. (line 32) @@ -20100,10 +20007,10 @@ Key index * C-c C-n: Motion. (line 8) * C-c C-o <1>: Key bindings and useful functions. (line 11) -* C-c C-o <2>: Agenda commands. (line 62) +* C-c C-o <2>: Agenda commands. (line 61) * C-c C-o <3>: Creating timestamps. (line 38) * C-c C-o <4>: Handling links. (line 101) -* C-c C-o: Footnotes. (line 90) +* C-c C-o: Footnotes. (line 78) * C-c C-p: Motion. (line 9) * C-c C-q <1>: Setting tags. (line 10) * C-c C-q: Editing and debugging formulas. @@ -20112,132 +20019,132 @@ Key index (line 53) * C-c C-r: Global and local cycling. (line 38) -* C-c C-s <1>: Agenda commands. (line 307) +* C-c C-s <1>: Agenda commands. (line 300) * C-c C-s: Inserting deadline/schedule. - (line 17) + (line 16) * C-c C-t <1>: Clocking commands. (line 67) * C-c C-t: TODO basics. (line 13) * C-c C-u: Motion. (line 18) * C-c C-v a: Key bindings and useful functions. - (line 54) + (line 36) * C-c C-v b: Key bindings and useful functions. - (line 32) + (line 25) * C-c C-v c: Key bindings and useful functions. - (line 42) + (line 30) * C-c C-v C-a: Key bindings and useful functions. - (line 54) + (line 36) * C-c C-v C-b: Key bindings and useful functions. - (line 32) + (line 25) * C-c C-v C-c: Key bindings and useful functions. - (line 42) + (line 30) * C-c C-v C-d: Key bindings and useful functions. - (line 36) + (line 27) * C-c C-v C-e: Key bindings and useful functions. - (line 20) + (line 19) * C-c C-v C-f: Key bindings and useful functions. - (line 40) + (line 29) * C-c C-v C-g: Key bindings and useful functions. - (line 28) + (line 23) * C-c C-v C-h: Key bindings and useful functions. - (line 56) + (line 37) * C-c C-v C-I: Key bindings and useful functions. - (line 50) + (line 34) * C-c C-v C-i: Key bindings and useful functions. - (line 48) + (line 33) * C-c C-v C-j: Key bindings and useful functions. - (line 44) + (line 31) * C-c C-v C-l: Key bindings and useful functions. - (line 46) + (line 32) * C-c C-v C-n: Key bindings and useful functions. (line 18) * C-c C-v C-o: Key bindings and useful functions. - (line 22) + (line 20) * C-c C-v C-p: Key bindings and useful functions. (line 18) * C-c C-v C-r: Key bindings and useful functions. - (line 30) + (line 24) * C-c C-v C-s: Key bindings and useful functions. - (line 34) + (line 26) * C-c C-v C-t: Key bindings and useful functions. - (line 38) + (line 28) * C-c C-v C-u: Key bindings and useful functions. - (line 26) + (line 22) * C-c C-v C-v: Key bindings and useful functions. - (line 24) + (line 21) * C-c C-v C-x: Key bindings and useful functions. - (line 58) + (line 38) * C-c C-v C-z: Key bindings and useful functions. - (line 52) + (line 35) * C-c C-v d: Key bindings and useful functions. - (line 36) + (line 27) * C-c C-v e: Key bindings and useful functions. - (line 20) + (line 19) * C-c C-v f: Key bindings and useful functions. - (line 40) + (line 29) * C-c C-v g: Key bindings and useful functions. - (line 28) + (line 23) * C-c C-v h: Key bindings and useful functions. - (line 56) + (line 37) * C-c C-v I: Key bindings and useful functions. - (line 50) + (line 34) * C-c C-v i <1>: Key bindings and useful functions. - (line 48) -* C-c C-v i: Library of Babel. (line 19) + (line 33) +* C-c C-v i: Library of Babel. (line 12) * C-c C-v j: Key bindings and useful functions. - (line 44) + (line 31) * C-c C-v l: Key bindings and useful functions. - (line 46) + (line 32) * C-c C-v n: Key bindings and useful functions. (line 18) * C-c C-v o: Key bindings and useful functions. - (line 22) + (line 20) * C-c C-v p: Key bindings and useful functions. (line 18) * C-c C-v r: Key bindings and useful functions. - (line 30) + (line 24) * C-c C-v s: Key bindings and useful functions. - (line 34) + (line 26) * C-c C-v t <1>: Key bindings and useful functions. - (line 38) + (line 28) * C-c C-v t: Extracting source code. - (line 26) + (line 36) * C-c C-v u: Key bindings and useful functions. - (line 26) + (line 22) * C-c C-v v: Key bindings and useful functions. - (line 24) + (line 21) * C-c C-v x: Key bindings and useful functions. - (line 58) + (line 38) * C-c C-v z: Key bindings and useful functions. - (line 52) -* C-c C-w <1>: Agenda commands. (line 254) + (line 35) +* C-c C-w <1>: Agenda commands. (line 247) * C-c C-w <2>: Refile and copy. (line 14) * C-c C-w <3>: Using capture. (line 22) -* C-c C-w: Structure editing. (line 110) +* C-c C-w: Structure editing. (line 103) +* C-c C-x ,: Timers. (line 44) * C-c C-x -: Timers. (line 35) * C-c C-x .: Timers. (line 31) * C-c C-x 0: Timers. (line 12) * C-c C-x ;: Timers. (line 20) * C-c C-x <: Agenda files. (line 42) -* C-c C-x > <1>: Agenda commands. (line 194) +* C-c C-x > <1>: Agenda commands. (line 193) * C-c C-x >: Agenda files. (line 49) * C-c C-x \ <1>: Subscripts and superscripts. - (line 21) -* C-c C-x \ <2>: Special symbols. (line 31) -* C-c C-x \: Timers. (line 44) + (line 20) +* C-c C-x \: Special symbols. (line 34) * C-c C-x _: Timers. (line 47) -* C-c C-x A: Agenda commands. (line 265) -* C-c C-x a: Agenda commands. (line 262) -* C-c C-x A: Internal archiving. (line 49) -* C-c C-x a: Internal archiving. (line 36) -* C-c C-x b <1>: Agenda commands. (line 53) +* C-c C-x A: Agenda commands. (line 258) +* C-c C-x a: Agenda commands. (line 255) +* C-c C-x A: Internal archiving. (line 50) +* C-c C-x a: Internal archiving. (line 37) +* C-c C-x b <1>: Agenda commands. (line 52) * C-c C-x b: Global and local cycling. (line 55) -* C-c C-x c: Structure editing. (line 102) -* C-c C-x C-a <1>: Agenda commands. (line 257) +* C-c C-x c: Structure editing. (line 95) +* C-c C-x C-a <1>: Agenda commands. (line 250) * C-c C-x C-a: Archiving. (line 11) * C-c C-x C-b: Checkboxes. (line 56) * C-c C-x C-c <1>: Agenda column view. (line 11) -* C-c C-x C-c <2>: Agenda commands. (line 183) +* C-c C-x C-c <2>: Agenda commands. (line 182) * C-c C-x C-c: Using column view. (line 9) * C-c C-x C-d: Clocking commands. (line 80) * C-c C-x C-e <1>: Effort estimates. (line 17) @@ -20251,44 +20158,44 @@ Key index * C-c C-x C-p: Handling links. (line 152) * C-c C-x C-q: Clocking commands. (line 71) * C-c C-x C-r: The clock table. (line 10) -* C-c C-x C-s <1>: Agenda commands. (line 269) +* C-c C-x C-s <1>: Agenda commands. (line 262) * C-c C-x C-s: Moving subtrees. (line 9) * C-c C-x C-t: Custom time format. (line 12) * C-c C-x C-u <1>: Dynamic blocks. (line 21) * C-c C-x C-u <2>: The clock table. (line 16) * C-c C-x C-u: Capturing column view. - (line 51) + (line 54) * C-c C-x C-v: Handling links. (line 133) * C-c C-x C-w <1>: Built-in table editor. (line 136) -* C-c C-x C-w: Structure editing. (line 76) +* C-c C-x C-w: Structure editing. (line 69) * C-c C-x C-x: Clocking commands. (line 42) * C-c C-x C-y <1>: Built-in table editor. (line 140) -* C-c C-x C-y: Structure editing. (line 84) +* C-c C-x C-y: Structure editing. (line 77) * C-c C-x d: Drawers. (line 6) * C-c C-x e: Effort estimates. (line 14) -* C-c C-x f: Footnotes. (line 51) +* C-c C-x f: Footnotes. (line 41) * C-c C-x G: RSS feeds. (line 27) * C-c C-x g: RSS feeds. (line 23) * C-c C-x i: Capturing column view. - (line 49) + (line 52) * C-c C-x M-w <1>: Built-in table editor. (line 132) -* C-c C-x M-w: Structure editing. (line 80) -* C-c C-x o <1>: Checkboxes. (line 76) +* C-c C-x M-w: Structure editing. (line 73) +* C-c C-x o <1>: Checkboxes. (line 77) * C-c C-x o: TODO dependencies. (line 37) * C-c C-x p <1>: Header arguments in Org mode properties. - (line 34) + (line 31) * C-c C-x p: Property syntax. (line 83) -* C-c C-x q: Tag hierarchy. (line 87) +* C-c C-x q: Tag hierarchy. (line 86) * C-c C-x v: Global and local cycling. (line 61) * C-c C-y <1>: Clocking commands. (line 51) * C-c C-y: Creating timestamps. (line 59) -* C-c C-z <1>: Agenda commands. (line 299) +* C-c C-z <1>: Agenda commands. (line 292) * C-c C-z: Drawers. (line 35) -* C-c l <1>: Literal examples. (line 81) +* C-c l <1>: Literal examples. (line 95) * C-c l: Handling links. (line 9) * C-c M-w: Refile and copy. (line 12) * C-c SPC: Built-in table editor. @@ -20300,17 +20207,18 @@ Key index (line 41) * C-c }: Editing and debugging formulas. (line 26) -* C-c ~: Cooperation. (line 63) -* C-k: Agenda commands. (line 248) -* C-S- <1>: Agenda commands. (line 246) +* C-c ~: Cooperation. (line 50) +* C-k: Agenda commands. (line 241) +* C-M-i: Completion. (line 47) +* C-S- <1>: Agenda commands. (line 239) * C-S-: Multiple sets in one file. (line 25) -* C-S-: Structure editing. (line 37) -* C-S- <1>: Agenda commands. (line 243) +* C-S-: Structure editing. (line 30) +* C-S- <1>: Agenda commands. (line 236) * C-S-: Multiple sets in one file. (line 25) * C-S-: Clocking commands. (line 56) -* C-TAB: Internal archiving. (line 46) +* C-TAB: Internal archiving. (line 47) * C-u C-c !: Creating timestamps. (line 19) * C-u C-c *: Updating the table. (line 16) * C-u C-c .: Creating timestamps. (line 19) @@ -20321,15 +20229,15 @@ Key index * C-u C-c c: Using capture. (line 43) * C-u C-c C-c: Updating the table. (line 19) * C-u C-c C-l: Handling links. (line 86) -* C-u C-c C-t: TODO basics. (line 28) +* C-u C-c C-t: TODO basics. (line 27) * C-u C-c C-w: Refile and copy. (line 33) -* C-u C-c C-x a: Internal archiving. (line 39) +* C-u C-c C-x a: Internal archiving. (line 40) * C-u C-c C-x C-s: Moving subtrees. (line 11) * C-u C-c C-x C-u <1>: Dynamic blocks. (line 22) * C-u C-c C-x C-u <2>: The clock table. (line 20) * C-u C-c C-x C-u: Capturing column view. - (line 55) -* C-u C-u <1>: Initial visibility. (line 25) + (line 58) +* C-u C-u <1>: Initial visibility. (line 21) * C-u C-u : Global and local cycling. (line 33) * C-u C-u C-c *: Updating the table. (line 22) @@ -20346,37 +20254,37 @@ Key index * C-u C-u C-u C-c C-t: TODO dependencies. (line 42) * C-v: The date/time prompt. (line 82) -* C-x C-s <1>: Agenda commands. (line 179) +* C-x C-s <1>: Agenda commands. (line 178) * C-x C-s: Editing and debugging formulas. (line 47) * C-x C-w <1>: Exporting agenda views. (line 12) -* C-x C-w: Agenda commands. (line 511) -* C-x n b: Structure editing. (line 129) -* C-x n s: Structure editing. (line 126) -* C-x n w: Structure editing. (line 132) -* C-y: Structure editing. (line 90) -* D: Agenda commands. (line 112) -* d: Agenda commands. (line 75) -* E: Agenda commands. (line 157) -* e: Using column view. (line 46) -* f: Agenda commands. (line 94) -* F: Agenda commands. (line 46) -* g: Agenda commands. (line 176) -* G: Agenda commands. (line 165) -* g: Using column view. (line 23) -* H: Agenda commands. (line 498) -* i: Agenda commands. (line 466) -* I: Agenda commands. (line 337) -* J: Agenda commands. (line 109) -* j: Agenda commands. (line 106) -* k: Agenda commands. (line 350) -* l: Agenda commands. (line 116) -* L: Agenda commands. (line 37) -* M: Agenda commands. (line 485) -* m: Agenda commands. (line 371) -* M-*: Agenda commands. (line 385) -* M- <1>: Agenda commands. (line 364) +* C-x C-w: Agenda commands. (line 504) +* C-x n b: Structure editing. (line 122) +* C-x n s: Structure editing. (line 119) +* C-x n w: Structure editing. (line 125) +* C-y: Structure editing. (line 83) +* D: Agenda commands. (line 111) +* d: Agenda commands. (line 74) +* E: Agenda commands. (line 156) +* e: Using column view. (line 47) +* f: Agenda commands. (line 93) +* F: Agenda commands. (line 45) +* g: Agenda commands. (line 175) +* G: Agenda commands. (line 164) +* g: Using column view. (line 24) +* H: Agenda commands. (line 491) +* i: Agenda commands. (line 459) +* I: Agenda commands. (line 330) +* J: Agenda commands. (line 108) +* j: Agenda commands. (line 105) +* k: Agenda commands. (line 343) +* l: Agenda commands. (line 115) +* L: Agenda commands. (line 36) +* M: Agenda commands. (line 478) +* m: Agenda commands. (line 364) +* M-*: Agenda commands. (line 378) +* M- <1>: Agenda commands. (line 357) * M- <2>: Editing and debugging formulas. (line 77) * M- <3>: Built-in table editor. @@ -20385,7 +20293,7 @@ Key index * M- <1>: Built-in table editor. (line 86) * M- <2>: Plain lists. (line 103) -* M-: Structure editing. (line 48) +* M-: Structure editing. (line 41) * M- <1>: Timers. (line 40) * M- <2>: Built-in table editor. (line 147) @@ -20394,14 +20302,14 @@ Key index * M- <1>: Built-in table editor. (line 86) * M- <2>: Plain lists. (line 103) -* M-: Structure editing. (line 51) -* M- <1>: Completion. (line 16) +* M-: Structure editing. (line 44) +* M- <1>: Completion. (line 15) * M- <2>: Property syntax. (line 80) * M- <3>: Setting tags. (line 6) * M- <4>: Per-file keywords. (line 23) * M-: Editing and debugging formulas. (line 64) -* M- <1>: Agenda commands. (line 360) +* M- <1>: Agenda commands. (line 353) * M- <2>: Editing and debugging formulas. (line 77) * M- <3>: Built-in table editor. @@ -20417,37 +20325,37 @@ Key index * M-g M-p: Sparse trees. (line 32) * M-g n: Sparse trees. (line 29) * M-g p: Sparse trees. (line 32) -* M-h: Structure editing. (line 66) -* M-m: Agenda commands. (line 382) +* M-h: Structure editing. (line 59) +* M-m: Agenda commands. (line 375) * M-S- <1>: The date/time prompt. (line 82) * M-S- <2>: Editing and debugging formulas. (line 72) * M-S- <3>: Built-in table editor. (line 101) -* M-S-: Structure editing. (line 63) +* M-S-: Structure editing. (line 56) * M-S- <1>: The date/time prompt. (line 82) * M-S- <2>: Built-in table editor. (line 88) * M-S- <3>: Plain lists. (line 108) -* M-S-: Structure editing. (line 54) -* M-S- <1>: Checkboxes. (line 73) +* M-S-: Structure editing. (line 47) +* M-S- <1>: Checkboxes. (line 74) * M-S- <2>: Plain lists. (line 89) -* M-S-: Structure editing. (line 33) +* M-S-: Structure editing. (line 26) * M-S- <1>: The date/time prompt. (line 82) * M-S- <2>: Built-in table editor. (line 91) * M-S- <3>: Plain lists. (line 108) -* M-S-: Structure editing. (line 57) +* M-S-: Structure editing. (line 50) * M-S- <1>: The date/time prompt. (line 82) * M-S- <2>: Editing and debugging formulas. (line 72) * M-S- <3>: Built-in table editor. (line 98) -* M-S-: Structure editing. (line 60) +* M-S-: Structure editing. (line 53) * M-up: Key bindings and useful functions. (line 12) * M-v: The date/time prompt. @@ -20456,61 +20364,61 @@ Key index * mouse-1 <1>: The date/time prompt. (line 82) * mouse-1 <2>: Handling links. (line 124) -* mouse-1: Footnotes. (line 90) -* mouse-2 <1>: Agenda commands. (line 40) +* mouse-1: Footnotes. (line 78) +* mouse-2 <1>: Agenda commands. (line 39) * mouse-2 <2>: Handling links. (line 124) -* mouse-2: Footnotes. (line 90) +* mouse-2: Footnotes. (line 78) * mouse-3 <1>: Agenda commands. (line 34) * mouse-3: Handling links. (line 129) * N: Agenda commands. (line 23) * n <1>: Agenda commands. (line 19) -* n: Using column view. (line 42) -* O: Agenda commands. (line 341) -* o: Agenda commands. (line 72) +* n: Using column view. (line 43) +* O: Agenda commands. (line 334) +* o: Agenda commands. (line 71) * P: Agenda commands. (line 26) * p <1>: Agenda commands. (line 20) -* p: Using column view. (line 42) -* q <1>: Agenda commands. (line 525) -* q: Using column view. (line 26) -* r: Agenda commands. (line 169) -* R: Agenda commands. (line 138) +* p: Using column view. (line 43) +* q <1>: Agenda commands. (line 518) +* q: Using column view. (line 27) +* r: Agenda commands. (line 168) +* R: Agenda commands. (line 137) * r <1>: Global TODO list. (line 23) -* r: Using column view. (line 19) -* S: Agenda commands. (line 489) -* s: Agenda commands. (line 179) -* S- <1>: Agenda commands. (line 296) +* r: Using column view. (line 20) +* S: Agenda commands. (line 482) +* s: Agenda commands. (line 178) +* S- <1>: Agenda commands. (line 289) * S- <2>: The date/time prompt. (line 82) * S- <3>: Creating timestamps. (line 47) -* S- <4>: Priorities. (line 29) +* S- <4>: Priorities. (line 28) * S- <5>: Editing and debugging formulas. (line 67) * S-: Plain lists. (line 90) -* S- <1>: Agenda commands. (line 328) +* S- <1>: Agenda commands. (line 321) * S- <2>: The clock table. (line 24) * S- <3>: The date/time prompt. (line 82) * S- <4>: Creating timestamps. (line 42) -* S- <5>: Using column view. (line 35) +* S- <5>: Using column view. (line 36) * S- <6>: Property syntax. (line 100) * S- <7>: Multiple sets in one file. (line 32) -* S- <8>: TODO basics. (line 34) +* S- <8>: TODO basics. (line 33) * S- <9>: Editing and debugging formulas. (line 67) * S-: Plain lists. (line 149) * S-: Built-in table editor. (line 165) -* S- <1>: Agenda commands. (line 314) +* S- <1>: Agenda commands. (line 307) * S- <2>: The clock table. (line 24) * S- <3>: The date/time prompt. (line 82) * S- <4>: Creating timestamps. (line 42) -* S- <5>: Using column view. (line 35) +* S- <5>: Using column view. (line 36) * S- <6>: Property syntax. (line 100) * S- <7>: Multiple sets in one file. (line 32) -* S- <8>: TODO basics. (line 34) +* S- <8>: TODO basics. (line 33) * S- <9>: Editing and debugging formulas. (line 67) * S-: Plain lists. (line 149) @@ -20518,49 +20426,51 @@ Key index (line 66) * S-: Global and local cycling. (line 22) -* S- <1>: Agenda commands. (line 291) +* S- <1>: Agenda commands. (line 284) * S- <2>: The date/time prompt. (line 82) * S- <3>: Creating timestamps. (line 47) -* S- <4>: Priorities. (line 29) +* S- <4>: Priorities. (line 28) * S-: Editing and debugging formulas. (line 67) -* S-M-: Using column view. (line 75) -* S-M-: TODO basics. (line 58) -* S-M-: Using column view. (line 72) +* S-M-: Using column view. (line 76) +* S-M-: TODO basics. (line 57) +* S-M-: Using column view. (line 73) * S-M-: Clocking commands. (line 60) -* T: Agenda commands. (line 274) -* t: Agenda commands. (line 239) -* U: Agenda commands. (line 379) -* u: Agenda commands. (line 376) -* v: Using column view. (line 55) -* v [: Agenda commands. (line 127) -* v A: Agenda commands. (line 134) -* v a: Agenda commands. (line 131) -* v c: Agenda commands. (line 149) -* v d: Agenda commands. (line 75) -* v E: Agenda commands. (line 157) -* v L: Agenda commands. (line 119) -* v l: Agenda commands. (line 116) -* v m: Agenda commands. (line 80) -* v R: Agenda commands. (line 138) -* v SPC: Agenda commands. (line 82) -* v t: Agenda commands. (line 79) -* v w: Agenda commands. (line 78) -* v y: Agenda commands. (line 81) -* w: Agenda commands. (line 78) -* x: Agenda commands. (line 526) -* X: Agenda commands. (line 344) -* z: Agenda commands. (line 299) +* T: Agenda commands. (line 267) +* t: Agenda commands. (line 232) +* TAB: Built-in table editor. + (line 62) +* U: Agenda commands. (line 372) +* u: Agenda commands. (line 369) +* v: Using column view. (line 56) +* v [: Agenda commands. (line 126) +* v A: Agenda commands. (line 133) +* v a: Agenda commands. (line 130) +* v c: Agenda commands. (line 148) +* v d: Agenda commands. (line 74) +* v E: Agenda commands. (line 156) +* v L: Agenda commands. (line 118) +* v l: Agenda commands. (line 115) +* v m: Agenda commands. (line 79) +* v R: Agenda commands. (line 137) +* v SPC: Agenda commands. (line 81) +* v t: Agenda commands. (line 78) +* v w: Agenda commands. (line 77) +* v y: Agenda commands. (line 80) +* w: Agenda commands. (line 77) +* x: Agenda commands. (line 519) +* X: Agenda commands. (line 337) +* z: Agenda commands. (line 292) * {: Filtering/limiting agenda items. - (line 66) -* | <1>: Agenda commands. (line 228) + (line 57) +* | <1>: Agenda commands. (line 221) * |: Filtering/limiting agenda items. - (line 109) + (line 112) * }: Filtering/limiting agenda items. - (line 66) + (line 57) * ~: Filtering/limiting agenda items. - (line 151) + (line 154)  File: org, Node: Command and Function Index, Next: Variable Index, Prev: Key Index, Up: Top @@ -20576,134 +20486,133 @@ Command and function index * next-error: Sparse trees. (line 29) * org-agenda <1>: Conventions. (line 35) * org-agenda: Activation. (line 6) -* org-agenda-add-note: Agenda commands. (line 299) -* org-agenda-archive: Agenda commands. (line 269) +* org-agenda-add-note: Agenda commands. (line 292) +* org-agenda-archive: Agenda commands. (line 262) * org-agenda-archive-default-with-confirmation: Agenda commands. - (line 257) -* org-agenda-archive-to-archive-sibling: Agenda commands. (line 265) -* org-agenda-archives-mode: Agenda commands. (line 131) -* org-agenda-archives-mode 'files: Agenda commands. (line 134) -* org-agenda-bulk-action: Agenda commands. (line 391) -* org-agenda-bulk-mark: Agenda commands. (line 371) -* org-agenda-bulk-mark-all: Agenda commands. (line 373) -* org-agenda-bulk-mark-regexp: Agenda commands. (line 388) -* org-agenda-bulk-remove-all-marks: Agenda commands. (line 379) -* org-agenda-bulk-toggle: Agenda commands. (line 382) -* org-agenda-bulk-toggle-all: Agenda commands. (line 385) -* org-agenda-bulk-unmark: Agenda commands. (line 376) -* org-agenda-capture: Agenda commands. (line 350) -* org-agenda-clock-cancel: Agenda commands. (line 344) -* org-agenda-clock-goto: Agenda commands. (line 109) -* org-agenda-clock-in: Agenda commands. (line 337) -* org-agenda-clock-out: Agenda commands. (line 341) -* org-agenda-clockreport-mode: Agenda commands. (line 138) + (line 250) +* org-agenda-archive-to-archive-sibling: Agenda commands. (line 258) +* org-agenda-archives-mode: Agenda commands. (line 130) +* org-agenda-archives-mode 'files: Agenda commands. (line 133) +* org-agenda-bulk-action: Agenda commands. (line 384) +* org-agenda-bulk-mark: Agenda commands. (line 364) +* org-agenda-bulk-mark-all: Agenda commands. (line 366) +* org-agenda-bulk-mark-regexp: Agenda commands. (line 381) +* org-agenda-bulk-remove-all-marks: Agenda commands. (line 372) +* org-agenda-bulk-toggle: Agenda commands. (line 375) +* org-agenda-bulk-toggle-all: Agenda commands. (line 378) +* org-agenda-bulk-unmark: Agenda commands. (line 369) +* org-agenda-capture: Agenda commands. (line 343) +* org-agenda-clock-cancel: Agenda commands. (line 337) +* org-agenda-clock-goto: Agenda commands. (line 108) +* org-agenda-clock-in: Agenda commands. (line 330) +* org-agenda-clock-out: Agenda commands. (line 334) +* org-agenda-clockreport-mode: Agenda commands. (line 137) * org-agenda-columns <1>: Agenda column view. (line 11) -* org-agenda-columns: Agenda commands. (line 183) -* org-agenda-convert-date: Agenda commands. (line 494) -* org-agenda-date-prompt: Agenda commands. (line 332) -* org-agenda-day-view: Agenda commands. (line 75) -* org-agenda-deadline: Agenda commands. (line 311) -* org-agenda-diary-entry: Agenda commands. (line 466) -* org-agenda-do-date-earlier: Agenda commands. (line 328) -* org-agenda-do-date-later: Agenda commands. (line 314) -* org-agenda-drag-line-backward: Agenda commands. (line 360) -* org-agenda-drag-line-forward: Agenda commands. (line 364) -* org-agenda-earlier: Agenda commands. (line 100) -* org-agenda-entry-text-mode: Agenda commands. (line 157) -* org-agenda-exit: Agenda commands. (line 526) +* org-agenda-columns: Agenda commands. (line 182) +* org-agenda-convert-date: Agenda commands. (line 487) +* org-agenda-date-prompt: Agenda commands. (line 325) +* org-agenda-day-view: Agenda commands. (line 74) +* org-agenda-deadline: Agenda commands. (line 304) +* org-agenda-diary-entry: Agenda commands. (line 459) +* org-agenda-do-date-earlier: Agenda commands. (line 321) +* org-agenda-do-date-later: Agenda commands. (line 307) +* org-agenda-drag-line-backward: Agenda commands. (line 353) +* org-agenda-drag-line-forward: Agenda commands. (line 357) +* org-agenda-earlier: Agenda commands. (line 99) +* org-agenda-entry-text-mode: Agenda commands. (line 156) +* org-agenda-exit: Agenda commands. (line 519) * org-agenda-file-to-front: Agenda files. (line 15) -* org-agenda-filter-by-category <1>: Agenda commands. (line 211) +* org-agenda-filter-by-category <1>: Agenda commands. (line 207) * org-agenda-filter-by-category: Filtering/limiting agenda items. - (line 76) + (line 67) +* org-agenda-filter-by-effort <1>: Agenda commands. (line 218) * org-agenda-filter-by-effort: Filtering/limiting agenda items. - (line 95) -* org-agenda-filter-by-regexp <1>: Agenda commands. (line 219) + (line 91) +* org-agenda-filter-by-regexp <1>: Agenda commands. (line 215) * org-agenda-filter-by-regexp: Filtering/limiting agenda items. - (line 86) -* org-agenda-filter-by-tag <1>: Agenda commands. (line 204) + (line 81) +* org-agenda-filter-by-tag <1>: Agenda commands. (line 203) * org-agenda-filter-by-tag: Filtering/limiting agenda items. (line 17) -* org-agenda-filter-by-tag-refine <1>: Agenda commands. (line 208) -* org-agenda-filter-by-tag-refine: Filtering/limiting agenda items. - (line 59) -* org-agenda-filter-by-top-headline <1>: Agenda commands. (line 215) +* org-agenda-filter-by-top-headline <1>: Agenda commands. (line 211) * org-agenda-filter-by-top-headline: Filtering/limiting agenda items. - (line 82) -* org-agenda-filter-remove-all <1>: Agenda commands. (line 228) + (line 77) +* org-agenda-filter-remove-all <1>: Agenda commands. (line 221) * org-agenda-filter-remove-all: Filtering/limiting agenda items. - (line 109) -* org-agenda-follow-mode: Agenda commands. (line 46) -* org-agenda-fortnight-view: Agenda commands. (line 79) -* org-agenda-goto: Agenda commands. (line 40) -* org-agenda-goto-calendar: Agenda commands. (line 461) -* org-agenda-goto-date: Agenda commands. (line 106) -* org-agenda-goto-today: Agenda commands. (line 103) -* org-agenda-holidays: Agenda commands. (line 498) -* org-agenda-kill: Agenda commands. (line 248) -* org-agenda-later: Agenda commands. (line 94) + (line 112) +* org-agenda-follow-mode: Agenda commands. (line 45) +* org-agenda-fortnight-view: Agenda commands. (line 78) +* org-agenda-goto: Agenda commands. (line 39) +* org-agenda-goto-calendar: Agenda commands. (line 454) +* org-agenda-goto-date: Agenda commands. (line 105) +* org-agenda-goto-today: Agenda commands. (line 102) +* org-agenda-holidays: Agenda commands. (line 491) +* org-agenda-kill: Agenda commands. (line 241) +* org-agenda-later: Agenda commands. (line 93) * org-agenda-limit-interactively: Filtering/limiting agenda items. - (line 151) + (line 154) * org-agenda-list: Weekly/daily agenda. (line 9) * org-agenda-list-stuck-projects: Stuck projects. (line 13) -* org-agenda-log-mode: Agenda commands. (line 116) -* org-agenda-manipulate-query-add: Agenda commands. (line 127) -* org-agenda-month-view: Agenda commands. (line 80) +* org-agenda-log-mode: Agenda commands. (line 115) +* org-agenda-manipulate-query-add: Agenda commands. (line 126) +* org-agenda-month-view: Agenda commands. (line 79) * org-agenda-next-item: Agenda commands. (line 23) * org-agenda-next-line: Agenda commands. (line 19) -* org-agenda-open-link: Agenda commands. (line 62) -* org-agenda-phases-of-moon: Agenda commands. (line 485) +* org-agenda-open-link: Agenda commands. (line 61) +* org-agenda-phases-of-moon: Agenda commands. (line 478) * org-agenda-previous-item: Agenda commands. (line 26) * org-agenda-previous-line: Agenda commands. (line 20) -* org-agenda-priority-down: Agenda commands. (line 296) -* org-agenda-priority-up: Agenda commands. (line 291) -* org-agenda-quit: Agenda commands. (line 525) -* org-agenda-recenter: Agenda commands. (line 37) -* org-agenda-redo: Agenda commands. (line 169) -* org-agenda-refile: Agenda commands. (line 254) -* org-agenda-remove-restriction-lock <1>: Agenda commands. (line 194) +* org-agenda-priority-down: Agenda commands. (line 289) +* org-agenda-priority-up: Agenda commands. (line 284) +* org-agenda-quit: Agenda commands. (line 518) +* org-agenda-recenter: Agenda commands. (line 36) +* org-agenda-redo: Agenda commands. (line 168) +* org-agenda-refile: Agenda commands. (line 247) +* org-agenda-remove-restriction-lock <1>: Agenda commands. (line 193) * org-agenda-remove-restriction-lock: Agenda files. (line 49) -* org-agenda-reset-view: Agenda commands. (line 82) -* org-agenda-schedule: Agenda commands. (line 307) +* org-agenda-reset-view: Agenda commands. (line 81) +* org-agenda-schedule: Agenda commands. (line 300) * org-agenda-set-restriction-lock: Agenda files. (line 42) -* org-agenda-set-tags: Agenda commands. (line 279) +* org-agenda-set-tags: Agenda commands. (line 272) * org-agenda-show-and-scroll-up: Agenda commands. (line 34) -* org-agenda-show-priority: Agenda commands. (line 288) -* org-agenda-show-tags: Agenda commands. (line 274) -* org-agenda-sunrise-sunset: Agenda commands. (line 489) -* org-agenda-switch-to: Agenda commands. (line 43) -* org-agenda-todo: Agenda commands. (line 239) -* org-agenda-todo-nextset: Agenda commands. (line 243) -* org-agenda-todo-previousset: Agenda commands. (line 246) -* org-agenda-toggle-archive-tag: Agenda commands. (line 262) -* org-agenda-toggle-diary: Agenda commands. (line 112) -* org-agenda-toggle-time-grid: Agenda commands. (line 165) -* org-agenda-tree-to-indirect-buffer: Agenda commands. (line 53) -* org-agenda-undo: Agenda commands. (line 235) -* org-agenda-week-view: Agenda commands. (line 78) +* org-agenda-show-priority: Agenda commands. (line 281) +* org-agenda-show-tags: Agenda commands. (line 267) +* org-agenda-sunrise-sunset: Agenda commands. (line 482) +* org-agenda-switch-to: Agenda commands. (line 42) +* org-agenda-todo: Agenda commands. (line 232) +* org-agenda-todo-nextset: Agenda commands. (line 236) +* org-agenda-todo-previousset: Agenda commands. (line 239) +* org-agenda-toggle-archive-tag: Agenda commands. (line 255) +* org-agenda-toggle-diary: Agenda commands. (line 111) +* org-agenda-toggle-time-grid: Agenda commands. (line 164) +* org-agenda-tree-to-indirect-buffer: Agenda commands. (line 52) +* org-agenda-undo: Agenda commands. (line 228) +* org-agenda-week-view: Agenda commands. (line 77) * org-agenda-write <1>: Exporting agenda views. (line 12) -* org-agenda-write: Agenda commands. (line 511) -* org-agenda-year-view: Agenda commands. (line 81) +* org-agenda-write: Agenda commands. (line 504) +* org-agenda-year-view: Agenda commands. (line 80) * org-archive-subtree: Moving subtrees. (line 9) * org-archive-subtree-default: Archiving. (line 11) -* org-archive-to-archive-sibling: Internal archiving. (line 49) +* org-archive-to-archive-sibling: Internal archiving. (line 50) * org-ascii-export-as-ascii: ASCII/Latin-1/UTF-8 export. (line 25) * org-ascii-export-to-ascii: ASCII/Latin-1/UTF-8 export. (line 21) -* org-attach <1>: Agenda commands. (line 304) +* org-attach <1>: Agenda commands. (line 297) * org-attach: Attachments. (line 26) * org-attach-attach: Attachments. (line 31) -* org-attach-delete-all: Attachments. (line 66) -* org-attach-delete-one: Attachments. (line 63) -* org-attach-new: Attachments. (line 41) -* org-attach-open: Attachments. (line 48) -* org-attach-open-in-emacs: Attachments. (line 54) -* org-attach-reveal: Attachments. (line 57) -* org-attach-reveal-in-emacs: Attachments. (line 60) -* org-attach-set-directory: Attachments. (line 70) -* org-attach-set-inherit: Attachments. (line 75) -* org-attach-sync: Attachments. (line 44) +* org-attach-delete-all: Attachments. (line 69) +* org-attach-delete-one: Attachments. (line 66) +* org-attach-new: Attachments. (line 44) +* org-attach-open: Attachments. (line 51) +* org-attach-open-in-emacs: Attachments. (line 57) +* org-attach-reveal: Attachments. (line 60) +* org-attach-reveal-in-emacs: Attachments. (line 63) +* org-attach-set-directory: Attachments. (line 73) +* org-attach-set-inherit: Attachments. (line 78) +* org-attach-sync: Attachments. (line 47) +* org-attach-url: Attachments. (line 41) * org-backward-same-level: Motion. (line 15) * org-beamer-export-as-latex: Beamer export commands. (line 9) @@ -20713,8 +20622,8 @@ Command and function index (line 12) * org-beamer-select-environment: Editing support. (line 11) * org-buffer-property-keys: Using the property API. - (line 35) -* org-calendar-goto-agenda: Agenda commands. (line 462) + (line 34) +* org-calendar-goto-agenda: Agenda commands. (line 455) * org-capture <1>: Using capture. (line 6) * org-capture <2>: Conventions. (line 35) * org-capture: Activation. (line 6) @@ -20722,11 +20631,11 @@ Command and function index * org-capture-kill: Using capture. (line 31) * org-capture-refile: Using capture. (line 22) * org-check-after-date: Inserting deadline/schedule. - (line 33) + (line 31) * org-check-before-date: Inserting deadline/schedule. - (line 30) + (line 28) * org-check-deadlines: Inserting deadline/schedule. - (line 23) + (line 21) * org-clock-cancel: Clocking commands. (line 71) * org-clock-display: Clocking commands. (line 80) * org-clock-goto: Clocking commands. (line 75) @@ -20738,28 +20647,28 @@ Command and function index * org-clock-report: The clock table. (line 10) * org-clock-timestamps-up/down: Clocking commands. (line 56) * org-clocktable-try-shift: The clock table. (line 24) -* org-clone-subtree-with-time-shift: Structure editing. (line 102) +* org-clone-subtree-with-time-shift: Structure editing. (line 95) * org-columns: Using column view. (line 9) -* org-columns-delete: Using column view. (line 75) -* org-columns-edit-allowed: Using column view. (line 59) -* org-columns-edit-value: Using column view. (line 46) -* org-columns-narrow: Using column view. (line 70) -* org-columns-new: Using column view. (line 72) -* org-columns-next-allowed-value: Using column view. (line 42) -* org-columns-previous-allowed-value: Using column view. (line 42) -* org-columns-quit: Using column view. (line 26) -* org-columns-redo: Using column view. (line 19) -* org-columns-set-tags-or-toggle: Using column view. (line 52) -* org-columns-show-value: Using column view. (line 55) -* org-columns-widen: Using column view. (line 70) +* org-columns-delete: Using column view. (line 76) +* org-columns-edit-allowed: Using column view. (line 60) +* org-columns-edit-value: Using column view. (line 47) +* org-columns-narrow: Using column view. (line 71) +* org-columns-new: Using column view. (line 73) +* org-columns-next-allowed-value: Using column view. (line 43) +* org-columns-previous-allowed-value: Using column view. (line 43) +* org-columns-quit: Using column view. (line 27) +* org-columns-redo: Using column view. (line 20) +* org-columns-set-tags-or-toggle: Using column view. (line 53) +* org-columns-show-value: Using column view. (line 56) +* org-columns-widen: Using column view. (line 71) * org-compute-property-at-point: Property syntax. (line 110) * org-copy: Refile and copy. (line 12) -* org-copy-subtree: Structure editing. (line 80) +* org-copy-subtree: Structure editing. (line 73) * org-copy-visible: Global and local cycling. (line 61) -* org-cut-subtree: Structure editing. (line 76) +* org-cut-subtree: Structure editing. (line 69) * org-cycle <1>: Plain lists. (line 68) -* org-cycle <2>: Structure editing. (line 42) +* org-cycle <2>: Structure editing. (line 35) * org-cycle: Global and local cycling. (line 10) * org-cycle-agenda-files: Agenda files. (line 22) @@ -20767,42 +20676,43 @@ Command and function index * org-dblock-update <1>: Dynamic blocks. (line 21) * org-dblock-update <2>: The clock table. (line 16) * org-dblock-update: Capturing column view. - (line 51) + (line 54) * org-deadline: Inserting deadline/schedule. (line 9) * org-delete-property: Property syntax. (line 104) * org-delete-property-globally: Property syntax. (line 107) * org-demote: Using the mapping API. - (line 83) -* org-demote-subtree: Structure editing. (line 57) -* org-do-demote: Structure editing. (line 51) -* org-do-promote: Structure editing. (line 48) -* org-edit-special: Cooperation. (line 61) + (line 78) +* org-demote-subtree: Structure editing. (line 50) +* org-do-demote: Structure editing. (line 44) +* org-do-promote: Structure editing. (line 41) +* org-edit-special: Cooperation. (line 48) +* org-entities-help: Special symbols. (line 16) * org-entry-add-to-multivalued-property: Using the property API. - (line 52) + (line 51) * org-entry-delete: Using the property API. - (line 29) + (line 28) * org-entry-get: Using the property API. - (line 20) + (line 19) * org-entry-get-multivalued-property: Using the property API. - (line 47) + (line 46) * org-entry-member-in-multivalued-property: Using the property API. - (line 64) + (line 63) * org-entry-properties: Using the property API. - (line 10) + (line 9) * org-entry-put: Using the property API. - (line 32) + (line 31) * org-entry-put-multivalued-property: Using the property API. - (line 42) + (line 41) * org-entry-remove-from-multivalued-property: Using the property API. - (line 58) + (line 57) * org-evaluate-time-range <1>: Clocking commands. (line 51) * org-evaluate-time-range: Creating timestamps. (line 59) * org-export-dispatch: The export dispatcher. - (line 11) + (line 10) * org-feed-goto-inbox: RSS feeds. (line 27) * org-feed-update-all: RSS feeds. (line 23) -* org-force-cycle-archived: Internal archiving. (line 46) +* org-force-cycle-archived: Internal archiving. (line 47) * org-forward-same-level: Motion. (line 12) * org-global-cycle: Global and local cycling. (line 22) @@ -20816,18 +20726,17 @@ Command and function index * org-icalendar-export-agenda-files: iCalendar export. (line 34) * org-icalendar-export-to-ics: iCalendar export. (line 32) * org-insert-columns-dblock: Capturing column view. - (line 49) + (line 52) * org-insert-heading <1>: Timers. (line 40) -* org-insert-heading <2>: Plain lists. (line 79) -* org-insert-heading: Structure editing. (line 6) -* org-insert-heading-respect-content: Structure editing. (line 28) +* org-insert-heading: Plain lists. (line 79) +* org-insert-heading-respect-content: Structure editing. (line 23) * org-insert-link: Handling links. (line 65) * org-insert-property-drawer: Using the property API. (line 18) -* org-insert-todo-heading <1>: Checkboxes. (line 73) -* org-insert-todo-heading <2>: TODO basics. (line 58) -* org-insert-todo-heading: Structure editing. (line 33) -* org-insert-todo-heading-respect-content: Structure editing. (line 37) +* org-insert-todo-heading <1>: Checkboxes. (line 74) +* org-insert-todo-heading <2>: TODO basics. (line 57) +* org-insert-todo-heading: Structure editing. (line 26) +* org-insert-todo-heading-respect-content: Structure editing. (line 30) * org-iswitchb: Activation. (line 6) * org-latex-export-as-latex: LaTeX export commands. (line 9) @@ -20839,36 +20748,39 @@ Command and function index * org-lookup-first: Lookup functions. (line 8) * org-lookup-last: Lookup functions. (line 18) * org-map-entries: Using the mapping API. - (line 13) -* org-mark-element: Structure editing. (line 66) + (line 12) +* org-mark-element: Structure editing. (line 59) * org-mark-ring-goto: Handling links. (line 146) * org-mark-ring-push: Handling links. (line 142) -* org-mark-subtree: Structure editing. (line 72) +* org-mark-subtree: Structure editing. (line 65) * org-match-sparse-tree <1>: Property searches. (line 10) * org-match-sparse-tree: Tag searches. (line 9) * org-md-export-as-markdown: Markdown export. (line 19) * org-md-export-to-markdown: Markdown export. (line 16) -* org-move-subtree-down: Structure editing. (line 63) -* org-move-subtree-up: Structure editing. (line 60) -* org-narrow-to-block: Structure editing. (line 129) -* org-narrow-to-subtree: Structure editing. (line 126) +* org-meta-return: Structure editing. (line 6) +* org-move-subtree-down: Structure editing. (line 56) +* org-move-subtree-up: Structure editing. (line 53) +* org-narrow-to-block: Structure editing. (line 122) +* org-narrow-to-subtree: Structure editing. (line 119) * org-next-link: Handling links. (line 152) +* org-next-visible-heading: Motion. (line 8) * org-occur: Sparse trees. (line 17) * org-odt-export-to-odt: ODT export commands. (line 6) * org-open-at-point <1>: Creating timestamps. (line 38) * org-open-at-point: Handling links. (line 101) * org-org-export-as-org: Org export. (line 16) * org-org-export-to-org: Org export. (line 13) -* org-paste-subtree: Structure editing. (line 84) +* org-paste-subtree: Structure editing. (line 77) * org-previous-link: Handling links. (line 152) +* org-previous-visible-heading: Motion. (line 9) * org-priority <1>: Using the mapping API. - (line 71) + (line 66) * org-priority: Priorities. (line 24) -* org-priority-down: Priorities. (line 29) -* org-priority-up: Priorities. (line 29) +* org-priority-down: Priorities. (line 28) +* org-priority-up: Priorities. (line 28) * org-promote: Using the mapping API. - (line 80) -* org-promote-subtree: Structure editing. (line 54) + (line 75) +* org-promote-subtree: Structure editing. (line 47) * org-property-action: Property syntax. (line 92) * org-property-next-allowed-value: Property syntax. (line 100) * org-property-previous-allowed-value: Property syntax. (line 100) @@ -20881,24 +20793,24 @@ Command and function index * org-publish-current-project: Triggering publication. (line 10) * org-refile <1>: Refile and copy. (line 14) -* org-refile: Structure editing. (line 110) +* org-refile: Structure editing. (line 103) * org-refile-cache-clear: Refile and copy. (line 47) * org-refile-goto-last-stored: Refile and copy. (line 36) * org-remove-file: Agenda files. (line 19) * org-reveal: Global and local cycling. (line 38) -* org-save-all-org-buffers: Agenda commands. (line 179) +* org-save-all-org-buffers: Agenda commands. (line 178) * org-schedule: Inserting deadline/schedule. - (line 17) + (line 16) * org-search-view: Search view. (line 9) * org-set-effort: Effort estimates. (line 14) * org-set-property: Property syntax. (line 83) -* org-set-startup-visibility <1>: Initial visibility. (line 25) +* org-set-startup-visibility <1>: Initial visibility. (line 21) * org-set-startup-visibility: Global and local cycling. (line 33) * org-set-tags-command: Setting tags. (line 10) -* org-show-todo-tree: TODO basics. (line 39) -* org-sort: Structure editing. (line 114) +* org-show-todo-tree: TODO basics. (line 38) +* org-sort: Structure editing. (line 107) * org-sparse-tree: Sparse trees. (line 15) * org-speedbar-set-agenda-restriction: Agenda files. (line 57) * org-store-agenda-views: Exporting agenda views. @@ -20917,7 +20829,7 @@ Command and function index (line 132) * org-table-create-or-convert-from-region: Built-in table editor. (line 41) -* org-table-create-with-table.el: Cooperation. (line 63) +* org-table-create-with-table.el: Cooperation. (line 50) * org-table-cut-region: Built-in table editor. (line 136) * org-table-delete-column: Built-in table editor. @@ -21012,7 +20924,6 @@ Command and function index (line 6) * org-time-stamp: Creating timestamps. (line 10) * org-time-stamp-inactive: Creating timestamps. (line 15) -* org-timeline: Timeline. (line 10) * org-timer: Timers. (line 31) * org-timer-item: Timers. (line 35) * org-timer-pause-or-continue: Timers. (line 44) @@ -21025,38 +20936,36 @@ Command and function index * org-timestamp-up-day: Creating timestamps. (line 42) * org-timestamp-up/down: Clocking commands. (line 60) * org-todo <1>: Using the mapping API. - (line 67) + (line 62) * org-todo <2>: Clocking commands. (line 67) * org-todo: TODO basics. (line 13) * org-todo-list <1>: Global TODO list. (line 9) -* org-todo-list: TODO basics. (line 50) -* org-toggle-archive-tag: Internal archiving. (line 36) +* org-todo-list: TODO basics. (line 49) +* org-toggle-archive-tag: Internal archiving. (line 37) * org-toggle-checkbox: Checkboxes. (line 52) -* org-toggle-heading: Structure editing. (line 135) +* org-toggle-heading: Structure editing. (line 128) * org-toggle-inline-images: Handling links. (line 133) -* org-toggle-ordered-property <1>: Checkboxes. (line 76) +* org-toggle-ordered-property <1>: Checkboxes. (line 77) * org-toggle-ordered-property: TODO dependencies. (line 37) * org-toggle-tag: Using the mapping API. - (line 75) + (line 70) * org-toggle-time-stamp-overlays: Custom time format. (line 12) * org-tree-to-indirect-buffer: Global and local cycling. (line 55) * org-update-all-dblocks: Capturing column view. - (line 55) -* org-update-statistics-cookies: Checkboxes. (line 84) -* org-yank: Structure editing. (line 90) -* outline-next-visible-heading: Motion. (line 8) -* outline-previous-visible-heading: Motion. (line 9) -* outline-up-heading: Motion. (line 18) -* pcomplete: Property syntax. (line 80) -* previous-error: Sparse trees. (line 32) -* show-all: Global and local cycling. + (line 58) +* org-update-statistics-cookies: Checkboxes. (line 85) +* org-yank: Structure editing. (line 83) +* outline-show-all: Global and local cycling. (line 35) -* show-branches: Global and local cycling. +* outline-show-branches: Global and local cycling. (line 47) -* show-children: Global and local cycling. +* outline-show-children: Global and local cycling. (line 51) -* widen: Structure editing. (line 132) +* outline-up-heading: Motion. (line 18) +* pcomplete: Property syntax. (line 80) +* previous-error: Sparse trees. (line 32) +* widen: Structure editing. (line 125)  File: org, Node: Variable Index, Prev: Command and Function Index, Up: Top @@ -21065,99 +20974,98 @@ Variable index ************** This is not a complete index of variables and faces, only the ones that -are mentioned in the manual. For a more complete list, use `M-x -org-customize ' and then click yourself through the tree. +are mentioned in the manual. For a complete list, use `M-x +org-customize '. [index] * Menu: * cdlatex-simplify-sub-super-scripts: CDLaTeX mode. (line 33) -* constants-unit-system <1>: In-buffer settings. (line 147) +* constants-unit-system <1>: In-buffer settings. (line 142) * constants-unit-system: References. (line 117) * htmlize-output-type: Exporting agenda views. (line 20) -* LaTeX-verbatim-environments: A LaTeX example. (line 21) -* org-adapt-indentation: Clean view. (line 46) +* LaTeX-verbatim-environments: A LaTeX example. (line 20) +* org-adapt-indentation: Clean view. (line 52) * org-agenda-add-entry-text-maxlines: Exporting agenda views. (line 20) -* org-agenda-bulk-custom-functions: Agenda commands. (line 371) -* org-agenda-category-filter-preset <1>: Agenda commands. (line 212) +* org-agenda-bulk-custom-functions: Agenda commands. (line 364) * org-agenda-category-filter-preset: Filtering/limiting agenda items. - (line 77) -* org-agenda-clock-consistency-checks: Agenda commands. (line 152) + (line 68) +* org-agenda-clock-consistency-checks: Agenda commands. (line 151) * org-agenda-columns-add-appointments-to-effort-sum: Effort estimates. (line 41) -* org-agenda-confirm-kill: Agenda commands. (line 251) +* org-agenda-confirm-kill: Agenda commands. (line 244) * org-agenda-custom-commands <1>: Extracting agenda information. (line 6) * org-agenda-custom-commands <2>: Setting options. (line 6) * org-agenda-custom-commands <3>: Storing searches. (line 9) * org-agenda-custom-commands: Sparse trees. (line 37) * org-agenda-custom-commands-contexts: Setting options. (line 61) -* org-agenda-diary-file: Agenda commands. (line 469) +* org-agenda-diary-file: Agenda commands. (line 462) * org-agenda-dim-blocked-tasks <1>: Speeding up your agendas. - (line 16) + (line 15) * org-agenda-dim-blocked-tasks: TODO dependencies. (line 47) * org-agenda-effort-filter-preset: Filtering/limiting agenda items. - (line 96) -* org-agenda-entry-text-maxlines: Agenda commands. (line 160) + (line 92) +* org-agenda-entry-text-maxlines: Agenda commands. (line 159) * org-agenda-exporter-settings <1>: Exporting agenda views. (line 13) -* org-agenda-exporter-settings: Agenda commands. (line 512) +* org-agenda-exporter-settings: Agenda commands. (line 505) * org-agenda-files <1>: iCalendar export. (line 37) * org-agenda-files <2>: Sorting agenda items. (line 8) * org-agenda-files: Agenda files. (line 6) * org-agenda-inhibit-startup <1>: Speeding up your agendas. - (line 19) + (line 18) * org-agenda-inhibit-startup: Initial visibility. (line 6) -* org-agenda-log-mode-items: Agenda commands. (line 119) +* org-agenda-log-mode-items: Agenda commands. (line 118) * org-agenda-max-effort: Filtering/limiting agenda items. - (line 115) + (line 118) * org-agenda-max-entries: Filtering/limiting agenda items. - (line 115) + (line 118) * org-agenda-max-tags: Filtering/limiting agenda items. - (line 115) + (line 118) * org-agenda-max-todos: Filtering/limiting agenda items. - (line 115) + (line 118) * org-agenda-ndays: Weekly/daily agenda. (line 15) * org-agenda-overriding-header: Special agenda views. - (line 45) + (line 38) * org-agenda-prefix-format: Presentation and sorting. (line 6) -* org-agenda-regexp-filter-preset <1>: Agenda commands. (line 220) * org-agenda-regexp-filter-preset: Filtering/limiting agenda items. - (line 87) -* org-agenda-restore-windows-after-quit: Agenda views. (line 40) + (line 82) +* org-agenda-restore-windows-after-quit: Agenda views. (line 42) * org-agenda-show-inherited-tags <1>: Speeding up your agendas. - (line 22) -* org-agenda-show-inherited-tags: Agenda commands. (line 277) -* org-agenda-skip-archived-trees: Internal archiving. (line 21) + (line 21) +* org-agenda-show-inherited-tags: Agenda commands. (line 270) +* org-agenda-skip-archived-trees <1>: Agenda views. (line 37) +* org-agenda-skip-archived-trees: Internal archiving. (line 22) +* org-agenda-skip-comment-trees: Agenda views. (line 37) * org-agenda-skip-deadline-prewarning-if-scheduled: Deadlines and scheduling. - (line 12) + (line 14) * org-agenda-skip-function <1>: Using the mapping API. - (line 52) + (line 49) * org-agenda-skip-function: Special agenda views. (line 6) * org-agenda-skip-function-global: Special agenda views. (line 6) * org-agenda-skip-scheduled-delay-if-deadline: Deadlines and scheduling. - (line 40) + (line 42) * org-agenda-skip-scheduled-if-deadline-is-shown: Repeated tasks. - (line 65) + (line 72) * org-agenda-skip-scheduled-if-done: Deadlines and scheduling. - (line 32) + (line 34) * org-agenda-sorting-strategy: Sorting agenda items. (line 27) -* org-agenda-span <1>: Agenda commands. (line 83) +* org-agenda-span <1>: Agenda commands. (line 82) * org-agenda-span: Weekly/daily agenda. (line 15) * org-agenda-start-day: Weekly/daily agenda. (line 15) * org-agenda-start-on-weekday: Weekly/daily agenda. (line 15) -* org-agenda-start-with-clockreport-mode: Agenda commands. (line 141) -* org-agenda-start-with-entry-text-mode: Agenda commands. (line 160) -* org-agenda-start-with-follow-mode: Agenda commands. (line 49) -* org-agenda-sticky: Agenda dispatcher. (line 53) -* org-agenda-tag-filter-preset <1>: Agenda commands. (line 205) +* org-agenda-start-with-clockreport-mode: Agenda commands. (line 140) +* org-agenda-start-with-entry-text-mode: Agenda commands. (line 159) +* org-agenda-start-with-follow-mode: Agenda commands. (line 48) +* org-agenda-sticky: Agenda dispatcher. (line 50) * org-agenda-tag-filter-preset: Filtering/limiting agenda items. (line 18) * org-agenda-tags-column: Presentation and sorting. @@ -21165,8 +21073,8 @@ org-customize ' and then click yourself through the tree. * org-agenda-tags-todo-honor-ignore-options: Matching tags and properties. (line 20) * org-agenda-text-search-extra-files <1>: Search view. (line 24) -* org-agenda-text-search-extra-files: Agenda dispatcher. (line 32) -* org-agenda-time-grid <1>: Agenda commands. (line 168) +* org-agenda-text-search-extra-files: Agenda dispatcher. (line 29) +* org-agenda-time-grid <1>: Agenda commands. (line 167) * org-agenda-time-grid: Time-of-day specifications. (line 41) * org-agenda-todo-ignore-deadlines: Global TODO list. (line 38) @@ -21176,15 +21084,15 @@ org-customize ' and then click yourself through the tree. * org-agenda-todo-list-sublevels <1>: Global TODO list. (line 47) * org-agenda-todo-list-sublevels: Breaking down tasks. (line 6) * org-agenda-use-tag-inheritance <1>: Speeding up your agendas. - (line 22) + (line 21) * org-agenda-use-tag-inheritance: Tag inheritance. (line 32) -* org-agenda-use-time-grid <1>: Agenda commands. (line 168) +* org-agenda-use-time-grid <1>: Agenda commands. (line 167) * org-agenda-use-time-grid: Time-of-day specifications. (line 41) -* org-agenda-window-setup: Agenda views. (line 40) -* org-archive-default-command <1>: Agenda commands. (line 260) +* org-agenda-window-setup: Agenda views. (line 42) +* org-archive-default-command <1>: Agenda commands. (line 253) * org-archive-default-command: Archiving. (line 12) -* org-archive-location <1>: In-buffer settings. (line 16) +* org-archive-location <1>: In-buffer settings. (line 14) * org-archive-location: Moving subtrees. (line 10) * org-archive-save-context-info: Moving subtrees. (line 41) * org-ascii-links-to-notes: ASCII/Latin-1/UTF-8 export. @@ -21194,7 +21102,7 @@ org-customize ' and then click yourself through the tree. * org-attach-directory: Attachments. (line 6) * org-attach-method: Attachments. (line 32) * org-babel-default-header-args <1>: Header arguments in Org mode properties. - (line 34) + (line 31) * org-babel-default-header-args: System-wide header arguments. (line 6) * org-beamer-environments-default: Sectioning Frames and Blocks in Beamer. @@ -21212,7 +21120,7 @@ org-customize ' and then click yourself through the tree. * org-capture-bookmark: Using capture. (line 50) * org-capture-templates-contexts: Templates in contexts. (line 6) -* org-capture-use-agenda-date: Agenda commands. (line 355) +* org-capture-use-agenda-date: Agenda commands. (line 348) * org-catch-invisible-edits: Catching invisible edits. (line 6) * org-checkbox-hierarchical-statistics: Checkboxes. (line 30) @@ -21221,22 +21129,23 @@ org-customize ' and then click yourself through the tree. * org-clock-idle-time: Resolving idle time. (line 14) * org-clock-into-drawer: Clocking commands. (line 7) * org-clock-modeline-total: Clocking commands. (line 20) -* org-clock-report-include-clocking-task: Agenda commands. (line 141) +* org-clock-report-include-clocking-task: Agenda commands. (line 140) * org-clock-x11idle-program-name: Resolving idle time. (line 9) * org-clocktable-defaults: The clock table. (line 38) * org-closed-keep-when-no-todo: Closing items. (line 11) -* org-coderef-label-format: Literal examples. (line 61) +* org-coderef-label-format: Literal examples. (line 75) * org-columns-default-format <1>: Agenda column view. (line 18) -* org-columns-default-format <2>: Agenda commands. (line 186) +* org-columns-default-format <2>: Agenda commands. (line 185) * org-columns-default-format <3>: Effort estimates. (line 31) * org-columns-default-format: Using column view. (line 10) -* org-columns-skip-archived-trees: Internal archiving. (line 31) +* org-columns-skip-archived-trees: Internal archiving. (line 32) +* org-columns-summary-types: Column attributes. (line 65) * org-confirm-babel-evaluate: Code evaluation security. - (line 34) + (line 26) * org-confirm-elisp-link-function: Code evaluation security. - (line 56) -* org-confirm-shell-link-function: Code evaluation security. (line 53) +* org-confirm-shell-link-function: Code evaluation security. + (line 50) * org-create-file-search-functions: Custom searches. (line 12) * org-ctrl-c-ctrl-c-hook: Context-sensitive commands. (line 6) @@ -21246,23 +21155,23 @@ org-customize ' and then click yourself through the tree. * org-cycle-global-at-bob: Global and local cycling. (line 16) * org-cycle-include-plain-lists: Plain lists. (line 69) -* org-cycle-open-archived-trees: Internal archiving. (line 11) +* org-cycle-open-archived-trees: Internal archiving. (line 12) * org-cycle-separator-lines: Headlines. (line 26) * org-deadline-warning-days <1>: Inserting deadline/schedule. - (line 26) + (line 24) * org-deadline-warning-days: Deadlines and scheduling. - (line 12) + (line 14) * org-default-notes-file <1>: Template elements. (line 49) * org-default-notes-file: Setting up capture. (line 9) -* org-default-priority <1>: In-buffer settings. (line 48) -* org-default-priority: Priorities. (line 38) +* org-default-priority <1>: In-buffer settings. (line 45) +* org-default-priority: Priorities. (line 37) * org-display-custom-times: Custom time format. (line 6) * org-display-internal-link-with-indirect-buffer: Handling links. (line 132) -* org-disputed-keys: Conflicts. (line 34) +* org-disputed-keys: Conflicts. (line 28) * org-done (face): Faces for TODO keywords. (line 6) -* org-edit-footnote-reference: Footnotes. (line 97) +* org-edit-footnote-reference: Footnotes. (line 85) * org-edit-src-auto-save-idle-delay: Editing source code. (line 6) * org-edit-src-turn-on-auto-save: Editing source code. (line 6) * org-emphasis-alist: Emphasis and monospace. @@ -21272,14 +21181,14 @@ org-customize ' and then click yourself through the tree. * org-enable-table-editor: Built-in table editor. (line 30) * org-enforce-todo-dependencies: TODO dependencies. (line 6) -* org-entities: Special symbols. (line 15) +* org-entities-user: Special symbols. (line 16) * org-execute-file-search-functions: Custom searches. (line 12) -* org-export-allow-bind-keywords: Export settings. (line 194) +* org-export-allow-bind-keywords: Export settings. (line 210) * org-export-async-init-file: The export dispatcher. - (line 25) + (line 24) * org-export-backends <1>: Other built-in back-ends. (line 6) -* org-export-backends: Export back-ends. (line 10) +* org-export-backends: Exporting. (line 38) * org-export-before-parsing-hook: Advanced configuration. (line 9) * org-export-before-processing-hook: Advanced configuration. @@ -21292,64 +21201,66 @@ org-customize ' and then click yourself through the tree. * org-export-dispatch-use-expert-ui: The export dispatcher. (line 6) * org-export-exclude-tags: Export settings. (line 51) -* org-export-headline-levels <1>: Export settings. (line 125) -* org-export-headline-levels: Headings and sections. - (line 6) +* org-export-global-macros: Macro replacement. (line 6) +* org-export-headline-levels: Export settings. (line 140) * org-export-in-background: The export dispatcher. - (line 34) + (line 33) * org-export-initial-scope: The export dispatcher. - (line 44) -* org-export-preserve-breaks: Export settings. (line 83) + (line 43) +* org-export-preserve-breaks: Export settings. (line 93) * org-export-select-tags: Export settings. (line 44) * org-export-time-stamp-file <1>: HTML preamble and postamble. (line 6) -* org-export-time-stamp-file: Export settings. (line 170) -* org-export-with-archived-trees <1>: Export settings. (line 91) -* org-export-with-archived-trees: Internal archiving. (line 27) -* org-export-with-author: Export settings. (line 96) -* org-export-with-clocks: Export settings. (line 100) -* org-export-with-creator: Export settings. (line 103) -* org-export-with-date: Export settings. (line 111) -* org-export-with-drawers <1>: Export settings. (line 107) +* org-export-time-stamp-file: Export settings. (line 185) +* org-export-use-babel: Exporting code blocks. + (line 36) +* org-export-with-archived-trees <1>: Export settings. (line 101) +* org-export-with-archived-trees: Internal archiving. (line 28) +* org-export-with-author: Export settings. (line 106) +* org-export-with-broken-links: Export settings. (line 110) +* org-export-with-clocks: Export settings. (line 115) +* org-export-with-creator: Export settings. (line 118) +* org-export-with-date: Export settings. (line 126) +* org-export-with-drawers <1>: Export settings. (line 122) * org-export-with-drawers: Drawers. (line 38) -* org-export-with-email: Export settings. (line 118) -* org-export-with-entities: Export settings. (line 115) -* org-export-with-fixed-width: Export settings. (line 76) -* org-export-with-footnotes: Export settings. (line 122) -* org-export-with-inlinetasks: Export settings. (line 130) -* org-export-with-latex <1>: Export settings. (line 166) -* org-export-with-latex: LaTeX fragments. (line 39) -* org-export-with-planning: Export settings. (line 141) -* org-export-with-priority: Export settings. (line 146) -* org-export-with-properties <1>: Export settings. (line 149) +* org-export-with-email: Export settings. (line 133) +* org-export-with-entities: Export settings. (line 130) +* org-export-with-fixed-width: Export settings. (line 86) +* org-export-with-footnotes: Export settings. (line 137) +* org-export-with-inlinetasks: Export settings. (line 145) +* org-export-with-latex <1>: Export settings. (line 181) +* org-export-with-latex: LaTeX fragments. (line 38) +* org-export-with-planning: Export settings. (line 156) +* org-export-with-priority: Export settings. (line 161) +* org-export-with-properties <1>: Export settings. (line 164) * org-export-with-properties: Drawers. (line 38) -* org-export-with-section-numbers: Export settings. (line 133) -* org-export-with-smart-quotes: Export settings. (line 66) -* org-export-with-special-strings: Export settings. (line 72) -* org-export-with-statistics-cookies: Export settings. (line 153) -* org-export-with-sub-superscripts: Export settings. (line 86) -* org-export-with-tables: Export settings. (line 185) -* org-export-with-tags: Export settings. (line 157) -* org-export-with-tasks: Export settings. (line 161) -* org-export-with-timestamps: Export settings. (line 79) -* org-export-with-title: Export settings. (line 174) -* org-export-with-toc <1>: Export settings. (line 177) -* org-export-with-toc: Table of contents. (line 6) -* org-export-with-todo-keywords: Export settings. (line 181) +* org-export-with-section-numbers: Export settings. (line 148) +* org-export-with-smart-quotes: Export settings. (line 73) +* org-export-with-special-strings: Export settings. (line 82) +* org-export-with-statistics-cookies: Export settings. (line 168) +* org-export-with-sub-superscripts: Export settings. (line 96) +* org-export-with-tables: Export settings. (line 200) +* org-export-with-tags: Export settings. (line 172) +* org-export-with-tasks: Export settings. (line 176) +* org-export-with-timestamps: Export settings. (line 89) +* org-export-with-title: Export settings. (line 189) +* org-export-with-toc <1>: Table of contents. (line 6) +* org-export-with-toc: Export settings. (line 192) +* org-export-with-todo-keywords: Export settings. (line 196) * org-fast-tag-selection-include-todo: Fast access to TODO states. (line 16) -* org-fast-tag-selection-single-key: Setting tags. (line 144) -* org-file-apps <1>: Attachments. (line 49) +* org-fast-tag-selection-single-key: Setting tags. (line 143) +* org-file-apps <1>: Attachments. (line 52) * org-file-apps: Handling links. (line 104) * org-fontify-emphasized-text: Emphasis and monospace. (line 6) -* org-footnote-auto-adjust <1>: In-buffer settings. (line 152) -* org-footnote-auto-adjust: Footnotes. (line 58) -* org-footnote-auto-label <1>: In-buffer settings. (line 152) -* org-footnote-auto-label: Footnotes. (line 44) -* org-footnote-define-inline <1>: In-buffer settings. (line 152) -* org-footnote-define-inline: Footnotes. (line 58) -* org-footnote-section <1>: Footnotes. (line 58) +* org-footnote-auto-adjust <1>: In-buffer settings. (line 147) +* org-footnote-auto-adjust: Footnotes. (line 48) +* org-footnote-auto-label <1>: In-buffer settings. (line 147) +* org-footnote-auto-label: Footnotes. (line 34) +* org-footnote-define-inline <1>: In-buffer settings. (line 147) +* org-footnote-define-inline: Footnotes. (line 48) +* org-footnote-section <1>: Footnotes. (line 48) * org-footnote-section: Headlines. (line 18) * org-format-latex-header <1>: Previewing LaTeX fragments. (line 12) @@ -21361,29 +21272,29 @@ org-customize ' and then click yourself through the tree. * org-global-properties: Property syntax. (line 75) * org-goto-auto-isearch: Motion. (line 26) * org-goto-interface: Motion. (line 37) -* org-group-tags: Tag hierarchy. (line 87) -* org-hide (face): Clean view. (line 66) +* org-group-tags: Tag hierarchy. (line 86) +* org-hide (face): Clean view. (line 70) * org-hide-block-startup: Blocks. (line 6) -* org-hide-leading-stars <1>: Clean view. (line 50) -* org-hide-leading-stars: In-buffer settings. (line 131) +* org-hide-leading-stars <1>: Clean view. (line 55) +* org-hide-leading-stars: In-buffer settings. (line 126) * org-hierarchical-todo-statistics: Breaking down tasks. (line 25) -* org-highest-priority <1>: In-buffer settings. (line 48) -* org-highest-priority: Priorities. (line 38) +* org-highest-priority <1>: In-buffer settings. (line 45) +* org-highest-priority: Priorities. (line 37) * org-html-container-element: HTML Specific export settings. (line 17) -* org-html-doctype <1>: HTML doctypes. (line 6) +* org-html-doctype <1>: HTML doctypes. (line 8) * org-html-doctype: HTML Specific export settings. (line 14) -* org-html-doctype-alist: HTML doctypes. (line 6) -* org-html-head <1>: CSS support. (line 42) +* org-html-doctype-alist: HTML doctypes. (line 8) +* org-html-head <1>: CSS support. (line 43) * org-html-head: HTML Specific export settings. (line 32) -* org-html-head-extra <1>: CSS support. (line 42) +* org-html-head-extra <1>: CSS support. (line 43) * org-html-head-extra: HTML Specific export settings. (line 36) -* org-html-head-include-default-style: CSS support. (line 42) -* org-html-html5-elements: HTML doctypes. (line 39) -* org-html-html5-fancy: HTML doctypes. (line 39) +* org-html-head-include-default-style: CSS support. (line 43) +* org-html-html5-elements: HTML doctypes. (line 69) +* org-html-html5-fancy: HTML doctypes. (line 36) * org-html-infojs-options: JavaScript support. (line 54) * org-html-inline-images: Images in HTML export. (line 6) @@ -21403,7 +21314,7 @@ org-customize ' and then click yourself through the tree. (line 6) * org-html-preamble-format: HTML preamble and postamble. (line 6) -* org-html-style-default: CSS support. (line 42) +* org-html-style-default: CSS support. (line 43) * org-html-table-align-individual-fields: Tables in HTML export. (line 20) * org-html-table-caption-above: Tables in HTML export. @@ -21432,48 +21343,57 @@ org-customize ' and then click yourself through the tree. * org-icalendar-use-deadline: iCalendar export. (line 6) * org-icalendar-use-scheduled: iCalendar export. (line 6) * org-id-link-to-org-use-id: Handling links. (line 21) -* org-imenu-depth: Cooperation. (line 38) -* org-insert-mode-line-in-empty-file: Activation. (line 32) +* org-imenu-depth: Cooperation. (line 30) +* org-insert-mode-line-in-empty-file: Activation. (line 27) * org-irc-link-to-logs: Handling links. (line 45) * org-keep-stored-link-after-insertion: Handling links. (line 66) -* org-latex-classes <1>: Header and sectioning. +* org-latex-bibtex-compiler: LaTeX export commands. + (line 21) +* org-latex-classes <1>: LaTeX header and sectioning. (line 13) * org-latex-classes: LaTeX specific export settings. (line 17) -* org-latex-create-formula-image-program: Previewing LaTeX fragments. - (line 6) -* org-latex-default-class <1>: Header and sectioning. +* org-latex-compiler <1>: LaTeX specific export settings. + (line 25) +* org-latex-compiler: LaTeX export commands. + (line 21) +* org-latex-default-class <1>: LaTeX header and sectioning. (line 13) * org-latex-default-class: LaTeX specific export settings. (line 17) -* org-latex-default-packages-alist: Header and sectioning. +* org-latex-default-packages-alist <1>: LaTeX header and sectioning. (line 13) -* org-latex-default-table-environment: LaTeX specific attributes. - (line 27) -* org-latex-default-table-mode: LaTeX specific attributes. - (line 18) +* org-latex-default-packages-alist: LaTeX export commands. + (line 21) +* org-latex-default-table-environment: Tables in LaTeX export. + (line 19) +* org-latex-default-table-mode: Tables in LaTeX export. + (line 11) +* org-latex-images-centered: Images in LaTeX export. + (line 52) * org-latex-listings: Literal examples. (line 23) -* org-latex-listings-options: LaTeX specific attributes. - (line 187) -* org-latex-minted-options: LaTeX specific attributes. - (line 187) -* org-latex-packages-alist: Header and sectioning. +* org-latex-listings-options: Source blocks in LaTeX export. + (line 26) +* org-latex-minted-options: Source blocks in LaTeX export. + (line 26) +* org-latex-packages-alist: LaTeX header and sectioning. (line 13) * org-latex-subtitle-format: LaTeX specific export settings. - (line 43) + (line 46) * org-latex-subtitle-separate: LaTeX specific export settings. - (line 43) -* org-latex-tables-booktabs: LaTeX specific attributes. - (line 63) -* org-latex-tables-centered: LaTeX specific attributes. - (line 63) + (line 46) +* org-latex-tables-booktabs: Tables in LaTeX export. + (line 55) +* org-latex-tables-centered: Tables in LaTeX export. + (line 55) * org-latex-to-mathml-convert-command: Working with LaTeX math snippets. (line 20) * org-latex-to-mathml-jar-file: Working with LaTeX math snippets. (line 20) -* org-link-abbrev-alist <1>: In-buffer settings. (line 43) +* org-link-abbrev-alist <1>: In-buffer settings. (line 40) * org-link-abbrev-alist: Link abbreviations. (line 12) * org-link-frame-setup: Handling links. (line 104) +* org-link-parameters: Handling links. (line 66) * org-list-allow-alphabetical: Plain lists. (line 14) * org-list-automatic-rules <1>: Checkboxes. (line 6) * org-list-automatic-rules: Plain lists. (line 62) @@ -21481,29 +21401,29 @@ org-customize ' and then click yourself through the tree. * org-list-empty-line-terminates-plain-lists: Plain lists. (line 30) * org-list-indent-offset: Plain lists. (line 56) * org-list-use-circular-motion: Plain lists. (line 94) -* org-log-done <1>: In-buffer settings. (line 106) -* org-log-done <2>: Agenda commands. (line 119) +* org-log-done <1>: In-buffer settings. (line 101) +* org-log-done <2>: Agenda commands. (line 118) * org-log-done: Tracking TODO state changes. (line 29) -* org-log-into-drawer <1>: Agenda commands. (line 302) +* org-log-into-drawer <1>: Agenda commands. (line 295) * org-log-into-drawer: Tracking TODO state changes. (line 6) -* org-log-note-clock-out <1>: In-buffer settings. (line 106) +* org-log-note-clock-out <1>: In-buffer settings. (line 101) * org-log-note-clock-out: Clocking commands. (line 37) * org-log-refile: Refile and copy. (line 17) -* org-log-repeat <1>: In-buffer settings. (line 106) +* org-log-repeat <1>: In-buffer settings. (line 101) * org-log-repeat: Repeated tasks. (line 37) * org-log-states-order-reversed: Tracking TODO state changes. (line 6) -* org-lowest-priority <1>: In-buffer settings. (line 48) -* org-lowest-priority: Priorities. (line 38) +* org-lowest-priority <1>: In-buffer settings. (line 45) +* org-lowest-priority: Priorities. (line 37) * org-M-RET-may-split-line <1>: Plain lists. (line 82) * org-M-RET-may-split-line: Structure editing. (line 7) * org-md-headline-style: Markdown export. (line 30) * org-odd-levels-only <1>: Special agenda views. - (line 48) -* org-odd-levels-only <2>: Clean view. (line 74) -* org-odd-levels-only <3>: In-buffer settings. (line 131) + (line 41) +* org-odd-levels-only <2>: Clean view. (line 75) +* org-odd-levels-only <3>: In-buffer settings. (line 126) * org-odd-levels-only: Matching tags and properties. (line 72) * org-odt-category-map-alist: Labels and captions in ODT export. @@ -21538,15 +21458,17 @@ org-customize ' and then click yourself through the tree. * org-plain-list-ordered-item-terminator: Plain lists. (line 14) * org-popup-calendar-for-date-prompt: The date/time prompt. (line 76) +* org-preview-latex-default-process: Previewing LaTeX fragments. + (line 6) * org-priority-faces: Priorities. (line 13) -* org-priority-start-cycle-with-default: Priorities. (line 33) +* org-priority-start-cycle-with-default: Priorities. (line 32) * org-property-allowed-value-functions: Using the property API. - (line 69) + (line 68) * org-publish-project-alist <1>: Publishing options. (line 13) * org-publish-project-alist: Project alist. (line 6) * org-publish-use-timestamps-flag: Triggering publication. (line 21) -* org-put-time-stamp-overlays: In-buffer settings. (line 142) +* org-put-time-stamp-overlays: In-buffer settings. (line 137) * org-read-date-display-live: The date/time prompt. (line 91) * org-read-date-force-compatible-dates: The date/time prompt. @@ -21560,33 +21482,33 @@ org-customize ' and then click yourself through the tree. * org-refile-use-outline-path: Refile and copy. (line 17) * org-remove-highlights-with-change <1>: Clocking commands. (line 83) * org-remove-highlights-with-change: Sparse trees. (line 20) -* org-replace-disputed-keys: Conflicts. (line 19) +* org-replace-disputed-keys: Conflicts. (line 18) * org-return-follows-link: Handling links. (line 123) * org-reverse-note-order: Refile and copy. (line 17) * org-scheduled-delay-days: Deadlines and scheduling. - (line 40) + (line 42) * org-show-context-detail: Sparse trees. (line 6) * org-sort-agenda-noeffort-is-high: Filtering/limiting agenda items. - (line 96) -* org-sparse-tree-open-archived-trees: Internal archiving. (line 17) + (line 92) +* org-sparse-tree-open-archived-trees: Internal archiving. (line 18) * org-special-ctrl-a/e: Headlines. (line 6) * org-special-ctrl-k: Headlines. (line 6) * org-speed-commands-user: Speed keys. (line 6) -* org-startup-align-all-tables <1>: In-buffer settings. (line 85) +* org-startup-align-all-tables <1>: In-buffer settings. (line 81) * org-startup-align-all-tables: Column width and alignment. (line 33) * org-startup-folded <1>: Speeding up your agendas. - (line 19) -* org-startup-folded <2>: In-buffer settings. (line 74) + (line 18) +* org-startup-folded <2>: In-buffer settings. (line 71) * org-startup-folded: Initial visibility. (line 6) -* org-startup-indented: In-buffer settings. (line 80) -* org-startup-with-inline-images <1>: In-buffer settings. (line 92) +* org-startup-indented: In-buffer settings. (line 76) +* org-startup-with-inline-images <1>: In-buffer settings. (line 88) * org-startup-with-inline-images: Handling links. (line 136) -* org-startup-with-latex-preview <1>: In-buffer settings. (line 99) +* org-startup-with-latex-preview <1>: In-buffer settings. (line 94) * org-startup-with-latex-preview: Previewing LaTeX fragments. (line 28) * org-store-link-functions: Adding hyperlink types. - (line 65) + (line 61) * org-stuck-projects: Stuck projects. (line 17) * org-support-shift-select <1>: Conflicts. (line 6) * org-support-shift-select: Plain lists. (line 94) @@ -21598,14 +21520,14 @@ org-customize ' and then click yourself through the tree. (line 6) * org-table-export-default-format: Built-in table editor. (line 205) -* org-table-formula: In-buffer settings. (line 33) -* org-table-formula-constants <1>: Cooperation. (line 17) -* org-table-formula-constants <2>: In-buffer settings. (line 33) +* org-table-formula: In-buffer settings. (line 30) +* org-table-formula-constants <1>: Cooperation. (line 12) +* org-table-formula-constants <2>: In-buffer settings. (line 30) * org-table-formula-constants: References. (line 110) * org-table-use-standard-references <1>: Editing and debugging formulas. (line 6) * org-table-use-standard-references: References. (line 17) -* org-tag-alist <1>: In-buffer settings. (line 176) +* org-tag-alist <1>: In-buffer settings. (line 171) * org-tag-alist: Setting tags. (line 23) * org-tag-faces: Tags. (line 10) * org-tag-persistent-alist: Setting tags. (line 38) @@ -21618,10 +21540,10 @@ org-customize ' and then click yourself through the tree. * org-tags-match-list-sublevels: Tag inheritance. (line 26) * org-texinfo-classes <1>: Headings and sectioning structure. (line 6) -* org-texinfo-classes: Document preamble. (line 22) -* org-texinfo-coding-system: Document preamble. (line 22) -* org-texinfo-def-table-markup: Texinfo specific attributes. - (line 17) +* org-texinfo-classes: Texinfo file header. (line 12) +* org-texinfo-coding-system: Texinfo file header. (line 12) +* org-texinfo-def-table-markup: Plain lists in Texinfo export. + (line 10) * org-texinfo-default-class <1>: Headings and sectioning structure. (line 6) * org-texinfo-default-class: Texinfo specific export settings. @@ -21629,38 +21551,38 @@ org-customize ' and then click yourself through the tree. * org-texinfo-info-process: Texinfo export commands. (line 6) * org-time-stamp-custom-formats: Custom time format. (line 6) -* org-time-stamp-overlay-formats: In-buffer settings. (line 142) +* org-time-stamp-overlay-formats: In-buffer settings. (line 137) * org-time-stamp-rounding-minutes: Creating timestamps. (line 23) * org-todo (face): Faces for TODO keywords. (line 6) * org-todo-keyword-faces: Faces for TODO keywords. (line 6) -* org-todo-keywords <1>: In-buffer settings. (line 196) +* org-todo-keywords <1>: In-buffer settings. (line 189) * org-todo-keywords <2>: Global TODO list. (line 18) * org-todo-keywords <3>: TODO extensions. (line 6) -* org-todo-keywords: TODO basics. (line 42) +* org-todo-keywords: TODO basics. (line 41) * org-todo-repeat-to-state: Repeated tasks. (line 19) -* org-todo-state-tags-triggers: TODO basics. (line 63) -* org-track-ordered-property-with-tag <1>: Checkboxes. (line 79) +* org-todo-state-tags-triggers: TODO basics. (line 62) +* org-track-ordered-property-with-tag <1>: Checkboxes. (line 80) * org-track-ordered-property-with-tag: TODO dependencies. (line 38) * org-treat-insert-todo-heading-as-state-change: Structure editing. - (line 36) + (line 29) * org-treat-S-cursor-todo-selection-as-state-change: TODO basics. - (line 35) + (line 34) * org-use-fast-todo-selection: TODO basics. (line 14) * org-use-property-inheritance <1>: Using the property API. (line 18) * org-use-property-inheritance <2>: Header arguments in Org mode properties. - (line 19) + (line 17) * org-use-property-inheritance <3>: iCalendar export. (line 46) * org-use-property-inheritance: Property inheritance. (line 6) * org-use-speed-commands: Speed keys. (line 6) * org-use-sub-superscripts: Subscripts and superscripts. - (line 15) + (line 14) * org-use-tag-inheritance: Tag inheritance. (line 22) -* org-yank-adjusted-subtrees: Structure editing. (line 93) -* org-yank-folded-subtrees: Structure editing. (line 93) +* org-yank-adjusted-subtrees: Structure editing. (line 86) +* org-yank-folded-subtrees: Structure editing. (line 86) * orgstruct-heading-prefix-regexp: Orgstruct mode. (line 26) * parse-time-months: The date/time prompt. (line 57) @@ -21676,537 +21598,533 @@ org-customize ' and then click yourself through the tree.  Tag Table: -Node: Top893 -Node: Introduction23740 -Node: Summary24181 -Node: Installation26877 -Node: Activation29559 -Ref: Activation-Footnote-131364 -Node: Feedback31486 -Ref: Feedback-Footnote-135194 -Node: Conventions35321 -Ref: Conventions-Footnote-137387 -Node: Document structure37479 -Node: Outlines38470 -Node: Headlines39099 -Ref: Headlines-Footnote-140301 -Ref: Headlines-Footnote-240477 -Node: Visibility cycling40548 -Node: Global and local cycling40927 -Ref: Global and local cycling-Footnote-143587 -Ref: Global and local cycling-Footnote-243645 -Ref: Global and local cycling-Footnote-343695 -Node: Initial visibility43964 -Ref: Initial visibility-Footnote-145216 -Node: Catching invisible edits45397 -Node: Motion45862 -Node: Structure editing47197 -Node: Sparse trees54199 -Ref: Sparse trees-Footnote-156698 -Ref: Sparse trees-Footnote-256809 -Ref: Sparse trees-Footnote-356880 -Node: Plain lists56995 -Ref: Plain lists-Footnote-164408 -Ref: Plain lists-Footnote-264762 -Ref: Plain lists-Footnote-364858 -Ref: Plain lists-Footnote-465105 -Ref: Plain lists-Footnote-565276 -Ref: Plain lists-Footnote-665339 -Ref: Plain lists-Footnote-765515 -Ref: Plain lists-Footnote-865615 -Ref: Plain lists-Footnote-965717 -Node: Drawers65783 -Node: Blocks67606 -Node: Footnotes68165 -Ref: Footnotes-Footnote-172787 -Ref: Footnotes-Footnote-272884 -Node: Orgstruct mode72961 -Node: Org syntax74591 -Node: Tables75495 -Node: Built-in table editor76136 -Ref: Built-in table editor-Footnote-185890 -Node: Column width and alignment85990 -Ref: Column width and alignment-Footnote-188553 -Ref: Column width and alignment-Footnote-288599 -Node: Column groups88696 -Node: Orgtbl mode90268 -Node: The spreadsheet91077 -Node: References92537 -Ref: References-Footnote-199255 -Ref: References-Footnote-299477 -Ref: References-Footnote-399746 -Ref: References-Footnote-499859 -Node: Formula syntax for Calc100149 -Ref: Formula syntax for Calc-Footnote-1105296 -Node: Formula syntax for Lisp105620 -Node: Durations and time values107355 -Node: Field and range formulas108433 -Node: Column formulas110830 -Node: Lookup functions112918 -Node: Editing and debugging formulas114841 -Ref: Using multiple #+TBLFM lines119100 -Node: Updating the table120313 -Node: Advanced features121669 -Ref: Advanced features-Footnote-1126150 -Node: Org-Plot126256 -Node: Hyperlinks130450 -Node: Link format131207 -Node: Internal links132466 -Ref: Internal links-Footnote-1134761 -Ref: Internal links-Footnote-2135001 -Node: Radio targets135139 -Node: External links135806 -Ref: External links-Footnote-1139878 -Ref: External links-Footnote-2140296 -Node: Handling links140553 -Ref: Handling links-Footnote-1148458 -Ref: Handling links-Footnote-2148617 -Ref: Handling links-Footnote-3148792 -Ref: Handling links-Footnote-4149087 -Ref: Handling links-Footnote-5149333 -Ref: Handling links-Footnote-6149410 -Ref: Handling links-Footnote-7149482 -Node: Using links outside Org149566 -Node: Link abbreviations150051 -Node: Search options152733 -Ref: Search options-Footnote-1154615 -Node: Custom searches154696 -Node: TODO items155706 -Ref: TODO items-Footnote-1156814 -Node: TODO basics156928 -Node: TODO extensions159774 -Node: Workflow states160804 -Ref: Workflow states-Footnote-1162105 -Node: TODO types162198 -Ref: TODO types-Footnote-1163796 -Node: Multiple sets in one file163878 -Node: Fast access to TODO states165732 -Ref: Fast access to TODO states-Footnote-1166605 -Ref: Fast access to TODO states-Footnote-2166689 -Node: Per-file keywords166982 -Ref: Per-file keywords-Footnote-1168353 -Node: Faces for TODO keywords168554 -Node: TODO dependencies169595 -Node: Progress logging171930 -Node: Closing items172642 -Ref: Closing items-Footnote-1173847 -Ref: Closing items-Footnote-2173916 -Node: Tracking TODO state changes173990 -Ref: Tracking TODO state changes-Footnote-1177026 -Ref: Tracking TODO state changes-Footnote-2177081 -Ref: Tracking TODO state changes-Footnote-3177221 -Node: Tracking your habits177509 -Node: Priorities181743 -Ref: Priorities-Footnote-1183733 -Node: Breaking down tasks183802 -Ref: Breaking down tasks-Footnote-1185781 -Node: Checkboxes185877 -Ref: Checkboxes-Footnote-1190403 -Ref: Checkboxes-Footnote-2190527 -Ref: Checkboxes-Footnote-3190701 -Node: Tags190815 -Node: Tag inheritance191871 -Ref: Tag inheritance-Footnote-1193682 -Ref: Tag inheritance-Footnote-2193782 -Node: Setting tags193908 -Ref: Setting tags-Footnote-1200215 -Node: Tag hierarchy200298 -Node: Tag searches203689 -Node: Properties and columns204984 -Node: Property syntax206420 -Node: Special properties210762 -Node: Property searches212419 -Node: Property inheritance213854 -Node: Column view215670 -Node: Defining columns216905 -Node: Scope of column definitions217283 -Node: Column attributes218188 -Ref: Column attributes-Footnote-1223012 -Node: Using column view223145 -Node: Capturing column view226006 -Ref: Capturing column view-Footnote-1229002 -Node: Property API229138 -Node: Dates and times229492 -Node: Timestamps230399 -Ref: Timestamps-Footnote-1232818 -Ref: Timestamps-Footnote-2233004 -Ref: Timestamps-Footnote-3233135 -Node: Creating timestamps233904 -Node: The date/time prompt236728 -Ref: The date/time prompt-Footnote-1241309 -Ref: The date/time prompt-Footnote-2241472 -Ref: The date/time prompt-Footnote-3241578 -Node: Custom time format241672 -Node: Deadlines and scheduling243394 -Ref: Deadlines and scheduling-Footnote-1246776 -Node: Inserting deadline/schedule246931 -Ref: Inserting deadline/schedule-Footnote-1248888 -Ref: Inserting deadline/schedule-Footnote-2249040 -Ref: Inserting deadline/schedule-Footnote-3249148 -Node: Repeated tasks249256 -Ref: Repeated tasks-Footnote-1253126 -Ref: Repeated tasks-Footnote-2253375 -Node: Clocking work time253574 -Ref: Clocking work time-Footnote-1254759 -Ref: Clocking work time-Footnote-2254903 -Node: Clocking commands255041 -Ref: Clocking commands-Footnote-1259987 -Ref: Clocking commands-Footnote-2260094 -Ref: Clocking commands-Footnote-3260144 -Ref: Clocking commands-Footnote-4260202 -Node: The clock table260280 -Ref: The clock table-Footnote-1267730 -Ref: The clock table-Footnote-2267824 -Node: Resolving idle time267949 -Ref: Resolving idle time-Footnote-1271796 -Node: Effort estimates272264 -Ref: Effort estimates-Footnote-1275017 -Node: Timers275124 -Node: Capture - Refile - Archive277423 -Node: Capture278413 -Node: Setting up capture279481 -Ref: Setting up capture-Footnote-1279890 -Node: Using capture279956 -Node: Capture templates282363 -Node: Template elements284324 -Ref: Template elements-Footnote-1290054 -Node: Template expansion290229 -Ref: Template expansion-Footnote-1294219 -Ref: Template expansion-Footnote-2294306 -Ref: Template expansion-Footnote-3294488 -Node: Templates in contexts294586 -Node: Attachments295408 -Ref: Attachments-Footnote-1298790 -Node: RSS feeds298940 -Node: Protocols300417 -Node: Refile and copy301132 -Ref: Refile and copy-Footnote-1303554 -Node: Archiving303650 -Node: Moving subtrees304350 -Node: Internal archiving306374 -Node: Agenda views309004 -Node: Agenda files311195 -Ref: Agenda files-Footnote-1313998 -Ref: Agenda files-Footnote-2314147 -Node: Agenda dispatcher314340 -Ref: Agenda dispatcher-Footnote-1317249 -Ref: Agenda dispatcher-Footnote-2317343 -Node: Built-in agenda views317445 -Node: Weekly/daily agenda318094 -Ref: Weekly/daily agenda-Footnote-1323439 -Ref: Weekly/daily agenda-Footnote-2323666 -Node: Global TODO list323841 -Node: Matching tags and properties326369 -Node: Timeline333357 -Node: Search view334049 -Node: Stuck projects335342 -Ref: Stuck projects-Footnote-1337402 -Node: Presentation and sorting337432 -Node: Categories338389 -Node: Time-of-day specifications339118 -Node: Sorting agenda items341087 -Node: Filtering/limiting agenda items342656 -Ref: Filtering/limiting agenda items-Footnote-1349784 -Node: Agenda commands350199 -Ref: Agenda commands-Footnote-1371720 -Ref: Agenda commands-Footnote-2371801 -Ref: Agenda commands-Footnote-3371920 -Ref: Agenda commands-Footnote-4372020 -Node: Custom agenda views372103 -Node: Storing searches372744 -Ref: Storing searches-Footnote-1375685 -Ref: Storing searches-Footnote-2375802 -Node: Block agenda376050 -Node: Setting options377288 -Node: Exporting agenda views380877 -Ref: Exporting agenda views-Footnote-1385778 -Ref: Exporting agenda views-Footnote-2385836 -Ref: Exporting agenda views-Footnote-3385992 -Ref: Exporting agenda views-Footnote-4386179 -Node: Agenda column view386261 -Node: Markup389335 -Node: Structural markup elements390367 -Node: Document title391022 -Node: Headings and sections391434 -Node: Table of contents392104 -Ref: Table of contents-Footnote-1393860 -Node: Lists394058 -Node: Paragraphs394349 -Node: Footnote markup395499 -Node: Emphasis and monospace395836 -Node: Horizontal rules396693 -Node: Comment lines396950 -Ref: Comment lines-Footnote-1397727 -Node: Images and tables397827 -Node: Literal examples399544 -Ref: Literal examples-Footnote-1403537 -Ref: Literal examples-Footnote-2404070 -Ref: Literal examples-Footnote-3404242 -Ref: Literal examples-Footnote-4404421 -Ref: Literal examples-Footnote-5404671 -Node: Include files404765 -Ref: Include files-Footnote-1407647 -Ref: Include files-Footnote-2407797 -Node: Index entries407963 -Node: Macro replacement408425 -Ref: Macro replacement-Footnote-1410382 -Node: Embedded LaTeX410612 -Ref: Embedded LaTeX-Footnote-1411576 -Node: Special symbols411766 -Ref: Special symbols-Footnote-1413367 -Node: Subscripts and superscripts413522 -Node: LaTeX fragments414627 -Ref: LaTeX fragments-Footnote-1416827 -Node: Previewing LaTeX fragments417031 -Ref: Previewing LaTeX fragments-Footnote-1418456 -Node: CDLaTeX mode418675 -Ref: CDLaTeX mode-Footnote-1421172 -Node: Special blocks421320 -Node: Exporting422251 -Node: The export dispatcher424206 -Ref: The export dispatcher-Footnote-1426328 -Node: Export back-ends426591 -Node: Export settings427501 -Ref: Export settings-Footnote-1434596 -Ref: Export settings-Footnote-2434698 -Ref: Export settings-Footnote-3434793 -Node: ASCII/Latin-1/UTF-8 export434836 -Node: Beamer export437608 -Node: Beamer export commands438331 -Node: Beamer specific export settings439006 -Node: Sectioning Frames and Blocks in Beamer440790 -Ref: Sectioning Frames and Blocks in Beamer-Footnote-1443746 -Ref: Sectioning Frames and Blocks in Beamer-Footnote-2443909 -Node: Beamer specific syntax444027 -Node: Editing support445659 -Node: A Beamer Example446090 -Node: HTML export447368 -Node: HTML Export commands448520 -Node: HTML Specific export settings449066 -Node: HTML doctypes450851 -Node: HTML preamble and postamble453098 -Node: Quoting HTML tags454146 -Node: Links in HTML export454776 -Node: Tables in HTML export455987 -Node: Images in HTML export457423 -Ref: Images in HTML export-Footnote-1458713 -Node: Math formatting in HTML export458768 -Ref: Math formatting in HTML export-Footnote-1460119 -Node: Text areas in HTML export460379 -Node: CSS support461161 -Ref: CSS support-Footnote-1464268 -Ref: CSS support-Footnote-2464440 -Node: JavaScript support464682 -Node: LaTeX and PDF export468063 -Ref: LaTeX and PDF export-Footnote-1469259 -Node: LaTeX export commands469549 -Node: LaTeX specific export settings470224 -Node: Header and sectioning472312 -Ref: Header and sectioning-Footnote-1473933 -Ref: Header and sectioning-Footnote-2474045 -Node: Quoting LaTeX code474208 -Node: LaTeX specific attributes474803 -Ref: LaTeX specific attributes-Footnote-1484208 -Ref: LaTeX specific attributes-Footnote-2484286 -Ref: LaTeX specific attributes-Footnote-3484360 -Ref: LaTeX specific attributes-Footnote-4484444 -Node: Markdown export484598 -Ref: Markdown export-Footnote-1485902 -Node: OpenDocument Text export485988 -Ref: OpenDocument Text export-Footnote-1487178 -Ref: OpenDocument Text export-Footnote-2487208 -Node: Pre-requisites for ODT export487352 -Node: ODT export commands487678 -Ref: x-export-to-odt487880 -Ref: ODT export commands-Footnote-1488879 -Ref: ODT export commands-Footnote-2488939 -Node: ODT specific export settings488990 -Node: Extending ODT export489830 -Ref: x-export-to-other-formats490816 -Ref: x-convert-to-other-formats491326 -Node: Applying custom styles491783 -Node: Links in ODT export493905 -Node: Tables in ODT export494550 -Ref: Tables in ODT export-Footnote-1496684 -Node: Images in ODT export496777 -Ref: Images in ODT export-Footnote-1499502 -Node: Math formatting in ODT export499735 -Node: Working with LaTeX math snippets500197 -Ref: Working with LaTeX math snippets-Footnote-1502363 -Ref: Working with LaTeX math snippets-Footnote-2502439 -Node: Working with MathML or OpenDocument formula files502484 -Node: Labels and captions in ODT export503038 -Node: Literal examples in ODT export504495 -Ref: Literal examples in ODT export-Footnote-1505396 -Node: Advanced topics in ODT export505507 -Node: Configuring a document converter506261 -Ref: x-odt-converter-capabilities507033 -Node: Working with OpenDocument style files507614 -Ref: x-factory-styles508090 -Ref: x-orgodtstyles-xml508328 -Ref: x-orgodtcontenttemplate-xml508655 -Ref: x-overriding-factory-styles509311 -Ref: x-org-odt-styles-file509591 -Ref: x-org-odt-content-template-file510472 -Node: Creating one-off styles510613 -Node: Customizing tables in ODT export512814 -Ref: Customizing tables in ODT export-Footnote-1517791 -Ref: Customizing tables in ODT export-Footnote-2517895 -Ref: Customizing tables in ODT export-Footnote-3517983 -Node: Validating OpenDocument XML518298 -Ref: Validating OpenDocument XML-Footnote-1519297 -Node: Org export519349 -Node: Texinfo export520113 -Node: Texinfo export commands520802 -Ref: Texinfo export commands-Footnote-1521337 -Node: Texinfo specific export settings521445 -Node: Document preamble522547 -Ref: Document preamble-Footnote-1525832 -Node: Headings and sectioning structure525894 -Node: Indices527348 -Node: Quoting Texinfo code528141 -Node: Texinfo specific attributes528625 -Ref: Texinfo specific attributes-Footnote-1530147 -Node: An example530213 -Node: iCalendar export532204 -Ref: iCalendar export-Footnote-1534936 -Ref: iCalendar export-Footnote-2535026 -Ref: iCalendar export-Footnote-3535126 -Node: Other built-in back-ends535263 -Node: Export in foreign buffers535856 -Node: Advanced configuration536846 -Node: Publishing543788 -Node: Configuration544656 -Node: Project alist545419 -Node: Sources and destinations546560 -Node: Selecting files548078 -Node: Publishing action549079 -Ref: Publishing action-Footnote-1550908 -Node: Publishing options551065 -Node: Publishing links563792 -Node: Sitemap564759 -Node: Generating an index567978 -Node: Uploading files568565 -Node: Sample configuration570329 -Node: Simple example570818 -Node: Complex example571465 -Node: Triggering publication573516 -Node: Working with source code574512 -Node: Structure of code blocks576204 -Ref: Structure of code blocks-Footnote-1578037 -Node: Editing source code578131 -Node: Exporting code blocks580254 -Node: Extracting source code582678 -Node: Evaluating code blocks584913 -Ref: Evaluating code blocks-Footnote-1588424 -Ref: Evaluating code blocks-Footnote-2588721 -Node: Library of Babel588847 -Node: Languages589820 -Node: Header arguments592253 -Node: Using header arguments592738 -Node: System-wide header arguments593768 -Node: Language-specific header arguments594575 -Node: Header arguments in Org mode properties595084 -Ref: Header arguments in Org mode properties-Footnote-1596813 -Node: Language-specific header arguments in Org mode properties597085 -Node: Code block specific header arguments598101 -Node: Header arguments in function calls599947 -Node: Specific header arguments600696 -Node: var603470 -Node: results610261 -Node: file615114 -Node: file-desc616026 -Node: file-ext616496 -Node: output-dir616994 -Node: dir617532 -Node: exports620467 -Node: tangle621205 -Node: mkdirp622016 -Node: comments622349 -Node: padline623484 -Node: no-expand624016 -Node: session624655 -Node: noweb625690 -Node: noweb-ref627867 -Ref: noweb-ref-Footnote-1629333 -Node: noweb-sep629462 -Node: cache629756 -Node: sep631488 -Node: hlines632060 -Node: colnames633562 -Node: rownames634865 -Node: shebang636040 -Node: tangle-mode636443 -Node: eval637194 -Node: wrap638232 -Node: post638672 -Node: prologue640564 -Node: epilogue641136 -Node: Results of evaluation641391 -Node: Noweb reference syntax645159 -Node: Key bindings and useful functions646810 -Node: Batch execution649555 -Node: Miscellaneous650589 -Node: Completion651418 -Node: Easy templates653372 -Node: Speed keys654781 -Node: Code evaluation security655605 -Node: Customization658315 -Node: In-buffer settings658910 -Ref: In-buffer settings-Footnote-1668650 -Node: The very busy C-c C-c key668698 -Node: Clean view670682 -Ref: Clean view-Footnote-1674667 -Ref: Clean view-Footnote-2674728 -Ref: Clean view-Footnote-3674912 -Ref: Clean view-Footnote-4674973 -Ref: Clean view-Footnote-5675085 -Ref: Clean view-Footnote-6675140 -Node: TTY keys675265 -Node: Interaction677031 -Node: Cooperation677425 -Node: Conflicts681203 -Node: org-crypt686172 -Node: Hacking687483 -Node: Hooks688469 -Node: Add-on packages688869 -Node: Adding hyperlink types689423 -Node: Adding export back-ends693343 -Node: Context-sensitive commands694783 -Ref: Context-sensitive commands-Footnote-1696360 -Node: Tables in arbitrary syntax696494 -Node: Radio tables697906 -Node: A LaTeX example700493 -Ref: A LaTeX example-Footnote-1704485 -Ref: A LaTeX example-Footnote-2704642 -Node: Translator functions705077 -Node: Radio lists707508 -Node: Dynamic blocks708637 -Node: Special agenda views710835 -Ref: x-agenda-skip-entry-regexp714298 -Ref: Special agenda views-Footnote-1715101 -Ref: Special agenda views-Footnote-2715296 -Node: Speeding up your agendas715431 -Node: Extracting agenda information716534 -Node: Using the property API720612 -Node: Using the mapping API723982 -Node: MobileOrg728404 -Node: Setting up the staging area730098 -Ref: Setting up the staging area-Footnote-1731179 -Ref: Setting up the staging area-Footnote-2731480 -Node: Pushing to MobileOrg731742 -Ref: Pushing to MobileOrg-Footnote-1732742 -Ref: Pushing to MobileOrg-Footnote-2732829 -Ref: Pushing to MobileOrg-Footnote-3733245 -Node: Pulling from MobileOrg733316 -Ref: Pulling from MobileOrg-Footnote-1735737 -Ref: Pulling from MobileOrg-Footnote-2735797 -Node: History and acknowledgments736172 -Node: GNU Free Documentation License751327 -Node: Main Index776517 -Node: Key Index865545 -Node: Command and Function Index918134 -Node: Variable Index953159 +Node: Top900 +Node: Introduction24537 +Node: Summary24978 +Node: Installation27674 +Node: Activation30370 +Ref: Activation-Footnote-131890 +Node: Feedback32012 +Ref: Feedback-Footnote-135667 +Node: Conventions35794 +Node: Document structure37831 +Node: Outlines38822 +Node: Headlines39451 +Ref: Headlines-Footnote-140653 +Ref: Headlines-Footnote-240829 +Node: Visibility cycling40900 +Node: Global and local cycling41279 +Ref: Global and local cycling-Footnote-143963 +Ref: Global and local cycling-Footnote-244021 +Ref: Global and local cycling-Footnote-344071 +Node: Initial visibility44340 +Ref: Initial visibility-Footnote-145375 +Node: Catching invisible edits45556 +Node: Motion46021 +Node: Structure editing47348 +Node: Sparse trees53950 +Ref: Sparse trees-Footnote-156460 +Ref: Sparse trees-Footnote-256571 +Node: Plain lists56642 +Ref: Plain lists-Footnote-164057 +Ref: Plain lists-Footnote-264411 +Ref: Plain lists-Footnote-364507 +Ref: Plain lists-Footnote-464754 +Ref: Plain lists-Footnote-564925 +Ref: Plain lists-Footnote-664988 +Ref: Plain lists-Footnote-765088 +Ref: Plain lists-Footnote-865190 +Node: Drawers65256 +Ref: Drawers-Footnote-167120 +Node: Blocks67256 +Node: Footnotes67815 +Ref: Footnotes-Footnote-171759 +Ref: Footnotes-Footnote-271856 +Node: Orgstruct mode71933 +Node: Org syntax73563 +Node: Tables74536 +Node: Built-in table editor75177 +Ref: Built-in table editor-Footnote-184929 +Node: Column width and alignment85029 +Ref: Column width and alignment-Footnote-187590 +Node: Column groups87687 +Node: Orgtbl mode89258 +Node: The spreadsheet90067 +Node: References91527 +Ref: References-Footnote-198245 +Ref: References-Footnote-298467 +Ref: References-Footnote-398736 +Ref: References-Footnote-498849 +Node: Formula syntax for Calc99139 +Ref: Formula syntax for Calc-Footnote-1104286 +Node: Formula syntax for Lisp104610 +Node: Durations and time values106345 +Node: Field and range formulas107423 +Node: Column formulas109820 +Node: Lookup functions111908 +Node: Editing and debugging formulas113831 +Ref: Using multiple #+TBLFM lines118092 +Ref: Editing and debugging formulas-Footnote-1119341 +Node: Updating the table119477 +Node: Advanced features120833 +Ref: Advanced features-Footnote-1125314 +Node: Org-Plot125420 +Node: Hyperlinks129614 +Node: Link format130371 +Node: Internal links131630 +Ref: Internal links-Footnote-1133925 +Ref: Internal links-Footnote-2134165 +Node: Radio targets134303 +Node: External links134970 +Ref: External links-Footnote-1138894 +Ref: External links-Footnote-2139312 +Node: Handling links139568 +Ref: Handling links-Footnote-1147432 +Ref: Handling links-Footnote-2147591 +Ref: Handling links-Footnote-3147773 +Ref: Handling links-Footnote-4148068 +Ref: Handling links-Footnote-5148314 +Ref: Handling links-Footnote-6148433 +Ref: Handling links-Footnote-7148505 +Node: Using links outside Org148589 +Node: Link abbreviations149074 +Node: Search options151843 +Ref: Search options-Footnote-1153725 +Node: Custom searches153806 +Node: TODO items154816 +Ref: TODO items-Footnote-1155924 +Node: TODO basics156038 +Node: TODO extensions158862 +Node: Workflow states159892 +Ref: Workflow states-Footnote-1161193 +Node: TODO types161286 +Ref: TODO types-Footnote-1162884 +Node: Multiple sets in one file162953 +Node: Fast access to TODO states164807 +Ref: Fast access to TODO states-Footnote-1165680 +Ref: Fast access to TODO states-Footnote-2165764 +Node: Per-file keywords166057 +Ref: Per-file keywords-Footnote-1167428 +Node: Faces for TODO keywords167629 +Node: TODO dependencies168670 +Node: Progress logging171005 +Node: Closing items171717 +Ref: Closing items-Footnote-1172694 +Ref: Closing items-Footnote-2172763 +Node: Tracking TODO state changes172837 +Ref: Tracking TODO state changes-Footnote-1175873 +Ref: Tracking TODO state changes-Footnote-2175928 +Ref: Tracking TODO state changes-Footnote-3176068 +Node: Tracking your habits176356 +Node: Priorities180590 +Ref: Priorities-Footnote-1182562 +Node: Breaking down tasks182631 +Ref: Breaking down tasks-Footnote-1184610 +Node: Checkboxes184706 +Ref: Checkboxes-Footnote-1189333 +Ref: Checkboxes-Footnote-2189457 +Ref: Checkboxes-Footnote-3189631 +Node: Tags189751 +Node: Tag inheritance190807 +Ref: Tag inheritance-Footnote-1192622 +Ref: Tag inheritance-Footnote-2192722 +Node: Setting tags192848 +Ref: Setting tags-Footnote-1199159 +Node: Tag hierarchy199242 +Node: Tag searches202610 +Node: Properties and columns203892 +Node: Property syntax205328 +Node: Special properties209670 +Node: Property searches211315 +Node: Property inheritance212750 +Node: Column view214566 +Node: Defining columns215801 +Node: Scope of column definitions216179 +Node: Column attributes217084 +Ref: Column attributes-Footnote-1221878 +Ref: Column attributes-Footnote-2222034 +Ref: Column attributes-Footnote-3222247 +Ref: Column attributes-Footnote-4222530 +Node: Using column view222663 +Node: Capturing column view225588 +Ref: Capturing column view-Footnote-1228665 +Node: Property API228801 +Node: Dates and times229155 +Node: Timestamps230062 +Ref: Timestamps-Footnote-1232462 +Ref: Timestamps-Footnote-2232648 +Ref: Timestamps-Footnote-3232779 +Node: Creating timestamps233548 +Node: The date/time prompt236372 +Ref: The date/time prompt-Footnote-1240954 +Ref: The date/time prompt-Footnote-2241117 +Ref: The date/time prompt-Footnote-3241223 +Node: Custom time format241317 +Node: Deadlines and scheduling243039 +Ref: Deadlines and scheduling-Footnote-1246519 +Node: Inserting deadline/schedule246674 +Ref: Inserting deadline/schedule-Footnote-1248474 +Ref: Inserting deadline/schedule-Footnote-2248582 +Node: Repeated tasks248690 +Ref: Repeated tasks-Footnote-1253093 +Ref: Repeated tasks-Footnote-2253342 +Node: Clocking work time253541 +Ref: Clocking work time-Footnote-1254726 +Ref: Clocking work time-Footnote-2254870 +Node: Clocking commands255008 +Ref: Clocking commands-Footnote-1259913 +Ref: Clocking commands-Footnote-2260020 +Ref: Clocking commands-Footnote-3260070 +Ref: Clocking commands-Footnote-4260128 +Node: The clock table260206 +Ref: The clock table-Footnote-1267741 +Ref: The clock table-Footnote-2267835 +Node: Resolving idle time267960 +Ref: Resolving idle time-Footnote-1271807 +Node: Effort estimates272275 +Ref: Effort estimates-Footnote-1275028 +Node: Timers275135 +Node: Capture - Refile - Archive277427 +Node: Capture278417 +Node: Setting up capture279485 +Ref: Setting up capture-Footnote-1279894 +Node: Using capture279960 +Node: Capture templates282368 +Node: Template elements284333 +Ref: Template elements-Footnote-1290910 +Ref: Template elements-Footnote-2291227 +Node: Template expansion291414 +Ref: Template expansion-Footnote-1295404 +Ref: Template expansion-Footnote-2295491 +Ref: Template expansion-Footnote-3295673 +Node: Templates in contexts295771 +Node: Attachments296593 +Ref: Attachments-Footnote-1300040 +Node: RSS feeds300190 +Node: Protocols301667 +Node: Refile and copy302382 +Ref: Refile and copy-Footnote-1304804 +Node: Archiving304900 +Node: Moving subtrees305600 +Node: Internal archiving307624 +Node: Agenda views310256 +Node: Agenda files312584 +Ref: Agenda files-Footnote-1315387 +Ref: Agenda files-Footnote-2315536 +Node: Agenda dispatcher315729 +Ref: Agenda dispatcher-Footnote-1318560 +Ref: Agenda dispatcher-Footnote-2318654 +Node: Built-in agenda views318756 +Node: Weekly/daily agenda319340 +Ref: Weekly/daily agenda-Footnote-1325074 +Ref: Weekly/daily agenda-Footnote-2325301 +Node: Global TODO list325476 +Node: Matching tags and properties328004 +Node: Search view334956 +Node: Stuck projects336269 +Ref: Stuck projects-Footnote-1338329 +Node: Presentation and sorting338359 +Node: Categories339316 +Node: Time-of-day specifications340045 +Node: Sorting agenda items342014 +Node: Filtering/limiting agenda items343583 +Ref: Filtering/limiting agenda items-Footnote-1350731 +Node: Agenda commands351146 +Ref: Agenda commands-Footnote-1372137 +Ref: Agenda commands-Footnote-2372218 +Ref: Agenda commands-Footnote-3372337 +Ref: Agenda commands-Footnote-4372437 +Node: Custom agenda views372520 +Node: Storing searches373161 +Ref: Storing searches-Footnote-1376113 +Ref: Storing searches-Footnote-2376230 +Node: Block agenda376478 +Node: Setting options377716 +Node: Exporting agenda views381305 +Ref: Exporting agenda views-Footnote-1386206 +Ref: Exporting agenda views-Footnote-2386264 +Ref: Exporting agenda views-Footnote-3386420 +Ref: Exporting agenda views-Footnote-4386607 +Node: Agenda column view386689 +Node: Markup389761 +Node: Paragraphs390748 +Node: Emphasis and monospace391914 +Node: Horizontal rules392756 +Node: Images and tables393007 +Node: Literal examples394714 +Ref: Literal examples-Footnote-1399223 +Ref: Literal examples-Footnote-2399756 +Ref: Literal examples-Footnote-3399925 +Ref: Literal examples-Footnote-4400104 +Ref: Literal examples-Footnote-5400354 +Node: Special symbols400448 +Ref: Special symbols-Footnote-1402377 +Ref: Special symbols-Footnote-2402532 +Node: Subscripts and superscripts402622 +Node: Embedded LaTeX403726 +Ref: Embedded LaTeX-Footnote-1404540 +Node: LaTeX fragments404730 +Ref: LaTeX fragments-Footnote-1406810 +Node: Previewing LaTeX fragments407033 +Ref: Previewing LaTeX fragments-Footnote-1408462 +Node: CDLaTeX mode408708 +Ref: CDLaTeX mode-Footnote-1411208 +Node: Exporting411356 +Ref: Exporting-Footnote-1413935 +Node: The export dispatcher414045 +Ref: The export dispatcher-Footnote-1416084 +Node: Export settings416347 +Ref: Export settings-Footnote-1423891 +Ref: Export settings-Footnote-2423989 +Ref: Export settings-Footnote-3424091 +Ref: Export settings-Footnote-4424186 +Node: Table of contents424229 +Ref: Table of contents-Footnote-1425980 +Node: Include files426178 +Ref: Include files-Footnote-1429099 +Ref: Include files-Footnote-2429249 +Node: Macro replacement429415 +Ref: Macro replacement-Footnote-1431666 +Node: Comment lines431896 +Ref: Comment lines-Footnote-1432702 +Node: ASCII/Latin-1/UTF-8 export432802 +Node: Beamer export435580 +Node: Beamer export commands436338 +Node: Beamer specific export settings437013 +Node: Sectioning Frames and Blocks in Beamer438797 +Ref: Sectioning Frames and Blocks in Beamer-Footnote-1441753 +Ref: Sectioning Frames and Blocks in Beamer-Footnote-2441916 +Node: Beamer specific syntax442034 +Node: Editing support443665 +Node: A Beamer Example444096 +Node: HTML export445374 +Node: HTML Export commands446518 +Node: HTML Specific export settings447064 +Node: HTML doctypes448849 +Node: HTML preamble and postamble451063 +Node: Quoting HTML tags452111 +Node: Links in HTML export452750 +Node: Tables in HTML export453961 +Node: Images in HTML export455397 +Ref: Images in HTML export-Footnote-1456687 +Node: Math formatting in HTML export456742 +Ref: Math formatting in HTML export-Footnote-1458133 +Node: Text areas in HTML export458393 +Node: CSS support459175 +Ref: CSS support-Footnote-1462347 +Ref: CSS support-Footnote-2462519 +Node: JavaScript support462761 +Node: LaTeX export466142 +Ref: LaTeX export-Footnote-1467428 +Node: LaTeX export commands467672 +Ref: LaTeX export commands-Footnote-1468774 +Node: LaTeX specific export settings468980 +Node: LaTeX header and sectioning471152 +Ref: LaTeX header and sectioning-Footnote-1472785 +Ref: LaTeX header and sectioning-Footnote-2472897 +Node: Quoting LaTeX code473060 +Node: Tables in LaTeX export473660 +Ref: Tables in LaTeX export-Footnote-1477270 +Ref: Tables in LaTeX export-Footnote-2477348 +Ref: Tables in LaTeX export-Footnote-3477422 +Node: Images in LaTeX export477506 +Ref: Images in LaTeX export-Footnote-1480122 +Node: Plain lists in LaTeX export480276 +Node: Source blocks in LaTeX export481392 +Node: Example blocks in LaTeX export482789 +Node: Special blocks in LaTeX export483425 +Node: Horizontal rules in LaTeX export484606 +Node: Markdown export484995 +Ref: Markdown export-Footnote-1486293 +Node: OpenDocument Text export486379 +Ref: OpenDocument Text export-Footnote-1487570 +Node: Pre-requisites for ODT export487714 +Node: ODT export commands488042 +Ref: x-export-to-odt488246 +Ref: ODT export commands-Footnote-1489245 +Ref: ODT export commands-Footnote-2489305 +Node: ODT specific export settings489356 +Node: Extending ODT export490198 +Ref: x-export-to-other-formats491186 +Ref: x-convert-to-other-formats491696 +Node: Applying custom styles492153 +Node: Links in ODT export494277 +Node: Tables in ODT export494924 +Ref: Tables in ODT export-Footnote-1497060 +Node: Images in ODT export497153 +Ref: Images in ODT export-Footnote-1499879 +Node: Math formatting in ODT export500112 +Node: Working with LaTeX math snippets500576 +Ref: Working with LaTeX math snippets-Footnote-1502795 +Ref: Working with LaTeX math snippets-Footnote-2502871 +Node: Working with MathML or OpenDocument formula files502916 +Node: Labels and captions in ODT export503470 +Node: Literal examples in ODT export504928 +Node: Advanced topics in ODT export505792 +Node: Configuring a document converter506548 +Ref: x-odt-converter-capabilities507320 +Node: Working with OpenDocument style files507901 +Ref: x-factory-styles508377 +Ref: x-orgodtstyles-xml508615 +Ref: x-orgodtcontenttemplate-xml508942 +Ref: x-overriding-factory-styles509598 +Ref: x-org-odt-styles-file509878 +Ref: x-org-odt-content-template-file510759 +Node: Creating one-off styles510900 +Node: Customizing tables in ODT export513121 +Ref: Customizing tables in ODT export-Footnote-1518098 +Ref: Customizing tables in ODT export-Footnote-2518202 +Ref: Customizing tables in ODT export-Footnote-3518290 +Node: Validating OpenDocument XML518605 +Ref: Validating OpenDocument XML-Footnote-1519604 +Node: Org export519656 +Node: Texinfo export520420 +Node: Texinfo export commands521520 +Ref: Texinfo export commands-Footnote-1522055 +Node: Texinfo specific export settings522163 +Node: Texinfo file header523197 +Ref: Texinfo file header-Footnote-1524199 +Node: Texinfo title and copyright page524261 +Node: Texinfo `Top' node525734 +Node: Headings and sectioning structure526473 +Node: Indices527928 +Node: Quoting Texinfo code528721 +Node: Plain lists in Texinfo export529213 +Ref: Plain lists in Texinfo export-Footnote-1529969 +Node: Tables in Texinfo export530035 +Node: Images in Texinfo export530497 +Node: Special blocks in Texinfo export530993 +Node: A Texinfo example531569 +Node: iCalendar export533588 +Ref: iCalendar export-Footnote-1536320 +Ref: iCalendar export-Footnote-2536410 +Ref: iCalendar export-Footnote-3536510 +Node: Other built-in back-ends536647 +Node: Advanced configuration537237 +Node: Export in foreign buffers544212 +Node: Publishing545169 +Node: Configuration546037 +Node: Project alist546800 +Node: Sources and destinations547941 +Node: Selecting files549464 +Node: Publishing action550465 +Ref: Publishing action-Footnote-1552294 +Node: Publishing options552451 +Node: Publishing links565601 +Node: Sitemap566953 +Node: Generating an index570681 +Node: Uploading files571463 +Node: Sample configuration573227 +Node: Simple example573716 +Node: Complex example574363 +Node: Triggering publication576414 +Node: Working with source code577410 +Node: Structure of code blocks581860 +Node: Editing source code584347 +Node: Exporting code blocks587106 +Node: Extracting source code589711 +Node: Evaluating code blocks592155 +Ref: Evaluating code blocks-Footnote-1595276 +Ref: Evaluating code blocks-Footnote-2595402 +Node: Library of Babel595588 +Node: Languages596267 +Node: Header arguments598664 +Node: Using header arguments599021 +Node: System-wide header arguments599827 +Node: Language-specific header arguments600522 +Node: Header arguments in Org mode properties601042 +Node: Language-specific mode properties602485 +Node: Code block specific header arguments603305 +Node: Arguments in function calls604956 +Node: Specific header arguments605716 +Node: var608398 +Node: results614980 +Node: file618879 +Node: file-desc619544 +Node: file-ext619942 +Node: output-dir620359 +Node: dir620757 +Node: exports622878 +Node: tangle623750 +Node: mkdirp624595 +Node: comments624909 +Node: padline625865 +Node: no-expand626256 +Node: session626968 +Node: noweb628045 +Node: noweb-ref629843 +Node: noweb-sep630931 +Node: cache631235 +Node: sep633833 +Node: hlines634224 +Node: colnames635706 +Node: rownames637110 +Node: shebang638299 +Node: tangle-mode638777 +Node: eval639561 +Node: wrap640545 +Node: post640852 +Node: prologue642587 +Node: epilogue643083 +Node: Results of evaluation643341 +Node: Noweb reference syntax647062 +Node: Key bindings and useful functions648582 +Node: Batch execution650621 +Node: Miscellaneous651659 +Node: Completion652498 +Node: Easy templates654541 +Node: Speed keys655726 +Node: Code evaluation security656734 +Node: Customization659539 +Node: In-buffer settings659965 +Node: The very busy C-c C-c key669192 +Node: Clean view671023 +Ref: Clean view-Footnote-1674422 +Ref: Clean view-Footnote-2674645 +Ref: Clean view-Footnote-3674700 +Node: TTY keys674772 +Node: Interaction676197 +Node: Cooperation676594 +Node: Conflicts679313 +Node: org-crypt683822 +Node: Hacking685074 +Node: Hooks686060 +Node: Add-on packages686378 +Node: Adding hyperlink types686906 +Node: Adding export back-ends690267 +Node: Context-sensitive commands691487 +Node: Tables in arbitrary syntax692168 +Node: Radio tables693831 +Node: A LaTeX example695904 +Ref: A LaTeX example-Footnote-1699617 +Ref: A LaTeX example-Footnote-2699783 +Node: Translator functions700218 +Node: Radio lists702324 +Node: Dynamic blocks703474 +Node: Special agenda views705520 +Ref: x-agenda-skip-entry-regexp708345 +Ref: Special agenda views-Footnote-1709110 +Ref: Special agenda views-Footnote-2709305 +Node: Speeding up your agendas709433 +Node: Extracting agenda information710477 +Node: Using the property API714301 +Node: Using the mapping API717626 +Node: MobileOrg721593 +Node: Setting up the staging area723153 +Ref: Setting up the staging area-Footnote-1724355 +Ref: Setting up the staging area-Footnote-2724524 +Node: Pushing to MobileOrg724731 +Ref: Pushing to MobileOrg-Footnote-1725610 +Ref: Pushing to MobileOrg-Footnote-2725696 +Ref: Pushing to MobileOrg-Footnote-3726055 +Node: Pulling from MobileOrg726127 +Ref: Pulling from MobileOrg-Footnote-1728147 +Node: History and acknowledgments728207 +Node: GNU Free Documentation License743392 +Node: Main Index768582 +Node: Key Index859819 +Node: Command and Function Index912407 +Node: Variable Index947358  End Tag Table diff --git a/elpa/org-plus-contrib-20150831/org-agenda.el b/elpa/org-plus-contrib-20170407/org-agenda.el similarity index 86% rename from elpa/org-plus-contrib-20150831/org-agenda.el rename to elpa/org-plus-contrib-20170407/org-agenda.el index 0d562353..8a590ce2 100644 --- a/elpa/org-plus-contrib-20150831/org-agenda.el +++ b/elpa/org-plus-contrib-20170407/org-agenda.el @@ -1,6 +1,6 @@ ;;; org-agenda.el --- Dynamic task and appointment lists for Org -;; Copyright (C) 2004-2015 Free Software Foundation, Inc. +;; Copyright (C) 2004-2017 Free Software Foundation, Inc. ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp @@ -24,7 +24,7 @@ ;; ;;; Commentary: -;; This file contains the code for creating and using the Agenda for Org-mode. +;; This file contains the code for creating and using the Agenda for Org. ;; ;; The functions `org-batch-agenda', `org-batch-agenda-csv', and ;; `org-batch-store-agenda-views' are implemented as macros to provide @@ -45,10 +45,9 @@ ;;; Code: +(require 'cl-lib) (require 'org) (require 'org-macs) -(eval-when-compile - (require 'cl)) (declare-function diary-add-to-list "diary-lib" (date string specifier &optional marker globcolor literal)) @@ -80,16 +79,15 @@ (declare-function org-is-habit-p "org-habit" (&optional pom)) (declare-function org-habit-parse-todo "org-habit" (&optional pom)) (declare-function org-habit-get-priority "org-habit" (habit &optional moment)) -(declare-function org-pop-to-buffer-same-window "org-compat" - (&optional buffer-or-name norecord label)) (declare-function org-agenda-columns "org-colview" ()) (declare-function org-add-archive-files "org-archive" (files)) (declare-function org-capture "org-capture" (&optional goto keys)) -(defvar calendar-mode-map) ; defined in calendar.el -(defvar org-clock-current-task nil) ; defined in org-clock.el -(defvar org-mobile-force-id-on-agenda-items) ; defined in org-mobile.el -(defvar org-habit-show-habits) ; defined in org-habit.el +(defvar calendar-mode-map) +(defvar org-clock-current-task) +(defvar org-current-tag-alist) +(defvar org-mobile-force-id-on-agenda-items) +(defvar org-habit-show-habits) (defvar org-habit-show-habits-only-for-today) (defvar org-habit-show-all-today) @@ -97,8 +95,8 @@ (defvar org-agenda-buffer-name "*Org Agenda*") (defvar org-agenda-overriding-header nil) (defvar org-agenda-title-append nil) -(org-no-warnings (defvar entry)) ;; unprefixed, from calendar.el -(org-no-warnings (defvar date)) ;; unprefixed, from calendar.el +(with-no-warnings (defvar entry)) ;; unprefixed, from calendar.el +(with-no-warnings (defvar date)) ;; unprefixed, from calendar.el (defvar original-date) ; dynamically scoped, calendar.el does scope this (defvar org-agenda-undo-list nil @@ -136,7 +134,7 @@ addresses the separator between the current and the previous block." (string))) (defgroup org-agenda-export nil - "Options concerning exporting agenda views in Org-mode." + "Options concerning exporting agenda views in Org mode." :tag "Org Agenda Export" :group 'org-agenda) @@ -153,7 +151,7 @@ before assigned to the variables. So make sure to quote values you do *not* want evaluated, for example (setq org-agenda-exporter-settings - '((ps-print-color-p 'black-white)))" + \\='((ps-print-color-p \\='black-white)))" :group 'org-agenda-export :type '(repeat (list @@ -238,7 +236,7 @@ you can \"misuse\" it to also add other text to the header." :type 'boolean) (defgroup org-agenda-custom-commands nil - "Options concerning agenda views in Org-mode." + "Options concerning agenda views in Org mode." :tag "Org Agenda Custom Commands" :group 'org-agenda) @@ -262,8 +260,8 @@ 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'. -(org-defvaralias 'org-agenda-filter-preset 'org-agenda-tag-filter-preset) -(org-defvaralias 'org-agenda-filter 'org-agenda-tag-filter) +(defvaralias 'org-agenda-filter-preset 'org-agenda-tag-filter-preset) +(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. @@ -440,10 +438,11 @@ This will be spliced into the custom type of (defcustom org-agenda-custom-commands - '(("n" "Agenda and all TODO's" ((agenda "") (alltodo "")))) + '(("n" "Agenda and all TODOs" ((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: +agenda dispatcher `\\[org-agenda]'. Each entry is a list like this: (key desc type match settings files) @@ -470,8 +469,8 @@ match What to search for: settings A list of option settings, similar to that in a let form, so like this: ((opt1 val1) (opt2 val2) ...). The values will be evaluated at the moment of execution, so quote them when needed. -files A list of files file to write the produced agenda buffer to - with the command `org-store-agenda-views'. +files A list of files to write the produced agenda buffer to with + the command `org-store-agenda-views'. If a file name ends in \".html\", an HTML version of the buffer is written out. If it ends in \".ps\", a postscript version is produced. Otherwise, only the plain text is written to the file. @@ -504,7 +503,7 @@ are prefix commands. For the dispatcher to display useful information, you should provide a description for the prefix, like (setq org-agenda-custom-commands - '((\"h\" . \"HOME + Name tag searches\") ; describe prefix \"h\" + \\='((\"h\" . \"HOME + Name tag searches\") ; describe prefix \"h\" (\"hl\" tags \"+HOME+Lisa\") (\"hp\" tags \"+HOME+Peter\") (\"hk\" tags \"+HOME+Kim\")))" @@ -608,14 +607,17 @@ subtree to see if any of the subtasks have project status. See also the variable `org-tags-match-list-sublevels' which applies to projects matched by this search as well. -After defining this variable, you may use \\[org-agenda-list-stuck-projects] -or `C-c a #' to produce the list." +After defining this variable, you may use `\\[org-agenda-list-stuck-projects]' +\(bound to `C-c a #') to produce the list." :group 'org-agenda-custom-commands :type '(list (string :tag "Tags/TODO match to identify a project") - (repeat :tag "Projects are *not* stuck if they have an entry with TODO keyword any of" (string)) - (repeat :tag "Projects are *not* stuck if they have an entry with TAG being any of" (string)) - (regexp :tag "Projects are *not* stuck if this regexp matches inside the subtree"))) + (repeat :tag "Projects are *not* stuck if they have an entry with \ +TODO keyword any of" (string)) + (repeat :tag "Projects are *not* stuck if they have an entry with \ +TAG being any of" (string)) + (regexp :tag "Projects are *not* stuck if this regexp matches inside \ +the subtree"))) (defgroup org-agenda-skip nil "Options concerning skipping parts of agenda files." @@ -767,10 +769,12 @@ to make his option also apply to the tags-todo list." (defcustom org-agenda-todo-ignore-deadlines nil "Non-nil means ignore some deadline TODO items when making TODO list. + There are different motivations for using different values, please think carefully when configuring this variable. -This applies when creating the global todo list. +This applies when creating the global TODO list. + Valid values are: near Don't show near deadline entries. A deadline is near when it is @@ -778,8 +782,8 @@ near Don't show near deadline entries. A deadline is near when it is is that such items will appear in the agenda anyway. far Don't show TODO entries where a deadline has been defined, but - the deadline is not near. This is useful if you don't want to - use the todo list to figure out what to do now. + is not going to happen anytime soon. This is useful if you want to use + the TODO list to figure out what to do now. past Don't show entries with a deadline timestamp for today or in the past. @@ -840,10 +844,9 @@ restricted to unfinished TODO entries only." (defcustom org-agenda-skip-scheduled-if-done nil "Non-nil means don't show scheduled items in agenda when they are done. -This is relevant for the daily/weekly agenda, not for the TODO list. And -it applies only to the actual date of the scheduling. Warnings about -an item with a past scheduling dates are always turned off when the item -is DONE." +This is relevant for the daily/weekly agenda, not for the TODO list. It +applies only to the actual date of the scheduling. Warnings about an item +with a past scheduling dates are always turned off when the item is DONE." :group 'org-agenda-skip :group 'org-agenda-daily/weekly :type 'boolean) @@ -892,8 +895,8 @@ several times." (defcustom org-agenda-skip-deadline-if-done nil "Non-nil means don't show deadlines when the corresponding item is done. When nil, the deadline is still shown and should give you a happy feeling. -This is relevant for the daily/weekly agenda. And it applied only to the -actually date of the deadline. Warnings about approaching and past-due +This is relevant for the daily/weekly agenda. It applies only to the +actual date of the deadline. Warnings about approaching and past-due deadlines are always turned off when the item is DONE." :group 'org-agenda-skip :group 'org-agenda-daily/weekly @@ -972,18 +975,6 @@ will only be dimmed." (const :tag "Dim to a gray face" t) (const :tag "Make invisible" invisible))) -(defcustom org-timeline-show-empty-dates 3 - "Non-nil means `org-timeline' also shows dates without an entry. -When nil, only the days which actually have entries are shown. -When t, all days between the first and the last date are shown. -When an integer, show also empty dates, but if there is a gap of more than -N days, just insert a special line indicating the size of the gap." - :group 'org-agenda-skip - :type '(choice - (const :tag "None" nil) - (const :tag "All" t) - (integer :tag "at most"))) - (defgroup org-agenda-startup nil "Options concerning initial settings in the Agenda in Org Mode." :tag "Org Agenda Startup" @@ -999,8 +990,6 @@ you want to use two-columns display (see `org-agenda-menu-two-columns')." :version "24.1" :type 'boolean) -(define-obsolete-variable-alias 'org-agenda-menu-two-column 'org-agenda-menu-two-columns "24.3") - (defcustom org-agenda-menu-two-columns nil "Non-nil means, use two columns to show custom commands in the dispatcher. If you use this, you probably want to set `org-agenda-menu-show-matcher' @@ -1009,7 +998,6 @@ to nil." :version "24.1" :type 'boolean) -(define-obsolete-variable-alias 'org-finalize-agenda-hook 'org-agenda-finalize-hook "24.3") (defcustom org-agenda-finalize-hook nil "Hook run just before displaying an agenda buffer. The buffer is still writable when the hook is called. @@ -1022,8 +1010,8 @@ headlines as the agenda display heavily relies on them." (defcustom org-agenda-mouse-1-follows-link nil "Non-nil means mouse-1 on a link will follow the link in the agenda. -A longer mouse click will still set point. Does not work on XEmacs. -Needs to be set before org.el is loaded." +A longer mouse click will still set point. Needs to be set +before org.el is loaded." :group 'org-agenda-startup :type 'boolean) @@ -1052,9 +1040,9 @@ current item's tree, in an indirect buffer." (defcustom org-agenda-entry-text-maxlines 5 "Number of text lines to be added when `E' is pressed in the agenda. -Note that this variable only used during agenda display. Add add entry text +Note that this variable only used during agenda display. To add entry text when exporting the agenda, configure the variable -`org-agenda-add-entry-ext-maxlines'." +`org-agenda-add-entry-text-maxlines'." :group 'org-agenda :type 'integer) @@ -1126,16 +1114,6 @@ option will be ignored." :group 'org-agenda-windows :type 'boolean) -(defcustom org-agenda-ndays nil - "Number of days to include in overview display. -Should be 1 or 7. -Obsolete, see `org-agenda-span'." - :group 'org-agenda-daily/weekly - :type '(choice (const nil) - (integer))) - -(make-obsolete-variable 'org-agenda-ndays 'org-agenda-span "24.1") - (defcustom org-agenda-span 'week "Number of days to include in overview display. Can be day, week, month, year, or any number of days. @@ -1211,7 +1189,7 @@ For example, 9:30am would become 09:30 rather than 9:30." :type 'boolean) (defun org-agenda-time-of-day-to-ampm (time) - "Convert TIME of a string like '13:45' to an AM/PM style time string." + "Convert TIME of a string like \"13:45\" to an AM/PM style time string." (let* ((hour-number (string-to-number (substring time 0 -3))) (minute (substring time -2)) (ampm "am")) @@ -1270,34 +1248,74 @@ Custom commands can set this variable in the options section." :version "24.1" :type 'boolean) -(defcustom org-agenda-repeating-timestamp-show-all t - "Non-nil means show all occurrences of a repeating stamp in the agenda. -When set to a list of strings, only show occurrences of repeating -stamps for these TODO keywords. When nil, only one occurrence is -shown, either today or the nearest into the future." +(defcustom org-agenda-show-future-repeats t + "Non-nil shows repeated entries in the future part of the agenda. +When set to the symbol `next' only the first future repeat is shown." + :group 'org-agenda-daily/weekly + :type '(choice + (const :tag "Show all repeated entries" t) + (const :tag "Show next repeated entry" next) + (const :tag "Do not show repeated entries" nil)) + :version "26.1" + :package-version '(Org . "9.1") + :safe #'symbolp) + +(defcustom org-agenda-prefer-last-repeat nil + "Non-nil sets date for repeated entries to their last repeat. + +When nil, display SCHEDULED and DEADLINE dates at their base +date, and in today's agenda, as a reminder. Display plain +time-stamps, on the other hand, at every repeat date in the past +in addition to the base date. + +When non-nil, show a repeated entry at its latest repeat date, +possibly being today even if it wasn't marked as done. This +setting is useful if you do not always mark repeated entries as +done and, yet, consider that reaching repeat date starts the task +anew. + +When set to a list of strings, prefer last repeats only for +entries with these TODO keywords." :group 'org-agenda-daily/weekly :type '(choice - (const :tag "Show repeating stamps" t) - (repeat :tag "Show repeating stamps for these TODO keywords" - (string :tag "TODO Keyword")) - (const :tag "Don't show repeating stamps" nil))) + (const :tag "Prefer last repeat" t) + (const :tag "Prefer base date" nil) + (repeat :tag "Prefer last repeat for entries with these TODO keywords" + (string :tag "TODO keyword"))) + :version "26.1" + :package-version '(Org . "9.1") + :safe (lambda (x) (or (booleanp x) (consp x)))) (defcustom org-scheduled-past-days 10000 "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." +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 or for the +number of days given here." :group 'org-agenda-daily/weekly - :type 'integer) + :type 'integer + :safe 'integerp) + +(defcustom org-deadline-past-days 10000 + "Number of days to warn about missed deadlines. +When an item has deadline on a date, it shows up in the agenda on +this day and will appear as a reminder until it is marked DONE or +for the number of days given here." + :group 'org-agenda-daily/weekly + :type 'integer + :version "26.1" + :package-version '(Org . "9.1") + :safe 'integerp) (defcustom org-agenda-log-mode-items '(closed clock) "List of items that should be shown in agenda log mode. +\\\ This list may contain the following symbols: closed Show entries that have been closed on that day. clock Show entries that have received clocked time on that day. state Show all logged state changes. -Note that instead of changing this variable, you can also press `C-u l' in +Note that instead of changing this variable, you can also press \ +`\\[universal-argument] \\[org-agenda-log-mode]' in the agenda to display all available LOG items temporarily." :group 'org-agenda-daily/weekly :type '(set :greedy t (const closed) (const clock) (const state))) @@ -1413,7 +1431,7 @@ boolean search." :version "24.1" :type 'boolean) -(org-defvaralias 'org-agenda-search-view-search-words-only +(defvaralias 'org-agenda-search-view-search-words-only 'org-agenda-search-view-always-boolean) (defcustom org-agenda-search-view-force-full-words nil @@ -1434,7 +1452,7 @@ value, don't limit agenda view by outline level." :type 'integer) (defgroup org-agenda-time-grid nil - "Options concerning the time grid in the Org-mode Agenda." + "Options concerning the time grid in the Org Agenda." :tag "Org Agenda Time Grid" :group 'org-agenda) @@ -1506,7 +1524,7 @@ a grid line." :type 'string) (defgroup org-agenda-sorting nil - "Options concerning sorting in the Org-mode Agenda." + "Options concerning sorting in the Org Agenda." :tag "Org Agenda Sorting" :group 'org-agenda) @@ -1612,7 +1630,7 @@ When nil, such items are sorted as 0 minutes effort." :type 'boolean) (defgroup org-agenda-line-format nil - "Options concerning the entry prefix in the Org-mode agenda display." + "Options concerning the entry prefix in the Org agenda display." :tag "Org Agenda Line Format" :group 'org-agenda) @@ -1792,17 +1810,18 @@ When non-nil, this must be the number of minutes, e.g. 60 for one hour." (defcustom org-agenda-show-inherited-tags t "Non-nil means show inherited tags in each agenda line. -When this option is set to 'always, it take precedences over +When this option is set to `always', it take precedences over `org-agenda-use-tag-inheritance' and inherited tags are shown in every agenda. When this option is set to t (the default), inherited tags are shown when they are available, i.e. when the value of -`org-agenda-use-tag-inheritance' has been taken into account. +`org-agenda-use-tag-inheritance' enables tag inheritance for the +given agenda type. This can be set to a list of agenda types in which the agenda -must display the inherited tags. Available types are 'todo, -'agenda, 'search and 'timeline. +must display the inherited tags. Available types are `todo', +`agenda', `search' and `timeline'. When set to nil, never show inherited tags in agenda lines." :group 'org-agenda-line-format @@ -1823,10 +1842,10 @@ controlled by `org-use-tag-inheritance'. In other agenda types, agenda entries. Still, you may want the agenda to be aware of the inherited tags anyway, e.g. for later tag filtering. -Allowed value are 'todo, 'search, 'timeline and 'agenda. +Allowed value are `todo', `search', `timeline' and `agenda'. This variable has no effect if `org-agenda-show-inherited-tags' -is set to 'always. In that case, the agenda is aware of those +is set to `always'. In that case, the agenda is aware of those tags. The default value sets tags in every agenda type. Setting this @@ -1858,10 +1877,10 @@ When this is the symbol `prefix', only remove tags when (const :tag "Never" nil) (const :tag "When prefix format contains %T" prefix))) -(org-defvaralias 'org-agenda-remove-tags-when-in-prefix +(defvaralias 'org-agenda-remove-tags-when-in-prefix 'org-agenda-remove-tags) -(defcustom org-agenda-tags-column (if (featurep 'xemacs) -79 -80) +(defcustom org-agenda-tags-column -80 "Shift tags in agenda items to this column. If this number is positive, it specifies the column. If it is negative, it means that the tags should be flushright to that column. For example, @@ -1869,7 +1888,7 @@ it means that the tags should be flushright to that column. For example, :group 'org-agenda-line-format :type 'integer) -(org-defvaralias 'org-agenda-align-tags-to-column 'org-agenda-tags-column) +(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. @@ -1932,7 +1951,7 @@ list as second element: For example, to display a 16px horizontal space for Emacs category, you can use: - (\"Emacs\" '(space . (:width (16))))" + (\"Emacs\" \\='(space . (:width (16))))" :group 'org-agenda-line-format :version "24.1" :type '(alist :key-type (string :tag "Regexp matching category") @@ -1948,6 +1967,14 @@ category, you can use: :tag "Org Agenda Column View" :group 'org-agenda) +(defcustom org-agenda-view-columns-initially nil + "When non-nil, switch to columns view right after creating the agenda." + :group 'org-agenda-column-view + :type 'boolean + :version "26.1" + :package-version '(Org . "9.0") + :safe #'booleanp) + (defcustom org-agenda-columns-show-summaries t "Non-nil means show summaries for columns displayed in the agenda view." :group 'org-agenda-column-view @@ -1975,7 +2002,8 @@ estimate." :type 'boolean) (defcustom org-agenda-auto-exclude-function nil - "A function called with a tag to decide if it is filtered on '/ RET'. + "A function called with a tag to decide if it is filtered on \ +\\`\\[org-agenda-filter-by-tag] RET'. The sole argument to the function, which is called once for each possible tag, is a string giving the name of the tag. The function should return either nil if the tag should be included @@ -1990,13 +2018,13 @@ the lower-case version of all tags." "Alist of characters and custom functions for bulk actions. For example, this value makes those two functions available: - '((?R set-category) + \\='((?R set-category) (?C bulk-cut)) With selected entries in an agenda buffer, `B R' will call the custom function `set-category' on the selected entries. Note that functions in this alist don't need to be quoted." - :type 'alist + :type '(alist :key-type character :value-type (group function)) :version "24.1" :group 'org-agenda) @@ -2006,7 +2034,7 @@ If STRING is non-nil, the text property will be fetched from position 0 in that string. If STRING is nil, it will be fetched from the beginning of the current line." (org-with-gensyms (marker) - `(let ((,marker (get-text-property (if string 0 (point-at-bol)) + `(let ((,marker (get-text-property (if ,string 0 (point-at-bol)) 'org-hd-marker ,string))) (with-current-buffer (marker-buffer ,marker) (save-excursion @@ -2027,7 +2055,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'.") -(org-defvaralias 'org-agenda-keymap 'org-agenda-mode-map) +(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. @@ -2044,6 +2072,8 @@ The buffer is still writable when this hook is called.") (defvar org-agenda-force-single-file nil) (defvar org-agenda-bulk-marked-entries nil "List of markers that refer to marked entries in the agenda.") +(defvar org-agenda-current-date nil + "Active date when building the agenda.") ;;; Multiple agenda buffers support @@ -2064,12 +2094,12 @@ When nil, `q' will kill the single agenda buffer." (> (prefix-numeric-value arg) 0) (not org-agenda-sticky)))) (if (equal new-value org-agenda-sticky) - (and (org-called-interactively-p 'interactive) + (and (called-interactively-p 'interactive) (message "Sticky agenda was already %s" (if org-agenda-sticky "enabled" "disabled"))) (setq org-agenda-sticky new-value) (org-agenda-kill-all-agenda-buffers) - (and (org-called-interactively-p 'interactive) + (and (called-interactively-p 'interactive) (message "Sticky agenda %s" (if org-agenda-sticky "enabled" "disabled")))))) @@ -2114,7 +2144,7 @@ When nil, `q' will kill the single agenda buffer." "Variables that must be local in agenda buffers to allow multiple buffers.") (defun org-agenda-mode () - "Mode for time-sorted view on action items in Org-mode files. + "Mode for time-sorted view on action items in Org files. The following commands are available: @@ -2134,32 +2164,32 @@ The following commands are available: (when (and val (member var org-agenda-local-vars)) (set var val))))) - (set (make-local-variable 'org-agenda-this-buffer-is-sticky) t)) + (setq-local org-agenda-this-buffer-is-sticky t)) (org-agenda-sticky ;; Creating a sticky Agenda buffer for the first time (kill-all-local-variables) (mapc 'make-local-variable org-agenda-local-vars) - (set (make-local-variable 'org-agenda-this-buffer-is-sticky) t)) + (setq-local org-agenda-this-buffer-is-sticky t)) (t ;; Creating a non-sticky agenda buffer (kill-all-local-variables) - (set (make-local-variable 'org-agenda-this-buffer-is-sticky) nil))) + (setq-local org-agenda-this-buffer-is-sticky nil))) (setq org-agenda-undo-list nil org-agenda-pending-undo-list nil org-agenda-bulk-marked-entries nil) (setq major-mode 'org-agenda-mode) ;; Keep global-font-lock-mode from turning on font-lock-mode - (org-set-local 'font-lock-global-modes (list 'not major-mode)) + (setq-local font-lock-global-modes (list 'not major-mode)) (setq mode-name "Org-Agenda") (setq indent-tabs-mode nil) (use-local-map org-agenda-mode-map) (easy-menu-add org-agenda-menu) (if org-startup-truncated (setq truncate-lines t)) - (org-set-local 'line-move-visual nil) - (org-add-hook 'post-command-hook 'org-agenda-update-agenda-type nil 'local) - (org-add-hook 'pre-command-hook 'org-unhighlight nil 'local) + (setq-local line-move-visual nil) + (add-hook 'post-command-hook 'org-agenda-update-agenda-type nil 'local) + (add-hook 'pre-command-hook 'org-unhighlight nil 'local) ;; Make sure properties are removed when copying text - (org-add-hook 'filter-buffer-substring-functions + (add-hook 'filter-buffer-substring-functions (lambda (fun start end delete) (substring-no-properties (funcall fun start end delete))) nil t) @@ -2307,6 +2337,7 @@ The following commands are available: (org-defkey org-agenda-mode-map "b" 'org-agenda-earlier) (org-defkey org-agenda-mode-map "\C-c\C-x\C-c" 'org-agenda-columns) (org-defkey org-agenda-mode-map "\C-c\C-x>" 'org-agenda-remove-restriction-lock) +(org-defkey org-agenda-mode-map "\C-c\C-x<" 'org-agenda-set-restriction-lock-from-agenda) (org-defkey org-agenda-mode-map "[" 'org-agenda-manipulate-query-add) (org-defkey org-agenda-mode-map "]" 'org-agenda-manipulate-query-subtract) @@ -2316,7 +2347,6 @@ The following commands are available: (org-defkey org-agenda-mode-map "_" 'org-agenda-filter-by-effort) (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-headline) @@ -2355,7 +2385,7 @@ The following commands are available: ["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"] + :keys "v t"] ["Month View" org-agenda-month-view :active (org-agenda-check-type nil 'agenda) :style radio :selected (eq org-agenda-current-span 'month) @@ -2396,7 +2426,7 @@ The following commands are available: ["Remove Restriction" org-agenda-remove-restriction-lock org-agenda-restrict]) ["Write view to file" org-agenda-write t] ["Rebuild buffer" org-agenda-redo t] - ["Save all Org-mode Buffers" org-save-all-org-buffers t] + ["Save all Org buffers" org-save-all-org-buffers t] "--" ["Show original entry" org-agenda-show t] ["Go To (other window)" org-agenda-goto t] @@ -2547,7 +2577,7 @@ For example, if you have a custom agenda command \"p\" and you want this command to be accessible only from plain text files, use this: - '((\"p\" ((in-file . \"\\\\.txt\\\\'\")))) + \\='((\"p\" ((in-file . \"\\\\.txt\\\\'\")))) Here are the available contexts definitions: @@ -2565,7 +2595,7 @@ accessible if there is at least one valid check. You can also bind a key to another agenda custom command depending on contextual rules. - '((\"p\" \"q\" ((in-file . \"\\\\.txt\\\\'\")))) + \\='((\"p\" \"q\" ((in-file . \"\\\\.txt\\\\'\")))) Here it means: in .txt files, use \"p\" as the key for the agenda command otherwise associated with \"q\". (The command @@ -2665,6 +2695,7 @@ to limit entries to in this type." (const timeline)) (integer :tag "Max number of minutes"))))) +(defvar org-agenda-keep-restricted-file-list nil) (defvar org-keys nil) (defvar org-match nil) ;;;###autoload @@ -2680,7 +2711,6 @@ T Call `org-todo-list' to display the global todo list, select only m Call `org-tags-view' to display headlines with tags matching a condition (the user is prompted for the condition). M Like `m', but select only TODO entries, no ordinary headlines. -L Create a timeline for the current buffer. e Export views to associated files. s Search entries for keywords. S Search entries for keywords, only with TODO keywords. @@ -2697,9 +2727,9 @@ More commands can be added by configuring the variable `org-agenda-custom-commands'. In particular, specific tags and TODO keyword searches can be pre-defined in this way. -If the current buffer is in Org-mode and visiting a file, you can also +If the current buffer is in Org mode and visiting a file, you can also first press `<' once to indicate that the agenda should be temporarily -\(until the next use of \\[org-agenda]) restricted to the current file. +\(until the next use of `\\[org-agenda]') restricted to the current file. Pressing `<' twice means to restrict to the current subtree or region \(if active)." (interactive "P") @@ -2731,7 +2761,7 @@ Pressing `<' twice means to restrict to the current subtree or region entry key type org-match lprops ans) ;; Turn off restriction unless there is an overriding one, (unless org-agenda-overriding-restriction - (unless (org-bound-and-true-p org-agenda-keep-restricted-file-list) + (unless org-agenda-keep-restricted-file-list ;; There is a request to keep the file list in place (put 'org-agenda-files 'org-restrict nil)) (setq org-agenda-restrict nil) @@ -2828,7 +2858,7 @@ Pressing `<' twice means to restrict to the current subtree or region ((equal org-keys "M") (org-call-with-arg 'org-tags-view (or arg '(4)))) ((equal org-keys "e") (call-interactively 'org-store-agenda-views)) ((equal org-keys "?") (org-tags-view nil "+FLAGGED") - (org-add-hook + (add-hook 'post-command-hook (lambda () (unless (current-message) @@ -2843,12 +2873,6 @@ Pressing `<' twice means to restrict to the current subtree or region (copy-sequence note)) nil 'face 'org-warning))))))) t t)) - ((equal org-keys "L") - (unless (derived-mode-p 'org-mode) - (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)) @@ -2898,15 +2922,15 @@ Agenda views are separated by `org-agenda-block-separator'." (erase-buffer) (insert (eval-when-compile (let ((header - "Press key for an agenda command: < Buffer, subtree/region restriction --------------------------------- > Remove restriction -a Agenda for current week or day e Export agenda views -t List of all TODO entries T Entries with special TODO kwd -m Match a TAGS/PROP/TODO query M Like m, but only TODO entries -s Search for keywords S Like s, but only TODO entries -L Timeline for current buffer # List stuck projects (!=configure) -/ Multi-occur C Configure custom agenda commands -? Find :FLAGGED: entries * Toggle sticky agenda views + "Press key for an agenda command: +-------------------------------- < Buffer, subtree/region restriction +a Agenda for current week or day > Remove restriction +t List of all TODO entries e Export agenda views +m Match a TAGS/PROP/TODO query T Entries with special TODO kwd +s Search for keywords M Like m, but only TODO entries +/ Multi-occur S Like s, but only TODO entries +? Find :FLAGGED: entries C Configure custom agenda commands +* Toggle sticky agenda views # List stuck projects (!=configure) ") (start 0)) (while (string-match @@ -2937,7 +2961,7 @@ L Timeline for current buffer # List stuck projects (!=configure) type (nth 2 entry) match (nth 3 entry)) (if (> (length key) 1) - (add-to-list 'prefixes (string-to-char key)) + (cl-pushnew (string-to-char key) prefixes :test #'equal) (setq line (format "%-4s%-14s" @@ -3043,7 +3067,7 @@ L Timeline for current buffer # List stuck projects (!=configure) (call-interactively 'org-toggle-sticky-agenda) (sit-for 2)) ((and (not restrict-ok) (memq c '(?1 ?0 ?<))) - (message "Restriction is only possible in Org-mode buffers") + (message "Restriction is only possible in Org buffers") (ding) (sit-for 1)) ((eq c ?1) (org-agenda-remove-restriction-lock 'noupdate) @@ -3101,9 +3125,9 @@ L Timeline for current buffer # List stuck projects (!=configure) match ;; The byte compiler incorrectly complains about this. Keep it! org-cmd type lprops) (while (setq org-cmd (pop cmds)) - (setq type (car org-cmd) - match (eval (nth 1 org-cmd)) - lprops (nth 2 org-cmd)) + (setq type (car org-cmd)) + (setq match (eval (nth 1 org-cmd))) + (setq lprops (nth 2 org-cmd)) (let ((org-agenda-overriding-arguments (if (eq org-agenda-overriding-cmd org-cmd) (or org-agenda-overriding-arguments @@ -3156,7 +3180,7 @@ 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) (let (org-agenda-sticky) - (if (> (length cmd-key) 2) + (if (> (length cmd-key) 1) (org-tags-view nil cmd-key) (org-agenda nil cmd-key)))) (set-buffer org-agenda-buffer-name) @@ -3244,7 +3268,7 @@ This ensures the export commands can easily use it." (setq tmp (replace-match "" t t tmp))) (when (and (setq re (plist-get props 'org-todo-regexp)) (setq re (concat "\\`\\.*" re " ?")) - (string-match re tmp)) + (let ((case-fold-search nil)) (string-match re tmp))) (plist-put props 'todo (match-string 1 tmp)) (setq tmp (replace-match "" t t tmp))) (plist-put props 'txt tmp))) @@ -3257,9 +3281,7 @@ This ensures the export commands can easily use it." ((not res) "") ((stringp res) res) (t (prin1-to-string res)))) - (while (string-match "," res) - (setq res (replace-match ";" t t res))) - (org-trim res))) + (org-trim (replace-regexp-in-string "," ";" res nil t)))) ;;;###autoload (defun org-store-agenda-views (&rest parameters) @@ -3335,23 +3357,26 @@ the agenda to write." (interactive "FWrite agenda to file: \nP") (if (or (not (file-writable-p file)) (and (file-exists-p file) - (if (org-called-interactively-p 'any) + (if (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 - (let ((bs (copy-sequence (buffer-string))) beg content) + (let ((bs (copy-sequence (buffer-string))) + (extension (file-name-extension file)) + (default-directory (file-name-directory file)) + beg content) (with-temp-buffer (rename-buffer org-agenda-write-buffer-name t) (set-buffer-modified-p nil) (insert bs) - (org-agenda-remove-marked-text 'org-filtered) + (org-agenda-remove-marked-text 'invisible 'org-filtered) (run-hooks 'org-agenda-before-write-hook) (cond - ((org-bound-and-true-p org-mobile-creating-agendas) + ((bound-and-true-p org-mobile-creating-agendas) (org-mobile-write-agenda-for-mobile file)) - ((string-match "\\.org\\'" file) + ((string= "org" extension) (let (content p m message-log-max) (goto-char (point-min)) (while (setq p (next-single-property-change (point) 'org-hd-marker nil)) @@ -3370,7 +3395,7 @@ the agenda to write." (write-file file) (kill-buffer (current-buffer)) (message "Org file written to %s" file))) - ((string-match "\\.html?\\'" file) + ((member extension '("html" "htm")) (require 'htmlize) (set-buffer (htmlize-buffer (current-buffer))) (when org-agenda-export-html-style @@ -3382,11 +3407,11 @@ the agenda to write." (write-file file) (kill-buffer (current-buffer)) (message "HTML written to %s" file)) - ((string-match "\\.ps\\'" file) + ((string= "ps" extension) (require 'ps-print) (ps-print-buffer-with-faces file) (message "Postscript written to %s" file)) - ((string-match "\\.pdf\\'" file) + ((string= "pdf" extension) (require 'ps-print) (ps-print-buffer-with-faces (concat (file-name-sans-extension file) ".ps")) @@ -3396,7 +3421,7 @@ the agenda to write." (expand-file-name file)) (delete-file (concat (file-name-sans-extension file) ".ps")) (message "PDF written to %s" file)) - ((string-match "\\.ics\\'" file) + ((string= "ics" extension) (require 'ox-icalendar) (org-icalendar-export-current-agenda (expand-file-name file))) (t @@ -3408,7 +3433,7 @@ the agenda to write." (kill-buffer (current-buffer)) (message "Plain text written to %s" file)))))))) (set-buffer (or agenda-bufname - (and (org-called-interactively-p 'any) (buffer-name)) + (and (called-interactively-p 'any) (buffer-name)) org-agenda-buffer-name))) (when open (org-open-file file))) @@ -3429,7 +3454,7 @@ This will add a maximum of `org-agenda-add-entry-text-maxlines' lines of the entry text following headings shown in the agenda. Drawers will be excluded, also the line with scheduling/deadline info." (when (and (> org-agenda-add-entry-text-maxlines 0) - (not (org-bound-and-true-p org-mobile-creating-agendas))) + (not (bound-and-true-p org-mobile-creating-agendas))) (let (m txt) (goto-char (point-min)) (while (not (eobp)) @@ -3454,85 +3479,83 @@ removed from the entry content. Currently only `planning' is allowed here." (with-current-buffer (marker-buffer marker) (if (not (derived-mode-p 'org-mode)) (setq txt "") - (save-excursion - (save-restriction - (widen) - (goto-char marker) - (end-of-line 1) - (setq txt (buffer-substring - (min (1+ (point)) (point-max)) - (progn (outline-next-heading) (point))) - drawer-re org-drawer-regexp - kwd-time-re (concat "^[ \t]*" org-keyword-time-regexp - ".*\n?")) - (with-temp-buffer - (insert txt) - (when org-agenda-add-entry-text-descriptive-links - (goto-char (point-min)) - (while (org-activate-bracket-links (point-max)) - (add-text-properties (match-beginning 0) (match-end 0) - '(face org-link)))) - (goto-char (point-min)) - (while (re-search-forward org-bracket-link-regexp (point-max) t) - (set-text-properties (match-beginning 0) (match-end 0) - nil)) - (goto-char (point-min)) - (while (re-search-forward drawer-re nil t) - (delete-region - (match-beginning 0) - (progn (re-search-forward - "^[ \t]*:END:.*\n?" nil 'move) - (point)))) - (unless (member 'planning keep) - (goto-char (point-min)) - (while (re-search-forward kwd-time-re nil t) - (replace-match ""))) - (goto-char (point-min)) - (when org-agenda-entry-text-exclude-regexps - (let ((re-list org-agenda-entry-text-exclude-regexps) re) - (while (setq re (pop re-list)) - (goto-char (point-min)) - (while (re-search-forward re nil t) - (replace-match ""))))) - (goto-char (point-max)) - (skip-chars-backward " \t\n") - (if (looking-at "[ \t\n]+\\'") (replace-match "")) - - ;; find and remove min common indentation - (goto-char (point-min)) - (untabify (point-min) (point-max)) - (setq ind (org-get-indentation)) - (while (not (eobp)) - (unless (looking-at "[ \t]*$") - (setq ind (min ind (org-get-indentation)))) - (beginning-of-line 2)) - (goto-char (point-min)) - (while (not (eobp)) - (unless (looking-at "[ \t]*$") - (move-to-column ind) - (delete-region (point-at-bol) (point))) - (beginning-of-line 2)) - - (run-hooks 'org-agenda-entry-text-cleanup-hook) - - (goto-char (point-min)) - (when indent - (while (and (not (eobp)) (re-search-forward "^" nil t)) - (replace-match indent t t))) - (goto-char (point-min)) - (while (looking-at "[ \t]*\n") (replace-match "")) - (goto-char (point-max)) - (when (> (org-current-line) - n-lines) - (org-goto-line (1+ n-lines)) - (backward-char 1)) - (setq txt (buffer-substring (point-min) (point))))))))) + (org-with-wide-buffer + (goto-char marker) + (end-of-line 1) + (setq txt (buffer-substring + (min (1+ (point)) (point-max)) + (progn (outline-next-heading) (point))) + drawer-re org-drawer-regexp + kwd-time-re (concat "^[ \t]*" org-keyword-time-regexp + ".*\n?")) + (with-temp-buffer + (insert txt) + (when org-agenda-add-entry-text-descriptive-links + (goto-char (point-min)) + (while (org-activate-bracket-links (point-max)) + (add-text-properties (match-beginning 0) (match-end 0) + '(face org-link)))) + (goto-char (point-min)) + (while (re-search-forward org-bracket-link-regexp (point-max) t) + (set-text-properties (match-beginning 0) (match-end 0) + nil)) + (goto-char (point-min)) + (while (re-search-forward drawer-re nil t) + (delete-region + (match-beginning 0) + (progn (re-search-forward + "^[ \t]*:END:.*\n?" nil 'move) + (point)))) + (unless (member 'planning keep) + (goto-char (point-min)) + (while (re-search-forward kwd-time-re nil t) + (replace-match ""))) + (goto-char (point-min)) + (when org-agenda-entry-text-exclude-regexps + (let ((re-list org-agenda-entry-text-exclude-regexps) re) + (while (setq re (pop re-list)) + (goto-char (point-min)) + (while (re-search-forward re nil t) + (replace-match ""))))) + (goto-char (point-max)) + (skip-chars-backward " \t\n") + (if (looking-at "[ \t\n]+\\'") (replace-match "")) + + ;; find and remove min common indentation + (goto-char (point-min)) + (untabify (point-min) (point-max)) + (setq ind (org-get-indentation)) + (while (not (eobp)) + (unless (looking-at "[ \t]*$") + (setq ind (min ind (org-get-indentation)))) + (beginning-of-line 2)) + (goto-char (point-min)) + (while (not (eobp)) + (unless (looking-at "[ \t]*$") + (move-to-column ind) + (delete-region (point-at-bol) (point))) + (beginning-of-line 2)) + + (run-hooks 'org-agenda-entry-text-cleanup-hook) + + (goto-char (point-min)) + (when indent + (while (and (not (eobp)) (re-search-forward "^" nil t)) + (replace-match indent t t))) + (goto-char (point-min)) + (while (looking-at "[ \t]*\n") (replace-match "")) + (goto-char (point-max)) + (when (> (org-current-line) + n-lines) + (org-goto-line (1+ n-lines)) + (backward-char 1)) + (setq txt (buffer-substring (point-min) (point)))))))) txt)) (defun org-check-for-org-mode () "Make sure current buffer is in org-mode. Error if not." (or (derived-mode-p 'org-mode) - (error "Cannot execute org-mode agenda command on buffer in %s" + (error "Cannot execute Org agenda command on buffer in %s" major-mode))) ;;; Agenda prepare and finalize @@ -3617,26 +3640,26 @@ FILTER-ALIST is an alist of filters we need to apply when ((equal (current-buffer) abuf) nil) (awin (select-window awin)) ((not (setq wconf (current-window-configuration)))) - ((equal org-agenda-window-setup 'current-window) - (org-pop-to-buffer-same-window abuf)) - ((equal org-agenda-window-setup 'other-window) + ((eq org-agenda-window-setup 'current-window) + (pop-to-buffer-same-window abuf)) + ((eq org-agenda-window-setup 'other-window) (org-switch-to-buffer-other-window abuf)) - ((equal org-agenda-window-setup 'other-frame) + ((eq org-agenda-window-setup 'other-frame) (switch-to-buffer-other-frame abuf)) ((eq org-agenda-window-setup 'only-window) (delete-other-windows) - (org-pop-to-buffer-same-window abuf)) - ((equal org-agenda-window-setup 'reorganize-frame) + (pop-to-buffer-same-window abuf)) + ((eq org-agenda-window-setup 'reorganize-frame) (delete-other-windows) (org-switch-to-buffer-other-window abuf))) - (setq org-agenda-tag-filter (cdr (assoc 'tag filter-alist))) - (setq org-agenda-category-filter (cdr (assoc 'cat filter-alist))) - (setq org-agenda-effort-filter (cdr (assoc 'effort filter-alist))) - (setq org-agenda-regexp-filter (cdr (assoc 're filter-alist))) + (setq org-agenda-tag-filter (cdr (assq 'tag filter-alist))) + (setq org-agenda-category-filter (cdr (assq 'cat filter-alist))) + (setq org-agenda-effort-filter (cdr (assq 'effort filter-alist))) + (setq org-agenda-regexp-filter (cdr (assq 're filter-alist))) ;; Additional test in case agenda is invoked from within agenda ;; buffer via elisp link. (unless (equal (current-buffer) abuf) - (org-pop-to-buffer-same-window abuf)) + (pop-to-buffer-same-window abuf)) (setq org-agenda-pre-window-conf (or wconf org-agenda-pre-window-conf)))) @@ -3700,7 +3723,7 @@ FILTER-ALIST is an alist of filters we need to apply when (setq org-agenda-last-prefix-arg current-prefix-arg) (setq org-agenda-this-buffer-name org-agenda-buffer-name) (and name (not org-agenda-name) - (org-set-local 'org-agenda-name name))) + (setq-local org-agenda-name name))) (setq buffer-read-only nil)))) (defvar org-agenda-overriding-columns-format) ; From org-colview.el @@ -3724,8 +3747,8 @@ FILTER-ALIST is an alist of filters we need to apply when (remove-text-properties (point-min) (point-max) '(face nil))) (if (and (boundp 'org-agenda-overriding-columns-format) org-agenda-overriding-columns-format) - (org-set-local 'org-agenda-overriding-columns-format - org-agenda-overriding-columns-format)) + (setq-local org-agenda-overriding-columns-format + org-agenda-overriding-columns-format)) (if (and (boundp 'org-agenda-view-columns-initially) org-agenda-view-columns-initially) (org-agenda-columns)) @@ -3782,13 +3805,13 @@ FILTER-ALIST is an alist of filters we need to apply when (when (get 'org-agenda-effort-filter :preset-filter) (org-agenda-filter-apply (get 'org-agenda-effort-filter :preset-filter) 'effort)) - (org-add-hook 'kill-buffer-hook 'org-agenda-reset-markers 'append 'local))))) + (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." ;; We need to widen when `org-agenda-finalize' is called from ;; `org-agenda-change-all-lines' (e.g. in `org-agenda-clock-in') - (when org-clock-current-task + (when (bound-and-true-p org-clock-current-task) (save-restriction (widen) (org-agenda-unmark-clocking-task) @@ -3837,11 +3860,11 @@ FILTER-ALIST is an alist of filters we need to apply when ov 'face (let ((special-face (cond ((org-face-from-face-or-color - 'priority nil + 'priority 'org-priority (cdr (assoc p org-priority-faces)))) ((and (listp org-agenda-fontify-priorities) (org-face-from-face-or-color - 'priority nil + 'priority 'org-priority (cdr (assoc p org-agenda-fontify-priorities))))) ((equal p l) 'italic) ((equal p h) 'bold)))) @@ -3851,11 +3874,11 @@ FILTER-ALIST is an alist of filters we need to apply when (defvar org-depend-tag-blocked) (defun org-agenda-dim-blocked-tasks (&optional invisible) - "Dim currently blocked TODO's in the agenda display. + "Dim currently blocked TODOs in the agenda display. When INVISIBLE is non-nil, hide currently blocked TODO instead of dimming them." (interactive "P") - (when (org-called-interactively-p 'interactive) + (when (called-interactively-p 'interactive) (message "Dim or hide blocked tasks...")) (dolist (o (overlays-in (point-min) (point-max))) (when (eq (overlay-get o 'org-type) 'org-blocked-todo) @@ -3887,7 +3910,7 @@ dimming them." (overlay-put ov 'face 'org-agenda-dimmed-todo-face)) (overlay-put ov 'org-type 'org-blocked-todo)))) (forward-line)))) - (when (org-called-interactively-p 'interactive) + (when (called-interactively-p 'interactive) (message "Dim or hide blocked tasks...done"))) (defvar org-agenda-skip-function nil @@ -3939,7 +3962,7 @@ functions do." (defvar org-agenda-markers nil "List of all currently active markers created by `org-agenda'.") -(defvar org-agenda-last-marker-time (org-float-time) +(defvar org-agenda-last-marker-time (float-time) "Creation time of the last agenda marker.") (defun org-agenda-new-marker (&optional pos) @@ -3947,7 +3970,7 @@ functions do." Maker is at point, or at POS if non-nil. Org mode keeps a list of these markers and resets them when they are no longer in use." (let ((m (copy-marker (or pos (point)) t))) - (setq org-agenda-last-marker-time (org-float-time)) + (setq org-agenda-last-marker-time (float-time)) (if org-agenda-buffer (with-current-buffer org-agenda-buffer (push m org-agenda-markers)) @@ -4008,156 +4031,14 @@ This check for agenda markers in all agenda buffers currently active." (defun org-agenda-get-day-face (date) "Return the face DATE should be displayed with." - (or (and (functionp org-agenda-day-face-function) - (funcall org-agenda-day-face-function date)) - (cond ((org-agenda-todayp date) - 'org-agenda-date-today) - ((member (calendar-day-of-week date) org-agenda-weekend-days) - 'org-agenda-date-weekend) - (t 'org-agenda-date)))) - -;;; 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. -Only entries with a time stamp of today or later will be listed. With -\\[universal-argument] prefix, all unfinished TODO items will also be shown, -under the current date. -If the buffer contains an active region, only check the region for -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)) - (beg (if (org-region-active-p) (region-beginning) (point-min))) - (end (if (org-region-active-p) (region-end) (point-max))) - (day-numbers (org-get-all-dates - beg end 'no-ranges - t org-agenda-show-log-scoped ; always include today - org-timeline-show-empty-dates)) - (org-deadline-warning-days 0) - (org-agenda-only-exact-dates t) - (today (org-today)) - (past t) - args - s e rtn d emptyp) - (setq org-agenda-redo-command - (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) - (if (>= x today) x nil)) - day-numbers)))) - (org-agenda-prepare (concat "Timeline " (file-name-nondirectory entry))) - (org-compile-prefix-format 'timeline) - (org-set-sorting-strategy 'timeline) - (if org-agenda-show-log-scoped (push :closed args)) - (push :timestamp args) - (push :deadline args) - (push :scheduled args) - (push :sexp args) - (if dotodo (push :todo args)) - (insert "Timeline of file " entry "\n") - (add-text-properties (point-min) (point) - (list 'face 'org-agenda-structure)) - (org-agenda-mark-header-line (point-min)) - (while (setq d (pop day-numbers)) - (if (and (listp d) (eq (car d) :omitted)) - (progn - (setq s (point)) - (insert (format "\n[... %d empty days omitted]\n\n" (cdr d))) - (put-text-property s (1- (point)) 'face 'org-agenda-structure)) - (if (listp d) (setq d (car d) emptyp t) (setq emptyp nil)) - (if (and (>= d today) - dopast - past) - (progn - (setq past nil) - (insert (make-string 79 ?-) "\n"))) - (setq date (calendar-gregorian-from-absolute d)) - (setq s (point)) - (setq rtn (and (not emptyp) - (apply 'org-agenda-get-day-entries entry - date args))) - (if (or rtn (equal d today) org-timeline-show-empty-dates) - (progn - (insert - (if (stringp org-agenda-format-date) - (format-time-string org-agenda-format-date - (org-time-from-absolute date)) - (funcall org-agenda-format-date date)) - "\n") - (put-text-property s (1- (point)) 'face - (org-agenda-get-day-face date)) - (put-text-property s (1- (point)) 'org-date-line t) - (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 'timeline) "\n")) - (put-text-property s (1- (point)) 'day d))))) - (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 org-redo-cmd ,org-agenda-redo-command)) - (org-agenda-finalize) - (setq buffer-read-only t))) - -(defun org-get-all-dates (beg end &optional no-ranges force-today inactive empty pre-re) - "Return a list of all relevant day numbers from BEG to END buffer positions. -If NO-RANGES is non-nil, include only the start and end dates of a range, -not every single day in the range. If FORCE-TODAY is non-nil, make -sure that TODAY is included in the list. If INACTIVE is non-nil, also -inactive time stamps (those in square brackets) are included. -When EMPTY is non-nil, also include days without any entries." - (let ((re (concat - (if pre-re pre-re "") - (if inactive org-ts-regexp-both org-ts-regexp))) - dates dates1 date day day1 day2 ts1 ts2 pos) - (if force-today - (setq dates (list (org-today)))) - (save-excursion - (goto-char beg) - (while (re-search-forward re end t) - (setq day (time-to-days (org-time-string-to-time - (substring (match-string 1) 0 10) - (current-buffer) (match-beginning 0)))) - (or (memq day dates) (push day dates))) - (unless no-ranges - (goto-char beg) - (while (re-search-forward org-tr-regexp end t) - (setq pos (match-beginning 0)) - (setq ts1 (substring (match-string 1) 0 10) - ts2 (substring (match-string 2) 0 10) - day1 (time-to-days (org-time-string-to-time - ts1 (current-buffer) pos)) - day2 (time-to-days (org-time-string-to-time - ts2 (current-buffer) pos))) - (while (< (setq day1 (1+ day1)) day2) - (or (memq day1 dates) (push day1 dates))))) - (setq dates (sort dates '<)) - (when empty - (while (setq day (pop dates)) - (setq day2 (car dates)) - (push day dates1) - (when (and day2 empty) - (if (or (eq empty t) - (and (numberp empty) (<= (- day2 day) empty))) - (while (< (setq day (1+ day)) day2) - (push (list day) dates1)) - (push (cons :omitted (- day2 day)) dates1)))) - (setq dates (nreverse dates1))) - dates))) + (cond ((and (functionp org-agenda-day-face-function) + (funcall org-agenda-day-face-function date))) + ((org-agenda-today-p date) 'org-agenda-date-today) + ((memq (calendar-day-of-week date) org-agenda-weekend-days) + 'org-agenda-date-weekend) + (t 'org-agenda-date))) + +(defvar org-agenda-show-log-scoped) ;;; Agenda Daily/Weekly @@ -4196,13 +4077,14 @@ items if they have an hour specification like [h]h:mm." (catch 'exit (setq org-agenda-buffer-name (or org-agenda-buffer-tmp-name + (and org-agenda-doing-sticky-redo org-agenda-buffer-name) (if org-agenda-sticky (cond ((and org-keys (stringp org-match)) (format "*Org Agenda(%s:%s)*" org-keys org-match)) (org-keys (format "*Org Agenda(%s)*" org-keys)) (t "*Org Agenda(a)*"))) - org-agenda-buffer-name)) + "*Org Agenda*")) (org-agenda-prepare "Day/Week") (setq start-day (or start-day org-agenda-start-day)) (if (stringp start-day) @@ -4210,8 +4092,7 @@ items if they have an hour specification like [h]h:mm." (setq start-day (time-to-days (org-read-date nil t start-day)))) (org-compile-prefix-format 'agenda) (org-set-sorting-strategy 'agenda) - (let* ((span (org-agenda-ndays-to-span - (or span org-agenda-ndays org-agenda-span))) + (let* ((span (org-agenda-ndays-to-span (or span org-agenda-span))) (today (org-today)) (sd (or start-day today)) (ndays (org-agenda-span-to-ndays span sd)) @@ -4241,9 +4122,9 @@ items if they have an hour specification like [h]h:mm." (setq day-numbers (nreverse day-numbers)) (setq clocktable-start (car day-numbers) clocktable-end (1+ (or (org-last day-numbers) 0))) - (org-set-local 'org-starting-day (car day-numbers)) - (org-set-local 'org-arg-loc arg) - (org-set-local 'org-agenda-current-span (org-agenda-ndays-to-span span)) + (setq-local org-starting-day (car day-numbers)) + (setq-local org-arg-loc arg) + (setq-local org-agenda-current-span (org-agenda-ndays-to-span span)) (unless org-agenda-compact-blocks (let* ((d1 (car day-numbers)) (d2 (org-last day-numbers)) @@ -4389,10 +4270,10 @@ START-DAY is an absolute time value." ((eq span 'fortnight) 14) ((eq span 'month) (let ((date (calendar-gregorian-from-absolute start-day))) - (calendar-last-day-of-month (car date) (caddr date)))) + (calendar-last-day-of-month (car date) (cl-caddr date)))) ((eq span 'year) (let ((date (calendar-gregorian-from-absolute start-day))) - (if (calendar-leap-year-p (caddr date)) 366 365))))) + (if (calendar-leap-year-p (cl-caddr date)) 366 365))))) (defun org-agenda-span-name (span) "Return a SPAN name." @@ -4407,7 +4288,7 @@ START-DAY is an absolute time value." (defvar org-agenda-search-history nil) (defvar org-search-syntax-table nil - "Special syntax table for org-mode search. + "Special syntax table for Org search. In this table, we have single quotes not as word constituents, to that when \"+Ameli\" is searched as a work, it will also match \"Ameli's\"") @@ -4612,7 +4493,7 @@ in `org-agenda-text-search-extra-files'." (> (org-reduced-level (org-outline-level)) org-agenda-search-view-max-outline-level) (forward-line -1) - (outline-back-to-heading t))) + (org-back-to-heading t))) (skip-chars-forward "* ") (setq beg (point-at-bol) beg1 (point) @@ -4639,7 +4520,8 @@ in `org-agenda-text-search-extra-files'." (goto-char (1- end)) (throw :skip t))) (if todo-only - (cons (concat "^\*+[ \t]+" org-not-done-regexp) + (cons (concat "^\\*+[ \t]+" + org-not-done-regexp) regexps+) regexps+)) (goto-char beg) @@ -4681,7 +4563,12 @@ in `org-agenda-text-search-extra-files'." (add-text-properties pos (1- (point)) (list 'face 'org-warning)) (setq pos (point)) (unless org-agenda-multi - (insert "Press `[', `]' to add/sub word, `{', `}' to add/sub regexp, `C-u r' to edit\n") + (insert (substitute-command-keys "\ +Press `\\[org-agenda-manipulate-query-add]', \ +`\\[org-agenda-manipulate-query-subtract]' to add/sub word, \ +`\\[org-agenda-manipulate-query-add-re]', \ +`\\[org-agenda-manipulate-query-subtract-re]' to add/sub regexp, \ +`\\[universal-argument] \\[org-agenda-redo]' to edit\n")) (add-text-properties pos (1- (point)) (list 'face 'org-agenda-structure)))) (org-agenda-mark-header-line (point-min)) @@ -4718,7 +4605,7 @@ in `org-agenda-text-search-extra-files'." (defun org-todo-list (&optional arg) "Show all (not done) TODO entries from all agenda file in a single list. The prefix arg can be used to select a specific TODO keyword and limit -the list to these. When using \\[universal-argument], you will be prompted +the list to these. When using `\\[universal-argument]', you will be prompted for a keyword. A numeric prefix directly selects the Nth keyword in `org-todo-keywords-1'." (interactive "P") @@ -4736,8 +4623,8 @@ for a keyword. A numeric prefix directly selects the Nth keyword in rtn rtnall files file pos) (when (equal arg '(4)) (setq org-select-this-todo-keyword - (org-icompleting-read "Keyword (or KWD1|K2D2|...): " - (mapcar 'list kwds) nil nil))) + (completing-read "Keyword (or KWD1|K2D2|...): " + (mapcar #'list kwds) nil nil))) (and (equal 0 arg) (setq org-select-this-todo-keyword nil)) (catch 'exit (if org-agenda-sticky @@ -4775,7 +4662,8 @@ for a keyword. A numeric prefix directly selects the Nth keyword in org-select-this-todo-keyword)) (setq pos (point)) (unless org-agenda-multi - (insert "Available with `N r': (0)[ALL]") + (insert (substitute-command-keys "Available with \ +`N \\[org-agenda-redo]': (0)[ALL]")) (let ((n 0) s) (mapc (lambda (x) (setq s (format "(%d)%s" (setq n (1+ n)) x)) @@ -4825,14 +4713,17 @@ The prefix arg TODO-ONLY limits the search to TODO entries." ;; 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)) + (setq org--matcher-tags-todo-only todo-only + 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) (setq org-agenda-redo-command - (list 'org-tags-view `(quote ,todo-only) - (list 'if 'current-prefix-arg nil `(quote ,org-agenda-query-string)))) + (list 'org-tags-view + `(quote ,org--matcher-tags-todo-only) + `(if current-prefix-arg nil ,org-agenda-query-string))) (setq files (org-agenda-files nil 'ifmode) rtnall nil) (while (setq file (pop files)) @@ -4855,7 +4746,9 @@ The prefix arg TODO-ONLY limits the search to TODO entries." (narrow-to-region org-agenda-restrict-begin org-agenda-restrict-end) (widen)) - (setq rtn (org-scan-tags 'agenda matcher todo-only)) + (setq rtn (org-scan-tags 'agenda + matcher + org--matcher-tags-todo-only)) (setq rtnall (append rtnall rtn)))))))) (if org-agenda-overriding-header (insert (org-add-props (copy-sequence org-agenda-overriding-header) @@ -4870,18 +4763,22 @@ The prefix arg TODO-ONLY limits the search to TODO entries." (add-text-properties pos (1- (point)) (list 'face 'org-warning)) (setq pos (point)) (unless org-agenda-multi - (insert "Press `C-u r' to search again with new search string\n")) - (add-text-properties pos (1- (point)) (list 'face 'org-agenda-structure))) + (insert (substitute-command-keys + "Press `\\[universal-argument] \\[org-agenda-redo]' \ +to search again with new search string\n"))) + (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 'tags) "\n")) (goto-char (point-min)) (or org-agenda-multi (org-agenda-fit-window-to-buffer)) - (add-text-properties (point-min) (point-max) - `(org-agenda-type tags - org-last-args (,todo-only ,match) - org-redo-cmd ,org-agenda-redo-command - org-series-cmd ,org-cmd)) + (add-text-properties + (point-min) (point-max) + `(org-agenda-type tags + org-last-args (,org--matcher-tags-todo-only ,match) + org-redo-cmd ,org-agenda-redo-command + org-series-cmd ,org-cmd)) (org-agenda-finalize) (setq buffer-read-only t)))) @@ -4897,43 +4794,6 @@ used by user-defined selections using `org-agenda-skip-function'.") This variable should not be set directly, but custom commands can bind it in the options section.") -(defun org-agenda-skip-entry-when-regexp-matches () - "Check if the current entry contains match for `org-agenda-skip-regexp'. -If yes, it returns the end position of this entry, causing agenda commands -to skip the entry but continuing the search in the subtree. This is a -function that can be put into `org-agenda-skip-function' for the duration -of a command." - (let ((end (save-excursion (org-end-of-subtree t))) - skip) - (save-excursion - (setq skip (re-search-forward org-agenda-skip-regexp end t))) - (and skip end))) - -(defun org-agenda-skip-subtree-when-regexp-matches () - "Check if the current subtree contains match for `org-agenda-skip-regexp'. -If yes, it returns the end position of this tree, causing agenda commands -to skip this subtree. This is a function that can be put into -`org-agenda-skip-function' for the duration of a command." - (let ((end (save-excursion (org-end-of-subtree t))) - skip) - (save-excursion - (setq skip (re-search-forward org-agenda-skip-regexp end t))) - (and skip end))) - -(defun org-agenda-skip-entry-when-regexp-matches-in-subtree () - "Check if the current subtree contains match for `org-agenda-skip-regexp'. -If yes, it returns the end position of the current entry (NOT the tree), -causing agenda commands to skip the entry but continuing the search in -the subtree. This is a function that can be put into -`org-agenda-skip-function' for the duration of a command. An important -use of this function is for the stuck project list." - (let ((end (save-excursion (org-end-of-subtree t))) - (entry-end (save-excursion (outline-next-heading) (1- (point)))) - skip) - (save-excursion - (setq skip (re-search-forward org-agenda-skip-regexp end t))) - (and skip entry-end))) - (defun org-agenda-skip-entry-if (&rest conditions) "Skip entry if any of CONDITIONS is true. See `org-agenda-skip-if' for details." @@ -4969,13 +4829,13 @@ the `regexp' or `notregexp' element. `todo' and `nottodo' accept as an argument a list of todo keywords, which may include \"*\" to match any todo keyword. - (org-agenda-skip-entry-if 'todo '(\"TODO\" \"WAITING\")) + (org-agenda-skip-entry-if \\='todo \\='(\"TODO\" \"WAITING\")) would skip all entries with \"TODO\" or \"WAITING\" keywords. Instead of a list, a keyword class may be given. For example: - (org-agenda-skip-entry-if 'nottodo 'done) + (org-agenda-skip-entry-if \\='nottodo \\='done) would skip entries that haven't been marked with any of \"DONE\" keywords. Possible classes are: `todo', `done', `any'. @@ -5069,45 +4929,44 @@ Stuck projects are project that have no next actions. For the definitions of what a project is and how to check if it stuck, customize the variable `org-stuck-projects'." (interactive) - (let* ((org-agenda-skip-function - 'org-agenda-skip-entry-when-regexp-matches-in-subtree) - ;; We could have used org-agenda-skip-if here. - (org-agenda-overriding-header + (let* ((org-agenda-overriding-header (or org-agenda-overriding-header "List of stuck projects: ")) (matcher (nth 0 org-stuck-projects)) (todo (nth 1 org-stuck-projects)) - (todo-wds (if (member "*" todo) - (progn - (org-agenda-prepare-buffers (org-agenda-files - nil 'ifmode)) - (org-delete-all - org-done-keywords-for-agenda - (copy-sequence org-todo-keywords-for-agenda))) - todo)) - (todo-re (concat "^\\*+[ \t]+\\(" - (mapconcat 'identity todo-wds "\\|") - "\\)\\>")) (tags (nth 2 org-stuck-projects)) - (tags-re (if (member "*" tags) - (concat org-outline-regexp-bol - (org-re ".*:[[:alnum:]_@#%]+:[ \t]*$")) - (if tags - (concat org-outline-regexp-bol - ".*:\\(" - (mapconcat 'identity tags "\\|") - (org-re "\\):[[:alnum:]_@#%:]*[ \t]*$"))))) - (gen-re (nth 3 org-stuck-projects)) - (re-list - (delq nil - (list - (if todo todo-re) - (if tags tags-re) - (and gen-re (stringp gen-re) (string-match "\\S-" gen-re) - gen-re))))) - (setq org-agenda-skip-regexp - (if re-list - (mapconcat 'identity re-list "\\|") - (error "No information how to identify unstuck projects"))) + (gen-re (org-string-nw-p (nth 3 org-stuck-projects))) + (todo-wds + (if (not (member "*" todo)) todo + (org-agenda-prepare-buffers (org-agenda-files nil 'ifmode)) + (org-delete-all org-done-keywords-for-agenda + (copy-sequence org-todo-keywords-for-agenda)))) + (todo-re (and todo + (format "^\\*+[ \t]+\\(%s\\)\\>" + (mapconcat #'identity todo-wds "\\|")))) + (tags-re (cond ((null tags) nil) + ((member "*" tags) + (eval-when-compile + (concat org-outline-regexp-bol + ".*:[[:alnum:]_@#%]+:[ \t]*$"))) + (tags (concat org-outline-regexp-bol + ".*:\\(" + (mapconcat #'identity tags "\\|") + "\\):[[:alnum:]_@#%:]*[ \t]*$")) + (t nil))) + (re-list (delq nil (list todo-re tags-re gen-re))) + (skip-re + (if (null re-list) + (error "Missing information to identify unstuck projects") + (mapconcat #'identity re-list "\\|"))) + (org-agenda-skip-function + ;; Skip entry if `org-agenda-skip-regexp' matches anywhere + ;; in the subtree. + `(lambda () + (and (save-excursion + (let ((case-fold-search nil)) + (re-search-forward + ,skip-re (save-excursion (org-end-of-subtree t)) t))) + (progn (outline-next-heading) (point)))))) (org-tags-view nil matcher) (setq org-agenda-buffer-name (buffer-name)) (with-current-buffer org-agenda-buffer-name @@ -5190,7 +5049,7 @@ date. It also removes lines that contain only whitespace." (while (re-search-forward "^ +\n" nil t) (replace-match "")) (goto-char (point-min)) - (if (re-search-forward "^Org-mode dummy\n?" nil t) + (if (re-search-forward "^Org mode dummy\n?" nil t) (replace-match "")) (run-hooks 'org-agenda-cleanup-fancy-diary-hook)) @@ -5208,7 +5067,7 @@ date. It also removes lines that contain only whitespace." (setq string (org-modify-diary-entry-string string)))))) (defun org-modify-diary-entry-string (string) - "Add text properties to string, allowing org-mode to act on it." + "Add text properties to string, allowing Org to act on it." (org-add-props string nil 'mouse-face 'highlight 'help-echo (if buffer-file-name @@ -5224,9 +5083,9 @@ Needed to avoid empty dates which mess up holiday display." ;; Catch the error if dealing with the new add-to-diary-alist (when org-disable-agenda-to-diary (condition-case nil - (org-add-to-diary-list original-date "Org-mode dummy" "") + (org-add-to-diary-list original-date "Org mode dummy" "") (error - (org-add-to-diary-list original-date "Org-mode dummy" "" nil))))) + (org-add-to-diary-list original-date "Org mode dummy" "" nil))))) (defun org-add-to-diary-list (&rest args) (if (fboundp 'diary-add-to-list) @@ -5262,7 +5121,7 @@ So the example above may also be written as The function expects the lisp variables `entry' and `date' to be provided by the caller, because this is how the calendar works. Don't use this function from a program - use `org-agenda-get-day-entries' instead." - (when (> (- (org-float-time) + (when (> (- (float-time) org-agenda-last-marker-time) 5) ;; I am not sure if this works with sticky agendas, because the marker @@ -5274,7 +5133,7 @@ function from a program - use `org-agenda-get-day-entries' instead." (let* ((files (if (and entry (stringp entry) (string-match "\\S-" entry)) (list entry) (org-agenda-files t))) - (time (org-float-time)) + (time (float-time)) file rtn results) (when (or (not org-diary-last-run-time) (> (- time @@ -5296,67 +5155,77 @@ function from a program - use `org-agenda-get-day-entries' instead." ;;; Agenda entry finders +(defun org-agenda--timestamp-to-absolute (&rest args) + "Call `org-time-string-to-absolute' with ARGS. +However, throw `:skip' whenever an error is raised." + (condition-case e + (apply #'org-time-string-to-absolute args) + (org-diary-sexp-no-match (throw :skip nil)) + (error + (message "%s; Skipping entry" (error-message-string e)) + (throw :skip nil)))) + (defun org-agenda-get-day-entries (file date &rest args) "Does the work for `org-diary' and `org-agenda'. 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 org-agenda-entry-types)) (let* ((org-startup-folded nil) (org-startup-align-all-tables nil) - (buffer (if (file-exists-p file) - (org-get-agenda-file-buffer file) - (error "No such file %s" file))) - arg results rtn deadline-results) + (buffer (if (file-exists-p file) (org-get-agenda-file-buffer file) + (error "No such file %s" file)))) (if (not buffer) - ;; If file does not exist, make sure an error message ends up in diary + ;; If file does not exist, signal it in diary nonetheless. (list (format "ORG-AGENDA-ERROR: No such org-file %s" file)) (with-current-buffer buffer (unless (derived-mode-p 'org-mode) (error "Agenda file %s is not in `org-mode'" file)) (setq org-agenda-buffer (or org-agenda-buffer buffer)) - (let ((case-fold-search nil)) - (save-excursion - (save-restriction - (if (eq buffer org-agenda-restrict) - (narrow-to-region org-agenda-restrict-begin - org-agenda-restrict-end) - (widen)) - ;; The way we repeatedly append to `results' makes it O(n^2) :-( - (while (setq arg (pop args)) - (cond - ((and (eq arg :todo) - (equal date (calendar-gregorian-from-absolute - (org-today)))) - (setq rtn (org-agenda-get-todos)) - (setq results (append results rtn))) - ((eq arg :timestamp) - (setq rtn (org-agenda-get-blocks)) - (setq results (append results rtn)) - (setq rtn (org-agenda-get-timestamps deadline-results)) - (setq results (append results rtn))) - ((eq arg :sexp) - (setq rtn (org-agenda-get-sexps)) - (setq results (append results rtn))) - ((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)))) + (setf org-agenda-current-date date) + (save-excursion + (save-restriction + (if (eq buffer org-agenda-restrict) + (narrow-to-region org-agenda-restrict-begin + org-agenda-restrict-end) + (widen)) + ;; Rationalize ARGS. Also make sure `:deadline' comes + ;; first in order to populate DEADLINES before passing it. + ;; + ;; We use `delq' since `org-uniquify' duplicates ARGS, + ;; guarding us from modifying `org-agenda-entry-types'. + (setf args (org-uniquify (or args org-agenda-entry-types))) + (when (and (memq :scheduled args) (memq :scheduled* args)) + (setf args (delq :scheduled* args))) + (cond + ((memq :deadline args) + (setf args (cons :deadline + (delq :deadline (delq :deadline* args))))) + ((memq :deadline* args) + (setf args (cons :deadline* (delq :deadline* args))))) + ;; Collect list of headlines. Return them flattened. + (let ((case-fold-search nil) results deadlines) + (dolist (arg args (apply #'nconc (nreverse results))) + (pcase arg + ((and :todo (guard (org-agenda-today-p date))) + (push (org-agenda-get-todos) results)) + (:timestamp + (push (org-agenda-get-blocks) results) + (push (org-agenda-get-timestamps deadlines) results)) + (:sexp + (push (org-agenda-get-sexps) results)) + (:scheduled + (push (org-agenda-get-scheduled deadlines) results)) + (:scheduled* + (push (org-agenda-get-scheduled deadlines t) results)) + (:closed + (push (org-agenda-get-progress) results)) + (:deadline + (setf deadlines (org-agenda-get-deadlines)) + (push deadlines results)) + (:deadline* + (setf deadlines (org-agenda-get-deadlines t)) + (push deadlines results))))))))))) (defsubst org-em (x y list) "Is X or Y a member of LIST?" @@ -5410,6 +5279,7 @@ and the timestamp type relevant for the sorting strategy in 'help-echo (format "mouse-2 or RET jump to org file %s" (abbreviate-file-name buffer-file-name)))) + (case-fold-search nil) (regexp (format org-heading-keyword-regexp-format (cond ((and org-select-this-todo-keyword @@ -5512,7 +5382,7 @@ This function is invoked if `org-agenda-todo-ignore-deadlines', (cond ((memq org-agenda-todo-ignore-deadlines '(t all)) t) ((eq org-agenda-todo-ignore-deadlines 'far) - (not (org-deadline-close (match-string 1)))) + (not (org-deadline-close-p (match-string 1)))) ((eq org-agenda-todo-ignore-deadlines 'future) (> (org-time-stamp-to-now (match-string 1) org-agenda-todo-ignore-time-comparison-use-seconds) 0)) @@ -5522,7 +5392,7 @@ This function is invoked if `org-agenda-todo-ignore-deadlines', ((numberp org-agenda-todo-ignore-deadlines) (org-agenda-todo-custom-ignore-p (match-string 1) org-agenda-todo-ignore-deadlines)) - (t (org-deadline-close (match-string 1))))) + (t (org-deadline-close-p (match-string 1))))) (and org-agenda-todo-ignore-timestamp (let ((buffer (current-buffer)) (regexp @@ -5551,24 +5421,27 @@ This function is invoked if `org-agenda-todo-ignore-deadlines', (match-string 1) org-agenda-todo-ignore-timestamp)) (t)))))))))) -(defun org-agenda-get-timestamps (&optional deadline-results) - "Return the date stamp information for agenda display." +(defun org-agenda-get-timestamps (&optional deadlines) + "Return the date stamp information for agenda display. +Optional argument DEADLINES is a list of deadline items to be +displayed in agenda view." (let* ((props (list 'face 'org-agenda-calendar-event 'org-not-done-regexp org-not-done-regexp 'org-todo-regexp org-todo-regexp 'org-complex-heading-regexp org-complex-heading-regexp 'mouse-face 'highlight 'help-echo - (format "mouse-2 or RET jump to org file %s" + (format "mouse-2 or RET jump to Org file %s" (abbreviate-file-name buffer-file-name)))) - (d1 (calendar-absolute-from-gregorian date)) - mm + (current (calendar-absolute-from-gregorian date)) + (today (org-today)) (deadline-position-alist - (mapcar (lambda (a) (and (setq mm (get-text-property - 0 'org-hd-marker a)) - (cons (marker-position mm) a))) - deadline-results)) - (remove-re org-ts-regexp) + (mapcar (lambda (d) + (let ((m (get-text-property 0 'org-hd-marker d))) + (and m (marker-position m)))) + deadlines)) + ;; Match time-stamps set to current date, time-stamps with + ;; a repeater, and S-exp time-stamps. (regexp (concat (if org-agenda-include-inactive-timestamps "[[<]" "<") @@ -5576,95 +5449,120 @@ This function is invoked if `org-agenda-todo-ignore-deadlines', (substring (format-time-string (car org-time-stamp-formats) - (apply 'encode-time ; DATE bound by calendar + (apply #'encode-time ; DATE bound by calendar (list 0 0 0 (nth 1 date) (car date) (nth 2 date)))) 1 11)) "\\|\\(<[0-9]+-[0-9]+-[0-9]+[^>\n]+?\\+[0-9]+[hdwmy]>\\)" "\\|\\(<%%\\(([^>\n]+)\\)>\\)")) - marker hdmarker deadlinep scheduledp clockp closedp inactivep - donep tmp priority category level ee txt timestr tags - b0 b3 e3 head todo-state end-of-match show-all warntime habitp - inherited-tags ts-date) + timestamp-items) (goto-char (point-min)) - (while (setq end-of-match (re-search-forward regexp nil t)) - (setq b0 (match-beginning 0) - b3 (match-beginning 3) e3 (match-end 3) - todo-state (save-match-data (ignore-errors (org-get-todo-state))) - habitp (and (functionp 'org-is-habit-p) (save-match-data (org-is-habit-p))) - show-all (or (eq org-agenda-repeating-timestamp-show-all t) - (member todo-state - org-agenda-repeating-timestamp-show-all))) + (while (re-search-forward regexp nil t) + ;; Skip date ranges, scheduled and deadlines, which are handled + ;; specially. Also skip time-stamps before first headline as + ;; there would be no entry to add to the agenda. Eventually, + ;; ignore clock entries. (catch :skip - (and (org-at-date-range-p) (throw :skip nil)) - (org-agenda-skip) - (if (and (match-end 1) - (not (= d1 (org-time-string-to-absolute - (match-string 1) d1 nil show-all - (current-buffer) b0)))) - (throw :skip nil)) - (if (and e3 - (not (org-diary-sexp-entry (buffer-substring b3 e3) "" date))) + (save-match-data + (when (or (org-at-date-range-p) + (org-at-planning-p) + (org-before-first-heading-p) + (and org-agenda-include-inactive-timestamps + (org-at-clock-log-p))) (throw :skip nil)) - (setq tmp (buffer-substring (max (point-min) - (- b0 org-ds-keyword-length)) - b0) - timestr (if b3 "" (buffer-substring b0 (point-at-eol))) - inactivep (= (char-after b0) ?\[) - deadlinep (string-match org-deadline-regexp tmp) - scheduledp (string-match org-scheduled-regexp tmp) - closedp (and org-agenda-include-inactive-timestamps - (string-match org-closed-string tmp)) - clockp (and org-agenda-include-inactive-timestamps - (or (string-match org-clock-string tmp) - (string-match "]-+\\'" tmp))) - warntime (get-text-property (point) 'org-appt-warntime) - donep (member todo-state org-done-keywords)) - (if (or scheduledp deadlinep closedp clockp - (and donep org-agenda-skip-timestamp-if-done)) + (org-agenda-skip)) + (let* ((pos (match-beginning 0)) + (repeat (match-string 1)) + (sexp-entry (match-string 3)) + (time-stamp (if (or repeat sexp-entry) (match-string 0) + (save-excursion + (goto-char pos) + (looking-at org-ts-regexp-both) + (match-string 0)))) + (todo-state (org-get-todo-state)) + (warntime (get-text-property (point) 'org-appt-warntime)) + (done? (member todo-state org-done-keywords))) + ;; Possibly skip done tasks. + (when (and done? org-agenda-skip-timestamp-if-done) (throw :skip t)) - (if (string-match ">" timestr) - ;; substring should only run to end of time stamp - (setq timestr (substring timestr 0 (match-end 0)))) - (setq marker (org-agenda-new-marker b0) - category (org-get-category b0)) - (save-excursion - (if (not (re-search-backward org-outline-regexp-bol nil t)) - (throw :skip nil) - (goto-char (match-beginning 0)) - (if (and (eq t org-agenda-skip-timestamp-if-deadline-is-shown) - (assoc (point) deadline-position-alist)) - (throw :skip nil)) - (setq hdmarker (org-agenda-new-marker) - inherited-tags - (or (eq org-agenda-show-inherited-tags 'always) - (and (listp org-agenda-show-inherited-tags) - (memq 'agenda org-agenda-show-inherited-tags)) - (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)) - 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 level category tags timestr - remove-re habitp))) - (setq priority (org-get-priority txt)) - (org-add-props txt props 'priority priority - 'org-marker marker 'org-hd-marker hdmarker - 'date date - 'level level - 'ts-date - (ignore-errors (org-time-string-to-absolute timestr)) - 'todo-state todo-state - 'warntime warntime - 'type "timestamp") - (push txt ee)) - (if org-agenda-skip-additional-timestamps-same-entry - (outline-next-heading) - (goto-char end-of-match)))) - (nreverse ee))) + ;; S-exp entry doesn't match current day: skip it. + (when (and sexp-entry (not (org-diary-sexp-entry sexp-entry "" date))) + (throw :skip nil)) + (when repeat + (let* ((past + ;; A repeating time stamp is shown at its base + ;; date and every repeated date up to TODAY. If + ;; `org-agenda-prefer-last-repeat' is non-nil, + ;; however, only the last repeat before today + ;; (inclusive) is shown. + (org-agenda--timestamp-to-absolute + repeat + (if (or (> current today) + (eq org-agenda-prefer-last-repeat t) + (member todo-state org-agenda-prefer-last-repeat)) + today + current) + 'past (current-buffer) pos)) + (future + ;; Display every repeated date past TODAY + ;; (exclusive) unless + ;; `org-agenda-show-future-repeats' is nil. If + ;; this variable is set to `next', only display + ;; the first repeated date after TODAY + ;; (exclusive). + (cond + ((<= current today) past) + ((not org-agenda-show-future-repeats) past) + (t + (let ((base (if (eq org-agenda-show-future-repeats 'next) + (1+ today) + current))) + (org-agenda--timestamp-to-absolute + repeat base 'future (current-buffer) pos)))))) + (when (and (/= current past) (/= current future)) + (throw :skip nil)))) + (save-excursion + (re-search-backward org-outline-regexp-bol nil t) + ;; Possibly skip time-stamp when a deadline is set. + (when (and org-agenda-skip-timestamp-if-deadline-is-shown + (assq (point) deadline-position-alist)) + (throw :skip nil)) + (let* ((category (org-get-category pos)) + (inherited-tags + (or (eq org-agenda-show-inherited-tags 'always) + (and (consp org-agenda-show-inherited-tags) + (memq 'agenda org-agenda-show-inherited-tags)) + (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))) + (level (make-string (org-reduced-level (org-outline-level)) + ?\s)) + (head (and (looking-at "\\*+[ \t]+\\(.*\\)") + (match-string 1))) + (inactive? (= (char-after pos) ?\[)) + (habit? (and (fboundp 'org-is-habit-p) (org-is-habit-p))) + (item + (org-agenda-format-item + (and inactive? org-agenda-inactive-leader) + head level category tags time-stamp org-ts-regexp habit?))) + (org-add-props item props + 'priority (if habit? + (org-habit-get-priority (org-habit-parse-todo)) + (org-get-priority item)) + 'org-marker (org-agenda-new-marker pos) + 'org-hd-marker (org-agenda-new-marker) + 'date date + 'level level + 'ts-date (if repeat (org-agenda--timestamp-to-absolute repeat) + current) + 'todo-state todo-state + 'warntime warntime + 'type "timestamp") + (push item timestamp-items)))) + (when org-agenda-skip-additional-timestamps-same-entry + (outline-next-heading)))) + (nreverse timestamp-items))) (defun org-agenda-get-sexps () "Return the sexp information for agenda display." @@ -5725,29 +5623,26 @@ This function is invoked if `org-agenda-todo-ignore-deadlines', ;; Calendar sanity: define some functions that are independent of ;; `calendar-date-style'. -;; Normally I would like to use ISO format when calling the diary functions, -;; but to make sure we still have Emacs 22 compatibility we bind -;; also `european-calendar-style' and use european format (defun org-anniversary (year month day &optional mark) "Like `diary-anniversary', but with fixed (ISO) order of arguments." - (org-no-warnings - (let ((calendar-date-style 'european) (european-calendar-style t)) - (diary-anniversary day month year mark)))) + (with-no-warnings + (let ((calendar-date-style 'iso)) + (diary-anniversary year month day mark)))) (defun org-cyclic (N year month day &optional mark) "Like `diary-cyclic', but with fixed (ISO) order of arguments." - (org-no-warnings - (let ((calendar-date-style 'european) (european-calendar-style t)) - (diary-cyclic N day month year mark)))) + (with-no-warnings + (let ((calendar-date-style 'iso)) + (diary-cyclic N year month day mark)))) (defun org-block (Y1 M1 D1 Y2 M2 D2 &optional mark) "Like `diary-block', but with fixed (ISO) order of arguments." - (org-no-warnings - (let ((calendar-date-style 'european) (european-calendar-style t)) - (diary-block D1 M1 Y1 D2 M2 Y2 mark)))) + (with-no-warnings + (let ((calendar-date-style 'iso)) + (diary-block Y1 M1 D1 Y2 M2 D2 mark)))) (defun org-date (year month day &optional mark) "Like `diary-date', but with fixed (ISO) order of arguments." - (org-no-warnings - (let ((calendar-date-style 'european) (european-calendar-style t)) - (diary-date day month year mark)))) + (with-no-warnings + (let ((calendar-date-style 'iso)) + (diary-date year month day mark)))) ;; Define the `org-class' function (defun org-class (y1 m1 d1 y2 m2 d2 dayname &rest skip-weeks) @@ -5774,26 +5669,6 @@ then those holidays will be skipped." (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) - "Like `org-class', but honor `calendar-date-style'. -The order of the first 2 times 3 arguments depends on the variable -`calendar-date-style' or, if that is not defined, on `european-calendar-style'. -So for American calendars, give this as MONTH DAY YEAR, for European as -DAY MONTH YEAR, and for ISO as YEAR MONTH DAY. -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. - -This function is here only for backward compatibility and it is deprecated, -please use `org-class' instead." - (let* ((date1 (org-order-calendar-date-args m1 d1 y1)) - (date2 (org-order-calendar-date-args m2 d2 y2))) - (org-class - (nth 2 date1) (car date1) (nth 1 date1) - (nth 2 date2) (car date2) (nth 1 date2) - dayname skip-weeks))) -(make-obsolete 'org-diary-class 'org-class "") - (defalias 'org-get-closed 'org-agenda-get-progress) (defun org-agenda-get-progress () "Return the logged TODO entries for agenda display." @@ -5902,23 +5777,22 @@ please use `org-class' instead." "Add overlays, showing issues with clocking. See also the user option `org-agenda-clock-consistency-checks'." (interactive) - (let* ((org-time-clocksum-use-effort-durations nil) - (pl org-agenda-clock-consistency-checks) + (let* ((pl org-agenda-clock-consistency-checks) (re (concat "^[ \t]*" org-clock-string "[ \t]+" - "\\(\\[.*?\\]\\)" ; group 1 is first stamp + "\\(\\[.*?\\]\\)" ; group 1 is first stamp "\\(-\\{1,3\\}\\(\\[.*?\\]\\)\\)?")) ; group 3 is second (tlstart 0.) (tlend 0.) - (maxtime (org-hh:mm-string-to-minutes + (maxtime (org-duration-to-minutes (or (plist-get pl :max-duration) "24:00"))) - (mintime (org-hh:mm-string-to-minutes + (mintime (org-duration-to-minutes (or (plist-get pl :min-duration) 0))) - (maxgap (org-hh:mm-string-to-minutes + (maxgap (org-duration-to-minutes ;; default 30:00 means never complain (or (plist-get pl :max-gap) "30:00"))) - (gapok (mapcar 'org-hh:mm-string-to-minutes + (gapok (mapcar #'org-duration-to-minutes (plist-get pl :gap-ok-around))) (def-face (or (plist-get pl :default-face) '((:background "DarkRed") (:foreground "white")))) @@ -5943,23 +5817,21 @@ See also the user option `org-agenda-clock-consistency-checks'." (throw 'next t)) (setq ts (match-string 1) te (match-string 3) - ts (org-float-time - (apply 'encode-time (org-parse-time-string ts))) - te (org-float-time - (apply 'encode-time (org-parse-time-string te))) + ts (float-time + (apply #'encode-time (org-parse-time-string ts))) + te (float-time + (apply #'encode-time (org-parse-time-string te))) dt (- te ts)))) (cond ((> dt (* 60 maxtime)) ;; a very long clocking chunk (setq issue (format "Clocking interval is very long: %s" - (org-minutes-to-clocksum-string - (floor (/ (float dt) 60.)))) + (org-duration-from-minutes (floor (/ 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-clocksum-string - (floor (/ (float dt) 60.)))) + (org-duration-from-minutes (floor (/ dt 60.)))) face (or (plist-get pl :short-face) face))) ((and (> tlend 0) (< ts tlend)) ;; Two clock entries are overlapping @@ -6032,306 +5904,342 @@ specification like [h]h:mm." (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 - (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 level - tags suppress-prewarning ee txt head face s todo-state - show-all upcomingp donep timestr warntime inherited-tags ts-date) + (today (org-today)) + (today? (org-agenda-today-p date)) ; DATE bound by calendar. + (current (calendar-absolute-from-gregorian date)) + deadline-items) (goto-char (point-min)) (while (re-search-forward regexp nil t) (catch :skip + (unless (save-match-data (org-at-planning-p)) (throw :skip nil)) (org-agenda-skip) - (setq s (match-string 1) - txt nil - pos (1- (match-beginning 1)) - todo-state (save-match-data (org-get-todo-state)) - show-all (or (eq org-agenda-repeating-timestamp-show-all t) - (member todo-state - org-agenda-repeating-timestamp-show-all)) - d2 (org-time-string-to-absolute - 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))))))) + (let* ((s (match-string 1)) + (pos (1- (match-beginning 1))) + (todo-state (save-match-data (org-get-todo-state))) + (done? (member todo-state org-done-keywords)) + (sexp? (string-prefix-p "%%" s)) + ;; DEADLINE is the deadline date for the entry. It is + ;; either the base date or the last repeat, according + ;; to `org-agenda-prefer-last-repeat'. + (deadline (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)) - dfrac (- 1 (/ (* 1.0 diff) (max wdays 1))) - upcomingp (and todayp (> diff 0))) - ;; When to show a deadline in the calendar: - ;; If the expiration is within wdays warning time. - ;; Past-due deadlines are only shown on the current date - (if (and (or (and (<= diff wdays) - (and todayp (not org-agenda-only-exact-dates))) - (= diff 0))) - (save-excursion - ;; (setq todo-state (org-get-todo-state)) - (setq donep (member todo-state org-done-keywords)) - (if (and donep - (or org-agenda-skip-deadline-if-done - (not (= diff 0)))) - (setq txt nil) - (setq category (org-get-category) - warntime (get-text-property (point) 'org-appt-warntime)) - (if (not (re-search-backward "^\\*+[ \t]+" nil t)) - (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) - (memq 'agenda org-agenda-show-inherited-tags)) - (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 pos1 (not inherited-tags))) - (setq head (buffer-substring - (point) - (progn (skip-chars-forward "^\r\n") - (point)))) - (if (string-match " \\([012]?[0-9]:[0-9][0-9]\\)" s) - (setq timestr - (concat (substring s (match-beginning 1)) " ")) - (setq timestr 'time)) - (setq txt (org-agenda-format-item - (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)) - 'todo-state todo-state - 'type (if upcomingp "upcoming-deadline" "deadline") - 'date (if upcomingp date d2) - 'face (if donep 'org-agenda-done face) - 'undone-face face 'done-face 'org-agenda-done) - (push txt ee)))))) - (nreverse ee))) + (sexp? (org-agenda--timestamp-to-absolute s current)) + ((or (eq org-agenda-prefer-last-repeat t) + (member todo-state org-agenda-prefer-last-repeat)) + (org-agenda--timestamp-to-absolute + s today 'past (current-buffer) pos)) + (t (org-agenda--timestamp-to-absolute s)))) + ;; REPEAT is the future repeat closest from CURRENT, + ;; according to `org-agenda-show-future-repeats'. If + ;; the latter is nil, or if the time stamp has no + ;; repeat part, default to DEADLINE. + (repeat + (cond + (sexp? deadline) + ((<= current today) deadline) + ((not org-agenda-show-future-repeats) deadline) + (t + (let ((base (if (eq org-agenda-show-future-repeats 'next) + (1+ today) + current))) + (org-agenda--timestamp-to-absolute + s base 'future (current-buffer) pos))))) + (diff (- deadline current)) + (suppress-prewarning + (let ((scheduled + (and org-agenda-skip-deadline-prewarning-if-scheduled + (org-entry-get nil "SCHEDULED")))) + (cond + ((not scheduled) nil) + ;; The current item has a scheduled date, 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 pre-warning to no earlier than SCHEDULED. + (min (- deadline + (org-agenda--timestamp-to-absolute scheduled)) + org-deadline-warning-days)) + ;; Set pre-warning to deadline. + (t 0)))) + (wdays (if suppress-prewarning + (let ((org-deadline-warning-days suppress-prewarning)) + (org-get-wdays s)) + (org-get-wdays s)))) + (cond + ;; Only display deadlines at their base date, at future + ;; repeat occurrences or in today agenda. + ((= current deadline) nil) + ((= current repeat) nil) + ((not today?) (throw :skip nil)) + ;; Upcoming deadline: display within warning period WDAYS. + ((> deadline current) (when (> diff wdays) (throw :skip nil))) + ;; Overdue deadline: warn about it for + ;; `org-deadline-past-days' duration. + (t (when (< org-deadline-past-days (- diff)) (throw :skip nil)))) + ;; Possibly skip done tasks. + (when (and done? + (or org-agenda-skip-deadline-if-done + (/= deadline current))) + (throw :skip nil)) + (save-excursion + (re-search-backward "^\\*+[ \t]+" nil t) + (goto-char (match-end 0)) + (let* ((category (org-get-category)) + (level (make-string (org-reduced-level (org-outline-level)) + ?\s)) + (head (buffer-substring (point) (line-end-position))) + (inherited-tags + (or (eq org-agenda-show-inherited-tags 'always) + (and (listp org-agenda-show-inherited-tags) + (memq 'agenda org-agenda-show-inherited-tags)) + (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))) + (time + (cond + ;; No time of day designation if it is only + ;; a reminder. + ((and (/= current deadline) (/= current repeat)) nil) + ((string-match " \\([012]?[0-9]:[0-9][0-9]\\)" s) + (concat (substring s (match-beginning 1)) " ")) + (t 'time))) + (item + (org-agenda-format-item + ;; Insert appropriate suffixes before deadlines. + ;; Those only apply to today agenda. + (pcase-let ((`(,now ,future ,past) + org-agenda-deadline-leaders)) + (cond + ((and today? (< deadline today)) (format past (- diff))) + ((and today? (> deadline today)) (format future diff)) + (t now))) + head level category tags time)) + (face (org-agenda-deadline-face + (- 1 (/ (float diff) (max wdays 1))))) + (upcoming? (and today? (> deadline today))) + (warntime (get-text-property (point) 'org-appt-warntime))) + (org-add-props item props + 'org-marker (org-agenda-new-marker pos) + 'org-hd-marker (org-agenda-new-marker (line-beginning-position)) + 'warntime warntime + 'level level + 'ts-date deadline + 'priority + ;; Adjust priority to today reminders about deadlines. + ;; Overdue deadlines get the highest priority + ;; increase, then imminent deadlines and eventually + ;; more distant deadlines. + (let ((adjust (if today? (- diff) 0))) + (+ adjust (org-get-priority item))) + 'todo-state todo-state + 'type (if upcoming? "upcoming-deadline" "deadline") + 'date (if upcoming? date deadline) + 'face (if done? 'org-agenda-done face) + 'undone-face face + 'done-face 'org-agenda-done) + (push item deadline-items)))))) + (nreverse deadline-items))) (defun org-agenda-deadline-face (fraction) "Return the face to displaying a deadline item. FRACTION is what fraction of the head-warning time has passed." - (let ((faces org-agenda-deadline-faces) f) - (catch 'exit - (while (setq f (pop faces)) - (if (>= fraction (car f)) (throw 'exit (cdr f))))))) + (assoc-default fraction org-agenda-deadline-faces #'<=)) -(defun org-agenda-get-scheduled (&optional deadline-results with-hour) +(defun org-agenda-get-scheduled (&optional deadlines 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." +Optional argument DEADLINES is a list of deadline items to be +displayed in agenda view. 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 'done-face 'org-agenda-done 'mouse-face 'highlight 'help-echo - (format "mouse-2 or RET jump to org file %s" + (format "mouse-2 or RET jump to Org file %s" (abbreviate-file-name buffer-file-name)))) (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 - (deadline-position-alist - (mapcar (lambda (a) (and (setq mm (get-text-property - 0 'org-hd-marker a)) - (cons (marker-position mm) a))) - deadline-results)) - d2 diff pos pos1 category level tags donep - ee txt head pastschedp todo-state face timestr s habitp show-all - did-habit-check-p warntime inherited-tags ts-date suppress-delay - ddays) + (today (org-today)) + (todayp (org-agenda-today-p date)) ; DATE bound by calendar. + (current (calendar-absolute-from-gregorian date)) + (deadline-pos + (mapcar (lambda (d) + (let ((m (get-text-property 0 'org-hd-marker d))) + (and m (marker-position m)))) + deadlines)) + scheduled-items) (goto-char (point-min)) (while (re-search-forward regexp nil t) (catch :skip + (unless (save-match-data (org-at-planning-p)) (throw :skip nil)) (org-agenda-skip) - (setq s (match-string 1) - txt nil - pos (1- (match-beginning 1)) - todo-state (save-match-data (org-get-todo-state)) - show-all (or (eq org-agenda-repeating-timestamp-show-all t) - (member todo-state - org-agenda-repeating-timestamp-show-all)) - d2 (org-time-string-to-absolute - 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))))))) + (let* ((s (match-string 1)) + (pos (1- (match-beginning 1))) + (todo-state (save-match-data (org-get-todo-state))) + (donep (member todo-state org-done-keywords)) + (sexp? (string-prefix-p "%%" s)) + ;; SCHEDULE is the scheduled date for the entry. It is + ;; either the bare date or the last repeat, according + ;; to `org-agenda-prefer-last-repeat'. + (schedule (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 (> 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))) - ;; org-is-habit-p uses org-entry-get, which is expansive - ;; so we go extra mile to only call it once - (and todayp - (boundp 'org-habit-show-all-today) - org-habit-show-all-today - (setq did-habit-check-p t) - (setq habitp (and (functionp 'org-is-habit-p) - (org-is-habit-p))))) - (save-excursion - (setq donep (member todo-state org-done-keywords)) - (if (and donep + (sexp? (org-agenda--timestamp-to-absolute s current)) + ((or (eq org-agenda-prefer-last-repeat t) + (member todo-state org-agenda-prefer-last-repeat)) + (org-agenda--timestamp-to-absolute + s today 'past (current-buffer) pos)) + (t (org-agenda--timestamp-to-absolute s)))) + ;; REPEAT is the future repeat closest from CURRENT, + ;; according to `org-agenda-show-future-repeats'. If + ;; the latter is nil, or if the time stamp has no + ;; repeat part, default to SCHEDULE. + (repeat + (cond + (sexp? schedule) + ((<= current today) schedule) + ((not org-agenda-show-future-repeats) schedule) + (t + (let ((base (if (eq org-agenda-show-future-repeats 'next) + (1+ today) + current))) + (org-agenda--timestamp-to-absolute + s base 'future (current-buffer) pos))))) + (diff (- current schedule)) + (warntime (get-text-property (point) 'org-appt-warntime)) + (pastschedp (< schedule today)) + (habitp (and (fboundp 'org-is-habit-p) (org-is-habit-p))) + (suppress-delay + (let ((deadline (and org-agenda-skip-scheduled-delay-if-deadline + (org-entry-get nil "DEADLINE")))) + (cond + ((not deadline) nil) + ;; The current item has a deadline date, 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 (- schedule + (org-agenda--timestamp-to-absolute deadline)) + org-scheduled-delay-days)) + (t 0)))) + (ddays + (cond + ;; Nullify delay when a repeater triggered already + ;; and the delay is of the form --Xd. + ((and (string-match-p "--[0-9]+[hdwmy]" s) + (> current schedule)) + 0) + (suppress-delay + (let ((org-scheduled-delay-days suppress-delay)) + (org-get-wdays s t t))) + (t (org-get-wdays s t))))) + ;; Display scheduled items at base date (SCHEDULE), today if + ;; scheduled before the current date, and at any repeat past + ;; today. However, skip delayed items and items that have + ;; been displayed for more than `org-scheduled-past-days'. + (unless (and todayp + habitp + (bound-and-true-p org-habit-show-all-today)) + (when (or (and (> ddays 0) (< diff ddays)) + (> diff org-scheduled-past-days) + (> schedule current) + (and (/= current schedule) + (/= current today) + (/= current repeat))) + (throw :skip nil))) + ;; Possibly skip done tasks. + (when (and donep (or org-agenda-skip-scheduled-if-done - (not (= diff 0)) - (and (functionp 'org-is-habit-p) - (org-is-habit-p)))) - (setq txt nil) - (setq habitp (if did-habit-check-p habitp - (and (functionp 'org-is-habit-p) - (org-is-habit-p)))) - (setq category (org-get-category)) - (if (and (eq org-agenda-skip-scheduled-if-deadline-is-shown - 'repeated-after-deadline) - (org-get-deadline-time (point)) - (<= 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)) - (setq pos1 (match-beginning 0)) - (if habitp - (if (or (not org-habit-show-habits) - (and (not todayp) - (boundp 'org-habit-show-habits-only-for-today) - org-habit-show-habits-only-for-today)) - (throw :skip nil)) - (if (and - (or (eq t 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))) - (setq inherited-tags - (or (eq org-agenda-show-inherited-tags 'always) - (and (listp org-agenda-show-inherited-tags) - (memq 'agenda org-agenda-show-inherited-tags)) - (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)))) - (if (string-match " \\([012]?[0-9]:[0-9][0-9]\\)" s) - (setq timestr - (concat (substring s (match-beginning 1)) " ")) - (setq timestr 'time)) - (setq txt (org-agenda-format-item - (if (= diff 0) - (car org-agenda-scheduled-leaders) - (format (nth 1 org-agenda-scheduled-leaders) - (- 1 diff))) - head level category tags - (if (not (= diff 0)) nil timestr) - nil habitp)))) - (when txt - (setq face + (/= schedule current))) + (throw :skip nil)) + ;; Skip entry if it already appears as a deadline, per + ;; `org-agenda-skip-scheduled-if-deadline-is-shown'. This + ;; doesn't apply to habits. + (when (pcase org-agenda-skip-scheduled-if-deadline-is-shown + ((guard + (or (not (memq (line-beginning-position 0) deadline-pos)) + habitp)) + nil) + (`repeated-after-deadline + (let ((deadline (time-to-days + (org-get-deadline-time (point))))) + (and (<= schedule deadline) (> current deadline)))) + (`not-today pastschedp) + (`t t) + (_ nil)) + (throw :skip nil)) + ;; Skip habits if `org-habit-show-habits' is nil, or if we + ;; only show them for today. Also skip done habits. + (when (and habitp + (or donep + (not (bound-and-true-p org-habit-show-habits)) + (and (not todayp) + (bound-and-true-p + org-habit-show-habits-only-for-today)))) + (throw :skip nil)) + (save-excursion + (re-search-backward "^\\*+[ \t]+" nil t) + (goto-char (match-end 0)) + (let* ((category (org-get-category)) + (inherited-tags + (or (eq org-agenda-show-inherited-tags 'always) + (and (listp org-agenda-show-inherited-tags) + (memq 'agenda org-agenda-show-inherited-tags)) + (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))) + (level (make-string (org-reduced-level (org-outline-level)) + ?\s)) + (head (buffer-substring (point) (line-end-position))) + (time (cond - ((and (not habitp) pastschedp) - 'org-scheduled-previously) - (todayp 'org-scheduled-today) - (t 'org-scheduled)) - habitp (and habitp (org-habit-parse-todo))) - (org-add-props txt props + ;; No time of day designation if it is only + ;; a reminder. + ((and (/= current schedule) (/= current repeat)) nil) + ((string-match " \\([012]?[0-9]:[0-9][0-9]\\)" s) + (concat (substring s (match-beginning 1)) " ")) + (t 'time))) + (item + (org-agenda-format-item + (pcase-let ((`(,first ,past) org-agenda-scheduled-leaders)) + ;; Show a reminder of a past scheduled today. + (if (and todayp pastschedp) + (format past diff) + first)) + head level category tags time nil habitp)) + (face (cond ((and (not habitp) pastschedp) + 'org-scheduled-previously) + (todayp 'org-scheduled-today) + (t 'org-scheduled))) + (habitp (and habitp (org-habit-parse-todo)))) + (org-add-props item props 'undone-face face 'face (if donep 'org-agenda-done face) 'org-marker (org-agenda-new-marker pos) - 'org-hd-marker (org-agenda-new-marker pos1) + 'org-hd-marker (org-agenda-new-marker (line-beginning-position)) 'type (if pastschedp "past-scheduled" "scheduled") - 'date (if pastschedp d2 date) - 'ts-date d2 + 'date (if pastschedp schedule date) + 'ts-date schedule 'warntime warntime 'level level - 'priority (if habitp - (org-habit-get-priority habitp) - (+ 94 (- 5 diff) (org-get-priority txt))) + 'priority (if habitp (org-habit-get-priority habitp) + (+ 99 diff (org-get-priority item))) 'org-habit-p habitp 'todo-state todo-state) - (push txt ee)))))) - (nreverse ee))) + (push item scheduled-items)))))) + (nreverse scheduled-items))) (defun org-agenda-get-blocks () "Return the date-range information for agenda display." @@ -6382,7 +6290,7 @@ an hour specification like [h]h:mm." tags (org-get-tags-at nil (not inherited-tags))) (setq level (make-string (org-reduced-level (org-outline-level)) ? )) - (looking-at "\\*+[ \t]+\\([^\r\n]+\\)") + (looking-at "\\*+[ \t]+\\(.*\\)") (setq head (match-string 1)) (let ((remove-re (if org-agenda-remove-timeranges-from-blocks @@ -6436,11 +6344,11 @@ The flag is set if the currently compiled format contains a `%b'.") (defun org-agenda-get-category-icon (category) "Return an image for CATEGORY according to `org-agenda-category-icon-alist'." - (dolist (entry org-agenda-category-icon-alist) - (when (org-string-match-p (car entry) category) + (cl-dolist (entry org-agenda-category-icon-alist) + (when (string-match-p (car entry) category) (if (listp (cadr entry)) - (return (cadr entry)) - (return (apply 'create-image (cdr entry))))))) + (cl-return (cadr entry)) + (cl-return (apply #'create-image (cdr entry))))))) (defun org-agenda-format-item (extra txt &optional level category tags dotime remove-re habitp) @@ -6467,8 +6375,8 @@ Any match of REMOVE-RE will be removed from TXT." ;; buffer (let* ((bindings (car org-prefix-format-compiled)) (formatter (cadr org-prefix-format-compiled))) - (loop for (var value) in bindings - do (set var value)) + (cl-loop for (var value) in bindings + do (set var value)) (save-match-data ;; Diary entries sometimes have extra whitespace at the beginning (setq txt (org-trim txt)) @@ -6525,21 +6433,21 @@ Any match of REMOVE-RE will be removed from TXT." (if s1 (setq s1 (org-get-time-of-day s1 'string t))) (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 - (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))))) + ;; 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-duration-from-minutes + (+ (org-duration-to-minutes s1 t) + org-agenda-default-appointment-duration) + nil t))) ;; Compute the duration (when s2 - (setq duration (- (org-hh:mm-string-to-minutes s2) - (org-hh:mm-string-to-minutes s1))))) + (setq duration (- (org-duration-to-minutes s2) + (org-duration-to-minutes s1))))) - (when (string-match (org-re "\\([ \t]+\\)\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$") - txt) + (when (string-match "\\([ \t]+\\)\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$" txt) ;; Tags are in the string (if (or (eq org-agenda-remove-tags t) (and org-agenda-remove-tags @@ -6614,7 +6522,7 @@ Any match of REMOVE-RE will be removed from TXT." The modified list may contain inherited tags, and tags matched by `org-agenda-hide-tags-regexp' will be removed." (when (or add-inherited hide-re) - (if (string-match (org-re "\\([ \t]+\\)\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$") txt) + (if (string-match "\\([ \t]+\\)\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$" txt) (setq txt (substring txt 0 (match-beginning 0)))) (setq tags (delq nil @@ -6719,12 +6627,12 @@ and stored in the variable `org-prefix-format-compiled'." c (or (match-string 3 s) "") opt (match-beginning 1) start (1+ (match-beginning 0))) - (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)) + (if (eq var 'time) (setq org-prefix-has-time t)) + (if (eq var 'tag) (setq org-prefix-has-tag t)) + (if (eq var 'effort) (setq org-prefix-has-effort t)) + (if (eq var 'breadcrumbs) (setq org-prefix-has-breadcrumbs t)) (setq f (concat "%" (match-string 2 s) "s")) - (when (equal var 'category) + (when (eq var 'category) (setq org-prefix-category-length (floor (abs (string-to-number (match-string 2 s))))) (setq org-prefix-category-max-length @@ -6947,8 +6855,14 @@ The optional argument TYPE tells the agenda type." (defsubst org-cmp-effort (a b) "Compare the effort values of string A and B." (let* ((def (if org-sort-agenda-noeffort-is-high 32767 -1)) - (ea (or (get-text-property (1- (length a)) 'effort-minutes a) def)) - (eb (or (get-text-property (1- (length b)) 'effort-minutes b) def))) + ;; `effort-minutes' property is not directly accessible from + ;; the strings, but is stored as a property in `txt'. + (ea (or (get-text-property + 0 'effort-minutes (get-text-property 0 'txt a)) + def)) + (eb (or (get-text-property + 0 'effort-minutes (get-text-property 0 'txt b)) + def))) (cond ((> ea eb) +1) ((< ea eb) -1)))) @@ -6986,7 +6900,8 @@ The optional argument TYPE tells the agenda type." (let* ((pla (text-property-any 0 (length a) 'org-heading t a)) (plb (text-property-any 0 (length b) 'org-heading t b)) (ta (and pla (substring a pla))) - (tb (and plb (substring b plb)))) + (tb (and plb (substring b plb))) + (case-fold-search nil)) (when pla (if (string-match (concat "\\`[ \t]*" (or (get-text-property 0 'org-todo-regexp a) "") "\\([ \t]*\\[[a-zA-Z0-9]\\]\\)? *") ta) @@ -7110,13 +7025,29 @@ their type." 'face 'org-agenda-restriction-lock) (overlay-put org-agenda-restriction-lock-overlay 'help-echo "Agendas are currently limited to this subtree.") -(org-detach-overlay org-agenda-restriction-lock-overlay) +(delete-overlay org-agenda-restriction-lock-overlay) + +(defun org-agenda-set-restriction-lock-from-agenda (arg) + "Set the restriction lock to the agenda item at point from within the agenda. +When called with a `\\[universal-argument]' prefix, restrict to +the file which contains the item. +Argument ARG is the prefix argument." + (interactive "P") + (unless (derived-mode-p 'org-agenda-mode) + (user-error "Not in an Org agenda buffer")) + (let* ((marker (or (org-get-at-bol 'org-marker) + (org-agenda-error))) + (buffer (marker-buffer marker)) + (pos (marker-position marker))) + (with-current-buffer buffer + (goto-char pos) + (org-agenda-set-restriction-lock arg)))) ;;;###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 -universal prefix '(4), or if the cursor is before the first headline +universal prefix \\='(4), or if the cursor is before the first headline in the file. Otherwise, restriction will be to the current subtree." (interactive "P") (org-agenda-remove-restriction-lock 'noupdate) @@ -7156,8 +7087,8 @@ in the file. Otherwise, restriction will be to the current subtree." (defun org-agenda-remove-restriction-lock (&optional noupdate) "Remove the agenda restriction lock." (interactive "P") - (org-detach-overlay org-agenda-restriction-lock-overlay) - (org-detach-overlay org-speedbar-restriction-lock-overlay) + (delete-overlay org-agenda-restriction-lock-overlay) + (delete-overlay org-speedbar-restriction-lock-overlay) (setq org-agenda-overriding-restriction nil) (setq org-agenda-restrict nil) (put 'org-agenda-files 'org-restrict nil) @@ -7187,7 +7118,7 @@ in the file. Otherwise, restriction will be to the current subtree." (defun org-agenda-check-type (error &rest types) "Check if agenda buffer is of allowed type. If ERROR is non-nil, throw an error, otherwise just return nil. -Allowed types are 'agenda 'timeline 'todo 'tags 'search." +Allowed types are `agenda' `timeline' `todo' `tags' `search'." (if (not org-agenda-type) (error "No Org agenda currently displayed") (if (memq org-agenda-type types) @@ -7220,8 +7151,8 @@ agenda." (defun org-agenda--quit (&optional bury) (if org-agenda-columns-active (org-columns-quit) - (let ((buf (current-buffer)) - (wconf org-agenda-pre-window-conf) + (let ((wconf org-agenda-pre-window-conf) + (buf (current-buffer)) (org-agenda-last-indirect-window (and (eq org-indirect-buffer-display 'other-window) org-agenda-last-indirect-buffer @@ -7243,7 +7174,11 @@ agenda." (not (one-window-p)) (delete-window)))) (if bury - (bury-buffer buf) + ;; Set the agenda buffer as the current buffer instead of + ;; passing it as an argument to `bury-buffer' so that + ;; `bury-buffer' removes it from the window. + (with-current-buffer buf + (bury-buffer)) (kill-buffer buf) (setq org-agenda-archives-mode nil org-agenda-buffer nil))))) @@ -7262,8 +7197,7 @@ touched. Also, exit the agenda even if it is in column view." (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." (interactive) (let (blist) (dolist (buf (buffer-list)) @@ -7343,7 +7277,7 @@ in the agenda." (when effort (org-agenda-filter-apply effort 'effort)) (when re (org-agenda-filter-apply re 'regexp))) (and top-hl-filter (org-agenda-filter-top-headline-apply top-hl-filter)) - (and cols (org-called-interactively-p 'any) (org-agenda-columns)) + (and cols (called-interactively-p 'any) (org-agenda-columns)) (org-goto-line line) (recenter window-line))) @@ -7352,8 +7286,11 @@ in the agenda." (defvar org-agenda-filtered-by-category nil) (defun org-agenda-filter-by-category (strip) - "Keep only those lines in the agenda buffer that have a specific category. -The category is that of the current line." + "Filter lines in the agenda buffer that have a specific category. +The category is that of the current line. +Without prefix argument, keep only the lines of that category. +With a prefix argument, exclude the lines of that category. +" (interactive "P") (if (and org-agenda-filtered-by-category org-agenda-category-filter) @@ -7363,21 +7300,22 @@ The category is that of the current line." ((and cat strip) (org-agenda-filter-apply (push (concat "-" cat) org-agenda-category-filter) 'category)) - ((and cat) + (cat (org-agenda-filter-apply (setq org-agenda-category-filter (list (concat "+" cat))) 'category)) (t (error "No category at point")))))) (defun org-find-top-headline (&optional pos) - "Find the topmost parent headline and return it." + "Find the topmost parent headline and return it. +POS when non-nil is the marker or buffer position to start the +search from." (save-excursion - (with-current-buffer (if pos (marker-buffer pos) (current-buffer)) - (if pos (goto-char pos)) - ;; Skip up to the topmost parent - (while (ignore-errors (outline-up-heading 1) t)) - (ignore-errors - (nth 4 (org-heading-components)))))) + (with-current-buffer (if (markerp pos) (marker-buffer pos) (current-buffer)) + (when pos (goto-char pos)) + ;; Skip up to the topmost parent. + (while (org-up-heading-safe)) + (ignore-errors (nth 4 (org-heading-components)))))) (defvar org-agenda-filtered-by-top-headline nil) (defun org-agenda-filter-by-top-headline (strip) @@ -7419,31 +7357,41 @@ With no prefix argument, keep entries matching the effort condition. With one prefix argument, filter out entries matching the condition. With two prefix arguments, remove the effort filters." (interactive "P") - (cond ((member strip '(nil 4)) - (let ((efforts (org-split-string - (or (cdr (assoc (concat org-effort-property "_ALL") - org-global-properties)) - "0 0:10 0:30 1:00 2:00 3:00 4:00 5:00 6:00 7:00 8:00" - ""))) - (eff -1) - effort-prompt op) - (while (not (member op '(?< ?> ?=))) - (setq op (read-char-exclusive "Effort operator? (> = or <)"))) - (loop for i from 0 to 9 do - (setq effort-prompt - (concat - effort-prompt " [" - (if (= i 9) "0" (int-to-string (1+ i))) - "]" (nth i efforts)))) - (message "Effort %s%s" (char-to-string op) effort-prompt) - (while (or (< eff 0) (> eff 9)) - (setq eff (string-to-number (char-to-string (read-char-exclusive))))) + (cond + ((member strip '(nil 4)) + (let* ((efforts (split-string + (or (cdr (assoc (concat org-effort-property "_ALL") + org-global-properties)) + "0 0:10 0:30 1:00 2:00 3:00 4:00 5:00 6:00 7:00"))) + ;; XXX: the following handles only up to 10 different + ;; effort values. + (allowed-keys (if (null efforts) nil + (mapcar (lambda (n) (mod n 10)) ;turn 10 into 0 + (number-sequence 1 (length efforts))))) + (op nil)) + (while (not (memq op '(?< ?> ?=))) + (setq op (read-char-exclusive "Effort operator? (> = or <)"))) + ;; Select appropriate duration. Ignore non-digit characters. + (let ((prompt + (apply #'format + (concat "Effort %c " + (mapconcat (lambda (s) (concat "[%d]" s)) + efforts + " ")) + op allowed-keys)) + (eff -1)) + (while (not (memq eff allowed-keys)) + (message prompt) + (setq eff (- (read-char-exclusive) 48))) (setq org-agenda-effort-filter (list (concat (if strip "-" "+") - (char-to-string op) (nth (1- eff) efforts)))) - (org-agenda-filter-apply org-agenda-effort-filter 'effort))) - (t (org-agenda-filter-show-all-effort) - (message "Effort filter removed")))) + (char-to-string op) + ;; Numbering is 1 2 3 ... 9 0, but we want + ;; 0 1 2 ... 8 9. + (nth (mod (1- eff) 10) efforts))))) + (org-agenda-filter-apply org-agenda-effort-filter 'effort))) + (t (org-agenda-filter-show-all-effort) + (message "Effort filter removed")))) (defun org-agenda-filter-remove-all () "Remove all filters from the current agenda buffer." @@ -7462,15 +7410,18 @@ With two prefix arguments, remove the effort filters." (defun org-agenda-filter-by-tag (arg &optional char exclude) "Keep only those lines in the agenda buffer that have a specific tag. -The tag is selected with its fast selection letter, as -configured. With a single \\[universal-argument] prefix ARG, -exclude the agenda search. With a double \\[universal-argument] -prefix ARG, filter the literal tag. I.e. don't filter on all its -group members. - -A lisp caller can specify CHAR. EXCLUDE means that the new tag should be -used to exclude the search - the interactive user can also press `-' or `+' -to switch between filtering and excluding." + +The tag is selected with its fast selection letter, as configured. + +With a `\\[universal-argument]' prefix, exclude the agenda search. + +With a `\\[universal-argument] \\[universal-argument]' prefix, filter the literal tag, \ +i.e. don't +filter on all its group members. + +A lisp caller can specify CHAR. EXCLUDE means that the new tag +should be used to exclude the search - the interactive user can +also press `-' or `+' to switch between filtering and excluding." (interactive "P") (let* ((alist org-tag-alist-for-agenda) (tag-chars (mapconcat @@ -7499,10 +7450,10 @@ to switch between filtering and excluding." ((eq char ?+) (setq exclude nil))))) (when (eq char ?\t) (unless (local-variable-p 'org-global-tags-completion-table (current-buffer)) - (org-set-local 'org-global-tags-completion-table - (org-global-tags-completion-table))) + (setq-local org-global-tags-completion-table + (org-global-tags-completion-table))) (let ((completion-ignore-case t)) - (setq tag (org-icompleting-read + (setq tag (completing-read "Tag: " org-global-tags-completion-table)))) (cond ((eq char ?\r) @@ -7547,10 +7498,6 @@ to switch between filtering and excluding." (get-text-property (point) 'tags)))) tags)) -(defun org-agenda-filter-by-tag-refine (arg &optional char) - "Refine the current filter. See `org-agenda-filter-by-tag'." - (interactive "P") - (org-agenda-filter-by-tag arg char 'refine)) (defun org-agenda-filter-make-matcher (filter type &optional expand) "Create the form that tests a line for agenda filter. Optional @@ -7603,30 +7550,22 @@ tags in the FILTER if any of the tags in FILTER are grouptags." (cons 'and (nreverse f)))) (defun org-agenda-filter-make-matcher-tag-exp (tags op) - "Create the form that tests a line for agenda filter for -tag-expressions. Return a match-expression given TAGS. OP is an -operator of type CHAR that allows the function to set the right -switches in the returned form." - (let (f f1) ;f = return expression. f1 = working-area - (dolist (x tags) + "Return a form associated to tag-expression TAGS. +Build a form testing a line for agenda filter for +tag-expressions. OP is an operator of type CHAR that allows the +function to set the right switches in the returned form." + (let (form) + ;; Any of the expressions can match if OP is +, all must match if + ;; the operator is -. + (dolist (x tags (cons (if (eq op ?-) 'and 'or) form)) (let* ((tag (substring x 1)) - (isregexp (and (equal "{" (substring tag 0 1)) - (equal "}" (substring tag -1)))) - regexp) - (cond - (isregexp - (setq regexp (substring tag 1 -1)) - (setq f1 (list 'org-match-any-p regexp 'tags))) - (t - (setq f1 (list 'member (downcase tag) 'tags)))) - (when (eq op ?-) - (setq f1 (list 'not f1)))) - (push f1 f)) - ;; Any of the expressions can match if op = + - ;; all must match if the operator is -. - (if (eq op ?-) - (cons 'and f) - (cons 'or f)))) + (f (cond + ((string= "" tag) '(not tags)) + ((and (string-match-p "\\`{" tag) (string-match-p "}\\'" tag)) + ;; TAG is a regexp. + (list 'org-match-any-p (substring tag 1 -1) 'tags)) + (t (list 'member (downcase tag) 'tags))))) + (push (if (eq op ?-) (list 'not f) f) form))))) (defun org-agenda-filter-effort-form (e) "Return the form to compare the effort of the current line with what E says. @@ -7639,13 +7578,16 @@ E looks like \"+<2:25\"." ((equal op ??) op) (t '=))) (list 'org-agenda-compare-effort (list 'quote op) - (org-duration-string-to-minutes e)))) + (org-duration-to-minutes e)))) (defun org-agenda-compare-effort (op value) "Compare the effort of the current line with VALUE, using OP. If the line does not have an effort defined, return nil." - (let ((eff (org-get-at-eol 'effort-minutes 1))) - (funcall op (or eff (if org-sort-agenda-noeffort-is-high 32767 -1)) + ;; `effort-minutes' property cannot be extracted directly from + ;; current line but is stored as a property in `txt'. + (let ((effort (get-text-property 0 'effort-minutes (org-get-at-bol 'txt)))) + (funcall op + (or effort (if org-sort-agenda-noeffort-is-high 32767 -1)) value))) (defun org-agenda-filter-expand-tags (filter &optional no-operator) @@ -7687,7 +7629,7 @@ tags in the FILTER if any of the tags in FILTER are grouptags." (progn (setq tags (org-get-at-bol 'tags) cat (org-get-at-eol 'org-category 1) - txt (org-get-at-eol 'txt 1)) + txt (org-get-at-bol 'txt)) (if (not (eval org-agenda-filter-form)) (org-agenda-filter-hide-line type)) (beginning-of-line 2)) @@ -7840,7 +7782,7 @@ Negative selection means regexp must not match for selection of an entry." (tdpos (goto-char tdpos)) ((eq org-agenda-type 'agenda) (let* ((sd (org-agenda-compute-starting-span - (org-today) (or curspan org-agenda-ndays org-agenda-span))) + (org-today) (or curspan org-agenda-span))) (org-agenda-overriding-arguments args)) (setf (nth 1 org-agenda-overriding-arguments) sd) (org-agenda-redo) @@ -7940,71 +7882,77 @@ With prefix ARG, go backward that many times the current span." (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))) - (case a - (?\ (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)) - (?L (org-agenda-log-mode '(4))) - (?c (org-agenda-log-mode 'clockcheck)) - ((?F ?f) (call-interactively 'org-agenda-follow-mode)) - (?a (call-interactively 'org-agenda-archives-mode)) - (?A (org-agenda-archives-mode 'files)) - ((?R ?r) (call-interactively 'org-agenda-clockreport-mode)) - ((?E ?e) (call-interactively 'org-agenda-entry-text-mode)) - (?G (call-interactively 'org-agenda-toggle-time-grid)) - (?D (call-interactively 'org-agenda-toggle-diary)) - (?\! (call-interactively 'org-agenda-toggle-deadlines)) - (?\[ (let ((org-agenda-include-inactive-timestamps t)) - (org-agenda-check-type t 'timeline 'agenda) - (org-agenda-redo)) - (message "Display now includes inactive timestamps as well")) - (?q (message "Abort")) - (otherwise (error "Invalid key" ))))) + (pcase (read-char-exclusive) + (?\ (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)) + (?L (org-agenda-log-mode '(4))) + (?c (org-agenda-log-mode 'clockcheck)) + ((or ?F ?f) (call-interactively 'org-agenda-follow-mode)) + (?a (call-interactively 'org-agenda-archives-mode)) + (?A (org-agenda-archives-mode 'files)) + ((or ?R ?r) (call-interactively 'org-agenda-clockreport-mode)) + ((or ?E ?e) (call-interactively 'org-agenda-entry-text-mode)) + (?G (call-interactively 'org-agenda-toggle-time-grid)) + (?D (call-interactively 'org-agenda-toggle-diary)) + (?\! (call-interactively 'org-agenda-toggle-deadlines)) + (?\[ (let ((org-agenda-include-inactive-timestamps t)) + (org-agenda-check-type t 'timeline 'agenda) + (org-agenda-redo)) + (message "Display now includes inactive timestamps as well")) + (?q (message "Abort")) + (key (user-error "Invalid key: %s" key)))) (defun org-agenda-reset-view () "Switch to default view for agenda." (interactive) - (org-agenda-change-time-span (or org-agenda-ndays org-agenda-span))) + (org-agenda-change-time-span org-agenda-span)) + (defun org-agenda-day-view (&optional day-of-month) "Switch to daily view for agenda. With argument DAY-OF-MONTH, switch to that day of the month." (interactive "P") (org-agenda-change-time-span 'day day-of-month)) + (defun org-agenda-week-view (&optional iso-week) - "Switch to daily view for agenda. + "Switch to weekly 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." +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 ranging from 70 years ago +to 30 years in the future 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. + "Switch to fortnightly 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." +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 ranging from 70 years ago +to 30 years in the future 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." +With argument MONTH, switch to that month. If MONTH has more +then 2 digits, only the last two encode the month. Any digits +before this encode a year. So 200712 means December year 2007. +Years ranging from 70 years ago to 30 years in the future can +also be written as 2-digit years." (interactive "P") (org-agenda-change-time-span 'month month)) + (defun org-agenda-year-view (&optional year) "Switch to yearly view for agenda. -With argument YEAR, switch to that year. -If MONTH has more then 2 digits, only the last two encode the -month. Any digits before this encode a year. So 200712 means -December year 2007. Years in the range 1938-2037 can also be -written as 2-digit years." +With argument YEAR, switch to that year. Years ranging from 70 +years ago to 30 years in the future can also be written as +2-digit years." (interactive "P") (when year (setq year (org-small-year-to-year year))) @@ -8108,7 +8056,7 @@ so that the date SD will be in that range." (defun org-unhighlight () "Detach overlay INDEX." - (org-detach-overlay org-hl)) + (delete-overlay org-hl)) (defun org-unhighlight-once () "Remove the highlight from its position, and this function from the hook." @@ -8165,9 +8113,12 @@ so that the date SD will be in that range." (defun org-agenda-log-mode (&optional special) "Toggle log mode in an agenda buffer. + With argument SPECIAL, show all possible log items, not only the ones configured in `org-agenda-log-mode-items'. -With a double `C-u' prefix arg, show *only* log items, nothing else." + +With a `\\[universal-argument] \\[universal-argument]' prefix, show *only* \ +log items, nothing else." (interactive "P") (org-agenda-check-type t 'agenda 'timeline) (setq org-agenda-show-log @@ -8181,8 +8132,7 @@ With a double `C-u' prefix arg, show *only* log items, nothing else." (setq org-agenda-start-with-log-mode org-agenda-show-log) (org-agenda-set-mode-name) (org-agenda-redo) - (message "Log mode is %s" - (if org-agenda-show-log "on" "off"))) + (message "Log mode is %s" (if org-agenda-show-log "on" "off"))) (defun org-agenda-archives-mode (&optional with-files) "Toggle inclusion of items in trees marked with :ARCHIVE:. @@ -8254,7 +8204,7 @@ When called with a prefix argument, include all archive files as well." (t "")) (if (or org-agenda-category-filter (get 'org-agenda-category-filter :preset-filter)) - '(:eval (org-propertize + '(:eval (propertize (concat " <" (mapconcat 'identity @@ -8267,7 +8217,7 @@ When called with a prefix argument, include all archive files as well." 'help-echo "Category used in filtering")) "") (if (or org-agenda-tag-filter (get 'org-agenda-tag-filter :preset-filter)) - '(:eval (org-propertize + '(:eval (propertize (concat " {" (mapconcat 'identity @@ -8280,7 +8230,7 @@ When called with a prefix argument, include all archive files as well." 'help-echo "Tags used in filtering")) "") (if (or org-agenda-effort-filter (get 'org-agenda-effort-filter :preset-filter)) - '(:eval (org-propertize + '(:eval (propertize (concat " {" (mapconcat 'identity @@ -8293,7 +8243,7 @@ When called with a prefix argument, include all archive files as well." 'help-echo "Effort conditions used in filtering")) "") (if (or org-agenda-regexp-filter (get 'org-agenda-regexp-filter :preset-filter)) - '(:eval (org-propertize + '(:eval (propertize (concat " [" (mapconcat 'identity @@ -8312,9 +8262,6 @@ When called with a prefix argument, include all archive files as well." (if org-agenda-clockreport-mode " Clock" ""))) (force-mode-line-update)) -(define-obsolete-function-alias - 'org-agenda-post-command-hook 'org-agenda-update-agenda-type "24.3") - (defun org-agenda-update-agenda-type () "Update the agenda type after each command." (setq org-agenda-type @@ -8377,7 +8324,7 @@ When called with a prefix argument, include all archive files as well." (message "No tags associated with this line")))) (defun org-agenda-goto (&optional highlight) - "Go to the entry at point in the corresponding Org-mode file." + "Go to the entry at point in the corresponding Org file." (interactive) (let* ((marker (or (org-get-at-bol 'org-marker) (org-agenda-error))) @@ -8389,15 +8336,11 @@ When called with a prefix argument, include all archive files as well." (goto-char pos) (when (derived-mode-p 'org-mode) (org-show-context 'agenda) - (save-excursion - (and (outline-next-heading) - (org-flag-heading nil))) ; show the next heading - (when (outline-invisible-p) - (show-entry)) ; display invisible text (recenter (/ (window-height) 2)) (org-back-to-heading t) - (if (re-search-forward org-complex-heading-regexp nil t) - (goto-char (match-beginning 4)))) + (let ((case-fold-search nil)) + (when (re-search-forward org-complex-heading-regexp nil t) + (goto-char (match-beginning 4))))) (run-hooks 'org-agenda-after-show-hook) (and highlight (org-highlight (point-at-bol) (point-at-eol))))) @@ -8484,7 +8427,7 @@ Point is in the buffer where the item originated.") (org-remove-subtree-entries-from-agenda)) (org-back-to-heading t) (funcall cmd))) - (error "Archiving works only in Org-mode files")))))) + (error "Archiving works only in Org files")))))) (defun org-remove-subtree-entries-from-agenda (&optional buf beg end) "Remove all lines in the agenda that correspond to a given subtree. @@ -8514,9 +8457,16 @@ If this information is not given, the function uses the tree at point." (defun org-agenda-refile (&optional goto rfloc no-update) "Refile the item at point. -When GOTO is 0 or '(64) or \\[universal-argument] \\[universal-argument] \\[universal-argument], clear the refile cache. -When GOTO is '(16) or \\[universal-argument] \\[universal-argument], go to the location of the last refiled item. +When called with `\\[universal-argument] \\[universal-argument]', \ +go to the location of the last +refiled item. + +When called with `\\[universal-argument] \\[universal-argument] \ +\\[universal-argument]' prefix or when GOTO is 0, clear +the refile cache. + 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") (cond @@ -8535,13 +8485,11 @@ When NO-UPDATE is non-nil, don't redo the agenda buffer." (if goto "Goto" "Refile to") buffer org-refile-allow-creating-parent-nodes)))) (with-current-buffer buffer - (save-excursion - (save-restriction - (widen) - (goto-char marker) - (let ((org-agenda-buffer-name buffer-orig)) - (org-remove-subtree-entries-from-agenda)) - (org-refile goto buffer rfloc))))) + (org-with-wide-buffer + (goto-char marker) + (let ((org-agenda-buffer-name buffer-orig)) + (org-remove-subtree-entries-from-agenda)) + (org-refile goto buffer rfloc)))) (unless no-update (org-agenda-redo))))) (defun org-agenda-open-link (&optional arg) @@ -8566,13 +8514,11 @@ It also looks at the text of the entry itself." (setq trg (and (string-match org-bracket-link-regexp l) (match-string 1 l))) (if (or (not trg) (string-match org-any-link-re trg)) - (save-excursion - (save-restriction - (widen) - (goto-char marker) - (when (search-forward l nil lkend) - (goto-char (match-beginning 0)) - (org-open-at-point)))) + (org-with-wide-buffer + (goto-char marker) + (when (search-forward l nil lkend) + (goto-char (match-beginning 0)) + (org-open-at-point))) ;; This is an internal link, widen the buffer (switch-to-buffer-other-window buffer) (widen) @@ -8592,8 +8538,9 @@ It also looks at the text of the entry itself." "Get a variable from a referenced buffer and install it here." (let ((m (org-get-at-bol 'org-marker))) (when (and m (buffer-live-p (marker-buffer m))) - (org-set-local var (with-current-buffer (marker-buffer m) - (symbol-value var)))))) + (set (make-local-variable var) + (with-current-buffer (marker-buffer m) + (symbol-value var)))))) (defun org-agenda-switch-to (&optional delete-other-windows) "Go to the Org mode file which contains the item at point. @@ -8609,7 +8556,7 @@ displayed Org file fills the frame." (buffer (marker-buffer marker)) (pos (marker-position marker))) (unless buffer (user-error "Trying to switch to non-existent buffer")) - (org-pop-to-buffer-same-window buffer) + (pop-to-buffer-same-window buffer) (when delete-other-windows (delete-other-windows)) (widen) (goto-char pos) @@ -8618,13 +8565,13 @@ displayed Org file fills the frame." (run-hooks 'org-agenda-after-show-hook))))) (defun org-agenda-goto-mouse (ev) - "Go to the Org-mode file which contains the item at the mouse click." + "Go to the Org file which contains the item at the mouse click." (interactive "e") (mouse-set-point ev) (org-agenda-goto)) (defun org-agenda-show (&optional full-entry) - "Display the Org-mode file which contains the item at point. + "Display the Org file which contains the item at point. With prefix argument FULL-ENTRY, make the entire entry visible if it was hidden in the outline." (interactive "P") @@ -8635,11 +8582,13 @@ if it was hidden in the outline." (defvar org-agenda-show-window nil) (defun org-agenda-show-and-scroll-up (&optional arg) - "Display the Org-mode file which contains the item at point. + "Display the Org file which contains the item at point. + When called repeatedly, scroll the window that is displaying the buffer. -With a \\[universal-argument] prefix, use `org-show-entry' instead of -`show-subtree' to display the item, so that drawers and logbooks stay -folded." + +With a `\\[universal-argument]' prefix, use `org-show-entry' instead of \ +`outline-show-subtree' +to display the item, so that drawers and logbooks stay folded." (interactive "P") (let ((win (selected-window))) (if (and (window-live-p org-agenda-show-window) @@ -8648,7 +8597,7 @@ folded." (select-window org-agenda-show-window) (ignore-errors (scroll-up))) (org-agenda-goto t) - (if arg (org-show-entry) (show-subtree)) + (if arg (org-show-entry) (outline-show-subtree)) (setq org-agenda-show-window (selected-window))) (select-window win))) @@ -8662,7 +8611,7 @@ folded." (select-window win)))) (defun org-agenda-show-1 (&optional more) - "Display the Org-mode file which contains the item at point. + "Display the Org file which contains the item at point. The prefix arg selects the amount of information to display: 0 hide the subtree @@ -8680,34 +8629,34 @@ if it was hidden in the outline." (set-window-start (selected-window) (point-at-bol)) (cond ((= more 0) - (hide-subtree) + (outline-hide-subtree) (save-excursion (org-back-to-heading) (run-hook-with-args 'org-cycle-hook 'folded)) (message "Remote: FOLDED")) - ((and (org-called-interactively-p 'any) (= more 1)) + ((and (called-interactively-p 'any) (= more 1)) (message "Remote: show with default settings")) ((= more 2) - (show-entry) - (show-children) + (outline-show-entry) + (org-show-children) (save-excursion (org-back-to-heading) (run-hook-with-args 'org-cycle-hook 'children)) (message "Remote: CHILDREN")) ((= more 3) - (show-subtree) + (outline-show-subtree) (save-excursion (org-back-to-heading) (run-hook-with-args 'org-cycle-hook 'subtree)) (message "Remote: SUBTREE")) ((= more 4) - (show-subtree) + (outline-show-subtree) (save-excursion (org-back-to-heading) (org-cycle-hide-drawers 'subtree '("LOGBOOK"))) (message "Remote: SUBTREE AND LOGBOOK")) ((> more 4) - (show-subtree) + (outline-show-subtree) (message "Remote: SUBTREE AND ALL DRAWERS"))) (select-window win))) @@ -8737,7 +8686,7 @@ docstring of `org-agenda-show-1'." (org-agenda-show-1 org-agenda-cycle-counter)) (defun org-agenda-recenter (arg) - "Display the Org-mode file which contains the item at point and recenter." + "Display the Org file which contains the item at point and recenter." (interactive "P") (let ((win (selected-window))) (org-agenda-goto t) @@ -8745,7 +8694,7 @@ docstring of `org-agenda-show-1'." (select-window win))) (defun org-agenda-show-mouse (ev) - "Display the Org-mode file which contains the item at the mouse click." + "Display the Org file which contains the item at the mouse click." (interactive "e") (mouse-set-point ev) (org-agenda-show)) @@ -8765,8 +8714,10 @@ This calls the command `org-tree-to-indirect-buffer' from the original buffer. With a numerical prefix ARG, go up to this level and then take that tree. With a negative numeric ARG, go up by this number of levels. -With a \\[universal-argument] prefix, make a separate frame for this tree (i.e. don't -use the dedicated frame)." + +With a `\\[universal-argument]' prefix, make a separate frame for this tree, \ +i.e. don't use +the dedicated frame." (interactive "P") (if current-prefix-arg (org-agenda-do-tree-to-indirect-buffer arg) @@ -8814,9 +8765,9 @@ by a remote command from the agenda.") (org-agenda-todo 'previousset)) (defun org-agenda-todo (&optional arg) - "Cycle TODO state of line at point, also in Org-mode file. + "Cycle TODO state of line at point, also in Org file. This changes the line at point, all other lines in the agenda referring to -the same tree node, and the headline of the tree node in the Org-mode file." +the same tree node, and the headline of the tree node in the Org file." (interactive "P") (org-agenda-check-no-diary) (let* ((col (current-column)) @@ -8825,7 +8776,7 @@ the same tree node, and the headline of the tree node in the Org-mode file." (buffer (marker-buffer marker)) (pos (marker-position marker)) (hdmarker (org-get-at-bol 'org-hd-marker)) - (todayp (org-agenda-todayp (org-get-at-bol 'day))) + (todayp (org-agenda-today-p (org-get-at-bol 'day))) (inhibit-read-only t) org-agenda-headline-snapshot-before-repeat newhead just-one) (org-with-remote-undo buffer @@ -8833,14 +8784,11 @@ the same tree node, and the headline of the tree node in the Org-mode file." (widen) (goto-char pos) (org-show-context 'agenda) - (save-excursion - (and (outline-next-heading) - (org-flag-heading nil))) ; show the next heading (let ((current-prefix-arg arg)) (call-interactively 'org-todo)) (and (bolp) (forward-char 1)) (setq newhead (org-get-heading)) - (when (and (org-bound-and-true-p + (when (and (bound-and-true-p org-agenda-headline-snapshot-before-repeat) (not (equal org-agenda-headline-snapshot-before-repeat newhead)) @@ -8853,7 +8801,7 @@ the same tree node, and the headline of the tree node in the Org-mode file." (beginning-of-line 1) (save-window-excursion (org-agenda-change-all-lines newhead hdmarker 'fixface just-one)) - (when (org-bound-and-true-p org-clock-out-when-done) + (when (bound-and-true-p org-clock-out-when-done) (string-match (concat "^" (regexp-opt org-done-keywords-for-agenda)) newhead) (org-agenda-unmark-clocking-task)) @@ -8874,9 +8822,6 @@ the same tree node, and the headline of the tree node in the Org-mode file." (widen) (goto-char pos) (org-show-context 'agenda) - (save-excursion - (and (outline-next-heading) - (org-flag-heading nil))) ; show the next heading (org-add-note)))) (defun org-agenda-change-all-lines (newhead hdmarker @@ -8893,9 +8838,9 @@ If FORCE-TAGS is non nil, the car of it returns the new tags." (line (org-current-line)) (org-agenda-buffer (current-buffer)) (thetags (with-current-buffer (marker-buffer hdmarker) - (save-excursion (save-restriction (widen) - (goto-char hdmarker) - (org-get-tags-at))))) + (org-with-wide-buffer + (goto-char hdmarker) + (org-get-tags-at)))) props m pl undone-face done-face finish new dotime level cat tags) (save-excursion (goto-char (point-max)) @@ -8916,20 +8861,25 @@ If FORCE-TAGS is non nil, the car of it returns the new tags." org-prefix-format-compiled)) (extra (org-get-at-bol 'extra))) (with-current-buffer (marker-buffer hdmarker) - (save-excursion - (save-restriction - (widen) - (org-agenda-format-item extra newhead level cat tags dotime))))) + (org-with-wide-buffer + (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)) (beginning-of-line 1) (cond - ((equal new "") - (and (looking-at ".*\n?") (replace-match ""))) + ((equal new "") (delete-region (point) (line-beginning-position 2))) ((looking-at ".*") - (replace-match new t t) - (beginning-of-line 1) + ;; When replacing the whole line, preserve bulk mark + ;; overlay, if any. + (let ((mark (catch :overlay + (dolist (o (overlays-in (point) (+ 2 (point)))) + (when (eq (overlay-get o 'type) + 'org-marked-entry-overlay) + (throw :overlay o)))))) + (replace-match new t t) + (beginning-of-line) + (when mark (move-overlay mark (point) (+ 2 (point))))) (add-text-properties (point-at-bol) (point-at-eol) props) (when fixface (add-text-properties @@ -8950,7 +8900,7 @@ If FORCE-TAGS is non nil, the car of it returns the new tags." (let ((inhibit-read-only t) l c) (save-excursion (goto-char (if line (point-at-bol) (point-min))) - (while (re-search-forward (org-re "\\([ \t]+\\)\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$") + (while (re-search-forward "\\([ \t]+\\)\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$" (if line (point-at-eol) nil) t) (add-text-properties (match-beginning 2) (match-end 2) @@ -8974,19 +8924,19 @@ If FORCE-TAGS is non nil, the car of it returns the new tags." (org-font-lock-add-tag-faces (point-max))))) (defun org-agenda-priority-up () - "Increase the priority of line at point, also in Org-mode file." + "Increase the priority of line at point, also in Org file." (interactive) (org-agenda-priority 'up)) (defun org-agenda-priority-down () - "Decrease the priority of line at point, also in Org-mode file." + "Decrease the priority of line at point, also in Org file." (interactive) (org-agenda-priority 'down)) (defun org-agenda-priority (&optional force-direction) - "Set the priority of line at point, also in Org-mode file. + "Set the priority of line at point, also in Org file. This changes the line at point, all other lines in the agenda referring to -the same tree node, and the headline of the tree node in the Org-mode file. +the same tree node, and the headline of the tree node in the Org file. Called with a universal prefix arg, show the priority instead of setting it." (interactive "P") (if (equal force-direction '(4)) @@ -9007,9 +8957,6 @@ Called with a universal prefix arg, show the priority instead of setting it." (widen) (goto-char pos) (org-show-context 'agenda) - (save-excursion - (and (outline-next-heading) - (org-flag-heading nil))) ; show the next heading (funcall 'org-priority force-direction) (end-of-line 1) (setq newhead (org-get-heading))) @@ -9021,7 +8968,7 @@ Called with a universal prefix arg, show the priority instead of setting it." "Set tags for the current headline." (interactive) (org-agenda-check-no-diary) - (if (and (org-region-active-p) (org-called-interactively-p 'any)) + (if (and (org-region-active-p) (called-interactively-p 'any)) (call-interactively 'org-change-tag-in-region) (let* ((hdmarker (or (org-get-at-bol 'org-hd-marker) (org-agenda-error))) @@ -9033,12 +8980,7 @@ Called with a universal prefix arg, show the priority instead of setting it." (with-current-buffer buffer (widen) (goto-char pos) - (save-excursion - (org-show-context 'agenda)) - (save-excursion - (and (outline-next-heading) - (org-flag-heading nil))) ; show the next heading - (goto-char pos) + (org-show-context 'agenda) (if tag (org-toggle-tag tag onoff) (call-interactively 'org-set-tags)) @@ -9061,12 +9003,7 @@ Called with a universal prefix arg, show the priority instead of setting it." (with-current-buffer buffer (widen) (goto-char pos) - (save-excursion - (org-show-context 'agenda)) - (save-excursion - (and (outline-next-heading) - (org-flag-heading nil))) ; show the next heading - (goto-char pos) + (org-show-context 'agenda) (call-interactively 'org-set-property))))) (defun org-agenda-set-effort () @@ -9083,12 +9020,7 @@ Called with a universal prefix arg, show the priority instead of setting it." (with-current-buffer buffer (widen) (goto-char pos) - (save-excursion - (org-show-context 'agenda)) - (save-excursion - (and (outline-next-heading) - (org-flag-heading nil))) ; show the next heading - (goto-char pos) + (org-show-context 'agenda) (call-interactively 'org-set-effort) (end-of-line 1) (setq newhead (org-get-heading))) @@ -9109,9 +9041,6 @@ Called with a universal prefix arg, show the priority instead of setting it." (widen) (goto-char pos) (org-show-context 'agenda) - (save-excursion - (and (outline-next-heading) - (org-flag-heading nil))) ; show the next heading (call-interactively 'org-toggle-archive-tag) (end-of-line 1) (setq newhead (org-get-heading))) @@ -9225,18 +9154,10 @@ Called with a universal prefix arg, show the priority instead of setting it." (when (equal marker (org-get-at-bol 'org-marker)) (remove-text-properties (point-at-bol) (point-at-eol) '(display)) (org-move-to-column (- (window-width) (length stamp)) t) - (if (featurep 'xemacs) - ;; Use `duplicable' property to trigger undo recording - (let ((ex (make-extent nil nil)) - (gl (make-glyph stamp))) - (set-glyph-face gl 'secondary-selection) - (set-extent-properties - ex (list 'invisible t 'end-glyph gl 'duplicable t)) - (insert-extent ex (1- (point)) (point-at-eol))) - (add-text-properties - (1- (point)) (point-at-eol) - (list 'display (org-add-props stamp nil - 'face '(secondary-selection default))))) + (add-text-properties + (1- (point)) (point-at-eol) + (list 'display (org-add-props stamp nil + 'face '(secondary-selection default)))) (beginning-of-line 1)) (beginning-of-line 0))))) @@ -9318,7 +9239,6 @@ ARG is passed through to `org-deadline'." (widen) (goto-char pos) (org-show-context 'agenda) - (org-show-entry) (org-cycle-hide-drawers 'children) (org-clock-in arg) (setq newhead (org-get-heading))) @@ -9333,14 +9253,12 @@ ARG is passed through to `org-deadline'." (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 - (save-restriction - (widen) - (goto-char org-clock-marker) - (org-back-to-heading t) - (move-marker marker (point)) - (org-clock-out) - (setq newhead (org-get-heading)))))) + (org-with-wide-buffer + (goto-char org-clock-marker) + (org-back-to-heading t) + (move-marker marker (point)) + (org-clock-out) + (setq newhead (org-get-heading))))) (org-agenda-change-all-lines newhead marker) (move-marker marker nil) (org-move-to-column col) @@ -9367,7 +9285,7 @@ buffer, display it in another window." (cond (pos (goto-char pos)) ;; If the currently clocked entry is not in the agenda ;; buffer, we visit it in another window: - (org-clock-current-task + ((bound-and-true-p org-clock-current-task) (org-switch-to-buffer-other-window (org-clock-goto))) (t (message "No running clock, use `C-c C-x C-j' to jump to the most recent one"))))) @@ -9417,11 +9335,13 @@ buffer, display it in another window." "Where in `org-agenda-diary-file' should new entries be added? Valid values: -date-tree in the date tree, as child of the date -top-level as top-level entries at the end of the file." +date-tree in the date tree, as first child of the date +date-tree-last in the date tree, as last child of the date +top-level as top-level entries at the end of the file." :group 'org-agenda :type '(choice - (const :tag "in a date tree" date-tree) + (const :tag "first in a date tree" date-tree) + (const :tag "last in a date tree" date-tree-last) (const :tag "as top level at end of file" top-level))) (defcustom org-agenda-insert-diary-extract-time nil @@ -9522,24 +9442,30 @@ a timestamp can be added there." (insert text) (org-end-of-meta-data) (unless (bolp) (insert "\n")) - (when org-adapt-indentation (org-indent-to-column 2))) + (when org-adapt-indentation (indent-to-column 2))) (defun org-agenda-insert-diary-make-new-entry (text) - "Make a new entry with TEXT as the first child of the current subtree. + "Make a new entry with TEXT as a child of the current subtree. Position the point in the heading's first body line so that a timestamp can be added there." - (outline-next-heading) - (org-back-over-empty-lines) - (unless (looking-at "[ \t]*$") (save-excursion (insert "\n"))) - (org-insert-heading nil t) - (org-do-demote) + (cond + ((eq org-agenda-insert-diary-strategy 'date-tree-last) + (end-of-line) + (org-insert-heading '(4) t) + (org-do-demote)) + (t + (outline-next-heading) + (org-back-over-empty-lines) + (unless (looking-at "[ \t]*$") (save-excursion (insert "\n"))) + (org-insert-heading nil t) + (org-do-demote))) (let ((col (current-column))) (insert text) (org-end-of-meta-data) ;; Ensure point is left on a blank line, at proper indentation. (unless (bolp) (insert "\n")) - (unless (org-looking-at-p "^[ \t]*$") (save-excursion (insert "\n"))) - (when org-adapt-indentation (org-indent-to-column col))) + (unless (looking-at-p "^[ \t]*$") (save-excursion (insert "\n"))) + (when org-adapt-indentation (indent-to-column col))) (org-show-set-visibility 'lineage)) (defun org-agenda-diary-entry () @@ -9547,7 +9473,7 @@ a timestamp can be added there." All the standard commands work: block, weekly etc. When `org-agenda-diary-file' points to a file, `org-agenda-diary-entry-in-org-file' is called instead to create -entries in that Org-mode file." +entries in that Org file." (interactive) (if (not (eq org-agenda-diary-file 'diary-file)) (org-agenda-diary-entry-in-org-file) @@ -9652,7 +9578,7 @@ argument, latitude and longitude will be prompted for." ;;;###autoload (defun org-calendar-goto-agenda () - "Compute the Org-mode agenda for the calendar date displayed at the cursor. + "Compute the Org agenda for the calendar date displayed at the cursor. This is a command that has to be installed in `calendar-mode-map'." (interactive) ;; Temporarily disable sticky agenda since user clearly wants to @@ -9681,7 +9607,7 @@ This is a command that has to be installed in `calendar-mode-map'." "Hebrew: " (calendar-hebrew-date-string date) " (until sunset)\n" "Islamic: " (calendar-islamic-date-string date) " (until sunset)\n" "French: " (calendar-french-date-string date) "\n" - "Baha'i: " (calendar-bahai-date-string date) " (until sunset)\n" + "Bahá’í: " (calendar-bahai-date-string date) " (until sunset)\n" "Mayan: " (calendar-mayan-date-string date) "\n" "Coptic: " (calendar-coptic-date-string date) "\n" "Ethiopic: " (calendar-ethiopic-date-string date) "\n" @@ -9694,6 +9620,7 @@ This is a command that has to be installed in `calendar-mode-map'." ;;; Bulk commands (defun org-agenda-bulk-marked-p () + "Non-nil when current entry is marked for bulk action." (eq (get-char-property (point-at-bol) 'type) 'org-marked-entry-overlay)) @@ -9735,9 +9662,12 @@ This is a command that has to be installed in `calendar-mode-map'." (goto-char (next-single-property-change (point) 'org-hd-marker)) (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 (get-char-property (point) 'invisible) + (beginning-of-line 2) + (when (string-match regexp txt-at-point) + (setq entries-marked (1+ entries-marked)) + (call-interactively 'org-agenda-bulk-mark))))) + (if (not entries-marked) (message "No entry matching this regexp.")))) @@ -9870,21 +9800,21 @@ The prefix arg is passed through to the command if possible." redo-at-end t)) ((equal action ?t) - (setq state (org-icompleting-read + (setq state (completing-read "Todo state: " (with-current-buffer (marker-buffer (car entries)) - (mapcar 'list org-todo-keywords-1)))) + (mapcar #'list org-todo-keywords-1)))) (setq cmd `(let ((org-inhibit-blocking t) (org-inhibit-logging 'note)) (org-agenda-todo ,state)))) ((memq action '(?- ?+)) - (setq tag (org-icompleting-read + (setq tag (completing-read (format "Tag to %s: " (if (eq action ?+) "add" "remove")) (with-current-buffer (marker-buffer (car entries)) (delq nil - (mapcar (lambda (x) - (if (stringp (car x)) x)) org-tag-alist))))) + (mapcar (lambda (x) (and (stringp (car x)) x)) + org-current-tag-alist))))) (setq cmd `(org-agenda-set-tags ,tag ,(if (eq action ?+) ''on ''off)))) ((memq action '(?s ?d)) @@ -9894,8 +9824,15 @@ The prefix arg is passed through to the command if possible." nil nil nil (if (eq action ?s) "(Re)Schedule to" "(Re)Set Deadline to") org-overriding-default-time))) - (c1 (if (eq action ?s) 'org-agenda-schedule 'org-agenda-deadline))) - (setq cmd `(eval '(,c1 arg ,time))))) + (c1 (if (eq action ?s) 'org-agenda-schedule + 'org-agenda-deadline))) + ;; Make sure to not prompt for a note when bulk + ;; rescheduling as Org cannot cope with simultaneous Org. + ;; Besides, it could be annoying depending on the number + ;; of items re-scheduled. + (setq cmd `(eval '(let ((org-log-reschedule + (and org-log-reschedule 'time))) + (,c1 arg ,time)))))) ((equal action ?S) (if (not (org-agenda-check-type nil 'agenda 'timeline 'todo)) @@ -9912,13 +9849,13 @@ The prefix arg is passed through to the command if possible." (calendar-gregorian-from-absolute (org-today))))) (dotimes (i (1+ dist)) (while (member day-of-week org-agenda-weekend-days) - (incf distance) - (incf day-of-week) - (if (= day-of-week 7) - (setq day-of-week 0))) - (incf day-of-week) - (if (= day-of-week 7) - (setq day-of-week 0))))) + (cl-incf distance) + (cl-incf day-of-week) + (when (= day-of-week 7) + (setq day-of-week 0))) + (cl-incf day-of-week) + (when (= day-of-week 7) + (setq day-of-week 0))))) ;; silently fail when try to replan a sexp entry (condition-case nil (let* ((date (calendar-gregorian-from-absolute @@ -9934,8 +9871,8 @@ The prefix arg is passed through to the command if possible." ((equal action ?f) (setq cmd (list (intern - (org-icompleting-read "Function: " - obarray 'fboundp t nil nil))))) + (completing-read "Function: " + obarray 'fboundp t nil nil))))) (t (user-error "Invalid bulk action"))) @@ -10060,7 +9997,9 @@ tag and (if present) the flagging note." (replace-match "\n" t t)) (goto-char (point-min)) (select-window win) - (message "Flagging note pushed to kill ring. Press [?] again to remove tag and note")))) + (message "%s" (substitute-command-keys "Flagging note pushed to \ +kill ring. Press `\\[org-agenda-show-the-flagging-note]' again to remove \ +tag and note"))))) (defun org-agenda-remove-flag (marker) "Remove the FLAGGED tag and any flagging note in the entry." @@ -10083,7 +10022,8 @@ tag and (if present) the flagging note." ;;;###autoload (defun org-agenda-to-appt (&optional refresh filter &rest args) "Activate appointments found in `org-agenda-files'. -With a \\[universal-argument] prefix, refresh the list of + +With a `\\[universal-argument]' prefix, refresh the list of \ appointments. If FILTER is t, interactively prompt the user for a regular @@ -10097,9 +10037,9 @@ calling the function returns nil. This function takes one argument: an entry from `org-agenda-get-day-entries'. FILTER can also be an alist with the car of each cell being -either 'headline or 'category. For example: +either `headline' or `category'. For example: - '((headline \"IMPORTANT\") + \\='((headline \"IMPORTANT\") (category \"Work\")) will only add headlines containing IMPORTANT or headlines @@ -10117,76 +10057,78 @@ to override `appt-message-warning-time'." (if refresh (setq appt-time-msg-list nil)) (if (eq filter t) (setq filter (read-from-minibuffer "Regexp filter: "))) - (let* ((cnt 0) ; count added events - (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 - ;; time and without date as argument, so it may pass wrong - ;; information otherwise - (today (org-date-to-gregorian - (time-to-days (current-time)))) - (org-agenda-restrict nil) - (files (org-agenda-files 'unrestricted)) entries file - (org-agenda-buffer nil)) + (let* ((cnt 0) ; count added events + (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 + ;; time and without date as argument, so it may pass wrong + ;; information otherwise + (today (org-date-to-gregorian + (time-to-days (current-time)))) + (org-agenda-restrict nil) + (files (org-agenda-files 'unrestricted)) entries file + (org-agenda-buffer nil)) ;; Get all entries which may contain an appt (org-agenda-prepare-buffers files) (while (setq file (pop files)) (setq entries - (delq nil - (append entries - (apply 'org-agenda-get-day-entries - file today scope))))) + (delq nil + (append entries + (apply 'org-agenda-get-day-entries + file today scope))))) ;; Map thru entries and find if we should filter them out (mapc - (lambda(x) + (lambda (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- (length x)) 'org-category x)) - (tod (get-text-property 1 'time-of-day x)) - (ok (or (null filter) - (and (stringp filter) (string-match filter evt)) - (and (functionp filter) (funcall filter x)) - (and (listp filter) - (let ((cat-filter (cadr (assoc 'category filter))) - (evt-filter (cadr (assoc 'headline filter)))) - (or (and (stringp cat-filter) - (string-match cat-filter cat)) - (and (stringp evt-filter) - (string-match evt-filter evt))))))) - (wrn (get-text-property 1 'warntime x))) - ;; FIXME: Shall we remove text-properties for the appt text? - ;; (setq evt (set-text-properties 0 (length evt) nil evt)) - (when (and ok tod) - (setq tod (concat "00" (number-to-string tod)) - tod (when (string-match - "\\([0-9]\\{1,2\\}\\)\\([0-9]\\{2\\}\\)\\'" tod) - (concat (match-string 1 tod) ":" - (match-string 2 tod)))) - (if (version< emacs-version "23.3") - (appt-add tod evt) - (appt-add tod evt wrn)) - (setq cnt (1+ cnt))))) entries) + (replace-regexp-in-string + org-bracket-link-regexp "\\3" + (or (get-text-property 1 'txt x) "")))) + (cat (get-text-property (1- (length x)) 'org-category x)) + (tod (get-text-property 1 'time-of-day x)) + (ok (or (null filter) + (and (stringp filter) (string-match filter evt)) + (and (functionp filter) (funcall filter x)) + (and (listp filter) + (let ((cat-filter (cadr (assq 'category filter))) + (evt-filter (cadr (assq 'headline filter)))) + (or (and (stringp cat-filter) + (string-match cat-filter cat)) + (and (stringp evt-filter) + (string-match evt-filter evt))))))) + (wrn (get-text-property 1 'warntime x))) + ;; FIXME: Shall we remove text-properties for the appt text? + ;; (setq evt (set-text-properties 0 (length evt) nil evt)) + (when (and ok tod (not (string-match "\\`DONE\\|CANCELLED" evt))) + (setq tod (concat "00" (number-to-string tod))) + (setq tod (when (string-match + "\\([0-9]\\{1,2\\}\\)\\([0-9]\\{2\\}\\)\\'" tod) + (concat (match-string 1 tod) ":" + (match-string 2 tod)))) + (when (if (version< emacs-version "23.3") + (appt-add tod evt) + (appt-add tod evt wrn)) + (setq cnt (1+ cnt)))))) + entries) (org-release-buffers org-agenda-new-buffers) (if (eq cnt 0) - (message "No event to add") + (message "No event to add") (message "Added %d event%s for today" cnt (if (> cnt 1) "s" ""))))) -(defun org-agenda-todayp (date) - "Does DATE mean today, when considering `org-extend-today-until'?" - (let ((today (org-today)) - (date (if (and date (listp date)) (calendar-absolute-from-gregorian date) - date))) - (eq date today))) +(defun org-agenda-today-p (date) + "Non nil when DATE means today. +DATE is either a list of the form (month day year) or a number of +days as returned by `calendar-absolute-from-gregorian' or +`org-today'. This function considers `org-extend-today-until' +when defining today." + (eq (org-today) + (if (consp date) (calendar-absolute-from-gregorian date) date))) (defun org-agenda-todo-yesterday (&optional arg) "Like `org-agenda-todo' but the time of change will be 23:59 of yesterday." (interactive "P") (let* ((org-use-effective-time t) - (hour (third (decode-time - (org-current-time)))) + (hour (nth 2 (decode-time (org-current-time)))) (org-extend-today-until (1+ hour))) (org-agenda-todo arg))) diff --git a/elpa/org-plus-contrib-20150831/org-annotate-file.el b/elpa/org-plus-contrib-20170407/org-annotate-file.el similarity index 100% rename from elpa/org-plus-contrib-20150831/org-annotate-file.el rename to elpa/org-plus-contrib-20170407/org-annotate-file.el diff --git a/elpa/org-plus-contrib-20150831/org-archive.el b/elpa/org-plus-contrib-20170407/org-archive.el similarity index 71% rename from elpa/org-plus-contrib-20150831/org-archive.el rename to elpa/org-plus-contrib-20170407/org-archive.el index 2919fda0..4ce81aab 100644 --- a/elpa/org-plus-contrib-20150831/org-archive.el +++ b/elpa/org-plus-contrib-20170407/org-archive.el @@ -1,6 +1,6 @@ -;;; org-archive.el --- Archiving for Org-mode +;;; org-archive.el --- Archiving for Org -*- lexical-binding: t; -*- -;; Copyright (C) 2004-2015 Free Software Foundation, Inc. +;; Copyright (C) 2004-2017 Free Software Foundation, Inc. ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp @@ -30,8 +30,9 @@ (require 'org) -(declare-function org-inlinetask-remove-END-maybe "org-inlinetask" ()) +(declare-function org-element-type "org-element" (element)) (declare-function org-datetree-find-date-create "org-datetree" (date &optional keep-restriction)) +(declare-function org-inlinetask-remove-END-maybe "org-inlinetask" ()) (defcustom org-archive-default-command 'org-archive-subtree "The default archiving command." @@ -56,7 +57,7 @@ See `org-archive-to-archive-sibling' for more information." (defcustom org-archive-mark-done nil "Non-nil means mark entries as DONE when they are moved to the archive file. -This can be a string to set the keyword to use. When t, Org-mode will +This can be a string to set the keyword to use. When non-nil, Org will use the first keyword in its list that means done." :group 'org-archive :type '(choice @@ -159,21 +160,24 @@ archive file is." (defun org-all-archive-files () "Get a list of all archive files used in the current buffer." - (let (file files) - (save-excursion - (save-restriction - (goto-char (point-min)) - (while (re-search-forward - "^[ \t]*\\(#\\+\\|:\\)ARCHIVE:[ \t]+\\(.*\\)" - nil t) - (setq file (org-extract-archive-file - (org-match-string-no-properties 2))) - (and file (> (length file) 0) (file-exists-p file) - (add-to-list 'files file))))) + (let ((case-fold-search t) + files) + (org-with-wide-buffer + (goto-char (point-min)) + (while (re-search-forward + "^[ \t]*\\(#\\+\\|:\\)ARCHIVE:[ \t]+\\(.*\\)" + nil t) + (when (save-match-data + (if (eq (match-string 1) ":") (org-at-property-p) + (eq (org-element-type (org-element-at-point)) 'keyword))) + (let ((file (org-extract-archive-file + (match-string-no-properties 2)))) + (when (and (org-string-nw-p file) (file-exists-p file)) + (push file files)))))) (setq files (nreverse files)) - (setq file (org-extract-archive-file)) - (and file (> (length file) 0) (file-exists-p file) - (add-to-list 'files file)) + (let ((file (org-extract-archive-file))) + (when (and (org-string-nw-p file) (file-exists-p file)) + (push file files))) files)) (defun org-extract-archive-file (&optional location) @@ -226,42 +230,30 @@ this heading." ((equal find-done '(16)) (org-archive-all-old)) (t ;; Save all relevant TODO keyword-relatex variables - (let ((tr-org-todo-line-regexp org-todo-line-regexp) ; keep despite compiler - (tr-org-todo-keywords-1 org-todo-keywords-1) - (tr-org-todo-kwd-alist org-todo-kwd-alist) - (tr-org-done-keywords org-done-keywords) - (tr-org-todo-regexp org-todo-regexp) - (tr-org-todo-line-regexp org-todo-line-regexp) - (tr-org-odd-levels-only org-odd-levels-only) - (this-buffer (current-buffer)) - ;; start of variables that will be used for saving context - ;; The compiler complains about them - keep them anyway! - (file (abbreviate-file-name - (or (buffer-file-name (buffer-base-buffer)) - (error "No file associated to buffer")))) - (olpath (mapconcat 'identity (org-get-outline-path) "/")) - (time (format-time-string - (substring (cdr org-time-stamp-formats) 1 -1))) - category todo priority ltags itags atags - ;; end of variables that will be used for saving context - location afile heading buffer level newfile-p infile-p visiting - datetree-date datetree-subheading-p) - - ;; Find the local archive location - (setq location (org-get-local-archive-location) - afile (org-extract-archive-file location) - heading (org-extract-archive-heading location) - infile-p (equal file (abbreviate-file-name (or afile "")))) - (unless afile - (error "Invalid `org-archive-location'")) - - (if (> (length afile) 0) - (setq newfile-p (not (file-exists-p afile)) - visiting (find-buffer-visiting afile) - buffer (or visiting (find-file-noselect afile))) - (setq buffer (current-buffer))) - (unless buffer - (error "Cannot access file \"%s\"" afile)) + (let* ((tr-org-todo-keywords-1 org-todo-keywords-1) + (tr-org-todo-kwd-alist org-todo-kwd-alist) + (tr-org-done-keywords org-done-keywords) + (tr-org-todo-regexp org-todo-regexp) + (tr-org-todo-line-regexp org-todo-line-regexp) + (tr-org-odd-levels-only org-odd-levels-only) + (this-buffer (current-buffer)) + (time (format-time-string + (substring (cdr org-time-stamp-formats) 1 -1))) + (file (abbreviate-file-name + (or (buffer-file-name (buffer-base-buffer)) + (error "No file associated to buffer")))) + (location (org-get-local-archive-location)) + (afile (or (org-extract-archive-file location) + (error "Invalid `org-archive-location'"))) + (heading (org-extract-archive-heading location)) + (infile-p (equal file (abbreviate-file-name (or afile "")))) + (newfile-p (and (org-string-nw-p afile) + (not (file-exists-p afile)))) + (buffer (cond ((not (org-string-nw-p afile)) this-buffer) + ((find-buffer-visiting afile)) + ((find-file-noselect afile)) + (t (error "Cannot access file \"%s\"" afile)))) + level datetree-date datetree-subheading-p) (when (string-match "\\`datetree/" heading) ;; Replace with ***, to represent the 3 levels of headings the ;; datetree has. @@ -275,106 +267,116 @@ this heading." (setq heading nil level 0)) (save-excursion (org-back-to-heading t) - ;; Get context information that will be lost by moving the tree - (setq category (org-get-category nil 'force-refresh) - todo (and (looking-at org-todo-line-regexp) - (match-string 2)) - priority (org-get-priority - (if (match-end 3) (match-string 3) "")) - ltags (org-get-tags) - itags (org-delete-all ltags (org-get-tags-at)) - atags (org-get-tags-at)) - (setq ltags (mapconcat 'identity ltags " ") - itags (mapconcat 'identity itags " ")) - ;; We first only copy, in case something goes wrong - ;; we need to protect `this-command', to avoid kill-region sets it, - ;; which would lead to duplication of subtrees - (let (this-command) (org-copy-subtree 1 nil t)) - (set-buffer buffer) - ;; Enforce org-mode for the archive buffer - (if (not (derived-mode-p 'org-mode)) - ;; Force the mode for future visits. - (let ((org-insert-mode-line-in-empty-file t) - (org-inhibit-startup t)) - (call-interactively 'org-mode))) - (when (and newfile-p org-archive-file-header-format) - (goto-char (point-max)) - (insert (format org-archive-file-header-format - (buffer-file-name this-buffer)))) - (when datetree-date - (require 'org-datetree) - (org-datetree-find-date-create datetree-date) - (org-narrow-to-subtree)) - ;; Force the TODO keywords of the original buffer - (let ((org-todo-line-regexp tr-org-todo-line-regexp) - (org-todo-keywords-1 tr-org-todo-keywords-1) - (org-todo-kwd-alist tr-org-todo-kwd-alist) - (org-done-keywords tr-org-done-keywords) - (org-todo-regexp tr-org-todo-regexp) - (org-todo-line-regexp tr-org-todo-line-regexp) - (org-odd-levels-only - (if (local-variable-p 'org-odd-levels-only (current-buffer)) - org-odd-levels-only - tr-org-odd-levels-only))) - (goto-char (point-min)) - (show-all) - (if (and heading (not (and datetree-date (not datetree-subheading-p)))) - (progn - (if (re-search-forward - (concat "^" (regexp-quote heading) - (org-re "[ \t]*\\(:[[:alnum:]_@#%:]+:\\)?[ \t]*\\($\\|\r\\)")) - nil t) - (goto-char (match-end 0)) - ;; Heading not found, just insert it at the end - (goto-char (point-max)) - (or (bolp) (insert "\n")) - ;; datetrees don't need too much spacing - (insert (if datetree-date "" "\n") heading "\n") - (end-of-line 0)) - ;; Make the subtree visible - (show-subtree) - (if org-archive-reversed-order - (progn - (org-back-to-heading t) - (outline-next-heading)) - (org-end-of-subtree t)) - (skip-chars-backward " \t\r\n") - (and (looking-at "[ \t\r\n]*") - ;; datetree archives don't need so much spacing. - (replace-match (if datetree-date "\n" "\n\n")))) - ;; No specific heading, just go to end of file. - (goto-char (point-max)) (unless datetree-date (insert "\n"))) - ;; Paste - (org-paste-subtree (org-get-valid-level level (and heading 1))) - ;; Shall we append inherited tags? - (and itags - (or (and (eq org-archive-subtree-add-inherited-tags 'infile) - infile-p) - (eq org-archive-subtree-add-inherited-tags t)) - (org-set-tags-to atags)) - ;; Mark the entry as done - (when (and org-archive-mark-done - (looking-at org-todo-line-regexp) - (or (not (match-end 2)) - (not (member (match-string 2) org-done-keywords)))) - (let (org-log-done org-todo-log-states) - (org-todo - (car (or (member org-archive-mark-done org-done-keywords) - org-done-keywords))))) - - ;; Add the context info - (when org-archive-save-context-info - (let ((l org-archive-save-context-info) e n v) - (while (setq e (pop l)) - (when (and (setq v (symbol-value e)) - (stringp v) (string-match "\\S-" v)) - (setq n (concat "ARCHIVE_" (upcase (symbol-name e)))) - (org-entry-put (point) n v))))) - - (widen) - ;; Save and kill the buffer, if it is not the same buffer. - (when (not (eq this-buffer buffer)) - (save-buffer)))) + ;; Get context information that will be lost by moving the + ;; tree. See `org-archive-save-context-info'. + (let* ((all-tags (org-get-tags-at)) + (local-tags (org-get-tags)) + (inherited-tags (org-delete-all local-tags all-tags)) + (context + `((category . ,(org-get-category nil 'force-refresh)) + (file . ,file) + (itags . ,(mapconcat #'identity inherited-tags " ")) + (ltags . ,(mapconcat #'identity local-tags " ")) + (olpath . ,(mapconcat #'identity + (org-get-outline-path) + "/")) + (time . ,time) + (todo . ,(org-entry-get (point) "TODO"))))) + ;; We first only copy, in case something goes wrong + ;; we need to protect `this-command', to avoid kill-region sets it, + ;; which would lead to duplication of subtrees + (let (this-command) (org-copy-subtree 1 nil t)) + (set-buffer buffer) + ;; Enforce Org mode for the archive buffer + (if (not (derived-mode-p 'org-mode)) + ;; Force the mode for future visits. + (let ((org-insert-mode-line-in-empty-file t) + (org-inhibit-startup t)) + (call-interactively 'org-mode))) + (when (and newfile-p org-archive-file-header-format) + (goto-char (point-max)) + (insert (format org-archive-file-header-format + (buffer-file-name this-buffer)))) + (when datetree-date + (require 'org-datetree) + (org-datetree-find-date-create datetree-date) + (org-narrow-to-subtree)) + ;; Force the TODO keywords of the original buffer + (let ((org-todo-line-regexp tr-org-todo-line-regexp) + (org-todo-keywords-1 tr-org-todo-keywords-1) + (org-todo-kwd-alist tr-org-todo-kwd-alist) + (org-done-keywords tr-org-done-keywords) + (org-todo-regexp tr-org-todo-regexp) + (org-todo-line-regexp tr-org-todo-line-regexp) + (org-odd-levels-only + (if (local-variable-p 'org-odd-levels-only (current-buffer)) + org-odd-levels-only + tr-org-odd-levels-only))) + (goto-char (point-min)) + (outline-show-all) + (if (and heading (not (and datetree-date (not datetree-subheading-p)))) + (progn + (if (re-search-forward + (concat "^" (regexp-quote heading) + "[ \t]*\\(:[[:alnum:]_@#%:]+:\\)?[ \t]*\\($\\|\r\\)") + nil t) + (goto-char (match-end 0)) + ;; Heading not found, just insert it at the end + (goto-char (point-max)) + (or (bolp) (insert "\n")) + ;; datetrees don't need too much spacing + (insert (if datetree-date "" "\n") heading "\n") + (end-of-line 0)) + ;; Make the subtree visible + (outline-show-subtree) + (if org-archive-reversed-order + (progn + (org-back-to-heading t) + (outline-next-heading)) + (org-end-of-subtree t)) + (skip-chars-backward " \t\r\n") + (and (looking-at "[ \t\r\n]*") + ;; datetree archives don't need so much spacing. + (replace-match (if datetree-date "\n" "\n\n")))) + ;; No specific heading, just go to end of file. + (goto-char (point-max)) + ;; Subtree narrowing can let the buffer end on + ;; a headline. `org-paste-subtree' then deletes it. + ;; To prevent this, make sure visible part of buffer + ;; always terminates on a new line, while limiting + ;; number of blank lines in a date tree. + (unless (and datetree-date (bolp)) (insert "\n"))) + ;; Paste + (org-paste-subtree (org-get-valid-level level (and heading 1))) + ;; Shall we append inherited tags? + (and inherited-tags + (or (and (eq org-archive-subtree-add-inherited-tags 'infile) + infile-p) + (eq org-archive-subtree-add-inherited-tags t)) + (org-set-tags-to all-tags)) + ;; Mark the entry as done + (when (and org-archive-mark-done + (let ((case-fold-search nil)) + (looking-at org-todo-line-regexp)) + (or (not (match-end 2)) + (not (member (match-string 2) org-done-keywords)))) + (let (org-log-done org-todo-log-states) + (org-todo + (car (or (member org-archive-mark-done org-done-keywords) + org-done-keywords))))) + + ;; Add the context info. + (dolist (item org-archive-save-context-info) + (let ((value (cdr (assq item context)))) + (when (org-string-nw-p value) + (org-entry-put + (point) + (concat "ARCHIVE_" (upcase (symbol-name item))) + value)))) + (widen) + ;; Save and kill the buffer, if it is not the same + ;; buffer. + (unless (eq this-buffer buffer) (save-buffer))))) ;; Here we are back in the original buffer. Everything seems ;; to have worked. So now run hooks, cut the tree and finish ;; up. @@ -394,9 +396,12 @@ this heading." ;;;###autoload (defun org-archive-to-archive-sibling () "Archive the current heading by moving it under the archive sibling. + The archive sibling is a sibling of the heading with the heading name `org-archive-sibling-heading' and an `org-archive-tag' tag. If this -sibling does not exist, it will be created at the end of the subtree." +sibling does not exist, it will be created at the end of the subtree. + +Archiving time is retained in the ARCHIVE_TIME node property." (interactive) (if (and (org-region-active-p) org-loop-over-headlines-in-active-region) (let ((cl (when (eq org-loop-over-headlines-in-active-region 'start-level) @@ -454,7 +459,7 @@ sibling does not exist, it will be created at the end of the subtree." (format-time-string (substring (cdr org-time-stamp-formats) 1 -1))) (outline-up-heading 1 t) - (hide-subtree) + (outline-hide-subtree) (org-cycle-show-empty-lines 'folded) (goto-char pos))) (org-reveal) @@ -467,9 +472,10 @@ If the cursor is not on a headline, try all level 1 trees. If it is on a headline, try all direct children. When TAG is non-nil, don't move trees, but mark them with the ARCHIVE tag." (org-archive-all-matches - (lambda (beg end) - (unless (re-search-forward org-not-done-heading-regexp end t) - "no open TODO items")) + (lambda (_beg end) + (let ((case-fold-search nil)) + (unless (re-search-forward org-not-done-heading-regexp end t) + "no open TODO items"))) tag)) (defun org-archive-all-old (&optional tag) @@ -478,7 +484,7 @@ If the cursor is not on a headline, try all level 1 trees. If it is on a headline, try all direct children. When TAG is non-nil, don't move trees, but mark them with the ARCHIVE tag." (org-archive-all-matches - (lambda (beg end) + (lambda (_beg end) (let (ts) (and (re-search-forward org-ts-regexp end t) (setq ts (match-string 0)) @@ -565,7 +571,7 @@ the children that do not contain any open TODO items." (save-excursion (org-back-to-heading t) (setq set (org-toggle-tag org-archive-tag)) - (when set (hide-subtree))) + (when set (org-flag-subtree t))) (and set (beginning-of-line 1)) (message "Subtree %s" (if set "archived" "unarchived")))))) diff --git a/elpa/org-plus-contrib-20150831/org-attach.el b/elpa/org-plus-contrib-20170407/org-attach.el similarity index 82% rename from elpa/org-plus-contrib-20150831/org-attach.el rename to elpa/org-plus-contrib-20170407/org-attach.el index fb4c385f..da2bd0e9 100644 --- a/elpa/org-plus-contrib-20150831/org-attach.el +++ b/elpa/org-plus-contrib-20170407/org-attach.el @@ -1,6 +1,6 @@ -;;; org-attach.el --- Manage file attachments to org-mode tasks +;;; org-attach.el --- Manage file attachments to Org tasks -*- lexical-binding: t; -*- -;; Copyright (C) 2008-2015 Free Software Foundation, Inc. +;; Copyright (C) 2008-2017 Free Software Foundation, Inc. ;; Author: John Wiegley ;; Keywords: org data task @@ -22,7 +22,7 @@ ;;; Commentary: -;; See the Org-mode manual for information on how to use it. +;; See the Org manual for information on how to use it. ;; ;; Attachments are managed in a special directory called "data", which ;; lives in the same directory as the org file itself. If this data @@ -37,14 +37,13 @@ ;;; Code: -(eval-when-compile - (require 'cl)) -(require 'org-id) +(require 'cl-lib) (require 'org) +(require 'org-id) (require 'vc-git) (defgroup org-attach nil - "Options concerning entry attachments in Org-mode." + "Options concerning entry attachments in Org mode." :tag "Org Attach" :group 'org) @@ -55,6 +54,14 @@ where the Org file lives." :group 'org-attach :type 'directory) +(defcustom org-attach-commit t + "If non-nil commit attachments with git. +This is only done if the Org file is in a git repository." + :group 'org-attach + :type 'boolean + :version "26.1" + :package-version '(Org . "9.0")) + (defcustom org-attach-git-annex-cutoff (* 32 1024) "If non-nil, files larger than this will be annexed instead of stored." :group 'org-attach @@ -124,13 +131,24 @@ lns create a symbol link. Note that this is not supported "Non-nil means attachments are deleted upon archiving a subtree. When set to `query', ask the user instead." :group 'org-attach - :version "25.1" + :version "26.1" :package-version '(Org . "8.3") :type '(choice (const :tag "Never delete attachments" nil) (const :tag "Always delete attachments" t) (const :tag "Query the user" query))) +(defcustom org-attach-annex-auto-get 'ask + "Confirmation preference for automatically getting annex files. +If \\='ask, prompt using `y-or-n-p'. If t, always get. If nil, never get." + :group 'org-attach + :package-version '(Org . "9") + :version "26.1" + :type '(choice + (const :tag "confirm with `y-or-n-p'" ask) + (const :tag "always get from annex if necessary" t) + (const :tag "never get from annex" nil))) + ;;;###autoload (defun org-attach () "The dispatcher for attachment commands. @@ -155,6 +173,7 @@ Shows a list of commands and prompts for another key to execute a command." a Select a file and attach it to the task, using `org-attach-method'. c/m/l/y Attach a file using copy/move/link/symbolic-link method. +u Attach a file from URL (downloading it). n Create a new attachment, as an Emacs buffer. z Synchronize the current task with its attachment directory, in case you added attachments yourself. @@ -184,6 +203,8 @@ i Make children of the current entry inherit its attachment directory."))) (let ((org-attach-method 'ln)) (call-interactively 'org-attach-attach))) ((memq c '(?y ?\C-y)) (let ((org-attach-method 'lns)) (call-interactively 'org-attach-attach))) + ((memq c '(?u ?\C-u)) + (let ((org-attach-method 'url)) (call-interactively 'org-attach-url))) ((memq c '(?n ?\C-n)) (call-interactively 'org-attach-new)) ((memq c '(?z ?\C-z)) (call-interactively 'org-attach-sync)) ((memq c '(?o ?\C-o)) (call-interactively 'org-attach-open)) @@ -208,25 +229,23 @@ using the entry ID will be invoked to access the unique directory for the current entry. If the directory does not exist and CREATE-IF-NOT-EXISTS-P is non-nil, the directory and (if necessary) the corresponding ID will be created." - (let (attach-dir uuid inherit) + (let (attach-dir uuid) (setq org-attach-inherited (org-entry-get nil "ATTACH_DIR_INHERIT")) (cond ((setq attach-dir (org-entry-get nil "ATTACH_DIR")) (org-attach-check-absolute-path attach-dir)) ((and org-attach-allow-inheritance - (setq inherit (org-entry-get nil "ATTACH_DIR_INHERIT" t))) + (org-entry-get nil "ATTACH_DIR_INHERIT" t)) (setq attach-dir - (save-excursion - (save-restriction - (widen) - (if (marker-position org-entry-property-inherited-from) - (goto-char org-entry-property-inherited-from) - (org-back-to-heading t)) - (let (org-attach-allow-inheritance) - (org-attach-dir create-if-not-exists-p))))) + (org-with-wide-buffer + (if (marker-position org-entry-property-inherited-from) + (goto-char org-entry-property-inherited-from) + (org-back-to-heading t)) + (let (org-attach-allow-inheritance) + (org-attach-dir create-if-not-exists-p)))) (org-attach-check-absolute-path attach-dir) (setq org-attach-inherited t)) - (t ; use the ID + (t ; use the ID (org-attach-check-absolute-path nil) (setq uuid (org-id-get (point) create-if-not-exists-p)) (when (or uuid create-if-not-exists-p) @@ -272,34 +291,59 @@ the ATTACH_DIR property) their own attachment directory." (org-entry-put nil "ATTACH_DIR_INHERIT" "t") (message "Children will inherit attachment directory")) +(defun org-attach-use-annex () + "Return non-nil if git annex can be used." + (let ((git-dir (vc-git-root (expand-file-name org-attach-directory)))) + (and org-attach-git-annex-cutoff + (or (file-exists-p (expand-file-name "annex" git-dir)) + (file-exists-p (expand-file-name ".git/annex" git-dir)))))) + +(defun org-attach-annex-get-maybe (path) + "Call git annex get PATH (via shell) if using git annex. +Signals an error if the file content is not available and it was not retrieved." + (let ((path-relative (file-relative-name path))) + (when (and (org-attach-use-annex) + (not + (string-equal + "found" + (shell-command-to-string + (format "git annex find --format=found --in=here %s" + (shell-quote-argument path-relative)))))) + (let ((should-get + (if (eq org-attach-annex-auto-get 'ask) + (y-or-n-p (format "Run git annex get %s? " path-relative)) + org-attach-annex-auto-get))) + (if should-get + (progn (message "Running git annex get \"%s\"." path-relative) + (call-process "git" nil nil nil "annex" "get" path-relative)) + (error "File %s stored in git annex but it is not available, and was not retrieved" + path)))))) + (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)) (git-dir (vc-git-root dir)) + (use-annex (org-attach-use-annex)) (changes 0)) (when (and git-dir (executable-find "git")) (with-temp-buffer (cd dir) - (let ((have-annex - (and org-attach-git-annex-cutoff - (or (file-exists-p (expand-file-name "annex" git-dir)) - (file-exists-p (expand-file-name ".git/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 (new-or-modified + (split-string + (shell-command-to-string + "git ls-files -zmo --exclude-standard") "\0" t)) + (if (and use-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)) + (cl-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)) + (cl-incf changes)) (when (> changes 0) (shell-command "git commit -m 'Synchronized attachments'")))))) @@ -322,10 +366,14 @@ Only do this when `org-attach-store-link-p' is non-nil." (file-name-nondirectory file)) org-stored-links))) +(defun org-attach-url (url) + (interactive "MURL of the file to attach: \n") + (org-attach-attach url)) + (defun org-attach-attach (file &optional visit-dir method) "Move/copy/link FILE into the attachment directory of the current task. If VISIT-DIR is non-nil, visit the directory with dired. -METHOD may be `cp', `mv', `ln', or `lns' default taken from +METHOD may be `cp', `mv', `ln', `lns' or `url' default taken from `org-attach-method'." (interactive "fFile to keep as an attachment: \nP") (setq method (or method org-attach-method)) @@ -339,8 +387,10 @@ METHOD may be `cp', `mv', `ln', or `lns' default taken from ((eq method 'mv) (rename-file file fname)) ((eq method 'cp) (copy-file file fname)) ((eq method 'ln) (add-name-to-file file fname)) - ((eq method 'lns) (make-symbolic-link file fname))) - (org-attach-commit) + ((eq method 'lns) (make-symbolic-link file fname)) + ((eq method 'url) (url-copy-file file fname))) + (when org-attach-commit + (org-attach-commit)) (org-attach-tag) (cond ((eq org-attach-store-link-p 'attached) (org-attach-store-link fname)) @@ -390,7 +440,7 @@ The attachment is created as an Emacs buffer." (let* ((attach-dir (org-attach-dir t)) (files (org-attach-file-list attach-dir)) (file (or file - (org-icompleting-read + (completing-read "Delete attachment: " (mapcar (lambda (f) (list (file-name-nondirectory f))) @@ -466,9 +516,11 @@ If IN-EMACS is non-nil, force opening in Emacs." (files (org-attach-file-list attach-dir)) (file (if (= (length files) 1) (car files) - (org-icompleting-read "Open attachment: " - (mapcar 'list files) nil t)))) - (org-open-file (expand-file-name file attach-dir) in-emacs))) + (completing-read "Open attachment: " + (mapcar #'list files) nil t))) + (path (expand-file-name file attach-dir))) + (org-attach-annex-get-maybe path) + (org-open-file path in-emacs))) (defun org-attach-open-in-emacs () "Open attachment, force opening in Emacs. diff --git a/elpa/org-plus-contrib-20150831/org-bbdb.el b/elpa/org-plus-contrib-20170407/org-bbdb.el similarity index 75% rename from elpa/org-plus-contrib-20150831/org-bbdb.el rename to elpa/org-plus-contrib-20170407/org-bbdb.el index c4893850..a4ccbca0 100644 --- a/elpa/org-plus-contrib-20150831/org-bbdb.el +++ b/elpa/org-plus-contrib-20170407/org-bbdb.el @@ -1,6 +1,6 @@ -;;; org-bbdb.el --- Support for links to BBDB entries from within Org-mode +;;; org-bbdb.el --- Support for links to BBDB entries -*- lexical-binding: t; -*- -;; Copyright (C) 2004-2015 Free Software Foundation, Inc. +;; Copyright (C) 2004-2017 Free Software Foundation, Inc. ;; Authors: Carsten Dominik ;; Thomas Baumann @@ -25,12 +25,12 @@ ;; ;;; Commentary: -;; This file implements links to BBDB database entries from within Org-mode. -;; Org-mode loads this module by default - if this is not what you want, +;; This file implements links to BBDB database entries from within Org. +;; Org mode loads this module by default - if this is not what you want, ;; configure the variable `org-modules'. ;; It also implements an interface (based on Ivar Rummelhoff's -;; bbdb-anniv.el) for those org-mode users, who do not use the diary +;; bbdb-anniv.el) for those Org users, who do not use the diary ;; but who do want to include the anniversaries stored in the BBDB ;; into the org-agenda. If you already include the `diary' into the ;; agenda, you might want to prefer to include the anniversaries in @@ -94,8 +94,7 @@ ;;; Code: (require 'org) -(eval-when-compile - (require 'cl)) +(require 'cl-lib) ;; Declare external functions and variables @@ -106,6 +105,7 @@ (declare-function bbdb-name "ext:bbdb-com" (string elidep)) (declare-function bbdb-completing-read-record "ext:bbdb-com" (prompt &optional omit-records)) +(declare-function bbdb-record-field "ext:bbdb" (recond field)) (declare-function bbdb-record-getprop "ext:bbdb" (record property)) (declare-function bbdb-record-name "ext:bbdb" (record)) (declare-function bbdb-records "ext:bbdb" @@ -124,7 +124,7 @@ (declare-function calendar-leap-year-p "calendar" (year)) (declare-function diary-ordinal-suffix "diary-lib" (n)) -(org-no-warnings (defvar date)) ;; unprefixed, from calendar.el +(with-no-warnings (defvar date)) ;; unprefixed, from calendar.el ;; Customization @@ -138,6 +138,24 @@ :group 'org-bbdb-anniversaries :require 'bbdb) +(defcustom org-bbdb-general-anniversary-description-after 7 + "When to switch anniversary descriptions to a more general format. + +Anniversary descriptions include the point in time, when the +anniversary appears. This is, in its most general form, just the +date of the anniversary. Or more specific terms, like \"today\", +\"tomorrow\" or \"in n days\" are used to describe the time span. + +If the anniversary happens in less than that number of days, the +specific description is used. Otherwise, the general one is +used." + :group 'org-bbdb-anniversaries + :version "26.1" + :package-version '(Org . "9.1") + :type 'integer + :require 'bbdb + :safe #'integerp) + (defcustom org-bbdb-anniversary-format-alist '(("birthday" . (lambda (name years suffix) @@ -194,10 +212,12 @@ date year)." :group 'org-bbdb-anniversaries :require 'bbdb) - ;; Install the link type -(org-add-link-type "bbdb" 'org-bbdb-open 'org-bbdb-export) -(add-hook 'org-store-link-functions 'org-bbdb-store-link) +(org-link-set-parameters "bbdb" + :follow #'org-bbdb-open + :export #'org-bbdb-export + :complete #'org-bbdb-complete-link + :store #'org-bbdb-store-link) ;; Implementation (defun org-bbdb-store-link () @@ -208,7 +228,7 @@ date year)." (name (bbdb-record-name rec)) (company (if (fboundp 'bbdb-record-getprop) (bbdb-record-getprop rec 'company) - (car (bbdb-record-get-field rec 'organization)))) + (car (bbdb-record-field rec 'organization)))) (link (concat "bbdb:" name))) (org-store-link-props :type "bbdb" :name name :company company :link link :description name) @@ -230,10 +250,9 @@ italicized, in all other cases it is left unchanged." (defun org-bbdb-open (name) "Follow a BBDB link to NAME." (require 'bbdb-com) - (let ((inhibit-redisplay (not debug-on-error)) - (bbdb-electric-p nil)) + (let ((inhibit-redisplay (not debug-on-error))) (if (fboundp 'bbdb-name) - (org-bbdb-open-old name) + (org-bbdb-open-old name) (org-bbdb-open-new name)))) (defun org-bbdb-open-old (name) @@ -280,14 +299,11 @@ italicized, in all other cases it is left unchanged." "Convert YYYY-MM-DD to (month date year). Argument TIME-STR is the value retrieved from BBDB. If YYYY- is omitted it will be considered unknown." - (multiple-value-bind (a b c) (values-list (org-split-string time-str "-")) - (if (eq c nil) - (list (string-to-number a) - (string-to-number b) - nil) - (list (string-to-number b) - (string-to-number c) - (string-to-number a))))) + (pcase (org-split-string time-str "-") + (`(,a ,b nil) (list (string-to-number a) (string-to-number b) nil)) + (`(,a ,b ,c) (list (string-to-number b) + (string-to-number c) + (string-to-number a))))) (defun org-bbdb-anniv-split (str) "Split multiple entries in the BBDB anniversary field. @@ -325,9 +341,9 @@ The anniversaries are assumed to be stored `org-bbdb-anniversary-field'." (bbdb-split "\n" annivs))) (while annivs (setq split (org-bbdb-anniv-split (pop annivs))) - (multiple-value-bind (m d y) - (values-list (funcall org-bbdb-extract-date-fun (car split))) - (setq tmp (gethash (list m d) org-bbdb-anniv-hash)) + (pcase-let ((`(,m ,d ,y) (funcall org-bbdb-extract-date-fun + (car split)))) + (setq tmp (gethash (list m d) org-bbdb-anniv-hash)) (puthash (list m d) (cons (list y (bbdb-record-name rec) (cadr split)) @@ -335,7 +351,7 @@ The anniversaries are assumed to be stored `org-bbdb-anniversary-field'." org-bbdb-anniv-hash)))))) (setq org-bbdb-updated-p nil)) -(defun org-bbdb-updated (rec) +(defun org-bbdb-updated (_rec) "Record the fact that BBDB has been updated. This is used by Org to re-create the anniversary hash table." (setq org-bbdb-updated-p t)) @@ -397,6 +413,83 @@ This is used by Org to re-create the anniversary hash table." )) text)) +;;; Return list of anniversaries for today and the next n-1 (default: n=7) days. +;;; This is meant to be used in an org file instead of org-bbdb-anniversaries: +;;; +;;; %%(org-bbdb-anniversaries-future) +;;; +;;; or +;;; +;;; %%(org-bbdb-anniversaries-future 3) +;;; +;;; to override the 7-day default. + +(defun org-bbdb-date-list (d n) + "Return a list of dates in (m d y) format from the given date D to n-1 days hence." + (let ((abs (calendar-absolute-from-gregorian d))) + (mapcar (lambda (i) (calendar-gregorian-from-absolute (+ abs i))) + (number-sequence 0 (1- n))))) + +(defun org-bbdb-anniversary-description (agenda-date anniv-date) + "Return a string used to incorporate into an agenda anniversary entry. +The calculation of the anniversary description string is based on +the difference between the anniversary date, given as ANNIV-DATE, +and the date on which the entry appears in the agenda, given as +AGENDA-DATE. This makes it possible to have different entries +for the same event depending on if it occurs in the next few days +or far away in the future." + (let ((delta (- (calendar-absolute-from-gregorian anniv-date) + (calendar-absolute-from-gregorian agenda-date)))) + + (cond + ((= delta 0) " -- today\\&") + ((= delta 1) " -- tomorrow\\&") + ((< delta org-bbdb-general-anniversary-description-after) (format " -- in %d days\\&" delta)) + ((pcase-let ((`(,month ,day ,year) anniv-date)) + (format " -- %d-%02d-%02d\\&" year month day)))))) + + +(defun org-bbdb-anniversaries-future (&optional n) + "Return list of anniversaries for today and the next n-1 days (default n=7)." + (let ((n (or n 7))) + (when (<= n 0) + (error "The (optional) argument of `org-bbdb-anniversaries-future' \ +must be positive")) + (let ( + ;; List of relevant dates. + (dates (org-bbdb-date-list date n)) + ;; Function to annotate text of each element of l with the + ;; anniversary date d. + (annotate-descriptions + (lambda (agenda-date d l) + (mapcar (lambda (x) + ;; The assumption here is that x is a bbdb link + ;; of the form [[bbdb:name][description]]. + ;; This function rather arbitrarily modifies + ;; the description by adding the date to it in + ;; a fixed format. + (let ((desc (org-bbdb-anniversary-description + agenda-date d))) + (string-match "]]" x) + (replace-match desc nil nil x))) + l)))) + ;; Map a function that generates anniversaries for each date + ;; over the dates and nconc the results into a single list. When + ;; it is no longer necessary to support older versions of Emacs, + ;; this can be done with a cl-mapcan; for now, we use the (apply + ;; #'nconc ...) method for compatibility. + (apply #'nconc + (mapcar + (lambda (d) + (let ((agenda-date date) + (date d)) + ;; Rebind 'date' so that org-bbdb-anniversaries will + ;; be fooled into giving us the list for the given + ;; date and then annotate the descriptions for that + ;; date. + (funcall annotate-descriptions agenda-date d (org-bbdb-anniversaries)))) + dates))))) + (defun org-bbdb-complete-link () "Read a bbdb link with name completion." (require 'bbdb-com) diff --git a/elpa/org-plus-contrib-20150831/org-bibtex-extras.el b/elpa/org-plus-contrib-20170407/org-bibtex-extras.el similarity index 92% rename from elpa/org-plus-contrib-20150831/org-bibtex-extras.el rename to elpa/org-plus-contrib-20170407/org-bibtex-extras.el index 5f050397..c5b521a2 100644 --- a/elpa/org-plus-contrib-20150831/org-bibtex-extras.el +++ b/elpa/org-plus-contrib-20170407/org-bibtex-extras.el @@ -1,6 +1,6 @@ ;;; org-bibtex-extras --- extras for working with org-bibtex entries -;; Copyright (C) 2008-2014 Free Software Foundation, Inc. +;; Copyright (C) 2008-2017 Free Software Foundation, Inc. ;; Author: Eric Schulte ;; Keywords: outlines, hypermedia, bibtex, d3 @@ -61,6 +61,8 @@ ;;; Code: (require 'org-bibtex) +(declare-function org-trim "org" (s &optional keep-lead)) + (defcustom obe-bibtex-file nil "File holding bibtex entries.") (defcustom obe-html-link-base nil @@ -91,7 +93,7 @@ For example, to point to your `obe-bibtex-file' use the following. (replace-match (save-match-data (mapconcat (lambda (c) (format "[[%s#%s][%s]]" obe-html-link-base c c)) - (mapcar #'org-babel-trim + (mapcar #'org-trim (split-string (match-string 1) ",")) ", ")))))) (defun obe-meta-to-json (meta &optional fields) @@ -111,12 +113,12 @@ For example, to point to your `obe-bibtex-file' use the following. (add (remove-duplicates (col field) :test #'string=))) ;; build the links in the graph (dolist (citation meta) - (let ((dest (id (cdr (assoc :title citation))))) - (dolist (author (mapcar #'id (cdr (assoc :authors citation)))) + (let ((dest (id (cdr (assq :title citation))))) + (dolist (author (mapcar #'id (cdr (assq :authors citation)))) (when author (push (cons author dest) links))) - (let ((jid (id (cdr (assoc :journal citation))))) + (let ((jid (id (cdr (assq :journal citation))))) (when jid (push (cons jid dest) links))) - (let ((cid (id (cdr (assoc :category citation))))) + (let ((cid (id (cdr (assq :category citation))))) (when cid (push (cons cid dest) links))))) ;; build the json string (format "{\"nodes\":[%s],\"links\":[%s]}" diff --git a/elpa/org-plus-contrib-20150831/org-bibtex.el b/elpa/org-plus-contrib-20170407/org-bibtex.el similarity index 90% rename from elpa/org-plus-contrib-20150831/org-bibtex.el rename to elpa/org-plus-contrib-20170407/org-bibtex.el index d795c534..0d4bd22c 100644 --- a/elpa/org-plus-contrib-20150831/org-bibtex.el +++ b/elpa/org-plus-contrib-20170407/org-bibtex.el @@ -1,6 +1,6 @@ -;;; org-bibtex.el --- Org links to BibTeX entries +;;; org-bibtex.el --- Org links to BibTeX entries -*- lexical-binding: t; -*- ;; -;; Copyright (C) 2007-2015 Free Software Foundation, Inc. +;; Copyright (C) 2007-2017 Free Software Foundation, Inc. ;; ;; Authors: Bastien Guerry ;; Carsten Dominik @@ -73,7 +73,7 @@ ;; ===================================================================== ;; ;; Additionally, the following functions are now available for storing -;; bibtex entries within Org-mode documents. +;; bibtex entries within Org documents. ;; ;; - Run `org-bibtex' to export the current file to a .bib. ;; @@ -92,27 +92,28 @@ ;; ;;; History: ;; -;; The link creation part has been part of Org-mode for a long time. +;; The link creation part has been part of Org for a long time. ;; ;; 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. ;; ;; Eric Schulte eventually added the functions for translating between -;; Org-mode headlines and Bibtex entries, and for fleshing out the Bibtex -;; fields of existing Org-mode headlines. +;; Org headlines and Bibtex entries, and for fleshing out the Bibtex +;; fields of existing Org headlines. ;; -;; Org-mode loads this module by default - if this is not what you want, +;; Org mode loads this module by default - if this is not what you want, ;; configure the variable `org-modules'. ;;; Code: (require 'org) (require 'bibtex) -(eval-when-compile - (require 'cl)) +(require 'cl-lib) (require 'org-compat) +(defvar org-agenda-overriding-header) +(defvar org-agenda-search-view-always-boolean) (defvar org-bibtex-description nil) ; dynamically scoped from org.el (defvar org-id-locations) @@ -120,7 +121,6 @@ (declare-function bibtex-generate-autokey "bibtex" ()) (declare-function bibtex-parse-entry "bibtex" (&optional content)) (declare-function bibtex-url "bibtex" (&optional pos no-browse)) -(declare-function org-babel-trim "ob" (string &optional regexp)) ;;; Bibtex data @@ -195,7 +195,7 @@ (:howpublished . "How something strange has been published. The first word should be capitalized.") (:institution . "The sponsoring institution of a technical report.") (:journal . "A journal name.") - (:key . "Used for alphabetizing, cross-referencing, and creating a label when the author information is missing. This field should not be confused with the key that appears in the \cite command and at the beginning of the database entry.") + (:key . "Used for alphabetizing, cross-referencing, and creating a label when the author information is missing. This field should not be confused with the key that appears in the \\cite command and at the beginning of the database entry.") (:month . "The month in which the work was published or, for an unpublished work, in which it was written. You should use the standard three-letter abbreviation,") (:note . "Any additional information that can help the reader. The first word should be capitalized.") (:number . "Any additional information that can help the reader. The first word should be capitalized.") @@ -221,7 +221,7 @@ (defcustom org-bibtex-prefix nil "Optional prefix for all bibtex property names. -For example setting to 'BIB_' would allow interoperability with fireforg." +For example setting to `BIB_' would allow interoperability with fireforg." :group 'org-bibtex :version "24.1" :type '(choice @@ -237,6 +237,17 @@ a missing title field." :version "24.1" :type 'boolean) +(defcustom org-bibtex-headline-format-function + (lambda (entry) (cdr (assq :title entry))) + "Function returning the headline text for `org-bibtex-write'. +It should take a single argument, the bibtex entry (an alist as +returned by `org-bibtex-read'). The default value simply returns +the entry title." + :group 'org-bibtex + :version "26.1" + :package-version '(Org . "9.1") + :type 'function) + (defcustom org-bibtex-export-arbitrary-fields nil "When converting to bibtex allow fields not defined in `org-bibtex-fields'. This only has effect if `org-bibtex-prefix' is defined, so as to @@ -293,7 +304,7 @@ It is relevant only if `org-bibtex-tags-are-keywords' is non-nil. Tag inheritence itself is controlled by `org-use-tag-inheritence' and `org-exclude-tags-from-inheritence'." :group 'org-bibtex - :version "25.1" + :version "26.1" :package-version '(Org . "8.3") :type 'boolean) @@ -312,7 +323,7 @@ and `org-exclude-tags-from-inheritence'." (org-entry-get (point) (upcase property)) (org-entry-get (point) (concat org-bibtex-prefix (upcase property))))))) - (when it (org-babel-trim it)))) + (when it (org-trim it)))) (defun org-bibtex-put (property value) (let ((prop (upcase (if (keywordp property) @@ -325,29 +336,27 @@ and `org-exclude-tags-from-inheritence'." (defun org-bibtex-headline () "Return a bibtex entry of the given headline as a string." - (let* ((val (lambda (key lst) (cdr (assoc key lst)))) - (to (lambda (string) (intern (concat ":" string)))) - (from (lambda (key) (substring (symbol-name key) 1))) - flatten ; silent compiler warning - (flatten (lambda (&rest lsts) - (apply #'append (mapcar - (lambda (e) - (if (listp e) (apply flatten e) (list e))) - lsts)))) - (notes (buffer-string)) - (id (org-bibtex-get org-bibtex-key-property)) - (type (org-bibtex-get org-bibtex-type-property-name)) - (tags (when org-bibtex-tags-are-keywords - (delq nil - (mapcar - (lambda (tag) - (unless (member tag - (append org-bibtex-tags - org-bibtex-no-export-tags)) - tag)) - (if org-bibtex-inherit-tags - (org-get-tags-at) - (org-get-local-tags-at))))))) + (letrec ((val (lambda (key lst) (cdr (assoc key lst)))) + (to (lambda (string) (intern (concat ":" string)))) + (from (lambda (key) (substring (symbol-name key) 1))) + (flatten (lambda (&rest lsts) + (apply #'append (mapcar + (lambda (e) + (if (listp e) (apply flatten e) (list e))) + lsts)))) + (id (org-bibtex-get org-bibtex-key-property)) + (type (org-bibtex-get org-bibtex-type-property-name)) + (tags (when org-bibtex-tags-are-keywords + (delq nil + (mapcar + (lambda (tag) + (unless (member tag + (append org-bibtex-tags + org-bibtex-no-export-tags)) + tag)) + (if org-bibtex-inherit-tags + (org-get-tags-at) + (org-get-local-tags-at))))))) (when type (let ((entry (format "@%s{%s,\n%s\n}\n" type id @@ -373,7 +382,7 @@ and `org-exclude-tags-from-inheritence'." (mapcar (lambda (field) (let ((value (or (org-bibtex-get (funcall from field)) - (and (equal :title field) + (and (eq :title field) (nth 4 (org-heading-components)))))) (when value (cons (funcall from field) value)))) (funcall flatten @@ -436,13 +445,14 @@ With optional argument OPTIONAL, also prompt for optional fields." (funcall val :required (funcall val type org-bibtex-types))) (when optional (funcall val :optional (funcall val type org-bibtex-types))))) (when (consp field) ; or'd pair of fields e.g., (:editor :author) - (let ((present (first (remove + (let ((present (nth 0 (remove nil (mapcar - (lambda (f) (when (org-bibtex-get (funcall name f)) f)) + (lambda (f) + (when (org-bibtex-get (funcall name f)) f)) field))))) (setf field (or present (funcall keyword - (org-icompleting-read + (completing-read "Field: " (mapcar name field))))))) (let ((name (funcall name field))) (unless (org-bibtex-get name) @@ -454,8 +464,9 @@ With optional argument OPTIONAL, also prompt for optional fields." ;;; Bibtex link functions -(org-add-link-type "bibtex" 'org-bibtex-open) -(add-hook 'org-store-link-functions 'org-bibtex-store-link) +(org-link-set-parameters "bibtex" + :follow #'org-bibtex-open + :store #'org-bibtex-store-link) (defun org-bibtex-open (path) "Visit the bibliography entry on PATH." @@ -548,21 +559,23 @@ With optional argument OPTIONAL, also prompt for optional fields." (add-hook 'org-execute-file-search-functions 'org-execute-file-search-in-bibtex) -;;; Bibtex <-> Org-mode headline translation functions -(defun org-bibtex (&optional filename) +;;; Bibtex <-> Org headline translation functions +(defun org-bibtex (filename) "Export each headline in the current file to a bibtex entry. Headlines are exported using `org-bibtex-headline'." (interactive (list (read-file-name "Bibtex file: " nil nil nil - (file-name-nondirectory - (concat (file-name-sans-extension (buffer-file-name)) ".bib"))))) + (let ((file (buffer-file-name (buffer-base-buffer)))) + (and file + (file-name-nondirectory + (concat (file-name-sans-extension file) ".bib"))))))) (let ((error-point (catch 'bib (let ((bibtex-entries (remove nil (org-map-entries (lambda () - (condition-case foo + (condition-case nil (org-bibtex-headline) (error (throw 'bib (point))))))))) (with-temp-file filename @@ -593,7 +606,7 @@ With prefix argument OPTIONAL also prompt for optional fields." With a prefix arg, query for optional fields as well. If nonew is t, add data to the headline of the entry at point." (interactive "P") - (let* ((type (org-icompleting-read + (let* ((type (completing-read "Type: " (mapcar (lambda (type) (substring (symbol-name (car type)) 1)) org-bibtex-types) @@ -612,7 +625,7 @@ If nonew is t, add data to the headline of the entry at point." (org-bibtex-put org-bibtex-type-property-name (substring (symbol-name type) 1)) (org-bibtex-fleshout type arg) - (mapc (lambda (tag) (org-toggle-tag tag 'on)) org-bibtex-tags))) + (dolist (tag org-bibtex-tags) (org-toggle-tag tag 'on)))) (defun org-bibtex-create-in-current-entry (&optional arg) "Add bibliographical data to the current entry. @@ -626,10 +639,10 @@ This uses `bibtex-parse-entry'." (interactive) (let ((keyword (lambda (str) (intern (concat ":" (downcase str))))) (clean-space (lambda (str) (replace-regexp-in-string - "[[:space:]\n\r]+" " " str))) + "[[:space:]\n\r]+" " " str))) (strip-delim - (lambda (str) ; strip enclosing "..." and {...} - (dolist (pair '((34 . 34) (123 . 125) (123 . 125))) + (lambda (str) ; strip enclosing "..." and {...} + (dolist (pair '((34 . 34) (123 . 125))) (when (and (> (length str) 1) (= (aref str 0) (car pair)) (= (aref str (1- (length str))) (cdr pair))) @@ -637,10 +650,10 @@ This uses `bibtex-parse-entry'." (push (mapcar (lambda (pair) (cons (let ((field (funcall keyword (car pair)))) - (case field + (pcase field (:=type= :type) (:=key= :key) - (otherwise field))) + (_ field))) (funcall clean-space (funcall strip-delim (cdr pair))))) (save-excursion (bibtex-beginning-of-entry) (bibtex-parse-entry))) org-bibtex-entries))) @@ -676,30 +689,28 @@ Return the number of saved entries." (val (lambda (field) (cdr (assoc field entry)))) (togtag (lambda (tag) (org-toggle-tag tag 'on)))) (org-insert-heading) - (insert (funcall val :title)) + (insert (funcall org-bibtex-headline-format-function entry)) (org-bibtex-put "TITLE" (funcall val :title)) (org-bibtex-put org-bibtex-type-property-name (downcase (funcall val :type))) (dolist (pair entry) - (case (car pair) + (pcase (car pair) (:title nil) (:type nil) (:key (org-bibtex-put org-bibtex-key-property (cdr pair))) (:keywords (if org-bibtex-tags-are-keywords - (mapc - (lambda (kw) - (funcall - togtag - (replace-regexp-in-string - "[^[:alnum:]_@#%]" "" - (replace-regexp-in-string "[ \t]+" "_" kw)))) - (split-string (cdr pair) ", *")) + (dolist (kw (split-string (cdr pair) ", *")) + (funcall + togtag + (replace-regexp-in-string + "[^[:alnum:]_@#%]" "" + (replace-regexp-in-string "[ \t]+" "_" kw)))) (org-bibtex-put (car pair) (cdr pair)))) - (otherwise (org-bibtex-put (car pair) (cdr pair))))) + (_ (org-bibtex-put (car pair) (cdr pair))))) (mapc togtag org-bibtex-tags))) (defun org-bibtex-yank () - "If kill ring holds a bibtex entry yank it as an Org-mode headline." + "If kill ring holds a bibtex entry yank it as an Org headline." (interactive) (let (entry) (with-temp-buffer (yank 1) (setf entry (org-bibtex-read))) @@ -708,7 +719,7 @@ Return the number of saved entries." (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." + "Read bibtex entries from FILE and insert as Org headlines after point." (interactive "fFile: ") (dotimes (_ (org-bibtex-read-file file)) (save-excursion (org-bibtex-write)) diff --git a/elpa/org-plus-contrib-20150831/org-bookmark.el b/elpa/org-plus-contrib-20170407/org-bookmark.el similarity index 94% rename from elpa/org-plus-contrib-20150831/org-bookmark.el rename to elpa/org-plus-contrib-20170407/org-bookmark.el index 9a69bbba..04a473b6 100644 --- a/elpa/org-plus-contrib-20150831/org-bookmark.el +++ b/elpa/org-plus-contrib-20170407/org-bookmark.el @@ -1,5 +1,5 @@ ;;; org-bookmark.el - Support for links to bookmark -;; Copyright (C) 2008-2014 Free Software Foundation, Inc. +;; Copyright (C) 2008-2017 Free Software Foundation, Inc. ;; ;; Author: Tokuya Kameshima ;; Version: 1.0 @@ -47,8 +47,9 @@ Otherwise prompt the user for the right bookmark to use." :group 'org-bookmark :type 'boolean) -(org-add-link-type "bookmark" 'org-bookmark-open) -(add-hook 'org-store-link-functions 'org-bookmark-store-link) +(org-link-set-parameters "bookmark" + :follow #'org-bookmark-open + :store #'org-bookmark-store-link) (defun org-bookmark-open (bookmark) "Visit the bookmark BOOKMARK." diff --git a/elpa/org-plus-contrib-20150831/org-capture.el b/elpa/org-plus-contrib-20170407/org-capture.el similarity index 65% rename from elpa/org-plus-contrib-20150831/org-capture.el rename to elpa/org-plus-contrib-20170407/org-capture.el index 93a7f2ab..03e5230e 100644 --- a/elpa/org-plus-contrib-20150831/org-capture.el +++ b/elpa/org-plus-contrib-20170407/org-capture.el @@ -1,6 +1,6 @@ -;;; org-capture.el --- Fast note taking in Org-mode +;;; org-capture.el --- Fast note taking in Org -*- lexical-binding: t; -*- -;; Copyright (C) 2010-2015 Free Software Foundation, Inc. +;; Copyright (C) 2010-2017 Free Software Foundation, Inc. ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp @@ -47,20 +47,19 @@ ;;; Code: -(eval-when-compile - (require 'cl)) +(require 'cl-lib) (require 'org) +(declare-function org-at-encrypted-entry-p "org-crypt" ()) (declare-function org-datetree-find-date-create "org-datetree" (date &optional keep-restriction)) +(declare-function org-decrypt-entry "org-crypt" ()) +(declare-function org-encrypt-entry "org-crypt" ()) (declare-function org-table-analyze "org-table" ()) +(declare-function org-table-current-dline "org-table" ()) (declare-function org-table-goto-line "org-table" (N)) -(declare-function org-pop-to-buffer-same-window "org-compat" - (&optional buffer-or-name norecord label)) -(declare-function org-at-encrypted-entry-p "org-crypt" ()) -(declare-function org-encrypt-entry "org-crypt" ()) -(declare-function org-decrypt-entry "org-crypt" ()) +(defvar org-end-time-was-given) (defvar org-remember-default-headline) (defvar org-remember-templates) (defvar org-table-hlines) @@ -77,11 +76,44 @@ ;; to indicate that the link properties have already been stored (defvar org-capture-link-is-already-stored nil) +(defvar org-capture-is-refiling nil + "Non-nil when capture process is refiling an entry.") + (defgroup org-capture nil "Options concerning capturing new entries." :tag "Org Capture" :group 'org) +(defun org-capture-upgrade-templates (templates) + "Update the template list to the new format. +TEMPLATES is a template list, as in `org-capture-templates'. The +new format unifies all the date/week tree targets into one that +also allows for an optional outline path to specify a target." + (let ((modified-templates + (mapcar + (lambda (entry) + (pcase entry + ;; Match templates with an obsolete "tree" target type. Replace + ;; it with common `file+olp-datetree'. Add new properties + ;; (i.e., `:time-prompt' and `:tree-type') if needed. + (`(,key ,desc ,type (file+datetree . ,path) ,tpl . ,props) + `(,key ,desc ,type (file+olp+datetree ,@path) ,tpl ,@props)) + (`(,key ,desc ,type (file+datetree+prompt . ,path) ,tpl . ,props) + `(,key ,desc ,type (file+olp+datetree ,@path) ,tpl + :time-prompt t ,@props)) + (`(,key ,desc ,type (file+weektree . ,path) ,tpl . ,props) + `(,key ,desc ,type (file+olp+datetree ,@path) ,tpl + :tree-type week ,@props)) + (`(,key ,desc ,type (file+weektree+prompt . ,path) ,tpl . ,props) + `(,key ,desc ,type (file+olp+datetree ,@path) ,tpl + :tree-type week :time-prompt t ,@props)) + ;; Other templates are left unchanged. + (_ entry))) + templates))) + (unless (equal modified-templates templates) + (message "Deprecated date/weektree capture templates changed to `file+olp+datetree'.")) + modified-templates)) + (defcustom org-capture-templates nil "Templates for the creation of new entries. @@ -104,9 +136,9 @@ description A short string describing the template, will be shown during selection. type The type of entry. Valid types are: - entry an Org-mode node, with a headline. Will be - filed as the child of the target entry or as - a top-level entry. + entry an Org node, with a headline. Will be filed + as the child of the target entry or as a + top-level entry. item a plain list item, will be placed in the first plain list at the target location. @@ -117,37 +149,39 @@ type The type of entry. Valid types are: plain text to be inserted as it is. target Specification of where the captured item should be placed. - In Org-mode files, targets usually define a node. Entries will + In Org files, targets usually define a node. Entries will become children of this node, other types will be added to the table or list in the body of this node. Most target specifications contain a file name. If that file name is the empty string, it defaults to `org-default-notes-file'. - A file can also be given as a variable, function, or Emacs Lisp - form. + A file can also be given as a variable or as a function called + with no argument. When an absolute path is not specified for a + target, it is taken as relative to `org-directory'. Valid values are: (file \"path/to/file\") Text will be placed at the beginning or end of that file - (id \"id of existing org entry\") + (id \"id of existing Org entry\") File as child of this entry, or in the body of the entry (file+headline \"path/to/file\" \"node headline\") Fast configuration if the target heading is unique in the file (file+olp \"path/to/file\" \"Level 1 heading\" \"Level 2\" ...) - For non-unique headings, the full path is safer + For non-unique headings, the full outline path is safer (file+regexp \"path/to/file\" \"regexp to find location\") File to the entry matching regexp - (file+datetree \"path/to/file\") - Will create a heading in a date tree for today's date - - (file+datetree+prompt \"path/to/file\") - Will create a heading in a date tree, prompts for date + (file+olp+datetree \"path/to/file\" \"Level 1 heading\" ...) + Will create a heading in a date tree for today's date. + If no heading is given, the tree will be on top level. + To prompt for date instead of using TODAY, use the + :time-prompt property. To create a week-tree, use the + :tree-type property. (file+function \"path/to/file\" function-finding-location) A function to find the right location in the file @@ -156,8 +190,8 @@ target Specification of where the captured item should be placed. File to the entry that is currently being clocked (function function-finding-location) - Most general way, write your own function to find both - file and location + Most general way: write your own function which both visits + the file and moves point to the right location template The template for creating the capture item. If you leave this empty, an appropriate default template will be used. See below @@ -205,6 +239,11 @@ properties are: When setting both to t, the current clock will run and the previous one will not be resumed. + :time-prompt Prompt for a date/time to be used for date/week trees + and when filling the template. + + :tree-type When `week', make a week tree instead of the month tree. + :unnarrowed Do not narrow the target buffer, simply show the full buffer. Default is to narrow it so that you only see the new stuff. @@ -219,15 +258,20 @@ properties are: is finalized. The template defines the text to be inserted. Often this is an -org-mode entry (so the first line should start with a star) that +Org mode entry (so the first line should start with a star) that will be filed as a child of the target headline. It can also be freely formatted text. Furthermore, the following %-escapes will -be replaced with content and expanded in this order: +be replaced with content and expanded: - %[pathname] Insert the contents of the file given by `pathname'. + %[pathname] Insert the contents of the file given by + `pathname'. These placeholders are expanded at the very + beginning of the process so they can be used to extend the + current template. %(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. + Only placeholders pre-existing within the template, or + introduced with %[pathname] are expanded this way. Since this + happens after expanding non-interactive %-escapes, those can + be used to fill the expression. %<...> The result of format-time-string on the ... format specification. %t Time stamp, date only. %T Time stamp with date and time. @@ -256,8 +300,8 @@ be replaced with content and expanded in this order: A default value and a completion table ca be specified like this: %^{prompt|default|completion2|completion3|...}. %? After completing the template, position cursor here. - %\\n Insert the text entered at the nth %^{prompt}, where `n' is - a number, starting from 1. + %\\1 ... %\\N Insert the text entered at the nth %^{prompt}, where N + is a number, starting from 1. Apart from these general escapes, you can access information specific to the link type that is created. For example, calling `org-capture' in emails @@ -275,13 +319,22 @@ gnus | %:from %:fromname %:fromaddress | %:date %:date-timestamp (as active timestamp) | %:date-timestamp-inactive (as inactive timestamp) gnus | %:group, for messages also all email fields -w3, w3m | %:type %:url +eww, w3, w3m | %:type %:url info | %:type %:file %:node -calendar | %:type %:date" +calendar | %:type %:date + +When you need to insert a literal percent sign in the template, +you can escape ambiguous cases with a backward slash, e.g., \\%i." :group 'org-capture :version "24.1" + :set (lambda (s v) (set s (org-capture-upgrade-templates v))) :type - '(repeat + (let ((file-variants '(choice :tag "Filename " + (file :tag "Literal") + (function :tag "Function") + (variable :tag "Variable") + (sexp :tag "Form")))) + `(repeat (choice :value ("" "" entry (file "~/org/notes.org") "") (list :tag "Multikey description" (string :tag "Keys ") @@ -298,39 +351,38 @@ calendar | %:type %:date" (choice :tag "Target location" (list :tag "File" (const :format "" file) - (file :tag " File")) + ,file-variants) (list :tag "ID" (const :format "" id) (string :tag " ID")) (list :tag "File & Headline" (const :format "" file+headline) - (file :tag " File ") + ,file-variants (string :tag " Headline")) (list :tag "File & Outline path" (const :format "" file+olp) - (file :tag " File ") + ,file-variants (repeat :tag "Outline path" :inline t (string :tag "Headline"))) (list :tag "File & Regexp" (const :format "" file+regexp) - (file :tag " File ") + ,file-variants (regexp :tag " Regexp")) - (list :tag "File & Date tree" - (const :format "" file+datetree) - (file :tag " File")) - (list :tag "File & Date tree, prompt for date" - (const :format "" file+datetree+prompt) - (file :tag " File")) + (list :tag "File [ & Outline path ] & Date tree" + (const :format "" file+olp+datetree) + ,file-variants + (option (repeat :tag "Outline path" :inline t + (string :tag "Headline")))) (list :tag "File & function" (const :format "" file+function) - (file :tag " File ") + ,file-variants (sexp :tag " Function")) (list :tag "Current clocking task" (const :format "" clock)) (list :tag "Function" (const :format "" function) (sexp :tag " Function"))) - (choice :tag "Template" + (choice :tag "Template " (string) (list :tag "File" (const :format "" file) @@ -349,9 +401,11 @@ calendar | %:type %:date" ((const :format "%v " :clock-in) (const t)) ((const :format "%v " :clock-keep) (const t)) ((const :format "%v " :clock-resume) (const t)) + ((const :format "%v " :time-prompt) (const t)) + ((const :format "%v " :tree-type) (const week)) ((const :format "%v " :unnarrowed) (const t)) - ((const :format "%v " :table-line-pos) (const t)) - ((const :format "%v " :kill-buffer) (const t)))))))) + ((const :format "%v " :table-line-pos) (string)) + ((const :format "%v " :kill-buffer) (const t))))))))) (defcustom org-capture-before-finalize-hook nil "Hook that is run right before a capture process is finalized. @@ -422,7 +476,7 @@ to avoid conflicts with other active capture processes." (defvar org-capture-mode-map (make-sparse-keymap) "Keymap for `org-capture-mode', a minor mode. -Use this map to set additional keybindings for when Org-mode is used +Use this map to set additional keybindings for when Org mode is used for a capture buffer.") (defvar org-capture-mode-hook nil @@ -433,11 +487,12 @@ for a capture buffer.") Turning on this mode runs the normal hook `org-capture-mode-hook'." nil " Rem" org-capture-mode-map - (org-set-local - 'header-line-format + (setq-local + header-line-format (substitute-command-keys - "\\Capture buffer. Finish \\[org-capture-finalize], \ -refile \\[org-capture-refile], abort \\[org-capture-kill]."))) + "\\Capture buffer. Finish \ +`\\[org-capture-finalize]', refile `\\[org-capture-refile]', \ +abort `\\[org-capture-kill]'."))) (define-key org-capture-mode-map "\C-c\C-c" 'org-capture-finalize) (define-key org-capture-mode-map "\C-c\C-k" 'org-capture-kill) (define-key org-capture-mode-map "\C-c\C-w" 'org-capture-refile) @@ -462,7 +517,7 @@ For example, if you have a capture template \"c\" and you want this template to be accessible only from `message-mode' buffers, use this: - '((\"c\" ((in-mode . \"message-mode\")))) + \\='((\"c\" ((in-mode . \"message-mode\")))) Here are the available contexts definitions: @@ -480,7 +535,7 @@ accessible if there is at least one valid check. You can also bind a key to another agenda custom command depending on contextual rules. - '((\"c\" \"d\" ((in-mode . \"message-mode\")))) + \\='((\"c\" \"d\" ((in-mode . \"message-mode\")))) Here it means: in `message-mode buffers', use \"c\" as the key for the capture template otherwise associated with \"d\". @@ -506,7 +561,8 @@ 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 capture 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) @@ -515,20 +571,26 @@ When nil, you can still capture using the date at point with \\[org-agenda-captu (defun org-capture (&optional goto keys) "Capture something. \\ -This will let you select a template from `org-capture-templates', and then -file the newly captured information. The text is immediately inserted -at the target location, and an indirect buffer is shown where you can -edit it. Pressing \\[org-capture-finalize] brings you back to the previous state -of Emacs, so that you can continue your work. - -When called interactively with a \\[universal-argument] prefix argument GOTO, don't capture -anything, just go to the file/headline where the selected template -stores its notes. With a double prefix argument \ -\\[universal-argument] \\[universal-argument], go to the last note -stored. +This will let you select a template from `org-capture-templates', and +then file the newly captured information. The text is immediately +inserted at the target location, and an indirect buffer is shown where +you can edit it. Pressing `\\[org-capture-finalize]' brings you back to the \ +previous +state of Emacs, so that you can continue your work. + +When called interactively with a `\\[universal-argument]' prefix argument \ +GOTO, don't +capture anything, just go to the file/headline where the selected +template stores its notes. + +With a `\\[universal-argument] \\[universal-argument]' prefix argument, go to \ +the last note stored. When called with a `C-0' (zero) prefix, insert a template at point. +When called with a `C-1' (one) prefix, force prompting for a date when +a datetree entry is made. + ELisp programs can set KEYS to a string associated with a template in `org-capture-templates'. In this case, interactive selection will be bypassed. @@ -546,7 +608,6 @@ of the day at point (if any) or the current HH:MM time." ((equal goto '(4)) (org-capture-goto-target)) ((equal goto '(16)) (org-capture-goto-last-stored)) (t - ;; FIXME: Are these needed? (let* ((orig-buf (current-buffer)) (annotation (if (and (boundp 'org-capture-link-is-already-stored) org-capture-link-is-already-stored) @@ -566,7 +627,7 @@ of the day at point (if any) or the current HH:MM time." ((equal entry "C") (customize-variable 'org-capture-templates)) ((equal entry "q") - (error "Abort")) + (user-error "Abort")) (t (org-capture-set-plist entry) (org-capture-get-template) @@ -598,10 +659,10 @@ of the day at point (if any) or the current HH:MM time." (org-capture-insert-template-here) (condition-case error (org-capture-place-template - (equal (car (org-capture-get :target)) 'function)) + (eq (car (org-capture-get :target)) 'function)) ((error quit) (if (and (buffer-base-buffer (current-buffer)) - (string-match "\\`CAPTURE-" (buffer-name))) + (string-prefix-p "CAPTURE-" (buffer-name))) (kill-buffer (current-buffer))) (set-window-configuration (org-capture-get :return-to-wconf)) (error "Capture template `%s': %s" @@ -615,7 +676,7 @@ of the day at point (if any) or the current HH:MM time." (org-capture-put :interrupted-clock (copy-marker org-clock-marker))) (org-clock-in) - (org-set-local 'org-capture-clock-was-started t)) + (setq-local org-capture-clock-was-started t)) (error "Could not start the clock in this capture buffer"))) (if (org-capture-get :immediate-finish) @@ -648,7 +709,7 @@ captured item after finalizing." (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")) + (error "This does not seem to be a capture buffer for Org mode")) (run-hooks 'org-capture-prepare-finalize-hook) @@ -684,7 +745,7 @@ captured item after finalizing." (m2 (org-capture-get :end-marker 'local))) (if (and m1 m2 (= m1 beg) (= m2 end)) (progn - (setq m2 (if (cdr (assoc 'heading org-blank-before-new-entry)) + (setq m2 (if (cdr (assq 'heading org-blank-before-new-entry)) m2 (1+ m2)) m2 (if (< (point-max) m2) (point-max) m2)) (setq abort-note 'clean) @@ -717,8 +778,7 @@ captured item after finalizing." ;; Store this place as the last one where we stored something ;; Do the marking in the base buffer, so that it makes sense after ;; the indirect buffer has been killed. - (when org-capture-bookmark - (org-capture-bookmark-last-stored-position)) + (org-capture-store-last-position) ;; Run the hook (run-hooks 'org-capture-before-finalize-hook)) @@ -772,11 +832,12 @@ captured item after finalizing." ;; Special cases (cond (abort-note - (cond - ((equal abort-note 'clean) - (message "Capture process aborted and target buffer cleaned up")) - ((equal abort-note 'dirty) - (error "Capture process aborted, but target buffer could not be cleaned up correctly")))) + (cl-case abort-note + (clean + (message "Capture process aborted and target buffer cleaned up")) + (dirty + (error "Capture process aborted, but target buffer could not be \ +cleaned up correctly")))) (stay-with-capture (org-capture-goto-last-stored))) ;; Return if we did store something @@ -788,19 +849,28 @@ Refiling is done from the base buffer, because the indirect buffer is then already gone. Any prefix argument will be passed to the refile command." (interactive) (unless (eq (org-capture-get :type 'local) 'entry) - (error - "Refiling from a capture buffer makes only sense for `entry'-type templates")) - (let ((pos (point)) - (base (buffer-base-buffer (current-buffer))) - (org-refile-for-capture t)) - (save-window-excursion - (with-current-buffer (or base (current-buffer)) - (save-excursion - (save-restriction - (widen) - (goto-char pos) - (call-interactively 'org-refile))))) - (org-capture-finalize))) + (user-error "Refiling from a capture buffer makes only sense \ +for `entry'-type templates")) + (let* ((base (or (buffer-base-buffer) (current-buffer))) + (pos (make-marker)) + (org-capture-is-refiling t) + (kill-buffer (org-capture-get :kill-buffer 'local))) + ;; Since `org-capture-finalize' may alter buffer contents (e.g., + ;; empty lines) around entry, use a marker to refer to the + ;; headline to be refiled. Place the marker in the base buffer, + ;; as the current indirect one is going to be killed. + (set-marker pos (save-excursion (org-back-to-heading t) (point)) base) + (org-capture-put :kill-buffer nil) + (unwind-protect + (progn + (org-capture-finalize) + (save-window-excursion + (with-current-buffer base + (org-with-wide-buffer + (goto-char pos) + (call-interactively 'org-refile)))) + (when kill-buffer (kill-buffer base))) + (set-marker pos nil)))) (defun org-capture-kill () "Abort the current capture process." @@ -835,166 +905,174 @@ already gone. Any prefix argument will be passed to the refile command." (defun org-capture-set-target-location (&optional target) "Find TARGET buffer and position. Store them in the capture property list." - (let ((target-entry-p t) decrypted-hl-pos) - (setq target (or target (org-capture-get :target))) + (let ((target-entry-p t)) (save-excursion - (cond - ((eq (car target) 'file) - (set-buffer (org-capture-target-buffer (nth 1 target))) - (org-capture-put-target-region-and-position) - (widen) - (setq target-entry-p nil)) - - ((eq (car target) 'id) - (let ((loc (org-id-find (nth 1 target)))) - (if (not loc) - (error "Cannot find target ID \"%s\"" (nth 1 target)) - (set-buffer (org-capture-target-buffer (car loc))) + (pcase (or target (org-capture-get :target)) + (`(file ,path) + (set-buffer (org-capture-target-buffer path)) + (org-capture-put-target-region-and-position) + (widen) + (setq target-entry-p nil)) + (`(id ,id) + (pcase (org-id-find id) + (`(,path . ,position) + (set-buffer (org-capture-target-buffer path)) (widen) (org-capture-put-target-region-and-position) - (goto-char (cdr loc))))) - - ((eq (car target) 'file+headline) - (set-buffer (org-capture-target-buffer (nth 1 target))) - (org-capture-put-target-region-and-position) - (widen) - (let ((hd (nth 2 target))) - (goto-char (point-min)) - (unless (derived-mode-p 'org-mode) - (error - "Target buffer \"%s\" for file+headline should be in Org mode" - (current-buffer))) - (if (re-search-forward - (format org-complex-heading-regexp-format (regexp-quote hd)) - nil t) - (goto-char (point-at-bol)) - (goto-char (point-max)) - (or (bolp) (insert "\n")) - (insert "* " hd "\n") - (beginning-of-line 0)))) - - ((eq (car target) 'file+olp) - (let ((m (org-find-olp - (cons (org-capture-expand-file (nth 1 target)) - (cddr target))))) - (set-buffer (marker-buffer m)) - (org-capture-put-target-region-and-position) - (widen) - (goto-char m))) - - ((eq (car target) 'file+regexp) - (set-buffer (org-capture-target-buffer (nth 1 target))) - (org-capture-put-target-region-and-position) - (widen) - (goto-char (point-min)) - (if (re-search-forward (nth 2 target) nil t) - (progn - (goto-char (if (org-capture-get :prepend) - (match-beginning 0) (match-end 0))) - (org-capture-put :exact-position (point)) - (setq target-entry-p (and (derived-mode-p 'org-mode) (org-at-heading-p)))) - (error "No match for target regexp in file %s" (nth 1 target)))) - - ((memq (car target) '(file+datetree file+datetree+prompt)) - (require 'org-datetree) - (set-buffer (org-capture-target-buffer (nth 1 target))) - (org-capture-put-target-region-and-position) - (widen) - ;; Make a date tree entry, with the current date (or yesterday, - ;; if we are extending dates for a couple of hours) - (org-datetree-find-date-create - (calendar-gregorian-from-absolute - (cond - (org-overriding-default-time - ;; use the overriding default time - (time-to-days org-overriding-default-time)) - - ((eq (car target) 'file+datetree+prompt) - ;; prompt for date - (let ((prompt-time (org-read-date - nil t nil "Date for tree entry:" - (current-time)))) - (org-capture-put - :default-time - (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))))) - ((string-match "\\([^ ]+\\)--?[^ ]+[ ]+\\(.*\\)" org-read-date-final-answer) - ;; Replace any time range by its start - (apply 'encode-time - (org-read-date-analyze - (replace-match "\\1 \\2" nil nil org-read-date-final-answer) - prompt-time (decode-time prompt-time)))) - (t prompt-time))) - (time-to-days prompt-time))) - (t - ;; current date, possibly corrected for late night workers - (org-today)))))) - - ((eq (car target) 'file+function) - (set-buffer (org-capture-target-buffer (nth 1 target))) - (org-capture-put-target-region-and-position) - (widen) - (funcall (nth 2 target)) - (org-capture-put :exact-position (point)) - (setq target-entry-p (and (derived-mode-p 'org-mode) (org-at-heading-p)))) - - ((eq (car target) 'function) - (funcall (nth 1 target)) - (org-capture-put :exact-position (point)) - (setq target-entry-p (and (derived-mode-p 'org-mode) (org-at-heading-p)))) - - ((eq (car target) 'clock) - (if (and (markerp org-clock-hd-marker) - (marker-buffer org-clock-hd-marker)) - (progn (set-buffer (marker-buffer org-clock-hd-marker)) - (org-capture-put-target-region-and-position) - (widen) - (goto-char org-clock-hd-marker)) - (error "No running clock that could be used as capture target"))) - - (t (error "Invalid capture target specification"))) - - (when (and (featurep 'org-crypt) (org-at-encrypted-entry-p)) - (org-decrypt-entry) - (setq decrypted-hl-pos - (save-excursion (and (org-back-to-heading t) (point))))) - - (org-capture-put :buffer (current-buffer) :pos (point) + (goto-char position)) + (_ (error "Cannot find target ID \"%s\"" id)))) + (`(file+headline ,path ,headline) + (set-buffer (org-capture-target-buffer path)) + (unless (derived-mode-p 'org-mode) + (error "Target buffer \"%s\" for file+headline not in Org mode" + (current-buffer))) + (org-capture-put-target-region-and-position) + (widen) + (goto-char (point-min)) + (if (re-search-forward (format org-complex-heading-regexp-format + (regexp-quote headline)) + nil t) + (goto-char (line-beginning-position)) + (goto-char (point-max)) + (or (bolp) (insert "\n")) + (insert "* " headline "\n") + (beginning-of-line 0))) + (`(file+olp ,path . ,outline-path) + (let ((m (org-find-olp (cons (org-capture-expand-file path) + outline-path)))) + (set-buffer (marker-buffer m)) + (org-capture-put-target-region-and-position) + (widen) + (goto-char m) + (set-marker m nil))) + (`(file+regexp ,path ,regexp) + (set-buffer (org-capture-target-buffer path)) + (org-capture-put-target-region-and-position) + (widen) + (goto-char (point-min)) + (if (not (re-search-forward regexp nil t)) + (error "No match for target regexp in file %s" path) + (goto-char (if (org-capture-get :prepend) + (match-beginning 0) + (match-end 0))) + (org-capture-put :exact-position (point)) + (setq target-entry-p + (and (derived-mode-p 'org-mode) (org-at-heading-p))))) + (`(file+olp+datetree ,path . ,outline-path) + (let ((m (if outline-path + (org-find-olp (cons (org-capture-expand-file path) + outline-path)) + (set-buffer (org-capture-target-buffer path)) + (point-marker)))) + (set-buffer (marker-buffer m)) + (org-capture-put-target-region-and-position) + (widen) + (goto-char m) + (set-marker m nil) + (require 'org-datetree) + (org-capture-put-target-region-and-position) + (widen) + ;; Make a date/week tree entry, with the current date (or + ;; yesterday, if we are extending dates for a couple of hours) + (funcall + (if (eq (org-capture-get :tree-type) 'week) + #'org-datetree-find-iso-week-create + #'org-datetree-find-date-create) + (calendar-gregorian-from-absolute + (cond + (org-overriding-default-time + ;; Use the overriding default time. + (time-to-days org-overriding-default-time)) + ((or (org-capture-get :time-prompt) + (equal current-prefix-arg 1)) + ;; Prompt for date. + (let ((prompt-time (org-read-date + nil t nil "Date for tree entry:" + (current-time)))) + (org-capture-put + :default-time + (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) + (cl-cdddr (decode-time prompt-time))))) + ((string-match "\\([^ ]+\\)--?[^ ]+[ ]+\\(.*\\)" + org-read-date-final-answer) + ;; Replace any time range by its start. + (apply #'encode-time + (org-read-date-analyze + (replace-match "\\1 \\2" nil nil + org-read-date-final-answer) + prompt-time (decode-time prompt-time)))) + (t prompt-time))) + (time-to-days prompt-time))) + (t + ;; Current date, possibly corrected for late night + ;; workers. + (org-today)))) + ;; the following is the keep-restriction argument for + ;; org-datetree-find-date-create + (if outline-path 'subtree-at-point)))) + (`(file+function ,path ,function) + (set-buffer (org-capture-target-buffer path)) + (org-capture-put-target-region-and-position) + (widen) + (funcall function) + (org-capture-put :exact-position (point)) + (setq target-entry-p + (and (derived-mode-p 'org-mode) (org-at-heading-p)))) + (`(function ,fun) + (funcall fun) + (org-capture-put :exact-position (point)) + (setq target-entry-p + (and (derived-mode-p 'org-mode) (org-at-heading-p)))) + (`(clock) + (if (and (markerp org-clock-hd-marker) + (marker-buffer org-clock-hd-marker)) + (progn (set-buffer (marker-buffer org-clock-hd-marker)) + (org-capture-put-target-region-and-position) + (widen) + (goto-char org-clock-hd-marker)) + (error "No running clock that could be used as capture target"))) + (target (error "Invalid capture target specification: %S" target))) + + (org-capture-put :buffer (current-buffer) + :pos (point) :target-entry-p target-entry-p - :decrypted decrypted-hl-pos)))) + :decrypted + (and (featurep 'org-crypt) + (org-at-encrypted-entry-p) + (save-excursion + (org-decrypt-entry) + (and (org-back-to-heading t) (point)))))))) (defun org-capture-expand-file (file) - "Expand functions and symbols for FILE. + "Expand functions, symbols and file names for FILE. When FILE is a function, call it. When it is a form, evaluate -it. When it is a variable, retrieve the value. When it is -a string, return it. However, if it is the empty string, return -`org-default-notes-file' instead." - (cond - ((equal file "") org-default-notes-file) - ((org-string-nw-p file) file) - ((functionp file) (funcall file)) - ((and (symbolp file) (boundp file)) (symbol-value file)) - ((consp file) (eval file)) - (t file))) +it. When it is a variable, return its value. When it is +a string, treat it as a file name, possibly expanding it +according to `org-directory', and return it. If it is the empty +string, however, return `org-default-notes-file'. In any other +case, raise an error." + (let ((location (cond ((equal file "") org-default-notes-file) + ((stringp file) (expand-file-name file org-directory)) + ((functionp file) (funcall file)) + ((and (symbolp file) (bound-and-true-p file))) + (t nil)))) + (or (org-string-nw-p location) + (error "Invalid file location: %S" location)))) (defun org-capture-target-buffer (file) - "Get a buffer for FILE." - (setq file (org-capture-expand-file file)) - (setq file (or (org-string-nw-p file) - org-default-notes-file - (error "No notes file specified, and no default available"))) - (or (org-find-base-buffer-visiting file) - (progn (org-capture-put :new-buffer t) - (find-file-noselect (expand-file-name file org-directory))))) - -(defun org-capture-steal-local-variables (buffer) - "Install Org-mode local variables of BUFFER." - (mapc (lambda (v) - (ignore-errors (org-set-local (car v) (cdr v)))) - (buffer-local-variables buffer))) + "Get a buffer for FILE. +FILE is a generalized file location, as handled by +`org-capture-expand-file'." + (let ((file (org-capture-expand-file file))) + (or (org-find-base-buffer-visiting file) + (progn (org-capture-put :new-buffer t) + (find-file-noselect file))))) (defun org-capture-place-template (&optional inhibit-wconf-store) "Insert the template at the target location, and display the buffer. @@ -1006,34 +1084,31 @@ may have been stored before." (org-switch-to-buffer-other-window (org-capture-get-indirect-buffer (org-capture-get :buffer) "CAPTURE")) (widen) - (show-all) + (outline-show-all) (goto-char (org-capture-get :pos)) - (org-set-local 'org-capture-target-marker - (point-marker)) - (org-set-local 'outline-level 'org-outline-level) - (let* ((template (org-capture-get :template)) - (type (org-capture-get :type))) - (case type - ((nil entry) (org-capture-place-entry)) - (table-line (org-capture-place-table-line)) - (plain (org-capture-place-plain-text)) - (item (org-capture-place-item)) - (checkitem (org-capture-place-item)))) + (setq-local outline-level 'org-outline-level) + (pcase (org-capture-get :type) + ((or `nil `entry) (org-capture-place-entry)) + (`table-line (org-capture-place-table-line)) + (`plain (org-capture-place-plain-text)) + (`item (org-capture-place-item)) + (`checkitem (org-capture-place-item))) (org-capture-mode 1) - (org-set-local 'org-capture-current-plist org-capture-plist)) + (setq-local org-capture-current-plist org-capture-plist)) (defun org-capture-place-entry () "Place the template as a new Org entry." (let* ((txt (org-capture-get :template)) (reversed (org-capture-get :prepend)) (target-entry-p (org-capture-get :target-entry-p)) - level beg end file) + level beg end) (and (org-capture-get :exact-position) (goto-char (org-capture-get :exact-position))) (cond ((not target-entry-p) - ;; Insert as top-level entry, either at beginning or at end of file + ;; Insert as top-level entry, either at beginning or at end of + ;; file. (setq level 1) (if reversed (progn (goto-char (point-min)) @@ -1132,7 +1207,7 @@ may have been stored before." (let* ((txt (org-capture-get :template)) (target-entry-p (org-capture-get :target-entry-p)) (table-line-pos (org-capture-get :table-line-pos)) - ind beg end) + beg end) (cond ((org-capture-get :exact-position) (goto-char (org-capture-get :exact-position))) @@ -1163,6 +1238,7 @@ may have been stored before." (cond ((and table-line-pos (string-match "\\(I+\\)\\([-+][0-9]\\)" table-line-pos)) + (goto-char (point-min)) ;; we have a complex line specification (let ((ll (ignore-errors (save-match-data (org-table-analyze)) @@ -1266,8 +1342,8 @@ Of course, if exact position has been required, just put it there." (org-table-current-dline)))) (t (error "This should not happen")))) -(defun org-capture-bookmark-last-stored-position () - "Bookmark the last-captured position." +(defun org-capture-store-last-position () + "Store the last-captured position." (let* ((where (org-capture-get :position-for-last-stored 'local)) (pos (cond ((markerp where) @@ -1280,16 +1356,11 @@ Of course, if exact position has been required, just put it there." (point-at-bol)) (point)))))) (with-current-buffer (buffer-base-buffer (current-buffer)) - (save-excursion - (save-restriction - (widen) - (goto-char pos) - (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))))))) + (org-with-point-at pos + (when org-capture-bookmark + (let ((bookmark (plist-get org-bookmark-names-plist :last-capture))) + (when bookmark (with-demoted-errors (bookmark-set bookmark))))) + (move-marker org-capture-last-stored-marker (point)))))) (defun org-capture-narrow (beg end) "Narrow, unless configuration says not to narrow." @@ -1375,13 +1446,11 @@ Point will remain at the first line after the inserted text." "Go to the target location of a capture template. The user is queried for the template." (interactive) - (let* (org-select-template-temp-major-mode - (entry (org-capture-select-template template-key))) - (unless entry - (error "No capture template selected")) + (let ((entry (org-capture-select-template template-key))) + (unless entry (error "No capture template selected")) (org-capture-set-plist entry) (org-capture-set-target-location) - (org-pop-to-buffer-same-window (org-capture-get :buffer)) + (pop-to-buffer-same-window (org-capture-get :buffer)) (goto-char (org-capture-get :pos)))) (defun org-capture-get-indirect-buffer (&optional buffer prefix) @@ -1391,7 +1460,7 @@ Use PREFIX as a prefix for the name of the indirect buffer." (let ((n 1) (base (buffer-name buffer)) bname) (setq bname (concat prefix "-" base)) (while (buffer-live-p (get-buffer bname)) - (setq bname (concat prefix "-" (number-to-string (incf n)) "-" base))) + (setq bname (concat prefix "-" (number-to-string (cl-incf n)) "-" base))) (condition-case nil (make-indirect-buffer buffer bname 'clone) (error @@ -1406,6 +1475,7 @@ Use PREFIX as a prefix for the name of the indirect buffer." (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. @@ -1413,7 +1483,7 @@ There should be two types of entries. 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 +2. Select-able 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. @@ -1424,84 +1494,72 @@ 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)) +PROMPT will be used when prompting for a key. SPECIAL is an +alist with (\"key\" \"description\") entries. When one of these +is selected, only the bare key is returned." + (save-window-excursion + (let ((inhibit-quit t) + (buffer (org-switch-to-buffer-other-window "*Org Select*")) + (prompt (or prompt "Select: ")) + current) + (unwind-protect + (catch 'exit + (while t + (erase-buffer) + (insert title "\n\n") + (let ((des-keys nil) + (allowed-keys '("\C-g")) + (cursor-type nil)) + ;; Populate allowed keys and descriptions keys + ;; available with CURRENT selector. + (let ((re (format "\\`%s\\(.\\)\\'" + (if current (regexp-quote current) ""))) + (prefix (if current (concat current " ") ""))) + (dolist (entry table) + (pcase entry + ;; Description. + (`(,(and key (pred (string-match re))) ,desc) + (let ((k (match-string 1 key))) + (push k des-keys) + (push k allowed-keys) + (insert prefix "[" k "]" "..." " " desc "..." "\n"))) + ;; Usable entry. + (`(,(and key (pred (string-match re))) ,desc . ,_) + (let ((k (match-string 1 key))) + (insert prefix "[" k "]" " " desc "\n") + (push k allowed-keys))) + (_ nil)))) + ;; Insert special entries, if any. + (when specials + (insert "----------------------------------------------------\ +---------------------------\n") + (pcase-dolist (`(,key ,description) specials) + (insert (format "[%s] %s\n" key description)) + (push key allowed-keys))) + ;; Display UI and let user select an entry or + ;; a sub-level prefix. + (goto-char (point-min)) + (unless (pos-visible-in-window-p (point-max)) + (org-fit-window-to-buffer)) + (message prompt) + (let ((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)))) + (setq current (concat current pressed)) + (cond + ((equal pressed "\C-g") (user-error "Abort")) + ;; Selection is a prefix: open a new menu. + ((member pressed des-keys)) + ;; Selection matches an association: return it. + ((let ((entry (assoc current table))) + (and entry (throw 'exit entry)))) + ;; Selection matches a special entry: return the + ;; selection prefix. + ((assoc current specials) (throw 'exit current)) + (t (error "No entry available"))))))) + (when buffer (kill-buffer buffer)))))) ;;; The template code (defun org-capture-select-template (&optional keys) @@ -1509,7 +1567,8 @@ only the bare key is returned." Lisp programs can force the template by setting KEYS to a string." (let ((org-capture-templates (or (org-contextualize-keys - org-capture-templates org-capture-templates-contexts) + (org-capture-upgrade-templates org-capture-templates) + org-capture-templates-contexts) '(("t" "Task" entry (file+headline "" "Tasks") "* TODO %?\n %u\n %a"))))) (if keys @@ -1524,43 +1583,35 @@ Lisp programs can force the template by setting KEYS to a string." (defun org-capture-fill-template (&optional template initial annotation) "Fill a template and return the filled template as a string. The template may still contain \"%?\" for cursor positioning." - (setq template (or template (org-capture-get :template))) - (when (stringp initial) - (setq initial (org-no-properties initial))) - (let* ((buffer (org-capture-get :buffer)) + (let* ((template (or template (org-capture-get :template))) + (buffer (org-capture-get :buffer)) (file (buffer-file-name (or (buffer-base-buffer buffer) buffer))) - (ct (org-capture-get :default-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)) - (plist-p (if org-store-link-plist t nil)) - (v-c (and (> (length kill-ring) 0) (current-kill 0))) + (time (let* ((c (or (org-capture-get :default-time) (current-time))) + (d (decode-time c))) + (if (< (nth 2 d) org-extend-today-until) + (encode-time 0 59 23 (1- (nth 3 d)) (nth 4 d) (nth 5 d)) + c))) + (v-t (format-time-string (org-time-stamp-format nil) time)) + (v-T (format-time-string (org-time-stamp-format t) time)) + (v-u (format-time-string (org-time-stamp-format nil t) time)) + (v-U (format-time-string (org-time-stamp-format t t) time)) + (v-c (and kill-ring (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) ct1)) - (v-T (format-time-string (cdr org-time-stamp-formats) ct1)) - (v-u (concat "[" (substring v-t 1 -1) "]")) - (v-U (concat "[" (substring v-T 1 -1) "]")) - ;; `initial' and `annotation' might habe been passed. - ;; But if the property list has them, we prefer those values + ;; `initial' and `annotation' might have been passed. But if + ;; the property list has them, we prefer those values. (v-i (or (plist-get org-store-link-plist :initial) - initial + (and (stringp initial) (org-no-properties initial)) (org-capture-get :initial) "")) - (v-a (or (plist-get org-store-link-plist :annotation) - annotation - (org-capture-get :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 + (let ((a (or (plist-get org-store-link-plist :annotation) + annotation + (org-capture-get :annotation) + ""))) + ;; Is the link empty? Then we do not want it... + (if (equal a "[[]]") "" a))) (l-re "\\[\\[\\(.*?\\)\\]\\(\\[.*?\\]\\)?\\]") (v-A (if (and v-a (string-match l-re v-a)) (replace-match "[[\\1][%^{Link description}]]" nil nil v-a) @@ -1569,203 +1620,263 @@ The template may still contain \"%?\" for cursor positioning." (replace-match "\\1" 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 (and (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-f (or (org-capture-get :original-file-nondirectory) "")) (v-F (or (org-capture-get :original-file) "")) - 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 strings) - - (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)) - (setq initial v-i) - - (unless template (setq template "") (message "No template") (ding) - (sit-for 1)) + (clipboards (delq nil + (list v-i + (org-get-x-clipboard 'PRIMARY) + (org-get-x-clipboard 'CLIPBOARD) + (org-get-x-clipboard 'SECONDARY) + v-c)))) + + (setq org-store-link-plist (plist-put org-store-link-plist :annotation v-a)) + (setq org-store-link-plist (plist-put org-store-link-plist :initial v-i)) + + (unless template + (setq template "") + (message "no template") (ding) + (sit-for 1)) (save-window-excursion (org-switch-to-buffer-other-window (get-buffer-create "*Capture*")) (erase-buffer) + (setq buffer-file-name nil) + (setq mark-active nil) (insert template) (goto-char (point-min)) - (org-capture-steal-local-variables buffer) - (setq buffer-file-name nil mark-active nil) - ;; %[] Insert contents of a file. - (goto-char (point-min)) - (while (re-search-forward "%\\[\\(.+\\)\\]" nil t) - (unless (org-capture-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))))))) - - ;; The current time - (goto-char (point-min)) - (while (re-search-forward "%<\\([^>\n]+\\)>" nil t) - (replace-match (format-time-string (match-string 1)) t t)) + ;; %[] insert contents of a file. + (save-excursion + (while (re-search-forward "%\\[\\(.+\\)\\]" nil t) + (let ((filename (expand-file-name (match-string 1))) + (beg (copy-marker (match-beginning 0))) + (end (copy-marker (match-end 0)))) + (unless (org-capture-escaped-%) + (delete-region beg end) + (set-marker beg nil) + (set-marker end nil) + (condition-case error + (insert-file-contents filename) + (error + (insert (format "%%![couldn not insert %s: %s]" + filename + error)))))))) - ;; Simple %-escapes - (goto-char (point-min)) - (while (re-search-forward "%\\([tTuUaliAcxkKInfF]\\)" nil t) - (unless (org-capture-escaped-%) - (when (and initial (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 initial "\n") - (concat "\n" lead)))))) - (replace-match (or (eval (intern (concat "v-" (match-string 1)))) "") - t t))) - - ;; From the property list - (when plist-p - (goto-char (point-min)) - (while (re-search-forward "%\\(:[-a-zA-Z]+\\)" nil t) - (unless (org-capture-escaped-%) - (and (setq x (or (plist-get org-store-link-plist - (intern (match-string 1))) "")) - (replace-match x t t))))) - - ;; %() embedded elisp - (goto-char (point-min)) + ;; Mark %() embedded elisp for later evaluation. + (org-capture-expand-embedded-elisp 'mark) + + ;; Expand non-interactive templates. + (let ((regexp "%\\(:[-a-za-z]+\\|<\\([^>\n]+\\)>\\|[aAcfFikKlntTuUx]\\)")) + (save-excursion + (while (re-search-forward regexp nil t) + ;; `org-capture-escaped-%' may modify buffer and cripple + ;; match-data. Use markers instead. Ditto for other + ;; templates. + (let ((pos (copy-marker (match-beginning 0))) + (end (copy-marker (match-end 0))) + (value (match-string 1)) + (time-string (match-string 2))) + (unless (org-capture-escaped-%) + (delete-region pos end) + (set-marker pos nil) + (set-marker end nil) + (let* ((inside-sexp? (org-capture-inside-embedded-elisp-p)) + (replacement + (pcase (string-to-char value) + (?< (format-time-string time-string time)) + (?: + (or (plist-get org-store-link-plist (intern value)) + "")) + (?i + (if inside-sexp? v-i + ;; Outside embedded Lisp, repeat leading + ;; characters before initial place holder + ;; every line. + (let ((lead (buffer-substring-no-properties + (line-beginning-position) (point)))) + (replace-regexp-in-string "\n\\(.\\)" + (concat lead "\\1") + v-i nil nil 1)))) + (?a v-a) + (?A v-A) + (?c v-c) + (?f v-f) + (?F v-F) + (?k v-k) + (?K v-K) + (?l v-l) + (?n v-n) + (?t v-t) + (?T v-T) + (?u v-u) + (?U v-U) + (?x v-x)))) + (insert + (if inside-sexp? + ;; Escape sensitive characters. + (replace-regexp-in-string "[\\\"]" "\\\\\\&" replacement) + replacement)))))))) + + ;; Expand %() embedded Elisp. Limit to Sexp originally marked. (org-capture-expand-embedded-elisp) - ;; Turn on org-mode in temp buffer, set local variables - ;; This is to support completion in interactive prompts + ;; Expand interactive templates. This is the last step so that + ;; template is mostly expanded when prompting happens. Turn on + ;; Org mode and set local variables. This is to support + ;; completion in interactive prompts. (let ((org-inhibit-startup t)) (org-mode)) - ;; Interactive template entries - (goto-char (point-min)) - (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))) - (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-capture-template-prompt-history::" - (or prompt ""))) - completions (mapcar 'list completions))) - (unless (boundp histvar) (set histvar nil)) - (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 ":")) - (and (org-at-heading-p) - (let ((org-ignore-region t)) - (org-set-tags nil 'align)))))) - ((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") - (org-set-property (org-no-properties prompt) nil)) - (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) char) t nil - prompt)) - (if (equal (upcase char) char) (setq org-time-was-given t)) - (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) - (push (org-completing-read-no-i - (concat (if prompt prompt "Enter string") - (if default (concat " [" default "]")) - ": ") - completions nil nil nil histvar default) - strings) - (insert (car strings))))))) - ;; Replace %n escapes with nth %^{...} string - (setq strings (nreverse strings)) - (goto-char (point-min)) - (while (re-search-forward "%\\\\\\([1-9][0-9]*\\)" nil t) - (unless (org-capture-escaped-%) - (replace-match - (nth (1- (string-to-number (match-string 1))) strings) - nil t))) + (org-clone-local-variables buffer "\\`org-") + (let (strings) ; Stores interactive answers. + (save-excursion + (let ((regexp "%\\^\\(?:{\\([^}]*\\)}\\)?\\([CgGLptTuU]\\)?")) + (while (re-search-forward regexp nil t) + (let* ((items (and (match-end 1) + (save-match-data + (split-string (match-string-no-properties 1) + "|")))) + (key (match-string 2)) + (beg (copy-marker (match-beginning 0))) + (end (copy-marker (match-end 0))) + (prompt (nth 0 items)) + (default (nth 1 items)) + (completions (nthcdr 2 items))) + (unless (org-capture-escaped-%) + (delete-region beg end) + (set-marker beg nil) + (set-marker end nil) + (pcase key + ((or "G" "g") + (let* ((org-last-tags-completion-table + (org-global-tags-completion-table + (cond ((equal key "G") (org-agenda-files)) + (file (list file)) + (t nil)))) + (org-add-colon-after-tag-completion t) + (ins (mapconcat + #'identity + (org-split-string + (completing-read + (if prompt (concat prompt ": ") "Tags: ") + 'org-tags-completion-function nil nil nil + 'org-tags-history) + "[^[:alnum:]_@#%]+") + ":"))) + (when (org-string-nw-p ins) + (unless (eq (char-before) ?:) (insert ":")) + (insert ins) + (unless (eq (char-after) ?:) (insert ":")) + (and (org-at-heading-p) + (let ((org-ignore-region t)) + (org-set-tags nil 'align)))))) + ("C" + (cond + ((= (length clipboards) 1) (insert (car clipboards))) + ((> (length clipboards) 1) + (insert (read-string "Clipboard/kill value: " + (car clipboards) + '(clipboards . 1) + (car clipboards)))))) + ("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)))))) + ("p" (org-set-property prompt nil)) + ((guard key) + ;; These are the date/time related ones. + (let* ((upcase? (equal (upcase key) key)) + (org-time-was-given upcase?) + (org-end-time-was-given) + (time (org-read-date upcase? t nil prompt))) + (org-insert-time-stamp + time org-time-was-given + (member key '("u" "U")) + nil nil (list org-end-time-was-given)))) + (_ + (push (org-completing-read + (concat (or prompt "Enter string") + (and default (format " [%s]" default)) + ": ") + completions nil nil nil nil default) + strings) + (insert (car strings))))))))) + + ;; Replace %n escapes with nth %^{...} string. + (setq strings (nreverse strings)) + (save-excursion + (while (re-search-forward "%\\\\\\([1-9][0-9]*\\)" nil t) + (unless (org-capture-escaped-%) + (replace-match + (nth (1- (string-to-number (match-string 1))) strings) + nil t))))) + ;; Make sure there are no empty lines before the text, and that - ;; it ends with a newline character - (goto-char (point-min)) - (while (looking-at "[ \t]*\n") (replace-match "")) - (if (re-search-forward "[ \t\n]*\\'" nil t) (replace-match "\n")) - ;; Return the expanded template and kill the temporary buffer + ;; it ends with a newline character. + (skip-chars-forward " \t\n") + (delete-region (point-min) (line-beginning-position)) + (goto-char (point-max)) + (skip-chars-backward " \t\n") + (delete-region (point) (point-max)) + (insert "\n") + + ;; Return the expanded template and kill the capture buffer. (untabify (point-min) (point-max)) (set-buffer-modified-p nil) - (prog1 (buffer-string) (kill-buffer (current-buffer)))))) + (prog1 (buffer-substring-no-properties (point-min) (point-max)) + (kill-buffer (current-buffer)))))) (defun org-capture-escaped-% () - "Check if % was escaped - if yes, unescape it now." - (if (equal (char-before (match-beginning 0)) ?\\) - (progn - (delete-region (1- (match-beginning 0)) (match-beginning 0)) - t) - nil)) - -(defun org-capture-expand-embedded-elisp () - "Evaluate embedded elisp %(sexp) and replace with the result." - (goto-char (point-min)) - (while (re-search-forward "%(" nil t) - (unless (org-capture-escaped-%) - (goto-char (match-beginning 0)) - (let ((template-start (point))) - (forward-char 1) - (let* ((sexp (read (current-buffer))) - (result (org-eval - (org-capture--expand-keyword-in-embedded-elisp sexp)))) - (delete-region template-start (point)) - (when result - (if (stringp result) - (insert result) - (error "Capture template sexp `%s' must evaluate to string or nil" - sexp)))))))) + "Non-nil if % was escaped. +If yes, unescape it now. Assume match-data contains the +placeholder to check." + (save-excursion + (goto-char (match-beginning 0)) + (let ((n (abs (skip-chars-backward "\\\\")))) + (delete-char (/ (1+ n) 2)) + (= (% n 2) 1)))) + +(defun org-capture-expand-embedded-elisp (&optional mark) + "Evaluate embedded elisp %(sexp) and replace with the result. +When optional MARK argument is non-nil, mark Sexp with a text +property (`org-embedded-elisp') for later evaluation. Only +marked Sexp are evaluated when this argument is nil." + (save-excursion + (goto-char (point-min)) + (while (re-search-forward "%(" nil t) + (cond + ((get-text-property (match-beginning 0) 'org-embedded-elisp) + (goto-char (match-beginning 0)) + (let ((template-start (point))) + (forward-char 1) + (let* ((sexp (read (current-buffer))) + (result (org-eval + (org-capture--expand-keyword-in-embedded-elisp + sexp)))) + (delete-region template-start (point)) + (cond + ((not result) nil) + ((stringp result) (insert result)) + (t (error + "Capture template sexp `%s' must evaluate to string or nil" + sexp)))))) + ((not mark) nil) + ;; Only mark valid and non-escaped sexp. + ((org-capture-escaped-%) nil) + (t + (let ((end (with-syntax-table emacs-lisp-mode-syntax-table + (ignore-errors (scan-sexps (1- (point)) 1))))) + (when end + (put-text-property (- (point) 2) end 'org-embedded-elisp t)))))))) (defun org-capture--expand-keyword-in-embedded-elisp (attr) "Recursively replace capture link keywords in ATTR sexp. @@ -1782,20 +1893,10 @@ Such keywords are prefixed with \"%:\". See (t attr))) (defun org-capture-inside-embedded-elisp-p () - "Return non-nil if point is inside of embedded elisp %(sexp)." - (let (beg end) - (with-syntax-table emacs-lisp-mode-syntax-table - (save-excursion - ;; `looking-at' and `search-backward' below do not match the "%(" if - ;; point is in its middle - (when (equal (char-before) ?%) - (backward-char)) - (save-match-data - (when (or (looking-at "%(") (search-backward "%(" nil t)) - (setq beg (point)) - (setq end (progn (forward-char) (forward-sexp) (1- (point))))))) - (when (and beg end) - (and (<= (point) end) (>= (point) beg)))))) + "Non-nil if point is inside of embedded elisp %(sexp). +Assume sexps have been marked with +`org-capture-expand-embedded-elisp' beforehand." + (get-text-property (point) 'org-embedded-elisp)) ;;;###autoload (defun org-capture-import-remember-templates () @@ -1839,6 +1940,9 @@ Such keywords are prefixed with \"%:\". See (if jump-to-captured '(:jump-to-captured t))))) org-remember-templates)))) +;;; The function was made obsolete by commit 65399674d5 of +;;; 2013-02-22. This make-obsolete call was added 2016-09-01. +(make-obsolete 'org-capture-import-remember-templates "use the `org-capture-templates' variable instead." "Org 9.0") (provide 'org-capture) diff --git a/elpa/org-plus-contrib-20150831/org-checklist.el b/elpa/org-plus-contrib-20170407/org-checklist.el similarity index 100% rename from elpa/org-plus-contrib-20150831/org-checklist.el rename to elpa/org-plus-contrib-20170407/org-checklist.el diff --git a/elpa/org-plus-contrib-20150831/org-choose.el b/elpa/org-plus-contrib-20170407/org-choose.el similarity index 100% rename from elpa/org-plus-contrib-20150831/org-choose.el rename to elpa/org-plus-contrib-20170407/org-choose.el diff --git a/elpa/org-plus-contrib-20150831/org-clock.el b/elpa/org-plus-contrib-20170407/org-clock.el similarity index 72% rename from elpa/org-plus-contrib-20150831/org-clock.el rename to elpa/org-plus-contrib-20170407/org-clock.el index 6de093f7..0973cc21 100644 --- a/elpa/org-plus-contrib-20150831/org-clock.el +++ b/elpa/org-plus-contrib-20170407/org-clock.el @@ -1,6 +1,6 @@ -;;; org-clock.el --- The time clocking code for Org-mode +;;; org-clock.el --- The time clocking code for Org mode -*- lexical-binding: t; -*- -;; Copyright (C) 2004-2015 Free Software Foundation, Inc. +;; Copyright (C) 2004-2017 Free Software Foundation, Inc. ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp @@ -24,26 +24,25 @@ ;; ;;; Commentary: -;; This file contains the time clocking code for Org-mode +;; This file contains the time clocking code for Org mode ;;; Code: -(eval-when-compile - (require 'cl)) +(require 'cl-lib) (require 'org) -(declare-function calendar-iso-to-absolute "cal-iso" (&optional date)) +(declare-function calendar-iso-to-absolute "cal-iso" (date)) (declare-function notifications-notify "notifications" (&rest params)) -(declare-function org-pop-to-buffer-same-window "org-compat" (&optional buffer-or-name norecord label)) (declare-function org-element-property "org-element" (property element)) (declare-function org-element-type "org-element" (element)) (declare-function org-table-goto-line "org-table" (n)) -(defvar org-time-stamp-formats) -(defvar org-ts-what) + (defvar org-frame-title-format-backup frame-title-format) +(defvar org-time-stamp-formats) + (defgroup org-clock nil - "Options concerning clocking working time in Org-mode." + "Options concerning clocking working time in Org mode." :tag "Org Clock" :group 'org-progress) @@ -65,7 +64,7 @@ Do not check directly this variable in a Lisp program. Call function `org-clock-into-drawer' instead." :group 'org-todo :group 'org-clock - :version "25.1" + :version "26.1" :package-version '(Org . "8.3") :type '(choice (const :tag "Always" t) @@ -85,7 +84,7 @@ Return value is either a string, an integer, or nil." (cond ((equal p "nil") nil) ((equal p "t") (or (org-log-into-drawer) "LOGBOOK")) ((org-string-nw-p p) - (if (org-string-match-p "\\`[0-9]+\\'" p) (string-to-number p) p)) + (if (string-match-p "\\`[0-9]+\\'" p) (string-to-number p) p)) ((org-string-nw-p org-clock-into-drawer)) ((integerp org-clock-into-drawer) org-clock-into-drawer) ((not org-clock-into-drawer) nil) @@ -94,9 +93,10 @@ Return value is either a string, an integer, or nil." (defcustom org-clock-out-when-done t "When non-nil, clock will be stopped when the clocked entry is marked DONE. +\\\ DONE here means any DONE-like state. A nil value means clock will keep running until stopped explicitly with -`C-c C-x C-o', or until the clock is started in a different item. +`\\[org-clock-out]', or until the clock is started in a different item. Instead of t, this can also be a list of TODO states that should trigger clocking out." :group 'org-clock @@ -234,9 +234,6 @@ file name Play this sound file, fall back to beep" (const :tag "Standard beep" t) (file :tag "Play sound file"))) -(define-obsolete-variable-alias 'org-clock-modeline-total - 'org-clock-mode-line-total "24.3") - (defcustom org-clock-mode-line-total 'auto "Default setting for the time included for the mode line clock. This can be overruled locally using the CLOCK_MODELINE_TOTAL property. @@ -255,7 +252,7 @@ auto Automatically, either `all', or `repeat' for repeating tasks" (const :tag "All task time" all) (const :tag "Automatically, `all' or since `repeat'" auto))) -(org-defvaralias 'org-task-overrun-text 'org-clock-task-overrun-text) +(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 @@ -279,14 +276,14 @@ string as argument." (function :tag "Function"))) (defgroup org-clocktable nil - "Options concerning the clock table in Org-mode." + "Options concerning the clock table in Org mode." :tag "Org Clock Table" :group 'org-clock) (defcustom org-clocktable-defaults (list :maxlevel 2 - :lang (or (org-bound-and-true-p org-export-default-language) "en") + :lang (or (bound-and-true-p org-export-default-language) "en") :scope 'file :block nil :wstart 1 @@ -323,7 +320,8 @@ For more information, see `org-clocktable-write-default'." '(("en" "File" "L" "Timestamp" "Headline" "Time" "ALL" "Total time" "File time" "Clock summary at") ("es" "Archivo" "N" "Fecha y hora" "Tarea" "Tiempo" "TODO" "Tiempo total" "Tiempo archivo" "Clock summary at") ("fr" "Fichier" "N" "Horodatage" "En-tête" "Durée" "TOUT" "Durée totale" "Durée fichier" "Horodatage sommaire à") - ("nl" "Bestand" "N" "Tijdstip" "Hoofding" "Duur" "ALLES" "Totale duur" "Bestandstijd" "Clock summary at")) + ("nl" "Bestand" "N" "Tijdstip" "Hoofding" "Duur" "ALLES" "Totale duur" "Bestandstijd" "Clock summary at") + ("de" "Datei" "N" "Timestamp" "Tätigkeit" "Dauer" "ALLES" "Gesamtdauer" "Datei Zeit" "Erstellt am")) "Terms used in clocktable, translated to different languages." :group 'org-clocktable :version "24.1" @@ -382,7 +380,7 @@ play with them." :type 'string) (defcustom org-clock-clocked-in-display 'mode-line - "When clocked in for a task, org-mode can display the current + "When clocked in for a task, Org can display the current task and accumulated time in the mode line and/or frame title. Allowed values are: @@ -400,8 +398,8 @@ nil current clock is not displayed" (defcustom org-clock-frame-title-format '(t org-mode-line-string) "The value for `frame-title-format' when clocking in. -When `org-clock-clocked-in-display' is set to 'frame-title -or 'both, clocking in will replace `frame-title-format' with +When `org-clock-clocked-in-display' is set to `frame-title' +or `both', clocking in will replace `frame-title-format' with this value. Clocking out will restore `frame-title-format'. `org-frame-title-string' is a format string using the same @@ -461,11 +459,16 @@ to add an effort property.") (defvar org-clock-has-been-used nil "Has the clock been used during the current Emacs session?") +(defvar org-clock-stored-history nil + "Clock history, populated by `org-clock-load'") +(defvar org-clock-stored-resume-clock nil + "Clock to resume, saved by `org-clock-load'") + (defconst org-clock--oldest-date (let* ((dichotomy (lambda (min max pred) (if (funcall pred min) min - (incf min) + (cl-incf min) (while (> (- max min) 1) (let ((mean (+ (ash min -1) (ash max -1) (logand min max 1)))) (if (funcall pred mean) (setq max mean) (setq min mean))))) @@ -518,6 +521,16 @@ of a different task.") (define-key org-clock-mode-line-map [mode-line mouse-2] 'org-clock-goto) (define-key org-clock-mode-line-map [mode-line mouse-1] 'org-clock-menu) +(defun org-clock--translate (s language) + "Translate string S into using string LANGUAGE. +Assume S in the English term to translate. Return S as-is if it +cannot be translated." + (or (nth (pcase s + ("File" 1) ("L" 2) ("Timestamp" 3) ("Headline" 4) ("Time" 5) + ("ALL" 6) ("Total time" 7) ("File time" 8) ("Clock summary at" 9)) + (assoc-string language org-clock-clocktable-language-setup t)) + s)) + (defun org-clock-menu () (interactive) (popup-menu @@ -553,8 +566,17 @@ of a different task.") (org-check-and-save-marker org-clock-hd-marker beg end) (org-check-and-save-marker org-clock-default-task beg end) (org-check-and-save-marker org-clock-interrupted-task beg end) - (mapc (lambda (m) (org-check-and-save-marker m beg end)) - org-clock-history)) + (dolist (m org-clock-history) + (org-check-and-save-marker m beg end))) + +(defun org-clock-drawer-name () + "Return clock drawer's name for current entry, or nil." + (let ((drawer (org-clock-into-drawer))) + (cond ((integerp drawer) + (let ((log-drawer (org-log-into-drawer))) + (if (stringp log-drawer) log-drawer "LOGBOOK"))) + ((stringp drawer) drawer) + (t nil)))) (defun org-clocking-buffer () "Return the clocking buffer if we are currently clocking a task or nil." @@ -572,8 +594,8 @@ of a different task.") (interactive) (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) + (dolist (c org-clock-history) + (unless (equal c (car och)) (push c och))) (setq och (reverse och) chl (length och)) (if (zerop chl) (user-error "No recent clock") @@ -594,17 +616,15 @@ of a different task.") (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) + (dolist (m och) + (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))) (run-hooks 'org-clock-before-select-task-hook) (goto-char (point-min)) ;; Set min-height relatively to circumvent a possible but in @@ -624,25 +644,22 @@ of a different task.") And return a cons cell with the selection character integer and the marker pointing to it." (when (marker-buffer marker) - (let (file cat task heading prefix) + (let (cat task heading prefix) (with-current-buffer (org-base-buffer (marker-buffer marker)) - (save-excursion - (save-restriction - (widen) - (ignore-errors - (goto-char marker) - (setq file (buffer-file-name (marker-buffer marker)) - cat (org-get-category) - heading (org-get-heading 'notags) - prefix (save-excursion - (org-back-to-heading t) - (looking-at org-outline-regexp) - (match-string 0)) - task (substring - (org-fontify-like-in-org-mode - (concat prefix heading) - org-odd-levels-only) - (length prefix))))))) + (org-with-wide-buffer + (ignore-errors + (goto-char marker) + (setq cat (org-get-category) + heading (org-get-heading 'notags) + prefix (save-excursion + (org-back-to-heading t) + (looking-at org-outline-regexp) + (match-string 0)) + task (substring + (org-fontify-like-in-org-mode + (concat prefix heading) + org-odd-levels-only) + (length prefix)))))) (when (and cat task) (insert (format "[%c] %-12s %s\n" i cat task)) (cons i marker))))) @@ -659,22 +676,21 @@ If an effort estimate was defined for the current item, use If not, show simply the clocked time like 01:50." (let ((clocked-time (org-clock-get-clocked-time))) (if org-clock-effort - (let* ((effort-in-minutes - (org-duration-string-to-minutes org-clock-effort)) + (let* ((effort-in-minutes (org-duration-to-minutes org-clock-effort)) (work-done-str - (org-propertize - (org-minutes-to-clocksum-string clocked-time) + (propertize + (org-duration-from-minutes 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 (org-minutes-to-clocksum-string effort-in-minutes)) - (clockstr (org-propertize + (effort-str (org-duration-from-minutes effort-in-minutes)) + (clockstr (propertize (concat " [%s/" effort-str "] (" (replace-regexp-in-string "%" "%%" org-clock-heading) ")") 'face 'org-mode-line-clock))) (format clockstr work-done-str)) - (org-propertize (concat "[" (org-minutes-to-clocksum-string clocked-time) - (format " (%s)" org-clock-heading) "]") - 'face 'org-mode-line-clock)))) + (propertize (concat " [" (org-duration-from-minutes 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." @@ -689,20 +705,21 @@ If not, show simply the clocked time like 01:50." (org-clock-notify-once-if-expired) (setq org-clock-task-overrun nil)) (setq org-mode-line-string - (org-propertize + (propertize (let ((clock-string (org-clock-get-clock-string)) - (help-text "Org-mode clock is running.\nmouse-1 shows a menu\nmouse-2 will jump to task")) + (help-text "Org mode clock is running.\nmouse-1 shows a \ +menu\nmouse-2 will jump to task")) (if (and (> org-clock-string-limit 0) (> (length clock-string) org-clock-string-limit)) - (org-propertize + (propertize (substring clock-string 0 org-clock-string-limit) 'help-echo (concat help-text ": " org-clock-heading)) - (org-propertize clock-string 'help-echo help-text))) + (propertize clock-string 'help-echo help-text))) 'local-map org-clock-mode-line-map - 'mouse-face (if (featurep 'xemacs) 'highlight 'mode-line-highlight))) + 'mouse-face 'mode-line-highlight)) (if (and org-clock-task-overrun org-clock-task-overrun-text) (setq org-mode-line-string - (concat (org-propertize + (concat (propertize org-clock-task-overrun-text 'face 'org-mode-line-clock-overrun) org-mode-line-string))) (force-mode-line-update)) @@ -712,8 +729,8 @@ If not, show simply the clocked time like 01:50." The time returned includes the time spent on this task in previous clocking intervals." (let ((currently-clocked-time - (floor (- (org-float-time) - (org-float-time org-clock-start-time)) 60))) + (floor (- (float-time) + (float-time org-clock-start-time)) 60))) (+ currently-clocked-time (or org-clock-total-time 0)))) (defun org-clock-modify-effort-estimate (&optional value) @@ -741,15 +758,15 @@ clocked item, and the value displayed in the mode line." ;; A string. See if it is a delta (setq sign (string-to-char value)) (if (member sign '(?- ?+)) - (setq current (org-duration-string-to-minutes current) + (setq current (org-duration-to-minutes current) value (substring value 1)) (setq current 0)) - (setq value (org-duration-string-to-minutes value)) + (setq value (org-duration-to-minutes value)) (if (equal ?- sign) (setq value (- current value)) (if (equal ?+ sign) (setq value (+ current value))))) (setq value (max 0 value) - org-clock-effort (org-minutes-to-clocksum-string value)) + org-clock-effort (org-duration-from-minutes value)) (org-entry-put org-clock-marker "Effort" org-clock-effort) (org-clock-update-mode-line) (message "Effort is now %s" org-clock-effort)) @@ -762,7 +779,7 @@ clocked item, and the value displayed in the mode line." "Show notification if we spent more time than we estimated before. Notification is shown only once." (when (org-clocking-p) - (let ((effort-in-minutes (org-duration-string-to-minutes org-clock-effort)) + (let ((effort-in-minutes (org-duration-to-minutes org-clock-effort)) (clocked-time (org-clock-get-clocked-time))) (if (setq org-clock-task-overrun (if (or (null effort-in-minutes) (zerop effort-in-minutes)) @@ -771,8 +788,9 @@ Notification is shown only once." (unless org-clock-notification-was-shown (setq org-clock-notification-was-shown t) (org-notify - (format "Task '%s' should be finished by now. (%s)" - org-clock-heading org-clock-effort) org-clock-sound)) + (format-message "Task `%s' should be finished by now. (%s)" + org-clock-heading org-clock-effort) + org-clock-sound)) (setq org-clock-notification-was-shown nil))))) (defun org-notify (notification &optional play-sound) @@ -792,7 +810,7 @@ use libnotify if available, or fall back on a message." org-show-notification-handler notification)) ((fboundp 'notifications-notify) (notifications-notify - :title "Org-mode message" + :title "Org mode message" :body notification ;; FIXME how to link to the Org icon? ;; :app-icon "~/.emacs.d/icons/mail.png" @@ -847,12 +865,10 @@ If CLOCK-SOUND is non-nil, it overrides `org-clock-sound'." (defmacro org-with-clock-position (clock &rest forms) "Evaluate FORMS with CLOCK as the current active clock." `(with-current-buffer (marker-buffer (car ,clock)) - (save-excursion - (save-restriction - (widen) - (goto-char (car ,clock)) - (beginning-of-line) - ,@forms)))) + (org-with-wide-buffer + (goto-char (car ,clock)) + (beginning-of-line) + ,@forms))) (def-edebug-spec org-with-clock-position (form body)) (put 'org-with-clock-position 'lisp-indent-function 1) @@ -866,7 +882,7 @@ This macro also protects the current active clock from being altered." (org-clock-effort) (org-clock-marker (car ,clock)) (org-clock-hd-marker (save-excursion - (outline-back-to-heading t) + (org-back-to-heading t) (point-marker)))) ,@forms))) (def-edebug-spec org-with-clock (form body)) @@ -951,7 +967,7 @@ If necessary, clock-out of the currently active clock." (org-with-wide-buffer (let ((drawer-re (format "^[ \t]*:%s:[ \t]*$" (regexp-quote (if (stringp drawer) drawer "LOGBOOK")))) - (beg (save-excursion (outline-back-to-heading t) (point)))) + (beg (save-excursion (org-back-to-heading t) (point)))) (catch 'exit (while (re-search-backward drawer-re beg t) (let ((element (org-element-at-point))) @@ -961,7 +977,7 @@ If necessary, clock-out of the currently active clock." (throw 'exit nil))))))))))) (defun org-clock-resolve (clock &optional prompt-fn last-valid fail-quietly) - "Resolve an open org-mode clock. + "Resolve an open Org clock. An open clock was found, with `dangling' possibly being non-nil. If this function was invoked with a prefix argument, non-dangling open clocks are ignored. The given clock requires some sort of @@ -979,7 +995,7 @@ The format of clock is (CONS MARKER START-TIME), where MARKER identifies the buffer and position the clock is open at (and thus, the heading it's under), and START-TIME is when the clock was started." - (assert clock) + (cl-assert clock) (let* ((ch (save-window-excursion (save-excursion @@ -987,7 +1003,7 @@ was started." (org-clock-jump-to-current-clock clock)) (unless org-clock-resolve-expert (with-output-to-temp-buffer "*Org Clock*" - (princ "Select a Clock Resolution Command: + (princ (format-message "Select a Clock Resolution Command: i/q Ignore this question; the same as keeping all the idle time. @@ -997,7 +1013,7 @@ k/K Keep X minutes of the idle time (default is all). If this 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 + 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 @@ -1009,13 +1025,9 @@ C Cancel the open timer altogether. It will be as though you j/J Jump to the current clock, to make manual adjustments. For all these options, using uppercase makes your final state -to be CLOCKED OUT."))) +to be CLOCKED OUT.")))) (org-fit-window-to-buffer (get-buffer-window "*Org Clock*")) (let (char-pressed) - (when (featurep 'xemacs) - (message (concat (funcall prompt-fn clock) - " [jkKgGsScCiq]? ")) - (setq char-pressed (read-char-exclusive))) (while (or (null char-pressed) (and (not (memq char-pressed '(?k ?K ?g ?G ?s ?S ?C @@ -1027,7 +1039,7 @@ to be CLOCKED OUT."))) nil 45))) (and (not (memq char-pressed '(?i ?q))) char-pressed))))) (default - (floor (/ (org-float-time + (floor (/ (float-time (time-subtract (current-time) last-valid)) 60))) (keep (and (memq ch '(?k ?K)) @@ -1036,8 +1048,8 @@ to be CLOCKED OUT."))) (and (memq ch '(?g ?G)) (read-number "Got back how many minutes ago? " default))) (subtractp (memq ch '(?s ?S))) - (barely-started-p (< (- (org-float-time last-valid) - (org-float-time (cdr clock))) 45)) + (barely-started-p (< (- (float-time last-valid) + (float-time (cdr clock))) 45)) (start-over (and subtractp barely-started-p))) (cond ((memq ch '(?j ?J)) @@ -1077,7 +1089,7 @@ to be CLOCKED OUT."))) ;;;###autoload (defun org-resolve-clocks (&optional only-dangling-p prompt-fn last-valid) - "Resolve all currently open org-mode clocks. + "Resolve all currently open Org clocks. If `only-dangling-p' is non-nil, only ask to resolve dangling \(i.e., not currently open and valid) clocks." (interactive "P") @@ -1096,8 +1108,8 @@ If `only-dangling-p' is non-nil, only ask to resolve dangling (lambda (clock) (format "Dangling clock started %d mins ago" - (floor (- (org-float-time) - (org-float-time (cdr clock))) + (floor (- (float-time) + (float-time (cdr clock))) 60))))) (or last-valid (cdr clock))))))))))) @@ -1106,7 +1118,7 @@ If `only-dangling-p' is non-nil, only ask to resolve dangling "Return the current Emacs idle time in seconds, or nil if not idle." (let ((idle-time (current-idle-time))) (if idle-time - (org-float-time idle-time) + (float-time idle-time) 0))) (defun org-mac-idle-seconds () @@ -1140,7 +1152,7 @@ This routine returns a floating point number." (defvar org-clock-user-idle-seconds) (defun org-resolve-clocks-if-idle () - "Resolve all currently open org-mode clocks. + "Resolve all currently open Org clocks. 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." @@ -1155,13 +1167,12 @@ so long." (org-clock-resolve (cons org-clock-marker org-clock-start-time) - (function - (lambda (clock) - (format "Clocked in & idle for %.1f mins" - (/ (org-float-time - (time-subtract (current-time) - org-clock-user-idle-start)) - 60.0)))) + (lambda (_) + (format "Clocked in & idle for %.1f mins" + (/ (float-time + (time-subtract (current-time) + org-clock-user-idle-start)) + 60.0))) org-clock-user-idle-start))))) (defvar org-clock-current-task nil "Task currently clocked in.") @@ -1171,20 +1182,25 @@ so long." ;;;###autoload (defun org-clock-in (&optional select start-time) "Start the clock on the current item. + If necessary, clock-out of the currently active clock. -With a prefix argument SELECT (\\[universal-argument]), offer a list of recently clocked -tasks to clock into. When SELECT is \\[universal-argument] \\[universal-argument], clock into the current task -and mark it as the default task, a special task that will always be offered -in the clocking selection, associated with the letter `d'. -When SELECT is \\[universal-argument] \\[universal-argument] \\[universal-argument], \ -clock in by using the last clock-out -time as the start time \(see `org-clock-continuously' to -make this the default behavior.)" + +With a `\\[universal-argument]' prefix argument SELECT, offer a list of \ +recently clocked +tasks to clock into. + +When SELECT is `\\[universal-argument] \ \\[universal-argument]', \ +clock into the current task and mark it as +the default task, a special task that will always be offered in the +clocking selection, associated with the letter `d'. + +When SELECT is `\\[universal-argument] \\[universal-argument] \ +\\[universal-argument]', clock in by using the last clock-out +time as the start time. See `org-clock-continuously' to make this +the default behavior." (interactive "P") (setq org-clock-notification-was-shown nil) - (org-refresh-properties - org-effort-property '((effort . identity) - (effort-minutes . org-duration-string-to-minutes))) + (org-refresh-effort-properties) (catch 'abort (let ((interrupting (and (not org-clock-resolving-clocks-due-to-idleness) (org-clocking-p))) @@ -1199,7 +1215,7 @@ make this the default behavior.)" (not org-clock-resolving-clocks)) (setq org-clock-leftover-time nil) (let ((org-clock-clocking-in t)) - (org-resolve-clocks))) ; check if any clocks are dangling + (org-resolve-clocks))) ; check if any clocks are dangling (when (equal select '(64)) ;; Set start-time to `org-clock-out-time' @@ -1252,116 +1268,116 @@ make this the default behavior.)" (set-buffer (org-base-buffer (marker-buffer selected-task))) (setq target-pos (marker-position selected-task)) (move-marker selected-task nil)) - (save-excursion - (save-restriction - (widen) - (goto-char target-pos) - (org-back-to-heading t) - (or interrupting (move-marker org-clock-interrupted-task nil)) - (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 - (match-string 2)))) - (if newstate (org-todo newstate)))) - ((and org-clock-in-switch-to-state - (not (looking-at (concat org-outline-regexp "[ \t]*" - org-clock-in-switch-to-state - "\\>")))) - (org-todo org-clock-in-switch-to-state))) - (setq org-clock-heading - (cond ((and org-clock-heading-function - (functionp org-clock-heading-function)) - (funcall org-clock-heading-function)) - ((nth 4 (org-heading-components)) - (replace-regexp-in-string - "\\[\\[.*?\\]\\[\\(.*?\\)\\]\\]" "\\1" - (match-string-no-properties 4))) - (t "???"))) - (org-clock-find-position org-clock-in-resume) - (cond - ((and org-clock-in-resume - (looking-at - (concat "^[ \t]*" org-clock-string - " \\[\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}" - " *\\sw+\.? +[012][0-9]:[0-5][0-9]\\)\\][ \t]*$"))) - (message "Matched %s" (match-string 1)) - (setq ts (concat "[" (match-string 1) "]")) - (goto-char (match-end 1)) - (setq org-clock-start-time - (apply 'encode-time - (org-parse-time-string (match-string 1)))) - (setq org-clock-effort (org-entry-get (point) org-effort-property)) - (setq org-clock-total-time (org-clock-sum-current-item - (org-clock-get-sum-start)))) - ((eq org-clock-in-resume 'auto-restart) - ;; called from org-clock-load during startup, - ;; do not interrupt, but warn! - (message "Cannot restart clock because task does not contain unfinished clock") - (ding) - (sit-for 2) - (throw 'abort nil)) - (t - (insert-before-markers "\n") - (backward-char 1) - (org-indent-line) - (when (and (save-excursion - (end-of-line 0) - (org-in-item-p))) - (beginning-of-line 1) - (org-indent-line-to (- (org-get-indentation) 2))) - (insert org-clock-string " ") - (setq org-clock-effort (org-entry-get (point) org-effort-property)) - (setq org-clock-total-time (org-clock-sum-current-item - (org-clock-get-sum-start))) - (setq org-clock-start-time - (or (and org-clock-continuously org-clock-out-time) - (and leftover - (y-or-n-p - (format - "You stopped another clock %d mins ago; start this one from then? " - (/ (- (org-float-time - (org-current-time org-clock-rounding-minutes t)) - (org-float-time leftover)) 60))) - leftover) - start-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)) - (move-marker org-clock-hd-marker - (save-excursion (org-back-to-heading t) (point)) - (buffer-base-buffer)) - (setq org-clock-has-been-used t) - ;; add to mode line - (when (or (eq org-clock-clocked-in-display 'mode-line) - (eq org-clock-clocked-in-display 'both)) - (or global-mode-string (setq global-mode-string '(""))) - (or (memq 'org-mode-line-string global-mode-string) - (setq global-mode-string - (append global-mode-string '(org-mode-line-string))))) - ;; add to frame title - (when (or (eq org-clock-clocked-in-display 'frame-title) - (eq org-clock-clocked-in-display 'both)) - (setq frame-title-format org-clock-frame-title-format)) - (org-clock-update-mode-line) - (when org-clock-mode-line-timer - (cancel-timer org-clock-mode-line-timer) - (setq org-clock-mode-line-timer nil)) - (when org-clock-clocked-in-display - (setq org-clock-mode-line-timer - (run-with-timer org-clock-update-period - org-clock-update-period - 'org-clock-update-mode-line))) - (when org-clock-idle-timer - (cancel-timer org-clock-idle-timer) - (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 org--msg-extra) - (run-hooks 'org-clock-in-hook))))))) + (org-with-wide-buffer + (goto-char target-pos) + (org-back-to-heading t) + (or interrupting (move-marker org-clock-interrupted-task nil)) + (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) + (let ((case-fold-search nil)) + (looking-at org-complex-heading-regexp)) + (let ((newstate (funcall org-clock-in-switch-to-state + (match-string 2)))) + (when newstate (org-todo newstate)))) + ((and org-clock-in-switch-to-state + (not (looking-at (concat org-outline-regexp "[ \t]*" + org-clock-in-switch-to-state + "\\>")))) + (org-todo org-clock-in-switch-to-state))) + (setq org-clock-heading + (cond ((and org-clock-heading-function + (functionp org-clock-heading-function)) + (funcall org-clock-heading-function)) + ((nth 4 (org-heading-components)) + (replace-regexp-in-string + "\\[\\[.*?\\]\\[\\(.*?\\)\\]\\]" "\\1" + (match-string-no-properties 4))) + (t "???"))) + (org-clock-find-position org-clock-in-resume) + (cond + ((and org-clock-in-resume + (looking-at + (concat "^[ \t]*" org-clock-string + " \\[\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}" + " *\\sw+.? +[012][0-9]:[0-5][0-9]\\)\\][ \t]*$"))) + (message "Matched %s" (match-string 1)) + (setq ts (concat "[" (match-string 1) "]")) + (goto-char (match-end 1)) + (setq org-clock-start-time + (apply 'encode-time + (org-parse-time-string (match-string 1)))) + (setq org-clock-effort (org-entry-get (point) org-effort-property)) + (setq org-clock-total-time (org-clock-sum-current-item + (org-clock-get-sum-start)))) + ((eq org-clock-in-resume 'auto-restart) + ;; called from org-clock-load during startup, + ;; do not interrupt, but warn! + (message "Cannot restart clock because task does not contain unfinished clock") + (ding) + (sit-for 2) + (throw 'abort nil)) + (t + (insert-before-markers "\n") + (backward-char 1) + (org-indent-line) + (when (and (save-excursion + (end-of-line 0) + (org-in-item-p))) + (beginning-of-line 1) + (indent-line-to (- (org-get-indentation) 2))) + (insert org-clock-string " ") + (setq org-clock-effort (org-entry-get (point) org-effort-property)) + (setq org-clock-total-time (org-clock-sum-current-item + (org-clock-get-sum-start))) + (setq org-clock-start-time + (or (and org-clock-continuously org-clock-out-time) + (and leftover + (y-or-n-p + (format + "You stopped another clock %d mins ago; start this one from then? " + (/ (- (float-time + (org-current-time org-clock-rounding-minutes t)) + (float-time leftover)) + 60))) + leftover) + start-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)) + (move-marker org-clock-hd-marker + (save-excursion (org-back-to-heading t) (point)) + (buffer-base-buffer)) + (setq org-clock-has-been-used t) + ;; add to mode line + (when (or (eq org-clock-clocked-in-display 'mode-line) + (eq org-clock-clocked-in-display 'both)) + (or global-mode-string (setq global-mode-string '(""))) + (or (memq 'org-mode-line-string global-mode-string) + (setq global-mode-string + (append global-mode-string '(org-mode-line-string))))) + ;; add to frame title + (when (or (eq org-clock-clocked-in-display 'frame-title) + (eq org-clock-clocked-in-display 'both)) + (setq frame-title-format org-clock-frame-title-format)) + (org-clock-update-mode-line) + (when org-clock-mode-line-timer + (cancel-timer org-clock-mode-line-timer) + (setq org-clock-mode-line-timer nil)) + (when org-clock-clocked-in-display + (setq org-clock-mode-line-timer + (run-with-timer org-clock-update-period + org-clock-update-period + 'org-clock-update-mode-line))) + (when org-clock-idle-timer + (cancel-timer org-clock-idle-timer) + (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 org--msg-extra) + (run-hooks 'org-clock-in-hook)))))) ;;;###autoload (defun org-clock-in-last (&optional arg) @@ -1448,13 +1464,10 @@ When FIND-UNCLOSED is non-nil, first check if there is an unclosed clock line and position cursor in that line." (org-back-to-heading t) (catch 'exit - (let* ((beg (line-beginning-position 2)) + (let* ((beg (line-beginning-position)) (end (save-excursion (outline-next-heading) (point))) (org-clock-into-drawer (org-clock-into-drawer)) - (drawer (cond - ((not org-clock-into-drawer) nil) - ((stringp org-clock-into-drawer) org-clock-into-drawer) - (t "LOGBOOK")))) + (drawer (org-clock-drawer-name))) ;; Look for a running clock if FIND-UNCLOSED in non-nil. (when find-unclosed (let ((open-clock-re @@ -1482,7 +1495,8 @@ line and position cursor in that line." (throw 'exit t))))))) (goto-char beg) (let ((clock-re (concat "^[ \t]*" org-clock-string)) - (count 0) positions first) + (count 0) + positions) ;; Count the CLOCK lines and store their positions. (save-excursion (while (re-search-forward clock-re end t) @@ -1493,10 +1507,7 @@ line and position cursor in that line." (cond ((null positions) ;; Skip planning line and property drawer, if any. - (when (org-looking-at-p org-planning-line-re) (forward-line)) - (when (looking-at org-property-drawer-re) - (goto-char (match-end 0)) - (forward-line)) + (org-end-of-meta-data) (unless (bolp) (insert "\n")) ;; Create a new drawer if necessary. (when (and org-clock-into-drawer @@ -1509,15 +1520,13 @@ line and position cursor in that line." (org-flag-drawer t) (forward-line)))) ;; When a clock drawer needs to be created because of the - ;; number of clock items, collect all clocks in the section - ;; and wrap them within the drawer. - ((and (wholenump org-clock-into-drawer) - (>= (1+ count) org-clock-into-drawer)) + ;; number of clock items or simply if it is missing, collect + ;; all clocks in the section and wrap them within the drawer. + ((if (wholenump org-clock-into-drawer) + (>= (1+ count) org-clock-into-drawer) + drawer) ;; Skip planning line and property drawer, if any. - (when (org-looking-at-p org-planning-line-re) (forward-line)) - (when (looking-at org-property-drawer-re) - (goto-char (match-end 0)) - (forward-line)) + (org-end-of-meta-data) (let ((beg (point))) (insert (mapconcat @@ -1569,7 +1578,7 @@ to, overriding the existing value of `org-clock-out-switch-to-state'." ts te s h m remove) (setq org-clock-out-time now) (save-excursion ; Do not replace this with `with-current-buffer'. - (org-no-warnings (set-buffer (org-clocking-buffer))) + (with-no-warnings (set-buffer (org-clocking-buffer))) (save-restriction (widen) (goto-char org-clock-marker) @@ -1582,24 +1591,28 @@ to, overriding the existing value of `org-clock-out-switch-to-state'." (delete-region (point) (point-at-eol)) (insert "--") (setq te (org-insert-time-stamp (or at-time now) 'with-hm 'inactive)) - (setq s (- (org-float-time (apply 'encode-time (org-parse-time-string te))) - (org-float-time (apply 'encode-time (org-parse-time-string ts)))) + (setq s (- (float-time + (apply #'encode-time (org-parse-time-string te))) + (float-time + (apply #'encode-time (org-parse-time-string ts)))) h (floor (/ s 3600)) s (- s (* 3600 h)) m (floor (/ s 60)) s (- s (* 60 s))) (insert " => " (format "%2d:%02d" h m)) - (when (setq remove (and org-clock-out-remove-zero-time-clocks - (= (+ h m) 0))) - (beginning-of-line 1) - (delete-region (point) (point-at-eol)) - (and (looking-at "\n") (> (point-max) (1+ (point))) - (delete-char 1))) (move-marker org-clock-marker nil) (move-marker org-clock-hd-marker nil) - (when org-log-note-clock-out - (org-add-log-setup 'clock-out nil nil nil nil - (concat "# Task: " (org-get-heading t) "\n\n"))) + ;; Possibly remove zero time clocks. However, do not add + ;; a note associated to the CLOCK line in this case. + (cond ((and org-clock-out-remove-zero-time-clocks + (= (+ h m) 0)) + (setq remove t) + (delete-region (line-beginning-position) + (line-beginning-position 2))) + (org-log-note-clock-out + (org-add-log-setup + 'clock-out nil nil nil + (concat "# Task: " (org-get-heading t) "\n\n")))) (when org-clock-mode-line-timer (cancel-timer org-clock-mode-line-timer) (setq org-clock-mode-line-timer nil)) @@ -1616,10 +1629,11 @@ to, overriding the existing value of `org-clock-out-switch-to-state'." (org-clock-out-when-done nil)) (cond ((functionp org-clock-out-switch-to-state) - (looking-at org-complex-heading-regexp) + (let ((case-fold-search nil)) + (looking-at org-complex-heading-regexp)) (let ((newstate (funcall org-clock-out-switch-to-state (match-string 2)))) - (if newstate (org-todo newstate)))) + (when newstate (org-todo newstate)))) ((and org-clock-out-switch-to-state (not (looking-at (concat org-outline-regexp "[ \t]*" org-clock-out-switch-to-state @@ -1627,37 +1641,27 @@ 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 " - (org-minutes-to-clocksum-string (+ (* 60 h) m)) "%s") + (org-duration-from-minutes (+ (* 60 h) m)) "%s") te (if remove " => LINE REMOVED" "")) - (let ((h org-clock-out-hook) - (clock-drawer (org-clock-into-drawer))) - ;; 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 clock-drawer - (not (stringp clock-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)) + (run-hooks 'org-clock-out-hook) (unless (org-clocking-p) (setq org-clock-current-task nil))))))) (add-hook 'org-clock-out-hook 'org-clock-remove-empty-clock-drawer) -(defun org-clock-remove-empty-clock-drawer nil - "Remove empty clock drawer in the current subtree." - (let ((clock-drawer (org-log-into-drawer)) - (end (save-excursion (org-end-of-subtree t t)))) - (when clock-drawer - (save-excursion - (org-back-to-heading t) - (while (and (< (point) end) - (search-forward clock-drawer end t)) - (goto-char (match-beginning 0)) - (org-remove-empty-drawer-at (point)) - (forward-line 1)))))) +(defun org-clock-remove-empty-clock-drawer () + "Remove empty clock drawers in current subtree." + (save-excursion + (org-back-to-heading t) + (org-map-tree + (lambda () + (let ((drawer (org-clock-drawer-name)) + (case-fold-search t)) + (when drawer + (let ((re (format "^[ \t]*:%s:[ \t]*$" (regexp-quote drawer))) + (end (save-excursion (outline-next-heading)))) + (while (re-search-forward re end t) + (org-remove-empty-drawer-at (point)))))))))) (defun org-clock-timestamps-up (&optional n) "Increase CLOCK timestamps at cursor. @@ -1673,13 +1677,13 @@ Optional argument N tells to change by that many units." (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 - 'org-timestamp-down)) - ts1 begts1 ts2 begts2 updatets1 tdiff) + (let ((tschange (if (eq updown 'up) 'org-timestamp-up + 'org-timestamp-down)) + (timestamp? (org-at-timestamp-p t)) + ts1 begts1 ts2 begts2 updatets1 tdiff) + (when timestamp? (save-excursion (move-beginning-of-line 1) (re-search-forward org-ts-regexp3 nil t) @@ -1691,24 +1695,24 @@ Optional argument N tells to change by that many units." (if (not ts2) ;; fall back on org-timestamp-up if there is only one (funcall tschange n) - ;; setq this so that (boundp 'org-ts-what is non-nil) (funcall tschange n) (let ((ts (if updatets1 ts2 ts1)) (begts (if updatets1 begts1 begts2))) (setq tdiff - (subtract-time + (time-subtract (org-time-string-to-time org-last-changed-timestamp) (org-time-string-to-time ts))) (save-excursion (goto-char begts) (org-timestamp-change - (round (/ (org-float-time tdiff) - (cond ((eq org-ts-what 'minute) 60) - ((eq org-ts-what 'hour) 3600) - ((eq org-ts-what 'day) (* 24 3600)) - ((eq org-ts-what 'month) (* 24 3600 31)) - ((eq org-ts-what 'year) (* 24 3600 365.2))))) - org-ts-what 'updown))))))) + (round (/ (float-time tdiff) + (pcase timestamp? + (`minute 60) + (`hour 3600) + (`day (* 24 3600)) + (`month (* 24 3600 31)) + (`year (* 24 3600 365.2))))) + timestamp? 'updown))))))) ;;;###autoload (defun org-clock-cancel () @@ -1721,10 +1725,10 @@ Optional argument N tells to change by that many units." (force-mode-line-update) (error "No active clock")) (save-excursion ; Do not replace this with `with-current-buffer'. - (org-no-warnings (set-buffer (org-clocking-buffer))) + (with-no-warnings (set-buffer (org-clocking-buffer))) (goto-char org-clock-marker) - (if (org-looking-back (concat "^[ \t]*" org-clock-string ".*") - (line-beginning-position)) + (if (looking-back (concat "^[ \t]*" org-clock-string ".*") + (line-beginning-position)) (progn (delete-region (1- (point-at-bol)) (point-at-eol)) (org-remove-empty-drawer-at (point))) (message "Clock gone, cancel the timer anyway") @@ -1755,7 +1759,7 @@ With prefix arg SELECT, offer recently clocked tasks for selection." (setq recent t) (car org-clock-history)) (t (error "No active or recent clock task"))))) - (org-pop-to-buffer-same-window (marker-buffer m)) + (pop-to-buffer-same-window (marker-buffer m)) (if (or (< m (point-min)) (> m (point-max))) (widen)) (goto-char m) (org-show-entry) @@ -1767,9 +1771,8 @@ With prefix arg SELECT, offer recently clocked tasks for selection." (message "No running clock, this is the most recently clocked task")) (run-hooks 'org-clock-goto-hook))) -(defvar org-clock-file-total-minutes nil +(defvar-local org-clock-file-total-minutes nil "Holds the file total time in minutes, after a call to `org-clock-sum'.") -(make-variable-buffer-local 'org-clock-file-total-minutes) (defun org-clock-sum-today (&optional headline-filter) "Sum the times for each subtree for today." @@ -1811,8 +1814,8 @@ PROPNAME lets you set a custom text property instead of :org-clock-minutes." time) (if (stringp tstart) (setq tstart (org-time-string-to-seconds tstart))) (if (stringp tend) (setq tend (org-time-string-to-seconds tend))) - (if (consp tstart) (setq tstart (org-float-time tstart))) - (if (consp tend) (setq tend (org-float-time tend))) + (if (consp tstart) (setq tstart (float-time tstart))) + (if (consp tend) (setq tend (float-time tend))) (remove-text-properties (point-min) (point-max) `(,(or propname :org-clock-minutes) t :org-clock-force-headline-inclusion t)) @@ -1824,10 +1827,10 @@ PROPNAME lets you set a custom text property instead of :org-clock-minutes." ;; Two time stamps (setq ts (match-string 2) te (match-string 3) - ts (org-float-time - (apply 'encode-time (org-parse-time-string ts))) - te (org-float-time - (apply 'encode-time (org-parse-time-string te))) + ts (float-time + (apply #'encode-time (org-parse-time-string ts))) + te (float-time + (apply #'encode-time (org-parse-time-string te))) ts (if tstart (max ts tstart) ts) te (if tend (min te tend) te) dt (- te ts) @@ -1843,10 +1846,11 @@ PROPNAME lets you set a custom text property instead of :org-clock-minutes." (equal (marker-position org-clock-hd-marker) (point)) tstart tend - (>= (org-float-time org-clock-start-time) tstart) - (<= (org-float-time org-clock-start-time) tend)) - (let ((time (floor (- (org-float-time) - (org-float-time org-clock-start-time)) 60))) + (>= (float-time org-clock-start-time) tstart) + (<= (float-time org-clock-start-time) tend)) + (let ((time (floor (- (float-time) + (float-time org-clock-start-time)) + 60))) (setq t1 (+ t1 time)))) (let* ((headline-forced (get-text-property (point) @@ -1861,24 +1865,22 @@ PROPNAME lets you set a custom text property instead of :org-clock-minutes." (when (or (> t1 0) (> (aref ltimes level) 0)) (when (or headline-included headline-forced) (if headline-included - (loop for l from 0 to level do - (aset ltimes l (+ (aref ltimes l) t1)))) + (cl-loop for l from 0 to level do + (aset ltimes l (+ (aref ltimes l) t1)))) (setq time (aref ltimes level)) (goto-char (match-beginning 0)) (put-text-property (point) (point-at-eol) (or propname :org-clock-minutes) time) - (if headline-filter - (save-excursion - (save-match-data - (while - (> (funcall outline-level) 1) - (outline-up-heading 1 t) - (put-text-property - (point) (point-at-eol) - :org-clock-force-headline-inclusion t)))))) + (when headline-filter + (save-excursion + (save-match-data + (while (org-up-heading-safe) + (put-text-property + (point) (line-end-position) + :org-clock-force-headline-inclusion t)))))) (setq t1 0) - (loop for l from level to (1- lmax) do - (aset ltimes l 0))))))) + (cl-loop for l from level to (1- lmax) do + (aset ltimes l 0))))))) (setq org-clock-file-total-minutes (aref ltimes 0)))))) (defun org-clock-sum-current-item (&optional tstart) @@ -1893,12 +1895,19 @@ PROPNAME lets you set a custom text property instead of :org-clock-minutes." (defun org-clock-display (&optional arg) "Show subtree times in the entire buffer. -With one universal prefix argument, show the total time for -today. With two universal prefix arguments, show the total time -for a custom range, entered at the prompt. With three universal -prefix arguments, show the total time in the echo area. +By default, show the total time for the range defined in +`org-clock-display-default-range'. With `\\[universal-argument]' \ +prefix, show +the total time for today instead. -Use \\[org-clock-remove-overlays] to remove the subtree times." +With `\\[universal-argument] \\[universal-argument]' prefix, \ +use a custom range, entered at prompt. + +With `\\[universal-argument] \ \\[universal-argument] \ +\\[universal-argument]' prefix, display the total time in the +echo area. + +Use `\\[org-clock-remove-overlays]' to remove the subtree times." (interactive "P") (org-clock-remove-overlays) (let* ((todayp (equal arg '(4))) @@ -1930,19 +1939,18 @@ Use \\[org-clock-remove-overlays] to remove the subtree times." m (- org-clock-file-total-minutes (* 60 h))) ;; Arrange to remove the overlays upon next change. (when org-remove-highlights-with-change - (org-add-hook 'before-change-functions 'org-clock-remove-overlays + (add-hook 'before-change-functions 'org-clock-remove-overlays nil 'local)))) (message (concat (format "Total file time%s: " (cond (todayp " for today") (customp " (custom)") (t ""))) - (org-minutes-to-clocksum-string + (org-duration-from-minutes org-clock-file-total-minutes) " (%d hours and %d minutes)") h m))) -(defvar org-clock-overlays nil) -(make-variable-buffer-local 'org-clock-overlays) +(defvar-local org-clock-overlays nil) (defun org-clock-put-overlay (time) "Put an overlays on the current line, displaying TIME. @@ -1950,10 +1958,11 @@ This creates a new overlay and stores it in `org-clock-overlays', so that it will be easy to remove." (let (ov tx) (beginning-of-line) - (when (looking-at org-complex-heading-regexp) - (goto-char (match-beginning 4))) + (let ((case-fold-search nil)) + (when (looking-at org-complex-heading-regexp) + (goto-char (match-beginning 4)))) (setq ov (make-overlay (point) (point-at-eol)) - tx (concat (buffer-substring-no-properties (point) (match-end 4)) + tx (concat (buffer-substring-no-properties (point) (match-end 4)) (org-add-props (make-string (max 0 (- (- 60 (current-column)) @@ -1961,23 +1970,20 @@ will be easy to remove." (length (org-get-at-bol 'line-prefix)))) ?·) '(face shadow)) (org-add-props - (format " %9s " (org-minutes-to-clocksum-string time)) + (format " %9s " (org-duration-from-minutes time)) '(face org-clock-overlay)) "")) - (if (not (featurep 'xemacs)) - (overlay-put ov 'display tx) - (overlay-put ov 'invisible t) - (overlay-put ov 'end-glyph (make-glyph tx))) + (overlay-put ov 'display tx) (push ov org-clock-overlays))) ;;;###autoload -(defun org-clock-remove-overlays (&optional beg end noremove) +(defun org-clock-remove-overlays (&optional _beg _end noremove) "Remove the occur highlights from the buffer. -BEG and END are ignored. If NOREMOVE is nil, remove this function -from the `before-change-functions' in the current buffer." +If NOREMOVE is nil, remove this function from the +`before-change-functions' in the current buffer." (interactive) (unless org-inhibit-highlight-removal - (mapc 'delete-overlay org-clock-overlays) + (mapc #'delete-overlay org-clock-overlays) (setq org-clock-overlays nil) (unless noremove (remove-hook 'before-change-functions @@ -2025,7 +2031,7 @@ fontified, and then returned." (org-mode) (org-create-dblock props) (org-update-dblock) - (font-lock-ensure) + (org-font-lock-ensure) (forward-line 2) (buffer-substring (point) (progn (re-search-forward "^[ \t]*#\\+END" nil t) @@ -2172,11 +2178,11 @@ have priority." key 'week))) ((string-match "\\`\\([0-9]+\\)-[qQ]\\([1-4]\\)\\'" skey) (require 'cal-iso) + (setq q (string-to-number (match-string 2 skey))) (let ((date (calendar-gregorian-from-absolute (calendar-iso-to-absolute (org-quarter-to-date - (string-to-number (match-string 2 skey)) - (string-to-number (match-string 1 skey))))))) + q (string-to-number (match-string 1 skey))))))) (setq d (nth 1 date) month (car date) y (nth 2 date) @@ -2195,22 +2201,22 @@ have priority." (when (and (memq key '(quarter thisq)) (> shift 0)) (error "Looking forward with quarters isn't implemented")))) (when (= shift 0) - (case key - (yesterday (setq key 'today shift -1)) - (lastweek (setq key 'week shift -1)) - (lastmonth (setq key 'month shift -1)) - (lastyear (setq key 'year shift -1)) - (lastq (setq key 'quarter shift -1)))) + (pcase key + (`yesterday (setq key 'today shift -1)) + (`lastweek (setq key 'week shift -1)) + (`lastmonth (setq key 'month shift -1)) + (`lastyear (setq key 'year shift -1)) + (`lastq (setq key 'quarter shift -1)))) ;; Prepare start and end times depending on KEY's type. - (case key - ((day today) (setq m 0 h 0 h1 24 d (+ d shift))) - ((week thisweek) + (pcase key + ((or `day `today) (setq m 0 h 0 h1 24 d (+ d shift))) + ((or `week `thisweek) (let* ((ws (or wstart 1)) (diff (+ (* -7 shift) (if (= dow 0) (- 7 ws) (- dow ws))))) (setq m 0 h 0 d (- d diff) d1 (+ 7 d)))) - ((month thismonth) + ((or `month `thismonth) (setq h 0 m 0 d (or mstart 1) month (+ month shift) month1 (1+ month))) - ((quarter thisq) + ((or `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. @@ -2218,7 +2224,7 @@ have priority." ((< (+ (- q 1) shift) 0) ; Shift not in this year. (let* ((interval (* -1 (+ (- q 1) shift))) ;; Set tmp to ((years to shift) (quarters to shift)). - (tmp (org-floor* interval 4))) + (tmp (cl-floor interval 4))) ;; Due to the use of floor, 0 quarters actually means 4. (if (= 0 (nth 1 tmp)) (setq shiftedy (- y (nth 0 tmp)) @@ -2233,35 +2239,35 @@ have priority." (setq shiftedy y) (let ((qshift (* 3 (1- (+ q shift))))) (setq m 0 h 0 d 1 month (+ 1 qshift) month1 (+ 4 qshift)))))) - ((year thisyear) + ((or `year `thisyear) (setq m 0 h 0 d 1 month 1 y (+ y shift) y1 (1+ y))) - ((interactive untilnow)) ; Special cases, ignore them. - (t (user-error "No such time block %s" key))) + ((or `interactive `untilnow)) ; Special cases, ignore them. + (_ (user-error "No such time block %s" key))) ;; Format start and end times according to AS-STRINGS. - (let* ((start (case key - (interactive (org-read-date nil t nil "Range start? ")) - (untilnow org-clock--oldest-date) - (t (encode-time 0 m h d month y)))) - (end (case key - (interactive (org-read-date nil t nil "Range end? ")) - (untilnow (current-time)) - (t (encode-time 0 + (let* ((start (pcase key + (`interactive (org-read-date nil t nil "Range start? ")) + (`untilnow org-clock--oldest-date) + (_ (encode-time 0 m h d month y)))) + (end (pcase key + (`interactive (org-read-date nil t nil "Range end? ")) + (`untilnow (current-time)) + (_ (encode-time 0 (or m1 m) (or h1 h) (or d1 d) (or month1 month) (or y1 y))))) (text - (case key - ((day today) (format-time-string "%A, %B %d, %Y" start)) - ((week thisweek) (format-time-string "week %G-W%V" start)) - ((month thismonth) (format-time-string "%B %Y" start)) - ((year thisyear) (format-time-string "the year %Y" start)) - ((quarter thisq) + (pcase key + ((or `day `today) (format-time-string "%A, %B %d, %Y" start)) + ((or `week `thisweek) (format-time-string "week %G-W%V" start)) + ((or `month `thismonth) (format-time-string "%B %Y" start)) + ((or `year `thisyear) (format-time-string "the year %Y" start)) + ((or `quarter `thisq) (concat (org-count-quarter shiftedq) " quarter of " (number-to-string shiftedy))) - (interactive "(Range interactively set)") - (untilnow "now")))) + (`interactive "(Range interactively set)") + (`untilnow "now")))) (if (not as-strings) (list start end text) (let ((f (cdr org-time-stamp-formats))) (list (format-time-string f start) @@ -2364,25 +2370,33 @@ the currently selected interval size." (setq params (org-combine-plists org-clocktable-defaults params)) (catch 'exit (let* ((scope (plist-get params :scope)) + (files (pcase scope + (`agenda + (org-agenda-files t)) + (`agenda-with-archives + (org-add-archive-files (org-agenda-files t))) + (`file-with-archives + (and buffer-file-name + (org-add-archive-files (list buffer-file-name)))) + ((pred functionp) (funcall scope)) + ((pred consp) scope) + (_ (or (buffer-file-name) (current-buffer))))) (block (plist-get params :block)) (ts (plist-get params :tstart)) (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) org-clock-clocktable-formatter 'org-clocktable-write-default)) - cc range-text ipos pos one-file-with-archives - scope-is-list tbls level) + cc) ;; 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 ws ms) - ts (car cc) te (nth 1 cc) range-text (nth 2 cc))) + ts (car cc) + te (nth 1 cc))) (when step ;; Write many tables, in steps (unless (or block (and ts te)) @@ -2390,65 +2404,49 @@ the currently selected interval size." (org-clocktable-steps params) (throw 'exit nil)) - (setq ipos (point)) ; remember the insertion position - - ;; Get the right scope - (setq pos (point)) - (cond - ((and scope (listp scope) (symbolp (car scope))) - (setq scope (eval scope))) - ((eq scope 'agenda) - (setq scope (org-agenda-files t))) - ((eq scope 'agenda-with-archives) - (setq scope (org-agenda-files t)) - (setq scope (org-add-archive-files scope))) - ((eq scope 'file-with-archives) - (setq scope (and buffer-file-name - (org-add-archive-files (list buffer-file-name))) - one-file-with-archives t))) - (setq scope-is-list (and scope (listp scope))) - (if scope-is-list - ;; we collect from several files - (let* ((files scope) - file) - (org-agenda-prepare-buffers files) - (while (setq file (pop files)) - (with-current-buffer (find-buffer-visiting file) - (save-excursion - (save-restriction - (push (org-clock-get-table-data file params) tbls)))))) - ;; Just from the current file - (save-restriction - ;; get the right range into the restriction - (org-agenda-prepare-buffers (list (or (buffer-file-name) - (current-buffer)))) - (cond - ((not scope)) ; use the restriction as it is now - ((eq scope 'file) (widen)) - ((eq scope 'subtree) (org-narrow-to-subtree)) - ((eq scope 'tree) - (while (org-up-heading-safe)) - (org-narrow-to-subtree)) - ((and (symbolp scope) (string-match "^tree\\([0-9]+\\)$" - (symbol-name scope))) - (setq level (string-to-number (match-string 1 (symbol-name scope)))) - (catch 'exit - (while (org-up-heading-safe) - (looking-at org-outline-regexp) - (if (<= (org-reduced-level (funcall outline-level)) level) - (throw 'exit nil)))) - (org-narrow-to-subtree))) - ;; do the table, with no file name. - (push (org-clock-get-table-data nil params) tbls))) - - ;; OK, at this point we tbls as a list of tables, one per file - (setq tbls (nreverse tbls)) - - (setq params (plist-put params :multifile scope-is-list)) - (setq params (plist-put params :one-file-with-archives - one-file-with-archives)) - - (funcall formatter ipos tbls params)))) + (org-agenda-prepare-buffers (if (consp files) files (list files))) + + (let ((origin (point)) + (tables + (if (consp files) + (mapcar (lambda (file) + (with-current-buffer (find-buffer-visiting file) + (save-excursion + (save-restriction + (org-clock-get-table-data file params))))) + files) + ;; Get the right restriction for the scope. + (save-restriction + (cond + ((not scope)) ;use the restriction as it is now + ((eq scope 'file) (widen)) + ((eq scope 'subtree) (org-narrow-to-subtree)) + ((eq scope 'tree) + (while (org-up-heading-safe)) + (org-narrow-to-subtree)) + ((and (symbolp scope) + (string-match "\\`tree\\([0-9]+\\)\\'" + (symbol-name scope))) + (let ((level (string-to-number + (match-string 1 (symbol-name scope))))) + (catch 'exit + (while (org-up-heading-safe) + (looking-at org-outline-regexp) + (when (<= (org-reduced-level (funcall outline-level)) + level) + (throw 'exit nil)))) + (org-narrow-to-subtree)))) + (list (org-clock-get-table-data nil params))))) + (multifile + ;; Even though `file-with-archives' can consist of + ;; multiple files, we consider this is one extended file + ;; instead. + (and (consp files) (not (eq scope 'file-with-archives))))) + + (funcall formatter + origin + tables + (org-combine-plists params `(:multifile ,multifile))))))) (defun org-clocktable-write-default (ipos tables params) "Write out a clock table at position IPOS in the current buffer. @@ -2461,236 +2459,205 @@ from the dynamic block definition." ;; someone wants to write their own special formatter, this maybe ;; much easier because there can be a fixed format with a ;; well-defined number of columns... - (let* ((hlchars '((1 . "*") (2 . "/"))) - (lwords (assoc (or (plist-get params :lang) - (org-bound-and-true-p org-export-default-language) - "en") - org-clock-clocktable-language-setup)) + (let* ((lang (or (plist-get params :lang) "en")) (multifile (plist-get params :multifile)) (block (plist-get params :block)) (sort (plist-get params :sort)) - (ts (plist-get params :tstart)) - (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)) + (header (plist-get params :header)) (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)) + (compact? (plist-get params :compact)) + (narrow (or (plist-get params :narrow) (and compact? '40!))) + (level? (and (not compact?) (plist-get params :level))) (timestamp (plist-get params :timestamp)) (properties (plist-get params :properties)) - (ntcol (max 1 (or (plist-get params :tcolumns) 100))) - (rm-file-column (plist-get params :one-file-with-archives)) - (indent (plist-get params :indent)) + (time-columns (if compact? 1 + (min maxlevel (or (plist-get params :tcolumns) 100)))) + (indent (or compact? (plist-get params :indent))) + (formula (plist-get params :formula)) (case-fold-search t) - range-text total-time tbl level hlc formula pcol - file-time entries entry headline - recalc content narrow-cut-p tcol) - - ;; Implement abbreviations - (when (plist-get params :compact) - (setq level nil indent t narrow (or narrow '40!) ntcol 1)) - - ;; Some consistency test for parameters - (unless (integerp ntcol) - (setq params (plist-put params :tcolumns (setq ntcol 100)))) + (total-time (apply #'+ (mapcar #'cadr tables))) + recalc narrow-cut-p) (when (and narrow (integerp narrow) link) - ;; We cannot have both integer narrow and link - (message - "Using hard narrowing in clocktable to allow for links") + ;; We cannot have both integer narrow and link. + (message "Using hard narrowing in clocktable to allow for links") (setq narrow (intern (format "%d!" narrow)))) - (when narrow - (cond - ((integerp narrow)) - ((and (symbolp narrow) - (string-match "\\`[0-9]+!\\'" (symbol-name narrow))) - (setq narrow-cut-p t - narrow (string-to-number (substring (symbol-name narrow) - 0 -1)))) - (t - (error "Invalid value %s of :narrow property in clock table" - narrow)))) - - (when block - ;; Get the range text for the header - (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))) + (pcase narrow + ((or `nil (pred integerp)) nil) ;nothing to do + ((and (pred symbolp) + (guard (string-match-p "\\`[0-9]+!\\'" (symbol-name narrow)))) + (setq narrow-cut-p t) + (setq narrow (string-to-number (symbol-name narrow)))) + (_ (error "Invalid value %s of :narrow property in clock table" narrow))) - ;; Now we need to output this tsuff + ;; Now we need to output this table stuff. (goto-char ipos) - ;; Insert the text *before* the actual table + ;; Insert the text *before* the actual table. (insert-before-markers (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"))) + ;; Format the standard header. + (format "#+CAPTION: %s %s%s\n" + (org-clock--translate "Clock summary at" lang) + (format-time-string (org-time-stamp-format t t)) + (if block + (let ((range-text + (nth 2 (org-clock-special-range + block nil t + (plist-get params :wstart) + (plist-get params :mstart))))) + (format ", for %s." range-text)) + "")))) ;; Insert the narrowing line (when (and narrow (integerp narrow) (not narrow-cut-p)) (insert-before-markers - "|" ; table line starter - (if multifile "|" "") ; file column, maybe - (if level-p "|" "") ; level column, maybe - (if timestamp "|" "") ; timestamp column, maybe - (if properties (make-string (length properties) ?|) "") ;properties columns, maybe - (format "<%d>| |\n" narrow))) ; headline and time columns + "|" ;table line starter + (if multifile "|" "") ;file column, maybe + (if level? "|" "") ;level column, maybe + (if timestamp "|" "") ;timestamp column, maybe + (if properties ;properties columns, maybe + (make-string (length properties) ?|) + "") + (format "<%d>| |\n" narrow))) ;headline and time columns ;; Insert the table header line (insert-before-markers - "|" ; table line starter - (if multifile (concat (nth 1 lwords) "|") "") ; file column, maybe - (if level-p (concat (nth 2 lwords) "|") "") ; level column, maybe - (if timestamp (concat (nth 3 lwords) "|") "") ; timestamp column, maybe - (if properties (concat (mapconcat 'identity properties "|") "|") "") ;properties columns, maybe - (concat (nth 4 lwords) "|" - (nth 5 lwords) "|\n")) ; headline and time columns + "|" ;table line starter + (if multifile ;file column, maybe + (concat (org-clock--translate "File" lang) "|") + "") + (if level? ;level column, maybe + (concat (org-clock--translate "L" lang) "|") + "") + (if timestamp ;timestamp column, maybe + (concat (org-clock--translate "Timestamp" lang) "|") + "") + (if properties ;properties columns, maybe + (concat (mapconcat #'identity properties "|") "|") + "") + (concat (org-clock--translate "Headline" lang)"|") + (concat (org-clock--translate "Time" lang) "|") + (make-string (max 0 (1- time-columns)) ?|) ;other time columns + (if (eq formula '%) "%|\n" "\n")) ;; Insert the total time in the table (insert-before-markers - "|-\n" ; a hline - "|" ; table line starter - (if multifile (concat "| " (nth 6 lwords) " ") "") - ; file column, maybe - (if level-p "|" "") ; level column, maybe - (if timestamp "|" "") ; timestamp column, maybe - (if properties (make-string (length properties) ?|) "") ; properties columns, maybe - (concat (format org-clock-total-time-cell-format (nth 7 lwords)) "| ") ; instead of a headline + "|-\n" ;a hline + "|" ;table line starter + (if multifile (format "| %s " (org-clock--translate "ALL" lang)) "") + ;file column, maybe + (if level? "|" "") ;level column, maybe + (if timestamp "|" "") ;timestamp column, maybe + (make-string (length properties) ?|) ;properties columns, maybe + (concat (format org-clock-total-time-cell-format + (org-clock--translate "Total time" lang)) + "| ") (format org-clock-total-time-cell-format - (org-minutes-to-clocksum-string (or total-time 0))) ; the time - "|\n") ; close line - - ;; Now iterate over the tables and insert the data - ;; but only if any time has been collected + (org-duration-from-minutes (or total-time 0))) ;time + "|" + (make-string (max 0 (1- time-columns)) ?|) + (cond ((not (eq formula '%)) "") + ((or (not total-time) (= total-time 0)) "0.0|") + (t "100.0|")) + "\n") + + ;; Now iterate over the tables and insert the data but only if any + ;; time has been collected. (when (and total-time (> total-time 0)) - - (while (setq tbl (pop tables)) - ;; now tbl is the table resulting from one file. - (setq file-time (nth 1 tbl)) + (pcase-dolist (`(,file-name ,file-time ,entries) tables) (when (or (and file-time (> file-time 0)) (not (plist-get params :fileskip0))) - (insert-before-markers "|-\n") ; a hline because a new file starts - ;; First the file time, if we have multiple files + (insert-before-markers "|-\n") ;hline at new file + ;; First the file time, if we have multiple files. (when multifile - ;; Summarize the time collected from this file + ;; Summarize the time collected from this file. (insert-before-markers (format (concat "| %s %s | %s%s" - (format org-clock-file-time-cell-format (nth 8 lwords)) + (format org-clock-file-time-cell-format + (org-clock--translate "File time" lang)) " | *%s*|\n") - (file-name-nondirectory (car tbl)) - (if level-p "| " "") ; level column, maybe - (if timestamp "| " "") ; timestamp column, maybe - (if properties (make-string (length properties) ?|) "") ;properties columns, maybe - (org-minutes-to-clocksum-string (nth 1 tbl))))) ; the time + (file-name-nondirectory file-name) + (if level? "| " "") ;level column, maybe + (if timestamp "| " "") ;timestamp column, maybe + (if properties ;properties columns, maybe + (make-string (length properties) ?|) + "") + (org-duration-from-minutes file-time)))) ;time ;; Get the list of node entries and iterate over it - (setq entries (nth 2 tbl)) - (while (setq entry (pop entries)) - (setq level (car entry) - headline (nth 1 entry) - hlc (if emph (or (cdr (assoc level hlchars)) "") "")) - (when narrow-cut-p - (if (and (string-match (concat "\\`" org-bracket-link-regexp - "\\'") - headline) - (match-end 3)) - (setq headline - (format "[[%s][%s]]" - (match-string 1 headline) - (org-shorten-string (match-string 3 headline) - narrow))) - (setq headline (org-shorten-string headline narrow)))) - (insert-before-markers - "|" ; start the table line - (if multifile "|" "") ; free space for file name column? - (if level-p (format "%d|" (car entry)) "") ; level, maybe - (if timestamp (concat (nth 2 entry) "|") "") ; timestamp, maybe - (if properties - (concat - (mapconcat - (lambda (p) (or (cdr (assoc p (nth 4 entry))) "")) - properties "|") "|") "") ;properties columns, maybe - (if indent (org-clocktable-indent-string level) "") ; indentation - hlc headline hlc "|" ; headline - (make-string (min (1- ntcol) (or (- level 1))) ?|) - ; empty fields for higher levels - hlc (org-minutes-to-clocksum-string (nth 3 entry)) hlc ; time - "|\n" ; close line - ))))) - ;; When exporting subtrees or regions the region might be - ;; activated, so let's disable ̀delete-active-region' - (let ((delete-active-region nil)) (backward-delete-char 1)) - (if (setq formula (plist-get params :formula)) - (cond - ((eq formula '%) - ;; compute the column where the % numbers need to go - (setq pcol (+ 2 - (if multifile 1 0) - (if level-p 1 0) - (if timestamp 1 0) - (min maxlevel (or ntcol 100)))) - ;; compute the column where the total time is - (setq tcol (+ 2 - (if multifile 1 0) - (if level-p 1 0) - (if timestamp 1 0))) - (insert - (format - "\n#+TBLFM: $%d='(org-clock-time%% @%d$%d $%d..$%d);%%.1f" - pcol ; the column where the % numbers should go - (if (and narrow (not narrow-cut-p)) 3 2) ; row of the total time - tcol ; column of the total time - tcol (1- pcol) ; range of columns where times can be found - )) - (setq recalc t)) - ((stringp formula) - (insert "\n#+TBLFM: " formula) - (setq recalc t)) - (t (error "Invalid formula in clocktable"))) - ;; Should we rescue an old formula? - (when (stringp (setq content (plist-get params :content))) - (when (string-match "^\\([ \t]*#\\+tblfm:.*\\)" content) + (when (> maxlevel 0) + (pcase-dolist (`(,level ,headline ,ts ,time ,props) entries) + (when narrow-cut-p + (setq headline + (if (and (string-match + (format "\\`%s\\'" org-bracket-link-regexp) + headline) + (match-end 3)) + (format "[[%s][%s]]" + (match-string 1 headline) + (org-shorten-string (match-string 3 headline) + narrow)) + (org-shorten-string headline narrow)))) + (cl-flet ((format-field (f) (format (cond ((not emph) "%s |") + ((= level 1) "*%s* |") + ((= level 2) "/%s/ |") + (t "%s |")) + f))) + (insert-before-markers + "|" ;start the table line + (if multifile "|" "") ;free space for file name column? + (if level? (format "%d|" level) "") ;level, maybe + (if timestamp (concat ts "|") "") ;timestamp, maybe + (if properties ;properties columns, maybe + (concat (mapconcat (lambda (p) (or (cdr (assoc p props)) "")) + properties + "|") + "|") + "") + (if indent ;indentation + (org-clocktable-indent-string level) + "") + (format-field headline) + ;; Empty fields for higher levels. + (make-string (max 0 (1- (min time-columns level))) ?|) + (format-field (org-duration-from-minutes time)) + (make-string (max 0 (- time-columns level)) ?|) + (if (eq formula '%) + (format "%.1f |" (* 100 (/ time (float total-time)))) + "") + "\n"))))))) + (delete-char -1) + (cond + ;; Possibly rescue old formula? + ((or (not formula) (eq formula '%)) + (let ((contents (org-string-nw-p (plist-get params :content)))) + (when (and contents (string-match "^\\([ \t]*#\\+tblfm:.*\\)" contents)) (setq recalc t) - (insert "\n" (match-string 1 (plist-get params :content))) + (insert "\n" (match-string 1 contents)) (beginning-of-line 0)))) - ;; Back to beginning, align the table, recalculate if necessary + ;; Insert specified formula line. + ((stringp formula) + (insert "\n#+TBLFM: " formula) + (setq recalc t)) + (t + (user-error "Invalid :formula parameter in clocktable"))) + ;; Back to beginning, align the table, recalculate if necessary. (goto-char ipos) (skip-chars-forward "^|") (org-table-align) (when org-hide-emphasis-markers - ;; we need to align a second time + ;; We need to align a second time. (org-table-align)) (when sort (save-excursion (org-table-goto-line 3) (org-table-goto-column (car sort)) (org-table-sort-lines nil (cdr sort)))) - (when recalc - (if (eq formula '%) - (save-excursion - (if (and narrow (not narrow-cut-p)) (beginning-of-line 2)) - (org-table-goto-column pcol nil 'force) - (insert "%"))) - (org-table-recalculate 'all)) - (when rm-file-column - ;; The file column is actually not wanted - (forward-char 1) - (org-table-delete-column)) + (when recalc (org-table-recalculate 'all)) total-time)) (defun org-clocktable-indent-string (level) @@ -2710,26 +2677,26 @@ LEVEL is an integer. Indent by two spaces per level above 1." (step (cdr (assoc step0 '((day . 86400) (week . 604800))))) (stepskip0 (plist-get p1 :stepskip0)) (block (plist-get p1 :block)) - cc range-text step-time tsb) + cc step-time tsb) (when block (setq cc (org-clock-special-range block nil t ws ms) - ts (car cc) te (nth 1 cc) range-text (nth 2 cc))) + ts (car cc) + te (nth 1 cc))) (cond ((numberp ts) - ;; If ts is a number, it's an absolute day number from org-agenda. - (destructuring-bind (month day year) (calendar-gregorian-from-absolute ts) - (setq ts (org-float-time (encode-time 0 0 0 day month year))))) + ;; If ts is a number, it's an absolute day number from + ;; org-agenda. + (pcase-let ((`(,month ,day ,year) (calendar-gregorian-from-absolute ts))) + (setq ts (float-time (encode-time 0 0 0 day month year))))) (ts - (setq ts (org-float-time - (apply 'encode-time (org-parse-time-string ts)))))) + (setq ts (float-time (apply #'encode-time (org-parse-time-string ts)))))) (cond ((numberp te) ;; Likewise for te. - (destructuring-bind (month day year) (calendar-gregorian-from-absolute te) - (setq te (org-float-time (encode-time 0 0 0 day month year))))) + (pcase-let ((`(,month ,day ,year) (calendar-gregorian-from-absolute te))) + (setq te (float-time (encode-time 0 0 0 day month year))))) (te - (setq te (org-float-time - (apply 'encode-time (org-parse-time-string te)))))) + (setq te (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))) @@ -2772,7 +2739,7 @@ following structure: (LEVEL HEADLINE TIMESTAMP TIME) LEVEL: The level of the headline, as an integer. This will be - the reduced leve, so 1,2,3,... even if only odd levels + the reduced level, so 1,2,3,... even if only odd levels are being used. HEADLINE: The text of the headline. Depending on PARAMS, this may already be formatted like a link. @@ -2793,14 +2760,14 @@ TIME: The sum of all time spend in this tree, in minutes. This time (tags (plist-get params :tags)) (properties (plist-get params :properties)) (inherit-property-p (plist-get params :inherit-props)) - todo-only - (matcher (if tags (cdr (org-make-tags-matcher tags)))) - cc range-text st p time level hdl props tsp tbl) + (matcher (and tags (cdr (org-make-tags-matcher tags)))) + cc st p time level hdl props tsp tbl) (setq org-clock-file-total-minutes nil) (when block (setq cc (org-clock-special-range block nil t ws ms) - ts (car cc) te (nth 1 cc) range-text (nth 2 cc))) + ts (car cc) + te (nth 1 cc))) (when (integerp ts) (setq ts (calendar-gregorian-from-absolute ts))) (when (integerp te) (setq te (calendar-gregorian-from-absolute te))) (when (and ts (listp ts)) @@ -2812,12 +2779,12 @@ TIME: The sum of all time spend in this tree, in minutes. This time (if te (setq te (org-matcher-time te))) (save-excursion (org-clock-sum ts te - (unless (null matcher) - (lambda () - (let* ((tags-list (org-get-tags-at)) - (org-scanner-tags tags-list) - (org-trust-scanner-tags t)) - (eval matcher))))) + (when matcher + `(lambda () + (let* ((tags-list (org-get-tags-at)) + (org-scanner-tags tags-list) + (org-trust-scanner-tags t)) + (funcall ,matcher nil tags-list nil))))) (goto-char (point-min)) (setq st t) (while (or (and (bobp) (prog1 st (setq st nil)) @@ -2829,7 +2796,7 @@ TIME: The sum of all time spend in this tree, in minutes. This time (when (setq time (get-text-property p :org-clock-minutes)) (save-excursion (beginning-of-line 1) - (when (and (looking-at (org-re "\\(\\*+\\)[ \t]+\\(.*?\\)\\([ \t]+:[[:alnum:]_@#%:]+:\\)?[ \t]*$")) + (when (and (looking-at "\\(\\*+\\)[ \t]+\\(.*?\\)\\([ \t]+:[[:alnum:]_@#%:]+:\\)?[ \t]*$") (setq level (org-reduced-level (- (match-end 1) (match-beginning 1)))) (<= level maxlevel)) @@ -2844,7 +2811,7 @@ TIME: The sum of all time spend in this tree, in minutes. This time (replace-regexp-in-string org-bracket-link-regexp (lambda (m) (or (match-string 3 m) - (match-string 1 m))) + (match-string 1 m))) (match-string 2))))) tsp (when timestamp (setq props (org-entry-properties (point))) @@ -2863,30 +2830,6 @@ TIME: The sum of all time spend in this tree, in minutes. This time (setq tbl (nreverse tbl)) (list file org-clock-file-total-minutes tbl)))) -(defun org-clock-time% (total &rest strings) - "Compute a time fraction in percent. -TOTAL s a time string like 10:21 specifying the total times. -STRINGS is a list of strings that should be checked for a time. -The first string that does have a time will be used. -This function is made for clock tables." - (let ((re "\\([0-9]+\\):\\([0-9]+\\)") - tot s) - (save-match-data - (catch 'exit - (if (not (string-match re total)) - (throw 'exit 0.) - (setq tot (+ (string-to-number (match-string 2 total)) - (* 60 (string-to-number (match-string 1 total))))) - (if (= tot 0.) (throw 'exit 0.))) - (while (setq s (pop strings)) - (if (string-match "\\([0-9]+\\):\\([0-9]+\\)" s) - (throw 'exit - (/ (* 100.0 (+ (string-to-number (match-string 2 s)) - (* 60 (string-to-number - (match-string 1 s))))) - tot)))) - 0)))) - ;; Saving and loading the clock (defvar org-clock-loaded nil @@ -2922,10 +2865,10 @@ Otherwise, return nil." (end-of-line 1) (setq ts (match-string 1) te (match-string 3)) - (setq s (- (org-float-time - (apply 'encode-time (org-parse-time-string te))) - (org-float-time - (apply 'encode-time (org-parse-time-string ts)))) + (setq s (- (float-time + (apply #'encode-time (org-parse-time-string te))) + (float-time + (apply #'encode-time (org-parse-time-string ts)))) neg (< s 0) s (abs s) h (floor (/ s 3600)) @@ -2943,86 +2886,67 @@ The details of what will be saved are regulated by the variable (or org-clock-loaded org-clock-has-been-used (not (file-exists-p org-clock-persist-file)))) - (let (b) - (with-current-buffer (find-file (expand-file-name org-clock-persist-file)) - (progn - (delete-region (point-min) (point-max)) - ;;Store clock - (insert (format ";; org-persist.el - %s at %s\n" - (system-name) (format-time-string - (cdr org-time-stamp-formats)))) - (if (and (memq org-clock-persist '(t clock)) - (setq b (org-clocking-buffer)) - (setq b (or (buffer-base-buffer b) b)) - (buffer-live-p b) - (buffer-file-name b) - (or (not org-clock-persist-query-save) - (y-or-n-p (concat "Save current clock (" - org-clock-heading ") ")))) - (insert "(setq resume-clock '(\"" - (buffer-file-name (org-clocking-buffer)) - "\" . " (int-to-string (marker-position org-clock-marker)) - "))\n")) - ;; Store clocked task history. Tasks are stored reversed to make - ;; reading simpler - (when (and (memq org-clock-persist '(t history)) - org-clock-history) - (insert - "(setq stored-clock-history '(" - (mapconcat - (lambda (m) - (when (and (setq b (marker-buffer m)) - (setq b (or (buffer-base-buffer b) b)) - (buffer-live-p b) - (buffer-file-name b)) - (concat "(\"" (buffer-file-name b) - "\" . " (int-to-string (marker-position m)) - ")"))) - (reverse org-clock-history) " ") "))\n")) - (save-buffer) - (kill-buffer (current-buffer))))))) + (with-temp-file org-clock-persist-file + (insert (format ";; %s - %s at %s\n" + (file-name-nondirectory org-clock-persist-file) + (system-name) + (format-time-string (org-time-stamp-format t)))) + ;; Store clock to be resumed. + (when (and (memq org-clock-persist '(t clock)) + (let ((b (org-base-buffer (org-clocking-buffer)))) + (and (buffer-live-p b) + (buffer-file-name b) + (or (not org-clock-persist-query-save) + (y-or-n-p (format "Save current clock (%s) " + org-clock-heading)))))) + (insert + (format "(setq org-clock-stored-resume-clock '(%S . %d))\n" + (buffer-file-name (org-base-buffer (org-clocking-buffer))) + (marker-position org-clock-marker)))) + ;; Store clocked task history. Tasks are stored reversed to + ;; make reading simpler. + (when (and (memq org-clock-persist '(t history)) + org-clock-history) + (insert + (format "(setq org-clock-stored-history '(%s))\n" + (mapconcat + (lambda (m) + (let ((b (org-base-buffer (marker-buffer m)))) + (when (and (buffer-live-p b) + (buffer-file-name b)) + (format "(%S . %d)" + (buffer-file-name b) + (marker-position m))))) + (reverse org-clock-history) + " "))))))) (defun org-clock-load () "Load clock-related data from disk, maybe resuming a stored clock." (when (and org-clock-persist (not org-clock-loaded)) - (let ((filename (expand-file-name org-clock-persist-file)) - (org-clock-in-resume 'auto-restart) - resume-clock stored-clock-history) - (if (not (file-readable-p filename)) - (message "Not restoring clock data; %s not found" - org-clock-persist-file) - (message "%s" "Restoring clock data") - (setq org-clock-loaded t) - (load-file filename) - ;; load history - (when stored-clock-history - (save-window-excursion - (mapc (lambda (task) - (if (file-exists-p (car task)) - (org-clock-history-push (cdr task) - (find-file (car task))))) - stored-clock-history))) - ;; resume clock - (when (and resume-clock org-clock-persist - (file-exists-p (car resume-clock)) - (or (not org-clock-persist-query-resume) - (y-or-n-p - (concat - "Resume clock (" - (with-current-buffer (find-file (car resume-clock)) - (save-excursion - (goto-char (cdr resume-clock)) - (org-back-to-heading t) - (and (looking-at org-complex-heading-regexp) - (match-string 4)))) - ") ")))) - (when (file-exists-p (car resume-clock)) - (with-current-buffer (find-file (car resume-clock)) - (goto-char (cdr resume-clock)) - (let ((org-clock-auto-clock-resolution nil)) - (org-clock-in) - (if (outline-invisible-p) - (org-show-context)))))))))) + (if (not (file-readable-p org-clock-persist-file)) + (message "Not restoring clock data; %S not found" org-clock-persist-file) + (message "Restoring clock data") + ;; Load history. + (load-file org-clock-persist-file) + (setq org-clock-loaded t) + (pcase-dolist (`(,(and file (pred file-exists-p)) . ,position) + org-clock-stored-history) + (org-clock-history-push position (find-file-noselect file))) + ;; Resume clock. + (pcase org-clock-stored-resume-clock + (`(,(and file (pred file-exists-p)) . ,position) + (with-current-buffer (find-file-noselect file) + (when (or (not org-clock-persist-query-resume) + (y-or-n-p (format "Resume clock (%s) " + (save-excursion + (goto-char position) + (org-get-heading t t))))) + (goto-char position) + (let ((org-clock-in-resume 'auto-restart) + (org-clock-auto-clock-resolution nil)) + (org-clock-in) + (when (outline-invisible-p) (org-show-context)))))) + (_ nil))))) ;; Suggested bindings (org-defkey org-mode-map "\C-c\C-x\C-e" 'org-clock-modify-effort-estimate) diff --git a/elpa/org-plus-contrib-20150831/org-collector.el b/elpa/org-plus-contrib-20170407/org-collector.el similarity index 99% rename from elpa/org-plus-contrib-20150831/org-collector.el rename to elpa/org-plus-contrib-20170407/org-collector.el index 58947072..10ec0cbf 100644 --- a/elpa/org-plus-contrib-20150831/org-collector.el +++ b/elpa/org-plus-contrib-20170407/org-collector.el @@ -1,6 +1,6 @@ ;;; org-collector --- collect properties into tables -;; Copyright (C) 2008-2014 Free Software Foundation, Inc. +;; Copyright (C) 2008-2017 Free Software Foundation, Inc. ;; Author: Eric Schulte ;; Keywords: outlines, hypermedia, calendar, wp, experimentation, diff --git a/elpa/org-plus-contrib-20170407/org-colview.el b/elpa/org-plus-contrib-20170407/org-colview.el new file mode 100644 index 00000000..1d068d32 --- /dev/null +++ b/elpa/org-plus-contrib-20170407/org-colview.el @@ -0,0 +1,1624 @@ +;;; org-colview.el --- Column View in Org -*- lexical-binding: t; -*- + +;; Copyright (C) 2004-2017 Free Software Foundation, Inc. + +;; Author: Carsten Dominik +;; 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 . +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;;; Commentary: + +;; This file contains the column view for Org. + +;;; Code: + +(require 'cl-lib) +(require 'org) + +(declare-function org-agenda-redo "org-agenda" (&optional all)) +(declare-function org-agenda-do-context-action "org-agenda" ()) +(declare-function org-clock-sum-today "org-clock" (&optional headline-filter)) +(declare-function org-element-extract-element "org-element" (element)) +(declare-function org-element-interpret-data "org-element" (data)) +(declare-function org-element-map "org-element" (data types fun &optional info first-match no-recursion with-affiliated)) +(declare-function org-element-parse-secondary-string "org-element" (string restriction &optional parent)) +(declare-function org-element-property "org-element" (property element)) +(declare-function org-element-restriction "org-element" (element)) +(declare-function org-element-type "org-element" (element)) + +(defvar org-agenda-columns-add-appointments-to-effort-sum) +(defvar org-agenda-columns-compute-summary-properties) +(defvar org-agenda-columns-show-summaries) +(defvar org-agenda-view-columns-initially) +(defvar org-inlinetask-min-level) + + +;;; Configuration + +(defcustom org-columns-modify-value-for-display-function nil + "Function that modifies values for display in column view. +For example, it can be used to cut out a certain part from a time stamp. +The function must take 2 arguments: + +column-title The title of the column (*not* the property name) +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 '(choice (const nil) (function))) + +(defcustom org-columns-summary-types nil + "Alist between operators and summarize functions. + +Each association follows the pattern (LABEL . SUMMARIZE) where + + LABEL is a string used in #+COLUMNS definition describing the + summary type. It can contain any character but \"}\". It is + case-sensitive. + + SUMMARIZE is a function called with two arguments. The first + argument is a non-empty list of values, as non-empty strings. + The second one is a format string or nil. It has to return + a string summarizing the list of values. + +Note that the return value can become one value for an higher +order summary, so the function is expected to handle its own +output. + +Types defined in this variable take precedence over those defined +in `org-columns-summary-types-default', which see." + :group 'org-properties + :version "26.1" + :package-version '(Org . "9.0") + :type '(alist :key-type (string :tag " Label") + :value-type (function :tag "Summarize"))) + + + +;;; Column View + +(defvar org-columns-overlays nil + "Holds the list of current column overlays.") + +(defvar org-columns--time 0.0 + "Number of seconds since the epoch, as a floating point number.") + +(defvar-local org-columns-current-fmt nil + "Local variable, holds the currently active column format.") + +(defvar-local org-columns-current-fmt-compiled nil + "Local variable, holds the currently active column format. +This is the compiled version of the format.") + +(defvar-local org-columns-current-maxwidths nil + "Currently active maximum column widths, as a vector.") + +(defvar org-columns-begin-marker (make-marker) + "Points to the position where last a column creation command was called.") + +(defvar org-columns-top-level-marker (make-marker) + "Points to the position where current columns region starts.") + +(defvar org-columns-map (make-sparse-keymap) + "The keymap valid in column display.") + +(defconst org-columns-summary-types-default + '(("+" . org-columns--summary-sum) + ("$" . org-columns--summary-currencies) + ("X" . org-columns--summary-checkbox) + ("X/" . org-columns--summary-checkbox-count) + ("X%" . org-columns--summary-checkbox-percent) + ("max" . org-columns--summary-max) + ("mean" . org-columns--summary-mean) + ("min" . org-columns--summary-min) + (":" . org-columns--summary-sum-times) + (":max" . org-columns--summary-max-time) + (":mean" . org-columns--summary-mean-time) + (":min" . org-columns--summary-min-time) + ("@max" . org-columns--summary-max-age) + ("@mean" . org-columns--summary-mean-age) + ("@min" . org-columns--summary-min-age) + ("est+" . org-columns--summary-estimate)) + "Map operators to summarize functions. +See `org-columns-summary-types' for details.") + +(defun org-columns-content () + "Switch to contents view while in columns view." + (interactive) + (org-overview) + (org-content)) + +(org-defkey org-columns-map "c" 'org-columns-content) +(org-defkey org-columns-map "o" 'org-overview) +(org-defkey org-columns-map "e" 'org-columns-edit-value) +(org-defkey org-columns-map "\C-c\C-t" 'org-columns-todo) +(org-defkey org-columns-map "\C-c\C-c" 'org-columns-set-tags-or-toggle) +(org-defkey org-columns-map "\C-c\C-o" 'org-columns-open-link) +(org-defkey org-columns-map "v" 'org-columns-show-value) +(org-defkey org-columns-map "q" 'org-columns-quit) +(org-defkey org-columns-map "r" 'org-columns-redo) +(org-defkey org-columns-map "g" 'org-columns-redo) +(org-defkey org-columns-map [left] 'backward-char) +(org-defkey org-columns-map "\M-b" 'backward-char) +(org-defkey org-columns-map "a" 'org-columns-edit-allowed) +(org-defkey org-columns-map "s" 'org-columns-edit-attributes) +(org-defkey org-columns-map "\M-f" + (lambda () (interactive) (goto-char (1+ (point))))) +(org-defkey org-columns-map [right] + (lambda () (interactive) (goto-char (1+ (point))))) +(org-defkey org-columns-map [down] + (lambda () (interactive) + (let ((col (current-column))) + (beginning-of-line 2) + (while (and (org-invisible-p2) (not (eobp))) + (beginning-of-line 2)) + (move-to-column col) + (if (eq major-mode 'org-agenda-mode) + (org-agenda-do-context-action))))) +(org-defkey org-columns-map [up] + (lambda () (interactive) + (let ((col (current-column))) + (beginning-of-line 0) + (while (and (org-invisible-p2) (not (bobp))) + (beginning-of-line 0)) + (move-to-column col) + (if (eq major-mode 'org-agenda-mode) + (org-agenda-do-context-action))))) +(org-defkey org-columns-map [(shift right)] 'org-columns-next-allowed-value) +(org-defkey org-columns-map "n" 'org-columns-next-allowed-value) +(org-defkey org-columns-map [(shift left)] 'org-columns-previous-allowed-value) +(org-defkey org-columns-map "p" 'org-columns-previous-allowed-value) +(org-defkey org-columns-map "<" 'org-columns-narrow) +(org-defkey org-columns-map ">" 'org-columns-widen) +(org-defkey org-columns-map [(meta right)] 'org-columns-move-right) +(org-defkey org-columns-map [(meta left)] 'org-columns-move-left) +(org-defkey org-columns-map [(shift meta right)] 'org-columns-new) +(org-defkey org-columns-map [(shift meta left)] 'org-columns-delete) +(dotimes (i 10) + (org-defkey org-columns-map (number-to-string i) + `(lambda () (interactive) + (org-columns-next-allowed-value nil ,i)))) + +(easy-menu-define org-columns-menu org-columns-map "Org Column Menu" + '("Column" + ["Edit property" org-columns-edit-value t] + ["Next allowed value" org-columns-next-allowed-value t] + ["Previous allowed value" org-columns-previous-allowed-value t] + ["Show full value" org-columns-show-value t] + ["Edit allowed values" org-columns-edit-allowed t] + "--" + ["Edit column attributes" org-columns-edit-attributes t] + ["Increase column width" org-columns-widen t] + ["Decrease column width" org-columns-narrow t] + "--" + ["Move column right" org-columns-move-right t] + ["Move column left" org-columns-move-left t] + ["Add column" org-columns-new t] + ["Delete column" org-columns-delete t] + "--" + ["CONTENTS" org-columns-content t] + ["OVERVIEW" org-overview t] + ["Refresh columns display" org-columns-redo t] + "--" + ["Open link" org-columns-open-link t] + "--" + ["Quit" org-columns-quit t])) + +(defun org-columns--displayed-value (spec value) + "Return displayed value for specification SPEC in current entry. + +SPEC is a column format specification as stored in +`org-columns-current-fmt-compiled'. VALUE is the real value to +display, as a string." + (cond + ((and (functionp org-columns-modify-value-for-display-function) + (funcall org-columns-modify-value-for-display-function + (nth 1 spec) + value))) + ((equal (car spec) "ITEM") + (concat (make-string (1- (org-current-level)) + (if org-hide-leading-stars ?\s ?*)) + "* " + (org-columns-compact-links value))) + (value))) + +(defun org-columns--collect-values (&optional compiled-fmt) + "Collect values for columns on the current line. + +Return a list of triplets (SPEC VALUE DISPLAYED) suitable for +`org-columns--display-here'. + +This function assumes `org-columns-current-fmt-compiled' is +initialized is set in the current buffer. However, it is +possible to override it with optional argument COMPILED-FMT." + (let ((summaries (get-text-property (point) 'org-summaries))) + (mapcar + (lambda (spec) + (pcase spec + (`(,p . ,_) + (let* ((v (or (cdr (assoc spec summaries)) + (org-entry-get (point) p 'selective t) + (and compiled-fmt ;assume `org-agenda-columns' + ;; Effort property is not defined. Try + ;; to use appointment duration. + org-agenda-columns-add-appointments-to-effort-sum + (string= p (upcase org-effort-property)) + (get-text-property (point) 'duration) + (propertize (org-duration-from-minutes + (get-text-property (point) 'duration)) + 'face 'org-warning)) + ""))) + (list spec v (org-columns--displayed-value spec v)))))) + (or compiled-fmt org-columns-current-fmt-compiled)))) + +(defun org-columns--set-widths (cache) + "Compute the maximum column widths from the format and CACHE. +This function sets `org-columns-current-maxwidths' as a vector of +integers greater than 0." + (setq org-columns-current-maxwidths + (apply #'vector + (mapcar + (lambda (spec) + (pcase spec + (`(,_ ,_ ,(and width (pred wholenump)) . ,_) width) + (`(,_ ,name . ,_) + ;; No width is specified in the columns format. + ;; Compute it by checking all possible values for + ;; PROPERTY. + (let ((width (length name))) + (dolist (entry cache width) + (let ((value (nth 2 (assoc spec (cdr entry))))) + (setq width (max (length value) width)))))))) + org-columns-current-fmt-compiled)))) + +(defun org-columns--new-overlay (beg end &optional string face) + "Create a new column overlay and add it to the list." + (let ((ov (make-overlay beg end))) + (overlay-put ov 'face (or face 'secondary-selection)) + (org-overlay-display ov string face) + (push ov org-columns-overlays) + ov)) + +(defun org-columns--summarize (operator) + "Return summary function associated to string OPERATOR." + (if (not operator) nil + (cdr (or (assoc operator org-columns-summary-types) + (assoc operator org-columns-summary-types-default) + (error "Unknown %S operator" operator))))) + +(defun org-columns--overlay-text (value fmt width property original) + "Return text " + (format fmt + (let ((v (org-columns-add-ellipses value width))) + (pcase property + ("PRIORITY" + (propertize v 'face (org-get-priority-face original))) + ("TAGS" + (if (not org-tags-special-faces-re) + (propertize v 'face 'org-tag) + (replace-regexp-in-string + org-tags-special-faces-re + (lambda (m) (propertize m 'face (org-get-tag-face m))) + v nil nil 1))) + ("TODO" (propertize v 'face (org-get-todo-face original))) + (_ v))))) + +(defun org-columns--display-here (columns &optional dateline) + "Overlay the current line with column display. +COLUMNS is an alist (SPEC VALUE DISPLAYED). Optional argument +DATELINE is non-nil when the face used should be +`org-agenda-column-dateline'." + (save-excursion + (beginning-of-line) + (let* ((level-face (and (looking-at "\\(\\**\\)\\(\\* \\)") + (org-get-level-face 2))) + (ref-face (or level-face + (and (eq major-mode 'org-agenda-mode) + (org-get-at-bol 'face)) + 'default)) + (color (list :foreground (face-attribute ref-face :foreground))) + (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))) + ;; Each column is an overlay on top of a character. So there has + ;; to be at least as many characters available on the line as + ;; columns to display. + (let ((columns (length org-columns-current-fmt-compiled)) + (chars (- (line-end-position) (line-beginning-position)))) + (when (> columns chars) + (save-excursion + (end-of-line) + (let ((inhibit-read-only t)) + (insert (make-string (- columns chars) ?\s)))))) + ;; Display columns. Create and install the overlay for the + ;; current column on the next character. + (let ((i 0) + (last (1- (length columns)))) + (dolist (column columns) + (pcase column + (`(,spec ,original ,value) + (let* ((property (car spec)) + (width (aref org-columns-current-maxwidths i)) + (fmt (format (if (= i last) "%%-%d.%ds |" + "%%-%d.%ds | ") + width width)) + (ov (org-columns--new-overlay + (point) (1+ (point)) + (org-columns--overlay-text + value fmt width property original) + (if dateline face1 face)))) + (overlay-put ov 'keymap org-columns-map) + (overlay-put ov 'org-columns-key property) + (overlay-put ov 'org-columns-value original) + (overlay-put ov 'org-columns-value-modified value) + (overlay-put ov 'org-columns-format fmt) + (overlay-put ov 'line-prefix "") + (overlay-put ov 'wrap-prefix "") + (forward-char)))) + (cl-incf i))) + ;; Make the rest of the line disappear. + (let ((ov (org-columns--new-overlay (point) (line-end-position)))) + (overlay-put ov 'invisible t) + (overlay-put ov 'keymap org-columns-map) + (overlay-put ov 'line-prefix "") + (overlay-put ov 'wrap-prefix "")) + (let ((ov (make-overlay (1- (line-end-position)) + (line-beginning-position 2)))) + (overlay-put ov 'keymap org-columns-map) + (push ov org-columns-overlays)) + (org-with-silent-modifications + (let ((inhibit-read-only t)) + (put-text-property + (line-end-position 0) + (line-beginning-position 2) + 'read-only + (substitute-command-keys + "Type \\`\\[org-columns-edit-value]' \ +to edit property"))))))) + +(defun org-columns-add-ellipses (string width) + "Truncate STRING with WIDTH characters, with ellipses." + (cond + ((<= (length string) width) string) + ((<= width (length org-columns-ellipses)) + (substring org-columns-ellipses 0 width)) + (t (concat (substring string 0 (- width (length org-columns-ellipses))) + org-columns-ellipses)))) + +(defvar org-columns-full-header-line-format nil + "The full header line format, will be shifted by horizontal scrolling." ) +(defvar org-previous-header-line-format nil + "The header line format before column view was turned on.") +(defvar org-columns-inhibit-recalculation nil + "Inhibit recomputing of columns on column view startup.") +(defvar org-columns-flyspell-was-active nil + "Remember the state of `flyspell-mode' before column view. +Flyspell-mode can cause problems in columns view, so it is turned off +for the duration of the command.") + +(defvar header-line-format) +(defvar org-columns-previous-hscroll 0) + +(defun org-columns--display-here-title () + "Overlay the newline before the current line with the table title." + (interactive) + (let ((title "") + (i 0)) + (dolist (column org-columns-current-fmt-compiled) + (pcase column + (`(,property ,name . ,_) + (let* ((width (aref org-columns-current-maxwidths i)) + (fmt (format "%%-%d.%ds | " width width))) + (setq title (concat title (format fmt (or name property))))))) + (cl-incf i)) + (setq-local org-previous-header-line-format header-line-format) + (setq org-columns-full-header-line-format + (concat + (org-add-props " " nil 'display '(space :align-to 0)) + (org-add-props (substring title 0 -1) nil 'face 'org-column-title))) + (setq org-columns-previous-hscroll -1) + (add-hook 'post-command-hook 'org-columns-hscroll-title nil 'local))) + +(defun org-columns-hscroll-title () + "Set the `header-line-format' so that it scrolls along with the table." + (sit-for .0001) ; need to force a redisplay to update window-hscroll + (when (not (= (window-hscroll) org-columns-previous-hscroll)) + (setq header-line-format + (concat (substring org-columns-full-header-line-format 0 1) + (substring org-columns-full-header-line-format + (1+ (window-hscroll)))) + org-columns-previous-hscroll (window-hscroll)) + (force-mode-line-update))) + +(defvar org-colview-initial-truncate-line-value nil + "Remember the value of `truncate-lines' across colview.") + +;;;###autoload +(defun org-columns-remove-overlays () + "Remove all currently active column overlays." + (interactive) + (when (marker-buffer org-columns-begin-marker) + (with-current-buffer (marker-buffer org-columns-begin-marker) + (when (local-variable-p 'org-previous-header-line-format) + (setq header-line-format org-previous-header-line-format) + (kill-local-variable 'org-previous-header-line-format) + (remove-hook 'post-command-hook 'org-columns-hscroll-title 'local)) + (move-marker org-columns-begin-marker nil) + (move-marker org-columns-top-level-marker nil) + (org-with-silent-modifications + (mapc 'delete-overlay org-columns-overlays) + (setq org-columns-overlays nil) + (let ((inhibit-read-only t)) + (remove-text-properties (point-min) (point-max) '(read-only t)))) + (when org-columns-flyspell-was-active + (flyspell-mode 1)) + (when (local-variable-p 'org-colview-initial-truncate-line-value) + (setq truncate-lines org-colview-initial-truncate-line-value))))) + +(defun org-columns-compact-links (s) + "Replace [[link][desc]] with [desc] or [link]." + (while (string-match org-bracket-link-regexp s) + (setq s (replace-match + (concat "[" (match-string (if (match-end 3) 3 1) s) "]") + t t s))) + s) + +(defun org-columns-show-value () + "Show the full value of the property." + (interactive) + (let ((value (get-char-property (point) 'org-columns-value))) + (message "Value is: %s" (or value "")))) + +(defvar org-agenda-columns-active) ;; defined in org-agenda.el + +(defun org-columns-quit () + "Remove the column overlays and in this way exit column editing." + (interactive) + (org-with-silent-modifications + (org-columns-remove-overlays) + (let ((inhibit-read-only t)) + (remove-text-properties (point-min) (point-max) '(read-only t)))) + (if (not (eq major-mode 'org-agenda-mode)) + (setq org-columns-current-fmt nil) + (setq org-agenda-columns-active nil) + (message + "Modification not yet reflected in Agenda buffer, use `r' to refresh"))) + +(defun org-columns-check-computed () + "Throw an error if current column value is computed." + (let ((spec (nth (current-column) org-columns-current-fmt-compiled))) + (and + (nth 3 spec) + (assoc spec (get-text-property (line-beginning-position) 'org-summaries)) + (error "This value is computed from the entry's children")))) + +(defun org-columns-todo (&optional _arg) + "Change the TODO state during column view." + (interactive "P") + (org-columns-edit-value "TODO")) + +(defun org-columns-set-tags-or-toggle (&optional _arg) + "Toggle checkbox at point, or set tags for current headline." + (interactive "P") + (if (string-match "\\`\\[[ xX-]\\]\\'" + (get-char-property (point) 'org-columns-value)) + (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." + (interactive) + (org-columns-check-computed) + (let* ((col (current-column)) + (bol (line-beginning-position)) + (eol (line-end-position)) + (pom (or (get-text-property bol 'org-hd-marker) (point))) + (key (or key (get-char-property (point) 'org-columns-key))) + (org-columns--time (float-time (current-time))) + (action + (pcase key + ("CLOCKSUM" + (error "This special column cannot be edited")) + ("ITEM" + (lambda () (org-with-point-at pom (org-edit-headline)))) + ("TODO" + (lambda () + (org-with-point-at pom (call-interactively #'org-todo)))) + ("PRIORITY" + (lambda () + (org-with-point-at pom + (call-interactively #'org-priority)))) + ("TAGS" + (lambda () + (org-with-point-at pom + (let ((org-fast-tag-selection-single-key + (if (eq org-fast-tag-selection-single-key 'expert) + t + org-fast-tag-selection-single-key))) + (call-interactively #'org-set-tags))))) + ("DEADLINE" + (lambda () + (org-with-point-at pom (call-interactively #'org-deadline)))) + ("SCHEDULED" + (lambda () + (org-with-point-at pom (call-interactively #'org-schedule)))) + ("BEAMER_ENV" + (lambda () + (org-with-point-at pom + (call-interactively #'org-beamer-select-environment)))) + (_ + (let* ((allowed (org-property-get-allowed-values pom key 'table)) + (value (get-char-property (point) 'org-columns-value)) + (nval (org-trim + (if (null allowed) (read-string "Edit: " value) + (completing-read + "Value: " allowed nil + (not (get-text-property + 0 'org-unrestricted (caar allowed)))))))) + (and (not (equal nval value)) + (lambda () (org-entry-put pom key nval)))))))) + (cond + ((null action)) + ((eq major-mode 'org-agenda-mode) + (org-columns--call action) + ;; The following let preserves the current format, and makes + ;; sure that in only a single file things need to be updated. + (let* ((org-agenda-overriding-columns-format org-columns-current-fmt) + (buffer (marker-buffer pom)) + (org-agenda-contributing-files + (list (with-current-buffer buffer + (buffer-file-name (buffer-base-buffer)))))) + (org-agenda-columns))) + (t + (let ((inhibit-read-only t)) + (org-with-silent-modifications + (remove-text-properties (max (point-min) (1- bol)) eol '(read-only t))) + (org-columns--call action)) + ;; Some properties can modify headline (e.g., "TODO"), and + ;; possible shuffle overlays. Make sure they are still all at + ;; the right place on the current line. + (let ((org-columns-inhibit-recalculation)) (org-columns-redo)) + (org-columns-update key) + (org-move-to-column col))))) + +(defun org-columns-edit-allowed () + "Edit the list of allowed values for the current property." + (interactive) + (let* ((pom (or (org-get-at-bol 'org-marker) + (org-get-at-bol 'org-hd-marker) + (point))) + (key (get-char-property (point) 'org-columns-key)) + (key1 (concat key "_ALL")) + (allowed (org-entry-get pom key1 t)) + nval) + ;; FIXME: Cover editing TODO, TAGS etc in-buffer settings.???? + ;; FIXME: Write back to #+PROPERTY setting if that is needed. + (setq nval (read-string "Allowed: " allowed)) + (org-entry-put + (cond ((marker-position org-entry-property-inherited-from) + org-entry-property-inherited-from) + ((marker-position org-columns-top-level-marker) + org-columns-top-level-marker) + (t pom)) + key1 nval))) + +(defun org-columns--call (fun) + "Call function FUN while preserving heading visibility. +FUN is a function called with no argument." + (let ((hide-body (and (/= (line-end-position) (point-max)) + (save-excursion + (move-beginning-of-line 2) + (org-at-heading-p t))))) + (unwind-protect (funcall fun) + (when hide-body (outline-hide-entry))))) + +(defun org-columns-previous-allowed-value () + "Switch to the previous allowed value for this column." + (interactive) + (org-columns-next-allowed-value t)) + +(defun org-columns-next-allowed-value (&optional previous nth) + "Switch to the next allowed value for this column. +When PREVIOUS is set, go to the previous value. When NTH is +an integer, select that value." + (interactive) + (org-columns-check-computed) + (let* ((column (current-column)) + (key (get-char-property (point) 'org-columns-key)) + (value (get-char-property (point) 'org-columns-value)) + (pom (or (get-text-property (line-beginning-position) 'org-hd-marker) + (point))) + (allowed + (let ((all + (or (org-property-get-allowed-values pom key) + (pcase (nth column org-columns-current-fmt-compiled) + (`(,_ ,_ ,_ ,(or "X" "X/" "X%") ,_) '("[ ]" "[X]"))) + (org-colview-construct-allowed-dates value)))) + (if previous (reverse all) all)))) + (when (equal key "ITEM") (error "Cannot edit item headline from here")) + (unless (or allowed (member key '("SCHEDULED" "DEADLINE" "CLOCKSUM"))) + (error "Allowed values for this property have not been defined")) + (let* ((l (length allowed)) + (new + (cond + ((member key '("SCHEDULED" "DEADLINE" "CLOCKSUM")) + (if previous 'earlier 'later)) + ((integerp nth) + (when (> (abs nth) l) + (user-error "Only %d allowed values for property `%s'" l key)) + (nth (mod (1- nth) l) allowed)) + ((member value allowed) + (when (= l 1) (error "Only one allowed value for this property")) + (or (nth 1 (member value allowed)) (car allowed))) + (t (car allowed)))) + (action (lambda () (org-entry-put pom key new)))) + (cond + ((eq major-mode 'org-agenda-mode) + (org-columns--call action) + ;; The following let preserves the current format, and makes + ;; sure that in only a single file things need to be updated. + (let* ((org-agenda-overriding-columns-format org-columns-current-fmt) + (buffer (marker-buffer pom)) + (org-agenda-contributing-files + (list (with-current-buffer buffer + (buffer-file-name (buffer-base-buffer)))))) + (org-agenda-columns))) + (t + (let ((inhibit-read-only t)) + (remove-text-properties (line-end-position 0) (line-end-position) + '(read-only t)) + (org-columns--call action)) + ;; Some properties can modify headline (e.g., "TODO"), and + ;; possible shuffle overlays. Make sure they are still all at + ;; the right place on the current line. + (let ((org-columns-inhibit-recalculation)) (org-columns-redo)) + (org-columns-update key) + (org-move-to-column column)))))) + +(defun org-colview-construct-allowed-dates (s) + "Construct a list of three dates around the date in S. +This respects the format of the time stamp in S, active or non-active, +and also including time or not. S must be just a time stamp, no text +around it." + (when (and s (string-match (concat "^" org-ts-regexp3 "$") s)) + (let* ((time (org-parse-time-string s 'nodefaults)) + (active (equal (string-to-char s) ?<)) + (fmt (funcall (if (nth 1 time) 'cdr 'car) org-time-stamp-formats)) + time-before time-after) + (unless active (setq fmt (concat "[" (substring fmt 1 -1) "]"))) + (setf (car time) (or (car time) 0)) + (setf (nth 1 time) (or (nth 1 time) 0)) + (setf (nth 2 time) (or (nth 2 time) 0)) + (setq time-before (copy-sequence time)) + (setq time-after (copy-sequence time)) + (setf (nth 3 time-before) (1- (nth 3 time))) + (setf (nth 3 time-after) (1+ (nth 3 time))) + (mapcar (lambda (x) (format-time-string fmt (apply 'encode-time x))) + (list time-before time time-after))))) + +(defun org-columns-open-link (&optional arg) + (interactive "P") + (let ((value (get-char-property (point) 'org-columns-value))) + (org-open-link-from-string value arg))) + +;;;###autoload +(defun org-columns-get-format-and-top-level () + (let ((fmt (org-columns-get-format))) + (org-columns-goto-top-level) + fmt)) + +(defun org-columns-get-format (&optional fmt-string) + "Return columns format specifications. +When optional argument FMT-STRING is non-nil, use it as the +current specifications. This function also sets +`org-columns-current-fmt-compiled' and +`org-columns-current-fmt'." + (interactive) + (let ((format + (or fmt-string + (org-entry-get nil "COLUMNS" t) + (org-with-wide-buffer + (goto-char (point-min)) + (catch :found + (let ((case-fold-search t)) + (while (re-search-forward "^[ \t]*#\\+COLUMNS: .+$" nil t) + (let ((element (org-element-at-point))) + (when (eq (org-element-type element) 'keyword) + (throw :found (org-element-property :value element))))) + nil))) + org-columns-default-format))) + (setq org-columns-current-fmt format) + (org-columns-compile-format format) + format)) + +(defun org-columns-goto-top-level () + "Move to the beginning of the column view area. +Also sets `org-columns-top-level-marker' to the new position." + (goto-char + (move-marker + org-columns-top-level-marker + (cond ((org-before-first-heading-p) (point-min)) + ((org-entry-get nil "COLUMNS" t) org-entry-property-inherited-from) + (t (org-back-to-heading) (point)))))) + +;;;###autoload +(defun org-columns (&optional global columns-fmt-string) + "Turn on column view on an Org mode file. + +Column view applies to the whole buffer if point is before the +first headline. Otherwise, it applies to the first ancestor +setting \"COLUMNS\" property. If there is none, it defaults to +the current headline. With a `\\[universal-argument]' prefix \ +argument, turn on column +view for the whole buffer unconditionally. + +When COLUMNS-FMT-STRING is non-nil, use it as the column format." + (interactive "P") + (org-columns-remove-overlays) + (move-marker org-columns-begin-marker (point)) + (org-columns-goto-top-level) + ;; Initialize `org-columns-current-fmt' and + ;; `org-columns-current-fmt-compiled'. + (let ((org-columns--time (float-time (current-time)))) + (org-columns-get-format columns-fmt-string) + (unless org-columns-inhibit-recalculation (org-columns-compute-all)) + (save-excursion + (save-restriction + (when (and (not global) (org-at-heading-p)) + (narrow-to-region (point) (org-end-of-subtree t t))) + (when (assoc "CLOCKSUM" org-columns-current-fmt-compiled) + (org-clock-sum)) + (when (assoc "CLOCKSUM_T" org-columns-current-fmt-compiled) + (org-clock-sum-today)) + (let ((cache + ;; Collect contents of columns ahead of time so as to + ;; compute their maximum width. + (org-map-entries + (lambda () (cons (point) (org-columns--collect-values))) + nil nil (and org-columns-skip-archived-trees 'archive)))) + (when cache + (org-columns--set-widths cache) + (org-columns--display-here-title) + (when (setq-local org-columns-flyspell-was-active + (bound-and-true-p flyspell-mode)) + (flyspell-mode 0)) + (unless (local-variable-p 'org-colview-initial-truncate-line-value) + (setq-local org-colview-initial-truncate-line-value + truncate-lines)) + (setq truncate-lines t) + (dolist (entry cache) + (goto-char (car entry)) + (org-columns--display-here (cdr entry))))))))) + +(defun org-columns-new (&optional spec &rest attributes) + "Insert a new column, to the left of the current column. +Interactively fill attributes for new column. When column format +specification SPEC is provided, edit it instead. + +When optional argument attributes can be a list of columns +specifications attributes to create the new column +non-interactively. See `org-columns-compile-format' for +details." + (interactive) + (let ((new (or attributes + (let ((prop + (completing-read + "Property: " + (mapcar #'list (org-buffer-property-keys t nil t)) + nil nil (nth 0 spec)))) + (list prop + (read-string (format "Column title [%s]: " prop) + (nth 1 spec)) + ;; Use `read-string' instead of `read-number' + ;; to allow empty width. + (let ((w (read-string + "Column width: " + (and (nth 2 spec) + (number-to-string (nth 2 spec)))))) + (and (org-string-nw-p w) (string-to-number w))) + (org-string-nw-p + (completing-read + "Summary: " + (delete-dups + (cons '("") ;Allow empty operator. + (mapcar (lambda (x) (list (car x))) + (append + org-columns-summary-types + org-columns-summary-types-default)))) + nil t (nth 3 spec))) + (org-string-nw-p + (read-string "Format: " (nth 4 spec)))))))) + (if spec + (progn (setcar spec (car new)) + (setcdr spec (cdr new))) + (push new (nthcdr (current-column) org-columns-current-fmt-compiled))) + (org-columns-store-format) + (org-columns-redo))) + +(defun org-columns-delete () + "Delete the column at point from columns view." + (interactive) + (let ((spec (nth (current-column) org-columns-current-fmt-compiled))) + (when (y-or-n-p (format "Are you sure you want to remove column %S? " + (nth 1 spec))) + (setq org-columns-current-fmt-compiled + (delq spec org-columns-current-fmt-compiled)) + (org-columns-store-format) + ;; This may leave a now wrong value in a node property. However + ;; updating it may prove counter-intuitive. See comments in + ;; `org-columns-move-right' for details. + (let ((org-columns-inhibit-recalculation t)) (org-columns-redo)) + (when (>= (current-column) (length org-columns-current-fmt-compiled)) + (backward-char))))) + +(defun org-columns-edit-attributes () + "Edit the attributes of the current column." + (interactive) + (org-columns-new (nth (current-column) org-columns-current-fmt-compiled))) + +(defun org-columns-widen (arg) + "Make the column wider by ARG characters." + (interactive "p") + (let* ((n (current-column)) + (entry (nth n org-columns-current-fmt-compiled)) + (width (aref org-columns-current-maxwidths n))) + (setq width (max 1 (+ width arg))) + (setcar (nthcdr 2 entry) width) + (org-columns-store-format) + (let ((org-columns-inhibit-recalculation t)) (org-columns-redo)))) + +(defun org-columns-narrow (arg) + "Make the column narrower by ARG characters." + (interactive "p") + (org-columns-widen (- arg))) + +(defun org-columns-move-right () + "Swap this column with the one to the right." + (interactive) + (let* ((n (current-column)) + (cell (nthcdr n org-columns-current-fmt-compiled)) + e) + (when (>= n (1- (length org-columns-current-fmt-compiled))) + (error "Cannot shift this column further to the right")) + (setq e (car cell)) + (setcar cell (car (cdr cell))) + (setcdr cell (cons e (cdr (cdr cell)))) + (org-columns-store-format) + ;; Do not compute again properties, since we're just moving + ;; columns around. It can put a property value a bit off when + ;; switching between an non-computed and a computed value for the + ;; same property, e.g. from "%A %A{+}" to "%A{+} %A". + ;; + ;; In this case, the value needs to be updated since the first + ;; column related to a property determines how its value is + ;; computed. However, (correctly) updating the value could be + ;; surprising, so we leave it as-is nonetheless. + (let ((org-columns-inhibit-recalculation t)) (org-columns-redo)) + (forward-char 1))) + +(defun org-columns-move-left () + "Swap this column with the one to the left." + (interactive) + (let* ((n (current-column))) + (when (= n 0) + (error "Cannot shift this column further to the left")) + (backward-char 1) + (org-columns-move-right) + (backward-char 1))) + +(defun org-columns-store-format () + "Store the text version of the current columns format. +The format is stored either in the COLUMNS property of the node +starting the current column display, or in a #+COLUMNS line of +the current buffer." + (let ((fmt (org-columns-uncompile-format org-columns-current-fmt-compiled))) + (setq-local org-columns-current-fmt fmt) + (when (marker-position org-columns-top-level-marker) + (org-with-wide-buffer + (goto-char org-columns-top-level-marker) + (if (and (org-at-heading-p) (org-entry-get nil "COLUMNS")) + (org-entry-put nil "COLUMNS" fmt) + (goto-char (point-min)) + (let ((case-fold-search t)) + ;; Try to replace the first COLUMNS keyword available. + (catch :found + (while (re-search-forward "^[ \t]*#\\+COLUMNS:\\(.*\\)" nil t) + (let ((element (save-match-data (org-element-at-point)))) + (when (and (eq (org-element-type element) 'keyword) + (equal (org-element-property :key element) + "COLUMNS")) + (replace-match (concat " " fmt) t t nil 1) + (throw :found nil)))) + ;; No COLUMNS keyword in the buffer. Insert one at the + ;; beginning, right before the first heading, if any. + (goto-char (point-min)) + (unless (org-at-heading-p t) (outline-next-heading)) + (let ((inhibit-read-only t)) + (insert-before-markers "#+COLUMNS: " fmt "\n")))) + (setq-local org-columns-default-format fmt)))))) + +(defun org-columns-update (property) + "Recompute PROPERTY, and update the columns display for it." + (org-columns-compute property) + (org-with-wide-buffer + (let ((p (upcase property))) + (dolist (ov org-columns-overlays) + (let ((key (overlay-get ov 'org-columns-key))) + (when (and key (equal key p) (overlay-start ov)) + (goto-char (overlay-start ov)) + (let* ((spec (nth (current-column) org-columns-current-fmt-compiled)) + (value + (or (cdr (assoc spec + (get-text-property (line-beginning-position) + 'org-summaries))) + (org-entry-get (point) key)))) + (when value + (let ((displayed (org-columns--displayed-value spec value)) + (format (overlay-get ov 'org-columns-format)) + (width + (aref org-columns-current-maxwidths (current-column)))) + (overlay-put ov 'org-columns-value value) + (overlay-put ov 'org-columns-value-modified displayed) + (overlay-put ov + 'display + (org-columns--overlay-text + displayed format width property value))))))))))) + +(defun org-columns-redo () + "Construct the column display again." + (interactive) + (message "Recomputing columns...") + (org-with-wide-buffer + (when (marker-position org-columns-begin-marker) + (goto-char org-columns-begin-marker)) + (org-columns-remove-overlays) + (if (derived-mode-p 'org-mode) + ;; Since we already know the columns format, provide it instead + ;; of computing again. + (call-interactively #'org-columns org-columns-current-fmt) + (org-agenda-redo) + (call-interactively #'org-agenda-columns))) + (message "Recomputing columns...done")) + +(defun org-columns-uncompile-format (compiled) + "Turn the compiled columns format back into a string representation. +COMPILED is an alist, as returned by +`org-columns-compile-format', which see." + (mapconcat + (lambda (spec) + (pcase spec + (`(,prop ,title ,width ,op ,printf) + (concat "%" + (and width (number-to-string width)) + prop + (and title (not (equal prop title)) (format "(%s)" title)) + (cond ((not op) nil) + (printf (format "{%s;%s}" op printf)) + (t (format "{%s}" op))))))) + compiled " ")) + +(defun org-columns-compile-format (fmt) + "Turn a column format string FMT into an alist of specifications. + +The alist has one entry for each column in the format. The elements of +that list are: +property the property name, as an upper-case string +title the title field for the columns, as a string +width the column width in characters, can be nil for automatic width +operator the summary operator, as a string, or nil +printf a printf format for computed values, as a string, or nil + +This function updates `org-columns-current-fmt-compiled'." + (setq org-columns-current-fmt-compiled nil) + (let ((start 0)) + (while (string-match + "%\\([0-9]+\\)?\\([[:alnum:]_-]+\\)\\(?:(\\([^)]+\\))\\)?\ +\\(?:{\\([^}]+\\)}\\)?\\s-*" + fmt start) + (setq start (match-end 0)) + (let* ((width (and (match-end 1) (string-to-number (match-string 1 fmt)))) + (prop (match-string-no-properties 2 fmt)) + (title (or (match-string-no-properties 3 fmt) prop)) + (operator (match-string-no-properties 4 fmt))) + (push (if (not operator) (list (upcase prop) title width nil nil) + (let (printf) + (when (string-match ";" operator) + (setq printf (substring operator (match-end 0))) + (setq operator (substring operator 0 (match-beginning 0)))) + (list (upcase prop) title width operator printf))) + org-columns-current-fmt-compiled))) + (setq org-columns-current-fmt-compiled + (nreverse org-columns-current-fmt-compiled)))) + + +;;;; Column View Summary + +(defun org-columns--age-to-minutes (s) + "Turn age string S into a number of minutes. +An age is either computed from a given time-stamp, or indicated +as a canonical duration, i.e., using units defined in +`org-duration-canonical-units'." + (cond + ((string-match-p org-ts-regexp s) + (/ (- org-columns--time + (float-time (apply #'encode-time (org-parse-time-string s)))) + 60)) + ((org-duration-p s) (org-duration-to-minutes s t)) ;skip user units + (t (user-error "Invalid age: %S" s)))) + +(defun org-columns--format-age (minutes) + "Format MINUTES float as an age string." + (org-duration-from-minutes minutes + '(("d" . nil) ("h" . nil) ("min" . nil)) + t)) ;ignore user's custom units + +(defun org-columns--summary-apply-times (fun times) + "Apply FUN to time values TIMES. +Return the result as a duration." + (org-duration-from-minutes + (apply fun + (mapcar (lambda (time) + ;; Unlike to `org-duration-to-minutes' standard + ;; behavior, we want to consider plain numbers as + ;; hours. As a consequence, we treat them + ;; differently. + (if (string-match-p "\\`[0-9]+\\(?:\\.[0-9]*\\)?\\'" time) + (* 60 (string-to-number time)) + (org-duration-to-minutes time))) + times)) + (org-duration-h:mm-only-p times))) + +(defun org-columns--compute-spec (spec &optional update) + "Update tree according to SPEC. +SPEC is a column format specification. When optional argument +UPDATE is non-nil, summarized values can replace existing ones in +properties drawers." + (let* ((lmax (if (bound-and-true-p org-inlinetask-min-level) + org-inlinetask-min-level + 29)) ;Hard-code deepest level. + (lvals (make-vector (1+ lmax) nil)) + (level 0) + (inminlevel lmax) + (last-level lmax) + (property (car spec)) + (printf (nth 4 spec)) + (summarize (org-columns--summarize (nth 3 spec)))) + (org-with-wide-buffer + ;; Find the region to compute. + (goto-char org-columns-top-level-marker) + (goto-char (condition-case nil (org-end-of-subtree t) (error (point-max)))) + ;; Walk the tree from the back and do the computations. + (while (re-search-backward + org-outline-regexp-bol org-columns-top-level-marker t) + (unless (or (= level 0) (eq level inminlevel)) + (setq last-level level)) + (setq level (org-reduced-level (org-outline-level))) + (let* ((pos (match-beginning 0)) + (value (org-entry-get nil property)) + (value-set (org-string-nw-p value))) + (cond + ((< level last-level) + ;; Collect values from lower levels and inline tasks here + ;; and summarize them using SUMMARIZE. Store them in text + ;; property `org-summaries', in alist whose key is SPEC. + (let* ((summary + (and summarize + (let ((values (append (and (/= last-level inminlevel) + (aref lvals last-level)) + (aref lvals inminlevel)))) + (and values (funcall summarize values printf)))))) + ;; Leaf values are not summaries: do not mark them. + (when summary + (let* ((summaries-alist (get-text-property pos 'org-summaries)) + (old (assoc spec summaries-alist))) + (if old (setcdr old summary) + (push (cons spec summary) summaries-alist) + (org-with-silent-modifications + (add-text-properties + pos (1+ pos) (list 'org-summaries summaries-alist))))) + ;; When PROPERTY exists in current node, even if empty, + ;; but its value doesn't match the one computed, use + ;; the latter instead. + (when (and update value (not (equal value summary))) + (org-entry-put (point) property summary))) + ;; Add current to current level accumulator. + (when (or summary value-set) + (push (or summary value) (aref lvals level))) + ;; Clear accumulators for deeper levels. + (cl-loop for l from (1+ level) to lmax do (aset lvals l nil)))) + (value-set (push value (aref lvals level))) + (t nil))))))) + +;;;###autoload +(defun org-columns-compute (property) + "Summarize the values of PROPERTY hierarchically. +Also update existing values for PROPERTY according to the first +column specification." + (interactive) + (let ((main-flag t) + (upcase-prop (upcase property))) + (dolist (spec org-columns-current-fmt-compiled) + (pcase spec + (`(,(pred (equal upcase-prop)) . ,_) + (org-columns--compute-spec spec main-flag) + ;; Only the first summary can update the property value. + (when main-flag (setq main-flag nil))))))) + +(defun org-columns-compute-all () + "Compute all columns that have operators defined." + (org-with-silent-modifications + (remove-text-properties (point-min) (point-max) '(org-summaries t))) + (let ((org-columns--time (float-time (current-time))) + seen) + (dolist (spec org-columns-current-fmt-compiled) + (let ((property (car spec))) + ;; Property value is updated only the first time a given + ;; property is encountered. + (org-columns--compute-spec spec (not (member property seen))) + (push property seen))))) + +(defun org-columns--summary-sum (values printf) + "Compute the sum of VALUES. +When PRINTF is non-nil, use it to format the result." + (format (or printf "%s") (apply #'+ (mapcar #'string-to-number values)))) + +(defun org-columns--summary-currencies (values _) + "Compute the sum of VALUES, with two decimals." + (format "%.2f" (apply #'+ (mapcar #'string-to-number values)))) + +(defun org-columns--summary-checkbox (check-boxes _) + "Summarize CHECK-BOXES with a check-box." + (let ((done (cl-count "[X]" check-boxes :test #'equal)) + (all (length check-boxes))) + (cond ((= done all) "[X]") + ((> done 0) "[-]") + (t "[ ]")))) + +(defun org-columns--summary-checkbox-count (check-boxes _) + "Summarize CHECK-BOXES with a check-box cookie." + (format "[%d/%d]" + (cl-count "[X]" check-boxes :test #'equal) + (length check-boxes))) + +(defun org-columns--summary-checkbox-percent (check-boxes _) + "Summarize CHECK-BOXES with a check-box percent." + (format "[%d%%]" + (round (* 100.0 (cl-count "[X]" check-boxes :test #'equal)) + (float (length check-boxes))))) + +(defun org-columns--summary-min (values printf) + "Compute the minimum of VALUES. +When PRINTF is non-nil, use it to format the result." + (format (or printf "%s") + (apply #'min (mapcar #'string-to-number values)))) + +(defun org-columns--summary-max (values printf) + "Compute the maximum of VALUES. +When PRINTF is non-nil, use it to format the result." + (format (or printf "%s") + (apply #'max (mapcar #'string-to-number values)))) + +(defun org-columns--summary-mean (values printf) + "Compute the mean of VALUES. +When PRINTF is non-nil, use it to format the result." + (format (or printf "%s") + (/ (apply #'+ (mapcar #'string-to-number values)) + (float (length values))))) + +(defun org-columns--summary-sum-times (times _) + "Sum TIMES." + (org-columns--summary-apply-times #'+ times)) + +(defun org-columns--summary-min-time (times _) + "Compute the minimum time among TIMES." + (org-columns--summary-apply-times #'min times)) + +(defun org-columns--summary-max-time (times _) + "Compute the maximum time among TIMES." + (org-columns--summary-apply-times #'max times)) + +(defun org-columns--summary-mean-time (times _) + "Compute the mean time among TIMES." + (org-columns--summary-apply-times + (lambda (&rest values) (/ (apply #'+ values) (float (length values)))) + times)) + +(defun org-columns--summary-min-age (ages _) + "Compute the minimum time among AGES." + (org-columns--format-age + (apply #'min (mapcar #'org-columns--age-to-minutes ages)))) + +(defun org-columns--summary-max-age (ages _) + "Compute the maximum time among AGES." + (org-columns--format-age + (apply #'max (mapcar #'org-columns--age-to-minutes ages)))) + +(defun org-columns--summary-mean-age (ages _) + "Compute the minimum time among AGES." + (org-columns--format-age + (/ (apply #'+ (mapcar #'org-columns--age-to-minutes ages)) + (float (length ages))))) + +(defun org-columns--summary-estimate (estimates printf) + "Combine a list of estimates, using mean and variance. +The mean and variance of the result will be the sum of the means +and variances (respectively) of the individual estimates." + (let ((mean 0) + (var 0)) + (dolist (e estimates) + (pcase (mapcar #'string-to-number (split-string e "-")) + (`(,low ,high) + (let ((m (/ (+ low high) 2.0))) + (cl-incf mean m) + (cl-incf var (- (/ (+ (* low low) (* high high)) 2.0) (* m m))))) + (`(,value) (cl-incf mean value)))) + (let ((sd (sqrt var))) + (format "%s-%s" + (format (or printf "%.0f") (- mean sd)) + (format (or printf "%.0f") (+ mean sd)))))) + + + +;;; Dynamic block for Column view + +(defun org-columns--capture-view (maxlevel skip-empty format local) + "Get the column view of the current buffer. + +MAXLEVEL sets the level limit. SKIP-EMPTY tells whether to skip +empty rows, an empty row being one where all the column view +specifiers but ITEM are empty. FORMAT is a format string for +columns, or nil. When LOCAL is non-nil, only capture headings in +current subtree. + +This function returns a list containing the title row and all +other rows. Each row is a list of fields, as strings, or +`hline'." + (org-columns (not local) format) + (goto-char org-columns-top-level-marker) + (let ((columns (length org-columns-current-fmt-compiled)) + (has-item (assoc "ITEM" org-columns-current-fmt-compiled)) + table) + (org-map-entries + (lambda () + (when (get-char-property (point) 'org-columns-key) + (let (row) + (dotimes (i columns) + (let* ((col (+ (line-beginning-position) i)) + (p (get-char-property col 'org-columns-key))) + (push (org-quote-vert + (get-char-property col + (if (string= p "ITEM") + 'org-columns-value + 'org-columns-value-modified))) + row))) + (unless (and skip-empty + (let ((r (delete-dups (remove "" row)))) + (or (null r) (and has-item (= (length r) 1))))) + (push (cons (org-reduced-level (org-current-level)) (nreverse row)) + table))))) + (and maxlevel (format "LEVEL<=%d" maxlevel)) + (and local 'tree) + 'archive 'comment) + (org-columns-quit) + ;; Add column titles and a horizontal rule in front of the table. + (cons (mapcar #'cadr org-columns-current-fmt-compiled) + (cons 'hline (nreverse table))))) + +(defun org-columns--clean-item (item) + "Remove sensitive contents from string ITEM. +This includes objects that may not be duplicated within +a document, e.g., a target, or those forbidden in tables, e.g., +an inline src-block." + (let ((data (org-element-parse-secondary-string + item (org-element-restriction 'headline)))) + (org-element-map data + '(footnote-reference inline-babel-call inline-src-block target + radio-target statistics-cookie) + #'org-element-extract-element) + (org-no-properties (org-element-interpret-data data)))) + +;;;###autoload +(defun org-dblock-write:columnview (params) + "Write the column view table. +PARAMS is a property list of parameters: + +:id the :ID: property of the entry where the columns view + should be built. When the symbol `local', call locally. + When `global' call column view with the cursor at the beginning + of the buffer (usually this means that the whole buffer switches + to column view). When \"file:path/to/file.org\", invoke column + view at the start of that file. Otherwise, the ID is located + using `org-id-find'. +:hlines When t, insert a hline before each item. When a number, insert + a hline before each level <= that number. +:indent When non-nil, indent each ITEM field according to its level. +:vlines When t, make each column a colgroup to enforce vertical lines. +:maxlevel When set to a number, don't capture headlines below this level. +:skip-empty-rows + When t, skip rows where all specifiers other than ITEM are empty. +:width apply widths specified in columns format using specifiers. +:format When non-nil, specify the column view format to use." + (let ((table + (let ((id (plist-get params :id)) + view-file view-pos) + (pcase id + (`global nil) + ((or `local `nil) (setq view-pos (point))) + ((and (let id-string (format "%s" id)) + (guard (string-match "^file:\\(.*\\)" id-string))) + (setq view-file (match-string-no-properties 1 id-string)) + (unless (file-exists-p view-file) + (user-error "No such file: %S" id-string))) + ((and (let idpos (org-find-entry-with-id id)) (guard idpos)) + (setq view-pos idpos)) + ((let `(,filename . ,position) (org-id-find id)) + (setq view-file filename) + (setq view-pos position)) + (_ (user-error "Cannot find entry with :ID: %s" id))) + (with-current-buffer (if view-file (get-file-buffer view-file) + (current-buffer)) + (org-with-wide-buffer + (when view-pos (goto-char view-pos)) + (org-columns--capture-view (plist-get params :maxlevel) + (plist-get params :skip-empty-rows) + (plist-get params :format) + view-pos)))))) + (when table + ;; Prune level information from the table. Also normalize + ;; headings: remove stars, add indentation entities, if + ;; required, and possibly precede some of them with a horizontal + ;; rule. + (let ((item-index + (let ((p (assoc "ITEM" org-columns-current-fmt-compiled))) + (and p (cl-position p + org-columns-current-fmt-compiled + :test #'equal)))) + (hlines (plist-get params :hlines)) + (indent (plist-get params :indent)) + new-table) + ;; Copy header and first rule. + (push (pop table) new-table) + (push (pop table) new-table) + (dolist (row table (setq table (nreverse new-table))) + (let ((level (car row))) + (when (and (not (eq (car new-table) 'hline)) + (or (eq hlines t) + (and (numberp hlines) (<= level hlines)))) + (push 'hline new-table)) + (when item-index + (let ((item (org-columns--clean-item (nth item-index (cdr row))))) + (setf (nth item-index (cdr row)) + (if (and indent (> level 1)) + (concat "\\_" (make-string (* 2 (1- level)) ?\s) item) + item)))) + (push (cdr row) new-table)))) + (when (plist-get params :width) + (setq table + (append table + (list + (mapcar (lambda (spec) + (let ((w (nth 2 spec))) + (if w (format "<%d>" (max 3 w)) ""))) + org-columns-current-fmt-compiled))))) + (when (plist-get params :vlines) + (setq table + (let ((size (length org-columns-current-fmt-compiled))) + (append (mapcar (lambda (x) (if (eq 'hline x) x (cons "" x))) + table) + (list (cons "/" (make-list size "<>"))))))) + (let ((content-lines (org-split-string (plist-get params :content) "\n")) + recalc) + ;; Insert affiliated keywords before the table. + (when content-lines + (while (string-match-p "\\`[ \t]*#\\+" (car content-lines)) + (insert (pop content-lines) "\n"))) + (save-excursion + ;; Insert table at point. + (insert + (mapconcat (lambda (row) + (if (eq row 'hline) "|-|" + (format "|%s|" (mapconcat #'identity row "|")))) + table + "\n")) + ;; Insert TBLFM lines following table. + (let ((case-fold-search t)) + (dolist (line content-lines) + (when (string-match-p "\\`[ \t]*#\\+TBLFM:" line) + (insert "\n" line) + (unless recalc (setq recalc t)))))) + (when recalc (org-table-recalculate 'all t)) + (org-table-align))))) + +;;;###autoload +(defun org-columns-insert-dblock () + "Create a dynamic block capturing a column view table." + (interactive) + (let ((id (completing-read + "Capture columns (local, global, entry with :ID: property) [local]: " + (append '(("global") ("local")) + (mapcar #'list (org-property-values "ID")))))) + (org-create-dblock + (list :name "columnview" + :hlines 1 + :id (cond ((string= id "global") 'global) + ((member id '("" "local")) 'local) + (id))))) + (org-update-dblock)) + + + +;;; Column view in the agenda + +;;;###autoload +(defun org-agenda-columns () + "Turn on or update column view in the agenda." + (interactive) + (org-columns-remove-overlays) + (move-marker org-columns-begin-marker (point)) + (let* ((org-columns--time (float-time (current-time))) + (fmt + (cond + ((bound-and-true-p org-agenda-overriding-columns-format)) + ((let ((m (org-get-at-bol 'org-hd-marker))) + (and m + (or (org-entry-get m "COLUMNS" t) + (with-current-buffer (marker-buffer m) + org-columns-default-format))))) + ((and (local-variable-p 'org-columns-current-fmt) + org-columns-current-fmt)) + ((let ((m (next-single-property-change (point-min) 'org-hd-marker))) + (and m + (let ((m (get-text-property m 'org-hd-marker))) + (or (org-entry-get m "COLUMNS" t) + (with-current-buffer (marker-buffer m) + org-columns-default-format)))))) + (t org-columns-default-format))) + (compiled-fmt (org-columns-compile-format fmt))) + (setq org-columns-current-fmt fmt) + (when org-agenda-columns-compute-summary-properties + (org-agenda-colview-compute org-columns-current-fmt-compiled)) + (save-excursion + ;; Collect properties for each headline in current view. + (goto-char (point-min)) + (let (cache) + (while (not (eobp)) + (let ((m (or (org-get-at-bol 'org-hd-marker) + (org-get-at-bol 'org-marker)))) + (when m + (push (cons (line-beginning-position) + ;; `org-columns-current-fmt-compiled' is + ;; initialized but only set locally to the + ;; agenda buffer. Since current buffer is + ;; changing, we need to force the original + ;; compiled-fmt there. + (org-with-point-at m + (org-columns--collect-values compiled-fmt))) + cache))) + (forward-line)) + (when cache + (org-columns--set-widths cache) + (org-columns--display-here-title) + (when (setq-local org-columns-flyspell-was-active + (bound-and-true-p flyspell-mode)) + (flyspell-mode 0)) + (dolist (entry cache) + (goto-char (car entry)) + (org-columns--display-here (cdr entry))) + (when org-agenda-columns-show-summaries + (org-agenda-colview-summarize cache))))))) + +(defun org-agenda-colview-summarize (cache) + "Summarize the summarizable columns in column view in the agenda. +This will add overlays to the date lines, to show the summary for each day." + (let ((fmt (mapcar + (lambda (spec) + (pcase spec + (`(,property ,title ,width . ,_) + (if (member property '("CLOCKSUM" "CLOCKSUM_T")) + (list property title width ":" nil) + spec)))) + org-columns-current-fmt-compiled))) + ;; Ensure there's at least one summation column. + (when (cl-some (lambda (spec) (nth 3 spec)) fmt) + (goto-char (point-max)) + (catch :complete + (while t + (when (or (get-text-property (point) 'org-date-line) + (eq (get-text-property (point) 'face) + 'org-agenda-structure)) + ;; OK, this is a date line that should be used. + (let (entries) + (let (rest) + (dolist (c cache) + (if (> (car c) (point)) + (push c entries) + (push c rest))) + (setq cache rest)) + ;; ENTRIES contains entries below the current one. + ;; CACHE is the rest. Compute the summaries for the + ;; properties we want, set nil properties for the rest. + (when (setq entries (mapcar #'cdr entries)) + (org-columns--display-here + (mapcar + (lambda (spec) + (pcase spec + (`("ITEM" . ,_) + ;; Replace ITEM with current date. Preserve + ;; properties for fontification. + (let ((date (buffer-substring + (line-beginning-position) + (line-end-position)))) + (list spec date date))) + (`(,_ ,_ ,_ nil ,_) (list spec "" "")) + (`(,_ ,_ ,_ ,operator ,printf) + (let* ((summarize (org-columns--summarize operator)) + (values + ;; Use real values for summary, not + ;; those prepared for display. + (delq nil + (mapcar + (lambda (e) (org-string-nw-p + (nth 1 (assoc spec e)))) + entries))) + (final (if values + (funcall summarize values printf) + ""))) + (unless (equal final "") + (put-text-property 0 (length final) + 'face 'bold final)) + (list spec final final))))) + fmt) + 'dateline) + (setq-local org-agenda-columns-active t)))) + (if (bobp) (throw :complete t) (forward-line -1))))))) + +(defun org-agenda-colview-compute (fmt) + "Compute the relevant columns in the contributing source buffers." + (let ((files org-agenda-contributing-files) + (org-columns-begin-marker (make-marker)) + (org-columns-top-level-marker (make-marker))) + (dolist (f files) + (let ((b (find-buffer-visiting f))) + (with-current-buffer (or (buffer-base-buffer b) b) + (org-with-wide-buffer + (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) + (dolist (spec fmt) + (let ((prop (car spec))) + (cond + ((equal prop "CLOCKSUM") (org-clock-sum)) + ((equal prop "CLOCKSUM_T") (org-clock-sum-today)) + ((and (nth 3 spec) + (let ((a (assoc prop org-columns-current-fmt-compiled))) + (equal (nth 3 a) (nth 3 spec)))) + (org-columns-compute prop))))))))))) + + +(provide 'org-colview) + +;;; org-colview.el ends here diff --git a/elpa/org-plus-contrib-20170407/org-compat.el b/elpa/org-plus-contrib-20170407/org-compat.el new file mode 100644 index 00000000..8106c5e2 --- /dev/null +++ b/elpa/org-plus-contrib-20170407/org-compat.el @@ -0,0 +1,575 @@ +;;; org-compat.el --- Compatibility Code for Older Emacsen -*- lexical-binding: t; -*- + +;; Copyright (C) 2004-2017 Free Software Foundation, Inc. + +;; Author: Carsten Dominik +;; 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 . +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;;; Commentary: + +;; This file contains code needed for compatibility with older +;; versions of GNU Emacs. + +;;; Code: + +(require 'cl-lib) +(require 'org-macs) + +(declare-function org-at-table.el-p "org" (&optional table-type)) +(declare-function org-element-at-point "org-element" ()) +(declare-function org-element-type "org-element" (element)) +(declare-function org-end-of-subtree "org" (&optional invisible-ok to-heading)) +(declare-function org-link-set-parameters "org" (type &rest rest)) +(declare-function org-table-end (&optional table-type)) +(declare-function outline-next-heading "outline" ()) +(declare-function table--at-cell-p "table" (position &optional object at-column)) + +(defvar org-table-any-border-regexp) +(defvar org-table-dataline-regexp) +(defvar org-table-tab-recognizes-table.el) +(defvar org-table1-hline-regexp) + +;;; Emacs < 25.1 compatibility + +(when (< emacs-major-version 25) + (defalias 'outline-hide-entry 'hide-entry) + (defalias 'outline-hide-sublevels 'hide-sublevels) + (defalias 'outline-hide-subtree 'hide-subtree) + (defalias 'outline-show-all 'show-all) + (defalias 'outline-show-branches 'show-branches) + (defalias 'outline-show-children 'show-children) + (defalias 'outline-show-entry 'show-entry) + (defalias 'outline-show-subtree 'show-subtree) + (defalias 'xref-find-definitions 'find-tag) + (defalias 'format-message 'format) + (defalias 'gui-get-selection 'x-get-selection)) + +(unless (fboundp 'directory-name-p) + (defun directory-name-p (name) + "Return non-nil if NAME ends with a directory separator character." + (let ((len (length name)) + (lastc ?.)) + (if (> len 0) + (setq lastc (aref name (1- len)))) + (or (= lastc ?/) + (and (memq system-type '(windows-nt ms-dos)) + (= lastc ?\\)))))) + +(unless (fboundp 'directory-files-recursively) + (defun directory-files-recursively (dir regexp &optional include-directories) + "Return list of all files under DIR that have file names matching REGEXP. +This function works recursively. Files are returned in \"depth first\" +order, and files from each directory are sorted in alphabetical order. +Each file name appears in the returned list in its absolute form. +Optional argument INCLUDE-DIRECTORIES non-nil means also include in the +output directories whose names match REGEXP." + (let ((result nil) + (files nil) + ;; When DIR is "/", remote file names like "/method:" could + ;; also be offered. We shall suppress them. + (tramp-mode (and tramp-mode (file-remote-p (expand-file-name dir))))) + (dolist (file (sort (file-name-all-completions "" dir) + 'string<)) + (unless (member file '("./" "../")) + (if (directory-name-p file) + (let* ((leaf (substring file 0 (1- (length file)))) + (full-file (expand-file-name leaf dir))) + ;; Don't follow symlinks to other directories. + (unless (file-symlink-p full-file) + (setq result + (nconc result (directory-files-recursively + full-file regexp include-directories)))) + (when (and include-directories + (string-match regexp leaf)) + (setq result (nconc result (list full-file))))) + (when (string-match regexp file) + (push (expand-file-name file dir) files))))) + (nconc result (nreverse files))))) + + +;;; Obsolete aliases (remove them once the next major release is released). + +;;;; XEmacs compatibility, now removed. +(define-obsolete-function-alias 'org-activate-mark 'activate-mark) +(define-obsolete-function-alias 'org-add-hook 'add-hook "Org 9.0") +(define-obsolete-function-alias 'org-bound-and-true-p 'bound-and-true-p "Org 9.0") +(define-obsolete-function-alias 'org-decompose-region 'decompose-region "Org 9.0") +(define-obsolete-function-alias 'org-defvaralias 'defvaralias "Org 9.0") +(define-obsolete-function-alias 'org-detach-overlay 'delete-overlay "Org 9.0") +(define-obsolete-function-alias 'org-file-equal-p 'file-equal-p "Org 9.0") +(define-obsolete-function-alias 'org-float-time 'float-time "Org 9.0") +(define-obsolete-function-alias 'org-indent-line-to 'indent-line-to "Org 9.0") +(define-obsolete-function-alias 'org-indent-to-column 'indent-to-column "Org 9.0") +(define-obsolete-function-alias 'org-looking-at-p 'looking-at-p "Org 9.0") +(define-obsolete-function-alias 'org-looking-back 'looking-back "Org 9.0") +(define-obsolete-function-alias 'org-match-string-no-properties 'match-string-no-properties "Org 9.0") +(define-obsolete-function-alias 'org-propertize 'propertize "Org 9.0") +(define-obsolete-function-alias 'org-select-frame-set-input-focus 'select-frame-set-input-focus "Org 9.0") + +(defmacro org-re (s) + "Replace posix classes in regular expression S." + (declare (debug (form)) + (obsolete "you can safely remove it." "Org 9.0")) + s) + +;;;; Functions from cl-lib that Org used to have its own implementation of. +(define-obsolete-function-alias 'org-count 'cl-count "Org 9.0") +(define-obsolete-function-alias 'org-every 'cl-every "Org 9.0") +(define-obsolete-function-alias 'org-find-if 'cl-find-if "Org 9.0") +(define-obsolete-function-alias 'org-reduce 'cl-reduce "Org 9.0") +(define-obsolete-function-alias 'org-remove-if 'cl-remove-if "Org 9.0") +(define-obsolete-function-alias 'org-remove-if-not 'cl-remove-if-not "Org 9.0") +(define-obsolete-function-alias 'org-some 'cl-some "Org 9.0") +(define-obsolete-function-alias 'org-floor* 'cl-floor "Org 9.0") + +(defun org-sublist (list start end) + "Return a section of LIST, from START to END. +Counting starts at 1." + (cl-subseq list (1- start) end)) +(make-obsolete 'org-sublist + "use cl-subseq (note the 0-based counting)." + "Org 9.0") + + +;;;; Functions available since Emacs 24.3 +(define-obsolete-function-alias 'org-buffer-narrowed-p 'buffer-narrowed-p "Org 9.0") +(define-obsolete-function-alias 'org-called-interactively-p 'called-interactively-p "Org 9.0") +(define-obsolete-function-alias 'org-char-to-string 'char-to-string "Org 9.0") +(define-obsolete-function-alias 'org-delete-directory 'delete-directory "Org 9.0") +(define-obsolete-function-alias 'org-format-seconds 'format-seconds "Org 9.0") +(define-obsolete-function-alias 'org-link-escape-browser 'url-encode-url "Org 9.0") +(define-obsolete-function-alias 'org-no-warnings 'with-no-warnings "Org 9.0") +(define-obsolete-function-alias 'org-number-sequence 'number-sequence "Org 9.0") +(define-obsolete-function-alias 'org-pop-to-buffer-same-window 'pop-to-buffer-same-window "Org 9.0") +(define-obsolete-function-alias 'org-string-match-p 'string-match-p "Org 9.0") + +;;;; Functions and variables from previous releases now obsolete. +(define-obsolete-function-alias 'org-element-remove-indentation + 'org-remove-indentation "Org 9.0") +(define-obsolete-variable-alias 'org-latex-create-formula-image-program + 'org-preview-latex-default-process "Org 9.0") +(define-obsolete-variable-alias 'org-latex-preview-ltxpng-directory + 'org-preview-latex-image-directory "Org 9.0") +(define-obsolete-function-alias 'org-table-p 'org-at-table-p "Org 9.0") +(define-obsolete-function-alias 'org-on-heading-p 'org-at-heading-p "Org 9.0") +(define-obsolete-function-alias 'org-at-regexp-p 'org-in-regexp "Org 8.3") +(define-obsolete-function-alias 'org-image-file-name-regexp + 'image-file-name-regexp "Org 9.0") +(define-obsolete-function-alias 'org-completing-read-no-i + 'completing-read "Org 9.0") +(define-obsolete-function-alias 'org-icompleting-read + 'completing-read "Org 9.0") +(define-obsolete-function-alias 'org-iread-file-name 'read-file-name "Org 9.0") +(define-obsolete-function-alias 'org-days-to-time + 'org-time-stamp-to-now "Org 8.2") +(define-obsolete-variable-alias 'org-agenda-ignore-drawer-properties + 'org-agenda-ignore-properties "Org 9.0") +(define-obsolete-function-alias 'org-preview-latex-fragment + 'org-toggle-latex-fragment "Org 8.3") +(define-obsolete-function-alias 'org-export-get-genealogy + 'org-element-lineage "Org 9.0") +(define-obsolete-variable-alias 'org-latex-with-hyperref + 'org-latex-hyperref-template "Org 9.0") +(define-obsolete-variable-alias 'hfy-optimisations 'hfy-optimizations "Org 9.0") +(define-obsolete-variable-alias 'org-export-htmlized-org-css-url + 'org-org-htmlized-css-url "Org 8.2") +(define-obsolete-function-alias 'org-list-parse-list 'org-list-to-lisp "Org 9.0") +(define-obsolete-function-alias 'org-agenda-todayp + 'org-agenda-today-p "Org 9.0") +(define-obsolete-function-alias 'org-babel-examplize-region + 'org-babel-examplify-region "Org 9.0") +(define-obsolete-variable-alias 'org-babel-capitalize-example-region-markers + 'org-babel-uppercase-example-markers "Org 9.1") + +(define-obsolete-function-alias 'org-babel-trim 'org-trim "Org 9.0") +(define-obsolete-variable-alias 'org-html-style 'org-html-head "24.4") +(define-obsolete-function-alias 'org-insert-columns-dblock + 'org-columns-insert-dblock "Org 9.0") +(define-obsolete-variable-alias 'org-export-babel-evaluate + 'org-export-use-babel "Org 9.1") + +(defun org-in-fixed-width-region-p () + "Non-nil if point in a fixed-width region." + (save-match-data + (eq 'fixed-width (org-element-type (org-element-at-point))))) +(make-obsolete 'org-in-fixed-width-region-p + "use `org-element' library" + "Org 9.0") + +(defun org-compatible-face (inherits specs) + "Make a compatible face specification. +If INHERITS is an existing face and if the Emacs version supports +it, just inherit the face. If INHERITS is not given and SPECS +is, use SPECS to define the face." + (declare (indent 1)) + (if (facep inherits) + (list (list t :inherit inherits)) + specs)) +(make-obsolete 'org-compatible-face "you can remove it." "Org 9.0") + +(defun org-add-link-type (type &optional follow export) + "Add a new TYPE link. +FOLLOW and EXPORT are two functions. + +FOLLOW should take the link path as the single argument and do whatever +is necessary to follow the link, for example find a file or display +a mail message. + +EXPORT should format the link path for export to one of the export formats. +It should be a function accepting three arguments: + + path the path of the link, the text after the prefix (like \"http:\") + desc the description of the link, if any + format the export format, a symbol like `html' or `latex' or `ascii'. + +The function may use the FORMAT information to return different values +depending on the format. The return value will be put literally into +the exported file. If the return value is nil, this means Org should +do what it normally does with links which do not have EXPORT defined. + +Org mode has a built-in default for exporting links. If you are happy with +this default, there is no need to define an export function for the link +type. For a simple example of an export function, see `org-bbdb.el'. + +If TYPE already exists, update it with the arguments. +See `org-link-parameters' for documentation on the other parameters." + (org-link-set-parameters type :follow follow :export export) + (message "Created %s link." type)) + +(make-obsolete 'org-add-link-type "use `org-link-set-parameters' instead." "Org 9.0") + +(defun org-table-recognize-table.el () + "If there is a table.el table nearby, recognize it and move into it." + (when (and org-table-tab-recognizes-table.el (org-at-table.el-p)) + (beginning-of-line) + (unless (or (looking-at org-table-dataline-regexp) + (not (looking-at org-table1-hline-regexp))) + (forward-line) + (when (looking-at org-table-any-border-regexp) + (forward-line -2))) + (if (re-search-forward "|" (org-table-end t) t) + (progn + (require 'table) + (if (table--at-cell-p (point)) t + (message "recognizing table.el table...") + (table-recognize-table) + (message "recognizing table.el table...done"))) + (error "This should not happen")))) + +;; Not used by Org core since commit 6d1e3082, Feb 2010. +(make-obsolete 'org-table-recognize-table.el + "please notify the org mailing list if you use this function." + "Org 9.0") + +(defun org-remove-angle-brackets (s) + (org-unbracket-string "<" ">" s)) +(make-obsolete 'org-remove-angle-brackets 'org-unbracket-string "Org 9.0") + +(defun org-remove-double-quotes (s) + (org-unbracket-string "\"" "\"" s)) +(make-obsolete 'org-remove-double-quotes 'org-unbracket-string "Org 9.0") + +(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) +(make-obsolete-variable + 'org-publish-sitemap-file-entry-format + "set `:sitemap-format-entry' in `org-publish-project-alist' instead." + "Org 9.1") + +(defvar org-agenda-skip-regexp) +(defun org-agenda-skip-entry-when-regexp-matches () + "Check if the current entry contains match for `org-agenda-skip-regexp'. +If yes, it returns the end position of this entry, causing agenda commands +to skip the entry but continuing the search in the subtree. This is a +function that can be put into `org-agenda-skip-function' for the duration +of a command." + (declare (obsolete "use `org-agenda-skip-if' instead." "Org 9.1")) + (let ((end (save-excursion (org-end-of-subtree t))) + skip) + (save-excursion + (setq skip (re-search-forward org-agenda-skip-regexp end t))) + (and skip end))) + +(defun org-agenda-skip-subtree-when-regexp-matches () + "Check if the current subtree contains match for `org-agenda-skip-regexp'. +If yes, it returns the end position of this tree, causing agenda commands +to skip this subtree. This is a function that can be put into +`org-agenda-skip-function' for the duration of a command." + (declare (obsolete "use `org-agenda-skip-if' instead." "Org 9.1")) + (let ((end (save-excursion (org-end-of-subtree t))) + skip) + (save-excursion + (setq skip (re-search-forward org-agenda-skip-regexp end t))) + (and skip end))) + +(defun org-agenda-skip-entry-when-regexp-matches-in-subtree () + "Check if the current subtree contains match for `org-agenda-skip-regexp'. +If yes, it returns the end position of the current entry (NOT the tree), +causing agenda commands to skip the entry but continuing the search in +the subtree. This is a function that can be put into +`org-agenda-skip-function' for the duration of a command. An important +use of this function is for the stuck project list." + (declare (obsolete "use `org-agenda-skip-if' instead." "Org 9.1")) + (let ((end (save-excursion (org-end-of-subtree t))) + (entry-end (save-excursion (outline-next-heading) (1- (point)))) + skip) + (save-excursion + (setq skip (re-search-forward org-agenda-skip-regexp end t))) + (and skip entry-end))) + +(define-obsolete-function-alias 'org-minutes-to-clocksum-string + 'org-duration-from-minutes "Org 9.1") + +(define-obsolete-function-alias 'org-hh:mm-string-to-minutes + 'org-duration-to-minutes "Org 9.1") + +(define-obsolete-function-alias 'org-duration-string-to-minutes + 'org-duration-to-minutes "Org 9.1") + +(make-obsolete-variable 'org-time-clocksum-format + "set `org-duration-format' instead." "Org 9.1") + +(make-obsolete-variable 'org-time-clocksum-use-fractional + "set `org-duration-format' instead." "Org 9.1") + +(make-obsolete-variable 'org-time-clocksum-fractional-format + "set `org-duration-format' instead." "Org 9.1") + +(make-obsolete-variable 'org-time-clocksum-use-effort-durations + "set `org-duration-units' instead." "Org 9.1") + + +;;;; Obsolete link types + +(eval-after-load 'org + '(progn + (org-link-set-parameters "file+emacs") ;since Org 9.0 + (org-link-set-parameters "file+sys"))) ;since Org 9.0 + + + +;;; Miscellaneous functions + +(defun org-version-check (version feature level) + (let* ((v1 (mapcar 'string-to-number (split-string version "[.]"))) + (v2 (mapcar 'string-to-number (split-string emacs-version "[.]"))) + (rmaj (or (nth 0 v1) 99)) + (rmin (or (nth 1 v1) 99)) + (rbld (or (nth 2 v1) 99)) + (maj (or (nth 0 v2) 0)) + (min (or (nth 1 v2) 0)) + (bld (or (nth 2 v2) 0))) + (if (or (< maj rmaj) + (and (= maj rmaj) + (< min rmin)) + (and (= maj rmaj) + (= min rmin) + (< bld rbld))) + (if (eq level :predicate) + ;; just return if we have the version + nil + (let ((msg (format "Emacs %s or greater is recommended for %s" + version feature))) + (display-warning 'org msg level) + t)) + t))) + +(defun org-get-x-clipboard (value) + "Get the value of the X or Windows clipboard." + (cond ((and (eq window-system 'x) + (fboundp 'gui-get-selection)) ;Silence byte-compiler. + (org-no-properties + (ignore-errors + (or (gui-get-selection value 'UTF8_STRING) + (gui-get-selection value 'COMPOUND_TEXT) + (gui-get-selection value 'STRING) + (gui-get-selection value 'TEXT))))) + ((and (eq window-system 'w32) (fboundp 'w32-get-clipboard-data)) + (w32-get-clipboard-data)))) + +(defun org-add-props (string plist &rest props) + "Add text properties to entire string, from beginning to end. +PLIST may be a list of properties, PROPS are individual properties and values +that will be added to PLIST. Returns the string that was modified." + (add-text-properties + 0 (length string) (if props (append plist props) plist) string) + string) +(put 'org-add-props 'lisp-indent-function 2) + +(defun org-fit-window-to-buffer (&optional window max-height min-height + shrink-only) + "Fit WINDOW to the buffer, but only if it is not a side-by-side window. +WINDOW defaults to the selected window. MAX-HEIGHT and MIN-HEIGHT are +passed through to `fit-window-to-buffer'. If SHRINK-ONLY is set, call +`shrink-window-if-larger-than-buffer' instead, the height limit is +ignored in this case." + (cond ((if (fboundp 'window-full-width-p) + (not (window-full-width-p window)) + ;; do nothing if another window would suffer + (> (frame-width) (window-width window)))) + ((and (fboundp 'fit-window-to-buffer) (not shrink-only)) + (fit-window-to-buffer window max-height min-height)) + ((fboundp 'shrink-window-if-larger-than-buffer) + (shrink-window-if-larger-than-buffer window))) + (or window (selected-window))) + +;; `set-transient-map' is only in Emacs >= 24.4 +(defalias 'org-set-transient-map + (if (fboundp 'set-transient-map) + 'set-transient-map + 'set-temporary-overlay-map)) + +;;; Region compatibility + +(defvar org-ignore-region nil + "Non-nil means temporarily disable the active region.") + +(defun org-region-active-p () + "Non-nil when the region active. +Unlike to `use-region-p', this function also checks +`org-ignore-region'." + (and (not org-ignore-region) (use-region-p))) + +(defun org-cursor-to-region-beginning () + (when (and (org-region-active-p) + (> (point) (region-beginning))) + (exchange-point-and-mark))) + +;;; Invisibility compatibility + +(defun org-remove-from-invisibility-spec (arg) + "Remove elements from `buffer-invisibility-spec'." + (if (fboundp 'remove-from-invisibility-spec) + (remove-from-invisibility-spec arg) + (if (consp buffer-invisibility-spec) + (setq buffer-invisibility-spec + (delete arg buffer-invisibility-spec))))) + +(defun org-in-invisibility-spec-p (arg) + "Is ARG a member of `buffer-invisibility-spec'?" + (if (consp buffer-invisibility-spec) + (member arg buffer-invisibility-spec))) + +(defun org-move-to-column (column &optional force _buffer) + "Move to column COLUMN. +Pass COLUMN and FORCE to `move-to-column'." + (let ((buffer-invisibility-spec + (if (listp buffer-invisibility-spec) + (remove '(org-filtered) buffer-invisibility-spec) + buffer-invisibility-spec))) + (move-to-column column force))) + +(defmacro org-find-library-dir (library) + `(file-name-directory (or (locate-library ,library) ""))) + +(defun org-count-lines (s) + "How many lines in string S?" + (let ((start 0) (n 1)) + (while (string-match "\n" s start) + (setq start (match-end 0) n (1+ n))) + (if (and (> (length s) 0) (= (aref s (1- (length s))) ?\n)) + (setq n (1- n))) + n)) + +(defun org-kill-new (string &rest args) + (remove-text-properties 0 (length string) '(line-prefix t wrap-prefix t) + string) + (apply 'kill-new string args)) + +;; `font-lock-ensure' is only available from 24.4.50 on +(defalias 'org-font-lock-ensure + (if (fboundp 'font-lock-ensure) + #'font-lock-ensure + (lambda (&optional _beg _end) + (with-no-warnings (font-lock-fontify-buffer))))) + +;; `file-local-name' was added in Emacs 26.1. +(defalias 'org-babel-local-file-name + (if (fboundp 'file-local-name) + 'file-local-name + (lambda (file) + "Return the local name component of FILE." + (or (file-remote-p file 'localname) file)))) + +(defmacro org-no-popups (&rest body) + "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))) + +;;;###autoload +(defmacro org-check-version () + "Try very hard to provide sensible version strings." + (let* ((org-dir (org-find-library-dir "org")) + (org-version.el (concat org-dir "org-version.el")) + (org-fixup.el (concat org-dir "../mk/org-fixup.el"))) + (if (require 'org-version org-version.el 'noerror) + '(progn + (autoload 'org-release "org-version.el") + (autoload 'org-git-version "org-version.el")) + (if (require 'org-fixup org-fixup.el 'noerror) + '(org-fixup) + ;; provide fallback definitions and complain + (warn "Could not define org version correctly. Check installation!") + '(progn + (defun org-release () "N/A") + (defun org-git-version () "N/A !!check installation!!")))))) + +(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)) + +;; Functions for Emacs < 24.4 compatibility +(defun org-define-error (name message) + "Define NAME as a new error signal. +MESSAGE is a string that will be output to the echo area if such +an error is signaled without being caught by a `condition-case'. +Implements `define-error' for older emacsen." + (if (fboundp 'define-error) (define-error name message) + (put name 'error-conditions + (copy-sequence (cons name (get 'error 'error-conditions)))))) + +(unless (fboundp 'string-suffix-p) + ;; From Emacs subr.el. + (defun string-suffix-p (suffix string &optional ignore-case) + "Return non-nil if SUFFIX is a suffix of STRING. +If IGNORE-CASE is non-nil, the comparison is done without paying +attention to case differences." + (let ((start-pos (- (length string) (length suffix)))) + (and (>= start-pos 0) + (eq t (compare-strings suffix nil nil + string start-pos nil ignore-case)))))) + +(provide 'org-compat) + +;;; org-compat.el ends here diff --git a/elpa/org-plus-contrib-20150831/org-contacts.el b/elpa/org-plus-contrib-20170407/org-contacts.el similarity index 82% rename from elpa/org-plus-contrib-20150831/org-contacts.el rename to elpa/org-plus-contrib-20170407/org-contacts.el index edc09feb..2cadd1da 100644 --- a/elpa/org-plus-contrib-20150831/org-contacts.el +++ b/elpa/org-plus-contrib-20170407/org-contacts.el @@ -52,9 +52,7 @@ ;; ;;; Code: -(eval-when-compile - (require 'cl)) - +(require 'cl-lib) (require 'org) (require 'gnus-util) (require 'gnus-art) @@ -161,12 +159,14 @@ The following replacements are available: :group 'org-contacts) (defcustom org-contacts-matcher - (mapconcat 'identity (list org-contacts-email-property - org-contacts-alias-property - org-contacts-tel-property - org-contacts-address-property - org-contacts-birthday-property) - "<>\"\"|") + (mapconcat #'identity + (mapcar (lambda (x) (concat x "<>\"\"")) + (list org-contacts-email-property + org-contacts-alias-property + org-contacts-tel-property + org-contacts-address-property + org-contacts-birthday-property)) + "|") "Matching rule for finding heading that are contacts. This can be a tag name, or a property check." :type 'string @@ -232,7 +232,7 @@ A regexp matching strings of whitespace, `,' and `;'.") (defun org-contacts-db-need-update-p () "Determine whether `org-contacts-db' needs to be refreshed." (or (null org-contacts-last-update) - (org-find-if (lambda (file) + (cl-find-if (lambda (file) (or (time-less-p org-contacts-last-update (elt (file-attributes file) 5)))) (org-contacts-files)) @@ -252,9 +252,8 @@ to dead or no buffer." (defun org-contacts-db () "Return the latest Org Contacts Database." - (let* (todo-only - (contacts-matcher - (cdr (org-make-tags-matcher org-contacts-matcher))) + (let* ((org--matcher-tags-todo-only nil) + (contacts-matcher (cdr (org-make-tags-matcher org-contacts-matcher))) result) (when (org-contacts-db-need-update-p) (let ((progress-reporter @@ -288,10 +287,9 @@ to dead or no buffer." (error "File %s is not in `org-mode'" file)) (setf result (append result - (org-scan-tags - 'org-contacts-at-point - contacts-matcher - todo-only))))) + (org-scan-tags 'org-contacts-at-point + contacts-matcher + org--matcher-tags-todo-only))))) (progress-reporter-update progress-reporter (setq i (1+ i)))) (setf org-contacts-db result org-contacts-last-update (current-time)) @@ -316,22 +314,22 @@ cell corresponding to the contact properties. (null prop-match) (null tags-match)) (org-contacts-db) - (loop for contact in (org-contacts-db) - if (or - (and name-match - (org-string-match-p name-match - (first contact))) - (and prop-match - (org-find-if (lambda (prop) - (and (string= (car prop-match) (car prop)) - (org-string-match-p (cdr prop-match) (cdr prop)))) - (caddr contact))) - (and tags-match - (org-find-if (lambda (tag) - (org-string-match-p tags-match tag)) - (org-split-string - (or (cdr (assoc-string "ALLTAGS" (caddr contact))) "") ":")))) - collect contact))) + (cl-loop for contact in (org-contacts-db) + if (or + (and name-match + (string-match-p name-match + (first contact))) + (and prop-match + (cl-find-if (lambda (prop) + (and (string= (car prop-match) (car prop)) + (string-match-p (cdr prop-match) (cdr prop)))) + (caddr contact))) + (and tags-match + (cl-find-if (lambda (tag) + (string-match-p tags-match tag)) + (org-split-string + (or (cdr (assoc-string "ALLTAGS" (caddr contact))) "") ":")))) + collect contact))) (when (not (fboundp 'completion-table-case-fold)) ;; That function is new in Emacs 24... @@ -344,34 +342,34 @@ cell corresponding to the contact properties. "Custom implementation of `try-completion'. This version works only with list and alist and it looks at all prefixes rather than just the beginning of the string." - (loop with regexp = (concat "\\b" (regexp-quote to-match)) - with ret = nil - with ret-start = nil - with ret-end = nil - - for el in collection - for string = (if (listp el) (car el) el) - - for start = (when (or (null predicate) (funcall predicate string)) - (string-match regexp string)) - - if start - do (let ((end (match-end 0)) - (len (length string))) - (if (= end len) - (return t) - (destructuring-bind (string start end) - (if (null ret) - (values string start end) - (org-contacts-common-substring - ret ret-start ret-end - string start end)) - (setf ret string - ret-start start - ret-end end)))) - - finally (return - (replace-regexp-in-string "\\`[ \t\n]*" "" ret)))) + (cl-loop with regexp = (concat "\\b" (regexp-quote to-match)) + with ret = nil + with ret-start = nil + with ret-end = nil + + for el in collection + for string = (if (listp el) (car el) el) + + for start = (when (or (null predicate) (funcall predicate string)) + (string-match regexp string)) + + if start + do (let ((end (match-end 0)) + (len (length string))) + (if (= end len) + (cl-return t) + (cl-destructuring-bind (string start end) + (if (null ret) + (values string start end) + (org-contacts-common-substring + ret ret-start ret-end + string start end)) + (setf ret string + ret-start start + ret-end end)))) + + finally (cl-return + (replace-regexp-in-string "\\`[ \t\n]*" "" ret)))) (defun org-contacts-compare-strings (s1 start1 end1 s2 start2 end2 &optional ignore-case) "Compare the contents of two strings, using `compare-strings'. @@ -430,22 +428,22 @@ This function returns a list whose contains: "Custom version of `all-completions'. This version works only with list and alist and it looks at all prefixes rather than just the beginning of the string." - (loop with regexp = (concat "\\b" (regexp-quote to-match)) - for el in collection - for string = (if (listp el) (car el) el) - for match? = (when (and (or (null predicate) (funcall predicate string))) - (string-match regexp string)) - if match? - collect (progn - (let ((end (match-end 0))) - (org-no-properties string) - (when (< end (length string)) - ;; Here we add a text property that will be used - ;; later to highlight the character right after - ;; the common part between each addresses. - ;; See `org-contacts-display-sort-function'. - (put-text-property end (1+ end) 'org-contacts-prefix 't string))) - string))) + (cl-loop with regexp = (concat "\\b" (regexp-quote to-match)) + for el in collection + for string = (if (listp el) (car el) el) + for match? = (when (and (or (null predicate) (funcall predicate string))) + (string-match regexp string)) + if match? + collect (progn + (let ((end (match-end 0))) + (org-no-properties string) + (when (< end (length string)) + ;; Here we add a text property that will be used + ;; later to highlight the character right after + ;; the common part between each addresses. + ;; See `org-contacts-display-sort-function'. + (put-text-property end (1+ end) 'org-contacts-prefix 't string))) + string))) (defun org-contacts-make-collection-prefix (collection) "Make a collection function from COLLECTION which will match on prefixes." @@ -460,7 +458,7 @@ prefixes rather than just the beginning of the string." ((eq flag 'lambda) (org-contacts-test-completion-prefix string collection predicate)) ((and (listp flag) (eq (car flag) 'boundaries)) - (destructuring-bind (to-ignore &rest suffix) + (cl-destructuring-bind (to-ignore &rest suffix) flag (org-contacts-boundaries-prefix string collection predicate suffix))) ((eq flag 'metadata) @@ -471,31 +469,28 @@ prefixes rather than just the beginning of the string." (defun org-contacts-display-sort-function (completions) "Sort function for contacts display." (mapcar (lambda (string) - (loop with len = (1- (length string)) - for i upfrom 0 to len - if (memq 'org-contacts-prefix - (text-properties-at i string)) - do (set-text-properties - i (1+ i) - (list 'font-lock-face - (if (char-equal (aref string i) - (string-to-char " ")) - ;; Spaces can't be bold. - 'underline - 'bold)) string) - else - do (set-text-properties i (1+ i) nil string) - finally (return string))) + (cl-loop with len = (1- (length string)) + for i upfrom 0 to len + if (memq 'org-contacts-prefix + (text-properties-at i string)) + do (set-text-properties + i (1+ i) + (list 'font-lock-face + (if (char-equal (aref string i) + (string-to-char " ")) + ;; Spaces can't be bold. + 'underline + 'bold)) string) + else + do (set-text-properties i (1+ i) nil string) + finally (cl-return string))) completions)) (defun org-contacts-test-completion-prefix (string collection predicate) - ;; Prevents `org-find-if' from redefining `predicate' and going into - ;; an infinite loop. - (lexical-let ((predicate predicate)) - (org-find-if (lambda (el) - (and (or (null predicate) (funcall predicate el)) - (string= string el))) - collection))) + (cl-find-if (lambda (el) + (and (or (null predicate) (funcall predicate el)) + (string= string el))) + collection)) (defun org-contacts-boundaries-prefix (string collection predicate suffix) (list* 'boundaries (completion-boundaries string collection predicate suffix))) @@ -510,7 +505,7 @@ prefixes rather than just the beginning of the string." A group FOO is composed of contacts with the tag FOO." (let* ((completion-ignore-case org-contacts-completion-ignore-case) - (group-completion-p (org-string-match-p + (group-completion-p (string-match-p (concat "^" org-contacts-group-prefix) string))) (when group-completion-p (let ((completion-list @@ -520,9 +515,9 @@ A group FOO is composed of contacts with the tag FOO." (propertize (concat org-contacts-group-prefix group) 'org-contacts-group group)) (org-uniquify - (loop for contact in (org-contacts-filter) - nconc (org-split-string - (or (cdr (assoc-string "ALLTAGS" (caddr contact))) "") ":"))))))) + (cl-loop for contact in (org-contacts-filter) + nconc (org-split-string + (or (cdr (assoc-string "ALLTAGS" (caddr contact))) "") ":"))))))) (list start end (if (= (length completion-list) 1) ;; We've found the correct group, returns the address @@ -530,21 +525,21 @@ A group FOO is composed of contacts with the tag FOO." (car completion-list)))) (lambda (string pred &optional to-ignore) (mapconcat 'identity - (loop for contact in (org-contacts-filter - nil - tag) - ;; The contact name is always the car of the assoc-list - ;; returned by `org-contacts-filter'. - for contact-name = (car contact) - ;; Grab the first email of the contact - for email = (org-contacts-strip-link - (or (car (org-contacts-split-property - (or - (cdr (assoc-string org-contacts-email-property - (caddr contact))) - ""))) "")) - ;; If the user has an email address, append USER . - if email collect (org-contacts-format-email contact-name email)) + (cl-loop for contact in (org-contacts-filter + nil + tag) + ;; The contact name is always the car of the assoc-list + ;; returned by `org-contacts-filter'. + for contact-name = (car contact) + ;; Grab the first email of the contact + for email = (org-contacts-strip-link + (or (car (org-contacts-split-property + (or + (cdr (assoc-string org-contacts-email-property + (cl-caddr contact))) + ""))) "")) + ;; If the user has an email address, append USER . + if email collect (org-contacts-format-email contact-name email)) ", "))) ;; We haven't found the correct group (completion-table-case-fold completion-list @@ -559,30 +554,30 @@ with BAR. See (org) Matching tags and properties for a complete description." (let* ((completion-ignore-case org-contacts-completion-ignore-case) - (completion-p (org-string-match-p + (completion-p (string-match-p (concat "^" org-contacts-tags-props-prefix) string))) (when completion-p (let ((result (mapconcat 'identity - (loop for contact in (org-contacts-db) - for contact-name = (car contact) - for email = (org-contacts-strip-link (or (car (org-contacts-split-property - (or - (cdr (assoc-string org-contacts-email-property - (caddr contact))) - ""))) "")) - for tags = (cdr (assoc "TAGS" (nth 2 contact))) - for tags-list = (if tags - (split-string (substring (cdr (assoc "TAGS" (nth 2 contact))) 1 -1) ":") - '()) - for marker = (second contact) - if (with-current-buffer (marker-buffer marker) - (save-excursion - (goto-char marker) - (let (todo-only) - (eval (cdr (org-make-tags-matcher (subseq string 1))))))) - collect (org-contacts-format-email contact-name email)) + (cl-loop for contact in (org-contacts-db) + for contact-name = (car contact) + for email = (org-contacts-strip-link (or (car (org-contacts-split-property + (or + (cdr (assoc-string org-contacts-email-property + (cl-caddr contact))) + ""))) "")) + for tags = (cdr (assoc "TAGS" (nth 2 contact))) + for tags-list = (if tags + (split-string (substring (cdr (assoc "TAGS" (nth 2 contact))) 1 -1) ":") + '()) + for marker = (nth 1 contact) + if (with-current-buffer (marker-buffer marker) + (save-excursion + (goto-char marker) + (let (todo-only) + (eval (cdr (org-make-tags-matcher (cl-subseq string 1))))))) + collect (org-contacts-format-email contact-name email)) ","))) (when (not (string= "" result)) ;; return (start end function) @@ -593,37 +588,37 @@ description." (defun org-contacts-remove-ignored-property-values (ignore-list list) "Remove all ignore-list's elements from list and you can use regular expressions in the ignore list." - (org-remove-if (lambda (el) - (org-find-if (lambda (x) - (string-match-p x el)) - ignore-list)) - list)) + (cl-remove-if (lambda (el) + (cl-find-if (lambda (x) + (string-match-p x el)) + ignore-list)) + list)) (defun org-contacts-complete-name (start end string) "Complete text at START with a user name and email." (let* ((completion-ignore-case org-contacts-completion-ignore-case) (completion-list - (loop for contact in (org-contacts-filter) - ;; The contact name is always the car of the assoc-list - ;; returned by `org-contacts-filter'. - for contact-name = (car contact) - - ;; Build the list of the email addresses which has - ;; been expired - for ignore-list = (org-contacts-split-property - (or (cdr (assoc-string org-contacts-ignore-property - (caddr contact))) "")) - ;; Build the list of the user email addresses. - for email-list = (org-contacts-remove-ignored-property-values - ignore-list - (org-contacts-split-property - (or (cdr (assoc-string org-contacts-email-property - (caddr contact))) ""))) - ;; If the user has email addresses… - if email-list - ;; … append a list of USER . - nconc (loop for email in email-list - collect (org-contacts-format-email contact-name (org-contacts-strip-link email))))) + (cl-loop for contact in (org-contacts-filter) + ;; The contact name is always the car of the assoc-list + ;; returned by `org-contacts-filter'. + for contact-name = (car contact) + + ;; Build the list of the email addresses which has + ;; been expired + for ignore-list = (org-contacts-split-property + (or (cdr (assoc-string org-contacts-ignore-property + (nth 2 contact))) "")) + ;; Build the list of the user email addresses. + for email-list = (org-contacts-remove-ignored-property-values + ignore-list + (org-contacts-split-property + (or (cdr (assoc-string org-contacts-email-property + (nth 2 contact))) ""))) + ;; If the user has email addresses… + if email-list + ;; … append a list of USER . + nconc (cl-loop for email in email-list + collect (org-contacts-format-email contact-name (org-contacts-strip-link email))))) (completion-list (org-contacts-all-completions-prefix string (org-uniquify completion-list)))) @@ -662,13 +657,13 @@ description." (let* ((address (org-contacts-gnus-get-name-email)) (name (car address)) (email (cadr address))) - (cadar (or (org-contacts-filter - nil - nil - (cons org-contacts-email-property (concat "\\b" (regexp-quote email) "\\b"))) - (when name - (org-contacts-filter - (concat "^" name "$"))))))) + (cl-cadar (or (org-contacts-filter + nil + nil + (cons org-contacts-email-property (concat "\\b" (regexp-quote email) "\\b"))) + (when name + (org-contacts-filter + (concat "^" name "$"))))))) (defun org-contacts-gnus-article-from-goto () "Go to contact in the From address of current Gnus message." @@ -677,14 +672,9 @@ description." (when marker (switch-to-buffer-other-window (marker-buffer marker)) (goto-char marker) - (when (eq major-mode 'org-mode) - (org-show-context 'agenda) - (save-excursion - (and (outline-next-heading) - ;; show the next heading - (org-flag-heading nil))))))) + (when (eq major-mode 'org-mode) (org-show-context 'agenda))))) -(org-no-warnings (defvar date)) ;; unprefixed, from calendar.el +(with-no-warnings (defvar date)) ;; unprefixed, from calendar.el (defun org-contacts-anniversaries (&optional field format) "Compute FIELD anniversary for each contact, returning FORMAT. Default FIELD value is \"BIRTHDAY\". @@ -698,23 +688,23 @@ Format is a string matching the following format specification: (let ((calendar-date-style 'american) (entry "")) (unless format (setq format org-contacts-birthday-format)) - (loop for contact in (org-contacts-filter) - for anniv = (let ((anniv (cdr (assoc-string - (or field org-contacts-birthday-property) - (caddr contact))))) - (when anniv - (calendar-gregorian-from-absolute - (org-time-string-to-absolute anniv)))) - ;; Use `diary-anniversary' to compute anniversary. - if (and anniv (apply 'diary-anniversary anniv)) - collect (format-spec format - `((?l . ,(org-with-point-at (cadr contact) (org-store-link nil))) - (?h . ,(car contact)) - (?y . ,(- (calendar-extract-year date) - (calendar-extract-year anniv))) - (?Y . ,(let ((years (- (calendar-extract-year date) - (calendar-extract-year anniv)))) - (format "%d%s" years (diary-ordinal-suffix years))))))))) + (cl-loop for contact in (org-contacts-filter) + for anniv = (let ((anniv (cdr (assoc-string + (or field org-contacts-birthday-property) + (nth 2 contact))))) + (when anniv + (calendar-gregorian-from-absolute + (org-time-string-to-absolute anniv)))) + ;; Use `diary-anniversary' to compute anniversary. + if (and anniv (apply 'diary-anniversary anniv)) + collect (format-spec format + `((?l . ,(org-with-point-at (cadr contact) (org-store-link nil))) + (?h . ,(car contact)) + (?y . ,(- (calendar-extract-year date) + (calendar-extract-year anniv))) + (?Y . ,(let ((years (- (calendar-extract-year date) + (calendar-extract-year anniv)))) + (format "%d%s" years (diary-ordinal-suffix years))))))))) (defun org-completing-read-date (prompt collection &optional predicate require-match initial-input @@ -995,7 +985,7 @@ to do our best." (defun org-contacts-vcard-format (contact) "Formats CONTACT in VCard 3.0 format." - (let* ((properties (caddr contact)) + (let* ((properties (nth 2 contact)) (name (org-contacts-vcard-escape (car contact))) (n (org-contacts-vcard-encode-name name)) (email (cdr (assoc-string org-contacts-email-property properties))) @@ -1054,15 +1044,15 @@ passed to `org-contacts-export-as-vcard-internal'." (interactive "P") (when (called-interactively-p 'any) (cl-psetf name - (when name - (read-string "Contact name: " - (first (org-contacts-at-point)))) - file - (when (equal name '(16)) - (read-file-name "File: " nil org-contacts-vcard-file)) - to-buffer - (when (equal name '(64)) - (read-buffer "Buffer: ")))) + (when name + (read-string "Contact name: " + (nth 0 (org-contacts-at-point)))) + file + (when (equal name '(16)) + (read-file-name "File: " nil org-contacts-vcard-file)) + to-buffer + (when (equal name '(64)) + (read-buffer "Buffer: ")))) (org-contacts-export-as-vcard-internal name file to-buffer)) (defun org-contacts-export-as-vcard-internal (&optional name file to-buffer) @@ -1094,9 +1084,9 @@ Requires google-maps-el." (error "`org-contacts-show-map' requires `google-maps-el'")) (google-maps-static-show :markers - (loop + (cl-loop for contact in (org-contacts-filter name) - for addr = (cdr (assoc-string org-contacts-address-property (caddr contact))) + for addr = (cdr (assoc-string org-contacts-address-property (nth 2 contact))) if addr collect (cons (list addr) (list :label (string-to-char (car contact))))))) @@ -1115,6 +1105,10 @@ link string and return the pure link target." (setq colonpos (string-match ":" link)) (if startpos (substring link (1+ colonpos)) link))))) +;; Add the link type supported by org-contacts-strip-link +;; so everything is in order for its use in Org files +(org-link-set-parameters "tel") + (defun org-contacts-split-property (string &optional separators omit-nulls) "Custom version of `split-string'. Split a property STRING into sub-strings bounded by matches diff --git a/elpa/org-plus-contrib-20150831/org-contribdir.el b/elpa/org-plus-contrib-20170407/org-contribdir.el similarity index 96% rename from elpa/org-plus-contrib-20150831/org-contribdir.el rename to elpa/org-plus-contrib-20170407/org-contribdir.el index d94e7a07..4ad31161 100644 --- a/elpa/org-plus-contrib-20150831/org-contribdir.el +++ b/elpa/org-plus-contrib-20170407/org-contribdir.el @@ -1,5 +1,5 @@ ;;; org-contribdir.el --- Mark the location of the contrib directory -;; Copyright (C) 2009-2014 Free Software Foundation, Inc. +;; Copyright (C) 2009-2017 Free Software Foundation, Inc. ;; ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp diff --git a/elpa/org-plus-contrib-20150831/org-crypt.el b/elpa/org-plus-contrib-20170407/org-crypt.el similarity index 69% rename from elpa/org-plus-contrib-20150831/org-crypt.el rename to elpa/org-plus-contrib-20170407/org-crypt.el index f527673c..4439c947 100644 --- a/elpa/org-plus-contrib-20150831/org-crypt.el +++ b/elpa/org-plus-contrib-20170407/org-crypt.el @@ -1,13 +1,12 @@ -;;; org-crypt.el --- Public key encryption for org-mode entries - -;; Copyright (C) 2007-2015 Free Software Foundation, Inc. +;;; org-crypt.el --- Public Key Encryption for Org Entries -*- lexical-binding: t; -*- +;; Copyright (C) 2007-2017 Free Software Foundation, Inc. ;; Emacs Lisp Archive Entry ;; Filename: org-crypt.el ;; Keywords: org-mode ;; Author: John Wiegley ;; Maintainer: Peter Jones -;; Description: Adds public key encryption to org-mode buffers +;; Description: Adds public key encryption to Org buffers ;; URL: http://www.newartisans.com/software/emacs.html ;; Compatibility: Emacs22 @@ -104,10 +103,10 @@ t : Disable auto-save-mode for the current buffer nil : Leave auto-save-mode enabled. This may cause data to be written to disk unencrypted! -'ask : Ask user whether or not to disable auto-save-mode +`ask' : Ask user whether or not to disable auto-save-mode for the current buffer. -'encrypt : Leave auto-save-mode enabled for the current buffer, +`encrypt': Leave auto-save-mode enabled for the current buffer, but automatically re-encrypt all decrypted entries *before* auto-saving. NOTE: This only works for entries which have a tag @@ -133,15 +132,16 @@ See `org-crypt-disable-auto-save'." (and (eq org-crypt-disable-auto-save 'ask) (y-or-n-p "org-decrypt: auto-save-mode may cause leakage. Disable it for current buffer? "))) - (message (concat "org-decrypt: Disabling auto-save-mode for " (or (buffer-file-name) (current-buffer)))) - ; The argument to auto-save-mode has to be "-1", since - ; giving a "nil" argument toggles instead of disabling. + (message "org-decrypt: Disabling auto-save-mode for %s" + (or (buffer-file-name) (current-buffer))) + ;; The argument to auto-save-mode has to be "-1", since + ;; giving a "nil" argument toggles instead of disabling. (auto-save-mode -1)) ((eq org-crypt-disable-auto-save nil) (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.") - (org-add-hook 'auto-save-hook + (add-hook 'auto-save-hook (lambda () (message "org-crypt: Re-encrypting all decrypted entries due to auto-save.") (org-encrypt-entries)) @@ -163,96 +163,96 @@ See `org-crypt-disable-auto-save'." (if (and (string= crypt-key (get-text-property 0 'org-crypt-key str)) (string= (sha1 str) (get-text-property 0 'org-crypt-checksum str))) (get-text-property 0 'org-crypt-text str) - (set (make-local-variable 'epg-context) (epg-make-context nil t t)) + (setq-local epg-context (epg-make-context nil t t)) (epg-encrypt-string epg-context str (epg-list-keys epg-context crypt-key)))) (defun org-encrypt-entry () "Encrypt the content of the current headline." (interactive) (require 'epg) - (save-excursion - (org-back-to-heading t) - (set (make-local-variable 'epg-context) (epg-make-context nil t t)) - (let ((start-heading (point))) - (forward-line) - (when (not (looking-at "-----BEGIN PGP MESSAGE-----")) - (let ((folded (outline-invisible-p)) - (crypt-key (org-crypt-key-for-heading)) - (beg (point)) - end encrypted-text) - (goto-char start-heading) - (org-end-of-subtree t t) - (org-back-over-empty-lines) - (setq end (point) - encrypted-text - (org-encrypt-string (buffer-substring beg end) crypt-key)) - (delete-region beg end) - (insert encrypted-text) - (when folded - (goto-char start-heading) - (hide-subtree)) - nil))))) + (org-with-wide-buffer + (org-back-to-heading t) + (setq-local epg-context (epg-make-context nil t t)) + (let ((start-heading (point))) + (org-end-of-meta-data) + (unless (looking-at-p "-----BEGIN PGP MESSAGE-----") + (let ((folded (outline-invisible-p)) + (crypt-key (org-crypt-key-for-heading)) + (beg (point))) + (goto-char start-heading) + (org-end-of-subtree t t) + (org-back-over-empty-lines) + (let ((contents (delete-and-extract-region beg (point)))) + (condition-case err + (insert (org-encrypt-string contents crypt-key)) + ;; If encryption failed, make sure to insert back entry + ;; contents in the buffer. + (error (insert contents) (error (nth 1 err))))) + (when folded + (goto-char start-heading) + (outline-hide-subtree)) + nil))))) (defun org-decrypt-entry () "Decrypt the content of the current headline." (interactive) (require 'epg) (unless (org-before-first-heading-p) - (save-excursion - (org-back-to-heading t) - (let ((heading-point (point)) - (heading-was-invisible-p - (save-excursion - (outline-end-of-heading) - (outline-invisible-p)))) - (forward-line) - (when (looking-at "-----BEGIN PGP MESSAGE-----") - (org-crypt-check-auto-save) - (set (make-local-variable 'epg-context) (epg-make-context nil t t)) - (let* ((end (save-excursion - (search-forward "-----END PGP MESSAGE-----") - (forward-line) - (point))) - (encrypted-text (buffer-substring-no-properties (point) end)) - (decrypted-text - (decode-coding-string - (epg-decrypt-string - epg-context - encrypted-text) - 'utf-8))) - ;; Delete region starting just before point, because the - ;; outline property starts at the \n of the heading. - (delete-region (1- (point)) end) - ;; Store a checksum of the decrypted and the encrypted - ;; text value. This allow to reuse the same encrypted text - ;; if the text does not change, and therefore avoid a - ;; re-encryption process. - (insert "\n" (propertize decrypted-text - 'org-crypt-checksum (sha1 decrypted-text) - 'org-crypt-key (org-crypt-key-for-heading) - 'org-crypt-text encrypted-text)) - (when heading-was-invisible-p - (goto-char heading-point) - (org-flag-subtree t)) - nil)))))) + (org-with-wide-buffer + (org-back-to-heading t) + (let ((heading-point (point)) + (heading-was-invisible-p + (save-excursion + (outline-end-of-heading) + (outline-invisible-p)))) + (org-end-of-meta-data) + (when (looking-at "-----BEGIN PGP MESSAGE-----") + (org-crypt-check-auto-save) + (setq-local epg-context (epg-make-context nil t t)) + (let* ((end (save-excursion + (search-forward "-----END PGP MESSAGE-----") + (forward-line) + (point))) + (encrypted-text (buffer-substring-no-properties (point) end)) + (decrypted-text + (decode-coding-string + (epg-decrypt-string + epg-context + encrypted-text) + 'utf-8))) + ;; Delete region starting just before point, because the + ;; outline property starts at the \n of the heading. + (delete-region (1- (point)) end) + ;; Store a checksum of the decrypted and the encrypted + ;; text value. This allows reusing the same encrypted text + ;; if the text does not change, and therefore avoid a + ;; re-encryption process. + (insert "\n" (propertize decrypted-text + 'org-crypt-checksum (sha1 decrypted-text) + 'org-crypt-key (org-crypt-key-for-heading) + 'org-crypt-text encrypted-text)) + (when heading-was-invisible-p + (goto-char heading-point) + (org-flag-subtree t)) + nil)))))) (defun org-encrypt-entries () "Encrypt all top-level entries in the current buffer." (interactive) - (let (todo-only) + (let ((org--matcher-tags-todo-only nil)) (org-scan-tags 'org-encrypt-entry (cdr (org-make-tags-matcher org-crypt-tag-matcher)) - todo-only))) + org--matcher-tags-todo-only))) (defun org-decrypt-entries () "Decrypt all entries in the current buffer." (interactive) - (let (todo-only) + (let ((org--matcher-tags-todo-only nil)) (org-scan-tags 'org-decrypt-entry (cdr (org-make-tags-matcher org-crypt-tag-matcher)) - todo-only))) + org--matcher-tags-todo-only))) (defun org-at-encrypted-entry-p () "Is the current entry encrypted?" @@ -266,7 +266,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 () (org-add-hook 'before-save-hook 'org-encrypt-entries nil t)))) + (lambda () (add-hook 'before-save-hook 'org-encrypt-entries nil t)))) (add-hook 'org-reveal-start-hook 'org-decrypt-entry) diff --git a/elpa/org-plus-contrib-20150831/org-ctags.el b/elpa/org-plus-contrib-20170407/org-ctags.el similarity index 86% rename from elpa/org-plus-contrib-20150831/org-ctags.el rename to elpa/org-plus-contrib-20170407/org-ctags.el index a9baf04b..98eb8068 100644 --- a/elpa/org-plus-contrib-20150831/org-ctags.el +++ b/elpa/org-plus-contrib-20170407/org-ctags.el @@ -1,6 +1,6 @@ -;;; org-ctags.el - Integrate Emacs "tags" facility with org mode. +;;; org-ctags.el - Integrate Emacs "tags" Facility with Org -*- lexical-binding: t; -*- ;; -;; Copyright (C) 2007-2015 Free Software Foundation, Inc. +;; Copyright (C) 2007-2017 Free Software Foundation, Inc. ;; Author: Paul Sexton @@ -26,20 +26,21 @@ ;; Synopsis ;; ======== ;; -;; Allows org-mode to make use of the Emacs `etags' system. Defines tag -;; destinations in org-mode files as any text between <>. This allows the tags-generation program `exuberant ctags' to -;; parse these files and create tag tables that record where these -;; destinations are found. Plain [[links]] in org mode files which do not have -;; <> within the same file will then be interpreted as -;; links to these 'tagged' destinations, allowing seamless navigation between -;; multiple org-mode files. Topics can be created in any org mode file and -;; will always be found by plain links from other files. Other file types -;; recognized by ctags (source code files, latex files, etc) will also be -;; available as destinations for plain links, and similarly, org-mode links -;; will be available as tags from source files. Finally, the function -;; `org-ctags-find-tag-interactive' lets you choose any known tag, using -;; autocompletion, and quickly jump to it. +;; Allows Org mode to make use of the Emacs `etags' system. Defines +;; tag destinations in Org files as any text between <>. This allows the tags-generation program `exuberant +;; ctags' to parse these files and create tag tables that record where +;; these destinations are found. Plain [[links]] in org mode files +;; which do not have <> within the same file +;; will then be interpreted as links to these 'tagged' destinations, +;; allowing seamless navigation between multiple Org files. Topics +;; can be created in any org mode file and will always be found by +;; plain links from other files. Other file types recognized by ctags +;; (source code files, latex files, etc) will also be available as +;; destinations for plain links, and similarly, Org links will be +;; available as tags from source files. Finally, the function +;; `org-ctags-find-tag-interactive' lets you choose any known tag, +;; using autocompletion, and quickly jump to it. ;; ;; Installation ;; ============ @@ -110,8 +111,9 @@ ;; Keeping the TAGS file up to date ;; ================================ ;; -;; Tags mode has no way of knowing that you have created new tags by typing in -;; your org-mode buffer. New tags make it into the TAGS file in 3 ways: +;; Tags mode has no way of knowing that you have created new tags by +;; typing in your Org buffer. New tags make it into the TAGS file in +;; 3 ways: ;; ;; 1. You re-run (org-ctags-create-tags "directory") to rebuild the file. ;; 2. You put the function `org-ctags-ask-rebuild-tags-file-then-find-tag' in @@ -135,12 +137,8 @@ ;;; Code: -(eval-when-compile (require 'cl)) - (require 'org) -(declare-function org-pop-to-buffer-same-window "org-compat" (&optional buffer-or-name norecord label)) - (defgroup org-ctags nil "Options concerning use of ctags within org mode." :tag "Org-Ctags" @@ -151,7 +149,7 @@ (defvar org-ctags-tag-regexp "/<<([^>]+)>>/\\1/d,definition/" "Regexp expression used by ctags external program. -The regexp matches tag destinations in org-mode files. +The regexp matches tag destinations in Org files. Format is: /REGEXP/TAGNAME/FLAGS,TAGTYPE/ See the ctags documentation for more information.") @@ -210,8 +208,8 @@ The following patterns are replaced in the string: (defadvice visit-tags-table (after org-ctags-load-tag-list activate compile) (when (and org-ctags-enabled-p tags-file-name) - (set (make-local-variable 'org-ctags-tag-list) - (org-ctags-all-tags-in-current-tags-table)))) + (setq-local org-ctags-tag-list + (org-ctags-all-tags-in-current-tags-table)))) (defun org-ctags-enable () @@ -273,11 +271,6 @@ Return the list." (replace-regexp-in-string (regexp-quote search) replace string t t)) -(defun y-or-n-minibuffer (prompt) - (let ((use-dialog-box nil)) - (y-or-n-p prompt))) - - ;;; Internal functions ======================================================= @@ -285,29 +278,28 @@ Return the list." "Visit or create a file called `NAME.org', and insert a new topic. The new topic will be titled NAME (or TITLE if supplied)." (interactive "sFile name: ") - (let ((filename (substitute-in-file-name (expand-file-name name)))) - (condition-case v - (progn - (org-open-file name t) - (message "Opened file OK") - (goto-char (point-max)) - (insert (org-ctags-string-search-and-replace - "%t" (capitalize (or title name)) - org-ctags-new-topic-template)) - (message "Inserted new file text OK") - (org-mode-restart)) - (error (error "Error %S in org-ctags-open-file" v))))) + (condition-case v + (progn + (org-open-file name t) + (message "Opened file OK") + (goto-char (point-max)) + (insert (org-ctags-string-search-and-replace + "%t" (capitalize (or title name)) + org-ctags-new-topic-template)) + (message "Inserted new file text OK") + (org-mode-restart)) + (error (error "Error %S in org-ctags-open-file" v)))) ;;;; Misc interoperability with etags system ================================= -(defadvice find-tag (before org-ctags-set-org-mark-before-finding-tag - activate compile) +(defadvice xref-find-definitions + (before org-ctags-set-org-mark-before-finding-tag activate compile) "Before trying to find a tag, save our current position on org mark ring." (save-excursion - (if (and (derived-mode-p 'org-mode) org-ctags-enabled-p) - (org-mark-ring-push)))) + (when (and (derived-mode-p 'org-mode) org-ctags-enabled-p) + (org-mark-ring-push)))) @@ -359,7 +351,7 @@ visit the file and location where the tag is found." (old-pnt (point-marker)) (old-mark (copy-marker (mark-marker)))) (condition-case nil - (progn (find-tag name) + (progn (xref-find-definitions name) t) (error ;; only restore old location if find-tag raises error @@ -386,7 +378,7 @@ the new file." (cond ((get-buffer (concat name ".org")) ;; Buffer is already open - (org-pop-to-buffer-same-window (get-buffer (concat name ".org")))) + (pop-to-buffer-same-window (get-buffer (concat name ".org")))) ((file-exists-p filename) ;; File exists but is not open --> open it (message "Opening existing org file `%S'..." @@ -394,7 +386,8 @@ the new file." (org-open-file filename t)) ((or (eql create t) (and (eql create 'ask) - (y-or-n-p (format "File `%s.org' not found; create?" name)))) + (y-or-n-p (format-message + "File `%s.org' not found; create?" name)))) (org-ctags-open-file filename name)) (t ;; File does not exist, and we don't want to create it. nil)))) @@ -420,7 +413,6 @@ the heading a destination for the tag `NAME'." (insert (org-ctags-string-search-and-replace "%t" (capitalize name) org-ctags-new-topic-template)) (backward-char 4) - (org-update-radio-target-regexp) (end-of-line) (forward-line 2) (when narrowp @@ -433,8 +425,8 @@ the heading a destination for the tag `NAME'." "This function is intended to be used in ORG-OPEN-LINK-FUNCTIONS. Wrapper for org-ctags-append-topic, which first asks the user if they want to append a new topic." - (if (y-or-n-p (format "Topic `%s' not found; append to end of buffer?" - name)) + (if (y-or-n-p (format-message + "Topic `%s' not found; append to end of buffer?" name)) (org-ctags-append-topic name narrowp) nil)) @@ -455,7 +447,7 @@ to rebuild (update) the TAGS file." Wrapper for org-ctags-rebuild-tags-file-then-find-tag." (if (and (buffer-file-name) (y-or-n-p - (format + (format-message "Tag `%s' not found. Rebuild table `%s/TAGS' and look again?" name (file-name-directory (buffer-file-name))))) @@ -463,10 +455,10 @@ Wrapper for org-ctags-rebuild-tags-file-then-find-tag." nil)) -(defun org-ctags-fail-silently (name) +(defun org-ctags-fail-silently (_name) "This function is intended to be used in ORG-OPEN-LINK-FUNCTIONS. -Put as the last function in the list if you want to prevent org's default -behavior of free text search." +Put as the last function in the list if you want to prevent Org's +default behavior of free text search." t) @@ -483,7 +475,7 @@ end up in one file, called TAGS, located in the directory. This function may take several seconds to finish if the directory or its subdirectories contain large numbers of taggable files." (interactive) - (assert (buffer-file-name)) + (cl-assert (buffer-file-name)) (let ((dir-name (or directory-name (file-name-directory (buffer-file-name)))) (exitcode nil)) @@ -498,8 +490,8 @@ its subdirectories contain large numbers of taggable files." (expand-file-name (concat dir-name "/*"))))) (cond ((eql 0 exitcode) - (set (make-local-variable 'org-ctags-tag-list) - (org-ctags-all-tags-in-current-tags-table))) + (setq-local org-ctags-tag-list + (org-ctags-all-tags-in-current-tags-table))) (t ;; This seems to behave differently on Linux, so just ignore ;; error codes for now @@ -527,7 +519,7 @@ a new topic." ((member tag org-ctags-tag-list) ;; Existing tag (push tag org-ctags-find-tag-history) - (find-tag tag)) + (xref-find-definitions tag)) (t ;; New tag (run-hook-with-args-until-success diff --git a/elpa/org-plus-contrib-20170407/org-datetree.el b/elpa/org-plus-contrib-20170407/org-datetree.el new file mode 100644 index 00000000..843e078a --- /dev/null +++ b/elpa/org-plus-contrib-20170407/org-datetree.el @@ -0,0 +1,248 @@ +;;; org-datetree.el --- Create date entries in a tree -*- lexical-binding: t; -*- + +;; Copyright (C) 2009-2017 Free Software Foundation, Inc. + +;; Author: Carsten Dominik +;; 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 . +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;;; Commentary: + +;; This file contains code to create entries in a tree where the top-level +;; nodes represent years, the level 2 nodes represent the months, and the +;; level 1 entries days. + +;;; Code: + +(require 'org) + +(defvar org-datetree-base-level 1 + "The level at which years should be placed in the date tree. +This is normally one, but if the buffer has an entry with a +DATE_TREE (or WEEK_TREE for ISO week entries) property (any +value), the date tree will become a subtree under that entry, so +the base level will be properly adjusted.") + +(defcustom org-datetree-add-timestamp nil + "When non-nil, add a time stamp matching date of entry. +Added time stamp is active unless value is `inactive'." + :group 'org-capture + :version "24.3" + :type '(choice + (const :tag "Do not add a time stamp" nil) + (const :tag "Add an inactive time stamp" inactive) + (const :tag "Add an active time stamp" active))) + +;;;###autoload +(defun org-datetree-find-date-create (d &optional keep-restriction) + "Find or create an entry for date D. +If KEEP-RESTRICTION is non-nil, do not widen the buffer. +When it is nil, the buffer will be widened to make sure an existing date +tree can be found. If it is the sympol `subtree-at-point', then the tree +will be built under the headline at point." + (setq-local org-datetree-base-level 1) + (save-restriction + (if (eq keep-restriction 'subtree-at-point) + (progn + (unless (org-at-heading-p) (error "Not at heading")) + (widen) + (org-narrow-to-subtree) + (setq-local org-datetree-base-level + (org-get-valid-level (org-current-level) 1))) + (unless keep-restriction (widen)) + ;; Support the old way of tree placement, using a property + (let ((prop (org-find-property "DATE_TREE"))) + (when prop + (goto-char prop) + (setq-local org-datetree-base-level + (org-get-valid-level (org-current-level) 1)) + (org-narrow-to-subtree)))) + (goto-char (point-min)) + (let ((year (calendar-extract-year d)) + (month (calendar-extract-month d)) + (day (calendar-extract-day d))) + (org-datetree--find-create + "^\\*+[ \t]+\\([12][0-9]\\{3\\}\\)\\(\\s-*?\ +\\([ \t]:[[:alnum:]:_@#%%]+:\\)?\\s-*$\\)" + year) + (org-datetree--find-create + "^\\*+[ \t]+%d-\\([01][0-9]\\) \\w+$" + year month) + (org-datetree--find-create + "^\\*+[ \t]+%d-%02d-\\([0123][0-9]\\) \\w+$" + year month day)))) + +;;;###autoload +(defun org-datetree-find-iso-week-create (d &optional keep-restriction) + "Find or create an ISO week entry for date D. +Compared to `org-datetree-find-date-create' this function creates +entries ordered by week instead of months. +When it is nil, the buffer will be widened to make sure an existing date +tree can be found. If it is the sympol `subtree-at-point', then the tree +will be built under the headline at point." + (setq-local org-datetree-base-level 1) + (save-restriction + (if (eq keep-restriction 'subtree-at-point) + (progn + (unless (org-at-heading-p) (error "Not at heading")) + (widen) + (org-narrow-to-subtree) + (setq-local org-datetree-base-level + (org-get-valid-level (org-current-level) 1))) + (unless keep-restriction (widen)) + ;; Support the old way of tree placement, using a property + (let ((prop (org-find-property "WEEK_TREE"))) + (when prop + (goto-char prop) + (setq-local org-datetree-base-level + (org-get-valid-level (org-current-level) 1)) + (org-narrow-to-subtree)))) + (goto-char (point-min)) + (require 'cal-iso) + (let* ((year (calendar-extract-year d)) + (month (calendar-extract-month d)) + (day (calendar-extract-day d)) + (time (encode-time 0 0 0 day month year)) + (iso-date (calendar-iso-from-absolute + (calendar-absolute-from-gregorian d))) + (weekyear (nth 2 iso-date)) + (week (nth 0 iso-date))) + ;; ISO 8601 week format is %G-W%V(-%u) + (org-datetree--find-create + "^\\*+[ \t]+\\([12][0-9]\\{3\\}\\)\\(\\s-*?\ +\\([ \t]:[[:alnum:]:_@#%%]+:\\)?\\s-*$\\)" + weekyear nil nil + (format-time-string "%G" time)) + (org-datetree--find-create + "^\\*+[ \t]+%d-W\\([0-5][0-9]\\)$" + weekyear week nil + (format-time-string "%G-W%V" time)) + ;; For the actual day we use the regular date instead of ISO week. + (org-datetree--find-create + "^\\*+[ \t]+%d-%02d-\\([0123][0-9]\\) \\w+$" + year month day)))) + +(defun org-datetree--find-create (regex year &optional month day insert) + "Find the datetree matched by REGEX for YEAR, MONTH, or DAY. +REGEX is passed to `format' with YEAR, MONTH, and DAY as +arguments. Match group 1 is compared against the specified date +component. If INSERT is non-nil and there is no match then it is +inserted into the buffer." + (when (or month day) + (org-narrow-to-subtree)) + (let ((re (format regex year month day)) + match) + (goto-char (point-min)) + (while (and (setq match (re-search-forward re nil t)) + (goto-char (match-beginning 1)) + (< (string-to-number (match-string 1)) (or day month year)))) + (cond + ((not match) + (goto-char (point-max)) + (unless (bolp) (insert "\n")) + (org-datetree-insert-line year month day insert)) + ((= (string-to-number (match-string 1)) (or day month year)) + (beginning-of-line)) + (t + (beginning-of-line) + (org-datetree-insert-line year month day insert))))) + +(defun org-datetree-insert-line (year &optional month day text) + (delete-region (save-excursion (skip-chars-backward " \t\n") (point)) (point)) + (insert "\n" (make-string org-datetree-base-level ?*) " \n") + (backward-char) + (when month (org-do-demote)) + (when day (org-do-demote)) + (if text + (insert text) + (insert (format "%d" year)) + (when month + (insert + (if day + (format-time-string "-%m-%d %A" (encode-time 0 0 0 day month year)) + (format-time-string "-%m %B" (encode-time 0 0 0 1 month year)))))) + (when (and day org-datetree-add-timestamp) + (save-excursion + (insert "\n") + (org-indent-line) + (org-insert-time-stamp + (encode-time 0 0 0 day month year) + nil + (eq org-datetree-add-timestamp 'inactive)))) + (beginning-of-line)) + +(defun org-datetree-file-entry-under (txt d) + "Insert a node TXT into the date tree under date D." + (org-datetree-find-date-create d) + (let ((level (org-get-valid-level (funcall outline-level) 1))) + (org-end-of-subtree t t) + (org-back-over-empty-lines) + (org-paste-subtree level txt))) + +(defun org-datetree-cleanup () + "Make sure all entries in the current tree are under the correct date. +It may be useful to restrict the buffer to the applicable portion +before running this command, even though the command tries to be smart." + (interactive) + (goto-char (point-min)) + (let ((dre (concat "\\<" org-deadline-string "\\>[ \t]*\\'")) + (sre (concat "\\<" org-scheduled-string "\\>[ \t]*\\'"))) + (while (re-search-forward org-ts-regexp nil t) + (catch 'next + (let ((tmp (buffer-substring + (max (line-beginning-position) + (- (match-beginning 0) org-ds-keyword-length)) + (match-beginning 0)))) + (when (or (string-suffix-p "-" tmp) + (string-match dre tmp) + (string-match sre tmp)) + (throw 'next nil)) + (let* ((dct (decode-time (org-time-string-to-time (match-string 0)))) + (date (list (nth 4 dct) (nth 3 dct) (nth 5 dct))) + (year (nth 2 date)) + (month (car date)) + (day (nth 1 date)) + (pos (point)) + (hdl-pos (progn (org-back-to-heading t) (point)))) + (unless (org-up-heading-safe) + ;; No parent, we are not in a date tree. + (goto-char pos) + (throw 'next nil)) + (unless (looking-at "\\*+[ \t]+[0-9]+-[0-1][0-9]-[0-3][0-9]") + ;; Parent looks wrong, we are not in a date tree. + (goto-char pos) + (throw 'next nil)) + (when (looking-at (format "\\*+[ \t]+%d-%02d-%02d" year month day)) + ;; At correct date already, do nothing. + (goto-char pos) + (throw 'next nil)) + ;; OK, we need to refile this entry. + (goto-char hdl-pos) + (org-cut-subtree) + (save-excursion + (save-restriction + (org-datetree-file-entry-under (current-kill 0) date))))))))) + +(provide 'org-datetree) + +;; Local variables: +;; generated-autoload-file: "org-loaddefs.el" +;; End: + +;;; org-datetree.el ends here diff --git a/elpa/org-plus-contrib-20150831/org-depend.el b/elpa/org-plus-contrib-20170407/org-depend.el similarity index 99% rename from elpa/org-plus-contrib-20150831/org-depend.el rename to elpa/org-plus-contrib-20170407/org-depend.el index 1cd41308..cd570c55 100644 --- a/elpa/org-plus-contrib-20150831/org-depend.el +++ b/elpa/org-plus-contrib-20170407/org-depend.el @@ -1,5 +1,5 @@ ;;; org-depend.el --- TODO dependencies for Org-mode -;; Copyright (C) 2008-2014 Free Software Foundation, Inc. +;; Copyright (C) 2008-2017 Free Software Foundation, Inc. ;; ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp @@ -270,7 +270,7 @@ This does two different kinds of triggers: (effort (when (or effort-up effort-down) (let ((effort (get-text-property (point) 'org-effort))) (when effort - (org-duration-string-to-minutes effort)))))) + (org-duration-to-minutes effort)))))) (push (list (point) todo-kwd priority tags effort) items)) (unless (org-goto-sibling) diff --git a/elpa/org-plus-contrib-20150831/org-docview.el b/elpa/org-plus-contrib-20170407/org-docview.el similarity index 88% rename from elpa/org-plus-contrib-20150831/org-docview.el rename to elpa/org-plus-contrib-20170407/org-docview.el index 479f4ffc..dfad8933 100644 --- a/elpa/org-plus-contrib-20150831/org-docview.el +++ b/elpa/org-plus-contrib-20170407/org-docview.el @@ -1,6 +1,6 @@ -;;; org-docview.el --- support for links to doc-view-mode buffers +;;; org-docview.el --- Support for links to doc-view-mode buffers -*- lexical-binding: t; -*- -;; Copyright (C) 2009-2015 Free Software Foundation, Inc. +;; Copyright (C) 2009-2017 Free Software Foundation, Inc. ;; Author: Jan Böcker ;; Keywords: outlines, hypermedia, calendar, wp @@ -25,7 +25,7 @@ ;;; Commentary: ;; This file implements links to open files in doc-view-mode. -;; Org-mode loads this module by default - if this is not what you want, +;; Org mode loads this module by default - if this is not what you want, ;; configure the variable `org-modules'. ;; The links take the form @@ -49,8 +49,10 @@ (declare-function doc-view-goto-page "doc-view" (page)) (declare-function image-mode-window-get "image-mode" (prop &optional winprops)) -(org-add-link-type "docview" 'org-docview-open 'org-docview-export) -(add-hook 'org-store-link-functions 'org-docview-store-link) +(org-link-set-parameters "docview" + :follow #'org-docview-open + :export #'org-docview-export + :store #'org-docview-store-link) (defun org-docview-export (link description format) "Export a docview link from Org files." @@ -61,7 +63,7 @@ (setq path (org-link-escape (expand-file-name path))) (cond ((eq format 'html) (format "%s" path desc)) - ((eq format 'latex) (format "\href{%s}{%s}" path desc)) + ((eq format 'latex) (format "\\href{%s}{%s}" path desc)) ((eq format 'ascii) (format "%s (%s)" desc path)) (t path))))) @@ -81,8 +83,7 @@ ;; This buffer is in doc-view-mode (let* ((path buffer-file-name) (page (image-mode-window-get 'page)) - (link (concat "docview:" path "::" (number-to-string page))) - (description "")) + (link (concat "docview:" path "::" (number-to-string page)))) (org-store-link-props :type "docview" :link link diff --git a/elpa/org-plus-contrib-20150831/org-drill.el b/elpa/org-plus-contrib-20170407/org-drill.el similarity index 100% rename from elpa/org-plus-contrib-20150831/org-drill.el rename to elpa/org-plus-contrib-20170407/org-drill.el diff --git a/elpa/org-plus-contrib-20170407/org-duration.el b/elpa/org-plus-contrib-20170407/org-duration.el new file mode 100644 index 00000000..51513d8c --- /dev/null +++ b/elpa/org-plus-contrib-20170407/org-duration.el @@ -0,0 +1,447 @@ +;;; org-duration.el --- Library handling durations -*- lexical-binding: t; -*- + +;; Copyright (C) 2017 Nicolas Goaziou + +;; Author: Nicolas Goaziou +;; Keywords: outlines, hypermedia, calendar, wp + +;; 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 . + +;;; Commentary: + +;; This library provides tools to manipulate durations. A duration +;; can have multiple formats: +;; +;; - 3:12 +;; - 1:23:45 +;; - 1y 3d 3h 4min +;; - 3d 13:35 +;; - 2.35h +;; +;; More accurately, it consists of numbers and units, as defined in +;; variable `org-duration-units', separated with white spaces, and +;; a "H:MM" or "H:MM:SS" part. White spaces are tolerated between the +;; number and its relative unit. Variable `org-duration-format' +;; controls durations default representation. +;; +;; The library provides functions allowing to convert a duration to, +;; and from, a number of minutes: `org-duration-to-minutes' and +;; `org-duration-from-minutes'. It also provides two lesser tools: +;; `org-duration-p', and `org-duration-h:mm-only-p'. +;; +;; Users can set the number of minutes per unit, or define new units, +;; in `org-duration-units'. The library also supports canonical +;; duration, i.e., a duration that doesn't depend on user's settings, +;; through optional arguments. + +;;; Code: + +(require 'cl-lib) +(require 'org-macs) +(declare-function org-trim "org-trim" (s &optional keep-lead)) + + +;;; Public variables + +(defconst org-duration-canonical-units + `(("min" . 1) + ("h" . 60) + ("d" . ,(* 60 24))) + "Canonical time duration units. +See `org-duration-units' for details.") + +(defcustom org-duration-units + `(("min" . 1) + ("h" . 60) + ("d" . ,(* 60 24)) + ("w" . ,(* 60 24 7)) + ("m" . ,(* 60 24 30)) + ("y" . ,(* 60 24 365.25))) + "Conversion factor to minutes for a duration. + +Each entry has the form (UNIT . MODIFIER). + +In a duration string, a number followed by UNIT is multiplied by +the specified number of MODIFIER to obtain a duration in minutes. + +For example, the following value + + \\=`((\"min\" . 1) + (\"h\" . 60) + (\"d\" . ,(* 60 8)) + (\"w\" . ,(* 60 8 5)) + (\"m\" . ,(* 60 8 5 4)) + (\"y\" . ,(* 60 8 5 4 10))) + +is meaningful if you work an average of 8 hours per day, 5 days +a week, 4 weeks a month and 10 months a year. + +When setting this variable outside the Customize interface, make +sure to call the following command: + + \\[org-duration-set-regexps]" + :group 'org-agenda + :version "26.1" + :package-version '(Org . "9.1") + :set (lambda (var val) (set-default var val) (org-duration-set-regexps)) + :initialize 'custom-initialize-changed + :type '(choice + (const :tag "H:MM" 'h:mm) + (const :tag "H:MM:SS" 'h:mm:ss) + (alist :key-type (string :tag "Unit") + :value-type (number :tag "Modifier")))) + +(defcustom org-duration-format '(("d" . nil) (special . h:mm)) + "Format definition for a duration. + +The value can be set to, respectively, the symbols `h:mm:ss' or +`h:mm', which means a duration is expressed as, respectively, +a \"H:MM:SS\" or \"H:MM\" string. + +Alternatively, the value can be a list of entries following the +pattern: + + (UNIT . REQUIRED?) + +UNIT is a unit string, as defined in `org-duration-units'. The +time duration is formatted using only the time components that +are specified here. If a time unit in missing, it falls back to +the next smallest unit. + +A non-nil REQUIRED? value for these keys indicates that the +corresponding time component should always be included, even if +its value is 0. + +Eventually, the list can contain one of the following special +entries: + + (special . h:mm) + (special . h:mm:ss) + + Units shorter than an hour are ignored. The hours and + minutes part of the duration is expressed unconditionally + with H:MM, or H:MM:SS, pattern. + + (special . PRECISION) + + A duration is expressed with a single unit, PRECISION being + the number of decimal places to show. The unit chosen is the + first one required or with a non-zero integer part. If there + is no such unit, the smallest one is used. + +For example, + + ((\"d\" . nil) (\"h\" . t) (\"min\" . t)) + +means a duration longer than a day is expressed in days, hours +and minutes, whereas a duration shorter than a day is always +expressed in hours and minutes, even when shorter than an hour. + +On the other hand, the value + + ((\"d\" . nil) (\"min\" . nil)) + +means a duration longer than a day is expressed in days and +minutes, whereas a duration shorter than a day is expressed +entirely in minutes, even when longer than an hour. + +The following format + + ((\"d\" . nil) (special . h:mm)) + +means that any duration longer than a day is expressed with both +a \"d\" unit and a \"H:MM\" part, whereas a duration shorter than +a day is expressed only as a \"H:MM\" string. + +Eventually, + + ((\"d\" . nil) (\"h\" . nil) (special . 2)) + +expresses a duration longer than a day as a decimal number, with +a 2-digits fractional part, of \"d\" unit. A duration shorter +than a day uses \"h\" unit instead." + :group 'org-time + :group 'org-clock + :version "26.1" + :package-version '(Org . "9.1") + :type '(choice + (const :tag "Use H:MM" h:mm) + (const :tag "Use H:MM:SS" h:mm:ss) + (repeat :tag "Use units" + (choice + (cons :tag "Use units" + (string :tag "Unit") + (choice (const :tag "Skip when zero" nil) + (const :tag "Always used" t))) + (cons :tag "Use a single decimal unit" + (const special) + (integer :tag "Number of decimals")) + (cons :tag "Use both units and H:MM" + (const special) + (const h:mm)) + (cons :tag "Use both units and H:MM:SS" + (const special) + (const h:mm:ss)))))) + + +;;; Internal variables and functions + +(defconst org-duration--h:mm-re + "\\`[ \t]*[0-9]+\\(?::[0-9]\\{2\\}\\)\\{1,2\\}[ \t]*\\'" + "Regexp matching a duration expressed with H:MM or H:MM:SS format. +See `org-duration--h:mm:ss-re' to only match the latter. Hours +can use any number of digits.") + +(defconst org-duration--h:mm:ss-re + "\\`[ \t]*[0-9]+\\(?::[0-9]\\{2\\}\\)\\{2\\}[ \t]*\\'" + "Regexp matching a duration expressed H:MM:SS format. +See `org-duration--h:mm-re' to also support H:MM format. Hours +can use any number of digits.") + +(defvar org-duration--unit-re nil + "Regexp matching a duration with an unit. +Allowed units are defined in `org-duration-units'. Match group +1 contains the bare number. Match group 2 contains the unit.") + +(defvar org-duration--full-re nil + "Regexp matching a duration expressed with units. +Allowed units are defined in `org-duration-units'.") + +(defvar org-duration--mixed-re nil + "Regexp matching a duration expressed with units and H:MM or H:MM:SS format. +Allowed units are defined in `org-duration-units'. Match group +1 contains units part. Match group 2 contains H:MM or H:MM:SS +part.") + +(defun org-duration--modifier (unit &optional canonical) + "Return modifier associated to string UNIT. +When optional argument CANONICAL is non-nil, refer to +`org-duration-canonical-units' instead of `org-duration-units'." + (or (cdr (assoc unit (if canonical + org-duration-canonical-units + org-duration-units))) + (error "Unknown unit: %S" unit))) + + +;;; Public functions + +;;;###autoload +(defun org-duration-set-regexps () + "Set duration related regexps." + (interactive) + (setq org-duration--unit-re + (concat "\\([0-9]+\\(?:\\.[0-9]*\\)?\\)[ \t]*" + ;; Since user-defined units in `org-duration-units' + ;; can differ from canonical units in + ;; `org-duration-canonical-units', include both in + ;; regexp. + (regexp-opt (mapcar #'car (append org-duration-canonical-units + org-duration-units)) + t))) + (setq org-duration--full-re + (format "\\`[ \t]*%s\\(?:[ \t]+%s\\)*[ \t]*\\'" + org-duration--unit-re + org-duration--unit-re)) + (setq org-duration--mixed-re + (format "\\`[ \t]*\\(?1:%s\\(?:[ \t]+%s\\)*\\)[ \t]+\ +\\(?2:[0-9]+\\(?::[0-9][0-9]\\)\\{1,2\\}\\)[ \t]*\\'" + org-duration--unit-re + org-duration--unit-re))) + +;;;###autoload +(defun org-duration-p (s) + "Non-nil when string S is a time duration." + (and (stringp s) + (or (string-match-p org-duration--full-re s) + (string-match-p org-duration--mixed-re s) + (string-match-p org-duration--h:mm-re s)))) + +;;;###autoload +(defun org-duration-to-minutes (duration &optional canonical) + "Return number of minutes of DURATION string. + +When optional argument CANONICAL is non-nil, ignore +`org-duration-units' and use standard time units value. + +As a special case, a bare number represents minutes. + +Return value as a float. Raise an error if duration format is +not recognized." + (cond + ((numberp duration) (float duration)) + ((string-match-p org-duration--h:mm-re duration) + (pcase-let ((`(,hours ,minutes ,seconds) + (mapcar #'string-to-number (split-string duration ":")))) + (+ (/ (or seconds 0) 60.0) minutes (* 60 hours)))) + ((string-match-p org-duration--full-re duration) + (let ((minutes 0) + (s 0)) + (while (string-match org-duration--unit-re duration s) + (setq s (match-end 0)) + (let ((value (string-to-number (match-string 1 duration))) + (unit (match-string 2 duration))) + (cl-incf minutes (* value (org-duration--modifier unit canonical))))) + (float minutes))) + ((string-match org-duration--mixed-re duration) + (let ((units-part (match-string 1 duration)) + (hms-part (match-string 2 duration))) + (+ (org-duration-to-minutes units-part) + (org-duration-to-minutes hms-part)))) + ((string-match-p "\\`[0-9]+\\(\\.[0-9]*\\)?\\'" duration) + (float (string-to-number duration))) + (t (error "Invalid duration format: %S" duration)))) + +;;;###autoload +(defun org-duration-from-minutes (minutes &optional fmt canonical) + "Return duration string for a given number of MINUTES. + +Format duration according to `org-duration-format' or FMT, when +non-nil. + +When optional argument CANONICAL is non-nil, ignore +`org-duration-units' and use standard time units value. + +Raise an error if expected format is unknown." + (pcase (or fmt org-duration-format) + (`h:mm + (let ((minutes (floor minutes))) + (format "%d:%02d" (/ minutes 60) (mod minutes 60)))) + (`h:mm:ss + (let ((seconds (floor (* 60 minutes)) )) + (format "%s:%02d" + (org-duration-from-minutes (/ seconds 60) 'h:mm) + (mod seconds 60)))) + ((pred atom) (error "Invalid duration format specification: %S" fmt)) + ;; Mixed format. Call recursively the function on both parts. + ((and duration-format + (let `(special . ,(and mode (or `h:mm:ss `h:mm))) + (assq 'special duration-format))) + (let* ((truncated-format + ;; Remove "special" mode from duration format in order to + ;; recurse properly. Also remove units smaller or equal + ;; to an hour since H:MM part takes care of it. + (cl-remove-if-not + (lambda (pair) + (pcase pair + (`(,(and unit (pred stringp)) . ,_) + (> (org-duration--modifier unit canonical) 60)) + (_ nil))) + duration-format)) + (min-modifier ;smallest modifier above hour + (and truncated-format + (apply #'min + (mapcar (lambda (p) + (org-duration--modifier (car p) canonical)) + truncated-format))))) + (if (or (null min-modifier) (< minutes min-modifier)) + ;; There is not unit above the hour or the smallest unit + ;; above the hour is too large for the number of minutes we + ;; need to represent. Use H:MM or H:MM:SS syntax. + (org-duration-from-minutes minutes mode canonical) + ;; Represent minutes above hour using provided units and H:MM + ;; or H:MM:SS below. + (let* ((units-part (* min-modifier (floor (/ minutes min-modifier)))) + (minutes-part (- minutes units-part))) + (concat + (org-duration-from-minutes units-part truncated-format canonical) + " " + (org-duration-from-minutes minutes-part mode)))))) + ;; Units format. + (duration-format + (let* ((fractional + (let ((digits (cdr (assq 'special duration-format)))) + (and digits + (or (wholenump digits) + (error "Unknown formatting directive: %S" digits)) + (format "%%.%df" digits)))) + (selected-units + (sort (cl-remove-if + ;; Ignore special format cells. + (lambda (pair) (pcase pair (`(special . ,_) t) (_ nil))) + duration-format) + (lambda (a b) + (> (org-duration--modifier (car a) canonical) + (org-duration--modifier (car b) canonical)))))) + (cond + ;; Fractional duration: use first unit that is either required + ;; or smaller than MINUTES. + (fractional + (let* ((unit (car + (or (cl-find-if + (lambda (pair) + (pcase pair + (`(,u . ,req?) + (or req? + (<= (org-duration--modifier u canonical) + minutes))))) + selected-units) + ;; Fall back to smallest unit. + (org-last selected-units)))) + (modifier (org-duration--modifier unit canonical))) + (concat (format fractional (/ (float minutes) modifier)) unit))) + ;; Otherwise build duration string according to available + ;; units. + ((org-string-nw-p + (org-trim + (mapconcat + (lambda (units) + (pcase-let* ((`(,unit . ,required?) units) + (modifier (org-duration--modifier unit canonical))) + (cond ((<= modifier minutes) + (let ((value (floor (/ minutes modifier)))) + (cl-decf minutes (* value modifier)) + (format " %d%s" value unit))) + (required? (concat " 0" unit)) + (t "")))) + selected-units + "")))) + ;; No unit can properly represent MINUTES. Use the smallest + ;; one anyway. + (t + (pcase-let ((`((,unit . ,_)) (last selected-units))) + (concat + (if (not fractional) "0" + (let ((modifier (org-duration--modifier unit canonical))) + (format fractional (/ (float minutes) modifier)))) + unit)))))))) + +;;;###autoload +(defun org-duration-h:mm-only-p (times) + "Non-nil when every duration in TIMES has \"H:MM\" or \"H:MM:SS\" format. + +TIMES is a list of duration strings. + +Return nil if any duration is expressed with units, as defined in +`org-duration-units'. Otherwise, if any duration is expressed +with \"H:MM:SS\" format, return `h:mm:ss'. Otherwise, return +`h:mm'." + (let (hms-flag) + (catch :exit + (dolist (time times) + (cond ((string-match-p org-duration--full-re time) + (throw :exit nil)) + ((string-match-p org-duration--mixed-re time) + (throw :exit nil)) + (hms-flag nil) + ((string-match-p org-duration--h:mm:ss-re time) + (setq hms-flag 'h:mm:ss)))) + (or hms-flag 'h:mm)))) + + +;;; Initialization + +(org-duration-set-regexps) + +(provide 'org-duration) +;;; org-duration.el ends here diff --git a/elpa/org-plus-contrib-20150831/org-effectiveness.el b/elpa/org-plus-contrib-20170407/org-effectiveness.el similarity index 70% rename from elpa/org-plus-contrib-20150831/org-effectiveness.el rename to elpa/org-plus-contrib-20170407/org-effectiveness.el index 0d830abd..a07084c9 100644 --- a/elpa/org-plus-contrib-20150831/org-effectiveness.el +++ b/elpa/org-plus-contrib-20170407/org-effectiveness.el @@ -1,6 +1,6 @@ ;;; org-effectiveness.el --- Measuring the personal effectiveness -;; Copyright (C) 2013 Free Software Foundation, Inc. +;; Copyright (C) 2013-2017 Free Software Foundation, Inc. ;; Author: David Arroyo Menéndez ;; Keywords: effectiveness, plot @@ -34,7 +34,7 @@ (require 'org) (defcustom org-effectiveness-max-todo 50 - "This variable is useful to advice to the user about + "This variable is useful to advice to the user about many TODO pending" :type 'integer :group 'org-effectiveness) @@ -42,9 +42,10 @@ many TODO pending" (defun org-effectiveness-advice() "Advicing about a possible excess of TODOS" (interactive) - (goto-char (point-min)) - (if (< org-effectiveness-max-todo (count-matches "* TODO")) - (message "An excess of TODOS!"))) + (save-excursion + (goto-char (point-min)) + (if (< org-effectiveness-max-todo (count-matches "* TODO")) + (message "An excess of TODOS!")))) ;; Check advice starting an org file (add-hook 'org-mode-hook 'org-effectiveness-advice) @@ -59,10 +60,10 @@ many TODO pending" (defun org-effectiveness-count-todo() "Print a message with the number of todo tasks in the current buffer" (interactive) - (save-excursion + (save-excursion (goto-char (point-min)) (message "Number of TODO: %d" (count-matches "* TODO")))) - + (defun org-effectiveness-count-done() "Print a message with the number of done tasks in the current buffer" (interactive) @@ -77,6 +78,13 @@ many TODO pending" (goto-char (point-min)) (message "Number of Canceled: %d" (count-matches "* CANCEL+ED")))) +(defun org-effectiveness-count-task() + "Print a message with the number of tasks and subtasks in the current buffer" + (interactive) + (save-excursion + (goto-char (point-min)) + (message "Number of tasks: %d" (count-matches "^*")))) + (defun org-effectiveness() "Returns the effectiveness in the current org buffer" (interactive) @@ -89,25 +97,41 @@ many TODO pending" (setq effectiveness (* 100 (/ done (+ done canc))))) (message "Effectiveness: %f" effectiveness)))) + (defun org-effectiveness-keywords-in-date(keyword date) (interactive "sKeyword: \nsDate: " keyword date) (setq count (count-matches (concat keyword ".*\n.*" date))) (message (concat "%sS: %d" keyword count))) -(defun org-effectiveness-dones-in-date(date) - (interactive "sGive me a date: " date) - (setq count (count-matches (concat "DONE.*\n.*" date))) - (message "DONES: %d" count)) +(defun org-effectiveness-dones-in-date(date &optional notmessage) + (interactive "sGive me a date: " date) + (save-excursion + (goto-char (point-min)) + (let ((count (count-matches (concat "DONE.*\n.*" date)))) + (if (eq notmessage 1) + (message "%d" count) + (message "DONES: %d " count))))) -(defun org-effectivenes-todos-in-date(date) - (interactive "sGive me a date: " date) - (setq count (count-matches (concat "TODO.*\n.*" date))) - (message "TODOS: %d" count)) +(defun org-effectiveness-todos-in-date(date) + (interactive "sGive me a date: " date) + (save-excursion + (goto-char (point-min)) + (setq count (count-matches (concat "TODO.*\n.*" date))) + (message "TODOS: %d" count))) (defun org-effectiveness-canceled-in-date(date) - (interactive "sGive me a date: " date) - (setq count (count-matches (concat "CANCEL+ED.*\n.*" date))) - (message "CANCELEDS: %d" count)) + (interactive "sGive me a date: " date) + (save-excursion + (goto-char (point-min)) + (setq count (count-matches (concat "CANCEL+ED.*\n.*" date))) + (message "CANCELEDS: %d" count))) + +(defun org-effectiveness-ntasks-in-date(date &optional notmessage) + (interactive "sGive me a date: " date) + (save-excursion + (goto-char (point-min)) + (let ((tasks (float (count-matches (concat "^*.*\n.*" date))))) + (message "%d" tasks)))) (defun org-effectiveness-in-date(date &optional notmessage) (interactive "sGive me a date: " date) @@ -130,14 +154,14 @@ many TODO pending" (defun org-effectiveness-plot(startdate enddate &optional save) (interactive "sGive me the start date: \nsGive me the end date: " startdate enddate) (setq dates (org-effectiveness-check-dates startdate enddate)) - (setq syear (cadr (assoc 'startyear dates))) - (setq smonth (cadr (assoc 'startmonth dates))) - (setq eyear (cadr (assoc 'endyear dates))) - (setq emonth (assoc 'endmonth dates)) + (setq syear (cadr (assq 'startyear dates))) + (setq smonth (cadr (assq 'startmonth dates))) + (setq eyear (cadr (assq 'endyear dates))) + (setq emonth (assq 'endmonth dates)) ;; Checking the format of the dates - (if (not (string-match "[0-9][0-9][0-9][0-9]-[0-9][0-9]" startdate)) + (if (not (string-match "[0-9][0-9][0-9][0-9]-[0-9][0-9]" startdate)) (message "The start date must have the next format YYYY-MM")) - (if (not (string-match "[0-9][0-9][0-9][0-9]-[0-9][0-9]" enddate)) + (if (not (string-match "[0-9][0-9][0-9][0-9]-[0-9][0-9]" enddate)) (message "The end date must have the next format YYYY-MM")) ;; Checking if startdate < enddate (if (string-match "^[0-9][0-9][0-9][0-9]" startdate) @@ -152,19 +176,19 @@ many TODO pending" (message "The start date must be before that end date")) (if (and (= startyear endyear) (> startmonth endmonth)) (message "The start date must be before that end date")) -;; Create a file +;; Create a file (let ((month startmonth) (year startyear) (str "")) - (while (or (> endyear year) (and (= endyear year) (>= endmonth month))) + (while (or (> endyear year) (and (= endyear year) (>= endmonth month))) (setq str (concat str (number-to-string year) "-" (org-effectiveness-month-to-string month) " " (org-effectiveness-in-date (concat (number-to-string year) "-" (org-effectiveness-month-to-string month)) 1) "\n")) (if (= month 12) - (progn + (progn (setq year (+ 1 year)) (setq month 1)) (setq month (+ 1 month)))) (write-region str nil "/tmp/org-effectiveness")) -;; Create the bar graph +;; Create the bar graph (if (eq save t) (setq strplot "/usr/bin/gnuplot -e 'set term png; set output \"/tmp/org-effectiveness.png\"; plot \"/tmp/org-effectiveness\" using 2:xticlabels(1) with histograms' -p") (setq strplot "/usr/bin/gnuplot -e 'plot \"/tmp/org-effectiveness\" using 2:xticlabels(1) with histograms' -p")) @@ -221,9 +245,9 @@ many TODO pending" (defun org-effectiveness-check-dates (startdate enddate) "Generate a list with ((startyear startmonth) (endyear endmonth))" (setq str nil) - (if (not (string-match "[0-9][0-9][0-9][0-9]-[0-9][0-9]" startdate)) + (if (not (string-match "[0-9][0-9][0-9][0-9]-[0-9][0-9]" startdate)) (setq str "The start date must have the next format YYYY-MM")) - (if (not (string-match "[0-9][0-9][0-9][0-9]-[0-9][0-9]" enddate)) + (if (not (string-match "[0-9][0-9][0-9][0-9]-[0-9][0-9]" enddate)) (setq str "The end date must have the next format YYYY-MM")) ;; Checking if startdate < enddate (if (string-match "^[0-9][0-9][0-9][0-9]" startdate) @@ -246,12 +270,12 @@ many TODO pending" (defun org-effectiveness-plot-ascii (startdate enddate) (interactive "sGive me the start date: \nsGive me the end date: " startdate enddate) (setq dates (org-effectiveness-check-dates startdate enddate)) - (let ((syear (cadr (assoc 'startyear dates))) - (smonth (cadr (assoc 'startmonth dates))) - (year (cadr (assoc 'startyear dates))) - (month (cadr (assoc 'startmonth dates))) - (emonth (cadr (assoc 'endmonth dates))) - (eyear (cadr (assoc 'endyear dates))) + (let ((syear (cadr (assq 'startyear dates))) + (smonth (cadr (assq 'startmonth dates))) + (year (cadr (assq 'startyear dates))) + (month (cadr (assq 'startmonth dates))) + (emonth (cadr (assq 'endmonth dates))) + (eyear (cadr (assq 'endyear dates))) (buffer (current-buffer)) (str "")) (while (or (> eyear year) (and (= eyear year) (>= emonth month))) @@ -260,22 +284,70 @@ many TODO pending" (org-effectiveness-ascii-bar (string-to-number str) (format "%s-%s" year month)) (switch-to-buffer buffer) (if (eq month 12) - (progn + (progn + (setq year (+ 1 year)) + (setq month 1)) + (setq month (+ 1 month))))) + (switch-to-buffer "*org-effectiveness*")) + + +(defun org-effectiveness-plot-ascii-ntasks (startdate enddate) + (interactive "sGive me the start date: \nsGive me the end date: " startdate enddate) + (setq dates (org-effectiveness-check-dates startdate enddate)) + (let ((syear (cadr (assq 'startyear dates))) + (smonth (cadr (assq 'startmonth dates))) + (year (cadr (assq 'startyear dates))) + (month (cadr (assq 'startmonth dates))) + (emonth (cadr (assq 'endmonth dates))) + (eyear (cadr (assq 'endyear dates))) + (buffer (current-buffer)) + (str "")) + (while (or (> eyear year) (and (= eyear year) (>= emonth month))) + (setq str (org-effectiveness-ntasks-in-date (concat (number-to-string year) "-" (org-effectiveness-month-to-string month)) 1)) + (switch-to-buffer "*org-effectiveness*") + (org-effectiveness-ascii-bar (string-to-number str) (format "%s-%s" year month)) + (switch-to-buffer buffer) + (if (eq month 12) + (progn (setq year (+ 1 year)) (setq month 1)) (setq month (+ 1 month))))) (switch-to-buffer "*org-effectiveness*")) +(defun org-effectiveness-plot-ascii-dones (startdate enddate) + (interactive "sGive me the start date: \nsGive me the end date: " startdate enddate) + (setq dates (org-effectiveness-check-dates startdate enddate)) + (let ((syear (cadr (assq 'startyear dates))) + (smonth (cadr (assq 'startmonth dates))) + (year (cadr (assq 'startyear dates))) + (month (cadr (assq 'startmonth dates))) + (emonth (cadr (assq 'endmonth dates))) + (eyear (cadr (assq 'endyear dates))) + (buffer (current-buffer)) + (str "")) + (while (or (> eyear year) (and (= eyear year) (>= emonth month))) + (setq str (org-effectiveness-dones-in-date (concat (number-to-string year) "-" (org-effectiveness-month-to-string month)) 1)) + (switch-to-buffer "*org-effectiveness*") + (org-effectiveness-ascii-bar (string-to-number str) (format "%s-%s" year month)) + (switch-to-buffer buffer) + (if (eq month 12) + (progn + (setq year (+ 1 year)) + (setq month 1)) + (setq month (+ 1 month))))) + (switch-to-buffer "*org-effectiveness*")) + + (defun org-effectiveness-plot-html (startdate enddate) "Print html bars about the effectiveness in a buffer" (interactive "sGive me the start date: \nsGive me the end date: " startdate enddate) (setq dates (org-effectiveness-check-dates startdate enddate)) - (let ((syear (cadr (assoc 'startyear dates))) - (smonth (cadr (assoc 'startmonth dates))) - (year (cadr (assoc 'startyear dates))) - (month (cadr (assoc 'startmonth dates))) - (emonth (cadr (assoc 'endmonth dates))) - (eyear (cadr (assoc 'endyear dates))) + (let ((syear (cadr (assq 'startyear dates))) + (smonth (cadr (assq 'startmonth dates))) + (year (cadr (assq 'startyear dates))) + (month (cadr (assq 'startmonth dates))) + (emonth (cadr (assq 'endmonth dates))) + (eyear (cadr (assq 'endyear dates))) (buffer (current-buffer)) (str "")) (switch-to-buffer "*org-effectiveness-html*") @@ -287,7 +359,7 @@ many TODO pending" (switch-to-buffer buffer) (format "%s-%s" year month) (if (eq month 12) - (progn + (progn (setq year (+ 1 year)) (setq month 1)) (setq month (+ 1 month)))) @@ -295,4 +367,3 @@ many TODO pending" (insert ""))) (provide 'org-effectiveness) - diff --git a/elpa/org-plus-contrib-20150831/org-eldoc.el b/elpa/org-plus-contrib-20170407/org-eldoc.el similarity index 87% rename from elpa/org-plus-contrib-20150831/org-eldoc.el rename to elpa/org-plus-contrib-20170407/org-eldoc.el index c970b275..74dc69bb 100644 --- a/elpa/org-plus-contrib-20150831/org-eldoc.el +++ b/elpa/org-plus-contrib-20170407/org-eldoc.el @@ -1,6 +1,6 @@ ;;; org-eldoc.el --- display org header and src block info using eldoc -;; Copyright (c) 2014 Free Software Foundation, Inc. +;; Copyright (c) 2014-2017 Free Software Foundation, Inc. ;; Author: Łukasz Gruner ;; Maintainer: Łukasz Gruner @@ -38,6 +38,10 @@ (require 'ob-core) (require 'eldoc) +(declare-function org-element-at-point "org-element" ()) +(declare-function org-element-property "org-element" (property element)) +(declare-function org-element-type "org-element" (element)) + (defgroup org-eldoc nil "" :group 'org) (defcustom org-eldoc-breadcrumb-separator "/" @@ -70,7 +74,7 @@ (save-match-data (when (looking-at "^[ \t]*#\\+\\(begin\\|end\\)_src") (setq info (org-babel-get-src-block-info 'light) - lang (propertize (nth 0 info) 'face 'font-lock-string-face) + lang (propertize (or (nth 0 info) "no lang") 'face 'font-lock-string-face) hdr-args (nth 2 info)) (concat lang @@ -87,13 +91,17 @@ (defun org-eldoc-get-src-lang () "Return value of lang for the current block if in block body and nil otherwise." - (let ((case-fold-search t)) - (save-match-data - (when (org-between-regexps-p ".*#\\+begin_src" - ".*#\\+end_src") - (save-excursion - (goto-char (org-babel-where-is-src-block-head)) - (car (org-babel-parse-src-block-match))))))) + (let ((element (save-match-data (org-element-at-point)))) + (and (eq (org-element-type element) 'src-block) + (>= (line-beginning-position) + (org-element-property :post-affiliated element)) + (<= + (line-end-position) + (org-with-wide-buffer + (goto-char (org-element-property :end element)) + (skip-chars-backward " \t\n") + (line-end-position))) + (org-element-property :language element)))) (defvar org-eldoc-local-functions-cache (make-hash-table :size 40 :test 'equal) "Cache of major-mode's eldoc-documentation-functions, @@ -147,7 +155,7 @@ (string= lang "golang")) (when (require 'go-eldoc nil t) (go-eldoc--documentation-function))) (t (let ((doc-fun (org-eldoc-get-mode-local-documentation-function lang))) - (when (fboundp doc-fun) (funcall doc-fun)))))))) + (when (functionp doc-fun) (funcall doc-fun)))))))) ;;;###autoload (defun org-eldoc-load () diff --git a/elpa/org-plus-contrib-20150831/org-element.el b/elpa/org-plus-contrib-20170407/org-element.el similarity index 81% rename from elpa/org-plus-contrib-20150831/org-element.el rename to elpa/org-plus-contrib-20170407/org-element.el index 8f41ab28..bec36a00 100644 --- a/elpa/org-plus-contrib-20150831/org-element.el +++ b/elpa/org-plus-contrib-20170407/org-element.el @@ -1,6 +1,6 @@ -;;; org-element.el --- Parser And Applications for Org syntax +;;; org-element.el --- Parser for Org Syntax -*- lexical-binding: t; -*- -;; Copyright (C) 2012-2015 Free Software Foundation, Inc. +;; Copyright (C) 2012-2017 Free Software Foundation, Inc. ;; Author: Nicolas Goaziou ;; Keywords: outlines, hypermedia, calendar, wp @@ -116,9 +116,9 @@ ;;; Code: -(eval-when-compile (require 'cl)) (require 'org) (require 'avl-tree) +(require 'cl-lib) @@ -151,7 +151,7 @@ specially in `org-element--object-lex'.") ;; Headlines, inlinetasks. org-outline-regexp "\\|" ;; Footnote definitions. - "\\[\\(?:[0-9]+\\|fn:[-_[:word:]]+\\)\\]" "\\|" + "\\[fn:[-_[:word:]]+\\]" "\\|" ;; Diary sexps. "%%(" "\\|" "[ \t]*\\(?:" @@ -177,15 +177,15 @@ specially in `org-element--object-lex'.") ;; Clock lines. (regexp-quote org-clock-string) "\\|" ;; Lists. - (let ((term (case org-plain-list-ordered-item-terminator - (?\) ")") (?. "\\.") (otherwise "[.)]"))) + (let ((term (pcase org-plain-list-ordered-item-terminator + (?\) ")") (?. "\\.") (_ "[.)]"))) (alpha (and org-list-allow-alphabetical "\\|[A-Za-z]"))) (concat "\\(?:[-+*]\\|\\(?:[0-9]+" alpha "\\)" term "\\)" "\\(?:[ \t]\\|$\\)")) "\\)\\)") org-element--object-regexp (mapconcat #'identity - (let ((link-types (regexp-opt org-link-types))) + (let ((link-types (regexp-opt (org-link-types)))) (list ;; Sub/superscript. "\\(?:[_^][-{(*+.,[:alnum:]]\\)" @@ -199,7 +199,12 @@ specially in `org-element--object-lex'.") ;; Objects starting with "[": regular link, ;; footnote reference, statistics cookie, ;; timestamp (inactive). - "\\[\\(?:fn:\\|\\(?:[0-9]\\|\\(?:%\\|/[0-9]*\\)\\]\\)\\|\\[\\)" + (concat "\\[\\(?:" + "fn:" "\\|" + "\\[" "\\|" + "[0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}" "\\|" + "[0-9]*\\(?:%\\|/[0-9]*\\)\\]" + "\\)") ;; Objects starting with "@": export snippets. "@@" ;; Objects starting with "{": macro. @@ -258,17 +263,6 @@ specially in `org-element--object-lex'.") (append org-element-recursive-objects '(paragraph table-row verse-block)) "List of object or element types that can directly contain objects.") -(defvar org-element-block-name-alist - '(("CENTER" . org-element-center-block-parser) - ("COMMENT" . org-element-comment-block-parser) - ("EXAMPLE" . org-element-example-block-parser) - ("QUOTE" . org-element-quote-block-parser) - ("SRC" . org-element-src-block-parser) - ("VERSE" . org-element-verse-block-parser)) - "Alist between block names and the associated parsing function. -Names must be uppercase. Any block whose name has no association -is parsed with `org-element-special-block-parser'.") - (defconst org-element-affiliated-keywords '("CAPTION" "DATA" "HEADER" "HEADERS" "LABEL" "NAME" "PLOT" "RESNAME" "RESULT" "RESULTS" "SOURCE" "SRCNAME" "TBLNAME") @@ -334,7 +328,7 @@ This list is checked after translations have been applied. See ;; Regular affiliated keywords. (format "\\(?1:%s\\)" (regexp-opt - (org-remove-if + (cl-remove-if (lambda (k) (member k org-element-dual-keywords)) org-element-affiliated-keywords))) "\\|" @@ -358,11 +352,11 @@ Don't modify it, set `org-element-affiliated-keywords' instead.") (italic ,@standard-set) (item ,@standard-set-no-line-break) (keyword ,@(remq 'footnote-reference standard-set)) - ;; Ignore all links excepted plain links in a link description. - ;; Also ignore radio-targets and line breaks. + ;; Ignore all links in a link description. Also ignore + ;; radio-targets and line breaks. (link bold code entity export-snippet inline-babel-call inline-src-block - italic latex-fragment macro plain-link statistics-cookie - strike-through subscript superscript underline verbatim) + italic latex-fragment macro statistics-cookie strike-through + subscript superscript underline verbatim) (paragraph ,@standard-set) ;; Remove any variable object from radio target as it would ;; prevent it from being properly recognized. @@ -399,6 +393,15 @@ still has an entry since one of its properties (`:title') does.") (item :tag)) "Alist between element types and locations of secondary values.") +(defconst org-element--pair-round-table + (let ((table (make-syntax-table))) + (modify-syntax-entry ?\( "()" table) + (modify-syntax-entry ?\) ")(" table) + (dolist (char '(?\{ ?\} ?\[ ?\] ?\< ?\>) table) + (modify-syntax-entry char " " table))) + "Table used internally to pair only round brackets. +Other brackets are treated as spaces.") + (defconst org-element--pair-square-table (let ((table (make-syntax-table))) (modify-syntax-entry ?\[ "(]" table) @@ -408,6 +411,33 @@ still has an entry since one of its properties (`:title') does.") "Table used internally to pair only square brackets. Other brackets are treated as spaces.") +(defconst org-element--pair-curly-table + (let ((table (make-syntax-table))) + (modify-syntax-entry ?\{ "(}" table) + (modify-syntax-entry ?\} "){" table) + (dolist (char '(?\[ ?\] ?\( ?\) ?\< ?\>) table) + (modify-syntax-entry char " " table))) + "Table used internally to pair only curly brackets. +Other brackets are treated as spaces.") + +(defun org-element--parse-paired-brackets (char) + "Parse paired brackets at point. +CHAR is the opening bracket to consider, as a character. Return +contents between brackets, as a string, or nil. Also move point +past the brackets." + (when (eq char (char-after)) + (let ((syntax-table (pcase char + (?\{ org-element--pair-curly-table) + (?\[ org-element--pair-square-table) + (?\( org-element--pair-round-table) + (_ nil))) + (pos (point))) + (when syntax-table + (with-syntax-table syntax-table + (let ((end (ignore-errors (scan-lists pos 1 0)))) + (when end + (goto-char end) + (buffer-substring-no-properties (1+ pos) (1- end))))))))) ;;; Accessors and Setters @@ -415,17 +445,19 @@ Other brackets are treated as spaces.") ;; Provide four accessors: `org-element-type', `org-element-property' ;; `org-element-contents' and `org-element-restriction'. ;; -;; Setter functions allow to modify elements by side effect. There is -;; `org-element-put-property', `org-element-set-contents'. These -;; low-level functions are useful to build a parse tree. +;; Setter functions allow modification of elements by side effect. +;; There is `org-element-put-property', `org-element-set-contents'. +;; These low-level functions are useful to build a parse tree. ;; ;; `org-element-adopt-element', `org-element-set-element', ;; `org-element-extract-element' and `org-element-insert-before' are ;; high-level functions useful to modify a parse tree. ;; ;; `org-element-secondary-p' is a predicate used to know if a given -;; object belongs to a secondary string. `org-element-copy' returns -;; an element or object, stripping its parent property in the process. +;; object belongs to a secondary string. `org-element-class' tells if +;; some parsed data is an element or an object, handling pseudo +;; elements and objects. `org-element-copy' returns an element or +;; object, stripping its parent property in the process. (defsubst org-element-type (element) "Return type of ELEMENT. @@ -465,10 +497,11 @@ Return modified element." element)) (defsubst org-element-set-contents (element &rest contents) - "Set ELEMENT contents to CONTENTS." - (cond ((not element) (list contents)) + "Set ELEMENT's contents to CONTENTS. +Return ELEMENT." + (cond ((null element) contents) ((not (symbolp (car element))) contents) - ((cdr element) (setcdr (cdr element) contents)) + ((cdr element) (setcdr (cdr element) contents) element) (t (nconc element contents)))) (defun org-element-secondary-p (object) @@ -482,6 +515,32 @@ Return value is the property name, as a keyword, or nil." (and (memq object (org-element-property p parent)) (throw 'exit p)))))) +(defsubst org-element-class (datum &optional parent) + "Return class for ELEMENT, as a symbol. +Class is either `element' or `object'. Optional argument PARENT +is the element or object containing DATUM. It defaults to the +value of DATUM `:parent' property." + (let ((type (org-element-type datum)) + (parent (or parent (org-element-property :parent datum)))) + (cond + ;; Trivial cases. + ((memq type org-element-all-objects) 'object) + ((memq type org-element-all-elements) 'element) + ;; Special cases. + ((eq type 'org-data) 'element) + ((eq type 'plain-text) 'object) + ((not type) 'object) + ;; Pseudo object or elements. Make a guess about its class. + ;; Basically a pseudo object is contained within another object, + ;; a secondary string or a container element. + ((not parent) 'element) + (t + (let ((parent-type (org-element-type parent))) + (cond ((not parent-type) 'object) + ((memq parent-type org-element-object-containers) 'object) + ((org-element-secondary-p datum) 'object) + (t 'element))))))) + (defsubst org-element-adopt-elements (parent &rest children) "Append elements to the contents of another element. @@ -533,16 +592,15 @@ Parse tree is modified by side effect." (specialp (and (not property) (eq siblings parent) (eq (car parent) location)))) - ;; Install ELEMENT at the appropriate POSITION within SIBLINGS. + ;; Install ELEMENT at the appropriate LOCATION within SIBLINGS. (cond (specialp) ((or (null siblings) (eq (car siblings) location)) (push element siblings)) ((null location) (nconc siblings (list element))) - (t (let ((previous (cadr (memq location (reverse siblings))))) - (if (not previous) - (error "No location found to insert element") - (let ((next (memq previous siblings))) - (setcdr next (cons element (cdr next)))))))) + (t + (let ((index (cl-position location siblings))) + (unless index (error "No location found to insert element")) + (push element (cdr (nthcdr (1- index) siblings)))))) ;; Store SIBLINGS at appropriate place in parse tree. (cond (specialp (setcdr parent (copy-sequence parent)) (setcar parent element)) @@ -587,11 +645,11 @@ DATUM is an element, object, string or nil. `:parent' property is cleared and contents are removed in the process." (when datum (let ((type (org-element-type datum))) - (case type - (org-data (list 'org-data nil)) - (plain-text (substring-no-properties datum)) - ((nil) (copy-sequence datum)) - (otherwise + (pcase type + (`org-data (list 'org-data nil)) + (`plain-text (substring-no-properties datum)) + (`nil (copy-sequence datum)) + (_ (list type (plist-put (copy-sequence (nth 1 datum)) :parent nil))))))) @@ -625,7 +683,7 @@ is cleared and contents are removed in the process." ;; cannot contain other greater elements of their own type. ;; ;; Beside implementing a parser and an interpreter, adding a new -;; greater element requires to tweak `org-element--current-element'. +;; greater element requires tweaking `org-element--current-element'. ;; Moreover, the newly defined type must be added to both ;; `org-element-all-elements' and `org-element-greater-elements'. @@ -674,8 +732,8 @@ Assume point is at the beginning of the block." :post-affiliated post-affiliated) (cdr affiliated)))))))) -(defun org-element-center-block-interpreter (center-block contents) - "Interpret CENTER-BLOCK element as Org syntax. +(defun org-element-center-block-interpreter (_ contents) + "Interpret a center-block element as Org syntax. CONTENTS is the contents of the element." (format "#+BEGIN_CENTER\n%s#+END_CENTER" contents)) @@ -702,7 +760,7 @@ Assume point is at beginning of drawer." (save-excursion (let* ((drawer-end-line (match-beginning 0)) (name (progn (looking-at org-drawer-regexp) - (org-match-string-no-properties 1))) + (match-string-no-properties 1))) (begin (car affiliated)) (post-affiliated (point)) ;; Empty drawers have no contents. @@ -758,8 +816,8 @@ Assume point is at beginning of dynamic block." (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)) + (match-string-no-properties 1))) + (arguments (match-string-no-properties 3)) (begin (car affiliated)) (post-affiliated (point)) ;; Empty blocks have no contents. @@ -796,6 +854,12 @@ CONTENTS is the contents of the element." ;;;; Footnote Definition +(defconst org-element--footnote-separator + (concat org-outline-regexp-bol "\\|" + org-footnote-definition-re "\\|" + "^\\([ \t]*\n\\)\\{2,\\}") + "Regexp used as a footnote definition separator.") + (defun org-element-footnote-definition-parser (limit affiliated) "Parse a footnote definition. @@ -811,24 +875,32 @@ a plist containing `:label', `:begin' `:end', `:contents-begin', 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))) + (match-string-no-properties 1))) (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]*\n\\)\\{2,\\}") limit 'move)) - (match-beginning 0) - (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))))) + (ending + (save-excursion + (end-of-line) + (cond + ((not + (re-search-forward org-element--footnote-separator limit t)) + limit) + ((eq (char-after (match-beginning 0)) ?\[) + ;; At a new footnote definition, make sure we end + ;; before any affiliated keyword above. + (forward-line -1) + (while (and (> (point) post-affiliated) + (looking-at-p org-element--affiliated-re)) + (forward-line -1)) + (line-beginning-position 2)) + (t (match-beginning 0))))) + (contents-begin + (progn + (search-forward "]") + (skip-chars-forward " \r\t\n" ending) + (cond ((= (point) ending) nil) + ((= (line-beginning-position) post-affiliated) (point)) + (t (line-beginning-position))))) (contents-end (and contents-begin ending)) (end (progn (goto-char ending) (skip-chars-forward " \r\t\n" limit) @@ -847,7 +919,7 @@ Assume point is at the beginning of the footnote definition." (defun org-element-footnote-definition-interpreter (footnote-definition contents) "Interpret FOOTNOTE-DEFINITION element as Org syntax. CONTENTS is the contents of the footnote-definition." - (concat (format "[%s]" (org-element-property :label footnote-definition)) + (concat (format "[fn:%s]" (org-element-property :label footnote-definition)) " " contents)) @@ -861,13 +933,13 @@ obtained through property drawer and default properties from the parser (e.g. `:end' and :END:). Return value is a plist." (save-excursion (forward-line) - (when (org-looking-at-p org-planning-line-re) (forward-line)) + (when (looking-at-p org-planning-line-re) (forward-line)) (when (looking-at org-property-drawer-re) (forward-line) (let ((end (match-end 0)) properties) (while (< (line-end-position) end) (looking-at org-property-re) - (push (org-match-string-no-properties 3) properties) + (push (match-string-no-properties 3) properties) (push (intern (concat ":" (upcase (match-string 2)))) properties) (forward-line)) properties)))) @@ -930,7 +1002,7 @@ Assume point is at beginning of the headline." (goto-char (match-end 0)))) (title-start (point)) (tags (when (re-search-forward - (org-re "[ \t]+\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$") + "[ \t]+\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$" (line-end-position) 'move) (goto-char (match-beginning 0)) @@ -944,15 +1016,14 @@ Assume point is at beginning of the headline." (standard-props (org-element--get-node-properties)) (time-props (org-element--get-time-properties)) (end (min (save-excursion (org-end-of-subtree t t)) limit)) - (pos-after-head (progn (forward-line) (point))) (contents-begin (save-excursion + (forward-line) (skip-chars-forward " \r\t\n" end) (and (/= (point) end) (line-beginning-position)))) (contents-end (and contents-begin (progn (goto-char end) (skip-chars-backward " \r\t\n") - (forward-line) - (point))))) + (line-beginning-position 2))))) (let ((headline (list 'headline (nconc @@ -961,7 +1032,7 @@ Assume point is at beginning of the headline." :end end :pre-blank (if (not contents-begin) 0 - (count-lines pos-after-head contents-begin)) + (1- (count-lines begin contents-begin))) :contents-begin contents-begin :contents-end contents-end :level level @@ -969,9 +1040,10 @@ Assume point is at beginning of the headline." :tags tags :todo-keyword todo :todo-type todo-type - :post-blank (count-lines - (or contents-end pos-after-head) - end) + :post-blank + (if contents-end + (count-lines contents-end end) + (1- (count-lines begin end))) :footnote-section-p footnote-section-p :archivedp archivedp :commentedp commentedp @@ -981,17 +1053,16 @@ Assume point is at beginning of the headline." (org-element-put-property headline :title (if raw-secondary-p raw-value - (let ((title (org-element--parse-objects - (progn (goto-char title-start) - (skip-chars-forward " \t") - (point)) - (progn (goto-char title-end) - (skip-chars-backward " \t") - (point)) - nil - (org-element-restriction 'headline)))) - (dolist (datum title title) - (org-element-put-property datum :parent headline))))))))) + (org-element--parse-objects + (progn (goto-char title-start) + (skip-chars-forward " \t") + (point)) + (progn (goto-char title-end) + (skip-chars-backward " \t") + (point)) + nil + (org-element-restriction 'headline) + headline))))))) (defun org-element-headline-interpreter (headline contents) "Interpret HEADLINE element as Org syntax. @@ -1043,10 +1114,11 @@ CONTENTS is the contents of the element." "Parse an inline task. Return a list whose CAR is `inlinetask' and CDR is a plist -containing `:title', `:begin', `:end', `:contents-begin' and -`:contents-end', `:level', `:priority', `:raw-value', `:tags', -`:todo-keyword', `:todo-type', `:scheduled', `:deadline', -`:closed', `:post-blank' and `:post-affiliated' keywords. +containing `:title', `:begin', `:end', `:pre-blank', +`:contents-begin' and `:contents-end', `:level', `:priority', +`:raw-value', `:tags', `:todo-keyword', `:todo-type', +`:scheduled', `:deadline', `:closed', `:post-blank' and +`:post-affiliated' keywords. The plist also contains any property set in the property drawer, with its name in upper cases and colons added at the @@ -1073,7 +1145,7 @@ Assume point is at beginning of the inline task." (aref (match-string 0) 2)))) (title-start (point)) (tags (when (re-search-forward - (org-re "[ \t]+\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$") + "[ \t]+\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$" (line-end-position) 'move) (goto-char (match-beginning 0)) @@ -1084,18 +1156,20 @@ Assume point is at beginning of the inline task." (task-end (save-excursion (end-of-line) (and (re-search-forward org-outline-regexp-bol limit t) - (org-looking-at-p "END[ \t]*$") + (looking-at-p "[ \t]*END[ \t]*$") (line-beginning-position)))) (standard-props (and task-end (org-element--get-node-properties))) (time-props (and task-end (org-element--get-time-properties))) - (contents-begin (progn (forward-line) - (and task-end (< (point) task-end) (point)))) + (contents-begin (and task-end + (< (point) task-end) + (progn + (forward-line) + (skip-chars-forward " \t\n") + (line-beginning-position)))) (contents-end (and contents-begin task-end)) - (before-blank (if (not task-end) (point) - (goto-char task-end) - (forward-line) - (point))) - (end (progn (skip-chars-forward " \r\t\n" limit) + (end (progn (when task-end (goto-char task-end)) + (forward-line) + (skip-chars-forward " \r\t\n" limit) (if (eobp) (point) (line-beginning-position)))) (inlinetask (list 'inlinetask @@ -1103,6 +1177,9 @@ Assume point is at beginning of the inline task." (list :raw-value raw-value :begin begin :end end + :pre-blank + (if (not contents-begin) 0 + (1- (count-lines begin contents-begin))) :contents-begin contents-begin :contents-end contents-end :level level @@ -1110,24 +1187,23 @@ Assume point is at beginning of the inline task." :tags tags :todo-keyword todo :todo-type todo-type - :post-blank (count-lines before-blank end) + :post-blank (1- (count-lines (or task-end begin) end)) :post-affiliated begin) time-props standard-props)))) (org-element-put-property inlinetask :title (if raw-secondary-p raw-value - (let ((title (org-element--parse-objects - (progn (goto-char title-start) - (skip-chars-forward " \t") - (point)) - (progn (goto-char title-end) - (skip-chars-backward " \t") - (point)) - nil - (org-element-restriction 'inlinetask)))) - (dolist (datum title title) - (org-element-put-property datum :parent inlinetask)))))))) + (org-element--parse-objects + (progn (goto-char title-start) + (skip-chars-forward " \t") + (point)) + (progn (goto-char title-end) + (skip-chars-backward " \t") + (point)) + nil + (org-element-restriction 'inlinetask) + inlinetask)))))) (defun org-element-inlinetask-interpreter (inlinetask contents) "Interpret INLINETASK element as Org syntax. @@ -1169,7 +1245,7 @@ CONTENTS is the contents of inlinetask." ;;;; Item -(defun org-element-item-parser (limit struct &optional raw-secondary-p) +(defun org-element-item-parser (_ struct &optional raw-secondary-p) "Parse an item. STRUCT is the structure of the plain list. @@ -1188,7 +1264,7 @@ Assume point is at the beginning of the item." (beginning-of-line) (looking-at org-list-full-item-re) (let* ((begin (point)) - (bullet (org-match-string-no-properties 1)) + (bullet (match-string-no-properties 1)) (checkbox (let ((box (match-string 3))) (cond ((equal "[ ]" box) 'off) ((equal "[X]" box) 'on) @@ -1239,11 +1315,10 @@ Assume point is at the beginning of the item." (let ((raw (org-list-get-tag begin struct))) (when raw (if raw-secondary-p raw - (let ((tag (org-element--parse-objects - (match-beginning 4) (match-end 4) nil - (org-element-restriction 'item)))) - (dolist (datum tag tag) - (org-element-put-property datum :parent item)))))))))) + (org-element--parse-objects + (match-beginning 4) (match-end 4) nil + (org-element-restriction 'item) + item)))))))) (defun org-element-item-interpreter (item contents) "Interpret ITEM element as Org syntax. @@ -1266,10 +1341,11 @@ CONTENTS is the contents of the element." (concat bullet (and counter (format "[@%d] " counter)) - (case checkbox - (on "[X] ") - (off "[ ] ") - (trans "[-] ")) + (pcase checkbox + (`on "[X] ") + (`off "[ ] ") + (`trans "[-] ") + (_ nil)) (and tag (format "%s :: " tag)) (when contents (let ((contents (replace-regexp-in-string @@ -1337,7 +1413,7 @@ CONTENTS is the contents of the element." (forward-line) (let ((origin (point))) (when (re-search-forward inlinetask-re limit t) - (if (org-looking-at-p "END[ \t]*$") (forward-line) + (if (looking-at-p "END[ \t]*$") (forward-line) (goto-char origin))))) ;; At some text line. Check if it ends any previous item. (t @@ -1379,7 +1455,7 @@ containing `:type', `:begin', `:end', `:contents-begin' and Assume point is at the beginning of the list." (save-excursion (let* ((struct (or structure (org-element--list-struct limit))) - (type (cond ((org-looking-at-p "[ \t]*[A-Za-z0-9]") 'ordered) + (type (cond ((looking-at-p "[ \t]*[A-Za-z0-9]") 'ordered) ((nth 5 (assq (point) struct)) 'descriptive) (t 'unordered))) (contents-begin (point)) @@ -1407,8 +1483,8 @@ Assume point is at the beginning of the list." :post-affiliated contents-begin) (cdr affiliated)))))) -(defun org-element-plain-list-interpreter (plain-list contents) - "Interpret PLAIN-LIST element as Org syntax. +(defun org-element-plain-list-interpreter (_ contents) + "Interpret plain-list element as Org syntax. CONTENTS is the contents of the element." (with-temp-buffer (insert contents) @@ -1447,8 +1523,8 @@ Assume point is at the beginning of the property drawer." :post-blank (count-lines before-blank end) :post-affiliated begin)))))) -(defun org-element-property-drawer-interpreter (property-drawer contents) - "Interpret PROPERTY-DRAWER element as Org syntax. +(defun org-element-property-drawer-interpreter (_ contents) + "Interpret property-drawer element as Org syntax. CONTENTS is the properties within the drawer." (format ":PROPERTIES:\n%s:END:" contents)) @@ -1497,19 +1573,17 @@ Assume point is at the beginning of the block." :post-affiliated post-affiliated) (cdr affiliated))))))))) -(defun org-element-quote-block-interpreter (quote-block contents) - "Interpret QUOTE-BLOCK element as Org syntax. +(defun org-element-quote-block-interpreter (_ contents) + "Interpret quote-block element as Org syntax. CONTENTS is the contents of the element." (format "#+BEGIN_QUOTE\n%s#+END_QUOTE" contents)) ;;;; Section -(defun org-element-section-parser (limit) +(defun org-element-section-parser (_) "Parse a section. -LIMIT bounds the search. - Return a list whose CAR is `section' and CDR is a plist containing `:begin', `:end', `:contents-begin', `contents-end', `:post-blank' and `:post-affiliated' keywords." @@ -1520,8 +1594,7 @@ containing `:begin', `:end', `:contents-begin', `contents-end', (end (progn (org-with-limited-levels (outline-next-heading)) (point))) (pos-before-blank (progn (skip-chars-backward " \r\t\n") - (forward-line) - (point)))) + (line-beginning-position 2)))) (list 'section (list :begin begin :end end @@ -1530,8 +1603,8 @@ containing `:begin', `:end', `:contents-begin', `contents-end', :post-blank (count-lines pos-before-blank end) :post-affiliated begin))))) -(defun org-element-section-interpreter (section contents) - "Interpret SECTION element as Org syntax. +(defun org-element-section-interpreter (_ contents) + "Interpret section element as Org syntax. CONTENTS is the contents of the element." contents) @@ -1602,9 +1675,6 @@ CONTENTS is the contents of the element." ;; through the following steps: implement a parser and an interpreter, ;; tweak `org-element--current-element' so that it recognizes the new ;; type and add that new type to `org-element-all-elements'. -;; -;; As a special case, when the newly defined type is a block type, -;; `org-element-block-name-alist' has to be modified accordingly. ;;;; Babel Call @@ -1651,9 +1721,8 @@ containing `:call', `:inside-header', `:arguments', :post-affiliated post-affiliated) (cdr affiliated)))))) -(defun org-element-babel-call-interpreter (babel-call contents) - "Interpret BABEL-CALL element as Org syntax. -CONTENTS is nil." +(defun org-element-babel-call-interpreter (babel-call _) + "Interpret BABEL-CALL element as Org syntax." (concat "#+CALL: " (org-element-property :call babel-call) (let ((h (org-element-property :inside-header babel-call))) @@ -1682,7 +1751,7 @@ Return a list whose CAR is `clock' and CDR is a plist containing (duration (and (search-forward " => " (line-end-position) t) (progn (skip-chars-forward " \t") (looking-at "\\(\\S-+\\)[ \t]*$")) - (org-match-string-no-properties 1))) + (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) @@ -1699,9 +1768,8 @@ Return a list whose CAR is `clock' and CDR is a plist containing :post-blank post-blank :post-affiliated begin))))) -(defun org-element-clock-interpreter (clock contents) - "Interpret CLOCK element as Org syntax. -CONTENTS is nil." +(defun org-element-clock-interpreter (clock _) + "Interpret CLOCK element as Org syntax." (concat org-clock-string " " (org-element-timestamp-interpreter (org-element-property :value clock) nil) @@ -1760,7 +1828,7 @@ Assume point is at comment beginning." :post-affiliated post-affiliated) (cdr affiliated)))))) -(defun org-element-comment-interpreter (comment contents) +(defun org-element-comment-interpreter (comment _) "Interpret COMMENT element as Org syntax. CONTENTS is nil." (replace-regexp-in-string "^" "# " (org-element-property :value comment))) @@ -1807,9 +1875,8 @@ Assume point is at comment block beginning." :post-affiliated post-affiliated) (cdr affiliated))))))))) -(defun org-element-comment-block-interpreter (comment-block contents) - "Interpret COMMENT-BLOCK element as Org syntax. -CONTENTS is nil." +(defun org-element-comment-block-interpreter (comment-block _) + "Interpret COMMENT-BLOCK element as Org syntax." (format "#+BEGIN_COMMENT\n%s#+END_COMMENT" (org-element-normalize-string (org-remove-indentation @@ -1833,7 +1900,7 @@ containing `:begin', `:end', `:value', `:post-blank' and (let ((begin (car affiliated)) (post-affiliated (point)) (value (progn (looking-at "\\(%%(.*\\)[ \t]*$") - (org-match-string-no-properties 1))) + (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))))) @@ -1846,9 +1913,8 @@ containing `:begin', `:end', `:value', `:post-blank' and :post-affiliated post-affiliated) (cdr affiliated)))))) -(defun org-element-diary-sexp-interpreter (diary-sexp contents) - "Interpret DIARY-SEXP as Org syntax. -CONTENTS is nil." +(defun org-element-diary-sexp-interpreter (diary-sexp _) + "Interpret DIARY-SEXP as Org syntax." (org-element-property :value diary-sexp)) @@ -1876,12 +1942,20 @@ containing `:begin', `:end', `:number-lines', `:preserve-indent', (let* ((switches (progn (looking-at "^[ \t]*#\\+BEGIN_EXAMPLE\\(?: +\\(.*\\)\\)?") - (org-match-string-no-properties 1))) - ;; Switches analysis + (match-string-no-properties 1))) + ;; Switches analysis. (number-lines - (cond ((not switches) nil) - ((string-match "-n\\>" switches) 'new) - ((string-match "+n\\>" switches) 'continued))) + (and switches + (string-match "\\([-+]\\)n\\(?: *\\([0-9]+\\)\\)?\\>" + switches) + (cons + (if (equal (match-string 1 switches) "-") + 'new + 'continued) + (if (not (match-end 2)) 0 + ;; Subtract 1 to give number of lines before + ;; first line. + (1- (string-to-number (match-string 2 switches))))))) (preserve-indent (and switches (string-match "-i\\>" switches))) ;; Should labels be retained in (or stripped from) example @@ -1903,13 +1977,10 @@ containing `:begin', `:end', `:number-lines', `:preserve-indent', ;; Standard block parsing. (begin (car affiliated)) (post-affiliated (point)) - (block-ind (progn (skip-chars-forward " \t") (current-column))) - (contents-begin (progn (forward-line) (point))) - (value (org-element-remove-indentation - (org-unescape-code-in-string - (buffer-substring-no-properties - contents-begin contents-end)) - block-ind)) + (contents-begin (line-beginning-position 2)) + (value (org-unescape-code-in-string + (buffer-substring-no-properties + contents-begin contents-end))) (pos-before-blank (progn (goto-char contents-end) (forward-line) (point))) @@ -1930,9 +2001,8 @@ containing `:begin', `:end', `:number-lines', `:preserve-indent', :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." +(defun org-element-example-block-interpreter (example-block _) + "Interpret EXAMPLE-BLOCK element as Org syntax." (let ((switches (org-element-property :switches example-block)) (value (org-element-property :value example-block))) (concat "#+BEGIN_EXAMPLE" (and switches (concat " " switches)) "\n" @@ -1941,7 +2011,7 @@ CONTENTS is nil." (if (or org-src-preserve-indentation (org-element-property :preserve-indent example-block)) value - (org-element-remove-indentation value)))) + (org-remove-indentation value)))) "#+END_EXAMPLE"))) @@ -1960,43 +2030,44 @@ containing `:begin', `:end', `:type', `:value', `:post-blank' and `:post-affiliated' keywords. Assume point is at export-block beginning." - (let* ((case-fold-search t) - (type (progn (looking-at "[ \t]*#\\+BEGIN_\\(\\S-+\\)") - (upcase (org-match-string-no-properties 1))))) + (let* ((case-fold-search t)) (if (not (save-excursion - (re-search-forward - (format "^[ \t]*#\\+END_%s[ \t]*$" type) limit t))) + (re-search-forward "^[ \t]*#\\+END_EXPORT[ \t]*$" limit t))) ;; Incomplete block: parse it as a paragraph. (org-element-paragraph-parser limit affiliated) - (let ((contents-end (match-beginning 0))) - (save-excursion - (let* ((begin (car affiliated)) - (post-affiliated (point)) - (contents-begin (progn (forward-line) (point))) - (pos-before-blank (progn (goto-char contents-end) - (forward-line) - (point))) - (end (progn (skip-chars-forward " \r\t\n" limit) - (if (eobp) (point) (line-beginning-position)))) - (value (buffer-substring-no-properties contents-begin - contents-end))) - (list 'export-block - (nconc - (list :begin begin - :end end - :type type - :value value - :post-blank (count-lines pos-before-blank end) - :post-affiliated post-affiliated) - (cdr affiliated))))))))) + (save-excursion + (let* ((contents-end (match-beginning 0)) + (backend + (progn + (looking-at + "[ \t]*#\\+BEGIN_EXPORT\\(?:[ \t]+\\(\\S-+\\)\\)?[ \t]*$") + (match-string-no-properties 1))) + (begin (car affiliated)) + (post-affiliated (point)) + (contents-begin (progn (forward-line) (point))) + (pos-before-blank (progn (goto-char contents-end) + (forward-line) + (point))) + (end (progn (skip-chars-forward " \r\t\n" limit) + (if (eobp) (point) (line-beginning-position)))) + (value (org-unescape-code-in-string + (buffer-substring-no-properties contents-begin + contents-end)))) + (list 'export-block + (nconc + (list :type (and backend (upcase backend)) + :begin begin + :end end + :value value + :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. -CONTENTS is nil." - (let ((type (org-element-property :type export-block))) - (concat (format "#+BEGIN_%s\n" type) - (org-element-property :value export-block) - (format "#+END_%s" type)))) +(defun org-element-export-block-interpreter (export-block _) + "Interpret EXPORT-BLOCK element as Org syntax." + (format "#+BEGIN_EXPORT %s\n%s#+END_EXPORT" + (org-element-property :type export-block) + (org-element-property :value export-block))) ;;;; Fixed-width @@ -2041,9 +2112,8 @@ Assume point is at the beginning of the fixed-width area." :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." +(defun org-element-fixed-width-interpreter (fixed-width _) + "Interpret FIXED-WIDTH element as Org syntax." (let ((value (org-element-property :value fixed-width))) (and value (replace-regexp-in-string @@ -2078,9 +2148,8 @@ keywords." :post-affiliated post-affiliated) (cdr affiliated)))))) -(defun org-element-horizontal-rule-interpreter (horizontal-rule contents) - "Interpret HORIZONTAL-RULE element as Org syntax. -CONTENTS is nil." +(defun org-element-horizontal-rule-interpreter (&rest _) + "Interpret HORIZONTAL-RULE element as Org syntax." "-----") @@ -2104,7 +2173,7 @@ containing `:key', `:value', `:begin', `:end', `:post-blank' and (let ((begin (or (car affiliated) (point))) (post-affiliated (point)) (key (progn (looking-at "[ \t]*#\\+\\(\\S-+*\\):") - (upcase (org-match-string-no-properties 1)))) + (upcase (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))) @@ -2120,9 +2189,8 @@ containing `:key', `:value', `:begin', `:end', `:post-blank' and :post-affiliated post-affiliated) (cdr affiliated)))))) -(defun org-element-keyword-interpreter (keyword contents) - "Interpret KEYWORD element as Org syntax. -CONTENTS is nil." +(defun org-element-keyword-interpreter (keyword _) + "Interpret KEYWORD element as Org syntax." (format "#+%s: %s" (org-element-property :key keyword) (org-element-property :value keyword))) @@ -2178,9 +2246,8 @@ Assume point is at the beginning of the latex environment." :post-affiliated code-begin) (cdr affiliated)))))))) -(defun org-element-latex-environment-interpreter (latex-environment contents) - "Interpret LATEX-ENVIRONMENT element as Org syntax. -CONTENTS is nil." +(defun org-element-latex-environment-interpreter (latex-environment _) + "Interpret LATEX-ENVIRONMENT element as Org syntax." (org-element-property :value latex-environment)) @@ -2197,8 +2264,8 @@ containing `:key', `:value', `:begin', `:end', `:post-blank' and (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)) + (key (match-string-no-properties 2)) + (value (match-string-no-properties 3)) (end (save-excursion (end-of-line) (if (re-search-forward org-property-re limit t) @@ -2212,9 +2279,8 @@ containing `:key', `:value', `:begin', `:end', `:post-blank' and :post-blank 0 :post-affiliated begin)))) -(defun org-element-node-property-interpreter (node-property contents) - "Interpret NODE-PROPERTY element as Org syntax. -CONTENTS is nil." +(defun org-element-node-property-interpreter (node-property _) + "Interpret NODE-PROPERTY element as Org syntax." (format org-property-format (format ":%s:" (org-element-property :key node-property)) (or (org-element-property :value node-property) ""))) @@ -2289,8 +2355,8 @@ Assume point is at the beginning of the paragraph." :post-affiliated contents-begin) (cdr affiliated)))))) -(defun org-element-paragraph-interpreter (paragraph contents) - "Interpret PARAGRAPH element as Org syntax. +(defun org-element-paragraph-interpreter (_ contents) + "Interpret paragraph element as Org syntax. CONTENTS is the contents of the element." contents) @@ -2333,11 +2399,10 @@ containing `:closed', `:deadline', `:scheduled', `:begin', :post-blank post-blank :post-affiliated begin))))) -(defun org-element-planning-interpreter (planning contents) - "Interpret PLANNING element as Org syntax. -CONTENTS is nil." +(defun org-element-planning-interpreter (planning _) + "Interpret PLANNING element as Org syntax." (mapconcat - 'identity + #'identity (delq nil (list (let ((deadline (org-element-property :deadline planning))) (when deadline @@ -2384,20 +2449,28 @@ Assume point is at the beginning of the block." (language (progn (looking-at - (concat "^[ \t]*#\\+BEGIN_SRC" - "\\(?: +\\(\\S-+\\)\\)?" - "\\(\\(?: +\\(?:-l \".*?\"\\|[-+][A-Za-z]\\)\\)+\\)?" - "\\(.*\\)[ \t]*$")) - (org-match-string-no-properties 1))) + "^[ \t]*#\\+BEGIN_SRC\ +\\(?: +\\(\\S-+\\)\\)?\ +\\(\\(?: +\\(?:-\\(?:l \".+\"\\|[ikr]\\)\\|[-+]n\\(?: *[0-9]+\\)?\\)\\)+\\)?\ +\\(.*\\)[ \t]*$") + (match-string-no-properties 1))) ;; Get switches. - (switches (org-match-string-no-properties 2)) + (switches (match-string-no-properties 2)) ;; Get parameters. - (parameters (org-match-string-no-properties 3)) - ;; Switches analysis + (parameters (match-string-no-properties 3)) + ;; Switches analysis. (number-lines - (cond ((not switches) nil) - ((string-match "-n\\>" switches) 'new) - ((string-match "+n\\>" switches) 'continued))) + (and switches + (string-match "\\([-+]\\)n\\(?: *\\([0-9]+\\)\\)?\\>" + switches) + (cons + (if (equal (match-string 1 switches) "-") + 'new + 'continued) + (if (not (match-end 2)) 0 + ;; Subtract 1 to give number of lines before + ;; first line. + (1- (string-to-number (match-string 2 switches))))))) (preserve-indent (and switches (string-match "-i\\>" switches))) (label-fmt @@ -2416,14 +2489,10 @@ Assume point is at the beginning of the block." (or (not switches) (and retain-labels (not (string-match "-k\\>" switches))))) - ;; Indentation. - (block-ind (progn (skip-chars-forward " \t") (current-column))) ;; Retrieve code. - (value (org-element-remove-indentation - (org-unescape-code-in-string - (buffer-substring-no-properties - (progn (forward-line) (point)) contents-end)) - block-ind)) + (value (org-unescape-code-in-string + (buffer-substring-no-properties + (line-beginning-position 2) contents-end))) (pos-before-blank (progn (goto-char contents-end) (forward-line) (point))) @@ -2449,9 +2518,8 @@ Assume point is at the beginning of the block." :post-affiliated post-affiliated) (cdr affiliated))))))))) -(defun org-element-src-block-interpreter (src-block contents) - "Interpret SRC-BLOCK element as Org syntax. -CONTENTS is nil." +(defun org-element-src-block-interpreter (src-block _) + "Interpret SRC-BLOCK element as Org syntax." (let ((lang (org-element-property :language src-block)) (switches (org-element-property :switches src-block)) (params (org-element-property :parameters src-block)) @@ -2461,11 +2529,12 @@ CONTENTS is nil." ((or org-src-preserve-indentation (org-element-property :preserve-indent src-block)) val) - ((zerop org-edit-src-content-indentation) val) + ((zerop org-edit-src-content-indentation) + (org-remove-indentation val)) (t (let ((ind (make-string org-edit-src-content-indentation ?\s))) (replace-regexp-in-string - "\\(^\\)[ \t]*\\S-" ind val nil nil 1))))))) + "^" ind (org-remove-indentation val)))))))) (concat (format "#+BEGIN_SRC%s\n" (concat (and lang (concat " " lang)) (and switches (concat " " switches)) @@ -2503,7 +2572,7 @@ Assume point is at the beginning of the table." (point))) (tblfm (let (acc) (while (looking-at "[ \t]*#\\+TBLFM: +\\(.*\\)[ \t]*$") - (push (org-match-string-no-properties 1) acc) + (push (match-string-no-properties 1) acc) (forward-line)) acc)) (pos-before-blank (point)) @@ -2542,11 +2611,9 @@ CONTENTS is a string, if table's type is `org', or nil." ;;;; Table Row -(defun org-element-table-row-parser (limit) +(defun org-element-table-row-parser (_) "Parse table row at point. -LIMIT bounds the search. - Return a list whose CAR is `table-row' and CDR is a plist containing `:begin', `:end', `:contents-begin', `:contents-end', `:type', `:post-blank' and `:post-affiliated' keywords." @@ -2555,9 +2622,7 @@ containing `:begin', `:end', `:contents-begin', `:contents-end', (begin (point)) ;; A table rule has no contents. In that case, ensure ;; CONTENTS-BEGIN matches CONTENTS-END. - (contents-begin (and (eq type 'standard) - (search-forward "|") - (point))) + (contents-begin (and (eq type 'standard) (search-forward "|"))) (contents-end (and (eq type 'standard) (progn (end-of-line) @@ -2577,7 +2642,7 @@ containing `:begin', `:end', `:contents-begin', `:contents-end', "Interpret TABLE-ROW element as Org syntax. CONTENTS is the contents of the table row." (if (eq (org-element-property :type table-row) 'rule) "|-" - (concat "| " contents))) + (concat "|" contents))) ;;;; Verse Block @@ -2620,8 +2685,8 @@ Assume point is at beginning of the block." :post-affiliated post-affiliated) (cdr affiliated))))))))) -(defun org-element-verse-block-interpreter (verse-block contents) - "Interpret VERSE-BLOCK element as Org syntax. +(defun org-element-verse-block-interpreter (_ contents) + "Interpret verse-block element as Org syntax. CONTENTS is verse block contents." (format "#+BEGIN_VERSE\n%s#+END_VERSE" contents)) @@ -2669,8 +2734,8 @@ Assume point is at the first star marker." :contents-end contents-end :post-blank post-blank)))))) -(defun org-element-bold-interpreter (bold contents) - "Interpret BOLD object as Org syntax. +(defun org-element-bold-interpreter (_ contents) + "Interpret bold object as Org syntax. CONTENTS is the contents of the object." (format "*%s*" contents)) @@ -2687,9 +2752,9 @@ keywords. Otherwise, return nil. Assume point is at the first tilde marker." (save-excursion (unless (bolp) (backward-char 1)) - (when (looking-at org-emph-re) + (when (looking-at org-verbatim-re) (let ((begin (match-beginning 2)) - (value (org-match-string-no-properties 4)) + (value (match-string-no-properties 4)) (post-blank (progn (goto-char (match-end 2)) (skip-chars-forward " \t"))) (end (point))) @@ -2699,9 +2764,8 @@ Assume point is at the first tilde marker." :end end :post-blank post-blank)))))) -(defun org-element-code-interpreter (code contents) - "Interpret CODE object as Org syntax. -CONTENTS is nil." +(defun org-element-code-interpreter (code _) + "Interpret CODE object as Org syntax." (format "~%s~" (org-element-property :value code))) @@ -2740,9 +2804,8 @@ Assume point is at the beginning of the entity." :use-brackets-p bracketsp :post-blank post-blank))))))) -(defun org-element-entity-interpreter (entity contents) - "Interpret ENTITY object as Org syntax. -CONTENTS is nil." +(defun org-element-entity-interpreter (entity _) + "Interpret ENTITY object as Org syntax." (concat "\\" (org-element-property :name entity) (when (org-element-property :use-brackets-p entity) "{}"))) @@ -2767,7 +2830,7 @@ Assume point is at the beginning of the snippet." (re-search-forward "@@" nil t) (match-beginning 0)))) (let* ((begin (match-beginning 0)) - (back-end (org-match-string-no-properties 1)) + (back-end (match-string-no-properties 1)) (value (buffer-substring-no-properties (match-end 0) contents-end)) (post-blank (skip-chars-forward " \t")) @@ -2779,9 +2842,8 @@ Assume point is at the beginning of the snippet." :end end :post-blank post-blank))))))) -(defun org-element-export-snippet-interpreter (export-snippet contents) - "Interpret EXPORT-SNIPPET object as Org syntax. -CONTENTS is nil." +(defun org-element-export-snippet-interpreter (export-snippet _) + "Interpret EXPORT-SNIPPET object as Org syntax." (format "@@%s:%s@@" (org-element-property :back-end export-snippet) (org-element-property :value export-snippet))) @@ -2802,14 +2864,10 @@ When at a footnote reference, return a list whose car is (when closing (save-excursion (let* ((begin (point)) - (label - (or (org-match-string-no-properties 2) - (org-match-string-no-properties 3) - (and (match-string 1) - (concat "fn:" (org-match-string-no-properties 1))))) - (type (if (or (not label) (match-string 1)) 'inline 'standard)) + (label (match-string-no-properties 1)) (inner-begin (match-end 0)) (inner-end (1- closing)) + (type (if (match-end 2) 'inline 'standard)) (post-blank (progn (goto-char closing) (skip-chars-forward " \t"))) (end (point))) @@ -2825,9 +2883,9 @@ When at a footnote reference, return a list whose car is (defun org-element-footnote-reference-interpreter (footnote-reference contents) "Interpret FOOTNOTE-REFERENCE object as Org syntax. CONTENTS is its definition, when inline, or nil." - (format "[%s]" - (concat (or (org-element-property :label footnote-reference) "fn:") - (and contents (concat ":" contents))))) + (format "[fn:%s%s]" + (or (org-element-property :label footnote-reference) "") + (if contents (concat ":" contents) ""))) ;;;; Inline Babel Call @@ -2842,31 +2900,39 @@ When at an inline babel call, return a list whose car is Assume point is at the beginning of the babel call." (save-excursion - (unless (bolp) (backward-char)) - (when (let ((case-fold-search t)) - (looking-at org-babel-inline-lob-one-liner-regexp)) - (let ((begin (match-end 1)) - (call (org-match-string-no-properties 2)) - (inside-header (org-string-nw-p (org-match-string-no-properties 4))) - (arguments (org-string-nw-p (org-match-string-no-properties 6))) - (end-header (org-string-nw-p (org-match-string-no-properties 8))) - (value (buffer-substring-no-properties (match-end 1) (match-end 0))) - (post-blank (progn (goto-char (match-end 0)) - (skip-chars-forward " \t"))) - (end (point))) - (list 'inline-babel-call - (list :call call - :inside-header inside-header - :arguments arguments - :end-header end-header - :begin begin - :end end - :value value - :post-blank post-blank)))))) + (catch :no-object + (when (let ((case-fold-search nil)) + (looking-at "\\. Unlike to ;; bracket links, follow RFC 3986 and remove any extra ;; whitespace in URI. ((looking-at org-angle-link-re) - (setq type (org-match-string-no-properties 1)) + (setq format 'angle) + (setq type (match-string-no-properties 1)) (setq link-end (match-end 0)) (setq raw-link (buffer-substring-no-properties (match-beginning 1) (match-end 2))) (setq path (replace-regexp-in-string - "[ \t]*\n[ \t]*" "" (org-match-string-no-properties 2)))) + "[ \t]*\n[ \t]*" "" (match-string-no-properties 2)))) (t (throw 'no-object nil))) ;; In any case, deduce end point after trailing white space from ;; LINK-END variable. @@ -3125,16 +3194,17 @@ Assume point is at the beginning of the link." (when (string-match "::\\(.*\\)\\'" path) (setq search-option (match-string 1 path)) (setq path (replace-match "" nil nil path))) - (setq path (replace-regexp-in-string "\\`/+" "/" path))) + (setq path (replace-regexp-in-string "\\`///*\\(.:\\)?/" "\\1/" path))) ;; Translate link, if `org-link-translation-function' is set. (let ((trans (and (functionp org-link-translation-function) (funcall org-link-translation-function type path)))) (when trans (setq type (car trans)) - (setq path (cdr trans)))) + (setq path (cdr trans)))) (list 'link (list :type type :path path + :format format :raw-link (or raw-link path) :application application :search-option search-option @@ -3150,18 +3220,38 @@ CONTENTS is the contents of the object, or nil." (let ((type (org-element-property :type link)) (path (org-element-property :path link))) (if (string= type "radio") path - (format "[[%s]%s]" - (cond ((string= type "coderef") (format "(%s)" path)) - ((string= type "custom-id") (concat "#" path)) - ((string= type "file") - (let ((app (org-element-property :application link)) - (opt (org-element-property :search-option link))) - (concat type (and app (concat "+" app)) ":" - path - (and opt (concat "::" opt))))) - ((string= type "fuzzy") path) - (t (concat type ":" path))) - (if contents (format "[%s]" contents) ""))))) + (let ((fmt (pcase (org-element-property :format link) + ;; Links with contents and internal links have to + ;; use bracket syntax. Ignore `:format' in these + ;; cases. This is also the default syntax when the + ;; property is not defined, e.g., when the object + ;; was crafted by the user. + ((guard contents) + (format "[[%%s][%s]]" + ;; Since this is going to be used as + ;; a format string, escape percent signs + ;; in description. + (replace-regexp-in-string "%" "%%" contents))) + ((or `bracket + `nil + (guard (member type '("coderef" "custom-id" "fuzzy")))) + "[[%s]]") + ;; Otherwise, just obey to `:format'. + (`angle "<%s>") + (`plain "%s") + (f (error "Wrong `:format' value: %s" f))))) + (format fmt + (pcase type + ("coderef" (format "(%s)" path)) + ("custom-id" (concat "#" path)) + ("file" + (let ((app (org-element-property :application link)) + (opt (org-element-property :search-option link))) + (concat type (and app (concat "+" app)) ":" + path + (and opt (concat "::" opt))))) + ("fuzzy" path) + (_ (concat type ":" path)))))))) ;;;; Macro @@ -3177,12 +3267,12 @@ Assume point is at the macro." (save-excursion (when (looking-at "{{{\\([a-zA-Z][-a-zA-Z0-9_]*\\)\\(([ \t\n]*\\([^\000]*?\\))\\)?}}}") (let ((begin (point)) - (key (downcase (org-match-string-no-properties 1))) - (value (org-match-string-no-properties 0)) + (key (downcase (match-string-no-properties 1))) + (value (match-string-no-properties 0)) (post-blank (progn (goto-char (match-end 0)) (skip-chars-forward " \t"))) (end (point)) - (args (let ((args (org-match-string-no-properties 3))) + (args (let ((args (match-string-no-properties 3))) (and args (org-macro-extract-arguments args))))) (list 'macro (list :key key @@ -3192,9 +3282,8 @@ Assume point is at the macro." :end end :post-blank post-blank)))))) -(defun org-element-macro-interpreter (macro contents) - "Interpret MACRO object as Org syntax. -CONTENTS is nil." +(defun org-element-macro-interpreter (macro _) + "Interpret MACRO object as Org syntax." (org-element-property :value macro)) @@ -3214,7 +3303,7 @@ Assume point is at the radio target." (let ((begin (point)) (contents-begin (match-beginning 1)) (contents-end (match-end 1)) - (value (org-match-string-no-properties 1)) + (value (match-string-no-properties 1)) (post-blank (progn (goto-char (match-end 0)) (skip-chars-forward " \t"))) (end (point))) @@ -3226,8 +3315,8 @@ Assume point is at the radio target." :post-blank post-blank :value value)))))) -(defun org-element-radio-target-interpreter (target contents) - "Interpret TARGET object as Org syntax. +(defun org-element-radio-target-interpreter (_ contents) + "Interpret target object as Org syntax. CONTENTS is the contents of the object." (concat "<<<" contents ">>>")) @@ -3256,9 +3345,8 @@ Assume point is at the beginning of the statistics-cookie." :value value :post-blank post-blank)))))) -(defun org-element-statistics-cookie-interpreter (statistics-cookie contents) - "Interpret STATISTICS-COOKIE object as Org syntax. -CONTENTS is nil." +(defun org-element-statistics-cookie-interpreter (statistics-cookie _) + "Interpret STATISTICS-COOKIE object as Org syntax." (org-element-property :value statistics-cookie)) @@ -3289,8 +3377,8 @@ Assume point is at the first plus sign marker." :contents-end contents-end :post-blank post-blank)))))) -(defun org-element-strike-through-interpreter (strike-through contents) - "Interpret STRIKE-THROUGH object as Org syntax. +(defun org-element-strike-through-interpreter (_ contents) + "Interpret strike-through object as Org syntax. CONTENTS is the contents of the object." (format "+%s+" contents)) @@ -3390,8 +3478,8 @@ and `:post-blank' keywords." :contents-end contents-end :post-blank 0)))) -(defun org-element-table-cell-interpreter (table-cell contents) - "Interpret TABLE-CELL element as Org syntax. +(defun org-element-table-cell-interpreter (_ contents) + "Interpret table-cell element as Org syntax. CONTENTS is the contents of the cell, or nil." (concat " " contents " |")) @@ -3409,7 +3497,7 @@ Assume point is at the target." (save-excursion (when (looking-at org-target-regexp) (let ((begin (point)) - (value (org-match-string-no-properties 1)) + (value (match-string-no-properties 1)) (post-blank (progn (goto-char (match-end 0)) (skip-chars-forward " \t"))) (end (point))) @@ -3419,9 +3507,8 @@ Assume point is at the target." :value value :post-blank post-blank)))))) -(defun org-element-target-interpreter (target contents) - "Interpret TARGET object as Org syntax. -CONTENTS is nil." +(defun org-element-target-interpreter (target _) + "Interpret TARGET object as Org syntax." (format "<<%s>>" (org-element-property :value target))) @@ -3448,7 +3535,7 @@ cdr a plist with `:type', `:raw-value', `:year-start', Otherwise, return nil. Assume point is at the beginning of the timestamp." - (when (org-looking-at-p org-element--timestamp-regexp) + (when (looking-at-p org-element--timestamp-regexp) (save-excursion (let* ((begin (point)) (activep (eq (char-after) ?<)) @@ -3486,8 +3573,8 @@ Assume point is at the beginning of the timestamp." (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))))) + (pcase (string-to-char (match-string 3 raw-value)) + (?h 'hour) (?d 'day) (?w 'week) (?m 'month) (_ 'year))))) (warning-props (and (not diaryp) (string-match "\\(-\\)?-\\([0-9]+\\)\\([hdwmy]\\)" raw-value) @@ -3495,8 +3582,8 @@ Assume point is at the beginning of the timestamp." :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))))) + (pcase (string-to-char (match-string 3 raw-value)) + (?h 'hour) (?d 'day) (?w 'week) (?m 'month) (_ 'year))))) year-start month-start day-start hour-start minute-start year-end month-end day-end hour-end minute-end) ;; Parse date-start. @@ -3536,26 +3623,24 @@ Assume point is at the beginning of the timestamp." repeater-props warning-props)))))) -(defun org-element-timestamp-interpreter (timestamp contents) - "Interpret TIMESTAMP object as Org syntax. -CONTENTS is nil." +(defun org-element-timestamp-interpreter (timestamp _) + "Interpret TIMESTAMP object as Org syntax." (let* ((repeat-string (concat - (case (org-element-property :repeater-type timestamp) - (cumulate "+") (catch-up "++") (restart ".+")) + (pcase (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")))) + (pcase (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 "-")) + (pcase (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")))) + (pcase (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 @@ -3564,7 +3649,7 @@ CONTENTS is nil." ;; 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) + (funcall (if with-time-p #'cdr #'car) org-time-stamp-formats) time))) (when (and hour-end minute-end) @@ -3583,8 +3668,8 @@ CONTENTS is nil." ;; Return value. ts))) (type (org-element-property :type timestamp))) - (case type - ((active inactive) + (pcase type + ((or `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)) @@ -3604,7 +3689,7 @@ CONTENTS is nil." (and hour-start minute-start) (and time-range-p hour-end) (and time-range-p minute-end)))) - ((active-range inactive-range) + ((or `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)) @@ -3630,7 +3715,7 @@ CONTENTS is nil." (org-element-property :year-end timestamp)) (eq type 'active-range) (and hour-end minute-end))))) - (otherwise (org-element-property :raw-value timestamp))))) + (_ (org-element-property :raw-value timestamp))))) ;;;; Underline @@ -3660,8 +3745,8 @@ Assume point is at the first underscore marker." :contents-end contents-end :post-blank post-blank)))))) -(defun org-element-underline-interpreter (underline contents) - "Interpret UNDERLINE object as Org syntax. +(defun org-element-underline-interpreter (_ contents) + "Interpret underline object as Org syntax. CONTENTS is the contents of the object." (format "_%s_" contents)) @@ -3678,9 +3763,9 @@ and cdr is a plist with `:value', `:begin', `:end' and Assume point is at the first equal sign marker." (save-excursion (unless (bolp) (backward-char 1)) - (when (looking-at org-emph-re) + (when (looking-at org-verbatim-re) (let ((begin (match-beginning 2)) - (value (org-match-string-no-properties 4)) + (value (match-string-no-properties 4)) (post-blank (progn (goto-char (match-end 2)) (skip-chars-forward " \t"))) (end (point))) @@ -3690,9 +3775,8 @@ Assume point is at the first equal sign marker." :end end :post-blank post-blank)))))) -(defun org-element-verbatim-interpreter (verbatim contents) - "Interpret VERBATIM object as Org syntax. -CONTENTS is nil." +(defun org-element-verbatim-interpreter (verbatim _) + "Interpret VERBATIM object as Org syntax." (format "=%s=" (org-element-property :value verbatim))) @@ -3759,10 +3843,14 @@ element it has to parse." (or (save-excursion (org-with-limited-levels (outline-next-heading))) limit))) ;; Planning. - ((and (eq mode 'planning) (looking-at org-planning-line-re)) + ((and (eq mode 'planning) + (eq ?* (char-after (line-beginning-position 0))) + (looking-at org-planning-line-re)) (org-element-planning-parser limit)) ;; Property drawer. ((and (memq mode '(planning property-drawer)) + (eq ?* (char-after (line-beginning-position + (if (eq mode 'planning) 0 -1)))) (looking-at org-property-drawer-re)) (org-element-property-drawer-parser limit)) ;; When not at bol, point is at the beginning of an item or @@ -3794,27 +3882,35 @@ element it has to parse." ;; 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)))) + (cond + ((looking-at "\\(?: \\|$\\)") + (beginning-of-line) + (org-element-comment-parser limit affiliated)) + ((looking-at "\\+BEGIN_\\(\\S-+\\)") + (beginning-of-line) + (funcall (pcase (upcase (match-string 1)) + ("CENTER" #'org-element-center-block-parser) + ("COMMENT" #'org-element-comment-block-parser) + ("EXAMPLE" #'org-element-example-block-parser) + ("EXPORT" #'org-element-export-block-parser) + ("QUOTE" #'org-element-quote-block-parser) + ("SRC" #'org-element-src-block-parser) + ("VERSE" #'org-element-verse-block-parser) + (_ #'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)) @@ -3879,10 +3975,11 @@ position of point and CDR is nil." (dualp (member kwd org-element-dual-keywords)) (dual-value (and dualp - (let ((sec (org-match-string-no-properties 2))) + (let ((sec (match-string-no-properties 2))) (if (or (not sec) (not parsedp)) sec - (org-element--parse-objects - (match-beginning 2) (match-end 2) nil restrict))))) + (save-match-data + (org-element--parse-objects + (match-beginning 2) (match-end 2) nil restrict)))))) ;; Attribute a property name to KWD. (kwd-sym (and kwd (intern (concat ":" (downcase kwd)))))) ;; Now set final shape for VALUE. @@ -3918,8 +4015,8 @@ position of point and CDR is nil." ;; `org-element-parse-secondary-string', which parses objects within ;; a given string. ;; -;; The (almost) almighty `org-element-map' allows to apply a function -;; on elements or objects matching some type, and accumulate the +;; The (almost) almighty `org-element-map' allows applying a function +;; on elements or objects matching some type, and accumulating the ;; resulting values. In an export situation, it also skips unneeded ;; parts of the parse tree. @@ -3995,14 +4092,11 @@ If STRING is the empty string or nil, return nil." (dolist (v local-variables) (ignore-errors (if (symbolp v) (makunbound v) - (org-set-local (car v) (cdr v))))) + (set (make-local-variable (car v)) (cdr v))))) (insert string) (restore-buffer-modified-p nil) - (let ((data (org-element--parse-objects - (point-min) (point-max) nil restriction))) - (when parent - (dolist (o data) (org-element-put-property o :parent parent))) - data)))))) + (org-element--parse-objects + (point-min) (point-max) nil restriction parent)))))) (defun org-element-map (data types fun &optional info first-match no-recursion with-affiliated) @@ -4041,30 +4135,30 @@ Assuming TREE is a variable containing an Org buffer parse tree, the following example will return a flat list of all `src-block' and `example-block' elements in it: - \(org-element-map tree '(example-block src-block) #'identity) + (org-element-map tree \\='(example-block src-block) #\\='identity) 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 - \(lambda (hl) - \(and (= (org-element-property :level hl) 1) - \(member \"phone\" (org-element-property :tags hl)) - \(org-element-property :begin hl))) + (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) 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) + (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 - \(lambda (b) - \(and (org-element-map b 'latex-snippet #'identity nil t) b)) + (org-element-map tree \\='bold + (lambda (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. (let* ((types (if (listp types) types (list types))) @@ -4072,94 +4166,93 @@ looking into captions: (list no-recursion))) ;; Recursion depth is determined by --CATEGORY. (--category - (catch 'found + (catch :--found (let ((category 'greater-elements) (all-objects (cons 'plain-text org-element-all-objects))) (dolist (type types category) (cond ((memq type all-objects) - ;; If one object is found, the function has to - ;; recurse into every object. - (throw 'found 'objects)) + ;; If one object is found, the function has + ;; to recurse into every object. + (throw :--found 'objects)) ((not (memq type org-element-greater-elements)) ;; If one regular element is found, the ;; function has to recurse, at least, into ;; every element it encounters. (and (not (eq category 'elements)) (setq category 'elements)))))))) - --acc - --walk-tree - (--walk-tree - (lambda (--data) - ;; Recursively walk DATA. INFO, if non-nil, is a plist - ;; holding contextual information. - (let ((--type (org-element-type --data))) - (cond - ((not --data)) - ;; Ignored element in an export context. - ((and info (memq --data (plist-get info :ignore-list)))) - ;; 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))) - (t - ;; Check if TYPE is matching among TYPES. If so, - ;; apply FUN to --DATA and accumulate return value - ;; into --ACC (or exit if FIRST-MATCH is non-nil). - (when (memq --type types) - (let ((result (funcall fun --data))) - (cond ((not result)) - (first-match (throw '--map-first-match result)) - (t (push result --acc))))) - ;; If --DATA has a secondary string that can contain - ;; objects with their type among TYPES, look into it. - (when (and (eq --category 'objects) (not (stringp --data))) - (dolist (p (cdr (assq --type - org-element-secondary-value-alist))) - (funcall --walk-tree (org-element-property p --data)))) - ;; If --DATA has any parsed 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)) - (dolist (kwd-pair org-element--parsed-properties-alist) - (let ((kwd (car kwd-pair)) - (value (org-element-property (cdr kwd-pair) --data))) - ;; Pay attention to the type of parsed keyword. - ;; In particular, preserve order for multiple - ;; keywords. - (cond - ((not value)) - ((member kwd org-element-dual-keywords) - (if (member kwd org-element-multiple-keywords) - (dolist (line (reverse value)) - (funcall --walk-tree (cdr line)) - (funcall --walk-tree (car line))) - (funcall --walk-tree (cdr value)) - (funcall --walk-tree (car value)))) - ((member kwd org-element-multiple-keywords) - (mapc --walk-tree (reverse value))) - (t (funcall --walk-tree value)))))) - ;; Determine if a recursion into --DATA is possible. - (cond - ;; --TYPE is explicitly removed from recursion. - ((memq --type no-recursion)) - ;; --DATA has no contents. - ((not (org-element-contents --data))) - ;; Looking for greater elements but --DATA is simply - ;; an element or an object. - ((and (eq --category 'greater-elements) - (not (memq --type org-element-greater-elements)))) - ;; Looking for elements but --DATA is an object. - ((and (eq --category 'elements) - (memq --type org-element-all-objects))) - ;; In any other case, map contents. - (t (mapc --walk-tree (org-element-contents --data)))))))))) - (catch '--map-first-match - (funcall --walk-tree data) - ;; Return value in a proper order. - (nreverse --acc)))) + --acc) + (letrec ((--walk-tree + (lambda (--data) + ;; Recursively walk DATA. INFO, if non-nil, is a plist + ;; holding contextual information. + (let ((--type (org-element-type --data))) + (cond + ((not --data)) + ;; Ignored element in an export context. + ((and info (memq --data (plist-get info :ignore-list)))) + ;; 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))) + (t + ;; Check if TYPE is matching among TYPES. If so, + ;; apply FUN to --DATA and accumulate return value + ;; into --ACC (or exit if FIRST-MATCH is non-nil). + (when (memq --type types) + (let ((result (funcall fun --data))) + (cond ((not result)) + (first-match (throw :--map-first-match result)) + (t (push result --acc))))) + ;; If --DATA has a secondary string that can contain + ;; objects with their type among TYPES, look inside. + (when (and (eq --category 'objects) (not (stringp --data))) + (dolist (p (cdr (assq --type + org-element-secondary-value-alist))) + (funcall --walk-tree (org-element-property p --data)))) + ;; If --DATA has any parsed affiliated keywords and + ;; WITH-AFFILIATED is non-nil, look for objects in + ;; them. + (when (and with-affiliated + (eq --category 'objects) + (eq (org-element-class --data) 'element)) + (dolist (kwd-pair org-element--parsed-properties-alist) + (let ((kwd (car kwd-pair)) + (value (org-element-property (cdr kwd-pair) --data))) + ;; Pay attention to the type of parsed + ;; keyword. In particular, preserve order for + ;; multiple keywords. + (cond + ((not value)) + ((member kwd org-element-dual-keywords) + (if (member kwd org-element-multiple-keywords) + (dolist (line (reverse value)) + (funcall --walk-tree (cdr line)) + (funcall --walk-tree (car line))) + (funcall --walk-tree (cdr value)) + (funcall --walk-tree (car value)))) + ((member kwd org-element-multiple-keywords) + (mapc --walk-tree (reverse value))) + (t (funcall --walk-tree value)))))) + ;; Determine if a recursion into --DATA is possible. + (cond + ;; --TYPE is explicitly removed from recursion. + ((memq --type no-recursion)) + ;; --DATA has no contents. + ((not (org-element-contents --data))) + ;; Looking for greater elements but --DATA is + ;; simply an element or an object. + ((and (eq --category 'greater-elements) + (not (memq --type org-element-greater-elements)))) + ;; Looking for elements but --DATA is an object. + ((and (eq --category 'elements) + (eq (org-element-class --data) 'object))) + ;; In any other case, map contents. + (t (mapc --walk-tree (org-element-contents --data)))))))))) + (catch :--map-first-match + (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. @@ -4180,20 +4273,21 @@ otherwise. Modes can be either `first-section', `item', `node-property', `planning', `property-drawer', `section', `table-row' or nil." (if parentp - (case type - (headline 'section) - (plain-list 'item) - (property-drawer 'node-property) - (section 'planning) - (table 'table-row)) - (case type - (item 'item) - (node-property 'node-property) - (planning 'property-drawer) - (table-row 'table-row)))) + (pcase type + (`headline 'section) + (`inlinetask 'planning) + (`plain-list 'item) + (`property-drawer 'node-property) + (`section 'planning) + (`table 'table-row)) + (pcase type + (`item 'item) + (`node-property 'node-property) + (`planning 'property-drawer) + (`table-row 'table-row)))) (defun org-element--parse-elements - (beg end mode structure granularity visible-only acc) + (beg end mode structure granularity visible-only acc) "Parse elements between BEG and END positions. MODE prioritizes some elements over the others. It can be set to @@ -4219,49 +4313,49 @@ Elements are accumulated into ACC." ;; 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))) - ;; Main loop start. - (while (< (point) end) - ;; Find current element's type and parse it accordingly to - ;; its category. - (let* ((element (org-element--current-element - end granularity mode structure)) - (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 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 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)) - (and (eq granularity 'greater-element) - (eq type 'section)) - (eq type 'headline))) - (org-element--parse-elements - cbeg (org-element-property :contents-end element) - ;; Possibly switch to a special mode. - (org-element--next-mode type t) - (and (memq type '(item plain-list)) - (org-element-property :structure element)) - granularity visible-only element)) - ;; ELEMENT has contents. Parse objects inside, if - ;; GRANULARITY allows it. - ((memq granularity '(object nil)) - (org-element--parse-objects - cbeg (org-element-property :contents-end element) element - (org-element-restriction type)))) - (org-element-adopt-elements acc element) - ;; Update mode. - (setq mode (org-element--next-mode type nil)))) - ;; Return result. - acc)) + (let (elements) + (while (< (point) end) + ;; Find current element's type and parse it accordingly to + ;; its category. + (let* ((element (org-element--current-element + end granularity mode structure)) + (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 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 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)) + (and (eq granularity 'greater-element) + (eq type 'section)) + (eq type 'headline))) + (org-element--parse-elements + cbeg (org-element-property :contents-end element) + ;; Possibly switch to a special mode. + (org-element--next-mode type t) + (and (memq type '(item plain-list)) + (org-element-property :structure element)) + granularity visible-only element)) + ;; ELEMENT has contents. Parse objects inside, if + ;; GRANULARITY allows it. + ((memq granularity '(object nil)) + (org-element--parse-objects + cbeg (org-element-property :contents-end element) element + (org-element-restriction type)))) + (push (org-element-put-property element :parent acc) elements) + ;; Update mode. + (setq mode (org-element--next-mode type nil)))) + ;; Return result. + (apply #'org-element-set-contents acc (nreverse elements))))) (defun org-element--object-lex (restriction) "Return next object in current buffer or nil. @@ -4269,27 +4363,41 @@ RESTRICTION is a list of object types, as symbols, that should be looked after. This function assumes that the buffer is narrowed to an appropriate container (e.g., a paragraph)." (if (memq 'table-cell restriction) (org-element-table-cell-parser) - (save-excursion - (let ((limit (and org-target-link-regexp - (save-excursion - (or (bolp) (backward-char)) - (re-search-forward org-target-link-regexp nil t)) - (match-beginning 1))) - found) + (let* ((start (point)) + (limit + (save-excursion + (cond ((not org-target-link-regexp) nil) + ((not (memq 'link restriction)) nil) + ((progn + (unless (bolp) (forward-char -1)) + (not (re-search-forward org-target-link-regexp nil t))) + nil) + ;; Since we moved backward, we do not want to + ;; match again an hypothetical 1-character long + ;; radio link before us. Realizing that this can + ;; only happen if such a radio link starts at + ;; beginning of line, we prevent this here. + ((and (= start (1+ (line-beginning-position))) + (= start (match-end 1))) + (and (re-search-forward org-target-link-regexp nil t) + (match-beginning 1))) + (t (match-beginning 1))))) + found) + (save-excursion (while (and (not found) - (re-search-forward org-element--object-regexp limit t)) + (re-search-forward org-element--object-regexp limit 'move)) (goto-char (match-beginning 0)) (let ((result (match-string 0))) (setq found (cond - ((eq (compare-strings result nil nil "call_" nil nil t) t) + ((string-prefix-p "call_" result t) (and (memq 'inline-babel-call restriction) (org-element-inline-babel-call-parser))) - ((eq (compare-strings result nil nil "src_" nil nil t) t) + ((string-prefix-p "src_" result t) (and (memq 'inline-src-block restriction) (org-element-inline-src-block-parser))) (t - (case (char-after) + (pcase (char-after) (?^ (and (memq 'superscript restriction) (org-element-superscript-parser))) (?_ (or (and (memq 'subscript restriction) @@ -4341,60 +4449,62 @@ to an appropriate container (e.g., a paragraph)." (and (memq 'statistics-cookie restriction) (org-element-statistics-cookie-parser))))) ;; This is probably a plain link. - (otherwise (and (or (memq 'link restriction) - (memq 'plain-link restriction)) - (org-element-link-parser))))))) + (_ (and (memq 'link restriction) + (org-element-link-parser))))))) (or (eobp) (forward-char)))) (cond (found) - ;; Radio link. - ((and limit (memq 'link restriction)) - (goto-char limit) (org-element-link-parser))))))) + (limit (org-element-link-parser)) ;radio link + (t nil)))))) -(defun org-element--parse-objects (beg end acc restriction) +(defun org-element--parse-objects (beg end acc restriction &optional parent) "Parse objects between BEG and END and return recursive structure. -Objects are accumulated in ACC. +Objects are accumulated in ACC. RESTRICTION is a list of object +successors which are allowed in the current object. -RESTRICTION is a list of object successors which are allowed in -the current object." +ACC becomes the parent for all parsed objects. However, if ACC +is nil (i.e., a secondary string is being parsed) and optional +argument PARENT is non-nil, use it as the parent for all objects. +Eventually, if both ACC and PARENT are nil, the common parent is +the list of objects itself." (save-excursion (save-restriction (narrow-to-region beg end) (goto-char (point-min)) - (let (next-object) + (let (next-object contents) (while (and (not (eobp)) (setq next-object (org-element--object-lex restriction))) - ;; 1. Text before any object. Untabify it. + ;; Text before any object. (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 ((text (buffer-substring-no-properties (point) obj-beg))) + (push (if acc (org-element-put-property text :parent acc) text) + contents)))) + ;; 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 - 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))) + (when acc (org-element-put-property next-object :parent acc)) + (push (if cont-beg + ;; Fill contents of NEXT-OBJECT if possible. + (org-element--parse-objects + cont-beg + (org-element-property :contents-end next-object) + next-object + (org-element-restriction next-object)) + next-object) + contents) + (goto-char obj-end))) + ;; Text after last object. + (unless (eobp) + (let ((text (buffer-substring-no-properties (point) end))) + (push (if acc (org-element-put-property text :parent acc) text) + contents))) + ;; Result. Set appropriate parent. + (if acc (apply #'org-element-set-contents acc (nreverse contents)) + (let* ((contents (nreverse contents)) + (parent (or parent contents))) + (dolist (datum contents contents) + (org-element-put-property datum :parent parent)))))))) @@ -4413,73 +4523,70 @@ the current object." "Interpret DATA as Org syntax. DATA is a parse tree, an element, an object or a secondary string to interpret. Return Org syntax as a string." - (org-element--interpret-data-1 data nil)) - -(defun org-element--interpret-data-1 (data parent) - "Interpret DATA as Org syntax. - -DATA is a parse tree, an element, an object or a secondary string -to interpret. PARENT is used for recursive calls. It contains -the element or object containing data, or nil. - -Return Org syntax as a string." - (let* ((type (org-element-type data)) - ;; Find interpreter for current object or element. If it - ;; doesn't exist (e.g. this is a pseudo object or element), - ;; return contents, if any. - (interpret - (let ((fun (intern (format "org-element-%s-interpreter" type)))) - (if (fboundp fun) fun (lambda (data contents) contents)))) - (results - (cond - ;; Secondary string. - ((not type) - (mapconcat - (lambda (obj) (org-element--interpret-data-1 obj parent)) data "")) - ;; Full Org document. - ((eq type 'org-data) - (mapconcat (lambda (obj) (org-element--interpret-data-1 obj parent)) - (org-element-contents data) "")) - ;; Plain text: return it. - ((stringp data) data) - ;; Element or object without contents. - ((not (org-element-contents data)) (funcall interpret data nil)) - ;; Element or object with contents. - (t - (funcall interpret data - ;; Recursively interpret contents. - (mapconcat - (lambda (obj) (org-element--interpret-data-1 obj data)) - (org-element-contents - (if (not (memq type '(paragraph verse-block))) - data - ;; Fix indentation of elements containing - ;; objects. We ignore `table-row' elements - ;; as they are one line long anyway. - (org-element-normalize-contents - data - ;; When normalizing first paragraph of an - ;; item or a footnote-definition, ignore - ;; first line's indentation. - (and (eq type 'paragraph) - (equal data (car (org-element-contents parent))) - (memq (org-element-type parent) - '(footnote-definition item)))))) - "")))))) - (if (memq type '(org-data plain-text nil)) results - ;; Build white spaces. If no `:post-blank' property is - ;; specified, assume its value is 0. - (let ((post-blank (or (org-element-property :post-blank data) 0))) - (if (or (memq type org-element-all-objects) - (and parent - (let ((type (org-element-type parent))) - (or (not type) - (memq type org-element-object-containers))))) - (concat results (make-string post-blank ?\s)) - (concat - (org-element--interpret-affiliated-keywords data) - (org-element-normalize-string results) - (make-string post-blank ?\n))))))) + (letrec ((fun + (lambda (data parent) + (let* ((type (org-element-type data)) + ;; Find interpreter for current object or + ;; element. If it doesn't exist (e.g. this is + ;; a pseudo object or element), return contents, + ;; if any. + (interpret + (let ((fun (intern + (format "org-element-%s-interpreter" type)))) + (if (fboundp fun) fun (lambda (_ contents) contents)))) + (results + (cond + ;; Secondary string. + ((not type) + (mapconcat (lambda (obj) (funcall fun obj parent)) + data + "")) + ;; Full Org document. + ((eq type 'org-data) + (mapconcat (lambda (obj) (funcall fun obj parent)) + (org-element-contents data) + "")) + ;; Plain text: return it. + ((stringp data) data) + ;; Element or object without contents. + ((not (org-element-contents data)) + (funcall interpret data nil)) + ;; Element or object with contents. + (t + (funcall + interpret + data + ;; Recursively interpret contents. + (mapconcat + (lambda (datum) (funcall fun datum data)) + (org-element-contents + (if (not (memq type '(paragraph verse-block))) + data + ;; Fix indentation of elements containing + ;; objects. We ignore `table-row' + ;; elements as they are one line long + ;; anyway. + (org-element-normalize-contents + data + ;; When normalizing first paragraph of + ;; an item or a footnote-definition, + ;; ignore first line's indentation. + (and (eq type 'paragraph) + (memq (org-element-type parent) + '(footnote-definition item)) + (eq data + (car (org-element-contents parent))))))) + "")))))) + (if (memq type '(org-data plain-text nil)) results + ;; Build white spaces. If no `:post-blank' property + ;; is specified, assume its value is 0. + (let ((blank (or (org-element-property :post-blank data) 0))) + (if (eq (org-element-class data parent) 'object) + (concat results (make-string blank ?\s)) + (concat (org-element--interpret-affiliated-keywords data) + (org-element-normalize-string results) + (make-string blank ?\n))))))))) + (funcall fun data nil))) (defun org-element--interpret-affiliated-keywords (element) "Return ELEMENT's affiliated keywords as Org syntax. @@ -4513,14 +4620,14 @@ If there is no affiliated keyword, return the empty string." ;; List all ELEMENT's properties matching an attribute line or an ;; affiliated keyword, but ignore translated keywords since they ;; cannot belong to the property list. - (loop for prop in (nth 1 element) by 'cddr - when (let ((keyword (upcase (substring (symbol-name prop) 1)))) - (or (string-match "^ATTR_" keyword) - (and - (member keyword org-element-affiliated-keywords) - (not (assoc keyword - org-element-keyword-translation-alist))))) - collect prop) + (cl-loop for prop in (nth 1 element) by 'cddr + when (let ((keyword (upcase (substring (symbol-name prop) 1)))) + (or (string-match "^ATTR_" keyword) + (and + (member keyword org-element-affiliated-keywords) + (not (assoc keyword + org-element-keyword-translation-alist))))) + collect prop) ""))) ;; Because interpretation of the parse tree must return the same @@ -4556,75 +4663,93 @@ If optional argument IGNORE-FIRST is non-nil, ignore first line's indentation to compute maximal common indentation. Return the normalized element that is element with global -indentation removed from its contents. The function assumes that -indentation is not done with TAB characters." - (let* ((min-ind most-positive-fixnum) - find-min-ind ; For byte-compiler. - (find-min-ind - ;; Return minimal common indentation within BLOB. This is - ;; done by walking recursively BLOB and updating MIN-IND - ;; along the way. FIRST-FLAG is non-nil when the next - ;; object is expected to be a string that doesn't start with - ;; a newline character. It happens for strings at the - ;; beginnings of the contents or right after a line break. - (lambda (blob first-flag) - (dolist (object (org-element-contents blob)) - (when first-flag - (setq first-flag nil) - ;; Objects cannot start with spaces: in this case, - ;; indentation is 0. - (if (not (stringp object)) (throw 'zero (setq min-ind 0)) - (string-match "\\` *" object) - (let ((len (match-end 0))) - ;; An indentation of zero means no string will be - ;; modified. Quit the process. - (if (zerop len) (throw 'zero (setq min-ind 0)) - (setq min-ind (min len min-ind)))))) - (cond - ((stringp object) - (dolist (line (cdr (org-split-string object " *\n"))) - (unless (string= line "") - (setq min-ind (min (org-get-indentation line) min-ind))))) - ((eq (org-element-type object) 'line-break) (setq first-flag t)) - ((memq (org-element-type object) org-element-recursive-objects) - (funcall find-min-ind object first-flag))))))) - ;; Find minimal indentation in ELEMENT. - (catch 'zero (funcall find-min-ind element (not ignore-first))) +indentation removed from its contents." + (letrec ((find-min-ind + ;; Return minimal common indentation within BLOB. This is + ;; done by walking recursively BLOB and updating MIN-IND + ;; along the way. FIRST-FLAG is non-nil when the next + ;; object is expected to be a string that doesn't start + ;; with a newline character. It happens for strings at + ;; the beginnings of the contents or right after a line + ;; break. + (lambda (blob first-flag min-ind) + (dolist (datum (org-element-contents blob) min-ind) + (when first-flag + (setq first-flag nil) + (cond + ;; Objects cannot start with spaces: in this + ;; case, indentation is 0. + ((not (stringp datum)) (throw :zero 0)) + ((not (string-match + "\\`\\([ \t]+\\)\\([^ \t\n]\\|\n\\|\\'\\)" datum)) + (throw :zero 0)) + ((equal (match-string 2 datum) "\n") + (put-text-property + (match-beginning 1) (match-end 1) 'org-ind 'empty datum)) + (t + (let ((i (string-width (match-string 1 datum)))) + (put-text-property + (match-beginning 1) (match-end 1) 'org-ind i datum) + (setq min-ind (min i min-ind)))))) + (cond + ((stringp datum) + (let ((s 0)) + (while (string-match + "\n\\([ \t]*\\)\\([^ \t\n]\\|\n\\|\\'\\)" datum s) + (setq s (match-end 1)) + (cond + ((equal (match-string 1 datum) "") + (unless (member (match-string 2 datum) '("" "\n")) + (throw :zero 0))) + ((equal (match-string 2 datum) "\n") + (put-text-property (match-beginning 1) (match-end 1) + 'org-ind 'empty datum)) + (t + (let ((i (string-width (match-string 1 datum)))) + (put-text-property (match-beginning 1) (match-end 1) + 'org-ind i datum) + (setq min-ind (min i min-ind)))))))) + ((eq (org-element-type datum) 'line-break) + (setq first-flag t)) + ((memq (org-element-type datum) org-element-recursive-objects) + (setq min-ind + (funcall find-min-ind datum first-flag min-ind))))))) + (min-ind + (catch :zero + (funcall find-min-ind + element (not ignore-first) most-positive-fixnum)))) (if (or (zerop min-ind) (= min-ind most-positive-fixnum)) element ;; Build ELEMENT back, replacing each string with the same ;; string minus common indentation. - (let* (build ; For byte compiler. - (build - (lambda (blob first-flag) - ;; Return BLOB with all its strings indentation - ;; shortened from MIN-IND white spaces. FIRST-FLAG is - ;; non-nil when the next object is expected to be - ;; a string that doesn't start with a newline - ;; character. - (setcdr (cdr blob) - (mapcar - (lambda (object) - (when first-flag - (setq first-flag nil) - (when (stringp object) - (setq object - (replace-regexp-in-string - (format "\\` \\{%d\\}" min-ind) - "" object)))) - (cond - ((stringp object) - (replace-regexp-in-string - (format "\n \\{%d\\}" min-ind) "\n" object)) - ((memq (org-element-type object) - org-element-recursive-objects) - (funcall build object first-flag)) - ((eq (org-element-type object) 'line-break) - (setq first-flag t) - object) - (t object))) - (org-element-contents blob))) - blob))) - (funcall build element (not ignore-first)))))) + (letrec ((build + (lambda (datum) + ;; Return DATUM with all its strings indentation + ;; shortened from MIN-IND white spaces. + (setcdr + (cdr datum) + (mapcar + (lambda (object) + (cond + ((stringp object) + (with-temp-buffer + (insert object) + (let ((s (point-min))) + (while (setq s (text-property-not-all + s (point-max) 'org-ind nil)) + (goto-char s) + (let ((i (get-text-property s 'org-ind))) + (delete-region s (progn + (skip-chars-forward " \t") + (point))) + (when (integerp i) (indent-to (- i min-ind)))))) + (buffer-string))) + ((memq (org-element-type object) + org-element-recursive-objects) + (funcall build object)) + (t object))) + (org-element-contents datum))) + datum))) + (funcall build element))))) @@ -4670,14 +4795,14 @@ indentation is not done with TAB characters." ;; associated to a key, obtained with `org-element--cache-key'. This ;; mechanism is robust enough to preserve total order among elements ;; even when the tree is only partially synchronized. -;; -;; Objects contained in an element are stored in a hash table, -;; `org-element--cache-objects'. -(defvar org-element-use-cache t - "Non nil when Org parser should cache its results. -This is mostly for debugging purpose.") +(defvar org-element-use-cache nil + "Non-nil when Org parser should cache its results. + +WARNING: for the time being, using cache sometimes triggers +freezes. Therefore, it is disabled by default. Activate it if +you want to help debugging the issue.") (defvar org-element-cache-sync-idle-time 0.6 "Length, in seconds, of idle time before syncing cache.") @@ -4701,34 +4826,6 @@ Each node of the tree contains an element. Comparison is done with `org-element--cache-compare'. This cache is used in `org-element-at-point'.") -(defvar org-element--cache-objects nil - "Hash table used as to cache objects. -Key is an element, as returned by `org-element-at-point', and -value is an alist where each association is: - - \(PARENT COMPLETEP . OBJECTS) - -where PARENT is an element or object, COMPLETEP is a boolean, -non-nil when all direct children of parent are already cached and -OBJECTS is a list of such children, as objects, from farthest to -closest. - -In the following example, \\alpha, bold object and \\beta are -contained within a paragraph - - \\alpha *\\beta* - -If the paragraph is completely parsed, OBJECTS-DATA will be - - \((PARAGRAPH t BOLD-OBJECT ENTITY-OBJECT) - \(BOLD-OBJECT t ENTITY-OBJECT)) - -whereas in a partially parsed paragraph, it could be - - \((PARAGRAPH nil ENTITY-OBJECT)) - -This cache is used in `org-element-context'.") - (defvar org-element--cache-sync-requests nil "List of pending synchronization requests. @@ -4814,16 +4911,16 @@ the following rules: gets a new level. Its value is the mean between LOWER and UPPER: - \(1 2) + (1 4) --> (1 3) + (1 2) + (1 4) --> (1 3) - If LOWER has no value to compare with, it is assumed that its value is `most-negative-fixnum'. E.g., - \(1 1) + (1 1 2) + (1 1) + (1 1 2) is equivalent to - \(1 1 m) + (1 1 2) + (1 1 m) + (1 1 2) where m is `most-negative-fixnum'. Likewise, if UPPER is short of levels, the current value is `most-positive-fixnum'. @@ -4831,18 +4928,18 @@ the following rules: - If they differ from only one, the new key inherits from current LOWER level and fork it at the next level. E.g., - \(2 1) + (3 3) + (2 1) + (3 3) is equivalent to - \(2 1) + (2 M) + (2 1) + (2 M) where M is `most-positive-fixnum'. - If the key is only one level long, it is returned as an integer: - \(1 2) + (3 2) --> 2 + (1 2) + (3 2) --> 2 When they are not equals, the function assumes that LOWER is lesser than UPPER, per `org-element--cache-key-less-p'." @@ -4903,7 +5000,8 @@ This function assumes `org-element--cache' is a valid AVL tree." (defsubst org-element--cache-active-p () "Non-nil when cache is active in current buffer." (and org-element-use-cache - (or (derived-mode-p 'org-mode) orgstruct-mode))) + org-element--cache + (derived-mode-p 'org-mode))) (defun org-element--cache-find (pos &optional side) "Find element in cache starting at POS or before. @@ -4959,41 +5057,33 @@ the cache." (setq node nil lower element upper element))))) - (case side - (both (cons lower upper)) - ((nil) lower) - (otherwise upper)))) - -(defun org-element--cache-put (element &optional data) - "Store ELEMENT in current buffer's cache, if allowed. -When optional argument DATA is non-nil, assume is it object data -relative to ELEMENT and store it in the objects cache." - (cond ((not (org-element--cache-active-p)) nil) - ((not data) - (when org-element--cache-sync-requests - ;; During synchronization, first build an appropriate key - ;; for the new element so `avl-tree-enter' can insert it at - ;; the right spot in the cache. - (let ((keys (org-element--cache-find - (org-element-property :begin element) 'both))) - (puthash element - (org-element--cache-generate-key - (and (car keys) (org-element--cache-key (car keys))) - (cond ((cdr keys) (org-element--cache-key (cdr keys))) - (org-element--cache-sync-requests - (aref (car org-element--cache-sync-requests) 0)))) - org-element--cache-sync-keys))) - (avl-tree-enter org-element--cache element)) - ;; Headlines are not stored in cache, so objects in titles are - ;; not stored either. - ((eq (org-element-type element) 'headline) nil) - (t (puthash element data org-element--cache-objects)))) + (pcase side + (`both (cons lower upper)) + (`nil lower) + (_ upper)))) + +(defun org-element--cache-put (element) + "Store ELEMENT in current buffer's cache, if allowed." + (when (org-element--cache-active-p) + (when org-element--cache-sync-requests + ;; During synchronization, first build an appropriate key for + ;; the new element so `avl-tree-enter' can insert it at the + ;; right spot in the cache. + (let ((keys (org-element--cache-find + (org-element-property :begin element) 'both))) + (puthash element + (org-element--cache-generate-key + (and (car keys) (org-element--cache-key (car keys))) + (cond ((cdr keys) (org-element--cache-key (cdr keys))) + (org-element--cache-sync-requests + (aref (car org-element--cache-sync-requests) 0)))) + org-element--cache-sync-keys))) + (avl-tree-enter org-element--cache element))) (defsubst org-element--cache-remove (element) "Remove ELEMENT from cache. Assume ELEMENT belongs to cache and that a cache is active." - (avl-tree-delete org-element--cache element) - (remhash element org-element--cache-objects)) + (avl-tree-delete org-element--cache element)) ;;;; Synchronization @@ -5036,8 +5126,8 @@ Properties are modified by side-effect." (not (eq (org-element-type (plist-get properties :parent)) 'item))) (dolist (item (plist-get properties :structure)) - (incf (car item) offset) - (incf (nth 6 item) offset))) + (cl-incf (car item) offset) + (cl-incf (nth 6 item) offset))) (dolist (key '(:begin :contents-begin :contents-end :end :post-affiliated)) (let ((value (and (or (not props) (memq key props)) (plist-get properties key)))) @@ -5076,7 +5166,7 @@ updated before current modification are actually submitted." ;; Request processed. Merge current and next offsets and ;; transfer ending position. (when next - (incf (aref next 3) (aref request 3)) + (cl-incf (aref next 3) (aref request 3)) (aset next 2 (aref request 2))) (setq org-element--cache-sync-requests (cdr org-element--cache-sync-requests)))) @@ -5249,11 +5339,7 @@ request." (throw 'interrupt nil)) ;; Shift element. (unless (zerop offset) - (org-element--cache-shift-positions data offset) - ;; Shift associated objects data, if any. - (dolist (object-data (gethash data org-element--cache-objects)) - (dolist (object (cddr object-data)) - (org-element--cache-shift-positions object offset)))) + (org-element--cache-shift-positions data offset)) (let ((begin (org-element-property :begin data))) ;; Update PARENT and re-parent DATA, only when ;; necessary. Propagate new structures for lists. @@ -5466,12 +5552,12 @@ that range. See `after-change-functions' for more information." ;; to both previous and current state. We make a special ;; case for headline editing: if a headline is modified but ;; not removed, do not extend. - (when (case org-element--cache-change-warning - ((t) t) - (headline + (when (pcase org-element--cache-change-warning + (`t t) + (`headline (not (and (org-with-limited-levels (org-at-heading-p)) (= (line-end-position) bottom)))) - (otherwise + (_ (let ((case-fold-search t)) (re-search-forward org-element--cache-sensitive-re bottom t)))) @@ -5552,7 +5638,7 @@ change, as an integer." ;; Current changes can be merged with first sync request: we ;; can save a partial cache synchronization. (progn - (incf (aref next 3) offset) + (cl-incf (aref next 3) offset) ;; If last change happened within area to be removed, extend ;; boundaries of robust parents, if any. Otherwise, find ;; first element to remove and update request accordingly. @@ -5602,7 +5688,8 @@ change, as an integer." ;; No element to remove. No need to re-parent either. ;; Simply shift additional elements, if any, by OFFSET. (when org-element--cache-sync-requests - (incf (aref (car org-element--cache-sync-requests) 3) offset))))))) + (cl-incf (aref (car org-element--cache-sync-requests) 3) + offset))))))) ;;;; Public Functions @@ -5615,15 +5702,14 @@ buffers." (interactive "P") (dolist (buffer (if all (buffer-list) (list (current-buffer)))) (with-current-buffer buffer - (when (org-element--cache-active-p) - (org-set-local 'org-element--cache - (avl-tree-create #'org-element--cache-compare)) - (org-set-local 'org-element--cache-objects (make-hash-table :test #'eq)) - (org-set-local 'org-element--cache-sync-keys - (make-hash-table :weakness 'key :test #'eq)) - (org-set-local 'org-element--cache-change-warning nil) - (org-set-local 'org-element--cache-sync-requests nil) - (org-set-local 'org-element--cache-sync-timer nil) + (when (and org-element-use-cache (derived-mode-p 'org-mode)) + (setq-local org-element--cache + (avl-tree-create #'org-element--cache-compare)) + (setq-local org-element--cache-sync-keys + (make-hash-table :weakness 'key :test #'eq)) + (setq-local org-element--cache-change-warning nil) + (setq-local org-element--cache-sync-requests nil) + (setq-local org-element--cache-sync-timer nil) (add-hook 'before-change-functions #'org-element--cache-before-change nil t) (add-hook 'after-change-functions @@ -5718,15 +5804,15 @@ Providing it allows for quicker computation." (org-with-wide-buffer (let* ((pos (point)) (element (or element (org-element-at-point))) - (type (org-element-type element))) + (type (org-element-type element)) + (post (org-element-property :post-affiliated element))) ;; If point is inside an element containing objects or ;; a secondary string, narrow buffer to the container and ;; proceed with parsing. 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 (< pos post))) + ((and post (< pos post)) (beginning-of-line) (let ((case-fold-search t)) (looking-at org-element--affiliated-re)) (cond @@ -5745,7 +5831,8 @@ Providing it allows for quicker computation." ;; 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) + (if (or (not tag) (/= (line-beginning-position) post)) + (throw 'objects-forbidden element) (beginning-of-line) (search-forward tag (line-end-position)) (goto-char (match-beginning 0)) @@ -5754,11 +5841,16 @@ Providing it allows for quicker computation." (throw 'objects-forbidden element))))) ;; At an headline or inlinetask, objects are in title. ((memq type '(headline inlinetask)) - (goto-char (org-element-property :begin element)) - (skip-chars-forward "*") - (if (and (> pos (point)) (< pos (line-end-position))) - (narrow-to-region (point) (line-end-position)) - (throw 'objects-forbidden element))) + (let ((case-fold-search nil)) + (goto-char (org-element-property :begin element)) + (looking-at org-complex-heading-regexp) + (let ((end (match-end 4))) + (if (not end) (throw 'objects-forbidden element) + (goto-char (match-beginning 4)) + (when (looking-at org-comment-string) + (goto-char (match-end 0))) + (if (>= (point) end) (throw 'objects-forbidden element) + (narrow-to-region (point) end)))))) ;; At a paragraph, a table-row or a verse block, objects are ;; located within their contents. ((memq type '(paragraph table-row verse-block)) @@ -5784,99 +5876,50 @@ Providing it allows for quicker computation." (goto-char (point-min)) (let ((restriction (org-element-restriction type)) (parent element) - (cache (cond ((not (org-element--cache-active-p)) nil) - (org-element--cache-objects - (gethash element org-element--cache-objects)) - (t (org-element-cache-reset) nil))) - next object-data last) - (prog1 - (catch 'exit - (while t - ;; When entering PARENT for the first time, get list - ;; of objects within known so far. Store it in - ;; OBJECT-DATA. - (unless next - (let ((data (assq parent cache))) - (if data (setq object-data data) - (push (setq object-data (list parent nil)) cache)))) - ;; Find NEXT object for analysis. - (catch 'found - ;; If NEXT is non-nil, we already exhausted the - ;; cache so we can parse buffer to find the object - ;; after it. - (if next (setq next (org-element--object-lex restriction)) - ;; Otherwise, check if cache can help us. - (let ((objects (cddr object-data)) - (completep (nth 1 object-data))) - (cond - ((and (not objects) completep) (throw 'exit parent)) - ((not objects) - (setq next (org-element--object-lex restriction))) - (t - (let ((cache-limit - (org-element-property :end (car objects)))) - (if (>= cache-limit pos) - ;; Cache contains the information needed. - (dolist (object objects (throw 'exit parent)) - (when (<= (org-element-property :begin object) - pos) - (if (>= (org-element-property :end object) - pos) - (throw 'found (setq next object)) - (throw 'exit parent)))) - (goto-char cache-limit) - (setq next - (org-element--object-lex restriction)))))))) - ;; If we have a new object to analyze, store it in - ;; cache. Otherwise record that there is nothing - ;; more to parse in this element at this depth. - (if next - (progn (org-element-put-property next :parent parent) - (push next (cddr object-data))) - (setcar (cdr object-data) t))) - ;; Process NEXT, if any, in order to know if we need - ;; to skip it, return it or move into it. - (if (or (not next) (> (org-element-property :begin next) pos)) - (throw 'exit (or last parent)) - (let ((end (org-element-property :end next)) - (cbeg (org-element-property :contents-begin next)) - (cend (org-element-property :contents-end next))) - (cond - ;; Skip objects ending before point. Also skip - ;; objects ending at point unless it is also the - ;; end of buffer, since we want to return the - ;; innermost object. - ((and (<= end pos) (/= (point-max) end)) - (goto-char end) - ;; For convenience, when object ends at POS, - ;; without any space, store it in LAST, as we - ;; will return it if no object starts here. - (when (and (= end pos) - (not (memq (char-before) '(?\s ?\t)))) - (setq last next))) - ;; If POS is within a container object, move - ;; into that object. - ((and cbeg cend - (>= pos cbeg) - (or (< pos cend) - ;; At contents' end, if there is no - ;; space before point, also move into - ;; object, for consistency with - ;; convenience feature above. - (and (= pos cend) - (or (= (point-max) pos) - (not (memq (char-before pos) - '(?\s ?\t))))))) - (goto-char cbeg) - (narrow-to-region (point) cend) - (setq parent next - restriction (org-element-restriction next) - next nil - object-data nil)) - ;; Otherwise, return NEXT. - (t (throw 'exit next))))))) - ;; Store results in cache, if applicable. - (org-element--cache-put element cache))))))) + last) + (catch 'exit + (while t + (let ((next (org-element--object-lex restriction))) + (when next (org-element-put-property next :parent parent)) + ;; Process NEXT, if any, in order to know if we need to + ;; skip it, return it or move into it. + (if (or (not next) (> (org-element-property :begin next) pos)) + (throw 'exit (or last parent)) + (let ((end (org-element-property :end next)) + (cbeg (org-element-property :contents-begin next)) + (cend (org-element-property :contents-end next))) + (cond + ;; Skip objects ending before point. Also skip + ;; objects ending at point unless it is also the + ;; end of buffer, since we want to return the + ;; innermost object. + ((and (<= end pos) (/= (point-max) end)) + (goto-char end) + ;; For convenience, when object ends at POS, + ;; without any space, store it in LAST, as we + ;; will return it if no object starts here. + (when (and (= end pos) + (not (memq (char-before) '(?\s ?\t)))) + (setq last next))) + ;; If POS is within a container object, move into + ;; that object. + ((and cbeg cend + (>= pos cbeg) + (or (< pos cend) + ;; At contents' end, if there is no + ;; space before point, also move into + ;; object, for consistency with + ;; convenience feature above. + (and (= pos cend) + (or (= (point-max) pos) + (not (memq (char-before pos) + '(?\s ?\t))))))) + (goto-char cbeg) + (narrow-to-region (point) cend) + (setq parent next) + (setq restriction (org-element-restriction next))) + ;; Otherwise, return NEXT. + (t (throw 'exit next))))))))))))) (defun org-element-lineage (blob &optional types with-self) "List all ancestors of a given element or object. @@ -5966,7 +6009,7 @@ end of ELEM-A." (goto-char beg-B) (when specialp (setq body-B (replace-regexp-in-string "\\`[ \t]*" "" body-B)) - (org-indent-to-column ind-B)) + (indent-to-column ind-B)) (insert body-A) ;; Restore ex ELEM-A overlays. (let ((offset (- beg-B beg-A))) @@ -5980,36 +6023,6 @@ end of ELEM-A." (move-overlay (car o) (- (nth 1 o) offset) (- (nth 2 o) offset)))) (goto-char (org-element-property :end elem-B))))) -(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))))) - - (provide 'org-element) diff --git a/elpa/org-plus-contrib-20150831/org-elisp-symbol.el b/elpa/org-plus-contrib-20170407/org-elisp-symbol.el similarity index 96% rename from elpa/org-plus-contrib-20150831/org-elisp-symbol.el rename to elpa/org-plus-contrib-20170407/org-elisp-symbol.el index 167731e8..a0899147 100644 --- a/elpa/org-plus-contrib-20150831/org-elisp-symbol.el +++ b/elpa/org-plus-contrib-20170407/org-elisp-symbol.el @@ -1,6 +1,6 @@ ;;; org-elisp-symbol.el --- Org links to emacs-lisp symbols ;; -;; Copyright 2007-2014 Free Software Foundation, Inc. +;; Copyright 2007-2017 Free Software Foundation, Inc. ;; ;; Author: Bastien Guerry ;; Version: 0.2 @@ -78,8 +78,9 @@ (require 'org) -(org-add-link-type "elisp-symbol" 'org-elisp-symbol-open) -(add-hook 'org-store-link-functions 'org-elisp-symbol-store-link) +(org-link-set-parameters "elisp-symbol" + :follow #'org-elisp-symbol-open + :store #'org-elisp-symbol-store-link) (defun org-elisp-symbol-open (path) "Visit the emacs-lisp elisp-symbol at PATH." diff --git a/elpa/org-plus-contrib-20150831/org-entities.el b/elpa/org-plus-contrib-20170407/org-entities.el similarity index 92% rename from elpa/org-plus-contrib-20150831/org-entities.el rename to elpa/org-plus-contrib-20170407/org-entities.el index f0f7b547..05ccf0cf 100644 --- a/elpa/org-plus-contrib-20150831/org-entities.el +++ b/elpa/org-plus-contrib-20170407/org-entities.el @@ -1,6 +1,6 @@ -;;; org-entities.el --- Support for special entities in Org-mode +;;; org-entities.el --- Support for Special Entities -*- lexical-binding: t; -*- -;; Copyright (C) 2010-2015 Free Software Foundation, Inc. +;; Copyright (C) 2010-2017 Free Software Foundation, Inc. ;; Author: Carsten Dominik , ;; Ulf Stegemann @@ -30,29 +30,24 @@ (declare-function org-toggle-pretty-entities "org" ()) (declare-function org-table-align "org-table" ()) -(eval-when-compile - (require 'cl)) - (defgroup org-entities nil - "Options concerning entities in Org-mode." + "Options concerning entities in Org mode." :tag "Org Entities" :group 'org) (defun org-entities--user-safe-p (v) "Non-nil if V is a safe value for `org-entities-user'." - (or (null v) - (and (listp v) - (= (length v) 7) - (stringp (nth 0 v)) - (stringp (nth 1 v)) - (booleanp (nth 2 v)) - (stringp (nth 3 v)) - (stringp (nth 4 v)) - (stringp (nth 5 v)) - (stringp (nth 6 v))))) + (pcase v + (`nil t) + (`(,(and (pred stringp) + (pred (string-match-p "\\`[a-zA-Z][a-zA-Z0-9]*\\'"))) + ,(pred stringp) ,(pred booleanp) ,(pred stringp) + ,(pred stringp) ,(pred stringp) ,(pred stringp)) + t) + (_ nil))) (defcustom org-entities-user nil - "User-defined entities used in Org-mode to produce special characters. + "User-defined entities used in Org to produce special characters. Each entry in this list is a list of strings. It associates the name of the entity that can be inserted into an Org file as \\name with the appropriate replacements for the different export backends. The order @@ -93,6 +88,8 @@ packages to be loaded, add these packages to `org-latex-packages-alist'." ("aacute" "\\'{a}" nil "á" "a" "á" "á") ("Acirc" "\\^{A}" nil "Â" "A" "Â" "Â") ("acirc" "\\^{a}" nil "â" "a" "â" "â") + ("Amacr" "\\bar{A}" nil "Ā" "A" "Ã" "Ã") + ("amacr" "\\bar{a}" nil "ā" "a" "ã" "ã") ("Atilde" "\\~{A}" nil "Ã" "A" "Ã" "Ã") ("atilde" "\\~{a}" nil "ã" "a" "ã" "ã") ("Auml" "\\\"{A}" nil "Ä" "Ae" "Ä" "Ä") @@ -168,7 +165,7 @@ packages to be loaded, add these packages to `org-latex-packages-alist'." ("beta" "\\beta" t "β" "beta" "beta" "β") ("Gamma" "\\Gamma" t "Γ" "Gamma" "Gamma" "Γ") ("gamma" "\\gamma" t "γ" "gamma" "gamma" "γ") - ("Delta" "\\Delta" t "Δ" "Delta" "Gamma" "Δ") + ("Delta" "\\Delta" t "Δ" "Delta" "Delta" "Δ") ("delta" "\\delta" t "δ" "delta" "delta" "δ") ("Epsilon" "E" nil "Ε" "Epsilon" "Epsilon" "Ε") ("epsilon" "\\epsilon" t "ε" "epsilon" "epsilon" "ε") @@ -208,8 +205,8 @@ packages to be loaded, add these packages to `org-latex-packages-alist'." ("upsih" "\\Upsilon" t "ϒ" "upsilon" "upsilon" "ϒ") ("upsilon" "\\upsilon" t "υ" "upsilon" "upsilon" "υ") ("Phi" "\\Phi" t "Φ" "Phi" "Phi" "Φ") - ("phi" "\\phi" t "φ" "phi" "phi" "φ") - ("varphi" "\\varphi" t "ϕ" "varphi" "varphi" "ɸ") + ("phi" "\\phi" t "φ" "phi" "phi" "ɸ") + ("varphi" "\\varphi" t "ϕ" "varphi" "varphi" "φ") ("Chi" "X" nil "Χ" "Chi" "Chi" "Χ") ("chi" "\\chi" t "χ" "chi" "chi" "χ") ("acutex" "\\acute x" t "´x" "'x" "'x" "𝑥́") @@ -265,8 +262,9 @@ packages to be loaded, add these packages to `org-latex-packages-alist'." "* Other" "** Misc. (often used)" - ("circ" "\\^{}" nil "ˆ" "^" "^" "ˆ") + ("circ" "\\^{}" nil "ˆ" "^" "^" "∘") ("vert" "\\vert{}" t "|" "|" "|" "|") + ("vbar" "|" nil "|" "|" "|" "|") ("brvbar" "\\textbrokenbar{}" nil "¦" "|" "¦" "¦") ("S" "\\S" nil "§" "paragraph" "§" "§") ("sect" "\\S" nil "§" "paragraph" "§" "§") @@ -285,7 +283,7 @@ packages to be loaded, add these packages to `org-latex-packages-alist'." ("ddag" "\\ddag{}" nil "‡" "[doubledagger]" "[doubledagger]" "‡") "** Whitespace" - ("nbsp" "~" nil " " " " " " " ") + ("nbsp" "~" nil " " " " "\x00A0" "\x00A0") ("ensp" "\\hspace*{.5em}" nil " " " " " " " ") ("emsp" "\\hspace*{1em}" nil " " " " " " " ") ("thinsp" "\\hspace*{.2em}" nil " " " " " " " ") @@ -326,7 +324,7 @@ packages to be loaded, add these packages to `org-latex-packages-alist'." ("deg" "\\textdegree{}" nil "°" "degree" "°" "°") ("prime" "\\prime" t "′" "'" "'" "′") ("Prime" "\\prime{}\\prime" t "″" "''" "''" "″") - ("infin" "\\propto" t "∞" "[infinity]" "[infinity]" "∞") + ("infin" "\\infty" t "∞" "[infinity]" "[infinity]" "∞") ("infty" "\\infty" t "∞" "[infinity]" "[infinity]" "∞") ("prop" "\\propto" t "∝" "[proportional to]" "[proportional to]" "∝") ("propto" "\\propto" t "∝" "[proportional to]" "[proportional to]" "∝") @@ -361,8 +359,8 @@ packages to be loaded, add these packages to `org-latex-packages-alist'." ("lessgtr" "\\lessgtr" t "≶" "[less than or greater than]" "[less than or greater than]" "≶") ("lesseqgtr" "\\lesseqgtr" t "⋚" "[less than or equal or greater than or equal]" "[less than or equal or greater than or equal]" "⋚") ("ll" "\\ll" t "≪" "<<" "<<" "≪") - ("Ll" "\lll" t "⋘" "<<<" "<<<" "⋘") - ("lll" "\lll" t "⋘" "<<<" "<<<" "⋘") + ("Ll" "\\lll" t "⋘" "<<<" "<<<" "⋘") + ("lll" "\\lll" t "⋘" "<<<" "<<<" "⋘") ("gg" "\\gg" t "≫" ">>" ">>" "≫") ("Gg" "\\ggg" t "⋙" ">>>" ">>>" "⋙") ("ggg" "\\ggg" t "⋙" ">>>" ">>>" "⋙") @@ -514,9 +512,8 @@ packages to be loaded, add these packages to `org-latex-packages-alist'." ("loz" "\\lozenge" t "◊" "[lozenge]" "[lozenge]" "â§«")) ;; Add "\_ "-entity family for spaces. (let (space-entities html-spaces (entity "_")) - (dotimes (n 20 (nreverse space-entities)) - (let ((n (+ 1 n)) - (spaces (make-string n ?\s))) + (dolist (n (number-sequence 1 20) (nreverse space-entities)) + (let ((spaces (make-string n ?\s))) (push (list (setq entity (concat entity " ")) (format "\\hspace*{%sem}" (* n .5)) nil @@ -539,29 +536,22 @@ This first checks the user list, then the built-in list." (defun org-entities-create-table () "Create an Org mode table with all entities." (interactive) - (let ((pos (point)) e latex mathp html latin utf8 name ascii) + (let ((pos (point))) (insert "|Name|LaTeX code|LaTeX|HTML code |HTML|ASCII|Latin1|UTF-8\n|-\n") - (mapc (lambda (e) (when (listp e) - (setq name (car e) - latex (nth 1 e) - mathp (nth 2 e) - html (nth 3 e) - ascii (nth 4 e) - latin (nth 5 e) - utf8 (nth 6 e)) - (if (equal ascii "|") (setq ascii "\\vert")) - (if (equal latin "|") (setq latin "\\vert")) - (if (equal utf8 "|") (setq utf8 "\\vert")) - (if (equal ascii "=>") (setq ascii "= >")) - (if (equal latin "=>") (setq latin "= >")) - (insert "|" name - "|" (format "=%s=" latex) - "|" (format (if mathp "$%s$" "$\\mbox{%s}$") - latex) - "|" (format "=%s=" html) "|" html - "|" ascii "|" latin "|" utf8 - "|\n"))) - org-entities) + (dolist (e org-entities) + (pcase e + (`(,name ,latex ,mathp ,html ,ascii ,latin ,utf8) + (if (equal ascii "|") (setq ascii "\\vert")) + (if (equal latin "|") (setq latin "\\vert")) + (if (equal utf8 "|") (setq utf8 "\\vert")) + (if (equal ascii "=>") (setq ascii "= >")) + (if (equal latin "=>") (setq latin "= >")) + (insert "|" name + "|" (format "=%s=" latex) + "|" (format (if mathp "$%s$" "$\\mbox{%s}$") latex) + "|" (format "=%s=" html) "|" html + "|" ascii "|" latin "|" utf8 + "|\n")))) (goto-char pos) (org-table-align))) @@ -570,31 +560,27 @@ This first checks the user list, then the built-in list." "Create a Help buffer with all available entities." (interactive) (with-output-to-temp-buffer "*Org Entity Help*" - (princ "Org-mode entities\n=================\n\n") + (princ "Org mode entities\n=================\n\n") (let ((ll (append '("* User-defined additions (variable org-entities-user)") org-entities-user org-entities)) - e latex mathp html latin utf8 name ascii (lastwasstring t) (head (concat "\n" " Symbol Org entity LaTeX code HTML code\n" " -----------------------------------------------------------\n"))) - (while ll - (setq e (pop ll)) - (if (stringp e) - (progn - (princ e) - (princ "\n") - (setq lastwasstring t)) - (if lastwasstring (princ head)) - (setq lastwasstring nil) - (setq name (car e) - latex (nth 1 e) - html (nth 3 e) - utf8 (nth 6 e)) - (princ (format " %-8s \\%-16s %-22s %-13s\n" - utf8 name latex html)))))) + (dolist (e ll) + (pcase e + (`(,name ,latex ,_ ,html ,_ ,_ ,utf8) + (when lastwasstring + (princ head) + (setq lastwasstring nil)) + (princ (format " %-8s \\%-16s %-22s %-13s\n" + utf8 name latex html))) + ((pred stringp) + (princ e) + (princ "\n") + (setq lastwasstring t)))))) (with-current-buffer "*Org Entity Help*" (org-mode) (when org-pretty-entities diff --git a/elpa/org-plus-contrib-20150831/org-eshell.el b/elpa/org-plus-contrib-20170407/org-eshell.el similarity index 86% rename from elpa/org-plus-contrib-20150831/org-eshell.el rename to elpa/org-plus-contrib-20170407/org-eshell.el index 115b3336..34cc4ffb 100644 --- a/elpa/org-plus-contrib-20150831/org-eshell.el +++ b/elpa/org-plus-contrib-20170407/org-eshell.el @@ -1,6 +1,6 @@ -;;; org-eshell.el - Support for links to working directories in eshell +;;; org-eshell.el - Support for Links to Working Directories in Eshell -*- lexical-binding: t; -*- -;; Copyright (C) 2011-2015 Free Software Foundation, Inc. +;; Copyright (C) 2011-2017 Free Software Foundation, Inc. ;; Author: Konrad Hinsen @@ -27,8 +27,9 @@ (require 'eshell) (require 'esh-mode) -(org-add-link-type "eshell" 'org-eshell-open) -(add-hook 'org-store-link-functions 'org-eshell-store-link) +(org-link-set-parameters "eshell" + :follow #'org-eshell-open + :store #'org-eshell-store-link) (defun org-eshell-open (link) "Switch to am eshell buffer and execute a command line. @@ -43,7 +44,7 @@ (eshell-buffer-name (car buffer-and-command)) (command (cadr buffer-and-command))) (if (get-buffer eshell-buffer-name) - (org-pop-to-buffer-same-window eshell-buffer-name) + (pop-to-buffer-same-window eshell-buffer-name) (eshell)) (goto-char (point-max)) (eshell-kill-input) diff --git a/elpa/org-plus-contrib-20150831/org-eval-light.el b/elpa/org-plus-contrib-20170407/org-eval-light.el similarity index 99% rename from elpa/org-plus-contrib-20150831/org-eval-light.el rename to elpa/org-plus-contrib-20170407/org-eval-light.el index 872f3a41..57ac2902 100644 --- a/elpa/org-plus-contrib-20150831/org-eval-light.el +++ b/elpa/org-plus-contrib-20170407/org-eval-light.el @@ -1,6 +1,6 @@ ;;; org-eval-light.el --- Display result of evaluating code in various languages (light) -;; Copyright (C) 2008-2014 Free Software Foundation, Inc. +;; Copyright (C) 2008-2017 Free Software Foundation, Inc. ;; Author: Carsten Dominik , ;; Eric Schulte diff --git a/elpa/org-plus-contrib-20150831/org-eval.el b/elpa/org-plus-contrib-20170407/org-eval.el similarity index 99% rename from elpa/org-plus-contrib-20150831/org-eval.el rename to elpa/org-plus-contrib-20170407/org-eval.el index cb5620cf..ecea46ad 100644 --- a/elpa/org-plus-contrib-20150831/org-eval.el +++ b/elpa/org-plus-contrib-20170407/org-eval.el @@ -1,5 +1,5 @@ ;;; org-eval.el --- Display result of evaluating code in various languages -;; Copyright (C) 2008-2014 Free Software Foundation, Inc. +;; Copyright (C) 2008-2017 Free Software Foundation, Inc. ;; ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp diff --git a/elpa/org-plus-contrib-20150831/org-eww.el b/elpa/org-plus-contrib-20170407/org-eww.el similarity index 60% rename from elpa/org-plus-contrib-20150831/org-eww.el rename to elpa/org-plus-contrib-20170407/org-eww.el index a6973e9c..7bc248d4 100644 --- a/elpa/org-plus-contrib-20150831/org-eww.el +++ b/elpa/org-plus-contrib-20170407/org-eww.el @@ -1,12 +1,12 @@ -;;; org-eww.el --- Store url and kill from Eww mode for Org +;;; org-eww.el --- Store url and kill from Eww mode for Org -*- lexical-binding: t -*- -;; Copyright (C) 2014, 2015 Free Software Foundation, Inc. +;; Copyright (C) 2014-2017 Free Software Foundation, Inc. ;; Author: Marco Wahl a ;; Keywords: link, eww ;; Homepage: http://orgmode.org ;; -;; This file is not part of GNU Emacs. +;; This file is part of GNU Emacs. ;; ;; 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 @@ -29,8 +29,8 @@ ;; In an eww buffer function `org-eww-copy-for-org-mode' kills either ;; a region or the whole buffer if no region is set and transforms the -;; text on the fly so that it can be pasted into an org-mode buffer -;; with hot links. +;; text on the fly so that it can be pasted into an Org buffer with +;; hot links. ;; C-c C-x C-w (and also C-c C-x M-w) trigger ;; `org-eww-copy-for-org-mode'. @@ -45,12 +45,20 @@ ;;; Code: (require 'org) +(require 'cl-lib) + +(defvar eww-current-title) +(defvar eww-current-url) +(defvar eww-data) +(defvar eww-mode-map) + +(declare-function eww-current-url "eww") ;; Store Org-link in eww-mode buffer -(add-hook 'org-store-link-functions 'org-eww-store-link) +(org-link-set-parameters "eww" :follow #'eww :store #'org-eww-store-link) (defun org-eww-store-link () - "Store a link to the url of a eww buffer." + "Store a link to the url of a Eww buffer." (when (eq major-mode 'eww-mode) (org-store-link-props :type "eww" @@ -61,22 +69,21 @@ :description (if (< emacs-major-version 25) (or eww-current-title eww-current-url) (or (plist-get eww-data :title) - (eww-current-url)))))) + (eww-current-url)))))) ;; Some auxiliary functions concerning links in eww buffers (defun org-eww-goto-next-url-property-change () - "Move cursor to the start of next link if exists. Else no -move. Return point." + "Move to the start of next link if exists. +Otherwise point is not moved. Return point." (goto-char (or (next-single-property-change (point) 'shr-url) (point)))) -(defun org-eww-no-next-link-p () - "Whether there is no next link after the cursor. -Return t if there is no next link; otherwise, return nil." +(defun org-eww-has-further-url-property-change-p () + "Non-nil if there is a next url property change." (save-excursion - (and (eq (point) (org-eww-goto-next-url-property-change)) t))) + (not (eq (point) (org-eww-goto-next-url-property-change))))) (defun org-eww-url-below-point () "Return the url below point if there is an url; otherwise, return nil." @@ -87,10 +94,10 @@ Return t if there is no next link; otherwise, return nil." "Copy current buffer content or active region with `org-mode' style links. This will encode `link-title' and `link-location' with `org-make-link-string', and insert the transformed test into the kill ring, -so that it can be yanked into an Org-mode buffer with links working correctly. +so that it can be yanked into an Org mode buffer with links working correctly. Further lines starting with a star get quoted with a comma to keep -the structure of the org file." +the structure of the Org file." (interactive) (let* ((regionp (org-region-active-p)) (transform-start (point-min)) @@ -102,53 +109,52 @@ the structure of the org file." (setq transform-start (region-beginning)) (setq transform-end (region-end)) ;; Deactivate mark if current mark is activate. - (if (fboundp 'deactivate-mark) (deactivate-mark))) + (when (fboundp 'deactivate-mark) (deactivate-mark))) (message "Transforming links...") (save-excursion (goto-char transform-start) - (while (and (not out-bound) ; still inside region to copy - (not (org-eww-no-next-link-p))) ; there is a next link - ;; store current point before jump next anchor + (while (and (not out-bound) ; still inside region to copy + (org-eww-has-further-url-property-change-p)) ; there is a next link + ;; Store current point before jump next anchor. (setq temp-position (point)) - ;; move to next anchor when current point is not at anchor + ;; Move to next anchor when current point is not at anchor. (or (org-eww-url-below-point) (org-eww-goto-next-url-property-change)) - (assert (org-eww-url-below-point) t - "program logic error: point must have an url below but it hasn't") - (if (<= (point) transform-end) ; if point is inside transform bound + (cl-assert + (org-eww-url-below-point) t + "program logic error: point must have an url below but it hasn't") + (if (<= (point) transform-end) ; if point is inside transform bound (progn - ;; get content between two links. - (if (> (point) temp-position) - (setq return-content (concat return-content - (buffer-substring - temp-position (point))))) - ;; get link location at current point. + ;; Get content between two links. + (when (< temp-position (point)) + (setq return-content (concat return-content + (buffer-substring + temp-position (point))))) + ;; Get link location at current point. (setq link-location (org-eww-url-below-point)) - ;; get link title at current point. + ;; Get link title at current point. (setq link-title (buffer-substring (point) (org-eww-goto-next-url-property-change))) ;; concat `org-mode' style url to `return-content'. - (setq return-content (concat return-content - (org-make-link-string - link-location link-title)))) - (goto-char temp-position) ; reset point before jump next anchor - (setq out-bound t) ; for break out `while' loop + (setq return-content + (concat return-content + (if (stringp link-location) + ;; hint: link-location is different for form-elements. + (org-make-link-string link-location link-title) + link-title)))) + (goto-char temp-position) ; reset point before jump next anchor + (setq out-bound t) ; for break out `while' loop )) - ;; add the rest until end of the region to be copied - (if (< (point) transform-end) - (setq return-content - (concat return-content - (buffer-substring (point) transform-end)))) - ;; quote lines starting with * - (org-kill-new - (with-temp-buffer - (insert return-content) - (goto-char 0) - (replace-regexp "^\*" ",*") - (buffer-string))) - (message "Transforming links...done, use C-y to insert text into Org-mode file")))) + ;; Add the rest until end of the region to be copied. + (when (< (point) transform-end) + (setq return-content + (concat return-content + (buffer-substring (point) transform-end)))) + ;; Quote lines starting with *. + (org-kill-new (replace-regexp-in-string "^\\*" ",*" return-content)) + (message "Transforming links...done, use C-y to insert text into Org mode file")))) ;; Additional keys for eww-mode @@ -161,9 +167,7 @@ the structure of the org file." (keymapp eww-mode-map)) ; eww is already up. (org-eww-extend-eww-keymap)) -(add-hook - 'eww-mode-hook - (lambda () (org-eww-extend-eww-keymap))) +(add-hook 'eww-mode-hook #'org-eww-extend-eww-keymap) (provide 'org-eww) diff --git a/elpa/org-plus-contrib-20150831/org-expiry.el b/elpa/org-plus-contrib-20170407/org-expiry.el similarity index 97% rename from elpa/org-plus-contrib-20150831/org-expiry.el rename to elpa/org-plus-contrib-20170407/org-expiry.el index 1506c3bc..2b8c0507 100644 --- a/elpa/org-plus-contrib-20150831/org-expiry.el +++ b/elpa/org-plus-contrib-20170407/org-expiry.el @@ -1,6 +1,6 @@ ;;; org-expiry.el --- expiry mechanism for Org entries ;; -;; Copyright 2007-2014 Free Software Foundation, Inc. +;; Copyright 2007-2017 Free Software Foundation, Inc. ;; ;; Author: Bastien Guerry ;; Version: 0.2 @@ -186,7 +186,7 @@ restart `org-mode' if necessary." ;; need this to refresh org-mode hooks (when (eq major-mode 'org-mode) (org-mode) - (if (org-called-interactively-p) + (if (called-interactively-p 'any) (message "Org-expiry insinuated, `org-mode' restarted."))))) (defun org-expiry-deinsinuate (&optional arg) @@ -207,7 +207,7 @@ and restart `org-mode' if necessary." ;; need this to refresh org-mode hooks (when (eq major-mode 'org-mode) (org-mode) - (if (org-called-interactively-p) + (if (called-interactively-p 'any) (message "Org-expiry de-insinuated, `org-mode' restarted."))))) ;;; org-expiry-expired-p: @@ -239,7 +239,7 @@ If FORCE is non-nil, don't require confirmation from the user. Otherwise rely on `org-expiry-confirm-flag' to decide." (interactive "P") (save-excursion - (when (org-called-interactively-p) (org-reveal)) + (when (called-interactively-p) (org-reveal)) (when (org-expiry-expired-p) (org-back-to-heading) (looking-at org-complex-heading-regexp) @@ -253,7 +253,7 @@ Otherwise rely on `org-expiry-confirm-flag' to decide." (not (interactive))) (and org-expiry-confirm-flag (y-or-n-p (format "Entry expired by %d days. Process? " d)))) - (funcall 'org-expiry-handler-function)) + (funcall org-expiry-handler-function)) (delete-overlay ov))))) (defun org-expiry-process-entries (beg end) @@ -271,7 +271,7 @@ The expiry process will run the function defined by (while (and (outline-next-heading) (< (point) end)) (when (org-expiry-expired-p) (setq expired (1+ expired)) - (if (if (org-called-interactively-p) + (if (if (called-interactively-p 'any) (call-interactively 'org-expiry-process-entry) (org-expiry-process-entry)) (setq processed (1+ processed))))) @@ -339,7 +339,7 @@ and insert today's date." (save-excursion (if (org-expiry-expired-p) (org-archive-subtree) - (if (org-called-interactively-p) + (if (called-interactively-p 'any) (message "Entry at point is not expired."))))) (defun org-expiry-add-keyword (&optional keyword) @@ -350,7 +350,7 @@ and insert today's date." (save-excursion (if (org-expiry-expired-p) (org-todo keyword) - (if (org-called-interactively-p) + (if (called-interactively-p 'any) (message "Entry at point is not expired.")))) (error "\"%s\" is not a to-do keyword in this buffer" keyword))) diff --git a/elpa/org-plus-contrib-20170407/org-faces.el b/elpa/org-plus-contrib-20170407/org-faces.el new file mode 100644 index 00000000..cd43d371 --- /dev/null +++ b/elpa/org-plus-contrib-20170407/org-faces.el @@ -0,0 +1,653 @@ +;;; org-faces.el --- Face definitions -*- lexical-binding: t; -*- + +;; Copyright (C) 2004-2017 Free Software Foundation, Inc. + +;; Author: Carsten Dominik +;; 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 . +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;;; Commentary: + +;; This file contains the face definitions for Org. + +;;; Code: + +(defgroup org-faces nil + "Faces in Org mode." + :tag "Org Faces" + :group 'org-appearance) + +(defface org-default '((t :inherit default)) + "Face used for default text." + :group 'org-faces) + +(defface org-hide + '((((background light)) (:foreground "white")) + (((background dark)) (:foreground "black"))) + "Face used to hide leading stars in headlines. +The foreground color of this face should be equal to the background +color of the frame." + :group 'org-faces) + +(defface org-level-1 '((t :inherit outline-1)) + "Face used for level 1 headlines." + :group 'org-faces) + +(defface org-level-2 '((t :inherit outline-2)) + "Face used for level 2 headlines." + :group 'org-faces) + +(defface org-level-3 '((t :inherit outline-3)) + "Face used for level 3 headlines." + :group 'org-faces) + +(defface org-level-4 '((t :inherit outline-4)) + "Face used for level 4 headlines." + :group 'org-faces) + +(defface org-level-5 '((t :inherit outline-5)) + "Face used for level 5 headlines." + :group 'org-faces) + +(defface org-level-6 '((t :inherit outline-6)) + "Face used for level 6 headlines." + :group 'org-faces) + +(defface org-level-7 '((t :inherit outline-7)) + "Face used for level 7 headlines." + :group 'org-faces) + +(defface org-level-8 '((t :inherit outline-8)) + "Face used for level 8 headlines." + :group 'org-faces) + +(defface org-special-keyword '((t :inherit font-lock-keyword-face)) + "Face used for special keywords." + :group 'org-faces) + +(defface org-drawer ;Copied from `font-lock-function-name-face' + '((((class color) (min-colors 88) (background light)) (:foreground "Blue1")) + (((class color) (min-colors 88) (background dark)) (:foreground "LightSkyBlue")) + (((class color) (min-colors 16) (background light)) (:foreground "Blue")) + (((class color) (min-colors 16) (background dark)) (:foreground "LightSkyBlue")) + (((class color) (min-colors 8)) (:foreground "blue" :bold t)) + (t (:bold t))) + "Face used for drawers." + :group 'org-faces) + +(defface org-property-value nil + "Face used for the value of a property." + :group 'org-faces) + +(defface org-column + '((((class color) (min-colors 16) (background light)) + (:background "grey90" :weight normal :slant normal :strike-through nil + :underline nil)) + (((class color) (min-colors 16) (background dark)) + (:background "grey30" :weight normal :slant normal :strike-through nil + :underline nil)) + (((class color) (min-colors 8)) + (:background "cyan" :foreground "black" + :weight normal :slant normal :strike-through nil + :underline nil)) + (t (:inverse-video t))) + "Face for column display of entry properties. +This is actually only part of the face definition for the text in column view. +The following faces apply, with this priority. + +1. The color of the reference face. This is normally the level fact that + is used in the outline. In agenda-mode, it will be the face of the + first character in the line. The color is explicitly retained to + make sure that the column line still looks a bit like the structure + line it is masking. + +2. The `org-column' face. + +3. The remaining properties of the reference face. + +Since column view works by putting overlays with a display property +over individual characters in the buffer, the face of the underlining +character (this might for example be the a TODO keyword) might still +shine through in some properties. So when your column view looks +funny, with \"random\" colors, weight, strike-through, try to explicitly +set the properties in the `org-column' face. For example, set +:underline to nil, or the :slant to `normal'." + :group 'org-faces) + +(defface org-column-title + '((((class color) (min-colors 16) (background light)) + (:background "grey90" :underline t :weight bold)) + (((class color) (min-colors 16) (background dark)) + (:background "grey30" :underline t :weight bold)) + (((class color) (min-colors 8)) + (:background "cyan" :foreground "black" :underline t :weight bold)) + (t (:inverse-video t))) + "Face for column display of entry properties." + :group 'org-faces) + +(defface org-agenda-column-dateline '((t :inherit org-column)) + "Face used in agenda column view for datelines with summaries." + :group 'org-faces) + +(defface org-warning '((t :inherit font-lock-warning-face)) + "Face for deadlines and TODO keywords." + :group 'org-faces) + +(defface org-archived '((t :inherit shadow)) + "Face for headline with the ARCHIVE tag." + :group 'org-faces) + +(defface org-link '((t :inherit link)) + "Face for links." + :group 'org-faces) + +(defface org-footnote + '((((class color) (background light)) (:foreground "Purple" :underline t)) + (((class color) (background dark)) (:foreground "Cyan" :underline t)) + (t (:underline t))) + "Face for footnotes." + :group 'org-faces) + +(defface org-ellipsis + '((((class color) (background light)) (:foreground "DarkGoldenrod" :underline t)) + (((class color) (background dark)) (:foreground "LightGoldenrod" :underline t)) + (t (:strike-through t))) + "Face for the ellipsis in folded text." + :group 'org-faces) + +(defface org-target + '((((class color) (background light)) (:underline t)) + (((class color) (background dark)) (:underline t)) + (t (:underline t))) + "Face for link targets." + :group 'org-faces) + +(defface org-date + '((((class color) (background light)) (:foreground "Purple" :underline t)) + (((class color) (background dark)) (:foreground "Cyan" :underline t)) + (t (:underline t))) + "Face for date/time stamps." + :group 'org-faces) + +(defface org-date-selected + '((((class color) (min-colors 16) (background light)) (:foreground "Red1" :inverse-video t)) + (((class color) (min-colors 16) (background dark)) (:foreground "Pink" :inverse-video t)) + (((class color) (min-colors 8) (background light)) (:foreground "red" :inverse-video t)) + (((class color) (min-colors 8) (background dark)) (:foreground "red" :inverse-video t)) + (t (:inverse-video t))) + "Face for highlighting the calendar day when using `org-read-date'. +Using a bold face here might cause discrepancies while displaying the +calendar." + :group 'org-faces) + +(defface org-sexp-date + '((((class color) (background light)) (:foreground "Purple")) + (((class color) (background dark)) (:foreground "Cyan")) + (t (:underline t))) + "Face for diary-like sexp date specifications." + :group 'org-faces) + +(defface org-tag '((t (:bold t))) + "Default face for tags. +Note that the variable `org-tag-faces' can be used to overrule this face for +specific tags." + :group 'org-faces) + +(defface org-list-dt '((t (:bold t))) + "Default face for definition terms in lists." + :group 'org-faces) + +(defface org-todo ;Copied from `font-lock-warning-face' + '((((class color) (min-colors 16) (background light)) (:foreground "Red1" :bold t)) + (((class color) (min-colors 16) (background dark)) (:foreground "Pink" :bold t)) + (((class color) (min-colors 8) (background light)) (:foreground "red" :bold t)) + (((class color) (min-colors 8) (background dark)) (:foreground "red" :bold t)) + (t (:inverse-video t :bold t))) + "Face for TODO keywords." + :group 'org-faces) + +(defface org-done ;Copied from `font-lock-type-face' + '((((class color) (min-colors 16) (background light)) (:foreground "ForestGreen" :bold t)) + (((class color) (min-colors 16) (background dark)) (:foreground "PaleGreen" :bold t)) + (((class color) (min-colors 8)) (:foreground "green")) + (t (:bold t))) + "Face used for todo keywords that indicate DONE items." + :group 'org-faces) + +(defface org-agenda-done ;Copied from `font-lock-type-face' + '((((class color) (min-colors 16) (background light)) (:foreground "ForestGreen")) + (((class color) (min-colors 16) (background dark)) (:foreground "PaleGreen")) + (((class color) (min-colors 8)) (:foreground "green")) + (t (:bold nil))) + "Face used in agenda, to indicate lines switched to DONE. +This face is used to de-emphasize items that where brightly colored in the +agenda because they were things to do, or overdue. The DONE state itself +is of course immediately visible, but for example a passed deadline is +\(by default) very bright read. This face could be simply the default face +of the frame, for example." + :group 'org-faces) + +(defface org-headline-done ;Copied from `font-lock-string-face' + '((((class color) (min-colors 16) (background light)) (:foreground "RosyBrown")) + (((class color) (min-colors 16) (background dark)) (:foreground "LightSalmon")) + (((class color) (min-colors 8) (background light)) (:bold nil))) + "Face used to indicate that a headline is DONE. +This face is only used if `org-fontify-done-headline' is set. If applies +to the part of the headline after the DONE keyword." + :group 'org-faces) + +(defcustom org-faces-easy-properties + '((todo . :foreground) (tag . :foreground) (priority . :foreground)) + "The property changes by easy faces. +This is an alist, the keys show the area of application, the values +can be `:foreground' or `:background'. A color string for special +keywords will then be interpreted as either foreground or background +color." + :group 'org-faces + :group 'org-todo + :version "24.1" + :type '(repeat + (cons (choice (const todo) (const tag) (const priority)) + (choice (const :foreground) (const :background))))) + +(defcustom org-todo-keyword-faces nil + "Faces for specific TODO keywords. +This is a list of cons cells, with TODO keywords in the car +and faces in the cdr. The face can be a symbol, a color +as a string (in which case the rest is inherited from the `org-todo' face), +or a property list of attributes, like + (:foreground \"blue\" :weight bold :underline t). +If it is a color string, the variable `org-faces-easy-properties' +determines if it is a foreground or a background color." + :group 'org-faces + :group 'org-todo + :type '(repeat + (cons + (string :tag "Keyword") + (choice :tag "Face " + (string :tag "Color") + (sexp :tag "Face"))))) + +(defface org-priority '((t :inherit font-lock-keyword-face)) + "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 +and faces in the cdr. The face can be a symbol, a color as +as a string, or a property list of attributes, like + (:foreground \"blue\" :weight bold :underline t). +If it is a color string, the variable `org-faces-easy-properties' +determines if it is a foreground or a background color." + :group 'org-faces + :group 'org-todo + :type '(repeat + (cons + (character :tag "Priority") + (choice :tag "Face " + (string :tag "Color") + (sexp :tag "Face"))))) + +(defvar org-tags-special-faces-re nil) +(defun org-set-tag-faces (var value) + (set var value) + (if (not value) + (setq org-tags-special-faces-re nil) + (setq org-tags-special-faces-re + (concat ":\\(" (mapconcat 'car value "\\|") "\\):")))) + +(defface org-checkbox '((t :inherit bold)) + "Face for checkboxes." + :group 'org-faces) + +(defface org-checkbox-statistics-todo '((t (:inherit org-todo))) + "Face used for unfinished checkbox statistics." + :group 'org-faces) + +(defface org-checkbox-statistics-done '((t (:inherit org-done))) + "Face used for finished checkbox statistics." + :group 'org-faces) + +(defcustom org-tag-faces nil + "Faces for specific tags. +This is a list of cons cells, with tags in the car and faces in the cdr. +The face can be a symbol, a foreground color (in which case the rest is +inherited from the `org-tag' face) or a property list of attributes, +like (:foreground \"blue\" :weight bold :underline t). +If you set this variable through customize, it will immediately be effective +in new buffers and in modified lines. +If you set it with Lisp, a restart of Emacs is required to activate the +changes." + :group 'org-faces + :group 'org-tags + :set 'org-set-tag-faces + :type '(repeat + (cons + (string :tag "Tag ") + (choice :tag "Face" + (string :tag "Foreground color") + (sexp :tag "Face"))))) + +(defface org-table ;Copied from `font-lock-function-name-face' + '((((class color) (min-colors 88) (background light)) (:foreground "Blue1")) + (((class color) (min-colors 88) (background dark)) (:foreground "LightSkyBlue")) + (((class color) (min-colors 16) (background light)) (:foreground "Blue")) + (((class color) (min-colors 16) (background dark)) (:foreground "LightSkyBlue")) + (((class color) (min-colors 8) (background light)) (:foreground "blue")) + (((class color) (min-colors 8) (background dark)))) + "Face used for tables." + :group 'org-faces) + +(defface org-formula + '((((class color) (min-colors 88) (background light)) (:foreground "Firebrick")) + (((class color) (min-colors 88) (background dark)) (:foreground "chocolate1")) + (((class color) (min-colors 8) (background light)) (:foreground "red")) + (((class color) (min-colors 8) (background dark)) (:foreground "red")) + (t (:bold t :italic t))) + "Face for formulas." + :group 'org-faces) + +(defface org-code '((t :inherit shadow)) + "Face for fixed-width text like code snippets." + :group 'org-faces + :version "22.1") + +(defface org-meta-line '((t :inherit font-lock-comment-face)) + "Face for meta lines starting with \"#+\"." + :group 'org-faces + :version "22.1") + +(defface org-document-title + '((((class color) (background light)) (:foreground "midnight blue" :weight bold)) + (((class color) (background dark)) (:foreground "pale turquoise" :weight bold)) + (t (:weight bold))) + "Face for document title, i.e. that which follows the #+TITLE: keyword." + :group 'org-faces) + +(defface org-document-info + '((((class color) (background light)) (:foreground "midnight blue")) + (((class color) (background dark)) (:foreground "pale turquoise")) + (t nil)) + "Face for document date, author and email; i.e. that which +follows a #+DATE:, #+AUTHOR: or #+EMAIL: keyword." + :group 'org-faces) + +(defface org-document-info-keyword '((t :inherit shadow)) + "Face for #+TITLE:, #+AUTHOR:, #+EMAIL: and #+DATE: keywords." + :group 'org-faces) + +(defface org-block '((t :inherit shadow)) + "Face text in #+begin ... #+end blocks. +For source-blocks `org-src-block-faces' takes precedence. +See also `org-fontify-quote-and-verse-blocks'." + :group 'org-faces + :version "26.1") + +(defface org-block-begin-line '((t (:inherit org-meta-line))) + "Face used for the line delimiting the begin of source blocks." + :group 'org-faces) + +(defface org-block-end-line '((t (:inherit org-block-begin-line))) + "Face used for the line delimiting the end of source blocks." + :group 'org-faces) + +(defface org-verbatim '((t (:inherit shadow))) + "Face for fixed-with text like code snippets" + :group 'org-faces + :version "22.1") + +(defface org-quote '((t (:inherit org-block))) + "Face for #+BEGIN_QUOTE ... #+END_QUOTE blocks." + :group 'org-faces) + +(defface org-verse '((t (:inherit org-block))) + "Face for #+BEGIN_VERSE ... #+END_VERSE blocks." + :group 'org-faces) + +(defcustom org-fontify-quote-and-verse-blocks nil + "Non-nil means, add a special face to #+begin_quote and #+begin_verse block. +When nil, format these as normal Org. This is the default, because the +content of these blocks will still be treated as Org syntax." + :group 'org-faces + :version "24.1" + :type 'boolean) + +(defface org-clock-overlay ;Copied from `secondary-selection' + '((((class color) (min-colors 88) (background light)) + (:background "LightGray" :foreground "black")) + (((class color) (min-colors 88) (background dark)) + (:background "SkyBlue4" :foreground "white")) + (((class color) (min-colors 16) (background light)) + (:background "gray" :foreground "black")) + (((class color) (min-colors 16) (background dark)) + (:background "SkyBlue4" :foreground "white")) + (((class color) (min-colors 8)) + (:background "cyan" :foreground "black")) + (t (:inverse-video t))) + "Basic face for displaying the secondary selection." + :group 'org-faces) + +(defface org-agenda-structure ;Copied from `font-lock-function-name-face' + '((((class color) (min-colors 88) (background light)) (:foreground "Blue1")) + (((class color) (min-colors 88) (background dark)) (:foreground "LightSkyBlue")) + (((class color) (min-colors 16) (background light)) (:foreground "Blue")) + (((class color) (min-colors 16) (background dark)) (:foreground "LightSkyBlue")) + (((class color) (min-colors 8)) (:foreground "blue" :bold t)) + (t (:bold t))) + "Face used in agenda for captions and dates." + :group 'org-faces) + +(defface org-agenda-date '((t (:inherit org-agenda-structure))) + "Face used in agenda for normal days." + :group 'org-faces) + +(defface org-agenda-date-today + '((t (:inherit org-agenda-date :weight bold :italic t))) + "Face used in agenda for today." + :group 'org-faces) + +(defface org-agenda-clocking '((t (:inherit secondary-selection))) + "Face marking the current clock item in the agenda." + :group 'org-faces) + +(defface org-agenda-date-weekend '((t (:inherit org-agenda-date :weight bold))) + "Face used in agenda for weekend days. + +See the variable `org-agenda-weekend-days' for a definition of +which days belong to the weekend." + :group 'org-faces) + +(defface org-scheduled + '((((class color) (min-colors 88) (background light)) (:foreground "DarkGreen")) + (((class color) (min-colors 88) (background dark)) (:foreground "PaleGreen")) + (((class color) (min-colors 8)) (:foreground "green")) + (t (:bold t :italic t))) + "Face for items scheduled for a certain day." + :group 'org-faces) + +(defface org-scheduled-today + '((((class color) (min-colors 88) (background light)) (:foreground "DarkGreen")) + (((class color) (min-colors 88) (background dark)) (:foreground "PaleGreen")) + (((class color) (min-colors 8)) (:foreground "green")) + (t (:bold t :italic t))) + "Face for items scheduled for a certain day." + :group 'org-faces) + +(defface org-agenda-dimmed-todo-face + '((((background light)) (:foreground "grey50")) + (((background dark)) (:foreground "grey50"))) + "Face used to dim blocked tasks in the agenda." + :group 'org-faces) + +(defface org-scheduled-previously + '((((class color) (min-colors 88) (background light)) (:foreground "Firebrick")) + (((class color) (min-colors 88) (background dark)) (:foreground "chocolate1")) + (((class color) (min-colors 8) (background light)) (:foreground "red")) + (((class color) (min-colors 8) (background dark)) (:foreground "red" :bold t)) + (t (:bold t))) + "Face for items scheduled previously, and not yet done." + :group 'org-faces) + +(defface org-upcoming-deadline + '((((class color) (min-colors 88) (background light)) (:foreground "Firebrick")) + (((class color) (min-colors 88) (background dark)) (:foreground "chocolate1")) + (((class color) (min-colors 8) (background light)) (:foreground "red")) + (((class color) (min-colors 8) (background dark)) (:foreground "red" :bold t)) + (t (:bold t))) + "Face for items scheduled previously, and not yet done." + :group 'org-faces) + +(defcustom org-agenda-deadline-faces + '((1.0 . org-warning) + (0.5 . org-upcoming-deadline) + (0.0 . default)) + "Faces for showing deadlines in the agenda. +This is a list of cons cells. The cdr of each cell is a face to be used, +and it can also just be like \\='(:foreground \"yellow\"). +Each car is a fraction of the head-warning time that must have passed for +this the face in the cdr to be used for display. The numbers must be +given in descending order. The head-warning time is normally taken +from `org-deadline-warning-days', but can also be specified in the deadline +timestamp itself, like this: + + DEADLINE: <2007-08-13 Mon -8d> + +You may use d for days, w for weeks, m for months and y for years. Months +and years will only be treated in an approximate fashion (30.4 days for a +month and 365.24 days for a year)." + :group 'org-faces + :group 'org-agenda-daily/weekly + :type '(repeat + (cons + (number :tag "Fraction of head-warning time passed") + (sexp :tag "Face")))) + +(defface org-agenda-restriction-lock + '((((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 '((t :inherit mode-line)) + "Face for tag(s) in the mode-line when filtering the agenda." + :group 'org-faces) + +(defface org-agenda-filter-regexp '((t :inherit mode-line)) + "Face for regexp(s) in the mode-line when filtering the agenda." + :group 'org-faces) + +(defface org-agenda-filter-category '((t :inherit mode-line)) + "Face for categories in the mode-line when filtering the agenda." + :group 'org-faces) + +(defface org-agenda-filter-effort '((t :inherit mode-line)) + "Face for effort in the mode-line when filtering the agenda." + :group 'org-faces) + +(defface org-time-grid ;Copied from `font-lock-variable-name-face' + '((((class color) (min-colors 16) (background light)) (:foreground "DarkGoldenrod")) + (((class color) (min-colors 16) (background dark)) (:foreground "LightGoldenrod")) + (((class color) (min-colors 8)) (:foreground "yellow" :weight light))) + "Face used for time grids." + :group 'org-faces) + +(defface org-agenda-current-time '((t (:inherit org-time-grid))) + "Face used to show the current time in the time grid." + :group 'org-faces) + +(defface org-agenda-diary '((t :inherit default)) + "Face used for agenda entries that come from the Emacs diary." + :group 'org-faces) + +(defface org-agenda-calendar-event '((t :inherit default)) + "Face used to show events and appointments in the agenda." + :group 'org-faces) + +(defface org-agenda-calendar-sexp '((t :inherit default)) + "Face used to show events computed from a S-expression." + :group 'org-faces) + +(defconst org-level-faces + '(org-level-1 org-level-2 org-level-3 org-level-4 + org-level-5 org-level-6 org-level-7 org-level-8)) + +(defcustom org-n-level-faces (length org-level-faces) + "The number of different faces to be used for headlines. +Org mode defines 8 different headline faces, so this can be at most 8. +If it is less than 8, the level-1 face gets re-used for level N+1 etc." + :type 'integer + :group 'org-faces) + +(defcustom org-cycle-level-faces t + "Non-nil means level styles cycle after level `org-n-level-faces'. +Then so level org-n-level-faces+1 is styled like level 1. +If nil, then all levels >=org-n-level-faces are styled like +level org-n-level-faces" + :group 'org-appearance + :group 'org-faces + :version "24.1" + :type 'boolean) + +(defface org-latex-and-related + (let ((font (cond ((assq :inherit custom-face-attributes) + '(:inherit underline)) + (t '(:underline t))))) + `((((class grayscale) (background light)) + (:foreground "DimGray" ,@font)) + (((class grayscale) (background dark)) + (:foreground "LightGray" ,@font)) + (((class color) (background light)) + (:foreground "SaddleBrown")) + (((class color) (background dark)) + (:foreground "burlywood")) + (t (,@font)))) + "Face used to highlight LaTeX data, entities and sub/superscript." + :group 'org-faces + :version "24.4" + :package-version '(Org . "8.0")) + +(defface org-macro '((t :inherit org-latex-and-related)) + "Face for macros." + :group 'org-faces + :version "24.4" + :package-version '(Org . "8.0")) + +(defface org-tag-group '((t :inherit org-tag)) + "Face for group tags." + :group 'org-faces + :version "24.4" + :package-version '(Org . "8.0")) + +(defface org-mode-line-clock '((t (:inherit mode-line))) + "Face used for clock display in mode line." + :group 'org-faces) + +(defface org-mode-line-clock-overrun + '((t (:inherit mode-line :background "red"))) + "Face used for clock display for overrun tasks in mode line." + :group 'org-faces) + +(provide 'org-faces) + +;;; org-faces.el ends here diff --git a/elpa/org-plus-contrib-20150831/org-feed.el b/elpa/org-plus-contrib-20170407/org-feed.el similarity index 87% rename from elpa/org-plus-contrib-20150831/org-feed.el rename to elpa/org-plus-contrib-20170407/org-feed.el index 1ef0bff6..6ebe5ecf 100644 --- a/elpa/org-plus-contrib-20150831/org-feed.el +++ b/elpa/org-plus-contrib-20170407/org-feed.el @@ -1,6 +1,6 @@ -;;; org-feed.el --- Add RSS feed items to Org files +;;; org-feed.el --- Add RSS feed items to Org files -*- lexical-binding: t; -*- ;; -;; Copyright (C) 2009-2015 Free Software Foundation, Inc. +;; Copyright (C) 2009-2017 Free Software Foundation, Inc. ;; ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp @@ -24,11 +24,11 @@ ;; ;;; Commentary: ;; -;; This module allows to create and change entries in an Org-mode -;; file triggered by items in an RSS feed. The basic functionality is -;; geared toward simply adding new items found in a feed as outline nodes -;; to an Org file. Using hooks, arbitrary actions can be triggered for -;; new or changed items. +;; This module allows entries to be created and changed in an Org mode +;; file triggered by items in an RSS feed. The basic functionality +;; is geared toward simply adding new items found in a feed as +;; outline nodes to an Org file. Using hooks, arbitrary actions can +;; be triggered for new or changed items. ;; ;; Selecting feeds and target locations ;; ------------------------------------ @@ -77,10 +77,8 @@ ;; org-feed.el needs to keep track of which feed items have been handled ;; before, so that they will not be handled again. For this, org-feed.el ;; stores information in a special drawer, FEEDSTATUS, under the heading -;; that received the input of the feed. You should add FEEDSTATUS -;; to your list of drawers in the files that receive feed input: +;; that received the input of the feed. ;; -;; #+DRAWERS: PROPERTIES CLOCK LOGBOOK RESULTS FEEDSTATUS ;; ;; Acknowledgments ;; --------------- @@ -93,7 +91,8 @@ (require 'org) (require 'sha1) -(declare-function url-retrieve-synchronously "url" (url)) +(declare-function url-retrieve-synchronously "url" + (url &optional silent inhibit-cookies timeout)) (declare-function xml-node-children "xml" (node)) (declare-function xml-get-children "xml" (node child-name)) (declare-function xml-get-attribute "xml" (node attribute)) @@ -101,8 +100,8 @@ (declare-function xml-substitute-special "xml" (string)) (declare-function org-capture-escaped-% "org-capture" ()) +(declare-function org-capture-expand-embedded-elisp "org-capture" (&optional mark)) (declare-function org-capture-inside-embedded-elisp-p "org-capture" ()) -(declare-function org-capture-expand-embedded-elisp "org-capture" ()) (defgroup org-feed nil "Options concerning RSS feeds as inputs for Org files." @@ -314,7 +313,7 @@ it can be a list structured like an entry in `org-feed-alist'." (parse-entry (or (nth 1 (memq :parse-entry feed)) 'org-feed-parse-rss-entry)) feed-buffer inbox-pos new-formatted - entries old-status status new changed guid-alist e guid olds) + entries old-status status new changed guid-alist guid olds) (setq feed-buffer (org-feed-get-feed url)) (unless (and feed-buffer (bufferp (get-buffer feed-buffer))) (error "Cannot get feed %s" name)) @@ -406,8 +405,8 @@ it can be a list structured like an entry in `org-feed-alist'." ;; Normalize the visibility of the inbox tree (goto-char inbox-pos) - (hide-subtree) - (show-children) + (outline-hide-subtree) + (org-show-children) (org-cycle-hide-drawers 'children) ;; Hooks and messages @@ -441,7 +440,7 @@ it can be a list structured like an entry in `org-feed-alist'." (if (stringp feed) (setq feed (assoc feed org-feed-alist))) (unless feed (error "No such feed in `org-feed-alist")) - (org-pop-to-buffer-same-window + (pop-to-buffer-same-window (org-feed-update feed 'retrieve-only)) (goto-char (point-min))) @@ -476,8 +475,7 @@ This will find DRAWER and extract the alist." "Write the feed STATUS to DRAWER in entry at POS." (save-excursion (goto-char pos) - (let ((end (save-excursion (org-end-of-subtree t t))) - guid) + (let ((end (save-excursion (org-end-of-subtree t t)))) (if (re-search-forward (concat "^[ \t]*:" drawer ":[ \t]*\n") end t) (progn @@ -513,66 +511,77 @@ ENTRY is a property list. This function adds a `:formatted-for-org' property and returns the full property list. If that property is already present, nothing changes." (require 'org-capture) - (if formatter - (funcall formatter entry) - (let (dlines time escape name tmp - v-h v-t v-T v-u v-U v-a) - (setq dlines (org-split-string (or (plist-get entry :description) "???") - "\n") - v-h (or (plist-get entry :title) (car dlines) "???") - time (or (if (plist-get entry :pubDate) - (org-read-date t t (plist-get entry :pubDate))) - (current-time)) - v-t (format-time-string (org-time-stamp-format nil nil) time) - v-T (format-time-string (org-time-stamp-format t nil) time) - v-u (format-time-string (org-time-stamp-format nil t) time) - v-U (format-time-string (org-time-stamp-format t t) time) - v-a (if (setq tmp (or (and (plist-get entry :guid-permalink) - (plist-get entry :guid)) - (plist-get entry :link))) - (concat "[[" tmp "]]\n") - "")) + (if formatter (funcall formatter entry) + (let* ((dlines + (org-split-string (or (plist-get entry :description) "???") + "\n")) + (time (or (if (plist-get entry :pubDate) + (org-read-date t t (plist-get entry :pubDate))) + (current-time))) + (v-h (or (plist-get entry :title) (car dlines) "???")) + (v-t (format-time-string (org-time-stamp-format nil nil) time)) + (v-T (format-time-string (org-time-stamp-format t nil) time)) + (v-u (format-time-string (org-time-stamp-format nil t) time)) + (v-U (format-time-string (org-time-stamp-format t t) time)) + (v-a (let ((tmp (or (and (plist-get entry :guid-permalink) + (plist-get entry :guid)) + (plist-get entry :link)))) + (if tmp (format "[[%s]]\n" tmp ) "")))) (with-temp-buffer - (insert template) - - ;; Simple %-escapes - ;; before embedded elisp to support simple %-escapes as - ;; arguments for embedded elisp - (goto-char (point-min)) - (while (re-search-forward "%\\([a-zA-Z]+\\)" nil t) - (unless (org-capture-escaped-%) - (setq name (match-string 1) - escape (org-capture-inside-embedded-elisp-p)) - (cond - ((member name '("h" "t" "T" "u" "U" "a")) - (setq tmp (symbol-value (intern (concat "v-" name))))) - ((setq tmp (plist-get entry (intern (concat ":" name)))) - (save-excursion - (save-match-data - (beginning-of-line 1) - (when (looking-at - (concat "^\\([ \t]*\\)%" name "[ \t]*$")) - (setq tmp (org-feed-make-indented-block - tmp (org-get-indentation)))))))) - (when tmp - ;; escape string delimiters `"' when inside %() embedded lisp - (when escape - (setq tmp (replace-regexp-in-string "\"" "\\\\\"" tmp))) - (replace-match tmp t t)))) - - ;; %() embedded elisp - (org-capture-expand-embedded-elisp) - - (decode-coding-string - (buffer-string) (detect-coding-region (point-min) (point-max) t)))))) + (insert template) + (goto-char (point-min)) + + ;; Mark %() embedded elisp for later evaluation. + (org-capture-expand-embedded-elisp 'mark) + + ;; Simple %-escapes. `org-capture-escaped-%' may modify + ;; buffer and cripple match-data. Use markers instead. + (while (re-search-forward "%\\([a-zA-Z]+\\)" nil t) + (let ((key (match-string 1)) + (beg (copy-marker (match-beginning 0))) + (end (copy-marker (match-end 0)))) + (unless (org-capture-escaped-%) + (delete-region beg end) + (set-marker beg nil) + (set-marker end nil) + (let ((replacement + (pcase key + ("h" v-h) + ("t" v-t) + ("T" v-T) + ("u" v-u) + ("U" v-U) + ("a" v-a) + (name + (let ((v (plist-get entry (intern (concat ":" name))))) + (save-excursion + (save-match-data + (beginning-of-line) + (if (looking-at + (concat "^\\([ \t]*\\)%" name "[ \t]*$")) + (org-feed-make-indented-block + v (org-get-indentation)) + v)))))))) + (when replacement + (insert + ;; Escape string delimiters within embedded lisp. + (if (org-capture-inside-embedded-elisp-p) + (replace-regexp-in-string "\"" "\\\\\"" replacement) + replacement))))))) + + ;; %() embedded elisp + (org-capture-expand-embedded-elisp) + + (decode-coding-string + (buffer-string) (detect-coding-region (point-min) (point-max) t)))))) (defun org-feed-make-indented-block (s n) "Add indentation of N spaces to a multiline string S." (if (not (string-match "\n" s)) s (mapconcat 'identity - (org-split-string s "\n") - (concat "\n" (make-string n ?\ ))))) + (org-split-string s "\n") + (concat "\n" (make-string n ?\ ))))) (defun org-feed-skip-http-headers (buffer) "Remove HTTP headers from BUFFER, and return it. @@ -604,6 +613,7 @@ Assumes headers are indeed present!" "Parse BUFFER for RSS feed entries. Returns a list of entries, with each entry a property list, containing the properties `:guid' and `:item-full-text'." + (require 'xml) (let ((case-fold-search t) entries beg end item guid entry) (with-current-buffer buffer @@ -615,7 +625,7 @@ containing the properties `:guid' and `:item-full-text'." (match-beginning 0))) (setq item (buffer-substring beg end) guid (if (string-match ".*?>\\(.*?\\)" item) - (org-match-string-no-properties 1 item))) + (xml-substitute-special (match-string-no-properties 1 item)))) (setq entry (list :guid guid :item-full-text item)) (push entry entries) (widen) @@ -690,7 +700,8 @@ formatted as a string, not the original XML data." (xml-node-children content))))) (t (setq entry (plist-put entry :description - (format "Unknown '%s' content." type))))))) + (format-message + "Unknown `%s' content." type))))))) entry)) (provide 'org-feed) diff --git a/elpa/org-plus-contrib-20150831/org-footnote.el b/elpa/org-plus-contrib-20170407/org-footnote.el similarity index 54% rename from elpa/org-plus-contrib-20150831/org-footnote.el rename to elpa/org-plus-contrib-20170407/org-footnote.el index 10e95ee6..e6a3321b 100644 --- a/elpa/org-plus-contrib-20150831/org-footnote.el +++ b/elpa/org-plus-contrib-20170407/org-footnote.el @@ -1,6 +1,6 @@ -;;; org-footnote.el --- Footnote support in Org and elsewhere +;;; org-footnote.el --- Footnote support in Org -*- lexical-binding: t; -*- ;; -;; Copyright (C) 2009-2015 Free Software Foundation, Inc. +;; Copyright (C) 2009-2017 Free Software Foundation, Inc. ;; ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp @@ -24,33 +24,28 @@ ;; ;;; Commentary: -;; This file contains the code dealing with footnotes in Org-mode. -;; The code can also be used in arbitrary text modes to provide -;; footnotes. Compared to Steven L Baur's footnote.el it provides -;; better support for resuming editing. It is less configurable than -;; Steve's code, though. +;; This file contains the code dealing with footnotes in Org mode. ;;; Code: -(eval-when-compile - (require 'cl)) +;;;; Declarations + +(require 'cl-lib) (require 'org-macs) (require 'org-compat) -(declare-function message-point-in-header-p "message" ()) (declare-function org-at-comment-p "org" ()) (declare-function org-at-heading-p "org" (&optional ignored)) (declare-function org-back-over-empty-lines "org" ()) -(declare-function org-back-to-heading "org" (&optional invisible-ok)) -(declare-function org-combine-plists "org" (&rest plists)) (declare-function org-edit-footnote-reference "org-src" ()) +(declare-function org-element-at-point "org-element" ()) +(declare-function org-element-class "org-element" (datum &optional parent)) (declare-function org-element-context "org-element" (&optional element)) +(declare-function org-element-lineage "org-element" (blob &optional types with-self)) (declare-function org-element-property "org-element" (property element)) (declare-function org-element-type "org-element" (element)) (declare-function org-end-of-subtree "org" (&optional invisible-ok to-heading)) (declare-function org-fill-paragraph "org" (&optional justify)) -(declare-function org-icompleting-read "org" (&rest args)) -(declare-function org-id-uuid "org-id" ()) (declare-function org-in-block-p "org" (names)) (declare-function org-in-regexp "org" (re &optional nlines visually)) (declare-function org-in-verbatim-emphasis "org" ()) @@ -58,45 +53,39 @@ (declare-function org-inside-latex-macro-p "org" ()) (declare-function org-mark-ring-push "org" (&optional pos buffer)) (declare-function org-show-context "org" (&optional key)) -(declare-function org-skip-whitespace "org" ()) -(declare-function org-skip-whitespace "org" ()) -(declare-function org-trim "org" (s)) +(declare-function org-trim "org" (s &optional keep-lead)) (declare-function outline-next-heading "outline") -(defvar message-cite-prefix-regexp) ; defined in message.el -(defvar message-signature-separator) ; defined in message.el +(defvar electric-indent-mode) +(defvar org-blank-before-new-entry) ; defined in org.el (defvar org-bracket-link-regexp) ; defined in org.el (defvar org-complex-heading-regexp) ; defined in org.el -(defvar org-element-all-elements) ; defined in org-element.el -(defvar org-element-all-objects) ; defined in org-element.el (defvar org-odd-levels-only) ; defined in org.el +(defvar org-outline-regexp) ; defined in org.el (defvar org-outline-regexp-bol) ; defined in org.el + +;;;; Constants + (defconst org-footnote-re - ;; Only [1]-like footnotes are closed in this regexp, as footnotes - ;; from other types might contain square brackets (i.e. links) in - ;; their definition. - ;; - ;; `org-re' is used for regexp compatibility with XEmacs. - (concat "\\[\\(?:" - ;; Match inline footnotes. - (org-re "fn:\\([-_[:word:]]+\\)?:\\|") - ;; Match other footnotes. - "\\(?:\\([0-9]+\\)\\]\\)\\|" - (org-re "\\(fn:[-_[:word:]]+\\)") - "\\)") - "Regular expression for matching footnotes.") - -(defconst org-footnote-definition-re - (org-re "^\\[\\([0-9]+\\|fn:[-_[:word:]]+\\)\\]") - "Regular expression matching the definition of a footnote.") - -(defconst org-footnote-forbidden-blocks - '("ascii" "beamer" "comment" "example" "html" "latex" "odt" "src") + "\\[fn:\\(?:\\(?1:[-_[:word:]]+\\)?\\(:\\)\\|\\(?1:[-_[:word:]]+\\)\\]\\)" + "Regular expression for matching footnotes. +Match group 1 contains footnote's label. It is nil for anonymous +footnotes. Match group 2 is non-nil only when footnote is +inline, i.e., it contains its own definition.") + +(defconst org-footnote-definition-re "^\\[fn:\\([-_[:word:]]+\\)\\]" + "Regular expression matching the definition of a footnote. +Match group 1 contains definition's label.") + +(defconst org-footnote-forbidden-blocks '("comment" "example" "export" "src") "Names of blocks where footnotes are not allowed.") + +;;;; Customization + (defgroup org-footnote nil - "Footnotes in Org-mode." + "Footnotes in Org mode." :tag "Org Footnote" :group 'org) @@ -118,7 +107,7 @@ this heading will be ignored. If you don't use the customize interface to change this variable, you will need to run the following command after the change: - \\[universal-argument] \\[org-element-cache-reset]" + `\\[universal-argument] \\[org-element-cache-reset]'" :group 'org-footnote :initialize 'custom-initialize-default :set (lambda (var val) @@ -129,20 +118,6 @@ you will need to run the following command after the change: (string :tag "Collect footnotes under heading") (const :tag "Define footnotes locally" nil))) -(defcustom org-footnote-tag-for-non-org-mode-files "Footnotes:" - "Tag marking the beginning of footnote section. -The Org footnote engine can be used in arbitrary text files as well -as in Org-mode. Outside Org mode, new footnotes are always placed at -the end of the file. When you normalize the notes, any line containing -only this tag will be removed, a new one will be inserted at the end -of the file, followed by the collected and normalized footnotes. - -If you don't want any tag in such buffers, set this variable to nil." - :group 'org-footnote - :type '(choice - (string :tag "Collect footnotes under tag") - (const :tag "Don't use a tag" nil))) - (defcustom org-footnote-define-inline nil "Non-nil means define footnotes inline, at reference location. When nil, footnotes will be defined in a special section near @@ -160,15 +135,13 @@ 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]." +random Automatically generate a unique, random label." :group 'org-footnote :type '(choice (const :tag "Prompt for label" nil) (const :tag "Create automatic [fn:N]" t) (const :tag "Offer automatic [fn:N] for editing" confirm) - (const :tag "Create a random label" random) - (const :tag "Create automatic [N]" plain))) + (const :tag "Create a random label" random))) (defcustom org-footnote-auto-adjust nil "Non-nil means automatically adjust footnotes after insert/delete. @@ -196,6 +169,9 @@ extracted will be filled again." :group 'org-footnote :type 'boolean) + +;;;; Predicates + (defun org-footnote-in-valid-context-p () "Is point in a context where footnotes are allowed?" (save-match-data @@ -206,12 +182,6 @@ extracted will be filled again." (save-excursion (beginning-of-line) (looking-at "[ \t]*:[ \t]+")) - ;; Avoid cited text and headers in message-mode. - (and (derived-mode-p 'message-mode) - (or (save-excursion - (beginning-of-line) - (looking-at message-cite-prefix-regexp)) - (message-point-in-header-p))) ;; Avoid forbidden blocks. (org-in-block-p org-footnote-forbidden-blocks))))) @@ -224,13 +194,9 @@ positions, and the definition, when inlined." (or (looking-at org-footnote-re) (org-in-regexp org-footnote-re) (save-excursion (re-search-backward org-footnote-re nil t))) - (/= (match-beginning 0) (point-at-bol))) + (/= (match-beginning 0) (line-beginning-position))) (let* ((beg (match-beginning 0)) - (label (or (org-match-string-no-properties 2) - (org-match-string-no-properties 3) - ;; Anonymous footnotes don't have labels - (and (match-string 1) - (concat "fn:" (org-match-string-no-properties 1))))) + (label (match-string-no-properties 1)) ;; Inline footnotes don't end at (match-end 0) as ;; `org-footnote-re' stops just after the second colon. ;; Find the real ending with `scan-sexps', so Org doesn't @@ -238,7 +204,8 @@ positions, and the definition, when inlined." (end (ignore-errors (scan-sexps beg 1)))) ;; Point is really at a reference if it's located before true ;; ending of the footnote. - (when (and end (< (point) end) + (when (and end + (< (point) end) ;; Verify match isn't a part of a link. (not (save-excursion (goto-char beg) @@ -250,9 +217,10 @@ positions, and the definition, when inlined." (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)) - (org-trim (buffer-substring-no-properties - (match-end 0) (1- end))))))))) + (and (match-end 2) + (org-trim + (buffer-substring-no-properties + (match-end 0) (1- end))))))))) (defun org-footnote-at-definition-p () "Is point within a footnote definition? @@ -275,26 +243,224 @@ otherwise." (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)) + (let ((label (match-string-no-properties 1)) (beg (match-beginning 0)) (beg-def (match-end 0)) - ;; In message-mode, do not search after signature. - (end (let ((bound (and (derived-mode-p 'message-mode) - (save-excursion - (goto-char (point-max)) - (re-search-backward - message-signature-separator nil t))))) - (if (progn - (end-of-line) - (re-search-forward - (concat org-outline-regexp-bol "\\|" - org-footnote-definition-re "\\|" - "^\\([ \t]*\n\\)\\{2,\\}") bound 'move)) - (match-beginning 0) - (point))))) + (end (if (progn + (end-of-line) + (re-search-forward + (concat org-outline-regexp-bol "\\|" + org-footnote-definition-re "\\|" + "^\\([ \t]*\n\\)\\{2,\\}") nil 'move)) + (match-beginning 0) + (point)))) (list label beg end (org-trim (buffer-substring-no-properties beg-def end))))))))) + +;;;; Internal functions + +(defun org-footnote--allow-reference-p () + "Non-nil when a footnote reference can be inserted at point." + ;; XXX: This is similar to `org-footnote-in-valid-context-p' but + ;; more accurate and usually faster, except in some corner cases. + ;; It may replace it after doing proper benchmarks as it would be + ;; used in fontification. + (unless (bolp) + (let* ((context (org-element-context)) + (type (org-element-type context))) + (cond + ;; No footnote reference in attributes. + ((let ((post (org-element-property :post-affiliated context))) + (and post (< (point) post))) + nil) + ;; Paragraphs and blank lines at top of document are fine. + ((memq type '(nil paragraph))) + ;; So are contents of verse blocks. + ((eq type 'verse-block) + (and (>= (point) (org-element-property :contents-begin context)) + (< (point) (org-element-property :contents-end context)))) + ;; In an headline or inlinetask, point must be either on the + ;; heading itself or on the blank lines below. + ((memq type '(headline inlinetask)) + (or (not (org-at-heading-p)) + (and (save-excursion + (beginning-of-line) + (and (let ((case-fold-search t)) + (not (looking-at-p "\\*+ END[ \t]*$"))) + (let ((case-fold-search nil)) + (looking-at org-complex-heading-regexp)))) + (match-beginning 4) + (>= (point) (match-beginning 4)) + (or (not (match-beginning 5)) + (< (point) (match-beginning 5)))))) + ;; White spaces after an object or blank lines after an element + ;; are OK. + ((>= (point) + (save-excursion (goto-char (org-element-property :end context)) + (skip-chars-backward " \r\t\n") + (if (eq (org-element-class context) 'object) (point) + (1+ (line-beginning-position 2)))))) + ;; Other elements are invalid. + ((eq (org-element-class context) 'element) nil) + ;; Just before object is fine. + ((= (point) (org-element-property :begin context))) + ;; Within recursive object too, but not in a link. + ((eq type 'link) nil) + ((let ((cbeg (org-element-property :contents-begin context)) + (cend (org-element-property :contents-end context))) + (and cbeg (>= (point) cbeg) (<= (point) cend)))))))) + +(defun org-footnote--clear-footnote-section () + "Remove all footnote sections in buffer and create a new one. +New section is created at the end of the buffer, before any file +local variable definition. Leave point within the new section." + (when org-footnote-section + (goto-char (point-min)) + (let ((regexp + (format "^\\*+ +%s[ \t]*$" + (regexp-quote org-footnote-section)))) + (while (re-search-forward regexp nil t) + (delete-region + (match-beginning 0) + (progn (org-end-of-subtree t t) + (if (not (eobp)) (point) + (org-footnote--goto-local-insertion-point) + (skip-chars-forward " \t\n") + (if (eobp) (point) (line-beginning-position))))))) + (goto-char (point-max)) + (org-footnote--goto-local-insertion-point) + (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"))) + +(defun org-footnote--set-label (label) + "Set label of footnote at point to string LABEL. +Assume point is at the beginning of the reference or definition +to rename." + (forward-char 4) + (cond ((eq (char-after) ?:) (insert label)) + ((looking-at "\\([-_[:word:]]+\\)") (replace-match label nil nil nil 1)) + (t nil))) + +(defun org-footnote--collect-references (&optional anonymous) + "Collect all labelled footnote references in current buffer. + +Return an alist where associations follow the pattern + + (LABEL MARKER TOP-LEVEL SIZE) + +with + + LABEL the label of the of the definition, + MARKER a marker pointing to its beginning, + TOP-LEVEL a boolean, nil when the footnote is contained within + another one, + SIZE the length of the inline definition, in characters, + or nil for non-inline references. + +When optional ANONYMOUS is non-nil, also collect anonymous +references. In such cases, LABEL is nil. + +References are sorted according to a deep-reading order." + (org-with-wide-buffer + (goto-char (point-min)) + (let ((regexp (if anonymous org-footnote-re "\\[fn:[-_[:word:]]+[]:]")) + references nested) + (save-excursion + (while (re-search-forward regexp nil t) + ;; Ignore definitions. + (unless (and (eq (char-before) ?\]) + (= (line-beginning-position) (match-beginning 0))) + ;; Ensure point is within the reference before parsing it. + (backward-char) + (let ((object (org-element-context))) + (when (eq (org-element-type object) 'footnote-reference) + (let* ((label (org-element-property :label object)) + (begin (org-element-property :begin object)) + (size + (and (eq (org-element-property :type object) 'inline) + (- (org-element-property :contents-end object) + (org-element-property :contents-begin object))))) + (let ((d (org-element-lineage object '(footnote-definition)))) + (push (list label (copy-marker begin) (not d) size) + references) + (when d + ;; Nested references are stored in alist NESTED. + ;; Associations there follow the pattern + ;; + ;; (DEFINITION-LABEL . REFERENCES) + (let* ((def-label (org-element-property :label d)) + (labels (assoc def-label nested))) + (if labels (push label (cdr labels)) + (push (list def-label label) nested))))))))))) + ;; Sort the list of references. Nested footnotes have priority + ;; over top-level ones. + (letrec ((ordered nil) + (add-reference + (lambda (ref allow-nested) + (when (or allow-nested (nth 2 ref)) + (push ref ordered) + (dolist (r (mapcar (lambda (l) (assoc l references)) + (reverse + (cdr (assoc (nth 0 ref) nested))))) + (funcall add-reference r t)))))) + (dolist (r (reverse references) (nreverse ordered)) + (funcall add-reference r nil)))))) + +(defun org-footnote--collect-definitions (&optional delete) + "Collect all footnote definitions in current buffer. + +Return an alist where associations follow the pattern + + (LABEL . DEFINITION) + +with LABEL and DEFINITION being, respectively, the label and the +definition of the footnote, as strings. + +When optional argument DELETE is non-nil, delete the definition +while collecting them." + (org-with-wide-buffer + (goto-char (point-min)) + (let (definitions seen) + (while (re-search-forward org-footnote-definition-re nil t) + (backward-char) + (let ((element (org-element-at-point))) + (let ((label (org-element-property :label element))) + (when (and (eq (org-element-type element) 'footnote-definition) + (not (member label seen))) + (push label seen) + (let* ((beg (progn + (goto-char (org-element-property :begin element)) + (skip-chars-backward " \r\t\n") + (if (bobp) (point) (line-beginning-position 2)))) + (end (progn + (goto-char (org-element-property :end element)) + (skip-chars-backward " \r\t\n") + (line-beginning-position 2))) + (def (org-trim (buffer-substring-no-properties beg end)))) + (push (cons label def) definitions) + (when delete (delete-region beg end))))))) + definitions))) + +(defun org-footnote--goto-local-insertion-point () + "Find insertion point for footnote, just before next outline heading. +Assume insertion point is within currently accessible part of the buffer." + (org-with-limited-levels (outline-next-heading)) + ;; Skip file local variables. See `modify-file-local-variable'. + (when (eobp) + (let ((case-fold-search t)) + (re-search-backward "^[ \t]*# +Local Variables:" + (max (- (point-max) 3000) (point-min)) + t))) + (skip-chars-backward " \t\n") + (forward-line) + (unless (bolp) (insert "\n"))) + + +;;;; Navigation + (defun org-footnote-get-next-reference (&optional label backward limit) "Return complete reference of the next footnote. @@ -305,7 +471,7 @@ the buffer position bounding the search. Return value is a list like those provided by `org-footnote-at-reference-p'. If no footnote is found, return nil." (save-excursion - (let* ((label-fmt (if label (format "\\[%s[]:]" label) org-footnote-re))) + (let* ((label-fmt (if label (format "\\[fn:%s[]:]" label) org-footnote-re))) (catch 'exit (while t (unless (funcall (if backward #'re-search-backward #'re-search-forward) @@ -329,45 +495,19 @@ If no footnote is found, return nil." (unless (re-search-forward org-footnote-re limit t) (goto-char origin) (throw 'exit nil)) - ;; Beware: with [1]-like footnotes point will be just after + ;; Beware: with non-inline footnotes point will be just after ;; the closing square bracket. (backward-char) (cond ((setq ref (org-footnote-at-reference-p)) (throw 'exit ref)) - ;; Definition: also grab the last square bracket, only - ;; matched in `org-footnote-re' for [1]-like footnotes. + ;; Definition: also grab the last square bracket, matched in + ;; `org-footnote-re' for non-inline footnotes. ((save-match-data (org-footnote-at-definition-p)) (let ((end (match-end 0))) (throw 'exit (list nil (match-beginning 0) - (if (eq (char-before end) 93) end (1+ end))))))))))) - -(defun org-footnote-get-definition (label) - "Return label, boundaries and definition of the footnote LABEL." - (let* ((label (regexp-quote (org-footnote-normalize-label label))) - (re (format "^\\[%s\\]\\|.\\[%s:" label label))) - (org-with-wide-buffer - (goto-char (point-min)) - (catch 'found - (while (re-search-forward re nil t) - (let* ((datum (progn (backward-char) (org-element-context))) - (type (org-element-type datum))) - (when (memq type '(footnote-definition footnote-reference)) - (throw 'found - (list - label - (org-element-property :begin datum) - (org-element-property :end datum) - (let ((cbeg (org-element-property :contents-begin datum))) - (if (not cbeg) "" - (replace-regexp-in-string - "[ \t\n]*\\'" - "" - (buffer-substring-no-properties - cbeg - (org-element-property :contents-end datum)))))))))) - nil)))) + (if (eq (char-before end) ?\]) end (1+ end))))))))))) (defun org-footnote-goto-definition (label &optional location) "Move point to the definition of the footnote LABEL. @@ -379,7 +519,8 @@ Throw an error if there is no definition or if it cannot be reached from current narrowed part of buffer. Return a non-nil value if point was successfully moved." (interactive "sLabel: ") - (let ((def-start (or location (nth 1 (org-footnote-get-definition label))))) + (let* ((label (org-footnote-normalize-label label)) + (def-start (or location (nth 1 (org-footnote-get-definition label))))) (cond ((not def-start) (user-error "Cannot find definition of footnote %s" label)) @@ -387,21 +528,21 @@ value if point was successfully moved." (user-error "Definition is outside narrowed part of buffer"))) (org-mark-ring-push) (goto-char def-start) - (looking-at (format "\\[%s[]:] ?" label)) + (looking-at (format "\\[fn:%s[]:] ?" (regexp-quote label))) (goto-char (match-end 0)) (org-show-context 'link-search) (when (derived-mode-p 'org-mode) - (message - (substitute-command-keys - "Edit definition and go back with `\\[org-mark-ring-goto]' or, if \ -unique, with `\\[org-ctrl-c-ctrl-c]'."))) + (message "%s" (substitute-command-keys + "Edit definition and go back with \ +`\\[org-mark-ring-goto]' or, if unique, with `\\[org-ctrl-c-ctrl-c]'."))) t)) (defun org-footnote-goto-previous-reference (label) "Find the first closest (to point) reference of footnote with label LABEL." (interactive "sLabel: ") (org-mark-ring-push) - (let* ((label (org-footnote-normalize-label label)) ref) + (let ((label (org-footnote-normalize-label label)) + ref) (save-excursion (setq ref (or (org-footnote-get-next-reference label t) (org-footnote-get-next-reference label) @@ -415,111 +556,74 @@ unique, with `\\[org-ctrl-c-ctrl-c]'."))) (goto-char (nth 1 ref)) (org-show-context 'link-search)))) + +;;;; Getters + (defun org-footnote-normalize-label (label) - "Return LABEL as an appropriate string." - (cond - ((numberp label) (number-to-string label)) - ((equal "" label) nil) - ((not (string-match "^[0-9]+$\\|^fn:" label)) - (concat "fn:" label)) - (t label))) - -(defun org-footnote-all-labels (&optional with-defs) - "Return list with all defined foot labels used in the buffer. - -If WITH-DEFS is non-nil, also associate the definition to each -label. The function will then return an alist whose key is label -and value definition." - (let* (rtn - (push-to-rtn - (function - ;; Depending on WITH-DEFS, store label or (label . def) of - ;; footnote reference/definition given as argument in RTN. - (lambda (el) - (let ((lbl (car el))) - (push (if with-defs (cons lbl (nth 3 el)) lbl) rtn)))))) - (save-excursion - (save-restriction - (widen) - ;; Find all labels found in definitions. - (goto-char (point-min)) - (let (def) - (while (re-search-forward org-footnote-definition-re nil t) - (when (setq def (org-footnote-at-definition-p)) - (funcall push-to-rtn def)))) - ;; Find all labels found in references. - (goto-char (point-min)) - (let (ref) - (while (setq ref (org-footnote-get-next-reference)) - (goto-char (nth 2 ref)) - (and (car ref) ; ignore anonymous footnotes - (not (funcall (if with-defs #'assoc #'member) (car ref) rtn)) - (funcall push-to-rtn ref)))))) - rtn)) + "Return LABEL without \"fn:\" prefix. +If LABEL is the empty string or constituted of white spaces only, +return nil instead." + (pcase (org-trim label) + ("" nil) + ((pred (string-prefix-p "fn:")) (substring label 3)) + (_ label))) + +(defun org-footnote-get-definition (label) + "Return label, boundaries and definition of the footnote LABEL." + (let* ((label (regexp-quote (org-footnote-normalize-label label))) + (re (format "^\\[fn:%s\\]\\|.\\[fn:%s:" label label))) + (org-with-wide-buffer + (goto-char (point-min)) + (catch 'found + (while (re-search-forward re nil t) + (let* ((datum (progn (backward-char) (org-element-context))) + (type (org-element-type datum))) + (when (memq type '(footnote-definition footnote-reference)) + (throw 'found + (list + label + (org-element-property :begin datum) + (org-element-property :end datum) + (let ((cbeg (org-element-property :contents-begin datum))) + (if (not cbeg) "" + (replace-regexp-in-string + "[ \t\n]*\\'" + "" + (buffer-substring-no-properties + cbeg + (org-element-property :contents-end datum)))))))))) + nil)))) + +(defun org-footnote-all-labels () + "List all defined footnote labels used throughout the buffer. +This function ignores narrowing, if any." + (org-with-wide-buffer + (goto-char (point-min)) + (let (all) + (while (re-search-forward org-footnote-re nil t) + (backward-char) + (let ((context (org-element-context))) + (when (memq (org-element-type context) + '(footnote-definition footnote-reference)) + (let ((label (org-element-property :label context))) + (when label (cl-pushnew label all :test #'equal)))))) + all))) (defun org-footnote-unique-label (&optional current) "Return a new unique footnote label. -The function returns the first \"fn:N\" or \"N\" label that is -currently not used. +The function returns the first numeric label currently unused. Optional argument CURRENT is the list of labels active in the buffer." - (unless current (setq current (org-footnote-all-labels))) - (let ((fmt (if (eq org-footnote-auto-label 'plain) "%d" "fn:%d")) - (cnt 1)) - (while (member (format fmt cnt) current) - (incf cnt)) - (format fmt cnt))) + (let ((current (or current (org-footnote-all-labels)))) + (let ((count 1)) + (while (member (number-to-string count) current) + (cl-incf count)) + (number-to-string count)))) -(defun org-footnote--allow-reference-p () - "Non-nil when a footnote reference can be inserted at point." - ;; XXX: This is similar to `org-footnote-in-valid-context-p' but - ;; more accurate and usually faster, except in some corner cases. - ;; It may replace it after doing proper benchmarks as it would be - ;; used in fontification. - (unless (bolp) - (let* ((context (org-element-context)) - (type (org-element-type context))) - (cond - ;; No footnote reference in attributes. - ((let ((post (org-element-property :post-affiliated context))) - (and post (< (point) post))) - nil) - ;; Paragraphs and blank lines at top of document are fine. - ((memq type '(nil paragraph))) - ;; So are contents of verse blocks. - ((eq type 'verse-block) - (and (>= (point) (org-element-property :contents-begin context)) - (< (point) (org-element-property :contents-end context)))) - ;; In an headline or inlinetask, point must be either on the - ;; heading itself or on the blank lines below. - ((memq type '(headline inlinetask)) - (or (not (org-at-heading-p)) - (and (save-excursion (beginning-of-line) - (and (let ((case-fold-search t)) - (not (looking-at "\\*+ END[ \t]*$"))) - (looking-at org-complex-heading-regexp))) - (match-beginning 4) - (>= (point) (match-beginning 4)) - (or (not (match-beginning 5)) - (< (point) (match-beginning 5)))))) - ;; White spaces after an object or blank lines after an element - ;; are OK. - ((>= (point) - (save-excursion (goto-char (org-element-property :end context)) - (skip-chars-backward " \r\t\n") - (if (memq type org-element-all-objects) (point) - (1+ (line-beginning-position 2)))))) - ;; Other elements are invalid. - ((memq type org-element-all-elements) nil) - ;; Just before object is fine. - ((= (point) (org-element-property :begin context))) - ;; Within recursive object too, but not in a link. - ((eq type 'link) nil) - ((let ((cbeg (org-element-property :contents-begin context)) - (cend (org-element-property :contents-end context))) - (and cbeg (>= (point) cbeg) (<= (point) cend)))))))) + +;;;; Adding, Deleting Footnotes (defun org-footnote-new () "Insert a new footnote. @@ -531,12 +635,12 @@ or new, let the user edit the definition of the footnote." (user-error "Cannot insert a footnote here")) (let* ((all (org-footnote-all-labels)) (label - (org-footnote-normalize-label - (if (eq org-footnote-auto-label 'random) - (format "fn:%x" (random #x100000000)) + (if (eq org-footnote-auto-label 'random) + (format "%x" (random most-positive-fixnum)) + (org-footnote-normalize-label (let ((propose (org-footnote-unique-label all))) - (if (memq org-footnote-auto-label '(t plain)) propose - (org-icompleting-read + (if (eq org-footnote-auto-label t) propose + (completing-read "Label (leave empty for anonymous): " (mapcar #'list all) nil nil (and (eq org-footnote-auto-label 'confirm) propose)))))))) @@ -544,14 +648,14 @@ or new, let the user edit the definition of the footnote." (insert "[fn::]") (backward-char 1)) ((member label all) - (insert "[" label "]") + (insert "[fn:" label "]") (message "New reference to existing note")) (org-footnote-define-inline - (insert "[" label ":]") + (insert "[fn:" label ":]") (backward-char 1) (org-footnote-auto-adjust-maybe)) (t - (insert "[" label "]") + (insert "[fn:" label "]") (let ((p (org-footnote-create-definition label))) ;; `org-footnote-goto-definition' needs to be called ;; after `org-footnote-auto-adjust-maybe'. Otherwise @@ -566,324 +670,27 @@ or new, let the user edit the definition of the footnote." (org-footnote-auto-adjust-maybe) (org-edit-footnote-reference))))))) -(defvar org-blank-before-new-entry) ; Silence byte-compiler. (defun org-footnote-create-definition (label) "Start the definition of a footnote with label LABEL. -Return buffer position at the beginning of the definition. In an -Org buffer, this function doesn't move point." +Return buffer position at the beginning of the definition. This +function doesn't move point." (let ((label (org-footnote-normalize-label label)) electric-indent-mode) ; Prevent wrong indentation. - (cond - ;; In an Org document. - ((derived-mode-p 'org-mode) - ;; If `org-footnote-section' is defined, find it, or create it - ;; at the end of the buffer. - (org-with-wide-buffer - (cond - ((not org-footnote-section) - (org-footnote--goto-local-insertion-point)) - ((save-excursion - (goto-char (point-min)) - (re-search-forward - (concat "^\\*+[ \t]+" (regexp-quote org-footnote-section) "[ \t]*$") - nil t)) - (goto-char (match-end 0)) - (forward-line) - (unless (bolp) (insert "\n"))) - (t - (goto-char (point-max)) - (unless (bolp) (insert "\n")) - ;; Insert new section. Separate it from the previous one - ;; with a blank line, unless `org-blank-before-new-entry' - ;; explicitly says no. - (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"))) - (when (zerop (org-back-over-empty-lines)) (insert "\n")) - (insert "[" label "] \n") - (line-beginning-position 0))) - (t - ;; In a non-Org file. Search for footnote tag, or create it if - ;; specified (at the end of buffer, or before signature if in - ;; Message mode). Set point after any definition already there. - (let ((tag (and org-footnote-tag-for-non-org-mode-files - (concat "^" (regexp-quote - org-footnote-tag-for-non-org-mode-files) - "[ \t]*$"))) - (max (if (and (derived-mode-p 'message-mode) - (goto-char (point-max)) - (re-search-backward - message-signature-separator nil t)) - (progn - ;; Ensure one blank line separates last - ;; footnote from signature. - (beginning-of-line) - (open-line 2) - (point-marker)) - (point-max-marker)))) - (set-marker-insertion-type max t) - (goto-char max) - ;; Check if the footnote tag is defined but missing. In this - ;; case, insert it, before any footnote or one blank line - ;; after any previous text. - (when (and tag (not (re-search-backward tag nil t))) - (skip-chars-backward " \t\r\n") - (while (re-search-backward org-footnote-definition-re nil t)) - (unless (bolp) (newline 2)) - (insert org-footnote-tag-for-non-org-mode-files "\n\n")) - ;; Remove superfluous white space and clear marker. - (goto-char max) - (skip-chars-backward " \t\r\n") - (delete-region (point) max) - (unless (bolp) (newline)) - (set-marker max nil)) - (when (zerop (org-back-over-empty-lines)) (insert "\n")) - (insert "[" label "] \n") - (backward-char) - (line-beginning-position))))) - -;;;###autoload -(defun org-footnote-action (&optional special) - "Do the right thing for footnotes. - -When at a footnote reference, jump to the definition. - -When at a definition, jump to the references if they exist, offer -to create them otherwise. - -When neither at definition or reference, create a new footnote, -interactively if possible. - -With prefix arg SPECIAL, or when no footnote can be created, -offer additional commands in a menu." - (interactive "P") - (let* ((context (and (not special) (org-element-context))) - (type (org-element-type context))) - (cond - ;; On white space after element, insert a new footnote. - ((and context - (> (point) - (save-excursion - (goto-char (org-element-property :end context)) - (skip-chars-backward " \t") - (point)))) - (org-footnote-new)) - ((eq type 'footnote-reference) - (let ((label (org-element-property :label context))) - (cond - ;; Anonymous footnote: move point at the beginning of its - ;; definition. - ((not label) - (goto-char (org-element-property :contents-begin context))) - ;; Check if a definition exists: then move to it. - ((let ((p (nth 1 (org-footnote-get-definition label)))) - (when p (org-footnote-goto-definition label p)))) - ;; No definition exists: offer to create it. - ((yes-or-no-p (format "No definition for %s. Create one? " label)) - (let ((p (org-footnote-create-definition label))) - (or (ignore-errors (org-footnote-goto-definition label p)) - ;; Since definition was created outside current scope, - ;; edit it remotely. - (org-edit-footnote-reference))))))) - ((eq type 'footnote-definition) - (org-footnote-goto-previous-reference - (org-element-property :label context))) - ((or special (not (org-footnote--allow-reference-p))) - (message "Footnotes: [s]ort | [r]enumber fn:N | [S]=r+s | \ -->[n]umeric | [d]elete") - (let ((c (read-char-exclusive))) - (cond - ((eq c ?s) (org-footnote-normalize 'sort)) - ((eq c ?r) (org-footnote-renumber-fn:N)) - ((eq c ?S) - (org-footnote-renumber-fn:N) - (org-footnote-normalize 'sort)) - ((eq c ?n) (org-footnote-normalize)) - ((eq c ?d) (org-footnote-delete)) - (t (error "No such footnote command %c" c))))) - (t (org-footnote-new))))) - -;;;###autoload -(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. - -When SORT-ONLY is set, only sort the footnote definitions into the -referenced sequence." - ;; This is based on Paul's function, but rewritten. - ;; - ;; Re-create `org-with-limited-levels', but not limited to Org - ;; buffers. - (let* ((limit-level - (and (boundp 'org-inlinetask-min-level) - org-inlinetask-min-level - (1- org-inlinetask-min-level))) - (nstars (and limit-level - (if org-odd-levels-only (1- (* limit-level 2)) - limit-level))) - (org-outline-regexp - (concat "\\*" (if nstars (format "\\{1,%d\\} " nstars) "+ "))) - (count 0) - ins-point ref ref-table) (org-with-wide-buffer - ;; 1. Find every footnote reference, extract the definition, and - ;; collect that data in REF-TABLE. If SORT-ONLY is nil, also - ;; normalize references. - (goto-char (point-min)) - (while (setq ref (org-footnote-get-next-reference)) - (let* ((lbl (car ref)) - (pos (nth 1 ref)) - ;; When footnote isn't anonymous, check if it's label - ;; (REF) is already stored in REF-TABLE. In that case, - ;; extract number used to identify it (MARKER). If - ;; footnote is unknown, increment the global counter - ;; (COUNT) to create an unused identifier. - (a (and lbl (assoc lbl ref-table))) - (marker (or (nth 1 a) (incf count))) - ;; Is the reference inline or pointing to an inline - ;; footnote? - (inlinep (or (stringp (nth 3 ref)) (nth 3 a)))) - ;; 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 sort-only (goto-char (nth 2 ref)) - (delete-region (nth 1 ref) (nth 2 ref)) - (goto-char (nth 1 ref)) - (insert (format "[%d]" marker)) - (and inlinep - org-footnote-fill-after-inline-note-extraction - (org-fill-paragraph))) - ;; Add label (REF), identifier (MARKER), definition (DEF) - ;; type (INLINEP) and position (POS) to REF-TABLE if data was - ;; unknown. - (unless a - (let ((def (or (nth 3 ref) ; Inline definition. - (nth 3 (org-footnote-get-definition lbl))))) - (push (list lbl marker def - ;; Reference beginning position is a marker - ;; to preserve it during further buffer - ;; modifications. - inlinep (copy-marker pos)) ref-table))))) - ;; 2. Find and remove the footnote section, if any. Also - ;; determine where footnotes shall be inserted (INS-POINT). (cond - ((and org-footnote-section (derived-mode-p 'org-mode)) - (goto-char (point-min)) - (if (re-search-forward - (concat "^\\*[ \t]+" (regexp-quote org-footnote-section) - "[ \t]*$") nil t) - (delete-region (match-beginning 0) (org-end-of-subtree t t))) - ;; A new footnote section is inserted by default at the end of - ;; the buffer. - (goto-char (point-max)) - (skip-chars-backward " \r\t\n") + ((not org-footnote-section) (org-footnote--goto-local-insertion-point)) + ((save-excursion + (goto-char (point-min)) + (re-search-forward + (concat "^\\*+[ \t]+" (regexp-quote org-footnote-section) "[ \t]*$") + nil t)) + (goto-char (match-end 0)) (forward-line) - (unless (bolp) (newline))) - ;; No footnote section set: Footnotes will be added at the end - ;; of the section containing their first reference. - ((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 - (let ((tag (concat "^" (regexp-quote - org-footnote-tag-for-non-org-mode-files) - "[ \t]*$"))) - (goto-char (point-min)) - (while (re-search-forward tag nil t) - (replace-match "") - (delete-region (point) (progn (forward-line) (point)))))) - ;; In Message mode, ensure footnotes are inserted before the - ;; signature. - (if (and (derived-mode-p 'message-mode) - (goto-char (point-max)) - (re-search-backward message-signature-separator nil t)) - (beginning-of-line) - (goto-char (point-max))))) - (setq ins-point (point-marker)) - ;; 3. Clean-up REF-TABLE. - (setq ref-table - (delq nil - (mapcar - (lambda (x) - (cond - ;; When only sorting, ignore inline footnotes. - ;; Also clear position marker. - ((and sort-only (nth 3 x)) - (set-marker (nth 4 x) nil) nil) - ;; No definition available: provide one. - ((not (nth 2 x)) - (append - (list (car x) (nth 1 x) - (format "DEFINITION NOT FOUND: %s" (car x))) - (nthcdr 3 x))) - (t x))) - ref-table))) - (setq ref-table (nreverse ref-table)) - ;; 4. Remove left-over definitions in the buffer. - (dolist (x ref-table) - (unless (nth 3 x) (org-footnote-delete-definitions (car x)))) - ;; 5. Insert the footnotes again in the buffer, at the - ;; appropriate spot. - (goto-char ins-point) - (cond - ;; 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) - ;; 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'. - (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")) - (set-marker ins-point nil) - ;; Insert the footnotes, separated by a blank line. - (insert - (mapconcat - (lambda (x) - ;; Clean markers. - (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"))) - ;; Each footnote definition has to be inserted at the end of the - ;; section where its first reference belongs. - (t - (dolist (x ref-table) - (let ((pos (nth 4 x))) - (goto-char pos) - ;; Clean marker. - (set-marker pos nil)) - (org-footnote--goto-local-insertion-point) - (insert (format "\n[%s] %s\n" - (nth (if sort-only 0 1) x) - (nth 2 x))))))))) - -(defun org-footnote--goto-local-insertion-point () - "Find insertion point for footnote, just before next outline heading. -Assume insertion point is within currently accessible part of the buffer." - (org-with-limited-levels (outline-next-heading)) - ;; Skip file local variables. See `modify-file-local-variable'. - (when (eobp) - (let ((case-fold-search t)) - (re-search-backward "^[ \t]*# +Local Variables:" - (max (- (point-max) 3000) (point-min)) - t))) - (skip-chars-backward " \t\n") - (forward-line) - (unless (bolp) (insert "\n"))) + (unless (bolp) (insert "\n"))) + (t (org-footnote--clear-footnote-section))) + (when (zerop (org-back-over-empty-lines)) (insert "\n")) + (insert "[fn:" label "] \n") + (line-beginning-position 0)))) (defun org-footnote-delete-references (label) "Delete every reference to footnote LABEL. @@ -894,7 +701,7 @@ Return the number of footnotes removed." (while (setq ref (org-footnote-get-next-reference label)) (goto-char (nth 1 ref)) (delete-region (nth 1 ref) (nth 2 ref)) - (incf nref)) + (cl-incf nref)) nref))) (defun org-footnote-delete-definitions (label) @@ -902,7 +709,7 @@ Return the number of footnotes removed." Return the number of footnotes removed." (save-excursion (goto-char (point-min)) - (let ((def-re (concat "^\\[" (regexp-quote label) "\\]")) + (let ((def-re (format "^\\[fn:%s\\]" (regexp-quote label))) (ndef 0)) (while (re-search-forward def-re nil t) (let ((full-def (org-footnote-at-definition-p))) @@ -912,7 +719,7 @@ Return the number of footnotes removed." (skip-chars-backward " \r\t\n") (unless (bolp) (forward-line)) (delete-region (point) (nth 2 full-def)) - (incf ndef)))) + (cl-incf ndef)))) ndef))) (defun org-footnote-delete (&optional label) @@ -948,24 +755,165 @@ If LABEL is non-nil, delete that footnote instead." (message "%d definition(s) of and %d reference(s) of footnote %s removed" ndef nref label)))) + +;;;; Sorting, Renumbering, Normalizing + (defun org-footnote-renumber-fn:N () - "Renumber the simple footnotes like fn:17 into a sequence in the document." + "Order numbered footnotes into a sequence in the document." (interactive) - (let (map (n 0)) - (org-with-wide-buffer - (goto-char (point-min)) - (while (re-search-forward "\\[fn:\\([0-9]+\\)[]:]" nil t) - (save-excursion - (goto-char (match-beginning 0)) - ;; Ensure match is a footnote reference or definition. - (when (save-match-data (if (bolp) - (org-footnote-at-definition-p) - (org-footnote-at-reference-p))) - (let ((new-val (or (cdr (assoc (match-string 1) map)) - (number-to-string (incf n))))) - (unless (assoc (match-string 1) map) - (push (cons (match-string 1) new-val) map)) - (replace-match new-val nil nil nil 1)))))))) + (let ((references (org-footnote--collect-references))) + (unwind-protect + (let* ((c 0) + (references (cl-remove-if-not + (lambda (r) (string-match-p "\\`[0-9]+\\'" (car r))) + references)) + (alist (mapcar (lambda (l) (cons l (number-to-string (cl-incf c)))) + (delete-dups (mapcar #'car references))))) + (org-with-wide-buffer + ;; Re-number references. + (dolist (ref references) + (goto-char (nth 1 ref)) + (org-footnote--set-label (cdr (assoc (nth 0 ref) alist)))) + ;; Re-number definitions. + (goto-char (point-min)) + (while (re-search-forward "^\\[fn:\\([0-9]+\\)\\]" nil t) + (replace-match (or (cdr (assoc (match-string 1) alist)) + ;; Un-referenced definitions get + ;; higher numbers. + (number-to-string (cl-incf c))) + nil nil nil 1)))) + (dolist (r references) (set-marker (nth 1 r) nil))))) + +(defun org-footnote-sort () + "Rearrange footnote definitions in the current buffer. +Sort footnote definitions so they match order of footnote +references. Also relocate definitions at the end of their +relative section or within a single footnote section, according +to `org-footnote-section'. Inline definitions are ignored." + (let ((references (org-footnote--collect-references))) + (unwind-protect + (let ((definitions (org-footnote--collect-definitions 'delete))) + (org-with-wide-buffer + (org-footnote--clear-footnote-section) + ;; Insert footnote definitions at the appropriate location, + ;; separated by a blank line. Each definition is inserted + ;; only once throughout the buffer. + (let (inserted) + (dolist (cell references) + (let ((label (car cell)) + (nested (not (nth 2 cell))) + (inline (nth 3 cell))) + (unless (or (member label inserted) inline) + (push label inserted) + (unless (or org-footnote-section nested) + ;; If `org-footnote-section' is non-nil, or + ;; reference is nested, point is already at the + ;; correct position. Otherwise, move at the + ;; appropriate location within the section + ;; containing the reference. + (goto-char (nth 1 cell)) + (org-footnote--goto-local-insertion-point)) + (insert "\n" + (or (cdr (assoc label definitions)) + (format "[fn:%s] DEFINITION NOT FOUND." label)) + "\n")))) + ;; Insert un-referenced footnote definitions at the end. + (let ((unreferenced + (cl-remove-if (lambda (d) (member (car d) inserted)) + definitions))) + (dolist (d unreferenced) (insert "\n" (cdr d) "\n")))))) + ;; Clear dangling markers in the buffer. + (dolist (r references) (set-marker (nth 1 r) nil))))) + +(defun org-footnote-normalize () + "Turn every footnote in buffer into a numbered one." + (interactive) + (let ((references (org-footnote--collect-references 'anonymous))) + (unwind-protect + (let ((n 0) + (translations nil) + (definitions nil)) + (org-with-wide-buffer + ;; Update label for reference. We need to do this before + ;; clearing definitions in order to rename nested footnotes + ;; before they are deleted. + (dolist (cell references) + (let* ((label (car cell)) + (anonymous (not label)) + (new + (cond + ;; In order to differentiate anonymous + ;; references from regular ones, set their + ;; labels to integers, not strings. + (anonymous (setcar cell (cl-incf n))) + ((cdr (assoc label translations))) + (t (let ((l (number-to-string (cl-incf n)))) + (push (cons label l) translations) + l))))) + (goto-char (nth 1 cell)) ; Move to reference's start. + (org-footnote--set-label + (if anonymous (number-to-string new) new)) + (let ((size (nth 3 cell))) + ;; Transform inline footnotes into regular references + ;; and retain their definition for later insertion as + ;; a regular footnote definition. + (when size + (let ((def (concat + (format "[fn:%s] " new) + (org-trim + (substring + (delete-and-extract-region + (point) (+ (point) size 1)) + 1))))) + (push (cons (if anonymous new label) def) definitions) + (when org-footnote-fill-after-inline-note-extraction + (org-fill-paragraph))))))) + ;; Collect definitions. Update labels according to ALIST. + (let ((definitions + (nconc definitions + (org-footnote--collect-definitions 'delete))) + (inserted)) + (org-footnote--clear-footnote-section) + (dolist (cell references) + (let* ((label (car cell)) + (anonymous (integerp label)) + (pos (nth 1 cell))) + ;; Move to appropriate location, if required. When + ;; there is a footnote section or reference is + ;; nested, point is already at the expected location. + (unless (or org-footnote-section (not (nth 2 cell))) + (goto-char pos) + (org-footnote--goto-local-insertion-point)) + ;; Insert new definition once label is updated. + (unless (member label inserted) + (push label inserted) + (let ((stored (cdr (assoc label definitions))) + ;; Anonymous footnotes' label is already + ;; up-to-date. + (new (if anonymous label + (cdr (assoc label translations))))) + (insert "\n" + (cond + ((not stored) + (format "[fn:%s] DEFINITION NOT FOUND." new)) + (anonymous stored) + (t + (replace-regexp-in-string + "\\`\\[fn:\\(.*?\\)\\]" new stored nil nil 1))) + "\n"))))) + ;; Insert un-referenced footnote definitions at the end. + (let ((unreferenced + (cl-remove-if (lambda (d) (member (car d) inserted)) + definitions))) + (dolist (d unreferenced) + (insert "\n" + (replace-regexp-in-string + org-footnote-definition-re + (format "[fn:%d]" (cl-incf n)) + (cdr d)) + "\n")))))) + ;; Clear dangling markers. + (dolist (r references) (set-marker (nth 1 r) nil))))) (defun org-footnote-auto-adjust-maybe () "Renumber and/or sort footnotes according to user settings." @@ -973,14 +921,77 @@ If LABEL is non-nil, delete that footnote instead." (org-footnote-renumber-fn:N)) (when (memq org-footnote-auto-adjust '(t sort)) (let ((label (car (org-footnote-at-definition-p)))) - (org-footnote-normalize 'sort) + (org-footnote-sort) (when label (goto-char (point-min)) - (and (re-search-forward (concat "^\\[" (regexp-quote label) "\\]") + (and (re-search-forward (format "^\\[fn:%s\\]" (regexp-quote label)) nil t) (progn (insert " ") (just-one-space))))))) + +;;;; End-user interface + +;;;###autoload +(defun org-footnote-action (&optional special) + "Do the right thing for footnotes. + +When at a footnote reference, jump to the definition. + +When at a definition, jump to the references if they exist, offer +to create them otherwise. + +When neither at definition or reference, create a new footnote, +interactively if possible. + +With prefix arg SPECIAL, or when no footnote can be created, +offer additional commands in a menu." + (interactive "P") + (let* ((context (and (not special) (org-element-context))) + (type (org-element-type context))) + (cond + ;; On white space after element, insert a new footnote. + ((and context + (> (point) + (save-excursion + (goto-char (org-element-property :end context)) + (skip-chars-backward " \t") + (point)))) + (org-footnote-new)) + ((eq type 'footnote-reference) + (let ((label (org-element-property :label context))) + (cond + ;; Anonymous footnote: move point at the beginning of its + ;; definition. + ((not label) + (goto-char (org-element-property :contents-begin context))) + ;; Check if a definition exists: then move to it. + ((let ((p (nth 1 (org-footnote-get-definition label)))) + (when p (org-footnote-goto-definition label p)))) + ;; No definition exists: offer to create it. + ((yes-or-no-p (format "No definition for %s. Create one? " label)) + (let ((p (org-footnote-create-definition label))) + (or (ignore-errors (org-footnote-goto-definition label p)) + ;; Since definition was created outside current scope, + ;; edit it remotely. + (org-edit-footnote-reference))))))) + ((eq type 'footnote-definition) + (org-footnote-goto-previous-reference + (org-element-property :label context))) + ((or special (not (org-footnote--allow-reference-p))) + (message "Footnotes: [s]ort | [r]enumber fn:N | [S]=r+s | [n]ormalize | \ +\[d]elete") + (pcase (read-char-exclusive) + (?s (org-footnote-sort)) + (?r (org-footnote-renumber-fn:N)) + (?S (org-footnote-renumber-fn:N) + (org-footnote-sort)) + (?n (org-footnote-normalize)) + (?d (org-footnote-delete)) + (char (error "No such footnote command %c" char)))) + (t (org-footnote-new))))) + + (provide 'org-footnote) ;; Local variables: diff --git a/elpa/org-plus-contrib-20150831/org-git-link.el b/elpa/org-plus-contrib-20170407/org-git-link.el similarity index 96% rename from elpa/org-plus-contrib-20150831/org-git-link.el rename to elpa/org-plus-contrib-20170407/org-git-link.el index ad0ce715..9d3ff324 100644 --- a/elpa/org-plus-contrib-20150831/org-git-link.el +++ b/elpa/org-plus-contrib-20170407/org-git-link.el @@ -69,7 +69,7 @@ ;; org link functions ;; bare git link -(org-add-link-type "gitbare" 'org-gitbare-open) +(org-link-set-parameters "gitbare" :follow #'org-gitbare-open) (defun org-gitbare-open (str) (let* ((strlist (org-git-split-string str)) @@ -92,7 +92,7 @@ (setq buffer-read-only t))) ;; user friendly link -(org-add-link-type "git" 'org-git-open) +(org-link-set-parameters "git" :follow #'org-git-open :store #'org-git-store-link) (defun org-git-open (str) (let* ((strlist (org-git-split-string str)) @@ -135,10 +135,8 @@ (eval-and-compile - (if (featurep 'xemacs) - (defalias 'org-git-gitrepos-p 'org-git-find-gitdir) - (defalias 'org-git-gitrepos-p 'org-git-find-gitdir - "Return non-nil if path is in git repository"))) + (defalias 'org-git-gitrepos-p 'org-git-find-gitdir + "Return non-nil if path is in git repository")) ;; splitting the link string @@ -192,8 +190,6 @@ than two double colons, str2 and/or str3 may be set the empty string." :type "git" :link (org-git-create-git-link file line)))))) -(add-hook 'org-store-link-functions 'org-git-store-link) - (defun org-git-insert-link-interactively (file searchstring &optional description) (interactive "FFile: \nsSearch string: \nsDescription: ") (insert (org-make-link-string (concat "git:" file "::" searchstring) description))) diff --git a/elpa/org-plus-contrib-20150831/org-gnus.el b/elpa/org-plus-contrib-20170407/org-gnus.el similarity index 87% rename from elpa/org-plus-contrib-20150831/org-gnus.el rename to elpa/org-plus-contrib-20170407/org-gnus.el index c7b46af9..b9d09895 100644 --- a/elpa/org-plus-contrib-20150831/org-gnus.el +++ b/elpa/org-plus-contrib-20170407/org-gnus.el @@ -1,6 +1,6 @@ -;;; org-gnus.el --- Support for links to Gnus groups and messages from within Org-mode +;;; org-gnus.el --- Support for Links to Gnus Groups and Messages -*- lexical-binding: t; -*- -;; Copyright (C) 2004-2015 Free Software Foundation, Inc. +;; Copyright (C) 2004-2017 Free Software Foundation, Inc. ;; Author: Carsten Dominik ;; Tassilo Horn @@ -25,8 +25,8 @@ ;; ;;; Commentary: -;; This file implements links to Gnus groups and messages from within Org-mode. -;; Org-mode loads this module by default - if this is not what you want, +;; This file implements links to Gnus groups and messages from within Org. +;; Org mode loads this module by default - if this is not what you want, ;; configure the variable `org-modules'. ;;; Code: @@ -39,18 +39,17 @@ (declare-function message-fetch-field "message" (header &optional not-all)) (declare-function message-narrow-to-head-1 "message" nil) -(declare-function nnimap-group-overview-filename "nnimap" (group server)) (declare-function gnus-summary-last-subject "gnus-sum" nil) (declare-function nnvirtual-map-article "nnvirtual" (article)) ;; Customization variables -(org-defvaralias 'org-usenet-links-prefer-google 'org-gnus-prefer-web-links) +(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. -When nil, Gnus will be used for such links. -Using a prefix arg to the command \\[org-store-link] (`org-store-link') +\\When nil, Gnus will be used for such links. +Using a prefix argument to the command `\\[org-store-link]' (`org-store-link') negates this setting for the duration of the command." :group 'org-link-store :type 'boolean) @@ -75,8 +74,7 @@ this variable to t." :type 'boolean) ;; Install the link type -(org-add-link-type "gnus" 'org-gnus-open) -(add-hook 'org-store-link-functions 'org-gnus-store-link) +(org-link-set-parameters "gnus" :follow #'org-gnus-open :store #'org-gnus-store-link) ;; Implementation @@ -85,8 +83,12 @@ this variable to t." MESSAGE-ID is the message-id header field that identifies the message. If the uid is not cached, return nil." (with-temp-buffer - (let ((nov (nnimap-group-overview-filename group server))) - (when (file-exists-p nov) + (let ((nov (and (fboundp 'nnimap-group-overview-filename) + ;; nnimap-group-overview-filename was removed from + ;; Gnus in September 2010, and therefore should + ;; only be present in Emacs 23.1. + (nnimap-group-overview-filename group server)))) + (when (and nov (file-exists-p nov)) (mm-insert-file-contents nov) (set-buffer-modified-p nil) (goto-char (point-min)) @@ -105,7 +107,7 @@ Otherwise create a link to the group inside Gnus. If `org-store-link' was called with a prefix arg the meaning of `org-gnus-prefer-web-links' is reversed." (let ((unprefixed-group (replace-regexp-in-string "^[^:]+:" "" group))) - (if (and (string-match "^nntp" group) ;; Only for nntp groups + (if (and (string-prefix-p "nntp" group) ;; Only for nntp groups (org-xor current-prefix-arg org-gnus-prefer-web-links)) (concat (if (string-match "gmane" unprefixed-group) @@ -157,25 +159,17 @@ If `org-store-link' was called with a prefix arg the meaning of (header (with-current-buffer gnus-summary-buffer (gnus-summary-article-header))) (from (mail-header-from header)) - (message-id (org-remove-angle-brackets (mail-header-id header))) + (message-id (org-unbracket-string "<" ">" (mail-header-id header))) (date (org-trim (mail-header-date header))) - (date-ts (and date - (ignore-errors - (format-time-string - (org-time-stamp-format t) - (date-to-time date))))) - (date-ts-ia (and date - (ignore-errors - (format-time-string - (org-time-stamp-format t t) - (date-to-time date))))) (subject (copy-sequence (mail-header-subject header))) (to (cdr (assq 'To (mail-header-extra header)))) newsgroups x-no-archive desc link) - (when (eq (car (gnus-find-method-for-group gnus-newsgroup-name)) - 'nnvirtual) - (setq group (car (nnvirtual-map-article - (gnus-summary-article-number))))) + (cl-case (car (gnus-find-method-for-group gnus-newsgroup-name)) + (nnvirtual + (setq group (car (nnvirtual-map-article + (gnus-summary-article-number))))) + (nnir + (setq group (nnir-article-group (gnus-summary-article-number))))) ;; Remove text properties of subject string to avoid Emacs bug ;; #3506 (set-text-properties 0 (length subject) nil subject) @@ -188,11 +182,8 @@ If `org-store-link' was called with a prefix arg the meaning of (setq to (or to (gnus-fetch-original-field "To")) newsgroups (gnus-fetch-original-field "Newsgroups") x-no-archive (gnus-fetch-original-field "x-no-archive"))) - (org-store-link-props :type "gnus" :from from :subject subject + (org-store-link-props :type "gnus" :from from :date date :subject subject :message-id message-id :group group :to to) - (when date - (org-add-link-props :date date :date-timestamp date-ts - :date-timestamp-inactive date-ts-ia)) (setq desc (org-email-link-description) link (org-gnus-article-link group newsgroups message-id x-no-archive)) @@ -211,7 +202,7 @@ If `org-store-link' was called with a prefix arg the meaning of (let ((gcc (car (last (message-unquote-tokens (message-tokenize-header (mail-fetch-field "gcc" nil t) " ,"))))) - (id (org-remove-angle-brackets (mail-fetch-field "Message-ID"))) + (id (org-unbracket-string "<" ">" (mail-fetch-field "Message-ID"))) (to (mail-fetch-field "To")) (from (mail-fetch-field "From")) (subject (mail-fetch-field "Subject")) diff --git a/elpa/org-plus-contrib-20150831/org-habit.el b/elpa/org-plus-contrib-20170407/org-habit.el similarity index 84% rename from elpa/org-plus-contrib-20150831/org-habit.el rename to elpa/org-plus-contrib-20170407/org-habit.el index 338aabcd..52a0628d 100644 --- a/elpa/org-plus-contrib-20150831/org-habit.el +++ b/elpa/org-plus-contrib-20170407/org-habit.el @@ -1,6 +1,6 @@ -;;; org-habit.el --- The habit tracking code for Org-mode +;;; org-habit.el --- The habit tracking code for Org -*- lexical-binding: t; -*- -;; Copyright (C) 2009-2015 Free Software Foundation, Inc. +;; Copyright (C) 2009-2017 Free Software Foundation, Inc. ;; Author: John Wiegley ;; Keywords: outlines, hypermedia, calendar, wp @@ -24,18 +24,16 @@ ;; ;;; Commentary: -;; This file contains the habit tracking code for Org-mode +;; This file contains the habit tracking code for Org mode ;;; Code: +(require 'cl-lib) (require 'org) (require 'org-agenda) -(eval-when-compile - (require 'cl)) - (defgroup org-habit nil - "Options concerning habit tracking in Org-mode." + "Options concerning habit tracking in Org mode." :tag "Org Habit" :group 'org-progress) @@ -170,9 +168,9 @@ Returns a list with the following elements: This list represents a \"habit\" for the rest of this module." (save-excursion (if pom (goto-char pom)) - (assert (org-is-habit-p (point))) + (cl-assert (org-is-habit-p (point))) (let* ((scheduled (org-get-scheduled-time (point))) - (scheduled-repeat (org-get-repeat org-scheduled-string)) + (scheduled-repeat (org-get-repeat (org-entry-get (point) "SCHEDULED"))) (end (org-entry-end-position)) (habit-entry (org-no-properties (nth 4 (org-heading-components)))) closed-dates deadline dr-days sr-days sr-type) @@ -181,11 +179,11 @@ This list represents a \"habit\" for the rest of this module." (error "Habit %s has no scheduled date" habit-entry)) (unless scheduled-repeat (error - "Habit '%s' has no scheduled repeat period or has an incorrect one" + "Habit `%s' has no scheduled repeat period or has an incorrect one" habit-entry)) (setq sr-days (org-habit-duration-to-days scheduled-repeat) sr-type (progn (string-match "[\\.+]?\\+" scheduled-repeat) - (org-match-string-no-properties 0 scheduled-repeat))) + (match-string-no-properties 0 scheduled-repeat))) (unless (> sr-days 0) (error "Habit %s scheduled repeat period is less than 1d" habit-entry)) (when (string-match "/\\([0-9]+[dwmy]\\)" scheduled-repeat) @@ -222,8 +220,8 @@ This list represents a \"habit\" for the rest of this module." (while (and (< count maxdays) (funcall search re limit t)) (push (time-to-days (org-time-string-to-time - (or (org-match-string-no-properties 1) - (org-match-string-no-properties 2)))) + (or (match-string-no-properties 1) + (match-string-no-properties 2)))) closed-dates) (setq count (1+ count)))) (list scheduled sr-days deadline dr-days closed-dates sr-type)))) @@ -286,7 +284,6 @@ Habits are assigned colors on the following basis: schedule's repeat period." (let* ((scheduled (or scheduled-days (org-habit-scheduled habit))) (s-repeat (org-habit-scheduled-repeat habit)) - (scheduled-end (+ scheduled (1- s-repeat))) (d-repeat (org-habit-deadline-repeat habit)) (deadline (if scheduled-days (+ scheduled-days (- d-repeat s-repeat)) @@ -310,13 +307,14 @@ Habits are assigned colors on the following basis: CURRENT gives the current time between STARTING and ENDING, for the purpose of drawing the graph. It need not be the actual current time." - (let* ((done-dates (sort (org-habit-done-dates habit) '<)) + (let* ((all-done-dates (sort (org-habit-done-dates habit) #'<)) + (done-dates all-done-dates) (scheduled (org-habit-scheduled habit)) (s-repeat (org-habit-scheduled-repeat habit)) (start (time-to-days starting)) (now (time-to-days current)) (end (time-to-days ending)) - (graph (make-string (1+ (- end start)) ?\ )) + (graph (make-string (1+ (- end start)) ?\s)) (index 0) last-done-date) (while (and done-dates (< (car done-dates) start)) @@ -325,35 +323,55 @@ current time." (while (< start end) (let* ((in-the-past-p (< start now)) (todayp (= start now)) - (donep (and done-dates - (= start (car done-dates)))) - (faces (if (and in-the-past-p - (not last-done-date) - (not (< scheduled now))) - '(org-habit-clear-face . org-habit-clear-future-face) - (org-habit-get-faces - habit start - (and in-the-past-p last-done-date - ;; Compute scheduled time for habit at the - ;; time START was current. - (let ((type (org-habit-repeat-type habit))) - (cond - ((equal type ".+") - (+ last-done-date s-repeat)) - ((equal type "+") - ;; Since LAST-DONE-DATE, each done - ;; mark shifted scheduled date by - ;; S-REPEAT. - (- scheduled (* (length done-dates) s-repeat))) - (t - ;; Scheduled time was the first time - ;; past LAST-DONE-STATE which can jump - ;; to current SCHEDULED time by - ;; S-REPEAT hops. - (- scheduled - (* (/ (- scheduled last-done-date) s-repeat) - s-repeat)))))) - donep))) + (donep (and done-dates (= start (car done-dates)))) + (faces + (if (and in-the-past-p + (not last-done-date) + (not (< scheduled now))) + '(org-habit-clear-face . org-habit-clear-future-face) + (org-habit-get-faces + habit start + (and in-the-past-p + last-done-date + ;; Compute scheduled time for habit at the time + ;; START was current. + (let ((type (org-habit-repeat-type habit))) + (cond + ;; At the last done date, use current + ;; scheduling in all cases. + ((null done-dates) scheduled) + ((equal type ".+") (+ last-done-date s-repeat)) + ((equal type "+") + ;; Since LAST-DONE-DATE, each done mark + ;; shifted scheduled date by S-REPEAT. + (- scheduled (* (length done-dates) s-repeat))) + (t + ;; Compute the scheduled time after the + ;; first repeat. This is the closest time + ;; past FIRST-DONE which can reach SCHEDULED + ;; by a number of S-REPEAT hops. + ;; + ;; Then, play TODO state change history from + ;; the beginning in order to find current + ;; scheduled time. + (let* ((first-done (car all-done-dates)) + (s (let ((shift (mod (- scheduled first-done) + s-repeat))) + (+ (if (= shift 0) s-repeat shift) + first-done)))) + (if (= first-done last-done-date) s + (catch :exit + (dolist (done (cdr all-done-dates) s) + ;; Each repeat shifts S by any + ;; number of S-REPEAT hops it takes + ;; to get past DONE, with a minimum + ;; of one hop. + (cl-incf s (* (1+ (/ (max (- done s) 0) + s-repeat)) + s-repeat)) + (when (= done last-done-date) + (throw :exit s)))))))))) + donep))) markedp face) (if donep (let ((done-time (time-add @@ -386,7 +404,7 @@ current time." (defun org-habit-insert-consistency-graphs (&optional line) "Insert consistency graph for any habitual tasks." - (let ((inhibit-read-only t) l c + (let ((inhibit-read-only t) (buffer-invisibility-spec '(org-link)) (moment (time-subtract (current-time) (list 0 (* 3600 org-extend-today-until) 0)))) diff --git a/elpa/org-plus-contrib-20150831/org-id.el b/elpa/org-plus-contrib-20170407/org-id.el similarity index 96% rename from elpa/org-plus-contrib-20150831/org-id.el rename to elpa/org-plus-contrib-20170407/org-id.el index 5c85d7a1..f07d243b 100644 --- a/elpa/org-plus-contrib-20150831/org-id.el +++ b/elpa/org-plus-contrib-20170407/org-id.el @@ -1,6 +1,6 @@ -;;; org-id.el --- Global identifiers for Org-mode entries +;;; org-id.el --- Global identifiers for Org entries -*- lexical-binding: t; -*- ;; -;; Copyright (C) 2008-2015 Free Software Foundation, Inc. +;; Copyright (C) 2008-2017 Free Software Foundation, Inc. ;; ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp @@ -24,7 +24,7 @@ ;; ;;; Commentary: -;; This file implements globally unique identifiers for Org-mode entries. +;; This file implements globally unique identifiers for Org entries. ;; Identifiers are stored in the entry as an :ID: property. Functions ;; are provided that create and retrieve such identifiers, and that find ;; entries based on the identifier. @@ -73,20 +73,17 @@ (require 'org) (declare-function message-make-fqdn "message" ()) -(declare-function org-pop-to-buffer-same-window - "org-compat" (&optional buffer-or-name norecord label)) ;;; Customization (defgroup org-id nil - "Options concerning global entry identifiers in Org-mode." + "Options concerning global entry identifiers in Org mode." :tag "Org ID" :group 'org) -(define-obsolete-variable-alias - 'org-link-to-org-use-id 'org-id-link-to-org-use-id "24.3") (defcustom org-id-link-to-org-use-id nil "Non-nil means storing a link to an Org file will use entry IDs. +\\\ The variable can have the following values: @@ -101,7 +98,7 @@ create-if-interactive call `org-capture' that automatically and preemptively creates a link. If you do want to get an ID link in a capture template to an entry not having an ID, create it first by explicitly creating - a link to it, using `C-c C-l' first. + a link to it, using `\\[org-store-link]' first. create-if-interactive-and-no-custom-id Like create-if-interactive, but do not create an ID if there is @@ -203,7 +200,7 @@ This variable is only relevant when `org-id-track-globally' is set." When Org reparses files to remake the list of files and IDs it is tracking, it will normally scan the agenda files, the archives related to agenda files, any files that are listed as ID containing in the current register, and -any Org-mode files currently visited by Emacs. +any Org file currently visited by Emacs. You can list additional files here. This variable is only relevant when `org-id-track-globally' is set." :group 'org-id @@ -277,7 +274,7 @@ If necessary, the ID is created." (move-marker pom nil)))) ;;;###autoload -(defun org-id-get-with-outline-drilling (&optional targets) +(defun org-id-get-with-outline-drilling () "Use an outline-cycling interface to retrieve the ID of an entry. This only finds entries in the current buffer, using `org-get-location'. It returns the ID of the entry. If necessary, the ID is created." @@ -294,7 +291,7 @@ Move the cursor to that entry in that buffer." (let ((m (org-id-find id 'marker))) (unless m (error "Cannot find entry with ID \"%s\"" id)) - (org-pop-to-buffer-same-window (marker-buffer m)) + (pop-to-buffer-same-window (marker-buffer m)) (goto-char m) (move-marker m nil) (org-show-context))) @@ -447,8 +444,7 @@ and time is the usual three-integer representation of time." Store the relation between files and corresponding IDs. This will scan all agenda files, all associated archives, and all files currently mentioned in `org-id-locations'. -When FILES is given, scan these files instead. -When CHECK is given, prepare detailed information about duplicate IDs." +When FILES is given, scan these files instead." (interactive) (if (not org-id-track-globally) (error "Please turn on `org-id-track-globally' if you want to track IDs") @@ -466,7 +462,7 @@ When CHECK is given, prepare detailed information about duplicate IDs." (if (symbolp org-id-extra-files) (symbol-value org-id-extra-files) org-id-extra-files) - ;; Files associated with live org-mode buffers + ;; Files associated with live Org buffers (delq nil (mapcar (lambda (b) (with-current-buffer b @@ -494,7 +490,7 @@ When CHECK is given, prepare detailed information about duplicate IDs." (goto-char (point-min)) (while (re-search-forward "^[ \t]*:ID:[ \t]+\\(\\S-+\\)[ \t]*$" nil t) - (setq id (org-match-string-no-properties 1)) + (setq id (match-string-no-properties 1)) (if (member id found) (progn (message "Duplicate ID \"%s\", also in file %s" @@ -678,7 +674,7 @@ optional argument MARKERP, return the position as a new marker." (move-marker m nil) (org-show-context))) -(org-add-link-type "id" 'org-id-open) +(org-link-set-parameters "id" :follow #'org-id-open) (provide 'org-id) diff --git a/elpa/org-plus-contrib-20150831/org-indent.el b/elpa/org-plus-contrib-20170407/org-indent.el similarity index 84% rename from elpa/org-plus-contrib-20150831/org-indent.el rename to elpa/org-plus-contrib-20170407/org-indent.el index 197042d0..e1a33172 100644 --- a/elpa/org-plus-contrib-20150831/org-indent.el +++ b/elpa/org-plus-contrib-20170407/org-indent.el @@ -1,5 +1,6 @@ -;;; org-indent.el --- Dynamic indentation for Org-mode -;; Copyright (C) 2009-2015 Free Software Foundation, Inc. +;;; org-indent.el --- Dynamic indentation for Org -*- lexical-binding: t; -*- + +;; Copyright (C) 2009-2017 Free Software Foundation, Inc. ;; ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp @@ -39,8 +40,7 @@ (require 'org-compat) (require 'org) -(eval-when-compile - (require 'cl)) +(require 'cl-lib) (declare-function org-inlinetask-get-task-level "org-inlinetask" ()) (declare-function org-inlinetask-in-task-p "org-inlinetask" ()) @@ -68,7 +68,7 @@ Delay used when the buffer to initialize is current.") Delay used when the buffer to initialize isn't current.") (defvar org-indent-agent-resume-delay '(0 0 100000) "Minimal time for other idle processes before switching back to agent.") -(defvar org-indent-initial-marker nil +(defvar org-indent--initial-marker nil "Position of initialization before interrupt. This is used locally in each buffer being initialized.") (defvar org-hide-leading-stars-before-indent-mode nil @@ -127,32 +127,23 @@ buffer, which can take a few seconds on large buffers, is done during idle time." nil " Ind" nil (cond - ((and org-indent-mode (featurep 'xemacs)) - (message "org-indent-mode does not work in XEmacs - refusing to turn it on") - (setq org-indent-mode nil)) - ((and org-indent-mode - (not (org-version-check "23.1.50" "Org Indent mode" :predicate))) - (message "org-indent-mode can crash Emacs 23.1 - refusing to turn it on!") - (ding) - (sit-for 1) - (setq org-indent-mode nil)) (org-indent-mode ;; mode was turned on. - (org-set-local 'indent-tabs-mode nil) - (org-set-local 'org-indent-initial-marker (copy-marker 1)) + (setq-local indent-tabs-mode nil) + (setq-local org-indent--initial-marker (copy-marker 1)) (when org-indent-mode-turns-off-org-adapt-indentation - (org-set-local 'org-adapt-indentation nil)) + (setq-local org-adapt-indentation nil)) (when org-indent-mode-turns-on-hiding-stars - (org-set-local 'org-hide-leading-stars-before-indent-mode - org-hide-leading-stars) - (org-set-local 'org-hide-leading-stars t)) - (org-add-hook 'filter-buffer-substring-functions + (setq-local org-hide-leading-stars-before-indent-mode + org-hide-leading-stars) + (setq-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 'after-change-functions 'org-indent-refresh-maybe nil 'local) - (org-add-hook 'before-change-functions + (add-hook 'after-change-functions 'org-indent-refresh-maybe nil 'local) + (add-hook 'before-change-functions 'org-indent-notify-modified-headline nil 'local) (and font-lock-mode (org-restart-font-lock)) (org-indent-remove-properties (point-min) (point-max)) @@ -169,11 +160,11 @@ during idle time." (kill-local-variable 'org-adapt-indentation) (setq org-indent-agentized-buffers (delq (current-buffer) org-indent-agentized-buffers)) - (when (markerp org-indent-initial-marker) - (set-marker org-indent-initial-marker nil)) + (when (markerp org-indent--initial-marker) + (set-marker org-indent--initial-marker nil)) (when (boundp 'org-hide-leading-stars-before-indent-mode) - (org-set-local 'org-hide-leading-stars - org-hide-leading-stars-before-indent-mode)) + (setq-local org-hide-leading-stars + org-hide-leading-stars-before-indent-mode)) (remove-hook 'filter-buffer-substring-functions (lambda (fun start end delete) (org-indent-remove-properties-from-string @@ -209,7 +200,7 @@ When no more buffer is being watched, the agent suppress itself." (when org-indent-agent-resume-timer (cancel-timer org-indent-agent-resume-timer)) (setq org-indent-agentized-buffers - (org-remove-if-not #'buffer-live-p org-indent-agentized-buffers)) + (cl-remove-if-not #'buffer-live-p org-indent-agentized-buffers)) (cond ;; Job done: kill agent. ((not org-indent-agentized-buffers) (cancel-timer org-indent-agent-timer)) @@ -233,13 +224,15 @@ a time value." (let ((interruptp ;; Always nil unless interrupted. (catch 'interrupt - (and org-indent-initial-marker - (marker-position org-indent-initial-marker) - (org-indent-add-properties org-indent-initial-marker + (and org-indent--initial-marker + (marker-position org-indent--initial-marker) + (equal (marker-buffer org-indent--initial-marker) + buffer) + (org-indent-add-properties org-indent--initial-marker (point-max) delay) nil)))) - (move-marker org-indent-initial-marker interruptp) + (move-marker org-indent--initial-marker interruptp) ;; Job is complete: un-agentize buffer. (unless interruptp (setq org-indent-agentized-buffers @@ -260,7 +253,7 @@ have `org-warning' face." ?*))) (line (cond - ((and (org-bound-and-true-p org-inlinetask-show-first-star) + ((and (bound-and-true-p org-inlinetask-show-first-star) (eq heading 'inlinetask)) (concat org-indent-inlinetask-first-star (org-add-props (substring stars 1) nil 'face 'org-hide))) @@ -319,7 +312,7 @@ stopped." ;; Headline or inline task. ((looking-at org-outline-regexp) (let* ((nstars (- (match-end 0) (match-beginning 0) 1)) - (type (or (org-looking-at-p limited-re) 'inlinetask))) + (type (or (looking-at-p limited-re) 'inlinetask))) (org-indent-set-line-properties nstars 0 type) ;; At an headline, define new value for LEVEL. (unless (eq type 'inlinetask) (setq level nstars)))) @@ -342,13 +335,14 @@ Flag will be non-nil if command is going to modify or delete an headline." (when org-indent-mode (setq org-indent-modified-headline-flag - (save-excursion - (goto-char beg) - (save-match-data - (or (and (org-at-heading-p) (< beg (match-end 0))) - (re-search-forward org-outline-regexp-bol end t))))))) - -(defun org-indent-refresh-maybe (beg end dummy) + (org-with-wide-buffer + (goto-char beg) + (save-match-data + (or (and (org-at-heading-p) (< beg (match-end 0))) + (re-search-forward + (org-with-limited-levels org-outline-regexp-bol) end t))))))) + +(defun org-indent-refresh-maybe (beg end _) "Refresh indentation properties in an adequate portion of buffer. BEG and END are the positions of the beginning and end of the range of inserted text. DUMMY is an unused argument. @@ -358,19 +352,21 @@ This function is meant to be called by `after-change-functions'." (save-match-data ;; If a headline was modified or inserted, set properties until ;; next headline. - (if (or org-indent-modified-headline-flag - (save-excursion - (goto-char beg) - (beginning-of-line) - (re-search-forward org-outline-regexp-bol end t))) - (let ((end (save-excursion - (goto-char end) - (org-with-limited-levels (outline-next-heading)) - (point)))) - (setq org-indent-modified-headline-flag nil) - (org-indent-add-properties beg end)) - ;; Otherwise, only set properties on modified area. - (org-indent-add-properties beg end))))) + (org-with-wide-buffer + (if (or org-indent-modified-headline-flag + (save-excursion + (goto-char beg) + (beginning-of-line) + (re-search-forward + (org-with-limited-levels org-outline-regexp-bol) end t))) + (let ((end (save-excursion + (goto-char end) + (org-with-limited-levels (outline-next-heading)) + (point)))) + (setq org-indent-modified-headline-flag nil) + (org-indent-add-properties beg end)) + ;; Otherwise, only set properties on modified area. + (org-indent-add-properties beg end)))))) (provide 'org-indent) diff --git a/elpa/org-plus-contrib-20170407/org-index.el b/elpa/org-plus-contrib-20170407/org-index.el new file mode 100644 index 00000000..8742b45d --- /dev/null +++ b/elpa/org-plus-contrib-20170407/org-index.el @@ -0,0 +1,3178 @@ +;;; org-index.el --- A personal adaptive index for org + +;; Copyright (C) 2011-2017 Free Software Foundation, Inc. + +;; Author: Marc Ihm +;; Version: 5.3.0 +;; Keywords: outlines index + +;; This file is not part of GNU Emacs. + +;;; License: + +;; 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, 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 GNU Emacs. If not, see . + +;;; Commentary: + +;; Purpose: +;; +;; Fast search for selected org nodes and things outside of org. +;; +;; org-index creates and updates an index table with keywords; each line +;; either points to a heading in org, references something outside or +;; carries a snippet of text to yank. When searching the index, the set +;; of matching lines is updated with every keystroke; results are sorted +;; by usage count and date, so that frequently used entries appear first +;; in the list of results. +;; +;; References are decorated numbers (e.g. 'R237' or '--455--'); they are +;; well suited to be used outside of org, e.g. in folder names, ticket +;; systems or on printed documents. +;; +;; On first invocation org-index will assist you in creating the index +;; table. +;; +;; To start using your index, invoke subcommands 'add', 'ref' and 'yank' +;; to create entries and 'occur' to find them. +;; +;; +;; Setup: +;; +;; - Place this file in a directory of your load-path, +;; e.g. org-mode/contrib/lisp. +;; +;; - Add these lines to your .emacs: +;; +;; (require 'org-index) +;; +;; - Restart your Emacs to make this effective. +;; +;; - Invoke `org-index'; on first run it will assist in creating your +;; index table. +;; +;; - Optionally invoke `M-x org-customize', group 'Org Index', to tune +;; some settings, e.g. the global prefix key 'C-c i'. +;; +;; +;; Further information: +;; +;; - Watch the screencast at http://2484.de/org-index.html. +;; +;; - See the documentation of `org-index', which can also be read by +;; invoking `org-index' and choosing the command help or '?'. +;; +;; +;; Updates: +;; +;; The latest published version of this file can always be found at: +;; +;; http://orgmode.org/w/?p=org-mode.git;a=blob_plain;f=contrib/lisp/org-index.el;hb=HEAD +;; +;; Development version under: +;; +;; https://github.com/marcIhm/org-index + +;;; Change Log: + +;; [2017-03-26 Su] Version 5.3.0 +;; - Focused can now be on a list of nodes (instead of a single one) +;; - Cleaned up undeclared dependencies +;; +;; [2017-02-18 Sa] Version 5.2.3 +;; - New command 'focus' +;; - Speeded up org-index--parse-table with the stored property "max-ref" +;; - Speeded up org-index--on with search +;; - Added org-index-prepare-when-idle +;; - Fixed compatibility issue with emacs 24 (font-lock-ensure) +;; - Added more customizations +;; - Bugfixes +;; +;; [2016-10-19 We] Version 5.1.4 +;; - Bugfixes +;; +;; [2016-08-26 Fr] Version 5.1.3 +;; - Offering help during query for subcommands +;; - Removed org-index-default-keybindings +;; - Renamed subcommand multi-occur to find-ref +;; - Subcommands add needs no longer be invoked from heading +;; - Many Bugfixes +;; +;; [2015-12-29 Tu] Version 5.0.2 +;; - New commands yank, column and edit +;; - New column tags +;; - All columns are now required +;; - References are now optional +;; - Subcommand enter has been renamed to index +;; - Subcommands kill and edit can be invoked from an occur buffer +;; - Many Bugfixes +;; - Added link to screencast +;; +;; [2015-08-20 Th] Version 4.3.0 +;; - Configuration is done now via standard customize +;; - New sorting strategy 'mixed' +;; - Silenced some compiler warnings +;; +;; [2015-03-18 We] Version 4.2.1 +;; - No garbage in kill-ring +;; - No recentering after add +;; +;; [2015-03-08 Su] Version 4.2.0 +;; - Reference numbers for subcommands can be passed as a prefix argument +;; - New variable org-index-default-keybindings-list with a list of +;; default keybindings for org-index-default-keybindings +;; - Added new column level +;; - removed flags get-category-on-add and get-heading-on-add +;; +;; [2015-02-26 Th] to [2015-03-05 Th] Version 4.0.0 to 4.1.2 +;; - Removed command "leave"; rather go back with org-mark-ring-goto +;; - Renamed column "link" to "id" +;; - Added maintainance options to find duplicate rows, to check ids, +;; update index or remove property org-index-ref from nodes +;; - Shortened versin history +;; +;; [2014-12-08 Mo] to [2015-01-31 Sa] Version 3.0.0 to 3.2.0: +;; - Complete sorting of index only occurs in idle-timer +;; - New command "maintain" with some subcommands +;; - Rewrote command "occur" with overlays in an indirect buffer +;; - Command "add" updates index, if node is already present +;; - New commands "add" and "delete" to easily add and remove +;; the current node to or from your index. +;; - New command "example" to create an example index. +;; - Several new flags that are explained within index node. +;; - Removed commands "reuse", "missing", "put", "goto", +;; "update", "link", "fill", "unhighlight" +;; - New function `org-index-default-keybindings' +;; +;; [2012-12-07 Fr] to [2014-04-26 Sa] Version 2.0.0 to 2.4.3: +;; - New functions org-index-new-line and org-index-get-line +;; offer access to org-index from other lisp programs +;; - Regression tests with ert +;; - Renamed from "org-favtable" to "org-index" +;; - Added an assistant to set up the index table +;; - occur is now incremental, searching as you type +;; - Integrated with org-mark-ring-goto +;; - Added full support for ids +;; - Renamed the package from "org-reftable" to "org-favtable" +;; - Additional columns are required (e.g. "link"). Error messages will +;; guide you +;; - Ask user explicitly, which command to invoke +;; - Renamed the package from "org-refer-by-number" to "org-reftable" +;; +;; [2011-12-10 Sa] to [2012-09-22 Sa] Version Version 1.2.0 to 1.5.0: +;; - New command "sort" to sort a buffer or region by reference number +;; - New commands "highlight" and "unhighlight" to mark references +;; - New command "head" to find a headline with a reference number +;; - New commands occur and multi-occur +;; - Started this Change Log + +;;; Code: + +(require 'org-table) +(require 'org-id) +(require 'cl-lib) +(require 'widget) + +;; Version of this package +(defvar org-index-version "5.3.0" "Version of `org-index', format is major.minor.bugfix, where \"major\" are incompatible changes and \"minor\" are new features.") + +;; customizable options +(defgroup org-index nil + "Options concerning the optional index for org." + :tag "Org Index" + :group 'org) + +(defcustom org-index-id nil + "Id of the Org-mode node, which contains the index table." + :group 'org-index) + +(defcustom org-index-sort-by 'mixed + "Strategy for sorting index table (and whence entries in occur). +Valid values are: + +last-access Sort index by date and time of last access; show + more recent entries first. +count Sort by usage count; more often used entries first. +mixed First, show all index entries, which have been + used today; sort them by last access. Then show + older entries sorted by usage count." + :group 'org-index + :set (lambda (s v) + (set-default s v) + (if (and org-index-id + org-index--buffer + (functionp 'org-index--sort-silent)) + (org-index--sort-silent))) + :initialize 'custom-initialize-default + :type '(choice + (const last-accessed) + (const count) + (const mixed))) + +(defcustom org-index-dispatch-key "i" + "Key to invoke ‘org-index-dispatch’, which is the central entry function for ‘org-index’." + :group 'org-index + :initialize 'custom-initialize-set + :set (lambda (var val) + (set-default var val) + (global-set-key org-index-dispatch-key 'org-index-dispatch)) + :type 'key-sequence) + +(defcustom org-index-idle-delay 68 + "Delay in seconds after which buffer will sorted or fontified when Emacs is idle." + :group 'org-index + :type 'integer) + +(defcustom org-index-prepare-when-idle nil + "Fontify and sort index-table when idle to make first call faster. +You only need this if your index has grown so large, that first +invocation of `org-index' needs a noticable amount of time." + :group 'org-index + :initialize 'custom-initialize-set + :set (lambda (var val) + (set-default var val) + (when val + (setq org-index--align-interactive 200) + (run-with-idle-timer org-index-idle-delay nil 'org-index--idle-prepare))) + :type 'boolean) + +(defcustom org-index-yank-after-add 'ref + "Specifies which column should be yanked after adding a new index row. +Valid values are some columns of index table." + :group 'org-index + :type '(choice + (const ref) + (const category) + (const keywords))) + +(defcustom org-index-copy-heading-to-keywords t + "When adding a new node to index: Copy heading to keywords-column ?" + :group 'org-index + :type '(choice (const :tag "Yes" t) + (const :tag "No" nil))) + +(defcustom org-index-strip-ref-and-date-from-heading t + "When adding a node to index: strip leading ref or timestamps ? + +This can be useful, if you have the habit of adding refs and +dates to the start of your headings; then, if you change your +heading and want to update your index, you do not need to remove +those pieces." + :group 'org-index + :type '(choice (const :tag "Yes" t) + (const :tag "No" nil))) + +(defcustom org-index-edit-on-add '(category keywords) + "List of columns to edit when adding a new row." + :group 'org-index + :type '(repeat (choice + (const category) + (const keywords)))) + +(defcustom org-index-edit-on-yank '(keywords yank) + "List of columns to edit when adding new text to yank." + :group 'org-index + :type '(repeat (choice + (const yank) + (const category) + (const keywords)))) + +(defcustom org-index-edit-on-ref '(category keywords) + "List of columns to edit when adding new ref." + :group 'org-index + :type '(repeat (choice + (const category) + (const keywords)))) + +;; Variables to hold the configuration of the index table +(defvar org-index--maxrefnum nil "Maximum number from reference table, e.g. 153.") +(defvar org-index--head nil "Header before number (e.g. 'R').") +(defvar org-index--tail nil "Tail after number (e.g. '}' or ')'.") +(defvar org-index--numcols nil "Number of columns in index table.") +(defvar org-index--ref-regex nil "Regular expression to match a reference.") +(defvar org-index--ref-format nil "Format, that can print a reference.") +(defvar org-index--columns nil "Columns of index-table.") +(defvar org-index--buffer nil "Buffer of index table.") +(defvar org-index--point nil "Position at start of headline of index table.") +(defvar org-index--below-hline nil "Position of first cell in first line below hline.") +(defvar org-index--saved-positions nil "Saved positions within current buffer and index buffer; filled by ‘org-index--save-positions’.") +(defvar org-index--headings nil "Headlines of index-table as a string.") +(defvar org-index--headings-visible nil "Visible part of headlines of index-table as a string.") +(defvar org-index--ids-focused-nodes nil "Ids of focused node (if any).") +(defvar org-index--id-last-goto-focus nil "Id of last node, that has been jumped to.") + +;; Variables to hold context and state +(defvar org-index--last-fingerprint nil "Fingerprint of last line created.") +(defvar org-index--category-before nil "Category of node before.") +(defvar org-index--active-region nil "Active region, initially. I.e. what has been marked.") +(defvar org-index--below-cursor nil "Word below cursor.") +(defvar org-index--within-index-node nil "True, if we are within node of the index table.") +(defvar org-index--within-occur nil "True, if we are within the occur-buffer.") +(defvar org-index--message-text nil "Text that was issued as an explanation; helpful for regression tests.") +(defvar org-index--occur-help-text nil "Text for help in occur buffer.") +(defvar org-index--occur-help-overlay nil "Overlay for help in occur buffer.") +(defvar org-index--occur-stack nil "Stack with overlays for hiding lines.") +(defvar org-index--occur-tail-overlay nil "Overlay to cover invisible lines.") +(defvar org-index--occur-lines-collected 0 "Number of lines collected in occur buffer; helpful for tests.") +(defvar org-index--last-sort-assumed nil "Last column, the index has been sorted after (best guess).") +(defvar org-index--sort-timer nil "Timer to sort index in correct order.") +(defvar org-index--aligned 0 "For this Emacs session: remember number of table lines aligned.") +(defvar org-index--align-interactive most-positive-fixnum "Number of rows to align in ‘org-index--parse-table’.") +(defvar org-index--edit-widgets nil "List of widgets used to edit.") +(defvar org-index--context-index nil "Position and line used for index in edit buffer.") +(defvar org-index--context-occur nil "Position and line used for occur in edit buffer.") +(defvar org-index--context-node nil "Buffer and position for node in edit buffer.") +(defvar org-index--short-help-buffer-name "*org-index commands*" "Name of buffer to display short help.") +(defvar org-index--display-short-help nil "True, if short help should be displayed.") +(defvar org-index--short-help-displayed nil "True, if short help message has been displayed.") +(defvar org-index--minibuffer-saved-key nil "Temporarily save entry of minibuffer keymap.") + +;; static information for this program package +(defconst org-index--commands '(occur add kill head ping index ref yank column edit help short-help focus set-focus example sort find-ref highlight maintain) "List of commands available.") +(defconst org-index--valid-headings '(ref id created last-accessed count keywords category level yank tags) "All valid headings.") +(defconst org-index--occur-buffer-name "*org-index-occur*" "Name of occur buffer.") +(defconst org-index--edit-buffer-name "*org-index-edit*" "Name of edit buffer.") +(defvar org-index--short-help-text nil "Cache for result of `org-index--get-short-help-text.") +(defvar org-index--shortcut-chars nil "Cache for result of `org-index--get-shortcut-chars.") + + +(defmacro org-index--on (column value &rest body) + "Execute the forms in BODY with point on index line whose COLUMN is VALUE. +The value returned is the value of the last form in BODY or nil, +if VALUE cannot be found." + (declare (indent 2) (debug t)) + (let ((pointvar (make-symbol "point")) ; avoid clash with same-named variables in body + (foundvar (make-symbol "found")) + (retvar (make-symbol "ret"))) + `(save-current-buffer + (let ((,pointvar (point)) + ,foundvar + ,retvar) + + (set-buffer org-index--buffer) + + (setq ,foundvar (org-index--go ,column ,value)) + (when ,foundvar + (setq ,retvar (progn ,@body))) + + (goto-char ,pointvar) + + ,retvar)))) + + +(defun org-index (&optional command search-ref arg) + "Fast search-index for selected org nodes and things outside of org. + +This function creates and updates an index table with keywords; +each line either points to a heading in org, references something +outside or carries a snippet of text to yank. The index table is +searched for keywords by means of an incremental occur; results +are sorted by usage count and date, so that frequently used +entries appear first. + +References are decorated numbers (e.g. 'R237' or '--455--'); they are +well suited to be used outside of org, e.g. in folder names, ticket +systems or on printed documents. + +On first invocation this function will help to create a dedicated node +for its index table. + +To start building up your index, use subcommands 'add', 'ref' and +'yank' to create entries and use 'occur' to find them. + +This is version 5.3.0 of org-index.el. + + +The function `org-index' is the only interactive function of this +package and its main entry point; it will present you with a list +of subcommands to choose from: + +\(Note the one-letter shortcuts, e.g. [o]; used like `\\[org-index-dispatch] o'.) + + occur: [o] Incrementally show matching lines from index. + Result is updated after every keystroke. You may enter a + list of words seperated by space or comma (`,'), to select + lines that contain all of the given words. + + add: [a] Add the current node to index. + So that (e.g.) it can be found through the subcommand + 'occur'. Update index, if node is already present. + + kill: [k] Kill (delete) the current node from index. + Can be invoked from index, from occur or from a headline. + + head: [h] Search for heading, by ref or from index line. + If invoked from within index table, go to associated + node (if any), otherwise ask for ref to search. + + index: [i] Enter index table and maybe go to a specific reference. + Use `org-mark-ring-goto' (\\[org-mark-ring-goto]) to go back. + + ping: [p] Echo line from index table for current node. + If current node is not in index, than search among its + parents. + + ref: [r] Create a new index line with a reference. + This line will not be associated with a node. + + yank: [y] Store a new string, that can be yanked from occur. + The index line will not be associated with a node. + + column: [c] From within index table: read char and jump to column. + Shortcut for column movement; stays within one index line. + + edit: [e] Present current line in edit buffer. + Can be invoked from index, from occur or from a headline. + + help: Show complete help text of `org-index'. + + focus: [f] Return to first focused node; repeat to see them all. + With prefix: reverse order. You Need to set-focus before. + The focused nodes are kept in a short list and can be found + by hitting a single key; they need not be part of the index + though. This can be useful, if you work in one or few nodes, + but make frequent excursions to others, which are part of the + index. + + set-focus: [F] Set focus to current node, with prefix: append. + To truncate the list of focused nodes, just focus on a single + node; to remove current node from focus list supply a double + prefix. + + short-help: [?] Show one-line description of each subcommand. + I.e. show this list but only first sentence each. + + example: Create an example index, that will not be saved. + May serve as an example. + + sort: Sort lines in index, in region or buffer. + Region or buffer can be sorted by contained reference; Index + by count, reference or last access. + + find-ref: Search for given reference in all org-buffers. + A wrapper to employ Emacs standard `multi-occur' function; + asks for reference. + + highlight: Highlight or unhighlight all references. + Operates on active region or whole buffer. Call with prefix + argument (`C-u') to remove highlights. + + maintain: Index maintainance. + Offers some choices to check, update or fix your index. + +If you invoke `org-index' for the first time, an assistant will be +invoked, that helps you to create your own index. + +Invoke `org-customize' to tweak the behaviour of `org-index'. + +This includes the global key `org-index-dispatch-key' to invoke +the most important subcommands with one additional key. + +A numeric prefix argument is used as a reference number for +commands, that need one (e.g. 'head') or to modify their +behaviour (e.g. 'focus'). + +Use from elisp: Optional argument COMMAND is a symbol naming the +command to execute. SEARCH-REF specifies a reference to search +for, if needed. ARG allows passing in a prefix argument as in +interactive calls." + + (interactive "i\ni\nP") + + (let (search-id ; id to search for + search-fingerprint ; fingerprint to search for + sort-what ; sort what ? + kill-new-text ; text that will be appended to kill ring + message-text) ; text that will be issued as an explanation + + (catch 'new-index + + ;; + ;; Initialize and parse + ;; + + ;; creates index table, if necessary + (org-index--verify-id) + + ;; Get configuration of index table + (org-index--parse-table org-index--align-interactive t) + + ;; store context information + (org-index--retrieve-context) + + + ;; + ;; Arrange for proper sorting of index + ;; + + ;; lets assume, that it has been sorted this way (we try hard to make sure) + (unless org-index--last-sort-assumed (setq org-index--last-sort-assumed org-index-sort-by)) + ;; rearrange for index beeing sorted into default sort order after 300 secs of idle time + (unless org-index--sort-timer + (setq org-index--sort-timer + (run-with-idle-timer org-index-idle-delay t 'org-index--sort-silent))) + + + ;; + ;; Find out, what we are supposed to do + ;; + + ;; Check or read command + (if (and command (not (eq command 'short-help))) + (unless (memq command org-index--commands) + (error "Unknown command '%s' passed as argument, valid choices are any of these symbols: %s" + command (mapconcat 'symbol-name org-index--commands ","))) + + ;; read command; if requested display help in read-loop + (setq org-index--display-short-help (eq command 'short-help)) + (setq command (org-index--read-command)) + (setq org-index--display-short-help nil)) + + ;; + ;; Get search string, if required; process possible sources one after + ;; another (lisp argument, prefix argument, user input). + ;; + + ;; Try prefix, if no lisp argument given + (if (and (not search-ref) + (numberp arg)) + (setq search-ref (format "%s%d%s" org-index--head arg org-index--tail))) + + ;; These actions really need a search string and may even prompt for it + (when (memq command '(index head find-ref)) + + ;; search from surrounding text ? + (unless search-ref + (if org-index--within-index-node + + (if (org-at-table-p) + (setq search-ref (org-index--get-or-set-field 'ref))) + + (if (and org-index--below-cursor + (string-match (concat "\\(" org-index--ref-regex "\\)") + org-index--below-cursor)) + (setq search-ref (match-string 1 org-index--below-cursor))))) + + ;; If we still do not have a search string, ask user explicitly + (unless search-ref + (if (eq command 'index) + (let ((r (org-index--read-search-for-index))) + (setq search-ref (cl-first r)) + (setq search-id (cl-second r)) + (setq search-fingerprint (cl-third r))) + (unless (and (eq command 'head) + org-index--within-index-node + (org-at-table-p)) + (setq search-ref (read-from-minibuffer "Search reference number: "))))) + + ;; Clean up search string + (when search-ref + (setq search-ref (org-trim search-ref)) + (if (string-match "^[0-9]+$" search-ref) + (setq search-ref (concat org-index--head search-ref org-index--tail))) + (if (string= search-ref "") (setq search-ref nil))) + + (if (and (not search-ref) + (not (eq command 'index)) + (not (and (eq command 'head) + org-index--within-index-node + (org-at-table-p)))) + (error "Command %s needs a reference number" command))) + + + ;; + ;; Command sort needs to know in advance, what to sort for + ;; + + (when (eq command 'sort) + (setq sort-what (intern (org-completing-read "You may sort:\n - index : your index table by various columns\n - region : the active region by contained reference\n - buffer : the whole current buffer\nPlease choose what to sort: " (list "index" "region" "buffer") nil t)))) + + + ;; + ;; Enter table + ;; + + ;; Arrange for beeing able to return + (when (and (memq command '(occur head index example sort maintain focus)) + (not (string= (buffer-name) org-index--occur-buffer-name))) + (org-mark-ring-push)) + + ;; These commands will leave user in index table after they are finished + (when (or (memq command '(index maintain)) + (and (eq command 'sort) + (eq sort-what 'index))) + + (pop-to-buffer-same-window org-index--buffer) + (goto-char org-index--point) + (org-index--unfold-buffer)) + + + ;; + ;; Actually do, what is requested + ;; + + (cond + + ((eq command 'help) + + ;; bring up help-buffer for this function + (describe-function 'org-index)) + + + ((eq command 'short-help) + + (org-index--display-short-help)) + + + ((eq command 'find-ref) + + ;; Construct list of all org-buffers + (let (org-buffers) + (dolist (buff (buffer-list)) + (set-buffer buff) + (if (string= major-mode "org-mode") + (setq org-buffers (cons buff org-buffers)))) + + ;; Do multi-occur + (multi-occur org-buffers (org-index--make-guarded-search search-ref)) + + ;; Present results + (if (get-buffer "*Occur*") + (progn + (setq message-text (format "Found '%s'" search-ref)) + (other-window 1) + (toggle-truncate-lines 1)) + (setq message-text (format "Did not find '%s'" search-ref))))) + + + ((eq command 'add) + + (let ((r (org-index--do-add-or-update (if (equal arg '(4)) t nil) + (if (numberp arg) arg nil)))) + (setq message-text (car r)) + (setq kill-new-text (cdr r)))) + + + ((eq command 'kill) + (setq message-text (org-index--do-kill))) + + + ((eq command 'head) + + (if (and org-index--within-index-node + (org-at-table-p)) + (setq search-id (org-index--get-or-set-field 'id))) + + (if (and (not search-id) search-ref) + (setq search-id (org-index--id-from-ref search-ref))) + + (setq message-text + (if search-id + (org-index--find-id search-id) + "Current line has no id"))) + + + ((eq command 'index) + + (goto-char org-index--below-hline) + + (setq message-text + + (if search-ref + (if (org-index--go 'ref search-ref) + (progn + (org-index--update-current-line) + (org-table-goto-column (org-index--column-num 'ref)) + (format "Found index line '%s'" search-ref)) + (format "Did not find index line with reference '%s'" search-ref)) + + (if search-id + (if (org-index--go 'id search-id) + (progn + (org-index--update-current-line) + (org-table-goto-column (org-index--column-num 'ref)) + (format "Found index line '%s'" (org-index--get-or-set-field 'ref))) + (format "Did not find index line with id '%s'" search-id)) + + (if search-fingerprint + (if (org-index--go 'fingerprint org-index--last-fingerprint) + (progn + (org-index--update-current-line) + (beginning-of-line) + (format "Found latest index line")) + (format "Did not find index line")) + + ;; simply go into table + "At index table")))) + + (recenter)) + + + ((eq command 'ping) + + (let ((moved-up 0) id info reached-top done) + + (unless (string= major-mode "org-mode") (error "No node at point")) + ;; take id from current node or reference + (setq id (if search-ref + (org-index--id-from-ref search-ref) + (org-id-get))) + + ;; move up until we find a node in index + (save-excursion + (outline-back-to-heading) + (while (not done) + (if id + (setq info (org-index--on 'id id + (mapcar (lambda (x) (org-index--get-or-set-field x)) + (list 'keywords 'count 'created 'last-accessed 'category 'ref))))) + + (setq reached-top (= (org-outline-level) 1)) + + (if (or info reached-top) + (setq done t) + (outline-up-heading 1 t) + (cl-incf moved-up)) + + (setq id (org-id-get)))) + + (if info + (progn + (setq message-text + (apply 'format + (append (list "'%s'%s has been accessed %s times between %s and %s; category is '%s', reference is '%s'" + (pop info) + (if (> moved-up 0) (format " (parent node, %d level up)" moved-up) "")) + info))) + (setq kill-new-text (car (last info)))) + (setq message-text "Neither this node nor any of its parents is part of index")))) + + + ((eq command 'occur) + + (set-buffer org-index--buffer) + (org-index--do-occur)) + + + ((eq command 'ref) + + (let (args newref) + + (setq args (org-index--collect-values-from-user org-index-edit-on-ref)) + (setq newref (org-index--get-save-maxref)) + (setq args (plist-put args 'ref newref)) + (apply 'org-index--do-new-line args) + + (setq kill-new-text newref) + + (setq message-text (format "Added new row with ref '%s'" newref)))) + + + ((eq command 'yank) + + (let (args) + + (setq args (org-index--collect-values-from-user org-index-edit-on-yank)) + (if (plist-get args 'yank) + (plist-put args 'yank (replace-regexp-in-string "|" "\\vert" (plist-get args 'yank) nil 'literal))) + (setq args (plist-put args 'category "yank")) + (apply 'org-index--do-new-line args) + + (setq message-text "Added new row with text to yank"))) + + + ((eq command 'column) + + (if (and org-index--within-index-node + (org-at-table-p)) + (let (char col num) + (setq char (read-char "Please specify, which column to go to (r=ref, k=keywords, c=category, y=yank): ")) + (unless (memq char (list ?r ?k ?c ?y)) + (error (format "Invalid char '%c', cannot goto this column" char))) + (setq col (cdr (assoc char '((?r . ref) (?k . keywords) (?c . category) (?y . yank))))) + (setq num (org-index--column-num col)) + (if num + (progn + (org-table-goto-column num) + (setq message-text (format "At column %s" (symbol-name col)))) + + (error (format "Column '%s' is not present" col)))) + (error "Need to be in index table to go to a specific column"))) + + + ((eq command 'edit) + + (setq message-text (org-index--do-edit))) + + + ((eq command 'sort) + + (let ((sorts (list "count" "last-accessed" "mixed" "id" "ref")) + sort groups-and-counts) + + (cond + ((eq sort-what 'index) + (setq sort + (intern + (completing-read + "Please choose column to sort index table: " + (cl-copy-list sorts) + nil t nil nil (symbol-name org-index-sort-by)))) + + (org-index--do-sort-index sort) + (org-table-goto-column (org-index--column-num (if (eq sort 'mixed) 'last-access sort))) + ;; When saving index, it should again be sorted correctly + (with-current-buffer org-index--buffer + (add-hook 'before-save-hook 'org-index--sort-silent t)) + + (setq message-text + (format + (concat "Your index has been sorted temporarily by %s and will be sorted again by %s after %d seconds of idle time" + (if groups-and-counts + "; %d groups with equal %s and a total of %d lines have been found" + "")) + (symbol-name sort) + org-index-sort-by + org-index-idle-delay + (cl-second groups-and-counts) + (symbol-name sort) + (cl-third groups-and-counts)))) + + ((memq sort-what '(region buffer)) + (org-index--do-sort-lines sort-what) + (setq message-text (format "Sorted %s by contained references" sort-what)))))) + + + ((eq command 'highlight) + + (let ((where "buffer")) + (save-excursion + (save-restriction + (when (and transient-mark-mode + mark-active) + (narrow-to-region (region-beginning) (region-end)) + (setq where "region")) + + (if arg + (progn + (unhighlight-regexp org-index--ref-regex) + (setq message-text (format "Removed highlights for references in %s" where))) + (highlight-regexp org-index--ref-regex 'isearch) + (setq message-text (format "Highlighted references in %s" where))))))) + + + ((eq command 'focus) + (setq message-text (org-index--goto-focus arg))) + + + ((eq command 'set-focus) + (setq message-text (org-index--set-focus arg))) + + + ((eq command 'maintain) + (setq message-text (org-index--do-maintain))) + + + ((eq command 'example) + + (if (y-or-n-p "This assistant will help you to create a temporary index with detailed comments.\nDo you want to proceed ? ") + (org-index--create-index t))) + + + ((not command) (setq message-text "No command given")) + + + (t (error "Unknown subcommand '%s'" command))) + + + ;; tell, what we have done and what can be yanked + (if kill-new-text (setq kill-new-text + (substring-no-properties kill-new-text))) + (if (string= kill-new-text "") (setq kill-new-text nil)) + (let ((m (concat + message-text + (if (and message-text kill-new-text) + " and r" + (if kill-new-text "R" "")) + (if kill-new-text (format "eady to yank '%s'." kill-new-text) (if message-text "." ""))))) + (unless (string= m "") + (message m) + (setq org-index--message-text m))) + (if kill-new-text (kill-new kill-new-text))))) + + +(defun org-index-dispatch (&optional arg) + "Read additional chars and call subcommands of `org-index'. +Can be bound in global keyboard map as central entry point. +Optional argument ARG is passed on." + (interactive "P") + (let (char command) + (if (sit-for 1) + (message "org-index (? for detailed prompt) -")) + (setq char (key-description (read-key-sequence nil))) + (if (string= char "C-g") (keyboard-quit)) + (if (string= char "SPC") (setq char "?")) + (setq command (cdr (assoc char (org-index--get-shortcut-chars)))) + (unless command + (message "No subcommand for '%s'; switching to detailed prompt" char) + (sit-for 1) + (setq command 'short-help)) + (org-index command nil arg))) + + +(defun org-index-new-line (&rest keys-values) + "Create a new line within the index table, returning its reference. + +The function takes a varying number of argument pairs; each pair +is a symbol for an existing column heading followed by its value. +The return value is the new reference. + +Example: + + (message \"Created reference %s\" + (org-index-new-line 'keywords \"foo bar\" 'category \"baz\")) + +Optional argument KEYS-VALUES specifies content of new line." + + (let ((ref (plist-get keys-values 'ref))) + (org-index--verify-id) + (org-index--parse-table) + (if (not (memq ref '(t nil))) + (error "Column 'ref' accepts only 't' or 'nil'")) + (when ref + (setq ref (org-index--get-save-maxref)) + (setq keys-values (plist-put keys-values 'ref ref))) + + (apply 'org-index--do-new-line keys-values) + ref)) + + +(defun org-index--read-command (&optional with-short-help) + "Read subcommand for ‘org-index’ from minibuffer. +Optional argument WITH-SHORT-HELP displays help screen upfront." + (let (minibuffer-scroll-window + minibuffer-setup-fun + command) + (setq org-index--short-help-displayed nil) + (add-hook 'minibuffer-setup-hook 'org-index--minibuffer-setup-function) + (add-hook 'minibuffer-exit-hook 'org-index--minibuffer-exit-function) + (unwind-protect + (setq command + (intern + (completing-read + (concat + "Please choose" + (if org-index--display-short-help "" " (? for short help)") + ": ") + (mapcar 'symbol-name org-index--commands) nil t))) + (remove-hook 'minibuffer-setup-hook 'org-index--minibuffer-setup-function) + (remove-hook 'minibuffer-exit-hook 'org-index--minibuffer-exit-function) + (when org-index--short-help-displayed + (quit-windows-on org-index--short-help-buffer-name))) + command)) + + +(defun org-index--minibuffer-setup-function () + "Prepare minibuffer for `org-index--read-command'." + (setq org-index--minibuffer-saved-key (local-key-binding (kbd "?"))) + (local-set-key (kbd "?") 'org-index--display-short-help) + (if org-index--display-short-help (org-index--display-short-help))) + + +(defun org-index--minibuffer-exit-function () + "Restore minibuffer after `org-index--read-command'." + (local-set-key (kbd "?") org-index--minibuffer-saved-key) + (setq org-index--minibuffer-saved-key nil)) + + +(defun org-index--display-short-help () + "Helper function to show help in minibuffer." + (interactive) + + (with-temp-buffer-window + org-index--short-help-buffer-name nil nil + (setq org-index--short-help-displayed t) + (princ "Short help; all subcommands of `org-index', shortcuts in []\n") + (princ (org-index--get-short-help-text))) + (with-current-buffer org-index--short-help-buffer-name + (let ((inhibit-read-only t) + height-before height-after win) + (setq win (get-buffer-window)) + (setq height-before (window-height win)) + (shrink-window-if-larger-than-buffer win) + (setq height-after (window-height win)) + (goto-char (point-min)) + (end-of-line) + (insert + (if (> height-before height-after) + "." + (concat ", " + (substitute-command-keys "\\[scroll-other-window]") + " to scroll:"))) + (goto-char (point-min))))) + + +(defun org-index--get-short-help-text () + "Extract text for short help message from long help." + (or org-index--short-help-text + (with-temp-buffer + (insert (documentation 'org-index)) + (goto-char (point-min)) + (search-forward (concat " " (symbol-name (cl-first org-index--commands)) ": ")) + (forward-line 0) + (kill-region (point-min) (point)) + (search-forward (concat " " (symbol-name (car (last org-index--commands))) ": ")) + (forward-line 1) + (kill-region (point) (point-max)) + (keep-lines "^ [-a-z]+:" (point-min) (point-max)) + (align-regexp (point-min) (point-max) "\\(\\s-*\\):") + (goto-char (point-min)) + (while (re-search-forward "\\. *$" nil t) + (replace-match "" nil nil)) + (goto-char (point-min)) + (re-search-forward "short-help") + (end-of-line) + (insert " (this text)") + (goto-char (point-min)) + (unless (= (line-number-at-pos (point-max)) (1+ (length org-index--commands))) + (error "Internal error, unable to properly extract one-line descriptions of subcommands")) + (setq org-index--short-help-text (buffer-string))))) + + +(defun org-index--get-shortcut-chars () + "Collect shortcut chars from short help message." + (or org-index--shortcut-chars + (with-temp-buffer + (insert (org-index--get-short-help-text)) + (goto-char (point-min)) + (while (< (point) (point-max)) + (when (looking-at "^ \\([-a-z]+\\)[ \t]+: +\\[\\([a-z?]\\)\\] ") + (setq org-index--shortcut-chars + (cons (cons (match-string 2) (intern (match-string 1))) + org-index--shortcut-chars))) + (forward-line 1)) + (unless (> (length org-index--shortcut-chars) 0) + (error "Internal error, did not find shortcut chars")) + org-index--shortcut-chars))) + + +(defun org-index--goto-focus (arg) + "Goto focus node, one after the other; with ARG: reverse." + (if org-index--ids-focused-nodes + (let ((maybe-reverse (lambda (&rest x) (if (equal arg '(4)) (reverse x) x))) + last-id next-ids marker) + (setq last-id (or org-index--id-last-goto-focus + (last org-index--ids-focused-nodes))) + (setq next-id + (car (or (cdr-safe (member last-id + (apply maybe-reverse + (append org-index--ids-focused-nodes + org-index--ids-focused-nodes)))) + (apply maybe-reverse org-index--ids-focused-nodes)))) + (or (setq marker (org-id-find next-id 'marker)) + (error "Could not find focus-node with id %s" next-id)) + (setq org-index--id-last-goto-focus next-id) + (pop-to-buffer-same-window (marker-buffer marker)) + (goto-char (marker-position marker)) + (org-index--unfold-buffer) + (move-marker marker nil) + (if (cdr org-index--ids-focused-nodes) + (format "Jumped to %s focus-node (out of %d)" + (if (equal arg '(4)) "previous" "next") + (length org-index--ids-focused-nodes)) + "Jumped to single focus-node")) + "No nodes in focus, use set-focus")) + + +(defun org-index--set-focus (arg) + "Set focus node, with prefix ARG, append to list, with double prefix: delete." + (let (id text) + + (setq text + (cond + + ((not arg) + (setq id (org-id-get-create)) + (setq org-index--ids-focused-nodes (list id)) + "Focus has been set on current node (1 node in focus)") + + ((equal arg '(4)) + (setq id (org-id-get-create)) + (unless (member id org-index--ids-focused-nodes) + (setq org-index--ids-focused-nodes (cons id org-index--ids-focused-nodes))) + (setq org-index--id-last-goto-focus id) + "Current node has been appended to list of focused nodes (%d node%s in focus)") + + ((equal arg '(16)) + (setq id (org-id-get)) + (if (and id (member id org-index--ids-focused-nodes)) + (progn + (setq org-index--id-last-goto-focus + (or (car-safe (cdr-safe (member id (reverse (append org-index--ids-focused-nodes + org-index--ids-focused-nodes))))) + org-index--id-last-goto-focus)) + (setq org-index--ids-focused-nodes (delete id org-index--ids-focused-nodes)) + "Current node has been removed from list of focused nodes (%d node%s in focus)") + "Current node has not been in list of focused nodes (%d node%s in focus)")))) + + (with-current-buffer org-index--buffer + (org-entry-put org-index--point "ids-focused-nodes" (string-join org-index--ids-focused-nodes " "))) + + (format text (length org-index--ids-focused-nodes) (if (cdr org-index--ids-focused-nodes) "s" "")))) + + +(defun org-index--do-edit () + "Perform command edit." + (let ((maxlen 0) cols-vals buffer-keymap field-keymap keywords-pos val) + + (setq org-index--context-node nil) + (setq org-index--context-occur nil) + + ;; change to index, if whithin occur + (if org-index--within-occur + (let ((pos (get-text-property (point) 'org-index-lbp))) + (org-index--occur-test-stale pos) + (setq org-index--context-occur (cons (point) (org-index--line-in-canonical-form))) + (set-buffer org-index--buffer) + (goto-char pos)) + + ;; change to index, if still not within + (if (not org-index--within-index-node) + (let ((id (org-id-get))) + (setq org-index--context-node (cons (current-buffer) (point))) + (set-buffer org-index--buffer) + (unless (and id (org-index--go 'id id)) + (setq org-index--context-node nil) + (error "This node is not in index"))))) + + ;; retrieve current content of index line + (dolist (col (mapcar 'car (reverse org-index--columns))) + (if (> (length (symbol-name col)) maxlen) + (setq maxlen (length (symbol-name col)))) + (setq val (org-index--get-or-set-field col)) + (if (and val (eq col 'yank)) (setq val (replace-regexp-in-string (regexp-quote "\\vert") "|" val nil 'literal))) + (setq cols-vals (cons (cons col val) + cols-vals))) + + ;; we need two different keymaps + (setq buffer-keymap (make-sparse-keymap)) + (set-keymap-parent buffer-keymap widget-keymap) + (define-key buffer-keymap (kbd "C-c C-c") 'org-index--edit-accept) + (define-key buffer-keymap (kbd "C-c C-k") 'org-index--edit-abort) + + (setq field-keymap (make-sparse-keymap)) + (set-keymap-parent field-keymap widget-field-keymap) + (define-key field-keymap (kbd "C-c C-c") 'org-index--edit-accept) + (define-key field-keymap (kbd "C-c C-k") 'org-index--edit-abort) + + ;; prepare buffer + (setq org-index--context-index (cons (point) (org-index--line-in-canonical-form))) + (if (get-buffer org-index--edit-buffer-name) (kill-buffer org-index--edit-buffer-name)) + (switch-to-buffer (get-buffer-create org-index--edit-buffer-name)) + + ;; create and fill widgets + (setq org-index--edit-widgets nil) + (widget-insert "Edit this line from index; type C-c C-c when done, C-c C-k to abort.\n\n") + (dolist (col-val cols-vals) + (if (eq (car col-val) 'keywords) (setq keywords-pos (point))) + (setq org-index--edit-widgets (cons + (cons (car col-val) + (widget-create 'editable-field + :format (format (format "%%%ds: %%%%v" maxlen) (symbol-name (car col-val))) + :keymap field-keymap + (or (cdr col-val) ""))) + org-index--edit-widgets))) + + (widget-setup) + (goto-char keywords-pos) + (beginning-of-line) + (forward-char (+ maxlen 2)) + (use-local-map buffer-keymap) + "Editing a single line from index")) + + +(defun org-index--edit-accept () + "Function to accept editing in Edit buffer." + (interactive) + + (let ((obuf (get-buffer org-index--occur-buffer-name)) + val line) + + ;; Time might have passed + (org-index--refresh-parse-table) + + (with-current-buffer org-index--buffer + + ;; check, if buffer has become stale + (save-excursion + (goto-char (car org-index--context-index)) + (unless (string= (cdr org-index--context-index) + (org-index--line-in-canonical-form)) + (switch-to-buffer org-index--edit-buffer-name) + (error "Index table has changed: Cannot find line, that this buffer is editing"))) + + (pop-to-buffer-same-window org-index--buffer) + (goto-char (car org-index--context-index)) + + ;; write back line to index + (dolist (col-widget org-index--edit-widgets) + (setq val (widget-value (cdr col-widget))) + (if (eq (car col-widget) 'yank) (setq val (replace-regexp-in-string "|" (regexp-quote "\\vert") val))) + (org-index--get-or-set-field (car col-widget) val)) + + (setq line (org-index--align-and-fontify-current-line)) + (beginning-of-line)) + + ;; write line to occur if appropriate + (if org-index--context-occur + (if obuf + (if (string= (cdr org-index--context-index) + (cdr org-index--context-occur)) + (progn + (pop-to-buffer-same-window obuf) + (goto-char (car org-index--context-occur)) + (beginning-of-line) + (let ((inhibit-read-only t)) + (delete-region (line-beginning-position) (line-end-position)) + (insert line) + (put-text-property (line-beginning-position) (line-end-position) + 'org-index-lbp (car org-index--context-index)))) + (error "Occur buffer and index buffer do not match any longer")) + (message "Occur buffer has gone, cannot switch back.")) + (setq org-index--context-occur nil)) + + ;; return to node, if invoked from there + (when org-index--context-node + (pop-to-buffer-same-window (car org-index--context-node)) + (goto-char (cdr org-index--context-node))) + + ;; clean up + (kill-buffer org-index--edit-buffer-name) + (setq org-index--context-index nil) + (setq org-index--edit-widgets nil) + (beginning-of-line) + (message "Index line has been edited."))) + + +(defun org-index--edit-abort () + "Function to abort editing in Edit buffer." + (interactive) + (kill-buffer org-index--edit-buffer-name) + (setq org-index--context-index nil) + (setq org-index--edit-widgets nil) + (beginning-of-line) + (message "Edit aborted.")) + + +(defun org-index--do-new-line (&rest keys-values) + "Do the work for `org-index-new-line'. +Optional argument KEYS-VALUES specifies content of new line." + + (org-index--retrieve-context) + (with-current-buffer org-index--buffer + (goto-char org-index--point) + + ;; check arguments early; they might come from userland + (let ((kvs keys-values) + k v) + (while kvs + (setq k (car kvs)) + (setq v (cadr kvs)) + (if (or (not (symbolp k)) + (and (symbolp v) (not (eq v t)) (not (eq v nil)))) + (error "Arguments must be alternation of key and value")) + (unless (org-index--column-num k) + (error "Unknown column or column not defined in table: '%s'" (symbol-name k))) + (setq kvs (cddr kvs)))) + + (let (yank) + ;; create new line + (org-index--create-new-line) + + ;; fill columns + (let ((kvs keys-values) + k v) + (while kvs + (setq k (car kvs)) + (setq v (cadr kvs)) + (org-table-goto-column (org-index--column-num k)) + (insert (org-trim (or v ""))) + (setq kvs (cddr kvs)))) + + ;; align and fontify line + (org-index--promote-current-line) + (org-index--align-and-fontify-current-line) + + ;; remember fingerprint to be able to return + (setq org-index--last-fingerprint (org-index--get-or-set-field 'fingerprint)) + + ;; get column to yank + (setq yank (org-index--get-or-set-field org-index-yank-after-add)) + + yank))) + + +(defun org-index-get-line (column value) + "Retrieve an existing line within the index table by ref or id. +Return its contents as a property list. + +The function `plist-get' may be used to retrieve specific elements +from the result. + +Example: + + (plist-get (org-index-get-line 'ref \"R12\") 'count) + +retrieves the value of the count-column for reference number 12. + +Argument COLUMN is a symbol, either ref or id, +argument VALUE specifies the value to search for." + ;; check arguments + (unless (memq column '(ref id keywords 'yank)) + (error "Argument column can only be 'ref', 'id', 'keywords' or 'yank'")) + + (unless value + (error "Need a value to search for")) + + (org-index--verify-id) + (org-index--parse-table) + + (org-index--get-line column value)) + + +(defun org-index--get-line (column value) + "Find a line by ID, return its contents. +Argument COLUMN and VALUE specify line to get." + (let (content) + (org-index--on + column value + (mapc (lambda (x) + (if (and (numberp (cdr x)) + (> (cdr x) 0)) + (setq content (cons (car x) (cons (or (org-index--get-or-set-field (car x)) "") content))))) + (reverse org-index--columns))) + content)) + + +(defun org-index--ref-from-id (id) + "Get reference from line ID." + (org-index--on 'id id (org-index--get-or-set-field 'ref))) + + +(defun org-index--id-from-ref (ref) + "Get id from line REF." + (org-index--on 'ref ref (org-index--get-or-set-field 'id))) + + +(defun org-index--get-fingerprint () + "Get fingerprint of current line." + (replace-regexp-in-string + "\\s " "" + (mapconcat (lambda (x) (org-index--get-or-set-field x)) '(id ref yank keywords created) ""))) + + +(defun org-index--read-search-for-index () + "Special input routine for command index." + + ;; Accept single char commands or switch to reading a sequence of digits + (let (char prompt search-ref search-id search-fingerprint) + + ;; start with short prompt but give more help on next iteration + (setq prompt "Please specify, where to go in index (0-9,.,space,backspace,return or ? for short help) - ") + + ;; read one character + (while (not (memq char (append (number-sequence ?0 ?9) (list ?\d ?\b ?\r ?\j ?\s ?.)))) + (setq char (read-char prompt)) + (setq prompt "Go to specific position in index table. Digits specify a reference number, goes to top of index, or to last line created and or `.' to index line of current node. Please choose - ")) + + (if (memq char (number-sequence ?0 ?9)) + ;; read rest of digits + (setq search-ref (read-from-minibuffer "Search reference number: " (char-to-string char)))) + ;; decode single chars + (if (memq char '(?\r ?\n ?.)) (setq search-id (org-id-get))) + (if (memq char '(?\d ?\b)) (setq search-fingerprint org-index--last-fingerprint)) + + (list search-ref search-id search-fingerprint))) + + +(defun org-index--verify-id () + "Check, that we have a valid id." + + ;; Check id + (unless org-index-id + (let ((answer (org-completing-read "Cannot find an index (org-index-id is not set). You may:\n - read-help : to learn more about org-index\n - create-index : invoke an assistant to create an initial index\nPlease choose: " (list "read-help" "create-index") nil t nil nil "read-help"))) + (if (string= answer "create-index") + (org-index--create-missing-index "Variable org-index-id is not set, so probably no index table has been created yet.") + (describe-function 'org-index) + (throw 'new-index nil)))) + + ;; Find node + (let (marker) + (setq marker (org-id-find org-index-id 'marker)) + (unless marker (org-index--create-missing-index "Cannot find the node with id \"%s\" (as specified by variable org-index-id)." org-index-id)) + ; Try again with new node + (setq marker (org-id-find org-index-id 'marker)) + (unless marker (error "Could not create node")) + (setq org-index--buffer (marker-buffer marker) + org-index--point (marker-position marker)) + (move-marker marker nil))) + + +(defun org-index--retrieve-context () + "Collect context information before starting with command." + + ;; Get the content of the active region or the word under cursor + (setq org-index--active-region + (if (and transient-mark-mode mark-active) + (buffer-substring (region-beginning) (region-end)) + nil)) + (setq org-index--below-cursor (thing-at-point 'symbol)) + + ;; get category of current node + (setq org-index--category-before + (save-excursion ; workaround: org-get-category does not give category when at end of buffer + (beginning-of-line) + (org-get-category (point) t))) + + ;; Find out, if we are within index table or occur buffer + (setq org-index--within-index-node (string= (org-id-get) org-index-id)) + (setq org-index--within-occur (string= (buffer-name) org-index--occur-buffer-name))) + + +(defun org-index--parse-table (&optional num-lines-to-format check-sort-mixed) + "Parse content of index table. +Optional argument NUM-LINES-TO-FORMAT limits formatting effort and duration. +Optional argument CHECK-SORT-MIXED triggers resorting if mixed and stale." + + (let (ref-field + ref-num + initial-point + end-of-headings + start-of-headings) + + (unless num-lines-to-format (setq num-lines-to-format 0)) + + (with-current-buffer org-index--buffer + + (setq initial-point (point)) + + (org-index--go-below-hline) + (org-reveal) + + ;; if table is sorted mixed and it was sorted correctly yesterday, it could still be wrong today; so check + (when (and check-sort-mixed (eq org-index-sort-by 'mixed)) + (goto-char org-index--below-hline) + (let (count-first-line count-second-line) + (setq count-first-line (string-to-number (concat (org-index--get-or-set-field 'count) " 0"))) + (forward-line) + (setq count-second-line (string-to-number (concat (org-index--get-or-set-field 'count) " 0"))) + (forward-line -1) + (if (and (string< (org-index--get-or-set-field 'last-accessed) + (org-index--get-mixed-time)) + (< count-first-line count-second-line)) + (org-index--do-sort-index org-index-sort-by))) + (org-index--go-below-hline)) + + ;; align and fontify table once for this emacs session + (when (> num-lines-to-format org-index--aligned) + (org-index--go-below-hline) + (message "Aligning and fontifying %s lines of index table (once per emacs session)..." + (if (= num-lines-to-format most-positive-fixnum) "all" (format "%d" num-lines-to-format))) + (save-restriction + (let (from to) + (forward-line -3) + (setq from (point)) + (setq to (org-table-end)) + (when (< num-lines-to-format most-positive-fixnum) + (forward-line (+ 3 num-lines-to-format)) + (narrow-to-region from (point)) + (setq to (min (point) to))) + (goto-char org-index--below-hline) + (org-table-align) + (setq to (min (point-max) to)) + (font-lock-fontify-region from to))) + (setq org-index--aligned num-lines-to-format) + (org-index--go-below-hline) + (message "Done.")) + + (beginning-of-line) + + ;; get headings to display during occur + (setq end-of-headings (point)) + (goto-char (org-table-begin)) + (setq start-of-headings (point)) + (setq org-index--headings-visible (substring-no-properties (org-index--copy-visible start-of-headings end-of-headings))) + (setq org-index--headings (buffer-substring start-of-headings end-of-headings)) + + ;; count columns + (org-table-goto-column 100) + (setq org-index--numcols (- (org-table-current-column) 1)) + + ;; go to top of table + (goto-char (org-table-begin)) + + ;; parse line of headings + (org-index--parse-headings) + + ;; read property or go through table to find maximum number + (goto-char org-index--below-hline) + (setq ref-field (or (org-entry-get org-index--point "max-ref") + (org-index--migrate-maxref-to-property))) + + (unless org-index--head (org-index--get-decoration-from-ref-field ref-field)) + (setq org-index--maxrefnum (org-index--extract-refnum ref-field)) + + ;; Get ids of focused node (if any) + (setq org-index--ids-focused-nodes (split-string (or (org-entry-get nil "ids-focused-nodes") ""))) + (org-entry-delete (point) "id-focused-node") ; migrate (kind of) from previous versions + + ;; save position below hline + (org-index--go-below-hline) + ;; go back to initial position + (goto-char initial-point)))) + + +(defun org-index--get-decoration-from-ref-field (ref-field) + "Extract decoration from a REF-FIELD." + (unless (string-match "^\\([^0-9]*\\)\\([0-9]+\\)\\([^0-9]*\\)$" ref-field) + (org-index--report-index-error + "Reference in index table ('%s') does not contain a number" ref-field)) + + ;; These are the decorations used within the first ref of index + (setq org-index--head (match-string 1 ref-field)) + (setq org-index--tail (match-string 3 ref-field)) + (setq org-index--ref-regex (concat (regexp-quote org-index--head) + "\\([0-9]+\\)" + (regexp-quote org-index--tail))) + (setq org-index--ref-format (concat org-index--head "%d" org-index--tail))) + + +(defun org-index--extract-refnum (ref-field) + "Extract the number from a complete reference REF-FIELD like 'R102'." + (unless (string-match org-index--ref-regex ref-field) + (org-index--report-index-error + "Reference '%s' is not formatted properly (does not match '%s')" ref-field org-index--ref-regex)) + (string-to-number (match-string 1 ref-field))) + + +(defun org-index--migrate-maxref-to-property () + "One-time migration: No property; need to go through whole table once to find max." + (org-index--go-below-hline) + (let (ref-field ref-num ref) + (message "One-time migration to set index-property maxref...") + (unless org-index--maxrefnum (setq org-index--maxrefnum 0)) + (while (org-at-table-p) + (setq ref-field (org-index--get-or-set-field 'ref)) + (when ref-field + (unless org-index--head (org-index--get-decoration-from-ref-field ref-field)) + (setq ref-num (org-index--extract-refnum ref-field)) + (if (> ref-num org-index--maxrefnum) (setq org-index--maxrefnum ref-num))) + (forward-line)) + (unless org-index--maxrefnum + (org-index--report-index-error "No reference found in property max-ref and none in index")) + (setq ref (org-index--get-save-maxref t)) + (org-index--go-below-hline) + (message "Done.") + ref)) + + +(defun org-index--get-save-maxref (&optional no-inc) + "Get next reference, increment number and store it in index. +Optional argument NO-INC skips automatic increment on maxref." + (let (ref) + (unless no-inc (setq org-index--maxrefnum (1+ org-index--maxrefnum))) + (setq ref (format org-index--ref-format org-index--maxrefnum)) + (with-current-buffer org-index--buffer + (org-entry-put org-index--point "max-ref" ref)) + ref)) + + +(defun org-index--refresh-parse-table () + "Fast refresh of selected results of parsing index table." + + (setq org-index--point (marker-position (org-id-find org-index-id 'marker))) + (with-current-buffer org-index--buffer + (save-excursion + (org-index--go-below-hline)))) + + +(defun org-index--do-maintain () + "Choose among and perform some tasks to maintain index." + (let ((check-what) (max-mini-window-height 1.0) message-text) + (setq check-what (intern (org-completing-read "These checks and fixes are available:\n - statistics : compute statistics about index table\n - check : check ids by visiting their nodes\n - duplicates : check index for duplicate rows (ref or id)\n - clean : remove obsolete property org-index-id\n - update : update content of index lines, with an id \nPlease choose: " (list "statistics" "check" "duplicates" "clean" "update") nil t nil nil "statistics"))) + (message nil) + + (cond + ((eq check-what 'check) + (setq message-text (or (org-index--check-ids) + "No problems found"))) + + ((eq check-what 'statistics) + (setq message-text (org-index--do-statistics))) + + ((eq check-what 'duplicates) + (setq message-text (org-index--find-duplicates))) + + ((eq check-what 'clean) + (let ((lines 0)) + (org-map-entries + (lambda () + (when (org-entry-get (point) "org-index-ref") + (cl-incf lines) + (org-entry-delete (point) "org-index-ref"))) + nil 'agenda) + (setq message-text (format "Removed property 'org-index-ref' from %d lines" lines)))) + + ((eq check-what 'update) + (if (y-or-n-p "Updating your index will overwrite certain columns with content from the associated heading and category. If unsure, you may try this for a single, already existing line of your index by invoking `add'. Are you SURE to proceed for ALL INDEX LINES ? ") + (setq message-text (org-index--update-all-lines)) + (setq message-text "Canceled.")))) + message-text)) + + +(defun org-index--get-mixed-time () + "Get timestamp for sorting order mixed." + (format-time-string + (org-time-stamp-format t t) + (apply 'encode-time (append '(0 0 0) (nthcdr 3 (decode-time)))))) + + +(defun org-index--do-sort-index (sort) + "Sort index table according to SORT." + + (let ((is-modified (buffer-modified-p)) + top + bottom + mixed-time) + + (unless buffer-read-only + + (message "Sorting index table for %s..." (symbol-name sort)) + (undo-boundary) + + (let ((message-log-max nil)) ; we have just issued a message, dont need those of sort-subr + + ;; if needed for mixed sort + (if (eq sort 'mixed) + (setq mixed-time (org-index--get-mixed-time))) + + ;; get boundaries of table + (org-index--go-below-hline) + (forward-line 0) + (setq top (point)) + (goto-char (org-table-end)) + + ;; kill all empty rows at bottom + (while (progn + (forward-line -1) + (org-table-goto-column 1) + (and + (not (org-index--get-or-set-field 'ref)) + (not (org-index--get-or-set-field 'id)) + (not (org-index--get-or-set-field 'yank)))) + (org-table-kill-row)) + (forward-line 1) + (setq bottom (point)) + + ;; sort lines + (save-restriction + (narrow-to-region top bottom) + (goto-char top) + (sort-subr t + 'forward-line + 'end-of-line + (lambda () + (org-index--get-sort-key sort t mixed-time)) + nil + 'string<) + (goto-char (point-min)) + + ;; restore modification state + (set-buffer-modified-p is-modified))) + + (setq org-index--last-sort-assumed sort)))) + + +(defun org-index--do-sort-lines (what) + "Sort lines in WHAT according to contained reference." + (save-restriction + (cond + ((eq what 'region) + (if (region-active-p) + (narrow-to-region (region-beginning) (region-end)) + (error "No active region, cannot sort"))) + ((eq what 'buffer) + (unless (y-or-n-p "Sort whole current buffer ? ") + (error "Canceled")) + (narrow-to-region (point-min) (point-max)))) + + (goto-char (point-min)) + (sort-subr nil 'forward-line 'end-of-line + (lambda () + (if (looking-at (concat ".*" + (org-index--make-guarded-search org-index--ref-regex 'dont-quote))) + (string-to-number (match-string 1)) + 0))))) + + +(defun org-index--go-below-hline () + "Move below hline in index-table." + + (let ((errstring (format "index table within node %s" org-index-id))) + + (goto-char org-index--point) + + ;; go to heading of node + (while (not (org-at-heading-p)) (forward-line -1)) + (forward-line 1) + + ;; go to first table, but make sure we do not get into another node + (while (and (not (org-at-table-p)) + (not (org-at-heading-p)) + (not (eobp))) + (forward-line)) + + ;; check, if there really is a table + (unless (org-at-table-p) + (org-index--create-missing-index "Cannot find %s." errstring)) + + ;; go just after hline + (while (and (not (org-at-table-hline-p)) + (org-at-table-p)) + (forward-line)) + (forward-line) + + ;; and check + (unless (org-at-table-p) + (org-index--report-index-error "Cannot find a hline within %s" errstring)) + + (org-table-goto-column 1) + (setq org-index--below-hline (point)))) + + +(defun org-index--parse-headings () + "Parse headings of index table." + + (let (field ;; field content + field-symbol) ;; and as a symbol + + (setq org-index--columns nil) + + ;; For each column + (dotimes (col org-index--numcols) + + (setq field (substring-no-properties (downcase (org-trim (org-table-get-field (+ col 1)))))) + + (if (string= field "") + (error "Heading of column cannot be empty")) + (if (and (not (string= (substring field 0 1) ".")) + (not (member (intern field) org-index--valid-headings))) + (error "Column name '%s' is not a valid heading (custom headings may start with a dot, e.g. '.foo')" field)) + + (setq field-symbol (intern field)) + + ;; check if heading has already appeared + (if (assoc field-symbol org-index--columns) + (org-index--report-index-error + "'%s' appears two times as column heading" (downcase field)) + ;; add it to list at front, reverse later + (setq org-index--columns (cons (cons field-symbol (+ col 1)) org-index--columns))))) + + (setq org-index--columns (reverse org-index--columns)) + + ;; check if all necessary headings have appeared + (mapc (lambda (head) + (unless (cdr (assoc head org-index--columns)) + (org-index--report-index-error "No column has heading '%s'" head))) + org-index--valid-headings)) + + +(defun org-index--create-missing-index (&rest reasons) + "Create a new empty index table with detailed explanation. Argument REASONS explains why." + + (org-index--ask-before-create-index "Cannot find index table: " + "new permanent" "." + reasons) + (org-index--create-index)) + + +(defun org-index--report-index-error (&rest reasons) + "Report an error (explained by REASONS) with the existing index and offer to create a valid one to compare with." + + (when org-index--buffer + (pop-to-buffer-same-window org-index--buffer) + (goto-char org-index--below-hline) + (org-reveal t)) + (org-index--ask-before-create-index "The existing index contains this error: " + "temporary" ", to compare with." + reasons) + (org-index--create-index t t)) + + +(defun org-index--ask-before-create-index (explanation type for-what reasons) + ; checkdoc-params: (explanation type for-what reasons) + "Ask the user before creating an index or throw error. Arguments specify bits of issued message." + (let (reason prompt) + + (setq reason (apply 'format reasons)) + + (setq prompt (concat explanation reason "\n" + "However, this assistant can help you to create a " + type " index with detailed comments" for-what "\n\n" + "Do you want to proceed ?")) + + (unless (let ((max-mini-window-height 1.0)) + (y-or-n-p prompt)) + (error (concat explanation reason))))) + + +(defun org-index--create-index (&optional temporary compare) + "Create a new empty index table with detailed explanation. +specify flag TEMPORARY for th new table temporary, maybe COMPARE it with existing index." + (let (buffer + title + firstref + id) + + (if temporary + (let ((file-name (concat temporary-file-directory "org-index--example-index.org")) + (buffer-name "*org-index-example-index*")) + (setq buffer (get-buffer-create buffer-name)) + (with-current-buffer buffer + ;; but it needs a file for its index to be found + (unless (string= (buffer-file-name) file-name) + (set-visited-file-name file-name)) + (rename-buffer buffer-name) ; name is change by line above + + (erase-buffer) + (org-mode))) + + (setq buffer (get-buffer (org-completing-read "Please choose the buffer, where the new node for the index table should be created; the new node will be inserted at its end.\n\nBuffer: " (mapcar 'buffer-name (org-buffer-list)))))) + + (setq title (read-from-minibuffer "Please enter the title of the index node (leave empty for default 'index'): ")) + (if (string= title "") (setq title "index")) + + (while (progn + (setq firstref (read-from-minibuffer "Please enter your first reference-number. This is an integer number preceeded by some and optionally followed by some non-numeric chars; e.g. 'R1', '-1-' or '#1#' (and your initial number does not need to be '1'). The format of your reference-numbers only needs to make sense for yourself, so that you can spot it easily in your texts or write it on a piece of paper; it should however not already appear frequently within your existing notes, to avoid too many false hits when searching.\n\nPlease choose (leave empty for default 'R1'): ")) + (if (string= firstref "") (setq firstref "R1")) + (let (desc) + (when (string-match "[[:blank:]]" firstref) + (setq desc "Contains whitespace")) + (when (string-match "[[:cntrl:]]" firstref) + (setq desc "Contains control characters")) + (unless (string-match "^[^0-9]+[0-9]+[^0-9]*$" firstref) + ;; firstref not okay, report details + (setq desc + (cond ((string= firstref "") "is empty") + ((not (string-match "^[^0-9]+" firstref)) "starts with a digit") + ((not (string-match "^[^0-9]+[0-9]+" firstref)) "does not contain a number") + ((not (string-match "^[^0-9]+[0-9]+[^0-9]*$" firstref)) "contains more than one sequence of digits") + + ))) + (if desc + (progn + (read-from-minibuffer (format "Your input '%s' does not meet the requirements because it %s.\nPlease hit RET and try again: " firstref desc)) + t) + nil)))) + + (with-current-buffer buffer + (goto-char (point-max)) + (insert (format "* %s %s\n" firstref title)) + (org-entry-put org-index--point "max-ref" firstref) + (if temporary + (insert " + Below you find your temporary index table, which WILL NOT LAST LONGER + THAN YOUR CURRENT EMACS SESSION; please use it only for evaluation. +") + (insert " + Below you find your initial index table, which will grow over time. +")) + (insert " You may start using it by adding some lines. Just + move to another heading within org, invoke `org-index' and + choose the command 'add'. After adding a few nodes, try the + command 'occur' to search among them. + + To gain further insight you may invoke the subcommand 'help', or + (same content) read the help of `org-index'. + + Within the index table below, the sequence of columns does not + matter. You may reorder them in any way you like. You may also + add your own columns, which should start with a dot + (e.g. '.my-column'). + + Invoke `org-customize' to tweak the behaviour of org-index + (see the group org-index). + + This node needs not be a top level node; its name is completely + at your choice; it is found through its ID only. +") + (unless temporary + (insert " + Remark: These lines of explanation can be removed at any time. +")) + + (setq id (org-id-get-create)) + (insert (format " + + | ref | category | keywords | tags | count | level | last-accessed | created | id | yank | + | | | | | | | | | <4> | <4> | + |-----+----------+----------+------+-------+-------+---------------+---------+-----+------| + | %s | | %s | | | | | %s | %s | | + +" + firstref + title + (with-temp-buffer (org-insert-time-stamp nil nil t)) + id)) + + ;; make sure, that node can be found + (org-id-add-location id (buffer-file-name)) + (setq buffer-save-without-query t) + (basic-save-buffer) + + (while (not (org-at-table-p)) (forward-line -1)) + (unless buffer-read-only (org-table-align)) + (while (not (org-at-heading-p)) (forward-line -1)) + + ;; read back some info about new index + (let ((org-index-id id)) + (org-index--verify-id)) + + ;; remember at least for this session + (setq org-index-id id) + + ;; present results to user + (if temporary + (progn + ;; Present existing and temporary index together + (when compare + (pop-to-buffer-same-window org-index--buffer) + (goto-char org-index--point) + (org-index--unfold-buffer) + (delete-other-windows) + (select-window (split-window-vertically))) + ;; show new index + (pop-to-buffer-same-window buffer) + (org-id-goto id) + (org-index--unfold-buffer) + (if compare + (progn + (message "Please compare your existing index (upper window) and a temporary new one (lower window) to fix your index") + (throw 'new-index nil)) + (message "This is your new temporary index, use command add to populate, occur to search."))) + (progn + ;; Only show the new index + (pop-to-buffer-same-window buffer) + (delete-other-windows) + (org-id-goto id) + (org-index--unfold-buffer) + (if (y-or-n-p "This is your new index table. It is already set for this Emacs session, so you may try it out. Do you want to save its id to make it available for future Emacs sessions too ? ") + (progn + (customize-save-variable 'org-index-id id) + (message "Saved org-index-id '%s' to %s." id (or custom-file + user-init-file)) + (throw 'new-index nil)) + (let (sq) + (setq sq (format "(setq org-index-id \"%s\")" id)) + (kill-new sq) + (message "Did not make the id of this new index permanent; you may want to put\n\n %s\n\ninto your own initialization; it is copied already, just yank it." sq) + (throw 'new-index nil)))))))) + + +(defun org-index--unfold-buffer () + "Helper function to unfold buffer." + (org-show-context) + (org-show-subtree) + (recenter 1) + (save-excursion + (org-back-to-heading) + (forward-line) ;; on property drawer + (org-cycle))) + + +(defun org-index--update-line (&optional ref-or-id-or-pos) + "Update columns count and last-accessed in line REF-OR-ID-OR-POS." + + (let (initial) + + (with-current-buffer org-index--buffer + (unless buffer-read-only + + ;; search reference or id, if given (or assume, that we are already positioned right) + (when ref-or-id-or-pos + (setq initial (point)) + (goto-char org-index--below-hline) + (while (and (org-at-table-p) + (not (if (integerp ref-or-id-or-pos) + (and (>= ref-or-id-or-pos (line-beginning-position)) + (< ref-or-id-or-pos (line-end-position))) + (or (string= ref-or-id-or-pos (org-index--get-or-set-field 'ref)) + (string= ref-or-id-or-pos (org-index--get-or-set-field 'id)))))) + (forward-line))) + + (if (not (org-at-table-p)) + (error "Did not find reference or id '%s'" ref-or-id-or-pos) + (org-index--update-current-line)) + + (if initial (goto-char initial)))))) + + +(defun org-index--update-current-line () + "Update current lines columns count and last-accessed." + (let (newcount (count-field (org-index--get-or-set-field 'count))) + + ;; update count field only if number or empty + (when (or (not count-field) + (string-match "^[0-9]+$" count-field)) + (setq newcount (+ 1 (string-to-number (or count-field "0")))) + (org-index--get-or-set-field 'count + (number-to-string newcount))) + + ;; update timestamp + (org-table-goto-column (org-index--column-num 'last-accessed)) + (org-table-blank-field) + (org-insert-time-stamp nil t t) + + ;; move line according to new content + (org-index--promote-current-line) + (org-index--align-and-fontify-current-line))) + + +(defun org-index--align-and-fontify-current-line (&optional num) + "Make current line (or NUM lines) blend well among others." + (let (lines) + ;; get current content + (unless num (setq num 1)) + (setq lines (delete-and-extract-region (line-beginning-position) (line-end-position num))) + ;; create minimum table with fixed-width columns to align and fontify new line + (insert (with-temp-buffer + (org-set-font-lock-defaults) + (insert org-index--headings-visible) + ;; fill columns, so that aligning cannot shrink them + (goto-char (point-min)) + (search-forward "|") + (while (search-forward " " (line-end-position) t) + (replace-match "." nil t)) + (goto-char (point-min)) + (while (search-forward ".|." (line-end-position) t) + (replace-match " | " nil t)) + (goto-char (point-min)) + (while (search-forward "|." (line-end-position) t) + (replace-match "| " nil t)) + (goto-char (point-max)) + (insert lines) + (forward-line 0) + (let ((start (point))) + (while (re-search-forward "^\s +|-" nil t) + (replace-match "| -")) + (goto-char start)) + (org-mode) + (org-table-align) + (font-lock-fontify-region (point-min) (point-max)) + (goto-char (point-max)) + (if (eq -1 (skip-chars-backward "\n")) + (delete-char 1)) + (forward-line (- 1 num)) + (buffer-substring (line-beginning-position) (line-end-position num)))) + lines)) + + +(defun org-index--promote-current-line () + "Move current line up in table according to changed sort fields." + (let (begin end key + (to-skip 0)) + + (forward-line 0) ; stay at beginning of line + + (setq key (org-index--get-sort-key)) + (setq begin (point)) + (setq end (line-beginning-position 2)) + + (forward-line -1) + (while (and (org-at-table-p) + (not (org-at-table-hline-p)) + (string< (org-index--get-sort-key) key)) + + (cl-incf to-skip) + (forward-line -1)) + (forward-line 1) + + ;; insert line at new position + (when (> to-skip 0) + (insert (delete-and-extract-region begin end)) + (forward-line -1)))) + + +(defun org-index--get-sort-key (&optional sort with-ref mixed-time) + "Get value for sorting from column SORT, optional WITH-REF; if mixes use MIXED-TIME." + (let (ref + ref-field + key) + + (unless sort (setq sort org-index--last-sort-assumed)) ; use default value + + (when (or with-ref + (eq sort 'ref)) + ;; get reference with leading zeroes, so it can be + ;; sorted as text + (setq ref-field (org-index--get-or-set-field 'ref)) + (if ref-field + (progn + (string-match org-index--ref-regex ref-field) + (setq ref (format + "%06d" + (string-to-number + (match-string 1 ref-field))))) + (setq ref "000000"))) + + (setq key + (cond + ((eq sort 'count) + (format "%08d" (string-to-number (or (org-index--get-or-set-field 'count) "")))) + ((eq sort 'mixed) + (let ((last-accessed (org-index--get-or-set-field 'last-accessed))) + (unless mixed-time (setq mixed-time (org-index--get-mixed-time))) + (concat + (if (string< mixed-time last-accessed) last-accessed mixed-time) + (format "%08d" (string-to-number (or (org-index--get-or-set-field 'count) "")))))) + ((eq sort 'ref) + ref) + ((memq sort '(id last-accessed created)) + (org-index--get-or-set-field sort)) + (t (error "This is a bug: unmatched case '%s'" sort)))) + + (if with-ref (setq key (concat key ref))) + + key)) + + +(defun org-index--get-or-set-field (key &optional value) + "Retrieve field KEY from index table or set it to VALUE." + (let (field) + (save-excursion + (if (eq key 'fingerprint) + (progn + (if value (error "Internal error, pseudo-column fingerprint cannot be set")) + (setq field (org-index--get-fingerprint))) + (setq field (org-trim (org-table-get-field (cdr (assoc key org-index--columns)) value)))) + (if (string= field "") (setq field nil)) + + (org-no-properties field)))) + + +(defun org-index--column-num (key) + "Return number of column KEY." + (if (numberp key) + key + (cdr (assoc key org-index--columns)))) + + +(defun org-index--make-guarded-search (ref &optional dont-quote) + "Make robust search string from REF; DONT-QUOTE it, if requested." + (concat "\\_<" (if dont-quote ref (regexp-quote ref)) "\\_>")) + + +(defun org-index--find-duplicates () + "Find duplicate references or ids in index table." + (let (ref-duplicates id-duplicates) + + (setq ref-duplicates (org-index--find-duplicates-helper 'ref)) + (setq id-duplicates (org-index--find-duplicates-helper 'id)) + (goto-char org-index--below-hline) + (if (or ref-duplicates id-duplicates) + (progn + ;; show results + (pop-to-buffer-same-window + (get-buffer-create "*org-index-duplicates*")) + (when ref-duplicates + (insert "These references appear more than once:\n") + (mapc (lambda (x) (insert " " x "\n")) ref-duplicates) + (insert "\n\n")) + (when id-duplicates + (insert "These ids appear more than once:\n") + (mapc (lambda (x) (insert " " x "\n")) id-duplicates)) + + "Some references or ids are duplicates") + "No duplicate references or ids found"))) + + +(defun org-index--find-duplicates-helper (column) + "Helper for `org-index--find-duplicates': Go through table and count given COLUMN." + (let (counts duplicates field found) + + ;; go through table + (goto-char org-index--below-hline) + (while (org-at-table-p) + + ;; get column + (setq field (org-index--get-or-set-field column)) + + ;; and increment + (setq found (assoc field counts)) + (if found + (cl-incf (cdr found)) + (setq counts (cons (cons field 1) counts))) + + (forward-line)) + + (mapc (lambda (x) (if (and (> (cdr x) 1) + (car x)) + (setq duplicates (cons (car x) duplicates)))) counts) + + duplicates)) + + +(defun org-index--do-statistics () + "Compute statistics about index table." + (let ((total-lines 0) (total-refs 0) + ref ref-field min max message) + + ;; go through table + (goto-char org-index--below-hline) + (while (org-at-table-p) + + ;; get ref + (setq ref-field (org-index--get-or-set-field 'ref)) + + (when ref-field + (string-match org-index--ref-regex ref-field) + (setq ref (string-to-number (match-string 1 ref-field))) + + ;; record min and max + (if (or (not min) (< ref min)) (setq min ref)) + (if (or (not max) (> ref max)) (setq max ref)) + + (setq total-refs (1+ total-refs))) + + ;; count + (setq total-lines (1+ total-lines)) + + (forward-line)) + + (setq message (format "%d Lines in index table. First reference is %s, last %s; %d of them are used (%d percent)" + total-lines + (format org-index--ref-format min) + (format org-index--ref-format max) + total-refs + (truncate (* 100 (/ (float total-refs) (1+ (- max min))))))) + + (goto-char org-index--below-hline) + message)) + + +(defun org-index--do-add-or-update (&optional create-ref tag-with-ref) + "For current node or current line in index, add or update in index table. +CREATE-REF and TAG-WITH-REF if given." + + (let* (id id-from-index ref args yank ret) + + (org-index--save-positions) + (unless (or org-index--within-index-node + org-index--within-occur) + (org-back-to-heading)) + + ;; try to do the same things from within index and from outside + (if org-index--within-index-node + + (progn + (unless (org-at-table-p) + (error "Within index node but not on table")) + + (setq id (org-index--get-or-set-field 'id)) + (setq ref (org-index--get-or-set-field 'ref)) + (setq args (org-index--collect-values-for-add-update-remote id)) + (org-index--write-fields args) + (setq yank (org-index--get-or-set-field org-index-yank-after-add)) + + (setq ret + (if ref + (cons (format "Updated index line %s" ref) yank) + (cons "Updated index line" nil)))) + + (setq id (org-id-get-create)) + (org-index--refresh-parse-table) + (setq id-from-index (org-index--on 'id id id)) + (setq ref (org-index--on 'id id (org-index--get-or-set-field 'ref))) + + (if tag-with-ref + (org-toggle-tag (format "%s%d%s" org-index--head tag-with-ref org-index--tail) 'on)) + (setq args (org-index--collect-values-for-add-update id)) + + (when (and create-ref + (not ref)) + (setq ref (org-index--get-save-maxref)) + (setq args (plist-put args 'ref ref))) + + + (if id-from-index + ;; already have an id in index, find it and update fields + (progn + + (org-index--on + 'id id + (org-index--write-fields args) + (setq yank (org-index--get-or-set-field org-index-yank-after-add))) + + (setq ret + (if ref + (cons (format "Updated index line %s" ref) yank) + (cons "Updated index line" nil)))) + + ;; no id here, create new line in index + (if ref (setq args (plist-put args 'ref ref))) + (setq yank (apply 'org-index--do-new-line args)) + + (setq ret + (if ref + (cons + (format "Added new index line %s" ref) + (concat yank " ")) + (cons + "Added new index line" + nil))))) + + (org-index--restore-positions) + + ret)) + + +(defun org-index--check-ids () + "Check, that ids really point to a node." + + (let ((lines 0) + id ids marker) + + (goto-char org-index--below-hline) + + (catch 'problem + (while (org-at-table-p) + + (when (setq id (org-index--get-or-set-field 'id)) + + ;; check for double ids + (when (member id ids) + (org-table-goto-column (org-index--column-num 'id)) + (throw 'problem "This id appears twice in index; please use command 'maintain' to check for duplicate ids")) + (cl-incf lines) + (setq ids (cons id ids)) + + ;; check, if id is valid + (setq marker (org-id-find id t)) + (unless marker + (org-table-goto-column (org-index--column-num 'id)) + (throw 'problem "This id cannot be found"))) + + (forward-line)) + + (goto-char org-index--below-hline) + nil))) + + +(defun org-index--update-all-lines () + "Update all lines of index at once." + + (let ((lines 0) + id ref kvs) + + ;; check for double ids + (or + (org-index--check-ids) + + (progn + (goto-char org-index--below-hline) + (while (org-at-table-p) + + ;; update single line + (when (setq id (org-index--get-or-set-field 'id)) + (setq ref (org-index--get-or-set-field 'ref)) + (setq kvs (org-index--collect-values-for-add-update-remote id)) + (org-index--write-fields kvs) + (cl-incf lines)) + (forward-line)) + + (goto-char org-index--below-hline) + (org-table-align) + (format "Updated %d lines" lines))))) + + +(defun org-index--collect-values-for-add-update (id &optional silent category) + "Collect values for adding or updating line specified by ID, do not ask if SILENT, use CATEGORY, if given." + + (let ((args (list 'id id)) + content) + + (dolist (col (mapcar 'car org-index--columns)) + + (setq content "") + + (cond + ((eq col 'keywords) + (if org-index-copy-heading-to-keywords + (setq content (nth 4 (org-heading-components)))) + + ;; Shift ref and timestamp ? + (if org-index-strip-ref-and-date-from-heading + (dotimes (i 2) + (if (or (string-match (concat "^\\s-*" org-index--ref-regex) content) + (string-match (concat "^\\s-*" org-ts-regexp-both) content)) + (setq content (substring content (match-end 0))))))) + + ((eq col 'category) + (setq content (or category org-index--category-before))) + + ((eq col 'level) + (setq content (number-to-string (org-outline-level)))) + + ((eq col 'tags) + (setq content (org-get-tags-string)))) + + (unless (string= content "") + (setq args (plist-put args col content)))) + + (if (not silent) + (let ((args-edited (org-index--collect-values-from-user org-index-edit-on-add args))) + (setq args (append args-edited args)))) + + args)) + + +(defun org-index--collect-values-for-add-update-remote (id) + "Wrap `org-index--collect-values-for-add-update' by prior moving to remote node identified by ID." + + (let (marker point args) + + (setq marker (org-id-find id t)) + ;; enter buffer and collect information + (with-current-buffer (marker-buffer marker) + (setq point (point)) + (goto-char marker) + (setq args (org-index--collect-values-for-add-update id t (org-get-category (point) t))) + (goto-char point)) + + args)) + + +(defun org-index--collect-values-from-user (cols &optional defaults) + "Collect values for adding a new line. +Argument COLS gives list of columns to edit. +Optional argument DEFAULTS gives default values." + + (let (content args) + + (dolist (col cols) + + (setq content "") + + (setq content (read-from-minibuffer + (format "Enter text for column '%s': " (symbol-name col)) + (plist-get col defaults))) + + (unless (string= content "") + (setq args (plist-put args col content)))) + args)) + + +(defun org-index--write-fields (kvs) + "Update current line with values from KVS (keys-values)." + (while kvs + (org-index--get-or-set-field (car kvs) (org-trim (cadr kvs))) + (setq kvs (cddr kvs)))) + + +(defun org-index--do-kill () + "Perform command kill from within occur, index or node." + + (let (id ref chars-deleted-index text-deleted-from pos-in-index) + + (org-index--save-positions) + (unless (or org-index--within-index-node + org-index--within-occur) + (org-back-to-heading)) + + ;; Collect information: What should be deleted ? + (if (or org-index--within-occur + org-index--within-index-node) + + (progn + (if org-index--within-index-node + ;; In index + (setq pos-in-index (point)) + ;; In occur + (setq pos-in-index (get-text-property (point) 'org-index-lbp)) + (org-index--occur-test-stale pos-in-index) + (set-buffer org-index--buffer) + (goto-char pos-in-index)) + ;; In Index (maybe moved there) + (setq id (org-index--get-or-set-field 'id)) + (setq ref (org-index--get-or-set-field 'ref))) + + ;; At a headline + (setq id (org-entry-get (point) "ID")) + (setq ref (org-index--ref-from-id id)) + (setq pos-in-index (org-index--on 'id id (point))) + (unless pos-in-index (error "This node is not in index"))) + + ;; Remark: Current buffer is not certain here, but we have all the information to delete + + ;; Delete from node + (when id + (let ((m (org-id-find id 'marker))) + (set-buffer (marker-buffer m)) + (goto-char m) + (move-marker m nil) + (unless (string= (org-id-get) id) + (error "Could not find node with id %s" id))) + + (org-index--delete-any-ref-from-tags) + (if ref (org-index--delete-ref-from-heading ref)) + (setq text-deleted-from (cons "node" text-deleted-from))) + + ;; Delete from index + (set-buffer org-index--buffer) + (unless pos-in-index "Internal error, pos-in-index should be defined here") + (goto-char pos-in-index) + (setq chars-deleted-index (length (delete-and-extract-region (line-beginning-position) (line-beginning-position 2)))) + (setq text-deleted-from (cons "index" text-deleted-from)) + + ;; Delete from occur only if we started there, accept that it will be stale otherwise + (if org-index--within-occur + (let ((inhibit-read-only t)) + (set-buffer org-index--occur-buffer-name) + (delete-region (line-beginning-position) (line-beginning-position 2)) + ;; correct positions + (while (org-at-table-p) + (put-text-property (line-beginning-position) (line-end-position) 'org-index-lbp + (- (get-text-property (point) 'org-index-lbp) chars-deleted-index)) + (forward-line)) + (setq text-deleted-from (cons "occur" text-deleted-from)))) + + (org-index--restore-positions) + (concat "Deleted from: " (mapconcat 'identity (sort text-deleted-from 'string<) ",")))) + + +(defun org-index--save-positions () + "Save current buffer and positions in index- and current buffer; not in occur-buffer." + + (let (cur-buf cur-mrk idx-pnt idx-mrk) + (setq cur-buf (current-buffer)) + (setq cur-mrk (point-marker)) + (set-buffer org-index--buffer) + (if (string= (org-id-get) org-index-id) + (setq idx-pnt (point)) + (setq idx-mrk (point-marker))) + (set-buffer cur-buf) + (setq org-index--saved-positions (list cur-buf cur-mrk idx-pnt idx-mrk)))) + + +(defun org-index--restore-positions () + "Restore positions as saved by `org-index--save-positions'." + + (cl-multiple-value-bind + (cur-buf cur-mrk idx-pnt idx-mrk buf) + org-index--saved-positions + (setq buf (current-buffer)) + (set-buffer cur-buf) + (goto-char cur-mrk) + (set-buffer org-index--buffer) + (goto-char (or idx-pnt idx-mrk)) + (set-buffer buf)) + (setq org-index--saved-positions nil)) + + +(defun org-index--delete-ref-from-heading (ref) + "Delete given REF from current heading." + (save-excursion + (end-of-line) + (let ((end (point))) + (beginning-of-line) + (when (search-forward ref end t) + (delete-char (- (length ref))) + (just-one-space))))) + + +(defun org-index--delete-any-ref-from-tags () + "Delete any reference from list of tags." + (let (new-tags) + (mapc (lambda (tag) + (unless (string-match org-index--ref-regex tag) + (setq new-tags (cons tag new-tags) ))) + (org-get-tags)) + (org-set-tags-to new-tags))) + + +(defun org-index--go (column value) + "Position cursor on index line where COLUMN equals VALUE. +Return t or nil, leave point on line or at top of table, needs to be in buffer initially." + (let (found) + + (unless (eq (current-buffer) org-index--buffer) + (error "This is a bug: Not in index buffer")) + + (unless value + (error "Cannot search for nil")) + + (if (string= value "") + (error "Cannot search for empty string")) + + (if (<= (length value) 2) + (warn "Searching for short string '%s' will be slow" value)) + + (goto-char org-index--below-hline) + (forward-line 0) + (save-restriction + (narrow-to-region (point) (org-table-end)) + (while (and (not found) + (search-forward value nil t)) + (setq found (string= value (org-index--get-or-set-field column))))) + + ;; return value + (if found + t + (goto-char org-index--below-hline) + nil))) + + +(defun org-index--find-id (id &optional other) + "Perform command head: Find node with REF or ID and present it. +If OTHER in separate window." + + (let (message marker) + + (setq marker (org-id-find id t)) + + (if marker + (progn + (org-index--update-line id) + (if other + (progn + (pop-to-buffer (marker-buffer marker))) + (pop-to-buffer-same-window (marker-buffer marker))) + + (goto-char marker) + (org-reveal t) + (org-show-entry) + (recenter) + (unless (string= (org-id-get) id) + (setq message (format "Could not go to node with id %s (narrowed ?)" id))) + (setq message "Found headline")) + (setq message (format "Did not find node with %s" id))) + message)) + + +(defun org-index--do-occur () + "Perform command occur." + (let ((word "") ; last word to search for growing and shrinking on keystrokes + (prompt "Search for: ") + (these-commands " NOTE: If you invoke the org-index subcommands edit or kill from within the occur buffer, the index is updated accordingly.") + (lines-wanted (window-body-height)) + (lines-found 0) ; number of lines found + words ; list words that should match + occur-buffer + begin ; position of first line + help-text ; cons with help text short and long + search-text ; description of text to search for + done ; true, if loop is done + in-c-backspace ; true, while processing C-backspace + help-overlay ; Overlay with help text + last-point ; Last position before end of search + initial-frame ; Frame when starting occur + key ; input from user in various forms + key-sequence + key-sequence-raw) + + + ;; make and show buffer + (if (get-buffer org-index--occur-buffer-name) + (kill-buffer org-index--occur-buffer-name)) + (setq occur-buffer (make-indirect-buffer org-index--buffer org-index--occur-buffer-name)) + (pop-to-buffer-same-window occur-buffer) + (setq initial-frame (selected-frame)) + + ;; avoid modifying direct buffer + (setq buffer-read-only t) + (toggle-truncate-lines 1) + (setq font-lock-keywords-case-fold-search t) + (setq case-fold-search t) + + ;; reset stack and overlays + (setq org-index--occur-stack nil) + (setq org-index--occur-tail-overlay nil) + + ;; narrow to table rows and one line before + (goto-char org-index--below-hline) + (forward-line 0) + (setq begin (point)) + (forward-line -1) + (narrow-to-region (point) (org-table-end)) + (forward-line) + + ;; initialize help text + (setq help-text (cons + (concat + (propertize "Incremental occur" 'face 'org-todo) + (propertize "; ? toggles help and headlines.\n" 'face 'org-agenda-dimmed-todo-face)) + (concat + (propertize + (org-index--wrap + (concat + "Normal keys add to search word; or start additional word; erases last char, last word; jumps to heading, jumps to heading in other window, jumps to matching line in index; all other keys end search." these-commands "\n")) + 'face 'org-agenda-dimmed-todo-face) + org-index--headings))) + + ;; insert overlays for help text and to cover unsearched lines + (setq help-overlay (make-overlay (point-min) begin)) + (overlay-put help-overlay 'display (car help-text)) + (setq org-index--occur-tail-overlay (make-overlay (point-max) (point-max))) + (overlay-put org-index--occur-tail-overlay 'invisible t) + + (while (not done) + + (if in-c-backspace + (setq key "") + (setq search-text (mapconcat 'identity (reverse (cons word words)) ",")) + + ;; read key, if selected frame has not changed + (if (eq initial-frame (selected-frame)) + (progn + (setq key-sequence + (let ((echo-keystrokes 0) + (full-prompt (format "%s%s%s" + prompt + search-text + (if (string= search-text "") "" " ")))) + (read-key-sequence full-prompt nil nil t t))) + (setq key (key-description key-sequence)) + (setq key-sequence-raw (this-single-command-raw-keys))) + (setq done t) + (setq key-sequence nil) + (setq key nil) + (setq key-sequence-raw nil))) + + + (cond + + + ((string= key "") + (setq in-c-backspace t)) + + + ((member key (list "" "DEL")) ; erase last char + + (if (= (length word) 0) + + ;; nothing more to delete from current word; try next + (progn + (setq word (car words)) + (setq words (cdr words)) + (setq in-c-backspace nil)) + + ;; unhighlight longer match + (unhighlight-regexp (regexp-quote word)) + + ;; some chars are left; shorten word + (setq word (substring word 0 -1)) + (when (= (length word) 0) ; when nothing left, use next word from list + (setq word (car words)) + (setq words (cdr words)) + (setq in-c-backspace nil)) + + ;; free top list of overlays and remove list + (setq lines-found (or (org-index--unhide) lines-wanted)) + (move-overlay org-index--occur-tail-overlay + (if org-index--occur-stack (cdr (assoc :end-of-visible (car org-index--occur-stack))) + (point-max)) + (point-max)) + + + ;; highlight shorter word + (unless (= (length word) 0) + (highlight-regexp (regexp-quote word) 'isearch)) + + ;; make sure, point is still visible + (goto-char begin))) + + + ((member key (list "SPC" ",")) ; space or comma: enter an additional search word + + ;; push current word and clear, no need to change display + (unless (string= word "") + (setq words (cons word words)) + (setq word ""))) + + + ((string= key "?") ; question mark: toggle display of headlines and help + (setq help-text (cons (cdr help-text) (car help-text))) + (overlay-put help-overlay 'display (car help-text))) + + ((and (= (length key) 1) + (aref printable-chars (elt key 0))) ; any printable char: add to current search word + + ;; unhighlight short word + (unless (= (length word) 0) + (unhighlight-regexp (regexp-quote word))) + + ;; add to word + (setq word (concat word key)) + + ;; make overlays to hide lines, that do not match longer word any more + (goto-char begin) + (setq lines-found (org-index--hide-with-overlays (cons word words) lines-wanted)) + (move-overlay org-index--occur-tail-overlay + (if org-index--occur-stack (cdr (assoc :end-of-visible (car org-index--occur-stack))) + (point-max)) + (point-max)) + + (goto-char begin) + + ;; highlight longer word + (highlight-regexp (regexp-quote word) 'isearch) + + ;; make sure, point is on a visible line + (line-move -1 t) + (line-move 1 t)) + + ;; anything else terminates input loop + (t (setq done t)))) + + ;; put back input event, that caused the loop to end + (unless (string= key "C-g") + (setq unread-command-events (listify-key-sequence key-sequence-raw)) + (message key)) + + ;; postprocessing + (setq last-point (point)) + + ;; For performance reasons do not show matching lines for rest of table. So no code here. + + ;; make permanent copy + ;; copy visible lines + (let ((lines-collected 0) + keymap line all-lines all-lines-lbp header-lines lbp) + + (setq cursor-type t) + (goto-char begin) + + ;; collect all visible lines + (while (and (not (eobp)) + (< lines-collected lines-wanted)) + ;; skip over invisible lines + (while (and (invisible-p (point)) + (not (eobp))) + (goto-char (1+ (overlay-end (car (overlays-at (point))))))) + (setq lbp (line-beginning-position)) + (setq line (buffer-substring-no-properties lbp (line-end-position))) + (unless (string= line "") + (cl-incf lines-collected) + (setq all-lines (cons (concat line + "\n") + all-lines)) + (setq all-lines-lbp (cons lbp all-lines-lbp))) + (forward-line 1)) + + (kill-buffer org-index--occur-buffer-name) ; cannot keep this buffer; might become stale soon + + ;; create new buffer + (setq occur-buffer (get-buffer-create org-index--occur-buffer-name)) + (pop-to-buffer-same-window occur-buffer) + (insert org-index--headings) + (setq header-lines (line-number-at-pos)) + + ;; insert into new buffer + (save-excursion + (apply 'insert (reverse all-lines)) + (if (= lines-collected lines-wanted) + (insert "\n(more lines omitted)\n"))) + (setq org-index--occur-lines-collected lines-collected) + + (org-mode) + (setq truncate-lines t) + (if all-lines (org-index--align-and-fontify-current-line (length all-lines))) + (when (fboundp 'font-lock-ensure) + (font-lock-ensure) + (font-lock-flush)) + (when all-lines-lbp + (while (not (org-at-table-p)) + (forward-line -1)) + (while all-lines-lbp + (put-text-property (line-beginning-position) (line-end-position) 'org-index-lbp (car all-lines-lbp)) + (setq all-lines-lbp (cdr all-lines-lbp)) + (forward-line -1))) + + ;; prepare help text + (goto-char (point-min)) + (forward-line (1- header-lines)) + (setq org-index--occur-help-overlay (make-overlay (point-min) (point))) + (setq org-index--occur-help-text + (cons + (org-index--wrap + (propertize "Search is done; ? toggles help and headlines.\n" 'face 'org-agenda-dimmed-todo-face)) + (concat + (org-index--wrap + (propertize + (format + (concat "Search is done." + (if (< lines-collected lines-wanted) + " Showing all %d matches for " + " Showing one window of matches for ") + "\"" search-text + "\". jumps to heading, jumps to heading in other window, jumps to matching line in index, increments count.\n" these-commands "\n") + (length all-lines)) + 'face 'org-agenda-dimmed-todo-face)) + org-index--headings))) + + (overlay-put org-index--occur-help-overlay 'display (car org-index--occur-help-text)) + + ;; highlight words + (setq case-fold-search t) + (setq font-lock-keywords-case-fold-search t) + (mapc (lambda (w) (unless (or (not w) (string= w "")) (highlight-regexp (regexp-quote w) 'isearch))) + (cons word words)) + + (setq buffer-read-only t) + + ;; install keyboard-shortcuts + (setq keymap (make-sparse-keymap)) + (set-keymap-parent keymap org-mode-map) + + (mapc (lambda (x) (define-key keymap (kbd x) + (lambda () (interactive) + (message "%s" (org-index--occur-action))))) + (list "" "RET")) + + (define-key keymap (kbd "") + (lambda () (interactive) + (message (org-index--occur-action t)))) + + (define-key keymap (kbd "SPC") + (lambda () (interactive) + (org-index--refresh-parse-table) + ;; increment in index + (let ((ref (org-index--get-or-set-field 'ref)) + count) + (org-index--on + 'ref ref + (setq count (+ 1 (string-to-number (org-index--get-or-set-field 'count)))) + (org-index--get-or-set-field 'count (number-to-string count)) + (org-index--promote-current-line) + (org-index--align-and-fontify-current-line)) + ;; increment in this buffer + (let ((inhibit-read-only t)) + (org-index--get-or-set-field 'count (number-to-string count))) + (message "Incremented count to %d" count)))) + + (define-key keymap (kbd "") + (lambda () (interactive) + (let ((pos (get-text-property (point) 'org-index-lbp))) + (org-index--refresh-parse-table) + (org-index--occur-test-stale pos) + (pop-to-buffer org-index--buffer) + (goto-char pos) + (org-reveal t) + (org-index--update-current-line) + (beginning-of-line)))) + + (define-key keymap (kbd "?") + (lambda () (interactive) + (org-index--refresh-parse-table) + (setq-local org-index--occur-help-text (cons (cdr org-index--occur-help-text) (car org-index--occur-help-text))) + (overlay-put org-index--occur-help-overlay 'display (car org-index--occur-help-text)))) + + (use-local-map keymap)))) + + +(defun org-index--occur-test-stale (pos) + "Test, if current line in occur buffer has become stale at POS." + (let (here there) + (org-index--refresh-parse-table) + (setq here (org-index--line-in-canonical-form)) + (with-current-buffer org-index--buffer + (goto-char pos) + (setq there (org-index--line-in-canonical-form))) + (unless (string= here there) + (error "Occur buffer has become stale")))) + + +(defun org-index--line-in-canonical-form () + "Return current line in its canonical form." + (org-trim (substring-no-properties (replace-regexp-in-string "\s +" " " (buffer-substring (line-beginning-position) (line-beginning-position 2)))))) + + +(defun org-index--wrap (text) + "Wrap TEXT at fill column." + (with-temp-buffer + (insert text) + (fill-region (point-min) (point-max) nil t) + (buffer-string))) + + +(defun org-index--occur-action (&optional other) + "Helper for `org-index--occur', find heading with ref or id; if OTHER, in other window; or copy yank column." + (if (org-at-table-p) + (let ((id (org-index--get-or-set-field 'id)) + (ref (org-index--get-or-set-field 'ref)) + (yank (org-index--get-or-set-field 'yank))) + (if id + (org-index--find-id id other) + (if ref + (progn + (org-mark-ring-goto) + (format "Found reference %s (no node is associated)" ref)) + (if yank + (progn + (org-index--update-line (get-text-property (point) 'org-index-lbp)) + (setq yank (replace-regexp-in-string (regexp-quote "\\vert") "|" yank nil 'literal)) + (kill-new yank) + (org-mark-ring-goto) + (if (string= (substring yank 0 3) "http") + (progn + (browse-url yank) + (format "Opened '%s' in browser (and copied it too)" yank)) + (format "Copied '%s' (no node is associated)" yank))) + (error "Internal error, this line contains neither id, nor reference, nor text to yank"))))) + (message "Not at table"))) + + +(defun org-index--hide-with-overlays (words lines-wanted) + "Hide text that is currently visible and does not match WORDS by creating overlays; leave LINES-WANTED lines visible." + (let ((lines-found 0) + (end-of-visible (point)) + overlay overlays start matched) + + ;; main loop + (while (and (not (eobp)) + (< lines-found lines-wanted)) + + ;; skip invisible lines + (while (and (not (eobp)) + (and + (invisible-p (point)) + (< (point) (overlay-start org-index--occur-tail-overlay)))) + (goto-char (overlay-end (car (overlays-at (point)))))) + + ;; find stretch of lines, that are currently visible but should be invisible now + (setq matched nil) + (setq start (point)) + (while (and (not (eobp)) + (not + (and + (invisible-p (point)) + (< (point) (overlay-start org-index--occur-tail-overlay)))) + (not (and (org-index--test-words words) + (setq matched t)))) ; for its side effect + (forward-line 1)) + + ;; create overlay to hide this stretch + (when (< start (point)) ; avoid creating an empty overlay + (setq overlay (make-overlay start (point))) + (overlay-put overlay 'invisible t) + (setq overlays (cons overlay overlays))) + + ;; skip and count line, that matched + (when matched + (forward-line 1) + (setq end-of-visible (point)) + (cl-incf lines-found))) + + ;; put new list on top of stack + (setq org-index--occur-stack + (cons (list (cons :overlays overlays) + (cons :end-of-visible end-of-visible) + (cons :lines lines-found)) + org-index--occur-stack)) + + lines-found)) + + +(defun org-index--unhide () + "Unhide text that does has been hidden by `org-index--hide-with-overlays'." + (when org-index--occur-stack + ;; delete overlays and make visible again + (mapc (lambda (y) + (delete-overlay y)) + (cdr (assoc :overlays (car org-index--occur-stack)))) + ;; remove from stack + (setq org-index--occur-stack (cdr org-index--occur-stack)) + ;; return number of lines, that are now visible + (if org-index--occur-stack (cdr (assoc :lines (car org-index--occur-stack)))))) + + +(defun org-index--test-words (words) + "Test current line for match against WORDS." + (let (line) + (setq line (downcase (buffer-substring (line-beginning-position) (line-beginning-position 2)))) + (catch 'not-found + (dolist (w words) + (or (cl-search w line) + (throw 'not-found nil))) + t))) + + +(defun org-index--create-new-line () + "Do the common work for `org-index-new-line' and `org-index'." + + ;; insert ref or id as last or first line, depending on sort-column + (goto-char org-index--below-hline) + (if (eq org-index-sort-by 'count) + (progn + (goto-char (org-table-end)) + (forward-line -1) + (org-table-insert-row t)) + (org-table-insert-row)) + + ;; insert some of the standard values + (org-table-goto-column (org-index--column-num 'created)) + (org-insert-time-stamp nil nil t) + (org-table-goto-column (org-index--column-num 'count)) + (insert "1")) + + +(defun org-index--sort-silent () + "Sort index for default column to remove any effects of temporary sorting." + (save-excursion + (org-index--verify-id) + (org-index--parse-table) + (with-current-buffer org-index--buffer + (save-excursion + (goto-char org-index--below-hline) + (org-index--do-sort-index org-index-sort-by) + (remove-hook 'before-save-hook 'org-index--sort-silent))))) + + +(defun org-index--idle-prepare () + "For parsing table when idle." + (org-index--verify-id) + (org-index--parse-table most-positive-fixnum t)) + + +(defun org-index--copy-visible (beg end) + "Copy the visible parts of the region between BEG and END without adding it to `kill-ring'; copy of `org-copy-visible'." + (let (snippets s) + (save-excursion + (save-restriction + (narrow-to-region beg end) + (setq s (goto-char (point-min))) + (while (not (= (point) (point-max))) + (goto-char (org-find-invisible)) + (push (buffer-substring s (point)) snippets) + (setq s (goto-char (org-find-visible)))))) + (apply 'concat (nreverse snippets)))) + + +(provide 'org-index) + +;; Local Variables: +;; fill-column: 75 +;; comment-column: 50 +;; End: + +;;; org-index.el ends here diff --git a/elpa/org-plus-contrib-20170407/org-info.el b/elpa/org-plus-contrib-20170407/org-info.el new file mode 100644 index 00000000..a13903a9 --- /dev/null +++ b/elpa/org-plus-contrib-20170407/org-info.el @@ -0,0 +1,148 @@ +;;; org-info.el --- Support for Links to Info Nodes -*- lexical-binding: t; -*- + +;; Copyright (C) 2004-2017 Free Software Foundation, Inc. + +;; Author: Carsten Dominik +;; 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 . +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;;; Commentary: + +;; This file implements links to Info nodes 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 Info-find-node "info" + (filename nodename &optional no-going-back strict-case)) +(defvar Info-current-file) +(defvar Info-current-node) + +;; Install the link type +(org-link-set-parameters "info" + :follow #'org-info-open + :export #'org-info-export + :store #'org-info-store-link) + +;; Implementation +(defun org-info-store-link () + "Store a link to an Info file and node." + (when (eq major-mode 'Info-mode) + (let ((link (concat "info:" + (file-name-nondirectory Info-current-file) + "#" Info-current-node)) + (desc (concat (file-name-nondirectory Info-current-file) + "#" Info-current-node))) + (org-store-link-props :type "info" :file Info-current-file + :node Info-current-node + :link link :desc desc) + link))) + +(defun org-info-open (path) + "Follow an Info file and node link specified by PATH." + (org-info-follow-link path)) + + +(defun org-info-follow-link (name) + "Follow an Info file and node link specified by NAME." + (if (or (string-match "\\(.*\\)[#:]:?\\(.*\\)" name) + (string-match "\\(.*\\)" name)) + (let ((filename (match-string 1 name)) + (nodename-or-index (or (match-string 2 name) "Top"))) + (require 'info) + ;; If nodename-or-index is invalid node name, then look it up + ;; in the index. + (condition-case nil + (Info-find-node filename nodename-or-index) + (user-error (Info-find-node filename "Top") + (condition-case nil + (Info-index nodename-or-index) + (user-error "Could not find '%s' node or index entry" + nodename-or-index))))) + (user-error "Could not open: %s" name))) + +(defconst org-info-emacs-documents + '("ada-mode" "auth" "autotype" "bovine" "calc" "ccmode" "cl" "dbus" "dired-x" + "ebrowse" "ede" "ediff" "edt" "efaq-w32" "efaq" "eieio" "eintr" "elisp" + "emacs-gnutls" "emacs-mime" "emacs" "epa" "erc" "ert" "eshell" "eudc" "eww" + "flymake" "forms" "gnus" "htmlfontify" "idlwave" "ido" "info" "mairix-el" + "message" "mh-e" "newsticker" "nxml-mode" "octave-mode" "org" "pcl-cvs" + "pgg" "rcirc" "reftex" "remember" "sasl" "sc" "semantic" "ses" "sieve" + "smtpmail" "speedbar" "srecode" "todo-mode" "tramp" "url" "vip" "viper" + "widget" "wisent" "woman") + "List of emacs documents available. +Taken from ") + +(defconst org-info-other-documents + '(("libc" . "http://www.gnu.org/software/libc/manual/html_mono/libc.html") + ("make" . "http://www.gnu.org/software/make/manual/make.html")) + "Alist of documents generated from Texinfo source. +When converting info links to HTML, links to any one of these manuals are +converted to use these URL.") + +(defun org-info-map-html-url (filename) + "Return URL or HTML file associated to Info FILENAME. +If FILENAME refers to an official GNU document, return a URL pointing to +the official page for that document, e.g., use \"gnu.org\" for all Emacs +related documents. Otherwise, append \".html\" extension to FILENAME. +See `org-info-emacs-documents' and `org-info-other-documents' for details." + (cond ((member filename org-info-emacs-documents) + (format "http://www.gnu.org/software/emacs/manual/html_mono/%s.html" + filename)) + ((cdr (assoc filename org-info-other-documents))) + (t (concat filename ".html")))) + +(defun org-info--expand-node-name (node) + "Expand Info NODE to HTML cross reference." + ;; See (info "(texinfo) HTML Xref Node Name Expansion") for the + ;; expansion rule. + (let ((node (replace-regexp-in-string + "\\([ \t\n\r]+\\)\\|\\([^a-zA-Z0-9]\\)" + (lambda (m) + (if (match-end 1) "-" (format "_%04x" (string-to-char m)))) + (org-trim node)))) + (cond ((string= node "") "") + ((string-match-p "\\`[0-9]" node) (concat "g_t" node)) + (t node)))) + +(defun org-info-export (path desc format) + "Export an info link. +See `org-link-parameters' for details about PATH, DESC and FORMAT." + (let* ((parts (split-string path "[#:]:?")) + (manual (car parts)) + (node (or (nth 1 parts) "Top"))) + (pcase format + (`html + (format "%s" + (org-info-map-html-url manual) + (org-info--expand-node-name node) + (or desc path))) + (`texinfo + (let ((title (or desc ""))) + (format "@ref{%s,%s,,%s,}" node title manual))) + (_ nil)))) + +(provide 'org-info) + +;;; org-info.el ends here diff --git a/elpa/org-plus-contrib-20150831/org-inlinetask.el b/elpa/org-plus-contrib-20170407/org-inlinetask.el similarity index 93% rename from elpa/org-plus-contrib-20150831/org-inlinetask.el rename to elpa/org-plus-contrib-20170407/org-inlinetask.el index 7e15b44c..2918d406 100644 --- a/elpa/org-plus-contrib-20150831/org-inlinetask.el +++ b/elpa/org-plus-contrib-20170407/org-inlinetask.el @@ -1,6 +1,6 @@ -;;; org-inlinetask.el --- Tasks independent of outline hierarchy +;;; org-inlinetask.el --- Tasks Independent of Outline Hierarchy -*- lexical-binding: t; -*- -;; Copyright (C) 2009-2015 Free Software Foundation, Inc. +;; Copyright (C) 2009-2017 Free Software Foundation, Inc. ;; ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp @@ -26,7 +26,7 @@ ;; ;;; Commentary: ;; -;; This module implements inline tasks in Org-mode. Inline tasks are +;; 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 @@ -167,9 +167,9 @@ The number of levels is controlled by `org-inlinetask-min-level'." (stars-re (org-inlinetask-outline-regexp)) (task-beg-re (concat stars-re "\\(?:.*\\)")) (task-end-re (concat stars-re "END[ \t]*$"))) - (or (org-looking-at-p task-beg-re) + (or (looking-at-p task-beg-re) (and (re-search-forward "^\\*+[ \t]+" nil t) - (progn (beginning-of-line) (org-looking-at-p task-end-re))))))) + (progn (beginning-of-line) (looking-at-p task-end-re))))))) (defun org-inlinetask-goto-beginning () "Go to the beginning of the inline task at point." @@ -177,7 +177,7 @@ The number of levels is controlled by `org-inlinetask-min-level'." (let ((case-fold-search t) (inlinetask-re (org-inlinetask-outline-regexp))) (re-search-backward inlinetask-re nil t) - (when (org-looking-at-p (concat inlinetask-re "END[ \t]*$")) + (when (looking-at-p (concat inlinetask-re "END[ \t]*$")) (re-search-backward inlinetask-re nil t)))) (defun org-inlinetask-goto-end () @@ -189,17 +189,16 @@ Return point." (inlinetask-re (org-inlinetask-outline-regexp)) (task-end-re (concat inlinetask-re "END[ \t]*$"))) (cond - ((looking-at task-end-re) (forward-line)) + ((looking-at task-end-re)) ((looking-at inlinetask-re) (forward-line) (cond - ((looking-at task-end-re) (forward-line)) + ((looking-at task-end-re)) ((looking-at inlinetask-re)) ((org-inlinetask-in-task-p) - (re-search-forward inlinetask-re nil t) - (forward-line)))) - (t (re-search-forward inlinetask-re nil t) - (forward-line))) + (re-search-forward inlinetask-re nil t)))) + (t (re-search-forward inlinetask-re nil t))) + (end-of-line) (point)))) (defun org-inlinetask-get-task-level () @@ -272,8 +271,7 @@ If the task has an end part, also demote it." (defvar org-indent-indentation-per-level) ; defined in org-indent.el -(defface org-inlinetask - (org-compatible-face 'shadow '((t (:bold t)))) +(defface org-inlinetask '((t :inherit shadow)) "Face for inlinetask headlines." :group 'org-faces) @@ -287,7 +285,7 @@ If the task has an end part, also demote it." ",\\}\\)\\(\\*\\* .*\\)")) ;; Virtual indentation will add the warning face on the first ;; star. Thus, in that case, only hide it. - (start-face (if (and (org-bound-and-true-p org-indent-mode) + (start-face (if (and (bound-and-true-p org-indent-mode) (> org-indent-indentation-per-level 1)) 'org-hide 'org-warning))) @@ -322,15 +320,15 @@ If the task has an end part, also demote it." (defun org-inlinetask-hide-tasks (state) "Hide inline tasks in buffer when STATE is `contents' or `children'. This function is meant to be used in `org-cycle-hook'." - (case state - (contents + (pcase state + (`contents (let ((regexp (org-inlinetask-outline-regexp))) (save-excursion (goto-char (point-min)) (while (re-search-forward regexp nil t) (org-inlinetask-toggle-visibility) (org-inlinetask-goto-end))))) - (children + (`children (save-excursion (while (and (outline-next-heading) (org-inlinetask-at-task-p)) (org-inlinetask-toggle-visibility) diff --git a/elpa/org-plus-contrib-20150831/org-install.el b/elpa/org-plus-contrib-20170407/org-install.el similarity index 100% rename from elpa/org-plus-contrib-20150831/org-install.el rename to elpa/org-plus-contrib-20170407/org-install.el diff --git a/elpa/org-plus-contrib-20150831/org-interactive-query.el b/elpa/org-plus-contrib-20170407/org-interactive-query.el similarity index 99% rename from elpa/org-plus-contrib-20150831/org-interactive-query.el rename to elpa/org-plus-contrib-20170407/org-interactive-query.el index 644132c8..147ddaec 100644 --- a/elpa/org-plus-contrib-20150831/org-interactive-query.el +++ b/elpa/org-plus-contrib-20170407/org-interactive-query.el @@ -1,6 +1,6 @@ ;;; org-interactive-query.el --- Interactive modification of agenda query ;; -;; Copyright 2007-2014 Free Software Foundation, Inc. +;; Copyright 2007-2017 Free Software Foundation, Inc. ;; ;; Author: Christopher League ;; Version: 1.0 @@ -81,7 +81,7 @@ not change the current one." (split-window-vertically) (org-switch-to-buffer-other-window (get-buffer-create " *Org tags*"))) (erase-buffer) - (org-set-local 'org-done-keywords done-keywords) + (setq-local org-done-keywords done-keywords) (insert "Query: " current "\n") (org-agenda-query-op-line op) (insert "\n\n") diff --git a/elpa/org-plus-contrib-20150831/org-invoice.el b/elpa/org-plus-contrib-20170407/org-invoice.el similarity index 93% rename from elpa/org-plus-contrib-20150831/org-invoice.el rename to elpa/org-plus-contrib-20170407/org-invoice.el index c1340a73..68688941 100644 --- a/elpa/org-plus-contrib-20150831/org-invoice.el +++ b/elpa/org-plus-contrib-20170407/org-invoice.el @@ -55,6 +55,8 @@ (require 'cl) (require 'org)) +(declare-function org-duration-from-minutes "org-duration" (minutes &optional fmt fractional)) + (defgroup org-invoice nil "OrgMode Invoice Helper" :tag "Org-Invoice" :group 'org) @@ -159,7 +161,7 @@ looks like tree2, where the level is 2." (setq title (replace-match "" nil nil title))) (when (string-match "[ \t]+$" title) (setq title (replace-match "" nil nil title))) - (setq work (org-hh:mm-string-to-minutes work)) + (setq work (org-duration-to-minutes work)) (setq rate (string-to-number rate)) (setq org-invoice-current-item (list (cons 'title title) (cons 'date date) @@ -176,8 +178,8 @@ looks like tree2, where the level is 2." "Return a list where the car is the min level, and the cdr the max." (let ((max 0) min level) (dolist (info ls) - (when (cdr (assoc 'date info)) - (setq level (cdr (assoc 'level info))) + (when (cdr (assq 'date info)) + (setq level (cdr (assq 'level info))) (when (or (not min) (< level min)) (setq min level)) (when (> level max) (setq max level)))) (cons (or min 0) max))) @@ -186,11 +188,11 @@ looks like tree2, where the level is 2." "Reorganize the given list by dates." (let ((min-max (org-invoice-level-min-max ls)) new) (dolist (info ls) - (let* ((date (cdr (assoc 'date info))) - (work (cdr (assoc 'work info))) - (price (cdr (assoc 'price info))) - (long-date (cdr (assoc 'long-date info))) - (level (cdr (assoc 'level info))) + (let* ((date (cdr (assq 'date info))) + (work (cdr (assq 'work info))) + (price (cdr (assq 'price info))) + (long-date (cdr (assq 'long-date info))) + (level (cdr (assq 'level info))) (bucket (cdr (assoc date new)))) (if (and (/= (car min-max) (cdr min-max)) (= (car min-max) level) @@ -208,26 +210,26 @@ looks like tree2, where the level is 2." (push (cons date bucket) new) (setq bucket (cdr (assoc date new)))) (when (and date bucket) - (setcdr (assoc 'total-work (car bucket)) - (+ work (cdr (assoc 'total-work (car bucket))))) - (setcdr (assoc 'price (car bucket)) - (+ price (cdr (assoc 'price (car bucket))))) + (setcdr (assq 'total-work (car bucket)) + (+ work (cdr (assq 'total-work (car bucket))))) + (setcdr (assq 'price (car bucket)) + (+ price (cdr (assq 'price (car bucket))))) (nconc bucket (list info)))))) (nreverse new))) (defun org-invoice-info-to-table (info) "Create a single org table row from the given info alist." - (let ((title (cdr (assoc 'title info))) - (total (cdr (assoc 'total-work info))) - (work (cdr (assoc 'work info))) - (price (cdr (assoc 'price info))) + (let ((title (cdr (assq 'title info))) + (total (cdr (assq 'total-work info))) + (work (cdr (assq 'work info))) + (price (cdr (assq 'price info))) (with-price (plist-get org-invoice-table-params :price))) (unless total (setq org-invoice-total-time (+ org-invoice-total-time work) org-invoice-total-price (+ org-invoice-total-price price))) - (setq total (and total (org-minutes-to-clocksum-string total))) - (setq work (and work (org-minutes-to-clocksum-string work))) + (setq total (and total (org-duration-from-minutes total))) + (setq work (and work (org-duration-from-minutes work))) (insert-before-markers (concat "|" title (cond @@ -251,7 +253,7 @@ looks like tree2, where the level is 2." (when with-summary (insert-before-markers (concat "|-\n|Total:|" - (org-minutes-to-clocksum-string org-invoice-total-time) + (org-duration-from-minutes org-invoice-total-time) (and with-price (concat "|" (format "%.2f" org-invoice-total-price))) "|\n"))))) diff --git a/elpa/org-plus-contrib-20150831/org-irc.el b/elpa/org-plus-contrib-20170407/org-irc.el similarity index 90% rename from elpa/org-plus-contrib-20150831/org-irc.el rename to elpa/org-plus-contrib-20170407/org-irc.el index 62f3d959..3a6a7f4d 100644 --- a/elpa/org-plus-contrib-20150831/org-irc.el +++ b/elpa/org-plus-contrib-20170407/org-irc.el @@ -1,6 +1,6 @@ -;;; org-irc.el --- Store links to IRC sessions +;;; org-irc.el --- Store Links to IRC Sessions -*- lexical-binding: t; -*- ;; -;; Copyright (C) 2008-2015 Free Software Foundation, Inc. +;; Copyright (C) 2008-2017 Free Software Foundation, Inc. ;; ;; Author: Philip Jackson ;; Keywords: erc, irc, link, org @@ -22,8 +22,8 @@ ;;; Commentary: -;; This file implements links to an IRC session from within Org-mode. -;; Org-mode loads this module by default - if this is not what you want, +;; This file implements links to an IRC session from within Org mode. +;; Org mode loads this module by default - if this is not what you want, ;; configure the variable `org-modules'. ;; ;; Please customize the variable `org-modules' to select @@ -59,8 +59,6 @@ (declare-function erc-server-buffer "erc" ()) (declare-function erc-get-server-nickname-list "erc" ()) (declare-function erc-cmd-JOIN "erc" (channel &optional key)) -(declare-function org-pop-to-buffer-same-window - "org-compat" (&optional buffer-or-name norecord label)) (defvar org-irc-client 'erc "The IRC client to act on.") @@ -73,9 +71,7 @@ ;; Generic functions/config (extend these for other clients) -(add-to-list 'org-store-link-functions 'org-irc-store-link) - -(org-add-link-type "irc" 'org-irc-visit nil) +(org-link-set-parameters "irc" :follow #'org-irc-visit :store #'org-irc-store-link) (defun org-irc-visit (link) "Parse LINK and dispatch to the correct function based on the client found." @@ -108,17 +104,15 @@ attributes that are found." (defun org-irc-ellipsify-description (string &optional after) "Remove unnecessary white space from STRING and add ellipses if necessary. Strip starting and ending white space from STRING and replace any -chars that the value AFTER with '...'" +chars that the value AFTER with `...'" (let* ((after (number-to-string (or after 30))) (replace-map (list (cons "^[ \t]*" "") (cons "[ \t]*$" "") (cons (concat "^\\(.\\{" after "\\}\\).*") "\\1...")))) - (mapc (lambda (x) - (when (string-match (car x) string) - (setq string (replace-match (cdr x) nil nil string)))) - replace-map) - string)) + (dolist (x replace-map string) + (when (string-match (car x) string) + (setq string (replace-match (cdr x) nil nil string)))))) ;; ERC specific functions @@ -172,7 +166,7 @@ the session itself." (org-store-link-props :type "irc" :link (concat "irc:/" link-text) - :description (concat "irc session '" link-text "'") + :description (concat "irc session `" link-text "'") :server (car (car link)) :port (or (string-to-number (cadr (pop link))) erc-default-port) :nick (pop link)) @@ -233,7 +227,7 @@ default." (throw 'found x)))))) (if chan-buf (progn - (org-pop-to-buffer-same-window chan-buf) + (pop-to-buffer-same-window chan-buf) ;; if we got a nick, and they're in the chan, ;; then start a chat with them (let ((nick (pop link))) @@ -244,9 +238,9 @@ default." (insert (concat nick ": "))) (error "%s not found in %s" nick chan-name))))) (progn - (org-pop-to-buffer-same-window server-buffer) + (pop-to-buffer-same-window server-buffer) (erc-cmd-JOIN chan-name)))) - (org-pop-to-buffer-same-window server-buffer))) + (pop-to-buffer-same-window server-buffer))) ;; no server match, make new connection (erc-select :server server :port port)))) diff --git a/elpa/org-plus-contrib-20150831/org-learn.el b/elpa/org-plus-contrib-20170407/org-learn.el similarity index 99% rename from elpa/org-plus-contrib-20150831/org-learn.el rename to elpa/org-plus-contrib-20170407/org-learn.el index 1755e712..db9580f8 100644 --- a/elpa/org-plus-contrib-20150831/org-learn.el +++ b/elpa/org-plus-contrib-20170407/org-learn.el @@ -1,6 +1,6 @@ ;;; org-learn.el --- Implements SuperMemo's incremental learning algorithm -;; Copyright (C) 2009-2014 Free Software Foundation, Inc. +;; Copyright (C) 2009-2017 Free Software Foundation, Inc. ;; Author: John Wiegley ;; Keywords: outlines, hypermedia, calendar, wp diff --git a/elpa/org-plus-contrib-20150831/org-license.el b/elpa/org-plus-contrib-20170407/org-license.el similarity index 99% rename from elpa/org-plus-contrib-20150831/org-license.el rename to elpa/org-plus-contrib-20170407/org-license.el index 426b148f..2fad68ff 100644 --- a/elpa/org-plus-contrib-20150831/org-license.el +++ b/elpa/org-plus-contrib-20170407/org-license.el @@ -1,6 +1,6 @@ ;;; org-license.el --- Add a license to your org files -;; Copyright (C) 2013 Free Software Foundation, Inc. +;; Copyright (C) 2013-2017 Free Software Foundation, Inc. ;; Author: David Arroyo Menéndez ;; Keywords: licenses, creative commons diff --git a/elpa/org-plus-contrib-20170407/org-link-edit.el b/elpa/org-plus-contrib-20170407/org-link-edit.el new file mode 100644 index 00000000..431c934e --- /dev/null +++ b/elpa/org-plus-contrib-20170407/org-link-edit.el @@ -0,0 +1,327 @@ +;;; org-link-edit.el --- Slurp and barf with Org links -*- lexical-binding: t; -*- + +;; Copyright (C) 2015 Kyle Meyer + +;; Author: Kyle Meyer +;; URL: https://github.com/kyleam/org-link-edit +;; Keywords: convenience +;; Version: 1.0.1 +;; Package-Requires: ((cl-lib "0.5") (org "8.2")) + +;; 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 . + +;;; Commentary: + +;; Org Link Edit provides Paredit-inspired slurping and barfing +;; commands for Org link descriptions. +;; +;; There are four commands, all which operate when point is on an Org +;; link. +;; +;; - org-link-edit-forward-slurp +;; - org-link-edit-backward-slurp +;; - org-link-edit-forward-barf +;; - org-link-edit-backward-barf +;; +;; Org Link Edit doesn't bind these commands to any keys. Finding +;; good keys for these commands is difficult because, while it's +;; convenient to be able to quickly repeat these commands, they won't +;; be used frequently enough to be worthy of a short, repeat-friendly +;; binding. Using Hydra [1] provides a nice solution to this. After +;; an initial key sequence, any of the commands will be repeatable +;; with a single key. (Plus, you get a nice interface that displays +;; the key for each command.) Below is one example of how you could +;; configure this. +;; +;; (define-key org-mode-map YOUR-KEY +;; (defhydra hydra-org-link-edit () +;; "Org Link Edit" +;; ("j" org-link-edit-forward-slurp "forward slurp") +;; ("k" org-link-edit-forward-barf "forward barf") +;; ("u" org-link-edit-backward-slurp "backward slurp") +;; ("i" org-link-edit-backward-barf "backward barf") +;; ("q" nil "cancel"))) +;; +;; [1] https://github.com/abo-abo/hydra + +;;; Code: + +(require 'org) +(require 'org-element) +(require 'cl-lib) + +(defun org-link-edit--get-link-data () + "Return list with information about the link at point. +The list includes +- the position at the start of the link +- the position at the end of the link +- the link text +- the link description (nil when on a plain link)" + (let ((el (org-element-context))) + ;; Don't use `org-element-lineage' because it isn't available + ;; until Org version 8.3. + (while (and el (not (memq (car el) '(link)))) + (setq el (org-element-property :parent el))) + (unless (eq (car el) 'link) + (user-error "Point is not on a link")) + (save-excursion + (goto-char (org-element-property :begin el)) + (cond + ;; Use match-{beginning,end} because match-end is consistently + ;; positioned after ]], while the :end property is positioned + ;; at the next word on the line, if one is present. + ((looking-at org-bracket-link-regexp) + (list (match-beginning 0) + (match-end 0) + (org-link-unescape (match-string-no-properties 1)) + (or (and (match-end 3) + (match-string-no-properties 3)) + ""))) + ((looking-at org-plain-link-re) + (list (match-beginning 0) + (match-end 0) + (org-link-unescape (match-string-no-properties 0)) + nil)) + (t + (error "What am I looking at?")))))) + +(defun org-link-edit--forward-blob (n &optional no-punctuation) + "Move forward N blobs (backward if N is negative). + +A block of non-whitespace characters is a blob. If +NO-PUNCTUATION is non-nil, trailing punctuation characters are +not considered part of the blob when going in the forward +direction. + +If the edge of the buffer is reached before completing the +movement, return nil. Otherwise, return t." + (let* ((forward-p (> n 0)) + (nblobs (abs n)) + (skip-func (if forward-p 'skip-syntax-forward 'skip-syntax-backward)) + skip-func-retval) + (while (/= nblobs 0) + (funcall skip-func " ") + (setq skip-func-retval (funcall skip-func "^ ")) + (setq nblobs (1- nblobs))) + (when (and forward-p no-punctuation) + (let ((punc-tail-offset (save-excursion (skip-syntax-backward ".")))) + ;; Don't consider trailing punctuation as part of the blob + ;; unless the whole blob consists of punctuation. + (unless (= skip-func-retval (- punc-tail-offset)) + (goto-char (+ (point) punc-tail-offset))))) + (/= skip-func-retval 0))) + +;;;###autoload +(defun org-link-edit-forward-slurp (&optional n) + "Slurp N trailing blobs into link's description. + + The \[\[http://orgmode.org/\]\[Org mode\]\] site + + | + v + + The \[\[http://orgmode.org/\]\[Org mode site\]\] + +A blob is a block of non-whitespace characters. When slurping +forward, trailing punctuation characters are not considered part +of a blob. + +After slurping, return the slurped text and move point to the +beginning of the link. + +If N is negative, slurp leading blobs instead of trailing blobs." + (interactive "p") + (setq n (or n 1)) + (cond + ((= n 0)) + ((< n 0) + (org-link-edit-backward-slurp (- n))) + (t + (cl-multiple-value-bind (beg end link desc) (org-link-edit--get-link-data) + (goto-char (save-excursion + (goto-char end) + (or (org-link-edit--forward-blob n 'no-punctuation) + (user-error "Not enough blobs after the link")) + (point))) + (let ((slurped (buffer-substring-no-properties end (point)))) + (setq slurped (replace-regexp-in-string "\n+" " " slurped)) + (when (and (= (length desc) 0) + (string-match "^\\s-+\\(.*\\)" slurped)) + (setq slurped (match-string 1 slurped))) + (setq desc (concat desc slurped) + end (+ end (length slurped))) + (delete-region beg (point)) + (insert (org-make-link-string link desc)) + (goto-char beg) + slurped))))) + +;;;###autoload +(defun org-link-edit-backward-slurp (&optional n) + "Slurp N leading blobs into link's description. + + The \[\[http://orgmode.org/\]\[Org mode\]\] site + + | + v + + \[\[http://orgmode.org/\]\[The Org mode\]\] site + +A blob is a block of non-whitespace characters. + +After slurping, return the slurped text and move point to the +beginning of the link. + +If N is negative, slurp trailing blobs instead of leading blobs." + (interactive "p") + (setq n (or n 1)) + (cond + ((= n 0)) + ((< n 0) + (org-link-edit-forward-slurp (- n))) + (t + (cl-multiple-value-bind (beg end link desc) (org-link-edit--get-link-data) + (goto-char (save-excursion + (goto-char beg) + (or (org-link-edit--forward-blob (- n)) + (user-error "Not enough blobs before the link")) + (point))) + (let ((slurped (buffer-substring-no-properties (point) beg))) + (when (and (= (length desc) 0) + (string-match "\\(.*\\)\\s-+$" slurped)) + (setq slurped (match-string 1 slurped))) + (setq slurped (replace-regexp-in-string "\n+" " " slurped)) + (setq desc (concat slurped desc) + beg (- beg (length slurped))) + (delete-region (point) end) + (insert (org-make-link-string link desc)) + (goto-char beg) + slurped))))) + +(defun org-link-edit--split-first-blobs (string n) + "Split STRING into (N first blobs . other) cons cell. +'N first blobs' contains all text from the start of STRING up to +the start of the N+1 blob. 'other' includes the remaining text +of STRING. If the number of blobs in STRING is fewer than N, +'other' is nil." + (when (< n 0) (user-error "N cannot be negative")) + (with-temp-buffer + (insert string) + (goto-char (point-min)) + (with-syntax-table org-mode-syntax-table + (let ((within-bound (org-link-edit--forward-blob n))) + (skip-syntax-forward " ") + (cons (buffer-substring 1 (point)) + (and within-bound + (buffer-substring (point) (point-max)))))))) + +(defun org-link-edit--split-last-blobs (string n) + "Split STRING into (other . N last blobs) cons cell. +'N last blobs' contains all text from the end of STRING back to +the end of the N+1 last blob. 'other' includes the remaining +text of STRING. If the number of blobs in STRING is fewer than +N, 'other' is nil." + (when (< n 0) (user-error "N cannot be negative")) + (with-temp-buffer + (insert string) + (goto-char (point-max)) + (with-syntax-table org-mode-syntax-table + (let ((within-bound (org-link-edit--forward-blob (- n)))) + (skip-syntax-backward " ") + (cons (and within-bound + (buffer-substring 1 (point))) + (buffer-substring (point) (point-max))))))) + +;;;###autoload +(defun org-link-edit-forward-barf (&optional n) + "Barf N trailing blobs from link's description. + + The \[\[http://orgmode.org/\]\[Org mode\]\] site + + | + v + + The \[\[http://orgmode.org/\]\[Org\]\] mode site + +A blob is a block of non-whitespace characters. + +After barfing, return the barfed text and move point to the +beginning of the link. + +If N is negative, barf leading blobs instead of trailing blobs." + (interactive "p") + (setq n (or n 1)) + (cond + ((= n 0)) + ((< n 0) + (org-link-edit-backward-barf (- n))) + (t + (cl-multiple-value-bind (beg end link desc) (org-link-edit--get-link-data) + (when (= (length desc) 0) + (user-error "Link has no description")) + (pcase-let ((`(,new-desc . ,barfed) (org-link-edit--split-last-blobs + desc n))) + (unless new-desc (user-error "Not enough blobs in description")) + (delete-region beg end) + (insert (org-make-link-string link new-desc)) + (if (string= new-desc "") + ;; Two brackets are dropped when an empty description is + ;; passed to `org-make-link-string'. + (progn (goto-char (- end (+ 2 (length desc)))) + (setq barfed (concat " " barfed))) + (goto-char (- end (- (length desc) (length new-desc))))) + (insert barfed) + (goto-char beg) + barfed))))) + +;;;###autoload +(defun org-link-edit-backward-barf (&optional n) + "Barf N leading blobs from link's description. + + The \[\[http://orgmode.org/\]\[Org mode\]\] site + + | + v + + The Org \[\[http://orgmode.org/\]\[mode\]\] site + +A blob is a block of non-whitespace characters. + +After barfing, return the barfed text and move point to the +beginning of the link. + +If N is negative, barf trailing blobs instead of leading blobs." + (interactive "p") + (setq n (or n 1)) + (cond + ((= n 0)) + ((< n 0) + (org-link-edit-forward-barf (- n))) + (t + (cl-multiple-value-bind (beg end link desc) (org-link-edit--get-link-data) + (when (= (length desc) 0) + (user-error "Link has no description")) + (pcase-let ((`(,barfed . ,new-desc) (org-link-edit--split-first-blobs + desc n))) + (unless new-desc (user-error "Not enough blobs in description")) + (delete-region beg end) + (insert (org-make-link-string link new-desc)) + (when (string= new-desc "") + (setq barfed (concat barfed " "))) + (goto-char beg) + (insert barfed) + (goto-char (+ beg (length barfed))) + barfed))))) + +(provide 'org-link-edit) +;;; org-link-edit.el ends here diff --git a/elpa/org-plus-contrib-20170407/org-lint.el b/elpa/org-plus-contrib-20170407/org-lint.el new file mode 100644 index 00000000..735c06e5 --- /dev/null +++ b/elpa/org-plus-contrib-20170407/org-lint.el @@ -0,0 +1,1240 @@ +;;; org-lint.el --- Linting for Org documents -*- lexical-binding: t; -*- + +;; Copyright (C) 2015-2017 Free Software Foundation + +;; Author: Nicolas Goaziou +;; Keywords: outlines, hypermedia, calendar, wp + +;; 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 . + +;;; Commentary: + +;; This library implements linting for Org syntax. The sole public +;; function is `org-lint', which see. + +;; Internally, the library defines a new structure: +;; `org-lint-checker', with the following slots: + +;; - NAME: Unique check identifier, as a non-nil symbol that doesn't +;; start with an hyphen. +;; +;; The check is done calling the function `org-lint-NAME' with one +;; mandatory argument, the parse tree describing the current Org +;; buffer. Such function calls are wrapped within +;; a `save-excursion' and point is always at `point-min'. Its +;; return value has to be an alist (POSITION MESSAGE) when +;; POSITION refer to the buffer position of the error, as an +;; integer, and MESSAGE is a string describing the error. + +;; - DESCRIPTION: Summary about the check, as a string. + +;; - CATEGORIES: Categories relative to the check, as a list of +;; symbol. They are used for filtering when calling `org-lint'. +;; Checkers not explicitly associated to a category are collected +;; in the `default' one. + +;; - TRUST: The trust level one can have in the check. It is either +;; `low' or `high', depending on the heuristics implemented and +;; the nature of the check. This has an indicative value only and +;; is displayed along reports. + +;; All checks have to be listed in `org-lint--checkers'. + +;; Results are displayed in a special "*Org Lint*" buffer with +;; a dedicated major mode, derived from `tabulated-list-mode'. +;; +;; In addition to the usual key-bindings inherited from it, "C-j" and +;; "TAB" display problematic line reported under point whereas "RET" +;; jumps to it. Also, "h" hides all reports similar to the current +;; one. Additionally, "i" removes them from subsequent reports. + +;; Checks currently implemented are: + +;; - duplicate CUSTOM_ID properties +;; - duplicate NAME values +;; - duplicate targets +;; - duplicate footnote definitions +;; - orphaned affiliated keywords +;; - obsolete affiliated keywords +;; - missing language in src blocks +;; - missing back-end in export blocks +;; - invalid Babel call blocks +;; - NAME values with a colon +;; - deprecated export block syntax +;; - deprecated Babel header properties +;; - wrong header arguments in src blocks +;; - misuse of CATEGORY keyword +;; - "coderef" links with unknown destination +;; - "custom-id" links with unknown destination +;; - "fuzzy" links with unknown destination +;; - "id" links with unknown destination +;; - links to non-existent local files +;; - SETUPFILE keywords with non-existent file parameter +;; - INCLUDE keywords with wrong link parameter +;; - obsolete markup in INCLUDE keyword +;; - unknown items in OPTIONS keyword +;; - spurious macro arguments or invalid macro templates +;; - special properties in properties drawer +;; - obsolete syntax for PROPERTIES drawers +;; - Invalid EFFORT property value +;; - missing definition for footnote references +;; - missing reference for footnote definitions +;; - non-footnote definitions in footnote section +;; - probable invalid keywords +;; - invalid blocks +;; - misplaced planning info line +;; - incomplete drawers +;; - indented diary-sexps +;; - obsolete QUOTE section +;; - obsolete "file+application" link +;; - blank headlines with tags + + +;;; Code: + +(require 'cl-lib) +(require 'org-element) +(require 'org-macro) +(require 'ox) +(require 'ob) + + +;;; Checkers + +(cl-defstruct (org-lint-checker (:copier nil)) + (name 'missing-checker-name) + (description "") + (categories '(default)) + (trust 'high)) ; `low' or `high' + +(defun org-lint-missing-checker-name (_) + (error + "`A checker has no `:name' property. Please verify `org-lint--checkers'")) + +(defconst org-lint--checkers + (list + (make-org-lint-checker + :name 'duplicate-custom-id + :description "Report duplicates CUSTOM_ID properties" + :categories '(link)) + (make-org-lint-checker + :name 'duplicate-name + :description "Report duplicate NAME values" + :categories '(babel link)) + (make-org-lint-checker + :name 'duplicate-target + :description "Report duplicate targets" + :categories '(link)) + (make-org-lint-checker + :name 'duplicate-footnote-definition + :description "Report duplicate footnote definitions" + :categories '(footnote)) + (make-org-lint-checker + :name 'orphaned-affiliated-keywords + :description "Report orphaned affiliated keywords" + :trust 'low) + (make-org-lint-checker + :name 'obsolete-affiliated-keywords + :description "Report obsolete affiliated keywords" + :categories '(obsolete)) + (make-org-lint-checker + :name 'deprecated-export-blocks + :description "Report deprecated export block syntax" + :categories '(obsolete export) + :trust 'low) + (make-org-lint-checker + :name 'deprecated-header-syntax + :description "Report deprecated Babel header syntax" + :categories '(obsolete babel) + :trust 'low) + (make-org-lint-checker + :name 'missing-language-in-src-block + :description "Report missing language in src blocks" + :categories '(babel)) + (make-org-lint-checker + :name 'missing-backend-in-export-block + :description "Report missing back-end in export blocks" + :categories '(export)) + (make-org-lint-checker + :name 'invalid-babel-call-block + :description "Report invalid Babel call blocks" + :categories '(babel)) + (make-org-lint-checker + :name 'colon-in-name + :description "Report NAME values with a colon" + :categories '(babel)) + (make-org-lint-checker + :name 'wrong-header-argument + :description "Report wrong babel headers" + :categories '(babel)) + (make-org-lint-checker + :name 'wrong-header-value + :description "Report invalid value in babel headers" + :categories '(babel) + :trust 'low) + (make-org-lint-checker + :name 'deprecated-category-setup + :description "Report misuse of CATEGORY keyword" + :categories '(obsolete)) + (make-org-lint-checker + :name 'invalid-coderef-link + :description "Report \"coderef\" links with unknown destination" + :categories '(link)) + (make-org-lint-checker + :name 'invalid-custom-id-link + :description "Report \"custom-id\" links with unknown destination" + :categories '(link)) + (make-org-lint-checker + :name 'invalid-fuzzy-link + :description "Report \"fuzzy\" links with unknown destination" + :categories '(link)) + (make-org-lint-checker + :name 'invalid-id-link + :description "Report \"id\" links with unknown destination" + :categories '(link)) + (make-org-lint-checker + :name 'link-to-local-file + :description "Report links to non-existent local files" + :categories '(link) + :trust 'low) + (make-org-lint-checker + :name 'non-existent-setupfile-parameter + :description "Report SETUPFILE keywords with non-existent file parameter" + :trust 'low) + (make-org-lint-checker + :name 'wrong-include-link-parameter + :description "Report INCLUDE keywords with misleading link parameter" + :categories '(export) + :trust 'low) + (make-org-lint-checker + :name 'obsolete-include-markup + :description "Report obsolete markup in INCLUDE keyword" + :categories '(obsolete export) + :trust 'low) + (make-org-lint-checker + :name 'unknown-options-item + :description "Report unknown items in OPTIONS keyword" + :categories '(export) + :trust 'low) + (make-org-lint-checker + :name 'invalid-macro-argument-and-template + :description "Report spurious macro arguments or invalid macro templates" + :categories '(export) + :trust 'low) + (make-org-lint-checker + :name 'special-property-in-properties-drawer + :description "Report special properties in properties drawers" + :categories '(properties)) + (make-org-lint-checker + :name 'obsolete-properties-drawer + :description "Report obsolete syntax for properties drawers" + :categories '(obsolete properties)) + (make-org-lint-checker + :name 'invalid-effort-property + :description "Report invalid duration in EFFORT property" + :categories '(properties)) + (make-org-lint-checker + :name 'undefined-footnote-reference + :description "Report missing definition for footnote references" + :categories '(footnote)) + (make-org-lint-checker + :name 'unreferenced-footnote-definition + :description "Report missing reference for footnote definitions" + :categories '(footnote)) + (make-org-lint-checker + :name 'extraneous-element-in-footnote-section + :description "Report non-footnote definitions in footnote section" + :categories '(footnote)) + (make-org-lint-checker + :name 'invalid-keyword-syntax + :description "Report probable invalid keywords" + :trust 'low) + (make-org-lint-checker + :name 'invalid-block + :description "Report invalid blocks" + :trust 'low) + (make-org-lint-checker + :name 'misplaced-planning-info + :description "Report misplaced planning info line" + :trust 'low) + (make-org-lint-checker + :name 'incomplete-drawer + :description "Report probable incomplete drawers" + :trust 'low) + (make-org-lint-checker + :name 'indented-diary-sexp + :description "Report probable indented diary-sexps" + :trust 'low) + (make-org-lint-checker + :name 'quote-section + :description "Report obsolete QUOTE section" + :categories '(obsolete) + :trust 'low) + (make-org-lint-checker + :name 'file-application + :description "Report obsolete \"file+application\" link" + :categories '(link obsolete)) + (make-org-lint-checker + :name 'empty-headline-with-tags + :description "Report ambiguous empty headlines with tags" + :categories '(headline) + :trust 'low)) + "List of all available checkers.") + +(defun org-lint--collect-duplicates + (ast type extract-key extract-position build-message) + "Helper function to collect duplicates in parse tree AST. + +EXTRACT-KEY is a function extracting key. It is called with +a single argument: the element or object. Comparison is done +with `equal'. + +EXTRACT-POSITION is a function returning position for the report. +It is called with two arguments, the object or element, and the +key. + +BUILD-MESSAGE is a function creating the report message. It is +called with one argument, the key used for comparison." + (let* (keys + originals + reports + (make-report + (lambda (position value) + (push (list position (funcall build-message value)) reports)))) + (org-element-map ast type + (lambda (datum) + (let ((key (funcall extract-key datum))) + (cond + ((not key)) + ((assoc key keys) (cl-pushnew (assoc key keys) originals) + (funcall make-report (funcall extract-position datum key) key)) + (t (push (cons key (funcall extract-position datum key)) keys)))))) + (dolist (e originals reports) (funcall make-report (cdr e) (car e))))) + +(defun org-lint-duplicate-custom-id (ast) + (org-lint--collect-duplicates + ast + 'node-property + (lambda (property) + (and (eq (compare-strings "CUSTOM_ID" nil nil + (org-element-property :key property) nil nil + t) + t) + (org-element-property :value property))) + (lambda (property _) (org-element-property :begin property)) + (lambda (key) (format "Duplicate CUSTOM_ID property \"%s\"" key)))) + +(defun org-lint-duplicate-name (ast) + (org-lint--collect-duplicates + ast + org-element-all-elements + (lambda (datum) (org-element-property :name datum)) + (lambda (datum name) + (goto-char (org-element-property :begin datum)) + (re-search-forward + (format "^[ \t]*#\\+[A-Za-z]+: +%s *$" (regexp-quote name))) + (match-beginning 0)) + (lambda (key) (format "Duplicate NAME \"%s\"" key)))) + +(defun org-lint-duplicate-target (ast) + (org-lint--collect-duplicates + ast + 'target + (lambda (target) (org-split-string (org-element-property :value target))) + (lambda (target _) (org-element-property :begin target)) + (lambda (key) + (format "Duplicate target <<%s>>" (mapconcat #'identity key " "))))) + +(defun org-lint-duplicate-footnote-definition (ast) + (org-lint--collect-duplicates + ast + 'footnote-definition + (lambda (definition) (org-element-property :label definition)) + (lambda (definition _) (org-element-property :post-affiliated definition)) + (lambda (key) (format "Duplicate footnote definition \"%s\"" key)))) + +(defun org-lint-orphaned-affiliated-keywords (ast) + ;; Ignore orphan RESULTS keywords, which could be generated from + ;; a source block returning no value. + (let ((keywords (cl-set-difference org-element-affiliated-keywords + '("RESULT" "RESULTS") + :test #'equal))) + (org-element-map ast 'keyword + (lambda (k) + (let ((key (org-element-property :key k))) + (and (or (let ((case-fold-search t)) + (string-match-p "\\`ATTR_[-_A-Za-z0-9]+\\'" key)) + (member key keywords)) + (list (org-element-property :post-affiliated k) + (format "Orphaned affiliated keyword: \"%s\"" key)))))))) + +(defun org-lint-obsolete-affiliated-keywords (_) + (let ((regexp (format "^[ \t]*#\\+%s:" + (regexp-opt '("DATA" "LABEL" "RESNAME" "SOURCE" + "SRCNAME" "TBLNAME" "RESULT" "HEADERS") + t))) + reports) + (while (re-search-forward regexp nil t) + (let ((key (upcase (match-string-no-properties 1)))) + (when (< (point) + (org-element-property :post-affiliated (org-element-at-point))) + (push + (list (line-beginning-position) + (format + "Obsolete affiliated keyword: \"%s\". Use \"%s\" instead" + key + (pcase key + ("HEADERS" "HEADER") + ("RESULT" "RESULTS") + (_ "NAME")))) + reports)))) + reports)) + +(defun org-lint-deprecated-export-blocks (ast) + (let ((deprecated '("ASCII" "BEAMER" "HTML" "LATEX" "MAN" "MARKDOWN" "MD" + "ODT" "ORG" "TEXINFO"))) + (org-element-map ast 'special-block + (lambda (b) + (let ((type (org-element-property :type b))) + (when (member-ignore-case type deprecated) + (list + (org-element-property :post-affiliated b) + (format + "Deprecated syntax for export block. Use \"BEGIN_EXPORT %s\" \ +instead" + type)))))))) + +(defun org-lint-deprecated-header-syntax (ast) + (let* ((deprecated-babel-properties + (mapcar (lambda (arg) (symbol-name (car arg))) + org-babel-common-header-args-w-values)) + (deprecated-re + (format "\\`%s[ \t]" (regexp-opt deprecated-babel-properties t)))) + (org-element-map ast '(keyword node-property) + (lambda (datum) + (let ((key (org-element-property :key datum))) + (pcase (org-element-type datum) + (`keyword + (let ((value (org-element-property :value datum))) + (and (string= key "PROPERTY") + (string-match deprecated-re value) + (list (org-element-property :begin datum) + (format "Deprecated syntax for \"%s\". \ +Use header-args instead" + (match-string-no-properties 1 value)))))) + (`node-property + (and (member-ignore-case key deprecated-babel-properties) + (list + (org-element-property :begin datum) + (format "Deprecated syntax for \"%s\". \ +Use :header-args: instead" + key)))))))))) + +(defun org-lint-missing-language-in-src-block (ast) + (org-element-map ast 'src-block + (lambda (b) + (unless (org-element-property :language b) + (list (org-element-property :post-affiliated b) + "Missing language in source block"))))) + +(defun org-lint-missing-backend-in-export-block (ast) + (org-element-map ast 'export-block + (lambda (b) + (unless (org-element-property :type b) + (list (org-element-property :post-affiliated b) + "Missing back-end in export block"))))) + +(defun org-lint-invalid-babel-call-block (ast) + (org-element-map ast 'babel-call + (lambda (b) + (cond + ((not (org-element-property :call b)) + (list (org-element-property :post-affiliated b) + "Invalid syntax in babel call block")) + ((let ((h (org-element-property :end-header b))) + (and h (string-match-p "\\`\\[.*\\]\\'" h))) + (list + (org-element-property :post-affiliated b) + "Babel call's end header must not be wrapped within brackets")))))) + +(defun org-lint-deprecated-category-setup (ast) + (org-element-map ast 'keyword + (let (category-flag) + (lambda (k) + (cond + ((not (string= (org-element-property :key k) "CATEGORY")) nil) + (category-flag + (list (org-element-property :post-affiliated k) + "Spurious CATEGORY keyword. Set :CATEGORY: property instead")) + (t (setf category-flag t) nil)))))) + +(defun org-lint-invalid-coderef-link (ast) + (let ((info (list :parse-tree ast))) + (org-element-map ast 'link + (lambda (link) + (let ((ref (org-element-property :path link))) + (and (equal (org-element-property :type link) "coderef") + (not (ignore-errors (org-export-resolve-coderef ref info))) + (list (org-element-property :begin link) + (format "Unknown coderef \"%s\"" ref)))))))) + +(defun org-lint-invalid-custom-id-link (ast) + (let ((info (list :parse-tree ast))) + (org-element-map ast 'link + (lambda (link) + (and (equal (org-element-property :type link) "custom-id") + (not (ignore-errors (org-export-resolve-id-link link info))) + (list (org-element-property :begin link) + (format "Unknown custom ID \"%s\"" + (org-element-property :path link)))))))) + +(defun org-lint-invalid-fuzzy-link (ast) + (let ((info (list :parse-tree ast))) + (org-element-map ast 'link + (lambda (link) + (and (equal (org-element-property :type link) "fuzzy") + (not (ignore-errors (org-export-resolve-fuzzy-link link info))) + (list (org-element-property :begin link) + (format "Unknown fuzzy location \"%s\"" + (let ((path (org-element-property :path link))) + (if (string-prefix-p "*" path) + (substring path 1) + path))))))))) + +(defun org-lint-invalid-id-link (ast) + (org-element-map ast 'link + (lambda (link) + (let ((id (org-element-property :path link))) + (and (equal (org-element-property :type link) "id") + (not (org-id-find id)) + (list (org-element-property :begin link) + (format "Unknown ID \"%s\"" id))))))) + +(defun org-lint-special-property-in-properties-drawer (ast) + (org-element-map ast 'node-property + (lambda (p) + (let ((key (org-element-property :key p))) + (and (member-ignore-case key org-special-properties) + (list (org-element-property :begin p) + (format + "Special property \"%s\" found in a properties drawer" + key))))))) + +(defun org-lint-obsolete-properties-drawer (ast) + (org-element-map ast 'drawer + (lambda (d) + (when (equal (org-element-property :drawer-name d) "PROPERTIES") + (let ((section (org-element-lineage d '(section)))) + (unless (org-element-map section 'property-drawer #'identity nil t) + (list (org-element-property :post-affiliated d) + (if (save-excursion + (goto-char (org-element-property :post-affiliated d)) + (forward-line -1) + (or (org-at-heading-p) (org-at-planning-p))) + "Incorrect contents for PROPERTIES drawer" + "Incorrect location for PROPERTIES drawer")))))))) + +(defun org-lint-invalid-effort-property (ast) + (org-element-map ast 'node-property + (lambda (p) + (when (equal "EFFORT" (org-element-property :key p)) + (let ((value (org-element-property :value p))) + (and (org-string-nw-p value) + (not (org-duration-p value)) + (list (org-element-property :begin p) + (format "Invalid effort duration format: %S" value)))))))) + +(defun org-lint-link-to-local-file (ast) + (org-element-map ast 'link + (lambda (l) + (when (equal (org-element-property :type l) "file") + (let ((file (org-link-unescape (org-element-property :path l)))) + (and (not (file-remote-p file)) + (not (file-exists-p file)) + (list (org-element-property :begin l) + (format (if (org-element-lineage l '(link)) + "Link to non-existent image file \"%s\"\ + in link description" + "Link to non-existent local file \"%s\"") + file)))))))) + +(defun org-lint-non-existent-setupfile-parameter (ast) + (org-element-map ast 'keyword + (lambda (k) + (when (equal (org-element-property :key k) "SETUPFILE") + (let ((file (org-unbracket-string + "\"" "\"" + (org-element-property :value k)))) + (and (not (file-remote-p file)) + (not (file-exists-p file)) + (list (org-element-property :begin k) + (format "Non-existent setup file \"%s\"" file)))))))) + +(defun org-lint-wrong-include-link-parameter (ast) + (org-element-map ast 'keyword + (lambda (k) + (when (equal (org-element-property :key k) "INCLUDE") + (let* ((value (org-element-property :value k)) + (path + (and (string-match "^\\(\".+\"\\|\\S-+\\)[ \t]*" value) + (save-match-data + (org-unbracket-string "\"" "\"" (match-string 1 value)))))) + (if (not path) + (list (org-element-property :post-affiliated k) + "Missing location argument in INCLUDE keyword") + (let* ((file (org-string-nw-p + (if (string-match "::\\(.*\\)\\'" path) + (substring path 0 (match-beginning 0)) + path))) + (search (and (not (equal file path)) + (org-string-nw-p (match-string 1 path))))) + (if (and file + (not (file-remote-p file)) + (not (file-exists-p file))) + (list (org-element-property :post-affiliated k) + "Non-existent file argument in INCLUDE keyword") + (let* ((visiting (if file (find-buffer-visiting file) + (current-buffer))) + (buffer (or visiting (find-file-noselect file)))) + (unwind-protect + (with-current-buffer buffer + (when (and search + (not + (ignore-errors + (let ((org-link-search-inhibit-query t)) + (org-link-search search nil t))))) + (list (org-element-property :post-affiliated k) + (format + "Invalid search part \"%s\" in INCLUDE keyword" + search)))) + (unless visiting (kill-buffer buffer)))))))))))) + +(defun org-lint-obsolete-include-markup (ast) + (let ((regexp (format "\\`\\(?:\".+\"\\|\\S-+\\)[ \t]+%s" + (regexp-opt + '("ASCII" "BEAMER" "HTML" "LATEX" "MAN" "MARKDOWN" "MD" + "ODT" "ORG" "TEXINFO") + t)))) + (org-element-map ast 'keyword + (lambda (k) + (when (equal (org-element-property :key k) "INCLUDE") + (let ((case-fold-search t) + (value (org-element-property :value k))) + (when (string-match regexp value) + (let ((markup (match-string-no-properties 1 value))) + (list (org-element-property :post-affiliated k) + (format "Obsolete markup \"%s\" in INCLUDE keyword. \ +Use \"export %s\" instead" + markup + markup)))))))))) + +(defun org-lint-unknown-options-item (ast) + (let ((allowed (delq nil + (append + (mapcar (lambda (o) (nth 2 o)) org-export-options-alist) + (cl-mapcan + (lambda (b) + (mapcar (lambda (o) (nth 2 o)) + (org-export-backend-options b))) + org-export-registered-backends)))) + reports) + (org-element-map ast 'keyword + (lambda (k) + (when (string= (org-element-property :key k) "OPTIONS") + (let ((value (org-element-property :value k)) + (start 0)) + (while (string-match "\\(.+?\\):\\((.*?)\\|\\S-*\\)[ \t]*" + value + start) + (setf start (match-end 0)) + (let ((item (match-string 1 value))) + (unless (member item allowed) + (push (list (org-element-property :post-affiliated k) + (format "Unknown OPTIONS item \"%s\"" item)) + reports)))))))) + reports)) + +(defun org-lint-invalid-macro-argument-and-template (ast) + (let ((extract-placeholders + (lambda (template) + (let ((start 0) + args) + (while (string-match "\\$\\([1-9][0-9]*\\)" template start) + (setf start (match-end 0)) + (push (string-to-number (match-string 1 template)) args)) + (sort (org-uniquify args) #'<)))) + reports) + ;; Check arguments for macro templates. + (org-element-map ast 'keyword + (lambda (k) + (when (string= (org-element-property :key k) "MACRO") + (let* ((value (org-element-property :value k)) + (name (and (string-match "^\\S-+" value) + (match-string 0 value))) + (template (and name + (org-trim (substring value (match-end 0)))))) + (cond + ((not name) + (push (list (org-element-property :post-affiliated k) + "Missing name in MACRO keyword") + reports)) + ((not (org-string-nw-p template)) + (push (list (org-element-property :post-affiliated k) + "Missing template in macro \"%s\"" name) + reports)) + (t + (unless (let ((args (funcall extract-placeholders template))) + (equal (number-sequence 1 (or (org-last args) 0)) args)) + (push (list (org-element-property :post-affiliated k) + (format "Unused placeholders in macro \"%s\"" + name)) + reports)))))))) + ;; Check arguments for macros. + (org-macro-initialize-templates) + (let ((templates (append + (mapcar (lambda (m) (cons m "$1")) + '("author" "date" "email" "title" "results")) + org-macro-templates))) + (org-element-map ast 'macro + (lambda (macro) + (let* ((name (org-element-property :key macro)) + (template (cdr (assoc-string name templates t)))) + (if (not template) + (push (list (org-element-property :begin macro) + (format "Undefined macro \"%s\"" name)) + reports) + (let ((arg-numbers (funcall extract-placeholders template))) + (when arg-numbers + (let ((spurious-args + (nthcdr (apply #'max arg-numbers) + (org-element-property :args macro)))) + (when spurious-args + (push + (list (org-element-property :begin macro) + (format "Unused argument%s in macro \"%s\": %s" + (if (> (length spurious-args) 1) "s" "") + name + (mapconcat (lambda (a) (format "\"%s\"" a)) + spurious-args + ", "))) + reports)))))))))) + reports)) + +(defun org-lint-undefined-footnote-reference (ast) + (let ((definitions (org-element-map ast 'footnote-definition + (lambda (f) (org-element-property :label f))))) + (org-element-map ast 'footnote-reference + (lambda (f) + (let ((label (org-element-property :label f))) + (and label + (not (member label definitions)) + (list (org-element-property :begin f) + (format "Missing definition for footnote [%s]" + label)))))))) + +(defun org-lint-unreferenced-footnote-definition (ast) + (let ((references (org-element-map ast 'footnote-reference + (lambda (f) (org-element-property :label f))))) + (org-element-map ast 'footnote-definition + (lambda (f) + (let ((label (org-element-property :label f))) + (and label + (not (member label references)) + (list (org-element-property :post-affiliated f) + (format "No reference for footnote definition [%s]" + label)))))))) + +(defun org-lint-colon-in-name (ast) + (org-element-map ast org-element-all-elements + (lambda (e) + (let ((name (org-element-property :name e))) + (and name + (string-match-p ":" name) + (list (progn + (goto-char (org-element-property :begin e)) + (re-search-forward + (format "^[ \t]*#\\+\\w+: +%s *$" (regexp-quote name))) + (match-beginning 0)) + (format + "Name \"%s\" contains a colon; Babel cannot use it as input" + name))))))) + +(defun org-lint-misplaced-planning-info (_) + (let ((case-fold-search t) + reports) + (while (re-search-forward org-planning-line-re nil t) + (unless (memq (org-element-type (org-element-at-point)) + '(comment-block example-block export-block planning + src-block verse-block)) + (push (list (line-beginning-position) "Misplaced planning info line") + reports))) + reports)) + +(defun org-lint-incomplete-drawer (_) + (let (reports) + (while (re-search-forward org-drawer-regexp nil t) + (let ((name (org-trim (match-string-no-properties 0))) + (element (org-element-at-point))) + (pcase (org-element-type element) + ((or `drawer `property-drawer) + (goto-char (org-element-property :end element)) + nil) + ((or `comment-block `example-block `export-block `src-block + `verse-block) + nil) + (_ + (push (list (line-beginning-position) + (format "Possible incomplete drawer \"%s\"" name)) + reports))))) + reports)) + +(defun org-lint-indented-diary-sexp (_) + (let (reports) + (while (re-search-forward "^[ \t]+%%(" nil t) + (unless (memq (org-element-type (org-element-at-point)) + '(comment-block diary-sexp example-block export-block + src-block verse-block)) + (push (list (line-beginning-position) "Possible indented diary-sexp") + reports))) + reports)) + +(defun org-lint-invalid-block (_) + (let ((case-fold-search t) + (regexp "^[ \t]*#\\+\\(BEGIN\\|END\\)\\(?::\\|_[^[:space:]]*\\)?[ \t]*") + reports) + (while (re-search-forward regexp nil t) + (let ((name (org-trim (buffer-substring-no-properties + (line-beginning-position) (line-end-position))))) + (cond + ((and (string-prefix-p "END" (match-string 1) t) + (not (eolp))) + (push (list (line-beginning-position) + (format "Invalid block closing line \"%s\"" name)) + reports)) + ((not (memq (org-element-type (org-element-at-point)) + '(center-block comment-block dynamic-block example-block + export-block quote-block special-block + src-block verse-block))) + (push (list (line-beginning-position) + (format "Possible incomplete block \"%s\"" + name)) + reports))))) + reports)) + +(defun org-lint-invalid-keyword-syntax (_) + (let ((regexp "^[ \t]*#\\+\\([^[:space:]:]*\\)\\(?: \\|$\\)") + (exception-re + (format "[ \t]*#\\+%s\\(\\[.*\\]\\)?:\\(?: \\|$\\)" + (regexp-opt org-element-dual-keywords))) + reports) + (while (re-search-forward regexp nil t) + (let ((name (match-string-no-properties 1))) + (unless (or (string-prefix-p "BEGIN" name t) + (string-prefix-p "END" name t) + (save-excursion + (beginning-of-line) + (let ((case-fold-search t)) (looking-at exception-re)))) + (push (list (match-beginning 0) + (format "Possible missing colon in keyword \"%s\"" name)) + reports)))) + reports)) + +(defun org-lint-extraneous-element-in-footnote-section (ast) + (org-element-map ast 'headline + (lambda (h) + (and (org-element-property :footnote-section-p h) + (org-element-map (org-element-contents h) + (cl-remove-if + (lambda (e) + (memq e '(comment comment-block footnote-definition + property-drawer section))) + org-element-all-elements) + (lambda (e) + (not (and (eq (org-element-type e) 'headline) + (org-element-property :commentedp e)))) + nil t '(footnote-definition property-drawer)) + (list (org-element-property :begin h) + "Extraneous elements in footnote section are not exported"))))) + +(defun org-lint-quote-section (ast) + (org-element-map ast '(headline inlinetask) + (lambda (h) + (let ((title (org-element-property :raw-value h))) + (and (or (string-prefix-p "QUOTE " title) + (string-prefix-p (concat org-comment-string " QUOTE ") title)) + (list (org-element-property :begin h) + "Deprecated QUOTE section")))))) + +(defun org-lint-file-application (ast) + (org-element-map ast 'link + (lambda (l) + (let ((app (org-element-property :application l))) + (and app + (list (org-element-property :begin l) + (format "Deprecated \"file+%s\" link type" app))))))) + +(defun org-lint-wrong-header-argument (ast) + (let* ((reports) + (verify + (lambda (datum language headers) + (let ((allowed + ;; If LANGUAGE is specified, restrict allowed + ;; headers to both LANGUAGE-specific and default + ;; ones. Otherwise, accept headers from any loaded + ;; language. + (append + org-babel-header-arg-names + (cl-mapcan + (lambda (l) + (let ((v (intern (format "org-babel-header-args:%s" l)))) + (and (boundp v) (mapcar #'car (symbol-value v))))) + (if language (list language) + (mapcar #'car org-babel-load-languages)))))) + (dolist (header headers) + (let ((h (symbol-name (car header))) + (p (or (org-element-property :post-affiliated datum) + (org-element-property :begin datum)))) + (cond + ((not (string-prefix-p ":" h)) + (push + (list p + (format "Missing colon in header argument \"%s\"" h)) + reports)) + ((assoc-string (substring h 1) allowed)) + (t (push (list p (format "Unknown header argument \"%s\"" h)) + reports))))))))) + (org-element-map ast '(babel-call inline-babel-call inline-src-block keyword + node-property src-block) + (lambda (datum) + (pcase (org-element-type datum) + ((or `babel-call `inline-babel-call) + (funcall verify + datum + nil + (cl-mapcan #'org-babel-parse-header-arguments + (list + (org-element-property :inside-header datum) + (org-element-property :end-header datum))))) + (`inline-src-block + (funcall verify + datum + (org-element-property :language datum) + (org-babel-parse-header-arguments + (org-element-property :parameters datum)))) + (`keyword + (when (string= (org-element-property :key datum) "PROPERTY") + (let ((value (org-element-property :value datum))) + (when (string-match "\\`header-args\\(?::\\(\\S-+\\)\\)?\\+? *" + value) + (funcall verify + datum + (match-string 1 value) + (org-babel-parse-header-arguments + (substring value (match-end 0)))))))) + (`node-property + (let ((key (org-element-property :key datum))) + (when (let ((case-fold-search t)) + (string-match "\\`HEADER-ARGS\\(?::\\(\\S-+\\)\\)?\\+?" + key)) + (funcall verify + datum + (match-string 1 key) + (org-babel-parse-header-arguments + (org-element-property :value datum)))))) + (`src-block + (funcall verify + datum + (org-element-property :language datum) + (cl-mapcan #'org-babel-parse-header-arguments + (cons (org-element-property :parameters datum) + (org-element-property :header datum)))))))) + reports)) + +(defun org-lint-wrong-header-value (ast) + (let (reports) + (org-element-map ast + '(babel-call inline-babel-call inline-src-block src-block) + (lambda (datum) + (let* ((type (org-element-type datum)) + (language (org-element-property :language datum)) + (allowed-header-values + (append (and language + (let ((v (intern (concat "org-babel-header-args:" + language)))) + (and (boundp v) (symbol-value v)))) + org-babel-common-header-args-w-values)) + (datum-header-values + (org-babel-parse-header-arguments + (org-trim + (pcase type + (`src-block + (mapconcat + #'identity + (cons (org-element-property :parameters datum) + (org-element-property :header datum)) + " ")) + (`inline-src-block + (or (org-element-property :parameters datum) "")) + (_ + (concat + (org-element-property :inside-header datum) + " " + (org-element-property :end-header datum)))))))) + (dolist (header datum-header-values) + (let ((allowed-values + (cdr (assoc-string (substring (symbol-name (car header)) 1) + allowed-header-values)))) + (unless (memq allowed-values '(:any nil)) + (let ((values (cdr header)) + groups-alist) + (dolist (v (if (stringp values) (org-split-string values) + (list values))) + (let ((valid-value nil)) + (catch 'exit + (dolist (group allowed-values) + (cond + ((not (funcall + (if (stringp v) #'assoc-string #'assoc) + v group)) + (when (memq :any group) + (setf valid-value t) + (push (cons group v) groups-alist))) + ((assq group groups-alist) + (push + (list + (or (org-element-property :post-affiliated datum) + (org-element-property :begin datum)) + (format + "Forbidden combination in header \"%s\": %s, %s" + (car header) + (cdr (assq group groups-alist)) + v)) + reports) + (throw 'exit nil)) + (t (push (cons group v) groups-alist) + (setf valid-value t)))) + (unless valid-value + (push + (list + (or (org-element-property :post-affiliated datum) + (org-element-property :begin datum)) + (format "Unknown value \"%s\" for header \"%s\"" + v + (car header))) + reports)))))))))))) + reports)) + +(defun org-lint-empty-headline-with-tags (ast) + (org-element-map ast '(headline inlinetask) + (lambda (h) + (let ((title (org-element-property :raw-value h))) + (and (string-match-p "\\`:[[:alnum:]_@#%:]+:\\'" title) + (list (org-element-property :begin h) + (format "Headline containing only tags is ambiguous: %S" + title))))))) + + +;;; Reports UI + +(defvar org-lint--report-mode-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map tabulated-list-mode-map) + (define-key map (kbd "RET") 'org-lint--jump-to-source) + (define-key map (kbd "TAB") 'org-lint--show-source) + (define-key map (kbd "C-j") 'org-lint--show-source) + (define-key map (kbd "h") 'org-lint--hide-checker) + (define-key map (kbd "i") 'org-lint--ignore-checker) + map) + "Local keymap for `org-lint--report-mode' buffers.") + +(define-derived-mode org-lint--report-mode tabulated-list-mode "OrgLint" + "Major mode used to display reports emitted during linting. +\\{org-lint--report-mode-map}" + (setf tabulated-list-format + `[("Line" 6 + (lambda (a b) + (< (string-to-number (aref (cadr a) 0)) + (string-to-number (aref (cadr b) 0)))) + :right-align t) + ("Trust" 5 t) + ("Warning" 0 t)]) + (tabulated-list-init-header)) + +(defun org-lint--generate-reports (buffer checkers) + "Generate linting report for BUFFER. + +CHECKERS is the list of checkers used. + +Return an alist (ID [LINE TRUST DESCRIPTION CHECKER]), suitable +for `tabulated-list-printer'." + (with-current-buffer buffer + (save-excursion + (goto-char (point-min)) + (let ((ast (org-element-parse-buffer)) + (id 0) + (last-line 1) + (last-pos 1)) + ;; Insert unique ID for each report. Replace buffer positions + ;; with line numbers. + (mapcar + (lambda (report) + (list + (cl-incf id) + (apply #'vector + (cons + (progn + (goto-char (car report)) + (beginning-of-line) + (prog1 (number-to-string + (cl-incf last-line + (count-lines last-pos (point)))) + (setf last-pos (point)))) + (cdr report))))) + ;; Insert trust level in generated reports. Also sort them + ;; by buffer position in order to optimize lines computation. + (sort (cl-mapcan + (lambda (c) + (let ((trust (symbol-name (org-lint-checker-trust c)))) + (mapcar + (lambda (report) + (list (car report) trust (nth 1 report) c)) + (save-excursion + (funcall + (intern (format "org-lint-%s" + (org-lint-checker-name c))) + ast))))) + checkers) + #'car-less-than-car)))))) + +(defvar-local org-lint--source-buffer nil + "Source buffer associated to current report buffer.") + +(defvar-local org-lint--local-checkers nil + "List of checkers used to build current report.") + +(defun org-lint--refresh-reports () + (setq tabulated-list-entries + (org-lint--generate-reports org-lint--source-buffer + org-lint--local-checkers)) + (tabulated-list-print)) + +(defun org-lint--current-line () + "Return current report line, as a number." + (string-to-number (aref (tabulated-list-get-entry) 0))) + +(defun org-lint--current-checker (&optional entry) + "Return current report checker. +When optional argument ENTRY is non-nil, use this entry instead +of current one." + (aref (if entry (nth 1 entry) (tabulated-list-get-entry)) 3)) + +(defun org-lint--display-reports (source checkers) + "Display linting reports for buffer SOURCE. +CHECKERS is the list of checkers used." + (let ((buffer (get-buffer-create "*Org Lint*"))) + (with-current-buffer buffer + (org-lint--report-mode) + (setf org-lint--source-buffer source) + (setf org-lint--local-checkers checkers) + (org-lint--refresh-reports) + (tabulated-list-print) + (add-hook 'tabulated-list-revert-hook #'org-lint--refresh-reports nil t)) + (pop-to-buffer buffer))) + +(defun org-lint--jump-to-source () + "Move to source line that generated the report at point." + (interactive) + (let ((l (org-lint--current-line))) + (switch-to-buffer-other-window org-lint--source-buffer) + (org-goto-line l) + (org-show-set-visibility 'local) + (recenter))) + +(defun org-lint--show-source () + "Show source line that generated the report at point." + (interactive) + (let ((buffer (current-buffer))) + (org-lint--jump-to-source) + (switch-to-buffer-other-window buffer))) + +(defun org-lint--hide-checker () + "Hide all reports from checker that generated the report at point." + (interactive) + (let ((c (org-lint--current-checker))) + (setf tabulated-list-entries + (cl-remove-if (lambda (e) (equal c (org-lint--current-checker e))) + tabulated-list-entries)) + (tabulated-list-print))) + +(defun org-lint--ignore-checker () + "Ignore all reports from checker that generated the report at point. +Checker will also be ignored in all subsequent reports." + (interactive) + (setf org-lint--local-checkers + (remove (org-lint--current-checker) org-lint--local-checkers)) + (org-lint--hide-checker)) + + +;;; Public function + +;;;###autoload +(defun org-lint (&optional arg) + "Check current Org buffer for syntax mistakes. + +By default, run all checkers. With a `\\[universal-argument]' prefix ARG, \ +select one +category of checkers only. With a `\\[universal-argument] \ +\\[universal-argument]' prefix, run one precise +checker by its name. + +ARG can also be a list of checker names, as symbols, to run." + (interactive "P") + (unless (derived-mode-p 'org-mode) (user-error "Not in an Org buffer")) + (when (called-interactively-p 'any) + (message "Org linting process starting...")) + (let ((checkers + (pcase arg + (`nil org-lint--checkers) + (`(4) + (let ((category + (completing-read + "Checker category: " + (mapcar #'org-lint-checker-categories org-lint--checkers) + nil t))) + (cl-remove-if-not + (lambda (c) + (assoc-string (org-lint-checker-categories c) category)) + org-lint--checkers))) + (`(16) + (list + (let ((name (completing-read + "Checker name: " + (mapcar #'org-lint-checker-name org-lint--checkers) + nil t))) + (catch 'exit + (dolist (c org-lint--checkers) + (when (string= (org-lint-checker-name c) name) + (throw 'exit c))))))) + ((pred consp) + (cl-remove-if-not (lambda (c) (memq (org-lint-checker-name c) arg)) + org-lint--checkers)) + (_ (user-error "Invalid argument `%S' for `org-lint'" arg))))) + (if (not (called-interactively-p 'any)) + (org-lint--generate-reports (current-buffer) checkers) + (org-lint--display-reports (current-buffer) checkers) + (message "Org linting process completed")))) + + +(provide 'org-lint) +;;; org-lint.el ends here diff --git a/elpa/org-plus-contrib-20150831/org-list.el b/elpa/org-plus-contrib-20170407/org-list.el similarity index 81% rename from elpa/org-plus-contrib-20150831/org-list.el rename to elpa/org-plus-contrib-20170407/org-list.el index e6a78f76..ddcf85cf 100644 --- a/elpa/org-plus-contrib-20150831/org-list.el +++ b/elpa/org-plus-contrib-20170407/org-list.el @@ -1,6 +1,6 @@ -;;; org-list.el --- Plain lists for Org-mode +;;; org-list.el --- Plain lists for Org -*- lexical-binding: t; -*- ;; -;; Copyright (C) 2004-2015 Free Software Foundation, Inc. +;; Copyright (C) 2004-2017 Free Software Foundation, Inc. ;; ;; Author: Carsten Dominik ;; Bastien Guerry @@ -25,7 +25,7 @@ ;; ;;; Commentary: -;; This file contains the code dealing with plain lists in Org-mode. +;; This file contains the code dealing with plain lists in Org mode. ;; The core concept behind lists is their structure. A structure is ;; a snapshot of the list, in the shape of a data tree (see @@ -76,8 +76,7 @@ ;;; Code: -(eval-when-compile - (require 'cl)) +(require 'cl-lib) (require 'org-macs) (require 'org-compat) @@ -88,32 +87,54 @@ (defvar org-closed-string) (defvar org-deadline-string) (defvar org-description-max-indent) +(defvar org-done-keywords) +(defvar org-drawer-regexp) +(defvar org-element-all-objects) +(defvar org-inhibit-startup) (defvar org-odd-levels-only) +(defvar org-outline-regexp-bol) (defvar org-scheduled-string) +(defvar org-todo-line-regexp) (defvar org-ts-regexp) (defvar org-ts-regexp-both) -(defvar org-drawer-regexp) (declare-function org-at-heading-p "org" (&optional invisible-ok)) (declare-function org-back-to-heading "org" (&optional invisible-ok)) (declare-function org-before-first-heading-p "org" ()) (declare-function org-combine-plists "org" (&rest plists)) -(declare-function org-count "org" (cl-item cl-seq)) (declare-function org-current-level "org" ()) (declare-function org-element-at-point "org-element" ()) (declare-function org-element-context "org-element" (&optional element)) -(declare-function org-element-lineage "org-element" - (blob &optional types with-self)) +(declare-function org-element-interpret-data "org-element" (data)) +(declare-function + org-element-lineage "org-element" (blob &optional types with-self)) +(declare-function org-element-macro-interpreter "org-element" (macro ##)) +(declare-function + org-element-map "org-element" + (data types fun &optional info first-match no-recursion with-affiliated)) +(declare-function org-element-normalize-string "org-element" (s)) +(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-set-element "org-element" (old new)) (declare-function org-element-type "org-element" (element)) (declare-function org-element-update-syntax "org-element" ()) (declare-function org-entry-get "org" (pom property &optional inherit literal-nil)) -(declare-function org-export-string-as "ox" - (string backend &optional body-only ext-plist)) +(declare-function org-export-create-backend "ox" (&rest rest) t) +(declare-function org-export-data-with-backend "ox" (data backend info)) +(declare-function org-export-get-backend "ox" (name)) +(declare-function org-export-get-environment "ox" + (&optional backend subtreep ext-plist)) +(declare-function org-export-get-next-element "ox" + (blob info &optional n)) +(declare-function org-export-with-backend "ox" + (backend data &optional contents info)) (declare-function org-fix-tags-on-the-fly "org" ()) (declare-function org-get-indentation "org" (&optional line)) -(declare-function org-icompleting-read "org" (&rest args)) +(declare-function org-get-todo-state "org" ()) (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" ()) @@ -122,15 +143,16 @@ (declare-function org-inlinetask-outline-regexp "org-inlinetask" ()) (declare-function org-level-increment "org" ()) (declare-function org-narrow-to-subtree "org" ()) +(declare-function org-outline-level "org" ()) (declare-function org-previous-line-empty-p "org" ()) (declare-function org-reduced-level "org" (L)) -(declare-function org-remove-if "org" (predicate seq)) +(declare-function org-remove-indentation "org" (code &optional n)) (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-trim "org" (s &optional keep-lead)) (declare-function org-uniquify "org" (list)) (declare-function outline-flag-region "outline" (from to flag)) (declare-function outline-invisible-p "outline" (&optional pos)) @@ -142,7 +164,7 @@ ;;; Configuration variables (defgroup org-plain-lists nil - "Options concerning plain lists in Org-mode." + "Options concerning plain lists in Org mode." :tag "Org Plain lists" :group 'org-structure) @@ -176,7 +198,7 @@ to the bullet that should be used when this item is demoted. For example, (setq org-list-demote-modify-bullet - '((\"+\" . \"-\") (\"-\" . \"+\") (\"*\" . \"+\"))) + \\='((\"+\" . \"-\") (\"-\" . \"+\") (\"*\" . \"+\"))) will make @@ -219,7 +241,7 @@ 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: - \\[org-element-update-syntax]" + `\\[org-element-update-syntax]'" :group 'org-plain-lists :type '(choice (const :tag "dot like in \"2.\"" ?.) (const :tag "paren like in \"2)\"" ?\)) @@ -227,8 +249,6 @@ interface or run the following code after updating it: :set (lambda (var val) (set var val) (when (featurep 'org-element) (org-element-update-syntax)))) -(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. @@ -240,7 +260,7 @@ 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: - \\[org-element-update-syntax]" + `\\[org-element-update-syntax]'" :group 'org-plain-lists :version "24.1" :type 'boolean @@ -259,23 +279,22 @@ spaces instead of one after the bullet in each item of the list." (const :tag "never" nil) (regexp))) -(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 - :type 'boolean) - (defcustom org-list-automatic-rules '((checkbox . t) (indent . t)) "Non-nil means apply set of rules when acting on lists. +\\ By default, automatic actions are taken when using - \\[org-meta-return], \\[org-metaright], \\[org-metaleft], - \\[org-shiftmetaright], \\[org-shiftmetaleft], - \\[org-ctrl-c-minus], \\[org-toggle-checkbox] or - \\[org-insert-todo-heading]. You can disable individually these - rules by setting them to nil. Valid rules are: + `\\[org-meta-return]', + `\\[org-metaright]', + `\\[org-metaleft]', + `\\[org-shiftmetaright]', + `\\[org-shiftmetaleft]', + `\\[org-ctrl-c-minus]', + `\\[org-toggle-checkbox]', + `\\[org-insert-todo-heading]'. + +You can disable individually these rules by setting them to nil. +Valid rules are: checkbox when non-nil, checkbox statistics is updated each time you either insert a new checkbox or toggle a checkbox. @@ -295,13 +314,15 @@ indent when non-nil, indenting or outdenting list top-item (defcustom org-list-use-circular-motion nil "Non-nil means commands implying motion in lists should be cyclic. - +\\ In that case, the item following the last item is the first one, and the item preceding the first item is the last one. -This affects the behavior of \\[org-move-item-up], - \\[org-move-item-down], \\[org-next-item] and - \\[org-previous-item]." +This affects the behavior of + `\\[org-move-item-up]', + `\\[org-move-item-down]', + `\\[org-next-item]', + `\\[org-previous-item]'." :group 'org-plain-lists :version "24.1" :type 'boolean) @@ -313,8 +334,6 @@ This hook runs even if checkbox rule in implement alternative ways of collecting statistics information.") -(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. @@ -323,8 +342,6 @@ with the word \"recursive\" in the value." :group 'org-plain-lists :type 'boolean) -(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 @@ -367,8 +384,7 @@ list, obtained by prompting the user." (list (symbol :tag "Major mode") (string :tag "Format")))) -(defvar org-list-forbidden-blocks '("example" "verse" "src" "ascii" "beamer" - "html" "latex" "odt") +(defvar org-list-forbidden-blocks '("example" "verse" "src" "export") "Names of blocks where lists are not allowed. Names must be in lower case.") @@ -383,10 +399,8 @@ specifically, type `block' is determined by the variable ;;; Predicates and regexps -(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-list-empty-line-terminates-plain-lists'.") +(defconst org-list-end-re "^[ \t]*\n[ \t]*\n" + "Regex matching the end of a plain list.") (defconst org-list-full-item-re (concat "^[ \t]*\\(\\(?:[-+*]\\|\\(?:[0-9]+\\|[A-Za-z]\\)[.)]\\)\\(?:[ \t]+\\|$\\)\\)" @@ -622,11 +636,11 @@ point-at-bol: will get the following structure: -\(\(1 0 \"- \" nil \"[X]\" nil 97\) - \(18 2 \"1. \" nil nil nil 34\) - \(34 2 \"5. \" \"5\" nil nil 55\) - \(97 0 \"- \" nil nil nil 131\) - \(109 2 \"+ \" nil nil \"tag\" 131\) + ((1 0 \"- \" nil \"[X]\" nil 97) + (18 2 \"1. \" nil nil nil 34) + (34 2 \"5. \" \"5\" nil nil 55) + (97 0 \"- \" nil nil nil 131) + (109 2 \"+ \" nil nil \"tag\" 131)) Assume point is at an item." (save-excursion @@ -653,7 +667,7 @@ Assume point is at an item." (match-string-no-properties 2) ; counter (match-string-no-properties 3) ; checkbox ;; Description tag. - (and (save-match-data (string-match "[-+*]" bullet)) + (and (string-match-p "[-+*]" bullet) (match-string-no-properties 4))))))) (end-before-blank (function @@ -1020,7 +1034,7 @@ Possible types are `descriptive', `ordered' and `unordered'. The type is determined by the first item of the list." (let ((first (org-list-get-list-begin item struct prevs))) (cond - ((string-match "[[:alnum:]]" (org-list-get-bullet first struct)) 'ordered) + ((string-match-p "[[:alnum:]]" (org-list-get-bullet first struct)) 'ordered) ((org-list-get-tag first struct) 'descriptive) (t 'unordered)))) @@ -1042,7 +1056,7 @@ that value." (let ((seq 0) (pos item) counter) (while (and (not (setq counter (org-list-get-counter pos struct))) (setq pos (org-list-get-prev-item pos struct prevs))) - (incf seq)) + (cl-incf seq)) (if (not counter) (1+ seq) (cond ((string-match "[A-Za-z]" counter) @@ -1222,7 +1236,7 @@ some heuristics to guess the result." (point)))))))) (cond ;; Trivial cases where there should be none. - ((or org-list-empty-line-terminates-plain-lists (not insert-blank-p)) 0) + ((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 @@ -1324,7 +1338,7 @@ This function modifies STRUCT." (size-offset (- item-size (length text-cut)))) ;; 4. Insert effectively item into buffer. (goto-char item) - (org-indent-to-column ind) + (indent-to-column ind) (insert body item-sep) ;; 5. Add new item to STRUCT. (mapc (lambda (e) @@ -1466,7 +1480,7 @@ This function returns, destructively, the new list structure." (save-excursion (goto-char (org-list-get-last-item item struct prevs)) (point-at-eol))) - ((string-match "\\`[0-9]+\\'" dest) + ((string-match-p "\\`[0-9]+\\'" dest) (let* ((all (org-list-get-all-items item struct prevs)) (len (length all)) (index (mod (string-to-number dest) len))) @@ -1481,7 +1495,7 @@ This function returns, destructively, the new list structure." (t dest))) (org-M-RET-may-split-line nil) ;; Store inner overlays (to preserve visibility). - (overlays (org-remove-if (lambda (o) (or (< (overlay-start o) item) + (overlays (cl-remove-if (lambda (o) (or (< (overlay-start o) item) (> (overlay-end o) item))) (overlays-in item item-end)))) (cond @@ -1640,7 +1654,7 @@ as returned by `org-list-prevs-alist'." (while item (let ((count (org-list-get-counter item struct))) ;; Virtually determine current bullet - (if (and count (string-match "[a-zA-Z]" count)) + (if (and count (string-match-p "[a-zA-Z]" count)) ;; Counters are not case-sensitive. (setq ascii (string-to-char (upcase count))) (setq ascii (1+ ascii))) @@ -1883,8 +1897,8 @@ Initial position of cursor is restored after the changes." ((and inlinetask-re (looking-at inlinetask-re)) (org-inlinetask-goto-beginning)) ;; Shift only non-empty lines. - ((org-looking-at-p "^[ \t]*\\S-") - (org-indent-line-to (+ (org-get-indentation) delta)))) + ((looking-at-p "^[ \t]*\\S-") + (indent-line-to (+ (org-get-indentation) delta)))) (forward-line -1))))) (modify-item (function @@ -1967,7 +1981,7 @@ Initial position of cursor is restored after the changes." (while (< (point) down) ;; Ignore empty lines. Also ignore blocks and ;; drawers contents. - (unless (org-looking-at-p "[ \t]*$") + (unless (looking-at-p "[ \t]*$") (setq min-ind (min (org-get-indentation) min-ind)) (cond ((and (looking-at "#\\+BEGIN\\(:\\|_\\S-+\\)") @@ -2036,7 +2050,7 @@ previous item, plus ARGS extra arguments. FUNCTION is applied on items in reverse order. -As an example, \(org-apply-on-list \(lambda \(result\) \(1+ result\)\) 0\) +As an example, \(org-apply-on-list \(lambda \(result) \(1+ result)) 0) will return the number of items in the current list. Sublists of the list are skipped. Cursor is always at the @@ -2083,15 +2097,23 @@ Possible values are: `folded', `children' or `subtree'. See "Return column at which body of ITEM should start." (save-excursion (goto-char item) - (looking-at "[ \t]*\\(\\S-+\\)\\(.*[ \t]+::\\)?\\([ \t]+\\|$\\)") - (if (match-beginning 2) - (let ((start (1+ (match-end 2))) + (if (save-excursion + (end-of-line) + (re-search-backward + "[ \t]::\\([ \t]\\|$\\)" (line-beginning-position) t)) + ;; Descriptive list item. Body starts after item's tag, if + ;; possible. + (let ((start (1+ (- (match-beginning 1) (line-beginning-position)))) (ind (org-get-indentation))) - (if (> start (+ ind org-description-max-indent)) (+ ind 5) start)) + (if (> start (+ ind org-list-description-max-indent)) + (+ ind 5) + start)) + ;; Regular item. Body starts after bullet. + (looking-at "[ \t]*\\(\\S-+\\)") (+ (progn (goto-char (match-end 1)) (current-column)) (if (and org-list-two-spaces-after-bullet-regexp - (org-string-match-p org-list-two-spaces-after-bullet-regexp - (match-string 1))) + (string-match-p org-list-two-spaces-after-bullet-regexp + (match-string 1))) 2 1))))) @@ -2228,6 +2250,7 @@ If CHECKBOX is non-nil, add a checkbox next to the bullet. Return t when things worked, nil when we are not in an item, or item is invisible." + (interactive "P") (let ((itemp (org-in-item-p)) (pos (point))) ;; If cursor isn't is a list or if list is invisible, return nil. @@ -2410,7 +2433,7 @@ in subtree, ignoring drawers." (parents (org-list-parents-alist struct)) (prevs (org-list-prevs-alist struct)) (bottom (copy-marker (org-list-get-bottom-point struct))) - (items-to-toggle (org-remove-if + (items-to-toggle (cl-remove-if (lambda (e) (or (< e lim-up) (> e lim-down))) (mapcar #'car struct)))) (mapc (lambda (e) (org-list-set-checkbox @@ -2506,8 +2529,8 @@ With optional prefix argument ALL, do this for the whole buffer." (lambda (e) (org-list-get-checkbox e s)) items)))) - (incf c-all (length cookies)) - (incf c-on (org-count "[X]" cookies))))))) + (cl-incf c-all (length cookies)) + (cl-incf c-on (cl-count "[X]" cookies :test #'equal))))))) cookies-list cache) ;; Move to start. (cond (all (goto-char (point-min))) @@ -2685,7 +2708,7 @@ Return t if successful." ;; of the subtree mustn't have a child. (let ((last-item (caar (reverse - (org-remove-if + (cl-remove-if (lambda (e) (>= (car e) end)) struct))))) (org-list-has-child-p last-item struct)))) @@ -2802,7 +2825,7 @@ Return t at each successful move." ((and (= ind (car org-tab-ind-state)) (ignore-errors (org-list-indent-item-generic 1 t struct)))) (t (delete-region (point-at-bol) (point-at-eol)) - (org-indent-to-column (car org-tab-ind-state)) + (indent-to-column (car org-tab-ind-state)) (insert (cdr org-tab-ind-state) " ") ;; Break cycle (setq this-command 'identity))) @@ -2862,8 +2885,8 @@ ignores hidden links." (getkey-func (or getkey-func (and (= (downcase sorting-type) ?f) - (intern (org-icompleting-read "Sort using function: " - obarray 'fboundp t nil nil)))))) + (intern (completing-read "Sort using function: " + obarray 'fboundp t nil nil)))))) (message "Sorting items...") (save-restriction (narrow-to-region start end) @@ -2905,7 +2928,7 @@ ignores hidden links." (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)))) + (t (float-time now)))) ((= dcst ?x) (or (and (stringp (match-string 1)) (match-string 1)) "")) @@ -2929,128 +2952,249 @@ ignores hidden links." (run-hooks 'org-after-sorting-entries-or-items-hook) (message "Sorting items...done"))))) +(defun org-toggle-item (arg) + "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 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 a list of items. +With a prefix argument ARG, change the region in a single item." + (interactive "P") + (let ((shift-text + (lambda (ind end) + ;; Shift text in current section to IND, from point to END. + ;; The function leaves point to END line. + (let ((min-i 1000) (end (copy-marker end))) + ;; First determine the minimum indentation (MIN-I) of + ;; the text. + (save-excursion + (catch 'exit + (while (< (point) end) + (let ((i (org-get-indentation))) + (cond + ;; Skip blank lines and inline tasks. + ((looking-at "^[ \t]*$")) + ((looking-at org-outline-regexp-bol)) + ;; We can't find less than 0 indentation. + ((zerop i) (throw 'exit (setq min-i 0))) + ((< i min-i) (setq min-i i)))) + (forward-line)))) + ;; Then indent each line so that a line indented to + ;; MIN-I becomes indented to IND. Ignore blank lines + ;; and inline tasks in the process. + (let ((delta (- ind min-i))) + (while (< (point) end) + (unless (or (looking-at "^[ \t]*$") + (looking-at org-outline-regexp-bol)) + (indent-line-to (+ (org-get-indentation) delta))) + (forward-line)))))) + (skip-blanks + (lambda (pos) + ;; Return beginning of first non-blank line, starting from + ;; line at POS. + (save-excursion + (goto-char pos) + (skip-chars-forward " \r\t\n") + (point-at-bol)))) + beg end) + ;; Determine boundaries of changes. + (if (org-region-active-p) + (setq beg (funcall skip-blanks (region-beginning)) + end (copy-marker (region-end))) + (setq beg (funcall skip-blanks (point-at-bol)) + end (copy-marker (point-at-eol)))) + ;; Depending on the starting line, choose an action on the text + ;; between BEG and END. + (org-with-limited-levels + (save-excursion + (goto-char beg) + (cond + ;; Case 1. Start at an item: de-itemize. Note that it only + ;; happens when a region is active: `org-ctrl-c-minus' + ;; would call `org-cycle-list-bullet' otherwise. + ((org-at-item-p) + (while (< (point) end) + (when (org-at-item-p) + (skip-chars-forward " \t") + (delete-region (point) (match-end 0))) + (forward-line))) + ;; Case 2. Start at an heading: convert to items. + ((org-at-heading-p) + (let* ((bul (org-list-bullet-string "-")) + (bul-len (length bul)) + ;; Indentation of the first heading. It should be + ;; relative to the indentation of its parent, if any. + (start-ind (save-excursion + (cond + ((not org-adapt-indentation) 0) + ((not (outline-previous-heading)) 0) + (t (length (match-string 0)))))) + ;; Level of first heading. Further headings will be + ;; compared to it to determine hierarchy in the list. + (ref-level (org-reduced-level (org-outline-level)))) + (while (< (point) end) + (let* ((level (org-reduced-level (org-outline-level))) + (delta (max 0 (- level ref-level))) + (todo-state (org-get-todo-state))) + ;; If current headline is less indented than the first + ;; one, set it as reference, in order to preserve + ;; subtrees. + (when (< level ref-level) (setq ref-level level)) + ;; Remove stars and TODO keyword. + (let ((case-fold-search nil)) (looking-at org-todo-line-regexp)) + (delete-region (point) (or (match-beginning 3) + (line-end-position))) + (insert bul) + (indent-line-to (+ start-ind (* delta bul-len))) + ;; Turn TODO keyword into a check box. + (when todo-state + (let* ((struct (org-list-struct)) + (old (copy-tree struct))) + (org-list-set-checkbox + (line-beginning-position) + struct + (if (member todo-state org-done-keywords) + "[X]" + "[ ]")) + (org-list-write-struct struct + (org-list-parents-alist struct) + old))) + ;; Ensure all text down to END (or SECTION-END) belongs + ;; to the newly created item. + (let ((section-end (save-excursion + (or (outline-next-heading) (point))))) + (forward-line) + (funcall shift-text + (+ start-ind (* (1+ delta) bul-len)) + (min end section-end))))))) + ;; 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") + (insert bul) + (forward-line) + (while (< (point) end) + ;; Ensure that lines less indented than first one + ;; still get included in item body. + (funcall shift-text + (+ ref-ind bul-len) + (min end (save-excursion (or (outline-next-heading) + (point))))) + (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)) + (when (looking-at "\\([ \t]*\\)\\(\\S-\\)") + (replace-match + (concat "\\1" (org-list-bullet-string "-") "\\2")))) + (forward-line)))))))) ;;; Send and receive lists -(defun org-list-parse-list (&optional delete) +(defun org-list-to-lisp (&optional delete) "Parse the list at point and maybe DELETE it. Return a list whose car is a symbol of list type, among `ordered', `unordered' and `descriptive'. Then, each item is -a list whose car is counter, and cdr are strings and other -sub-lists. Inside strings, check-boxes are replaced by -\"[CBON]\", \"[CBOFF]\" and \"[CBTRANS]\". +a list of strings and other sub-lists. For example, the following list: -1. first item - + sub-item one - + [X] sub-item two - more text in first item -2. [@3] last item + 1. first item + + sub-item one + + [X] sub-item two + more text in first item + 2. [@3] last item -will be parsed as: +is parsed as -\(ordered - \(nil \"first item\" - \(unordered - \(nil \"sub-item one\"\) - \(nil \"[CBON] sub-item two\"\)\) - \"more text in first item\"\) - \(3 \"last item\"\)\) + (ordered + (\"first item\" + (unordered + (\"sub-item one\") + (\"[X] sub-item two\")) + \"more text in first item\") + (\"[@3] last item\")) -Point is left at list end." - (defvar parse-item) ;FIXME: Or use `cl-labels' or `letrec'. - (let* ((struct (org-list-struct)) - (prevs (org-list-prevs-alist struct)) - (parents (org-list-parents-alist struct)) - (top (org-list-get-top-point struct)) - (bottom (org-list-get-bottom-point struct)) - out - (get-text - (function - ;; Return text between BEG and END, trimmed, with - ;; checkboxes replaced. - (lambda (beg end) - (let ((text (org-trim (buffer-substring beg end)))) - (if (string-match "\\`\\[\\([-X ]\\)\\]" text) - (replace-match - (let ((box (match-string 1 text))) - (cond - ((equal box " ") "CBOFF") - ((equal box "-") "CBTRANS") - (t "CBON"))) - t nil text 1) - text))))) - (parse-sublist - (function - ;; Return a list whose car is list type and cdr a list of - ;; items' body. - (lambda (e) - (cons (org-list-get-list-type (car e) struct prevs) - (mapcar parse-item e))))) - (parse-item - (function - ;; Return a list containing counter of item, if any, text - ;; and any sublist inside it. - (lambda (e) - (let ((start (save-excursion - (goto-char e) - (looking-at "[ \t]*\\S-+\\([ \t]+\\[@\\(start:\\)?\\([0-9]+\\|[a-zA-Z]\\)\\]\\)?[ \t]*") - (match-end 0))) - ;; Get counter number. For alphabetic counter, get - ;; its position in the alphabet. - (counter (let ((c (org-list-get-counter e struct))) - (cond - ((not c) nil) - ((string-match "[A-Za-z]" c) - (- (string-to-char (upcase (match-string 0 c))) - 64)) - ((string-match "[0-9]+" c) - (string-to-number (match-string 0 c)))))) - (childp (org-list-has-child-p e struct)) - (end (org-list-get-item-end e struct))) - ;; If item has a child, store text between bullet and - ;; next child, then recursively parse all sublists. At - ;; the end of each sublist, check for the presence of - ;; text belonging to the original item. - (if childp - (let* ((children (org-list-get-children e struct parents)) - (body (list (funcall get-text start childp)))) - (while children - (let* ((first (car children)) - (sub (org-list-get-all-items first struct prevs)) - (last-c (car (last sub))) - (last-end (org-list-get-item-end last-c struct))) - (push (funcall parse-sublist sub) body) - ;; Remove children from the list just parsed. - (setq children (cdr (member last-c children))) - ;; There is a chunk of text belonging to the - ;; item if last child doesn't end where next - ;; child starts or where item ends. - (unless (= (or (car children) end) last-end) - (push (funcall get-text - last-end (or (car children) end)) - body)))) - (cons counter (nreverse body))) - (list counter (funcall get-text start end)))))))) +Point is left at list's end." + (letrec ((struct (org-list-struct)) + (prevs (org-list-prevs-alist struct)) + (parents (org-list-parents-alist struct)) + (top (org-list-get-top-point struct)) + (bottom (org-list-get-bottom-point struct)) + (trim + (lambda (text) + ;; Remove indentation and final newline from TEXT. + (org-remove-indentation + (if (string-match-p "\n\\'" text) + (substring text 0 -1) + text)))) + (parse-sublist + (lambda (e) + ;; Return a list whose car is list type and cdr a list + ;; of items' body. + (cons (org-list-get-list-type (car e) struct prevs) + (mapcar parse-item e)))) + (parse-item + (lambda (e) + ;; Return a list containing counter of item, if any, + ;; text and any sublist inside it. + (let* ((end (org-list-get-item-end e struct)) + (children (org-list-get-children e struct parents)) + (body + (save-excursion + (goto-char e) + (looking-at "[ \t]*\\S-+[ \t]*") + (list + (funcall + trim + (concat + (make-string (string-width (match-string 0)) ?\s) + (buffer-substring-no-properties + (match-end 0) (or (car children) end)))))))) + (while children + (let* ((child (car children)) + (sub (org-list-get-all-items child struct prevs)) + (last-in-sub (car (last sub)))) + (push (funcall parse-sublist sub) body) + ;; Remove whole sub-list from children. + (setq children (cdr (memq last-in-sub children))) + ;; There is a chunk of text belonging to the item + ;; if last child doesn't end where next child + ;; starts or where item ends. + (let ((sub-end (org-list-get-item-end last-in-sub struct)) + (next (or (car children) end))) + (when (/= sub-end next) + (push (funcall + trim + (buffer-substring-no-properties sub-end next)) + body))))) + (nreverse body))))) ;; Store output, take care of cursor position and deletion of ;; list, then return output. - (setq out (funcall parse-sublist (org-list-get-all-items top struct prevs))) - (goto-char top) - (when delete - (delete-region top bottom) - (when (and (not (looking-at "[ \t]*$")) (looking-at org-list-end-re)) - (replace-match ""))) - out)) + (prog1 (funcall parse-sublist (org-list-get-all-items top struct prevs)) + (goto-char top) + (when delete + (delete-region top bottom) + (when (and (not (looking-at "[ \t]*$")) (looking-at org-list-end-re)) + (replace-match "")))))) (defun org-list-make-subtree () "Convert the plain list at point into a subtree." (interactive) (if (not (ignore-errors (goto-char (org-in-item-p)))) (error "Not in a list") - (let ((list (save-excursion (org-list-parse-list t)))) + (let ((list (save-excursion (org-list-to-lisp t)))) (insert (org-list-to-subtree list))))) (defun org-list-insert-radio-list () @@ -3076,11 +3220,13 @@ for this list." (catch 'exit (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]+SEND[ \t]+\\(\\S-+\\)[ \t]+\\(\\S-+\\)") - (if maybe (throw 'exit nil) - (error "Don't know how to transform this list")))) - (let* ((name (match-string 1)) + (let ((case-fold-search t)) + (re-search-backward "^[ \t]*#\\+ORGLST:" nil t) + (unless (looking-at + "[ \t]*#\\+ORGLST:[ \t]+SEND[ \t]+\\(\\S-+\\)[ \t]+\\([^ \t\n]+\\)") + (if maybe (throw 'exit nil) + (error "Don't know how to transform this list"))))) + (let* ((name (regexp-quote (match-string 1))) (transform (intern (match-string 2))) (bottom-point (save-excursion @@ -3092,220 +3238,371 @@ for this list." (re-search-backward "#\\+ORGLST" nil t) (re-search-forward (org-item-beginning-re) bottom-point t) (match-beginning 0))) - (plain-list (buffer-substring-no-properties top-point bottom-point)) - beg) + (plain-list (save-excursion + (goto-char top-point) + (org-list-to-lisp)))) (unless (fboundp transform) (error "No such transformation function %s" transform)) (let ((txt (funcall transform plain-list))) - ;; Find the insertion place + ;; Find the insertion(s) place(s). (save-excursion (goto-char (point-min)) - (unless (re-search-forward - (concat "BEGIN RECEIVE ORGLST +" - name - "\\([ \t]\\|$\\)") - nil t) - (error "Don't know where to insert translated list")) - (goto-char (match-beginning 0)) - (beginning-of-line 2) - (setq beg (point)) - (unless (re-search-forward (concat "END RECEIVE ORGLST +" name) nil t) - (error "Cannot find end of insertion region")) - (delete-region beg (point-at-bol)) - (goto-char beg) - (insert txt "\n"))) - (message "List converted and installed at receiver location")))) - -(defsubst org-list-item-trim-br (item) - "Trim line breaks in a list ITEM." - (setq item (replace-regexp-in-string "\n +" " " item))) + (let ((receiver-count 0) + (begin-re (format "BEGIN +RECEIVE +ORGLST +%s\\([ \t]\\|$\\)" + name)) + (end-re (format "END +RECEIVE +ORGLST +%s\\([ \t]\\|$\\)" + name))) + (while (re-search-forward begin-re nil t) + (cl-incf receiver-count) + (let ((beg (line-beginning-position 2))) + (unless (re-search-forward end-re nil t) + (user-error "Cannot find end of receiver location at %d" beg)) + (beginning-of-line) + (delete-region beg (point)) + (insert txt "\n"))) + (cond + ((> receiver-count 1) + (message "List converted and installed at receiver locations")) + ((= receiver-count 1) + (message "List converted and installed at receiver location")) + (t (user-error "No valid receiver location found"))))))))) (defun org-list-to-generic (list params) - "Convert a LIST parsed through `org-list-parse-list' to other formats. -Valid parameters PARAMS are: - -:ustart String to start an unordered list -:uend String to end an unordered list - -:ostart String to start an ordered list -:oend String to end an ordered list - -:dstart String to start a descriptive list -:dend String to end a descriptive list -:dtstart String to start a descriptive term -:dtend String to end a descriptive term -:ddstart String to start a description -:ddend String to end a description - -:splice When set to t, return only list body lines, don't wrap - them into :[u/o]start and :[u/o]end. Default is nil. - -:istart String to start a list item. -:icount String to start an item with a counter. -:iend String to end a list item -:isep String to separate items -:lsep String to separate sublists -:csep String to separate text from a sub-list - -:cboff String to insert for an unchecked check-box -:cbon String to insert for a checked check-box -:cbtrans String to insert for a check-box in transitional state - -:nobr Non-nil means remove line breaks in lists items. - -Alternatively, each parameter can also be a form returning -a string. These sexp can use keywords `counter' and `depth', -representing respectively counter associated to the current -item, and depth of the current sub-list, starting at 0. -Obviously, `counter' is only available for parameters applying to -items." - (interactive) - (let* ((p params) - (splicep (plist-get p :splice)) - (ostart (plist-get p :ostart)) - (oend (plist-get p :oend)) - (ustart (plist-get p :ustart)) - (uend (plist-get p :uend)) - (dstart (plist-get p :dstart)) - (dend (plist-get p :dend)) - (dtstart (plist-get p :dtstart)) - (dtend (plist-get p :dtend)) - (ddstart (plist-get p :ddstart)) - (ddend (plist-get p :ddend)) - (istart (plist-get p :istart)) - (icount (plist-get p :icount)) - (iend (plist-get p :iend)) - (isep (plist-get p :isep)) - (lsep (plist-get p :lsep)) - (csep (plist-get p :csep)) - (cbon (plist-get p :cbon)) - (cboff (plist-get p :cboff)) - (cbtrans (plist-get p :cbtrans)) - (nobr (plist-get p :nobr)) - export-sublist ; for byte-compiler - (export-item - (function - ;; Export an item ITEM of type TYPE, at DEPTH. First - ;; string in item is treated in a special way as it can - ;; bring extra information that needs to be processed. - (lambda (item type depth) - (let* ((counter (pop item)) - (fmt (concat - (cond - ((eq type 'descriptive) - ;; Stick DTSTART to ISTART by - ;; left-trimming the latter. - (concat (let ((s (eval istart))) - (or (and (string-match "[ \t\n\r]+\\'" s) - (replace-match "" t t s)) - istart)) - "%s" (eval ddend))) - ((and counter (eq type 'ordered)) - (concat (eval icount) "%s")) - (t (concat (eval istart) "%s"))) - (eval iend))) - (first (car item))) - ;; Replace checkbox if any is found. - (cond - ((string-match "\\[CBON\\]" first) - (setq first (replace-match cbon t t first))) - ((string-match "\\[CBOFF\\]" first) - (setq first (replace-match cboff t t first))) - ((string-match "\\[CBTRANS\\]" first) - (setq first (replace-match cbtrans t t first)))) - ;; Replace line breaks if required - (when nobr (setq first (org-list-item-trim-br first))) - ;; Insert descriptive term if TYPE is `descriptive'. - (when (eq type 'descriptive) - (let* ((complete - (string-match "^\\(.*\\)[ \t]+::[ \t]*" first)) - (term (if complete - (save-match-data - (org-trim (match-string 1 first))) - "???")) - (desc (if complete (substring first (match-end 0)) - first))) - (setq first (concat (eval dtstart) term (eval dtend) - (eval ddstart) desc)))) - (setcar item first) - (format fmt - (mapconcat (lambda (e) - (if (stringp e) e - (funcall export-sublist e (1+ depth)))) - item (or (eval csep) ""))))))) - (export-sublist - (function - ;; Export sublist SUB at DEPTH. - (lambda (sub depth) - (let* ((type (car sub)) - (items (cdr sub)) - (fmt (concat (cond - (splicep "%s") - ((eq type 'ordered) - (concat (eval ostart) "%s" (eval oend))) - ((eq type 'descriptive) - (concat (eval dstart) "%s" (eval dend))) - (t (concat (eval ustart) "%s" (eval uend)))) - (eval lsep)))) - (format fmt (mapconcat (lambda (e) - (funcall export-item e type depth)) - items (or (eval isep) "")))))))) - (concat (funcall export-sublist list 0) "\n"))) - -(defun org-list-to-latex (list &optional _params) + "Convert a LIST parsed through `org-list-to-lisp' to a custom format. + +LIST is a list as returned by `org-list-to-lisp', which see. +PARAMS is a property list of parameters used to tweak the output +format. + +Valid parameters are: + +:backend, :raw + + Export back-end used as a basis to transcode elements of the + list, when no specific parameter applies to it. It is also + used to translate its contents. You can prevent this by + setting :raw property to a non-nil value. + +:splice + + When non-nil, only export the contents of the top most plain + list, effectively ignoring its opening and closing lines. + +:ustart, :uend + + Strings to start and end an unordered list. They can also be + set to a function returning a string or nil, which will be + called with the depth of the list, counting from 1. + +:ostart, :oend + + Strings to start and end an ordered list. They can also be set + to a function returning a string or nil, which will be called + with the depth of the list, counting from 1. + +:dstart, :dend + + Strings to start and end a descriptive list. They can also be + set to a function returning a string or nil, which will be + called with the depth of the list, counting from 1. + +:dtstart, :dtend, :ddstart, :ddend + + Strings to start and end a descriptive term. + +:istart, :iend + + Strings to start or end a list item, and to start a list item + with a counter. They can also be set to a function returning + a string or nil, which will be called with two arguments: the + type of list and the depth of the item, counting from 1. + +:icount + + Strings to start a list item with a counter. It can also be + set to a function returning a string or nil, which will be + called with three arguments: the type of list, the depth of the + item, counting from 1, and the counter. Its value, when + non-nil, has precedence over `:istart'. + +:isep + + String used to separate items. It can also be set to + a function returning a string or nil, which will be called with + two arguments: the type of list and the depth of the item, + counting from 1. It always start on a new line. + +:ifmt + + Function to be applied to the contents of every item. It is + called with two arguments: the type of list and the contents. + +:cbon, :cboff, :cbtrans + + String to insert, respectively, an un-checked check-box, + a checked check-box and a check-box in transitional state." + (require 'ox) + (let* ((backend (plist-get params :backend)) + (custom-backend + (org-export-create-backend + :parent (or backend 'org) + :transcoders + `((plain-list . ,(org-list--to-generic-plain-list params)) + (item . ,(org-list--to-generic-item params)) + (macro . (lambda (m c i) (org-element-macro-interpreter m nil)))))) + data info) + ;; Write LIST back into Org syntax and parse it. + (with-temp-buffer + (let ((org-inhibit-startup t)) (org-mode)) + (letrec ((insert-list + (lambda (l) + (dolist (i (cdr l)) + (funcall insert-item i (car l))))) + (insert-item + (lambda (i type) + (let ((start (point))) + (insert (if (eq type 'ordered) "1. " "- ")) + (dolist (e i) + (if (consp e) (funcall insert-list e) + (insert e) + (insert "\n"))) + (beginning-of-line) + (save-excursion + (let ((ind (if (eq type 'ordered) 3 2))) + (while (> (point) start) + (unless (looking-at-p "[ \t]*$") + (indent-to ind)) + (forward-line -1)))))))) + (funcall insert-list list)) + (setf data + (org-element-map (org-element-parse-buffer) 'plain-list + #'identity nil t)) + (setf info (org-export-get-environment backend nil params))) + (when (and backend (symbolp backend) (not (org-export-get-backend backend))) + (user-error "Unknown :backend value")) + (unless backend (require 'ox-org)) + ;; When`:raw' property has a non-nil value, turn all objects back + ;; into Org syntax. + (when (and backend (plist-get params :raw)) + (org-element-map data org-element-all-objects + (lambda (object) + (org-element-set-element + object (org-element-interpret-data object))))) + ;; We use a low-level mechanism to export DATA so as to skip all + ;; usual pre-processing and post-processing, i.e., hooks, filters, + ;; Babel code evaluation, include keywords and macro expansion, + ;; and filters. + (let ((output (org-export-data-with-backend data custom-backend info))) + ;; Remove final newline. + (if (org-string-nw-p output) (substring-no-properties output 0 -1) "")))) + +(defun org-list--depth (element) + "Return the level of ELEMENT within current plain list. +ELEMENT is either an item or a plain list." + (cl-count-if (lambda (ancestor) (eq (org-element-type ancestor) 'plain-list)) + (org-element-lineage element nil t))) + +(defun org-list--trailing-newlines (string) + "Return the number of trailing newlines in STRING." + (with-temp-buffer + (insert string) + (skip-chars-backward " \t\n") + (count-lines (line-beginning-position 2) (point-max)))) + +(defun org-list--generic-eval (value &rest args) + "Evaluate VALUE according to its type. +VALUE is either nil, a string or a function. In the latter case, +it is called with arguments ARGS." + (cond ((null value) nil) + ((stringp value) value) + ((functionp value) (apply value args)) + (t (error "Wrong value: %s" value)))) + +(defun org-list--to-generic-plain-list (params) + "Return a transcoder for `plain-list' elements. +PARAMS is a plist used to tweak the behavior of the transcoder." + (let ((ustart (plist-get params :ustart)) + (uend (plist-get params :uend)) + (ostart (plist-get params :ostart)) + (oend (plist-get params :oend)) + (dstart (plist-get params :dstart)) + (dend (plist-get params :dend)) + (splice (plist-get params :splice)) + (backend (plist-get params :backend))) + (lambda (plain-list contents info) + (let* ((type (org-element-property :type plain-list)) + (depth (org-list--depth plain-list)) + (start (and (not splice) + (org-list--generic-eval + (pcase type + (`ordered ostart) + (`unordered ustart) + (_ dstart)) + depth))) + (end (and (not splice) + (org-list--generic-eval + (pcase type + (`ordered oend) + (`unordered uend) + (_ dend)) + depth)))) + ;; Make sure trailing newlines in END appear in the output by + ;; setting `:post-blank' property to their number. + (when end + (org-element-put-property + plain-list :post-blank (org-list--trailing-newlines end))) + ;; Build output. + (concat (and start (concat start "\n")) + (if (or start end splice (not backend)) + contents + (org-export-with-backend backend plain-list contents info)) + end))))) + +(defun org-list--to-generic-item (params) + "Return a transcoder for `item' elements. +PARAMS is a plist used to tweak the behavior of the transcoder." + (let ((backend (plist-get params :backend)) + (istart (plist-get params :istart)) + (iend (plist-get params :iend)) + (isep (plist-get params :isep)) + (icount (plist-get params :icount)) + (ifmt (plist-get params :ifmt)) + (cboff (plist-get params :cboff)) + (cbon (plist-get params :cbon)) + (cbtrans (plist-get params :cbtrans)) + (dtstart (plist-get params :dtstart)) + (dtend (plist-get params :dtend)) + (ddstart (plist-get params :ddstart)) + (ddend (plist-get params :ddend))) + (lambda (item contents info) + (let* ((type + (org-element-property :type (org-element-property :parent item))) + (tag (org-element-property :tag item)) + (depth (org-list--depth item)) + (separator (and (org-export-get-next-element item info) + (org-list--generic-eval isep type depth))) + (closing (pcase (org-list--generic-eval iend type depth) + ((or `nil "") "\n") + ((and (guard separator) s) + (if (equal (substring s -1) "\n") s (concat s "\n"))) + (s s)))) + ;; When a closing line or a separator is provided, make sure + ;; its trailing newlines are taken into account when building + ;; output. This is done by setting `:post-blank' property to + ;; the number of such lines in the last line to be added. + (let ((last-string (or separator closing))) + (when last-string + (org-element-put-property + item + :post-blank + (max (1- (org-list--trailing-newlines last-string)) 0)))) + ;; Build output. + (concat + (let ((c (org-element-property :counter item))) + (if (and c icount) (org-list--generic-eval icount type depth c) + (org-list--generic-eval istart type depth))) + (let ((body + (if (or istart iend icount ifmt cbon cboff cbtrans (not backend) + (and (eq type 'descriptive) + (or dtstart dtend ddstart ddend))) + (concat + (pcase (org-element-property :checkbox item) + (`on cbon) + (`off cboff) + (`trans cbtrans)) + (and tag + (concat dtstart + (if backend + (org-export-data-with-backend + tag backend info) + (org-element-interpret-data tag)) + dtend)) + (and tag ddstart) + (let ((contents + (if (= (length contents) 0) "" + (substring contents 0 -1)))) + (if ifmt (org-list--generic-eval ifmt type contents) + contents)) + (and tag ddend)) + (org-export-with-backend backend item contents info)))) + ;; Remove final newline. + (if (equal body "") "" + (substring (org-element-normalize-string body) 0 -1))) + closing + separator))))) + +(defun org-list-to-latex (list &optional params) "Convert LIST into a LaTeX list. -LIST is as string representing the list to transform, as Org -syntax. Return converted list as a string." +LIST is a parsed plain list, as returned by `org-list-to-lisp'. +PARAMS is a property list with overruling parameters for +`org-list-to-generic'. Return converted list as a string." (require 'ox-latex) - (org-export-string-as list 'latex t)) + (org-list-to-generic list (org-combine-plists '(:backend latex) params))) -(defun org-list-to-html (list) +(defun org-list-to-html (list &optional params) "Convert LIST into a HTML list. -LIST is as string representing the list to transform, as Org -syntax. Return converted list as a string." +LIST is a parsed plain list, as returned by `org-list-to-lisp'. +PARAMS is a property list with overruling parameters for +`org-list-to-generic'. Return converted list as a string." (require 'ox-html) - (org-export-string-as list 'html t)) + (org-list-to-generic list (org-combine-plists '(:backend html) params))) -(defun org-list-to-texinfo (list &optional _params) +(defun org-list-to-texinfo (list &optional params) "Convert LIST into a Texinfo list. -LIST is as string representing the list to transform, as Org -syntax. Return converted list as a string." +LIST is a parsed plain list, as returned by `org-list-to-lisp'. +PARAMS is a property list with overruling parameters for +`org-list-to-generic'. Return converted list as a string." (require 'ox-texinfo) - (org-export-string-as list 'texinfo t)) + (org-list-to-generic list (org-combine-plists '(:backend texinfo) params))) -(defun org-list-to-subtree (list &optional params) - "Convert LIST into an Org subtree. +(defun org-list-to-org (list &optional params) + "Convert LIST into an Org plain list. LIST is as returned by `org-list-parse-list'. PARAMS is a property list with overruling parameters for `org-list-to-generic'." - (defvar get-stars) (defvar org--blankp) - (let* ((rule (cdr (assq 'heading org-blank-before-new-entry))) + (let* ((make-item + (lambda (type _depth &optional c) + (concat (if (eq type 'ordered) "1. " "- ") + (and c (format "[@%d] " c))))) + (defaults + (list :istart make-item + :icount make-item + :ifmt (lambda (_type contents) + (replace-regexp-in-string "\n" "\n " contents)) + :dtend " :: " + :cbon "[X] " + :cboff "[ ] " + :cbtrans "[-] "))) + (org-list-to-generic list (org-combine-plists defaults params)))) + +(defun org-list-to-subtree (list &optional params) + "Convert LIST into an Org subtree. +LIST is as returned by `org-list-to-lisp'. PARAMS is a property +list with overruling parameters for `org-list-to-generic'." + (let* ((blank (pcase (cdr (assq 'heading org-blank-before-new-entry)) + (`t t) + (`auto (save-excursion + (org-with-limited-levels (outline-previous-heading)) + (org-previous-line-empty-p))))) (level (org-reduced-level (or (org-current-level) 0))) - (org--blankp (or (eq rule t) - (and (eq rule 'auto) - (save-excursion - (outline-previous-heading) - (org-previous-line-empty-p))))) - (get-stars ;FIXME: Can't rename without renaming it in org.el as well! - (function - ;; Return the string for the heading, depending on depth D - ;; of current sub-list. - (lambda (d) - (let ((oddeven-level (+ level d 1))) - (concat (make-string (if org-odd-levels-only - (1- (* 2 oddeven-level)) - oddeven-level) - ?*) - " ")))))) + (make-stars + (lambda (_type depth &optional _count) + ;; Return the string for the heading, depending on DEPTH + ;; of current sub-list. + (let ((oddeven-level (+ level depth))) + (concat (make-string (if org-odd-levels-only + (1- (* 2 oddeven-level)) + oddeven-level) + ?*) + " "))))) (org-list-to-generic list (org-combine-plists - '(:splice t - :dtstart " " :dtend " " - :istart (funcall get-stars depth) - :icount (funcall get-stars depth) - :isep (if org--blankp "\n\n" "\n") - :csep (if org--blankp "\n\n" "\n") - :cbon "DONE" :cboff "TODO" :cbtrans "TODO") + (list :splice t + :istart make-stars + :icount make-stars + :dtstart " " :dtend " " + :isep (if blank "\n\n" "\n") + :cbon "DONE " :cboff "TODO " :cbtrans "TODO ") params)))) (provide 'org-list) diff --git a/elpa/org-plus-contrib-20150831/org-loaddefs.el b/elpa/org-plus-contrib-20170407/org-loaddefs.el similarity index 77% rename from elpa/org-plus-contrib-20150831/org-loaddefs.el rename to elpa/org-plus-contrib-20170407/org-loaddefs.el index b81ac892..a5f72d07 100644 --- a/elpa/org-plus-contrib-20150831/org-loaddefs.el +++ b/elpa/org-plus-contrib-20170407/org-loaddefs.el @@ -2,28 +2,16 @@ ;; ;;; Code: -;;;### (autoloads (org-babel-mark-block org-babel-previous-src-block -;;;;;; org-babel-next-src-block org-babel-goto-named-result org-babel-goto-named-src-block -;;;;;; org-babel-goto-src-block-head org-babel-hide-result-toggle-maybe -;;;;;; org-babel-sha1-hash org-babel-execute-subtree org-babel-execute-buffer -;;;;;; org-babel-map-executables org-babel-map-call-lines org-babel-map-inline-src-blocks -;;;;;; org-babel-map-src-blocks org-babel-open-src-block-result -;;;;;; org-babel-do-in-edit-buffer org-babel-switch-to-session-with-code -;;;;;; org-babel-switch-to-session org-babel-initiate-session org-babel-load-in-session -;;;;;; org-babel-insert-header-arg org-babel-check-src-block org-babel-expand-src-block -;;;;;; org-babel-execute-src-block org-babel-pop-to-session-maybe -;;;;;; org-babel-load-in-session-maybe org-babel-expand-src-block-maybe -;;;;;; org-babel-view-src-block-info org-babel-execute-maybe org-babel-execute-safely-maybe) -;;;;;; "ob-core" "ob-core.el" "73dfba1940f5e5b43a352c8c790b72f7") +;;;### (autoloads nil "ob-core" "ob-core.el" (22757 57238 0 0)) ;;; Generated autoloads from ob-core.el (autoload 'org-babel-execute-safely-maybe "ob-core" "\ -Not documented + \(fn)" nil nil) (autoload 'org-babel-execute-maybe "ob-core" "\ -Not documented + \(fn)" t nil) @@ -123,7 +111,7 @@ Switch to code buffer and display session. 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. -\(fn &rest BODY)" nil (quote macro)) +\(fn &rest BODY)" nil t) (autoload 'org-babel-open-src-block-result "ob-core" "\ If `point' is on a src block then open the results of the @@ -155,26 +143,36 @@ 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 -\(fn FILE &rest BODY)" nil (quote macro)) +\(fn FILE &rest BODY)" nil t) + +(function-put 'org-babel-map-src-blocks 'lisp-indent-function '1) (autoload 'org-babel-map-inline-src-blocks "ob-core" "\ -Evaluate BODY forms on each inline source-block in FILE. +Evaluate BODY forms on each inline source block in FILE. If FILE is nil evaluate BODY forms on source blocks in current buffer. -\(fn FILE &rest BODY)" nil (quote macro)) +\(fn FILE &rest BODY)" nil t) + +(function-put 'org-babel-map-inline-src-blocks 'lisp-indent-function '1) (autoload 'org-babel-map-call-lines "ob-core" "\ Evaluate BODY forms on each call line in FILE. If FILE is nil evaluate BODY forms on source blocks in current buffer. -\(fn FILE &rest BODY)" nil (quote macro)) +\(fn FILE &rest BODY)" nil t) + +(function-put 'org-babel-map-call-lines 'lisp-indent-function '1) (autoload 'org-babel-map-executables "ob-core" "\ -Not documented +Evaluate BODY forms on each active Babel code in FILE. +If FILE is nil evaluate BODY forms on source blocks in current +buffer. + +\(fn FILE &rest BODY)" nil t) -\(fn FILE &rest BODY)" nil (quote macro)) +(function-put 'org-babel-map-executables 'lisp-indent-function '1) (autoload 'org-babel-execute-buffer "ob-core" "\ Execute source code blocks in a buffer. @@ -234,8 +232,7 @@ Mark current src block. ;;;*** -;;;### (autoloads (org-babel-describe-bindings) "ob-keys" "ob-keys.el" -;;;;;; "120511b104b79537595411024cdbd951") +;;;### (autoloads nil "ob-keys" "ob-keys.el" (22757 57238 0 0)) ;;; Generated autoloads from ob-keys.el (autoload 'org-babel-describe-bindings "ob-keys" "\ @@ -245,8 +242,7 @@ Describe all keybindings behind `org-babel-key-prefix'. ;;;*** -;;;### (autoloads (org-babel-lob-get-info org-babel-lob-execute-maybe) -;;;;;; "ob-lob" "ob-lob.el" "dc5eea39f8ebcd4f8965f663f02abfa9") +;;;### (autoloads nil "ob-lob" "ob-lob.el" (22757 57238 0 0)) ;;; Generated autoloads from ob-lob.el (autoload 'org-babel-lob-execute-maybe "ob-lob" "\ @@ -257,14 +253,16 @@ if so then run the appropriate source block from the Library. \(fn)" t nil) (autoload 'org-babel-lob-get-info "ob-lob" "\ -Return a Library of Babel function call as a string. +Return internal representation for Library of Babel function call. +Consider DATUM, when provided, or element at point. Return nil +when not on an appropriate location. Otherwise return a list +compatible with `org-babel-get-src-block-info', which see. -\(fn)" nil nil) +\(fn &optional DATUM)" nil nil) ;;;*** -;;;### (autoloads (org-babel-tangle org-babel-tangle-file) "ob-tangle" -;;;;;; "ob-tangle.el" "968d3cfa982f9109d98abc8424192433") +;;;### (autoloads nil "ob-tangle" "ob-tangle.el" (22757 57238 0 0)) ;;; Generated autoloads from ob-tangle.el (autoload 'org-babel-tangle-file "ob-tangle" "\ @@ -292,13 +290,8 @@ used to limit the exported source code blocks by language. ;;;*** -;;;### (autoloads (org-agenda-to-appt org-calendar-goto-agenda org-agenda-set-restriction-lock -;;;;;; org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item -;;;;;; org-diary org-agenda-list-stuck-projects org-tags-view org-todo-list -;;;;;; org-search-view org-agenda-list org-batch-store-agenda-views -;;;;;; org-store-agenda-views org-batch-agenda-csv org-batch-agenda -;;;;;; org-agenda org-toggle-sticky-agenda) "org-agenda" "org-agenda.el" -;;;;;; (21986 36918)) +;;;### (autoloads nil "org-agenda" "org-agenda.el" (22757 57238 0 +;;;;;; 0)) ;;; Generated autoloads from org-agenda.el (autoload 'org-toggle-sticky-agenda "org-agenda" "\ @@ -318,7 +311,6 @@ T Call `org-todo-list' to display the global todo list, select only m Call `org-tags-view' to display headlines with tags matching a condition (the user is prompted for the condition). M Like `m', but select only TODO entries, no ordinary headlines. -L Create a timeline for the current buffer. e Export views to associated files. s Search entries for keywords. S Search entries for keywords, only with TODO keywords. @@ -335,9 +327,9 @@ More commands can be added by configuring the variable `org-agenda-custom-commands'. In particular, specific tags and TODO keyword searches can be pre-defined in this way. -If the current buffer is in Org-mode and visiting a file, you can also +If the current buffer is in Org mode and visiting a file, you can also first press `<' once to indicate that the agenda should be temporarily -\(until the next use of \\[org-agenda]) restricted to the current file. +\(until the next use of `\\[org-agenda]') restricted to the current file. Pressing `<' twice means to restrict to the current subtree or region \(if active). @@ -351,7 +343,7 @@ 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. -\(fn CMD-KEY &rest PARAMETERS)" nil (quote macro)) +\(fn CMD-KEY &rest PARAMETERS)" nil t) (autoload 'org-batch-agenda-csv "org-agenda" "\ Run an agenda command in batch mode and send the result to STDOUT. @@ -388,7 +380,7 @@ priority-l The priority letter if any was given priority-n The computed numerical priority agenda-day The day in the agenda where this is listed -\(fn CMD-KEY &rest PARAMETERS)" nil (quote macro)) +\(fn CMD-KEY &rest PARAMETERS)" nil t) (autoload 'org-store-agenda-views "org-agenda" "\ Store agenda views. @@ -398,7 +390,7 @@ Store agenda views. (autoload 'org-batch-store-agenda-views "org-agenda" "\ Run all custom agenda commands that have a file argument. -\(fn &rest PARAMETERS)" nil (quote macro)) +\(fn &rest PARAMETERS)" nil t) (autoload 'org-agenda-list "org-agenda" "\ Produce a daily/weekly view from all files in variable `org-agenda-files'. @@ -466,7 +458,7 @@ in `org-agenda-text-search-extra-files'. (autoload 'org-todo-list "org-agenda" "\ Show all (not done) TODO entries from all agenda file in a single list. The prefix arg can be used to select a specific TODO keyword and limit -the list to these. When using \\[universal-argument], you will be prompted +the list to these. When using `\\[universal-argument]', you will be prompted for a keyword. A numeric prefix directly selects the Nth keyword in `org-todo-keywords-1'. @@ -523,21 +515,21 @@ Do we have a reason to ignore this TODO entry because it has a time stamp? (autoload 'org-agenda-set-restriction-lock "org-agenda" "\ Set restriction lock for agenda, to current subtree or file. Restriction will be the file if TYPE is `file', or if type is the -universal prefix '(4), or if the cursor is before the first headline +universal prefix \\='(4), or if the cursor is before the first headline in the file. Otherwise, restriction will be to the current subtree. \(fn &optional TYPE)" t nil) (autoload 'org-calendar-goto-agenda "org-agenda" "\ -Compute the Org-mode agenda for the calendar date displayed at the cursor. +Compute the Org agenda for the calendar date displayed at the cursor. This is a command that has to be installed in `calendar-mode-map'. \(fn)" t nil) (autoload 'org-agenda-to-appt "org-agenda" "\ Activate appointments found in `org-agenda-files'. -With a \\[universal-argument] prefix, refresh the list of -appointments. + +With a `\\[universal-argument]' prefix, refresh the list of appointments. If FILTER is t, interactively prompt the user for a regular expression, and filter out entries that don't match it. @@ -550,9 +542,9 @@ calling the function returns nil. This function takes one argument: an entry from `org-agenda-get-day-entries'. FILTER can also be an alist with the car of each cell being -either 'headline or 'category. For example: +either `headline' or `category'. For example: - '((headline \"IMPORTANT\") + \\='((headline \"IMPORTANT\") (category \"Work\")) will only add headlines containing IMPORTANT or headlines @@ -571,8 +563,8 @@ to override `appt-message-warning-time'. ;;;*** -;;;### (autoloads (org-annotate-file-show-section org-annotate-file) -;;;;;; "org-annotate-file" "org-annotate-file.el" (21953 19361)) +;;;### (autoloads nil "org-annotate-file" "org-annotate-file.el" +;;;;;; (22757 57238 0 0)) ;;; Generated autoloads from org-annotate-file.el (autoload 'org-annotate-file "org-annotate-file" "\ @@ -591,10 +583,8 @@ The annotation will link to ANNOTATED-BUFFER if specified, ;;;*** -;;;### (autoloads (org-archive-subtree-default-with-confirmation -;;;;;; org-archive-subtree-default org-toggle-archive-tag org-archive-to-archive-sibling -;;;;;; org-archive-subtree org-add-archive-files) "org-archive" -;;;;;; "org-archive.el" "3d45871a918bccfda0ed5aa8ce2828f8") +;;;### (autoloads nil "org-archive" "org-archive.el" (22757 57238 +;;;;;; 0 0)) ;;; Generated autoloads from org-archive.el (autoload 'org-add-archive-files "org-archive" "\ @@ -622,10 +612,13 @@ this heading. (autoload 'org-archive-to-archive-sibling "org-archive" "\ Archive the current heading by moving it under the archive sibling. + The archive sibling is a sibling of the heading with the heading name `org-archive-sibling-heading' and an `org-archive-tag' tag. If this sibling does not exist, it will be created at the end of the subtree. +Archiving time is retained in the ARCHIVE_TIME node property. + \(fn)" t nil) (autoload 'org-toggle-archive-tag "org-archive" "\ @@ -649,7 +642,8 @@ This command is set with the variable `org-archive-default-command'. ;;;*** -;;;### (autoloads (org-attach) "org-attach" "org-attach.el" "02c6d147939c83c1311423492e8bbda3") +;;;### (autoloads nil "org-attach" "org-attach.el" (22757 57238 0 +;;;;;; 0)) ;;; Generated autoloads from org-attach.el (autoload 'org-attach "org-attach" "\ @@ -660,8 +654,7 @@ Shows a list of commands and prompts for another key to execute a command. ;;;*** -;;;### (autoloads (org-bbdb-anniversaries) "org-bbdb" "org-bbdb.el" -;;;;;; "7b7a2669c8c50375f19fac9b951a3cdc") +;;;### (autoloads nil "org-bbdb" "org-bbdb.el" (22757 57238 0 0)) ;;; Generated autoloads from org-bbdb.el (autoload 'org-bbdb-anniversaries "org-bbdb" "\ @@ -671,20 +664,8 @@ Extract anniversaries from BBDB for display in the agenda. ;;;*** -;;;### (autoloads (org-bullets-mode) "org-bullets" "org-bullets.el" -;;;;;; (21028 28790)) -;;; Generated autoloads from org-bullets.el - -(autoload 'org-bullets-mode "org-bullets" "\ -UTF-8 bullets for `org-mode'. - -\(fn &optional ARG)" t nil) - -;;;*** - -;;;### (autoloads (org-capture-import-remember-templates org-capture -;;;;;; org-capture-string) "org-capture" "org-capture.el" (21976 -;;;;;; 1078)) +;;;### (autoloads nil "org-capture" "org-capture.el" (22757 57238 +;;;;;; 0 0)) ;;; Generated autoloads from org-capture.el (autoload 'org-capture-string "org-capture" "\ @@ -695,19 +676,23 @@ Capture STRING with the template selected by KEYS. (autoload 'org-capture "org-capture" "\ Capture something. \\ -This will let you select a template from `org-capture-templates', and then -file the newly captured information. The text is immediately inserted -at the target location, and an indirect buffer is shown where you can -edit it. Pressing \\[org-capture-finalize] brings you back to the previous state -of Emacs, so that you can continue your work. +This will let you select a template from `org-capture-templates', and +then file the newly captured information. The text is immediately +inserted at the target location, and an indirect buffer is shown where +you can edit it. Pressing `\\[org-capture-finalize]' brings you back to the previous +state of Emacs, so that you can continue your work. + +When called interactively with a `\\[universal-argument]' prefix argument GOTO, don't +capture anything, just go to the file/headline where the selected +template stores its notes. -When called interactively with a \\[universal-argument] prefix argument GOTO, don't capture -anything, just go to the file/headline where the selected template -stores its notes. With a double prefix argument \\[universal-argument] \\[universal-argument], go to the last note -stored. +With a `\\[universal-argument] \\[universal-argument]' prefix argument, go to the last note stored. When called with a `C-0' (zero) prefix, insert a template at point. +When called with a `C-1' (one) prefix, force prompting for a date when +a datetree entry is made. + ELisp programs can set KEYS to a string associated with a template in `org-capture-templates'. In this case, interactive selection will be bypassed. @@ -726,16 +711,11 @@ Set `org-capture-templates' to be similar to `org-remember-templates'. ;;;*** -;;;### (autoloads (org-clock-update-time-maybe org-dblock-write:clocktable -;;;;;; org-clocktable-shift org-clock-report org-clock-get-clocktable -;;;;;; org-clock-remove-overlays org-clock-display org-clock-sum -;;;;;; org-clock-goto org-clock-cancel org-clock-out org-clock-in-last -;;;;;; org-clock-in org-resolve-clocks) "org-clock" "org-clock.el" -;;;;;; "f302d113e841b271b28c1d507f6133c5") +;;;### (autoloads nil "org-clock" "org-clock.el" (22757 57238 0 0)) ;;; Generated autoloads from org-clock.el (autoload 'org-resolve-clocks "org-clock" "\ -Resolve all currently open org-mode clocks. +Resolve all currently open Org clocks. If `only-dangling-p' is non-nil, only ask to resolve dangling \(i.e., not currently open and valid) clocks. @@ -743,14 +723,19 @@ If `only-dangling-p' is non-nil, only ask to resolve dangling (autoload 'org-clock-in "org-clock" "\ Start the clock on the current item. + If necessary, clock-out of the currently active clock. -With a prefix argument SELECT (\\[universal-argument]), offer a list of recently clocked -tasks to clock into. When SELECT is \\[universal-argument] \\[universal-argument], clock into the current task -and mark it as the default task, a special task that will always be offered -in the clocking selection, associated with the letter `d'. -When SELECT is \\[universal-argument] \\[universal-argument] \\[universal-argument], clock in by using the last clock-out -time as the start time (see `org-clock-continuously' to -make this the default behavior.) + +With a `\\[universal-argument]' prefix argument SELECT, offer a list of recently clocked +tasks to clock into. + +When SELECT is `\\[universal-argument] \\[universal-argument]', clock into the current task and mark it as +the default task, a special task that will always be offered in the +clocking selection, associated with the letter `d'. + +When SELECT is `\\[universal-argument] \\[universal-argument] \\[universal-argument]', clock in by using the last clock-out +time as the start time. See `org-clock-continuously' to make this +the default behavior. \(fn &optional SELECT START-TIME)" t nil) @@ -800,19 +785,23 @@ PROPNAME lets you set a custom text property instead of :org-clock-minutes. (autoload 'org-clock-display "org-clock" "\ Show subtree times in the entire buffer. -With one universal prefix argument, show the total time for -today. With two universal prefix arguments, show the total time -for a custom range, entered at the prompt. With three universal -prefix arguments, show the total time in the echo area. +By default, show the total time for the range defined in +`org-clock-display-default-range'. With `\\[universal-argument]' prefix, show +the total time for today instead. + +With `\\[universal-argument] \\[universal-argument]' prefix, use a custom range, entered at prompt. -Use \\[org-clock-remove-overlays] to remove the subtree times. +With `\\[universal-argument] \\[universal-argument] \\[universal-argument]' prefix, display the total time in the +echo area. + +Use `\\[org-clock-remove-overlays]' to remove the subtree times. \(fn &optional ARG)" t nil) (autoload 'org-clock-remove-overlays "org-clock" "\ Remove the occur highlights from the buffer. -BEG and END are ignored. If NOREMOVE is nil, remove this function -from the `before-change-functions' in the current buffer. +If NOREMOVE is nil, remove this function from the +`before-change-functions' in the current buffer. \(fn &optional BEG END NOREMOVE)" t nil) @@ -860,37 +849,8 @@ Otherwise, return nil. ;;;*** -;;;### (autoloads (org-columns-number-to-string org-columns-compute -;;;;;; org-columns-get-format-and-top-level org-columns-remove-overlays) -;;;;;; "org-colview-xemacs" "org-colview-xemacs.el" (21953 19361)) -;;; Generated autoloads from org-colview-xemacs.el - -(autoload 'org-columns-remove-overlays "org-colview-xemacs" "\ -Remove all currently active column overlays. - -\(fn)" t nil) - -(autoload 'org-columns-get-format-and-top-level "org-colview-xemacs" "\ -Not documented - -\(fn)" nil nil) - -(autoload 'org-columns-compute "org-colview-xemacs" "\ -Sum the values of property PROPERTY hierarchically, for the entire buffer. - -\(fn PROPERTY)" t nil) - -(autoload 'org-columns-number-to-string "org-colview-xemacs" "\ -Convert a computed column number to a string value, according to FMT. - -\(fn N FMT &optional PRINTF)" nil nil) - -;;;*** - -;;;### (autoloads (org-agenda-columns org-insert-columns-dblock org-dblock-write:columnview -;;;;;; org-columns-number-to-string org-columns-compute org-columns -;;;;;; org-columns-get-format-and-top-level org-columns-remove-overlays) -;;;;;; "org-colview" "org-colview.el" (21964 9912)) +;;;### (autoloads nil "org-colview" "org-colview.el" (22757 57238 +;;;;;; 0 0)) ;;; Generated autoloads from org-colview.el (autoload 'org-columns-remove-overlays "org-colview" "\ @@ -899,31 +859,34 @@ Remove all currently active column overlays. \(fn)" t nil) (autoload 'org-columns-get-format-and-top-level "org-colview" "\ -Not documented + \(fn)" nil nil) (autoload 'org-columns "org-colview" "\ -Turn on column view on an org-mode file. +Turn on column view on an Org mode file. + +Column view applies to the whole buffer if point is before the +first headline. Otherwise, it applies to the first ancestor +setting \"COLUMNS\" property. If there is none, it defaults to +the current headline. With a `\\[universal-argument]' prefix argument, turn on column +view for the whole buffer unconditionally. + When COLUMNS-FMT-STRING is non-nil, use it as the column format. -\(fn &optional COLUMNS-FMT-STRING)" t nil) +\(fn &optional GLOBAL COLUMNS-FMT-STRING)" t nil) (autoload 'org-columns-compute "org-colview" "\ -Sum the values of property PROPERTY hierarchically, for the entire buffer. +Summarize the values of PROPERTY hierarchically. +Also update existing values for PROPERTY according to the first +column specification. \(fn PROPERTY)" t nil) -(autoload 'org-columns-number-to-string "org-colview" "\ -Convert a computed column number to a string value, according to FMT. - -\(fn N FMT &optional PRINTF)" nil nil) - (autoload 'org-dblock-write:columnview "org-colview" "\ Write the column view table. PARAMS is a property list of parameters: -:width enforce same column widths with specifiers. :id the :ID: property of the entry where the columns view should be built. When the symbol `local', call locally. When `global' call column view with the cursor at the beginning @@ -933,15 +896,17 @@ PARAMS is a property list of parameters: using `org-id-find'. :hlines When t, insert a hline before each item. When a number, insert a hline before each level <= that number. +:indent When non-nil, indent each ITEM field according to its level. :vlines When t, make each column a colgroup to enforce vertical lines. :maxlevel When set to a number, don't capture headlines below this level. :skip-empty-rows When t, skip rows where all specifiers other than ITEM are empty. +:width apply widths specified in columns format using specifiers. :format When non-nil, specify the column view format to use. \(fn PARAMS)" nil nil) -(autoload 'org-insert-columns-dblock "org-colview" "\ +(autoload 'org-columns-insert-dblock "org-colview" "\ Create a dynamic block capturing a column view table. \(fn)" t nil) @@ -953,19 +918,19 @@ Turn on or update column view in the agenda. ;;;*** -;;;### (autoloads (org-check-version) "org-compat" "org-compat.el" -;;;;;; (21953 39595)) +;;;### (autoloads nil "org-compat" "org-compat.el" (22757 57238 0 +;;;;;; 0)) ;;; Generated autoloads from org-compat.el (autoload 'org-check-version "org-compat" "\ Try very hard to provide sensible version strings. -\(fn)" nil (quote macro)) +\(fn)" nil t) ;;;*** -;;;### (autoloads (org-contacts) "org-contacts" "org-contacts.el" -;;;;;; (21953 19361)) +;;;### (autoloads nil "org-contacts" "org-contacts.el" (22757 57238 +;;;;;; 0 0)) ;;; Generated autoloads from org-contacts.el (autoload 'org-contacts "org-contacts" "\ @@ -975,22 +940,86 @@ Create agenda view for contacts matching NAME. ;;;*** -;;;### (autoloads (org-datetree-find-date-create) "org-datetree" -;;;;;; "org-datetree.el" "f59e07b5e58409e8f540661bb1de0721") +;;;### (autoloads nil "org-datetree" "org-datetree.el" (22757 57238 +;;;;;; 0 0)) ;;; Generated autoloads from org-datetree.el (autoload 'org-datetree-find-date-create "org-datetree" "\ -Find or create an entry for DATE. +Find or create an entry for date D. If KEEP-RESTRICTION is non-nil, do not widen the buffer. When it is nil, the buffer will be widened to make sure an existing date -tree can be found. +tree can be found. If it is the sympol `subtree-at-point', then the tree +will be built under the headline at point. + +\(fn D &optional KEEP-RESTRICTION)" nil nil) + +(autoload 'org-datetree-find-iso-week-create "org-datetree" "\ +Find or create an ISO week entry for date D. +Compared to `org-datetree-find-date-create' this function creates +entries ordered by week instead of months. +When it is nil, the buffer will be widened to make sure an existing date +tree can be found. If it is the sympol `subtree-at-point', then the tree +will be built under the headline at point. -\(fn DATE &optional KEEP-RESTRICTION)" nil nil) +\(fn D &optional KEEP-RESTRICTION)" nil nil) ;;;*** -;;;### (autoloads (org-eldoc-load) "org-eldoc" "org-eldoc.el" (21953 -;;;;;; 19361)) +;;;### (autoloads nil "org-duration" "org-duration.el" (22757 57238 +;;;;;; 0 0)) +;;; Generated autoloads from org-duration.el + +(autoload 'org-duration-set-regexps "org-duration" "\ +Set duration related regexps. + +\(fn)" t nil) + +(autoload 'org-duration-p "org-duration" "\ +Non-nil when string S is a time duration. + +\(fn S)" nil nil) + +(autoload 'org-duration-to-minutes "org-duration" "\ +Return number of minutes of DURATION string. + +When optional argument CANONICAL is non-nil, ignore +`org-duration-units' and use standard time units value. + +As a special case, a bare number represents minutes. + +Return value as a float. Raise an error if duration format is +not recognized. + +\(fn DURATION &optional CANONICAL)" nil nil) + +(autoload 'org-duration-from-minutes "org-duration" "\ +Return duration string for a given number of MINUTES. + +Format duration according to `org-duration-format' or FMT, when +non-nil. + +When optional argument CANONICAL is non-nil, ignore +`org-duration-units' and use standard time units value. + +Raise an error if expected format is unknown. + +\(fn MINUTES &optional FMT CANONICAL)" nil nil) + +(autoload 'org-duration-h:mm-only-p "org-duration" "\ +Non-nil when every duration in TIMES has \"H:MM\" or \"H:MM:SS\" format. + +TIMES is a list of duration strings. + +Return nil if any duration is expressed with units, as defined in +`org-duration-units'. Otherwise, if any duration is expressed +with \"H:MM:SS\" format, return `h:mm:ss'. Otherwise, return +`h:mm'. + +\(fn TIMES)" nil nil) + +;;;*** + +;;;### (autoloads nil "org-eldoc" "org-eldoc.el" (22757 57238 0 0)) ;;; Generated autoloads from org-eldoc.el (autoload 'org-eldoc-load "org-eldoc" "\ @@ -1002,9 +1031,8 @@ Set up org-eldoc documentation function. ;;;*** -;;;### (autoloads (org-element-context org-element-at-point org-element-cache-refresh -;;;;;; org-element-cache-reset org-element-interpret-data org-element-update-syntax) -;;;;;; "org-element" "org-element.el" "8630e3513ba21fa84402649f9de8a254") +;;;### (autoloads nil "org-element" "org-element.el" (22757 57238 +;;;;;; 0 0)) ;;; Generated autoloads from org-element.el (autoload 'org-element-update-syntax "org-element" "\ @@ -1076,8 +1104,7 @@ Providing it allows for quicker computation. ;;;*** -;;;### (autoloads (org-feed-show-raw-feed org-feed-goto-inbox org-feed-update -;;;;;; org-feed-update-all) "org-feed" "org-feed.el" "2c0e0609c30cfb526256f48c8bac87e2") +;;;### (autoloads nil "org-feed" "org-feed.el" (22757 57238 0 0)) ;;; Generated autoloads from org-feed.el (autoload 'org-feed-update-all "org-feed" "\ @@ -1104,8 +1131,8 @@ Show the raw feed buffer of a feed. ;;;*** -;;;### (autoloads (org-footnote-normalize org-footnote-action) "org-footnote" -;;;;;; "org-footnote.el" "69cb58a7f018fde2fd452ebca8ed0fc6") +;;;### (autoloads nil "org-footnote" "org-footnote.el" (22757 57238 +;;;;;; 0 0)) ;;; Generated autoloads from org-footnote.el (autoload 'org-footnote-action "org-footnote" "\ @@ -1124,23 +1151,9 @@ offer additional commands in a menu. \(fn &optional SPECIAL)" t nil) -(autoload 'org-footnote-normalize "org-footnote" "\ -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. - -When SORT-ONLY is set, only sort the footnote definitions into the -referenced sequence. - -\(fn &optional SORT-ONLY)" nil nil) - ;;;*** -;;;### (autoloads (org-id-store-link org-id-find-id-file org-id-update-id-locations -;;;;;; org-id-new org-id-find org-id-goto org-id-get-with-outline-drilling -;;;;;; org-id-get-with-outline-path-completion org-id-get org-id-copy -;;;;;; org-id-get-create) "org-id" "org-id.el" "51d4c84bdf5847a8855826d220da1ed5") +;;;### (autoloads nil "org-id" "org-id.el" (22757 57238 0 0)) ;;; Generated autoloads from org-id.el (autoload 'org-id-get-create "org-id" "\ @@ -1180,7 +1193,7 @@ Use an outline-cycling interface to retrieve the ID of an entry. This only finds entries in the current buffer, using `org-get-location'. It returns the ID of the entry. If necessary, the ID is created. -\(fn &optional TARGETS)" nil nil) +\(fn)" nil nil) (autoload 'org-id-goto "org-id" "\ Switch to the buffer containing the entry with id ID. @@ -1217,7 +1230,6 @@ Store the relation between files and corresponding IDs. This will scan all agenda files, all associated archives, and all files currently mentioned in `org-id-locations'. When FILES is given, scan these files instead. -When CHECK is given, prepare detailed information about duplicate IDs. \(fn &optional FILES SILENT)" t nil) @@ -1233,8 +1245,8 @@ Store a link to the current entry, using its ID. ;;;*** -;;;### (autoloads (org-indent-mode) "org-indent" "org-indent.el" -;;;;;; "0a614b4056871d7fd7a5f3b89cbf801c") +;;;### (autoloads nil "org-indent" "org-indent.el" (22757 57238 0 +;;;;;; 0)) ;;; Generated autoloads from org-indent.el (autoload 'org-indent-mode "org-indent" "\ @@ -1251,7 +1263,7 @@ during idle time. ;;;*** -;;;### (autoloads (org-irc-store-link) "org-irc" "org-irc.el" "08634f24d3c9ac188f7c86dea6be6825") +;;;### (autoloads nil "org-irc" "org-irc.el" (22757 57238 0 0)) ;;; Generated autoloads from org-irc.el (autoload 'org-irc-store-link "org-irc" "\ @@ -1261,19 +1273,286 @@ Dispatch to the appropriate function to store a link to an IRC session. ;;;*** -;;;### (autoloads (org-load-noerror-mustsuffix) "org-macs" "org-macs.el" -;;;;;; (21961 33719)) +;;;### (autoloads nil "org-link-edit" "org-link-edit.el" (22757 57238 +;;;;;; 0 0)) +;;; Generated autoloads from org-link-edit.el + +(autoload 'org-link-edit-forward-slurp "org-link-edit" "\ +Slurp N trailing blobs into link's description. + + The [[http://orgmode.org/][Org mode]] site + + | + v + + The [[http://orgmode.org/][Org mode site]] + +A blob is a block of non-whitespace characters. When slurping +forward, trailing punctuation characters are not considered part +of a blob. + +After slurping, return the slurped text and move point to the +beginning of the link. + +If N is negative, slurp leading blobs instead of trailing blobs. + +\(fn &optional N)" t nil) + +(autoload 'org-link-edit-backward-slurp "org-link-edit" "\ +Slurp N leading blobs into link's description. + + The [[http://orgmode.org/][Org mode]] site + + | + v + + [[http://orgmode.org/][The Org mode]] site + +A blob is a block of non-whitespace characters. + +After slurping, return the slurped text and move point to the +beginning of the link. + +If N is negative, slurp trailing blobs instead of leading blobs. + +\(fn &optional N)" t nil) + +(autoload 'org-link-edit-forward-barf "org-link-edit" "\ +Barf N trailing blobs from link's description. + + The [[http://orgmode.org/][Org mode]] site + + | + v + + The [[http://orgmode.org/][Org]] mode site + +A blob is a block of non-whitespace characters. + +After barfing, return the barfed text and move point to the +beginning of the link. + +If N is negative, barf leading blobs instead of trailing blobs. + +\(fn &optional N)" t nil) + +(autoload 'org-link-edit-backward-barf "org-link-edit" "\ +Barf N leading blobs from link's description. + + The [[http://orgmode.org/][Org mode]] site + + | + v + + The Org [[http://orgmode.org/][mode]] site + +A blob is a block of non-whitespace characters. + +After barfing, return the barfed text and move point to the +beginning of the link. + +If N is negative, barf trailing blobs instead of leading blobs. + +\(fn &optional N)" t nil) + +;;;*** + +;;;### (autoloads nil "org-lint" "org-lint.el" (22757 57238 0 0)) +;;; Generated autoloads from org-lint.el + +(autoload 'org-lint "org-lint" "\ +Check current Org buffer for syntax mistakes. + +By default, run all checkers. With a `\\[universal-argument]' prefix ARG, select one +category of checkers only. With a `\\[universal-argument] \\[universal-argument]' prefix, run one precise +checker by its name. + +ARG can also be a list of checker names, as symbols, to run. + +\(fn &optional ARG)" t nil) + +;;;*** + +;;;### (autoloads nil "org-mac-link" "org-mac-link.el" (22757 57238 +;;;;;; 0 0)) +;;; Generated autoloads from org-mac-link.el + +(autoload 'org-mac-grab-link "org-mac-link" "\ +Prompt for an application to grab a link from. +When done, go grab the link, and insert it at point. + +\(fn)" t nil) + +(autoload 'org-mac-firefox-get-frontmost-url "org-mac-link" "\ + + +\(fn)" t nil) + +(autoload 'org-mac-firefox-insert-frontmost-url "org-mac-link" "\ + + +\(fn)" t nil) + +(autoload 'org-mac-vimperator-get-frontmost-url "org-mac-link" "\ + + +\(fn)" t nil) + +(autoload 'org-mac-vimperator-insert-frontmost-url "org-mac-link" "\ + + +\(fn)" t nil) + +(autoload 'org-mac-chrome-get-frontmost-url "org-mac-link" "\ + + +\(fn)" t nil) + +(autoload 'org-mac-chrome-insert-frontmost-url "org-mac-link" "\ + + +\(fn)" t nil) + +(autoload 'org-mac-safari-get-frontmost-url "org-mac-link" "\ + + +\(fn)" t nil) + +(autoload 'org-mac-safari-insert-frontmost-url "org-mac-link" "\ + + +\(fn)" t nil) + +(autoload 'org-mac-together-get-selected "org-mac-link" "\ + + +\(fn)" t nil) + +(autoload 'org-mac-together-insert-selected "org-mac-link" "\ + + +\(fn)" t nil) + +(autoload 'org-mac-finder-item-get-selected "org-mac-link" "\ + + +\(fn)" t nil) + +(autoload 'org-mac-finder-insert-selected "org-mac-link" "\ + + +\(fn)" t nil) + +(autoload 'org-mac-addressbook-item-get-selected "org-mac-link" "\ + + +\(fn)" t nil) + +(autoload 'org-mac-addressbook-insert-selected "org-mac-link" "\ + + +\(fn)" t nil) + +(autoload 'org-mac-skim-get-page "org-mac-link" "\ + + +\(fn)" t nil) + +(autoload 'org-mac-skim-insert-page "org-mac-link" "\ + + +\(fn)" t nil) + +(autoload 'org-mac-acrobat-get-page "org-mac-link" "\ + + +\(fn)" t nil) + +(autoload 'org-mac-acrobat-insert-page "org-mac-link" "\ + + +\(fn)" t nil) + +(autoload 'org-mac-outlook-message-get-links "org-mac-link" "\ +Create links to the messages currently selected or flagged in Microsoft Outlook.app. +This will use AppleScript to get the message-id and the subject of the +messages in Microsoft Outlook.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. + +\(fn &optional SELECT-OR-FLAG)" t nil) + +(autoload 'org-mac-outlook-message-insert-selected "org-mac-link" "\ +Insert a link to the messages currently selected in Microsoft Outlook.app. +This will use AppleScript to get the message-id and the subject +of the active mail in Microsoft Outlook.app and make a link out +of it. + +\(fn)" t nil) + +(autoload 'org-mac-outlook-message-insert-flagged "org-mac-link" "\ +Asks for an org buffer and a heading within it, and replace message links. +If heading exists, delete all mac-outlook:// links within +heading's first level. If heading doesn't exist, create it at +point-max. Insert list of mac-outlook:// links to flagged mail +after heading. + +\(fn ORG-BUFFER ORG-HEADING)" t nil) + +(autoload 'org-mac-evernote-note-insert-selected "org-mac-link" "\ +Insert a link to the notes currently selected in Evernote.app. +This will use AppleScript to get the note id and the title of the +note(s) in Evernote.app and make a link out of it/them. + +\(fn)" t nil) + +(autoload 'org-mac-devonthink-item-insert-selected "org-mac-link" "\ +Insert a link to the item(s) currently selected in DEVONthink Pro Office. +This will use AppleScript to get the `uuid'(s) and the name(s) of the +selected items in DEVONthink Pro Office and make link(s) out of it/them. + +\(fn)" t nil) + +(autoload 'org-mac-message-get-links "org-mac-link" "\ +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. + +\(fn &optional SELECT-OR-FLAG)" t nil) + +(autoload 'org-mac-message-insert-selected "org-mac-link" "\ +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. + +\(fn)" t nil) + +(autoload 'org-mac-message-insert-flagged "org-mac-link" "\ +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. + +\(fn ORG-BUFFER ORG-HEADING)" t nil) + +;;;*** + +;;;### (autoloads nil "org-macs" "org-macs.el" (22757 57238 0 0)) ;;; Generated autoloads from org-macs.el (autoload 'org-load-noerror-mustsuffix "org-macs" "\ -Load FILE with optional arguments NOERROR and MUSTSUFFIX. Drop the MUSTSUFFIX argument for XEmacs, which doesn't recognize it. +Load FILE with optional arguments NOERROR and MUSTSUFFIX. -\(fn FILE)" nil (quote macro)) +\(fn FILE)" nil t) ;;;*** -;;;### (autoloads (org-mobile-pull org-mobile-push) "org-mobile" -;;;;;; "org-mobile.el" "fa167263b2f8f3a5352fc25dbe49b69b") +;;;### (autoloads nil "org-mobile" "org-mobile.el" (22757 57238 0 +;;;;;; 0)) ;;; Generated autoloads from org-mobile.el (autoload 'org-mobile-push "org-mobile" "\ @@ -1292,8 +1571,8 @@ agenda view showing the flagged items. ;;;*** -;;;### (autoloads (org-passwords org-passwords-mode) "org-passwords" -;;;;;; "org-passwords.el" (21953 19361)) +;;;### (autoloads nil "org-passwords" "org-passwords.el" (22757 57238 +;;;;;; 0 0)) ;;; Generated autoloads from org-passwords.el (autoload 'org-passwords-mode "org-passwords" "\ @@ -1317,7 +1596,7 @@ With a double prefix arg \\[universal-argument] \\[universal-argument], open the ;;;*** -;;;### (autoloads (org-plot/gnuplot) "org-plot" "org-plot.el" "d127faa9ca32ef2814c5542901d23e1b") +;;;### (autoloads nil "org-plot" "org-plot.el" (22757 57238 0 0)) ;;; Generated autoloads from org-plot.el (autoload 'org-plot/gnuplot "org-plot" "\ @@ -1329,9 +1608,8 @@ line directly before or after the table. ;;;*** -;;;### (autoloads (org-registry-update org-registry-insinuate org-registry-initialize -;;;;;; org-registry-visit org-registry-show) "org-registry" "org-registry.el" -;;;;;; (21196 60374)) +;;;### (autoloads nil "org-registry" "org-registry.el" (22757 57238 +;;;;;; 0 0)) ;;; Generated autoloads from org-registry.el (autoload 'org-registry-show "org-registry" "\ @@ -1368,9 +1646,8 @@ Update the registry for the current Org file. ;;;*** -;;;### (autoloads (org-screenshot-show-unused org-screenshot-rotate-next -;;;;;; org-screenshot-rotate-prev org-screenshot-take) "org-screenshot" -;;;;;; "org-screenshot.el" (21196 60374)) +;;;### (autoloads nil "org-screenshot" "org-screenshot.el" (22757 +;;;;;; 57238 0 0)) ;;; Generated autoloads from org-screenshot.el (autoload 'org-screenshot-take "org-screenshot" "\ @@ -1413,33 +1690,12 @@ Open A Dired buffer with unused screenshots marked ;;;*** -;;;### (autoloads (orgtbl-ascii-plot orgtbl-to-orgtbl orgtbl-to-texinfo -;;;;;; orgtbl-to-html orgtbl-to-latex orgtbl-to-csv orgtbl-to-tsv -;;;;;; orgtbl-to-generic org-table-to-lisp orgtbl-mode org-table-toggle-formula-debugger -;;;;;; org-table-toggle-coordinate-overlays org-table-edit-formulas -;;;;;; org-table-iterate-buffer-tables org-table-recalculate-buffer-tables -;;;;;; org-table-iterate org-table-recalculate org-table-eval-formula -;;;;;; org-table-maybe-recalculate-line org-table-analyze org-table-rotate-recalc-marks -;;;;;; org-table-maybe-eval-formula org-table-get-stored-formulas -;;;;;; org-table-sum org-table-edit-field org-table-wrap-region -;;;;;; org-table-convert org-table-paste-rectangle org-table-copy-region -;;;;;; org-table-cut-region org-table-sort-lines org-table-kill-row -;;;;;; org-table-hline-and-move org-table-insert-hline org-table-insert-row -;;;;;; org-table-move-row org-table-move-row-up org-table-move-row-down -;;;;;; org-table-move-column org-table-move-column-left org-table-move-column-right -;;;;;; org-table-delete-column org-table-insert-column org-table-goto-column -;;;;;; org-table-current-dline org-table-field-info org-table-blank-field -;;;;;; org-table-copy-down org-table-next-row org-table-previous-field -;;;;;; org-table-next-field org-table-justify-field-maybe org-table-end -;;;;;; org-table-begin org-table-align org-table-export org-table-import -;;;;;; org-table-convert-region org-table-create org-table-create-or-convert-from-region -;;;;;; org-table-create-with-table\.el) "org-table" "org-table.el" -;;;;;; "e75a308b982103eeb16090dfaad827c1") +;;;### (autoloads nil "org-table" "org-table.el" (22757 57238 0 0)) ;;; Generated autoloads from org-table.el (autoload 'org-table-create-with-table\.el "org-table" "\ Use the table.el package to insert a new table. -If there is already a table at point, convert between Org-mode tables +If there is already a table at point, convert between Org tables and table.el tables. \(fn)" t nil) @@ -1462,16 +1718,17 @@ SIZE is a string Columns x Rows like for example \"3x2\". (autoload 'org-table-convert-region "org-table" "\ Convert region to a table. + The region goes from BEG0 to END0, but these borders will be moved slightly, to make sure a beginning of line in the first line is included. SEPARATOR specifies the field separator in the lines. It can have the following values: -'(4) Use the comma as a field separator -'(16) Use a TAB as field separator -'(64) Prompt for a regular expression as field separator -integer When a number, use that many spaces as field separator +\(4) Use the comma as a field separator +\(16) Use a TAB as field separator +\(64) Prompt for a regular expression as field separator +integer When a number, use that many spaces, or a TAB, as field separator regexp When a regular expression, use it to match the separator nil When nil, the command tries to be smart and figure out the separator in the following way: @@ -1581,12 +1838,6 @@ Show info about the current field, and highlight any reference at point. \(fn ARG)" t nil) -(autoload 'org-table-current-dline "org-table" "\ -Find out what table data line we are in. -Only data lines count for this. - -\(fn)" t nil) - (autoload 'org-table-goto-column "org-table" "\ Move the cursor to the Nth column in the current table line. With optional argument ON-DELIM, stop with point before the left delimiter @@ -1714,13 +1965,13 @@ lines. (autoload 'org-table-convert "org-table" "\ Convert from `org-mode' table to table.el and back. -Obviously, this only works within limits. When an Org-mode table is -converted to table.el, all horizontal separator lines get lost, because -table.el uses these as cell boundaries and has no notion of horizontal lines. -A table.el table can be converted to an Org-mode table only if it does not -do row or column spanning. Multiline cells will become multiple cells. -Beware, Org-mode does not test if the table can be successfully converted - it -blindly applies a recipe that works for simple tables. +Obviously, this only works within limits. When an Org table is converted +to table.el, all horizontal separator lines get lost, because table.el uses +these as cell boundaries and has no notion of horizontal lines. A table.el +table can be converted to an Org table only if it does not do row or column +spanning. Multiline cells will become multiple cells. Beware, Org mode +does not test if the table can be successfully converted - it blindly +applies a recipe that works for simple tables. \(fn)" t nil) @@ -1752,8 +2003,11 @@ blank, and the content is appended to the field above. (autoload 'org-table-edit-field "org-table" "\ Edit table field in a different window. This is mainly useful for fields that contain hidden parts. -When called with a \\[universal-argument] prefix, just make the full field visible so that -it can be edited in place. + +When called with a `\\[universal-argument]' prefix, just make the full field +visible so that it can be edited in place. + +When called with a `\\[universal-argument] \\[universal-argument]' prefix, toggle `org-table-follow-field-mode'. \(fn ARG)" t nil) @@ -1777,8 +2031,11 @@ If NLAST is a number, only the NLAST fields will actually be summed. (autoload 'org-table-get-stored-formulas "org-table" "\ Return an alist with the stored formulas directly after current table. +By default, only return active formulas, i.e., formulas located +on the first line after the table. However, if optional argument +LOCATION is a buffer position, consider the formulas there. -\(fn &optional NOERROR)" t nil) +\(fn &optional NOERROR LOCATION)" nil nil) (autoload 'org-table-maybe-eval-formula "org-table" "\ Check if the current field starts with \"=\" or \":=\". @@ -1822,20 +2079,14 @@ Recompute the current line if marked for it, and if we haven't just done it. (autoload 'org-table-eval-formula "org-table" "\ Replace the table field value at the cursor by the result of a calculation. -This function makes use of Dave Gillespie's Calc package, in my view the -most exciting program ever written for GNU Emacs. So you need to have Calc -installed in order to use this function. - In a table, this command replaces the value in the current field with the result of a formula. It also installs the formula as the \"current\" column formula, by storing it in a special line below the table. When called -with a `C-u' prefix, the current field must be a named field, and the -formula is installed as valid in only this specific field. +with a `\\[universal-argument]' prefix the formula is installed as a field formula. -When called with two `C-u' prefixes, insert the active equation -for the field back into the current field, so that it can be -edited there. This is useful in order to use \\[org-table-show-reference] -to check the referenced fields. +When called with a `\\[universal-argument] \\[universal-argument]' prefix, insert the active equation for the field +back into the current field, so that it can be edited there. This is useful +in order to use \\`\\[org-table-show-reference]' to check the referenced fields. When called, the command first prompts for a formula, which is read in the minibuffer. Previously entered formulas are available through the @@ -1844,25 +2095,36 @@ These stored formulas are adapted correctly when moving, inserting, or deleting columns with the corresponding commands. The formula can be any algebraic expression understood by the Calc package. -For details, see the Org-mode manual. +For details, see the Org mode manual. This function can also be called from Lisp programs and offers additional arguments: EQUATION can be the formula to apply. If this -argument is given, the user will not be prompted. SUPPRESS-ALIGN is -used to speed-up recursive calls by by-passing unnecessary aligns. +argument is given, the user will not be prompted. + +SUPPRESS-ALIGN is used to speed-up recursive calls by by-passing +unnecessary aligns. + SUPPRESS-CONST suppresses the interpretation of constants in the -formula, assuming that this has been done already outside the function. -SUPPRESS-STORE means the formula should not be stored, either because -it is already stored, or because it is a modified equation that should -not overwrite the stored one. +formula, assuming that this has been done already outside the +function. + +SUPPRESS-STORE means the formula should not be stored, either +because it is already stored, or because it is a modified +equation that should not overwrite the stored one. + +SUPPRESS-ANALYSIS prevents analyzing the table and checking +location of point. \(fn &optional ARG EQUATION SUPPRESS-ALIGN SUPPRESS-CONST SUPPRESS-STORE SUPPRESS-ANALYSIS)" t nil) (autoload 'org-table-recalculate "org-table" "\ Recalculate the current table line by applying all stored formulas. + With prefix arg ALL, do this for all lines in the table. -With the prefix argument ALL is `(16)' (a double \\[universal-prefix] \\[universal-prefix] prefix), or if -it is the symbol `iterate', recompute the table until it no longer changes. + +When called with a `\\[universal-argument] \\[universal-argument]' prefix, or if ALL is the symbol `iterate', +recompute the table until it no longer changes. + If NOALIGN is not nil, do not re-align the table after the computations are done. This is typically used internally to save time, if it is known that the table will be realigned a little later anyway. @@ -2099,19 +2361,20 @@ be set to provide ORGTBL directives for the generated table. \(fn TABLE PARAMS)" nil nil) (autoload 'orgtbl-ascii-plot "org-table" "\ -Draw an ascii bar plot in a column. -With cursor in a column containing numerical values, this -function will draw a plot in a new column. +Draw an ASCII bar plot in a column. + +With cursor in a column containing numerical values, this function +will draw a plot in a new column. + ASK, if given, is a numeric prefix to override the default 12 -characters width of the plot. ASK may also be the -\\[universal-argument] prefix, which will prompt for the width. +characters width of the plot. ASK may also be the `\\[universal-argument]' prefix, +which will prompt for the width. \(fn &optional ASK)" t nil) ;;;*** -;;;### (autoloads (org-timer-set-timer org-timer-item org-timer-change-times-in-region -;;;;;; org-timer org-timer-start) "org-timer" "org-timer.el" "143f9df8170fabaaaef9f5c60dabcf1f") +;;;### (autoloads nil "org-timer" "org-timer.el" (22757 57238 0 0)) ;;; Generated autoloads from org-timer.el (autoload 'org-timer-start "org-timer" "\ @@ -2129,16 +2392,18 @@ the region 0:00:00. (autoload 'org-timer "org-timer" "\ Insert a H:MM:SS string from the timer into the buffer. -The first time this command is used, the timer is started. When used with -a \\[universal-argument] prefix, force restarting the timer. -When used with a double prefix argument \\[universal-argument], change all the timer string -in the region by a fixed amount. This can be used to recalibrate a timer -that was not started at the correct moment. +The first time this command is used, the timer is started. + +When used with a `\\[universal-argument]' prefix, force restarting the timer. + +When used with a `\\[universal-argument] \\[universal-argument]' prefix, change all the timer strings +in the region by a fixed amount. This can be used to re-calibrate +a timer that was not started at the correct moment. -If NO-INSERT-P is non-nil, return the string instead of inserting +If NO-INSERT is non-nil, return the string instead of inserting it in the buffer. -\(fn &optional RESTART NO-INSERT-P)" t nil) +\(fn &optional RESTART NO-INSERT)" t nil) (autoload 'org-timer-change-times-in-region "org-timer" "\ Change all h:mm:ss time in region by a DELTA. @@ -2175,7 +2440,7 @@ using three `C-u' prefix arguments. ;;;*** -;;;### (autoloads (org-toc-show) "org-toc" "org-toc.el" (21986 36918)) +;;;### (autoloads nil "org-toc" "org-toc.el" (22757 57238 0 0)) ;;; Generated autoloads from org-toc.el (autoload 'org-toc-show "org-toc" "\ @@ -2185,8 +2450,7 @@ Show the table of contents of the current Org-mode buffer. ;;;*** -;;;### (autoloads (org-track-compile-org org-track-fetch-package) -;;;;;; "org-track" "org-track.el" (21196 60374)) +;;;### (autoloads nil "org-track" "org-track.el" (22757 57238 0 0)) ;;; Generated autoloads from org-track.el (autoload 'org-track-fetch-package "org-track" "\ @@ -2207,19 +2471,19 @@ DIRECTORY is where the directory org-mode/ lives (i.e. the ;;;*** -;;;### (autoloads (org-git-version org-release) "org-version" "org-version.el" -;;;;;; (21987 57178)) +;;;### (autoloads nil "org-version" "org-version.el" (22759 18886 +;;;;;; 245978 766000)) ;;; Generated autoloads from org-version.el (autoload 'org-release "org-version" "\ -The release version of org-mode. - Inserted by installing org-mode or when a release is made. +The release version of Org. +Inserted by installing Org mode or when a release is made. \(fn)" nil nil) (autoload 'org-git-version "org-version" "\ The Git version of org-mode. - Inserted by installing org-mode or when a release is made. +Inserted by installing Org or when a release is made. \(fn)" nil nil) @@ -2228,13 +2492,7 @@ The location of ODT styles.") ;;;*** -;;;### (autoloads (org-customize org-reload org-submit-bug-report -;;;;;; org-cycle-agenda-files org-switchb org-open-link-from-string -;;;;;; org-open-at-point-global org-insert-link-global org-store-link -;;;;;; org-run-like-in-org-mode turn-on-orgstruct++ turn-on-orgstruct -;;;;;; orgstruct-mode org-global-cycle org-cycle org-mode org-clock-persistence-insinuate -;;;;;; turn-on-orgtbl org-version org-babel-load-file org-babel-do-load-languages) -;;;;;; "org" "org.el" (21986 36918)) +;;;### (autoloads nil "org" "org.el" (22757 57238 0 0)) ;;; Generated autoloads from org.el (autoload 'org-babel-do-load-languages "org" "\ @@ -2243,7 +2501,7 @@ Load the languages defined in `org-babel-load-languages'. \(fn SYM VALUE)" nil nil) (autoload 'org-babel-load-file "org" "\ -Load Emacs Lisp source code blocks in the Org-mode FILE. +Load Emacs Lisp source code blocks in the Org 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 @@ -2252,7 +2510,7 @@ file to byte-code before it is loaded. \(fn FILE &optional COMPILE)" t nil) (autoload 'org-version "org" "\ -Show the org-mode version. +Show the Org version. Interactively, or when MESSAGE is non-nil, show it in echo area. With prefix argument, or when HERE is non-nil, insert it at point. In non-interactive uses, a reduced version string is output unless @@ -2274,15 +2532,15 @@ Set up hooks for clock persistence. Outline-based notes management and organizer, alias \"Carsten's outline-mode for keeping track of everything.\" -Org-mode develops organizational tasks around a NOTES file which -contains information about projects as plain text. Org-mode is -implemented on top of outline-mode, which is ideal to keep the content +Org mode develops organizational tasks around a NOTES file which +contains information about projects as plain text. Org mode is +implemented on top of Outline mode, which is ideal to keep the content of large files well structured. It supports ToDo items, deadlines and time stamps, which magically appear in the diary listing of the Emacs calendar. Tables are easily created with a built-in table editor. Plain text URL-like links connect to websites, emails (VM), Usenet messages (Gnus), BBDB entries, and any files related to the project. -For printing and sharing of notes, an Org-mode file (or a part of it) +For printing and sharing of notes, an Org file (or a part of it) can be exported as a structured ASCII or HTML file. The following commands are available: @@ -2292,58 +2550,60 @@ The following commands are available: \(fn)" t nil) (autoload 'org-cycle "org" "\ -TAB-action and visibility cycling for Org-mode. +TAB-action and visibility cycling for Org mode. -This is the command invoked in Org-mode by the TAB key. Its main purpose -is outline visibility cycling, but it also invokes other actions +This is the command invoked in Org mode by the `TAB' key. Its main +purpose is outline visibility cycling, but it also invokes other actions in special contexts. -- When this function is called with a prefix argument, rotate the entire - buffer through 3 states (global cycling) +When this function is called with a `\\[universal-argument]' prefix, rotate the entire +buffer through 3 states (global cycling) 1. OVERVIEW: Show only top-level headlines. 2. CONTENTS: Show all headlines of all levels, but no body text. 3. SHOW ALL: Show everything. - When called with two `C-u C-u' prefixes, switch to the startup visibility, - determined by the variable `org-startup-folded', and by any VISIBILITY - properties in the buffer. - When called with three `C-u C-u C-u' prefixed, show the entire buffer, - including any drawers. -- When inside a table, re-align the table and move to the next field. +With a `\\[universal-argument] \\[universal-argument]' prefix argument, switch to the startup visibility, +determined by the variable `org-startup-folded', and by any VISIBILITY +properties in the buffer. -- When point is at the beginning of a headline, rotate the subtree started - by this line through 3 different states (local cycling) +With a `\\[universal-argument] \\[universal-argument] \\[universal-argument]' prefix argument, show the entire buffer, including +any drawers. + +When inside a table, re-align the table and move to the next field. + +When point is at the beginning of a headline, rotate the subtree started +by this line through 3 different states (local cycling) 1. FOLDED: Only the main headline is shown. 2. CHILDREN: The main headline and the direct children are shown. From this state, you can move to one of the children and zoom in further. 3. SUBTREE: Show the entire subtree, including body text. - If there is no subtree, switch directly from CHILDREN to FOLDED. +If there is no subtree, switch directly from CHILDREN to FOLDED. -- When point is at the beginning of an empty headline and the variable - `org-cycle-level-after-item/entry-creation' is set, cycle the level - of the headline by demoting and promoting it to likely levels. This - speeds up creation document structure by pressing TAB once or several - times right after creating a new headline. +When point is at the beginning of an empty headline and the variable +`org-cycle-level-after-item/entry-creation' is set, cycle the level +of the headline by demoting and promoting it to likely levels. This +speeds up creation document structure by pressing `TAB' once or several +times right after creating a new headline. -- When there is a numeric prefix, go up to a heading with level ARG, do - a `show-subtree' and return to the previous cursor position. If ARG - is negative, go up that many levels. +When there is a numeric prefix, go up to a heading with level ARG, do +a `show-subtree' and return to the previous cursor position. If ARG +is negative, go up that many levels. -- When point is not at the beginning of a headline, execute the global - binding for TAB, which is re-indenting the line. See the option - `org-cycle-emulate-tab' for details. +When point is not at the beginning of a headline, execute the global +binding for `TAB', which is re-indenting the line. See the option +`org-cycle-emulate-tab' for details. -- Special case: if point is at the beginning of the buffer and there is - no headline in line 1, this function will act as if called with prefix arg - (C-u TAB, same as S-TAB) also when called without prefix arg. - But only if also the variable `org-cycle-global-at-bob' is t. +As a special case, if point is at the beginning of the buffer and there is +no headline in line 1, this function will act as if called with prefix arg +\(`\\[universal-argument] TAB', same as `S-TAB') also when called without prefix arg, but only +if the variable `org-cycle-global-at-bob' is t. \(fn &optional ARG)" t nil) (autoload 'org-global-cycle "org" "\ Cycle the global visibility. For details see `org-cycle'. -With \\[universal-argument] prefix arg, switch to startup visibility. +With `\\[universal-argument]' prefix ARG, switch to startup visibility. With a numeric prefix, show all headlines up to that level. \(fn &optional ARG)" t nil) @@ -2351,10 +2611,10 @@ With a numeric prefix, show all headlines up to that level. (autoload 'orgstruct-mode "org" "\ Toggle the minor mode `orgstruct-mode'. -This mode is for using Org-mode structure commands in other -modes. The following keys behave as if Org-mode were active, if +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). +defined by Org mode). \(fn &optional ARG)" t nil) @@ -2369,61 +2629,59 @@ Unconditionally turn on `orgstruct++-mode'. \(fn)" nil nil) (autoload 'org-run-like-in-org-mode "org" "\ -Run a command, pretending that the current buffer is in Org-mode. +Run a command, pretending that the current buffer is in Org mode. This will temporarily bind local variables that are typically bound in -Org-mode to the values they have in Org-mode, and then interactively +Org mode to the values they have in Org mode, and then interactively call CMD. \(fn CMD)" nil nil) (autoload 'org-store-link "org" "\ -\\Store an org-link to the current location. +Store an org-link to the current location. +\\ This link is added to `org-stored-links' and can later be inserted -into an Org buffer with \\[org-insert-link]. +into an Org buffer with `org-insert-link' (`\\[org-insert-link]'). -For some link types, a prefix ARG is interpreted. +For some link types, a `\\[universal-argument]' 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'. -A double prefix ARG force skipping storing functions that are not -part of Org's core. +A `\\[universal-argument] \\[universal-argument]' prefix ARG forces skipping storing functions that are not +part of Org core. -A triple prefix ARG force storing a link for each line in the +A `\\[universal-argument] \\[universal-argument] \\[universal-argument]' prefix ARG forces storing a link for each line in the active region. \(fn ARG)" t nil) (autoload 'org-insert-link-global "org" "\ -Insert a link like Org-mode does. -This command can be called in any mode to insert a link in Org-mode syntax. +Insert a link like Org mode does. +This command can be called in any mode to insert a link in Org syntax. \(fn)" t nil) (autoload 'org-open-at-point-global "org" "\ -Follow a link like Org-mode does. -This command can be called in any mode to follow a link that has -Org-mode syntax. +Follow a link or time-stamp like Org mode does. +This command can be called in any mode to follow an external link +or a time-stamp that has Org mode syntax. Its behavior is +undefined when called on internal links (e.g., fuzzy links). +Raise an error when there is nothing to follow. \(fn)" t nil) (autoload 'org-open-link-from-string "org" "\ -Open a link in the string S, as if it was in Org-mode. +Open a link in the string S, as if it was in Org mode. \(fn S &optional ARG REFERENCE-BUFFER)" t nil) (autoload 'org-switchb "org" "\ Switch between Org buffers. -With one prefix argument, restrict available buffers to files. -With two prefix arguments, restrict available buffers to agenda files. -Defaults to `iswitchb' for buffer name completion. -Set `org-completion-use-ido' to make it use ido instead. - -\(fn &optional ARG)" t nil) +With `\\[universal-argument]' prefix, restrict available buffers to files. -(defalias 'org-ido-switchb 'org-switchb) +With `\\[universal-argument] \\[universal-argument]' prefix, restrict available buffers to agenda files. -(defalias 'org-iswitchb 'org-switchb) +\(fn &optional ARG)" t nil) (autoload 'org-cycle-agenda-files "org" "\ Cycle through the files in `org-agenda-files'. @@ -2433,13 +2691,13 @@ If the current buffer does not, find the first agenda file. \(fn)" t nil) (autoload 'org-submit-bug-report "org" "\ -Submit a bug report on Org-mode via mail. +Submit a bug report on Org via mail. Don't hesitate to report any problems or inaccurate documentation. If you don't have setup sending mail from (X)Emacs, please copy the output buffer into your mail program, as it gives us important -information about your Org-mode version and configuration. +information about your Org version and configuration. \(fn)" t nil) @@ -2456,177 +2714,7 @@ Call the customize function with org as argument. ;;;*** -;;;### (autoloads nil "ox" "ox.el" "abc66ef82e22fc92b4296805fc5dc448") -;;; Generated autoloads from ox.el - -(autoload 'org-export-as "ox" "\ -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. - -\(fn BACKEND &optional SUBTREEP VISIBLE-ONLY BODY-ONLY EXT-PLIST)" nil nil) - -(autoload 'org-export-string-as "ox" "\ -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. - -\(fn STRING BACKEND &optional BODY-ONLY EXT-PLIST)" nil nil) - -(autoload 'org-export-replace-region-by "ox" "\ -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. - -\(fn BACKEND)" nil nil) - -(autoload 'org-export-insert-default-template "ox" "\ -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. - -\(fn &optional BACKEND SUBTREEP)" t nil) - -(autoload 'org-export-to-buffer "ox" "\ -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. - -\(fn BACKEND BUFFER &optional ASYNC SUBTREEP VISIBLE-ONLY BODY-ONLY EXT-PLIST POST-PROCESS)" nil nil) - -(put 'org-export-to-buffer 'lisp-indent-function '2) - -(autoload 'org-export-to-file "ox" "\ -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 will 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. - -\(fn BACKEND FILE &optional ASYNC SUBTREEP VISIBLE-ONLY BODY-ONLY EXT-PLIST POST-PROCESS)" nil nil) - -(put 'org-export-to-file 'lisp-indent-function '2) - -(autoload 'org-export-dispatch "ox" "\ -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. - -\(fn &optional ARG)" t nil) - -;;;*** - -;;;### (autoloads (org-ascii-publish-to-utf8 org-ascii-publish-to-latin1 -;;;;;; org-ascii-publish-to-ascii org-ascii-export-to-ascii org-ascii-export-as-ascii) -;;;;;; "ox-ascii" "ox-ascii.el" "7009055e46700dbb68151c69c95e7e90") +;;;### (autoloads nil "ox-ascii" "ox-ascii.el" (22757 57238 0 0)) ;;; Generated autoloads from ox-ascii.el (autoload 'org-ascii-export-as-ascii "ox-ascii" "\ @@ -2726,10 +2814,7 @@ Return output file name. ;;;*** -;;;### (autoloads (org-beamer-publish-to-pdf org-beamer-publish-to-latex -;;;;;; org-beamer-select-environment org-beamer-export-to-pdf org-beamer-export-to-latex -;;;;;; org-beamer-export-as-latex org-beamer-mode) "ox-beamer" "ox-beamer.el" -;;;;;; "fcf86747012a3c93318a8c76d7e6dae8") +;;;### (autoloads nil "ox-beamer" "ox-beamer.el" (22757 57238 0 0)) ;;; Generated autoloads from ox-beamer.el (autoload 'org-beamer-mode "ox-beamer" "\ @@ -2864,8 +2949,8 @@ Return output file name. ;;;*** -;;;### (autoloads (org-freemind-export-to-freemind) "ox-freemind" -;;;;;; "ox-freemind.el" (21953 19361)) +;;;### (autoloads nil "ox-freemind" "ox-freemind.el" (22757 57238 +;;;;;; 0 0)) ;;; Generated autoloads from ox-freemind.el (autoload 'org-freemind-export-to-freemind "ox-freemind" "\ @@ -2900,71 +2985,7 @@ Return output file's name. ;;;*** -;;;### (autoloads (org-gfm-export-to-markdown org-gfm-convert-region-to-md -;;;;;; org-gfm-export-as-markdown) "ox-gfm" "ox-gfm.el" "3bc2b77679d68fc74f9b8186350c7944") -;;; Generated autoloads from ox-gfm.el - -(autoload 'org-gfm-export-as-markdown "ox-gfm" "\ -Export current buffer to a Github Flavored 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 GFM Export*\", which will -be displayed when `org-export-show-temporary-export-buffer' is -non-nil. - -\(fn &optional ASYNC SUBTREEP VISIBLE-ONLY)" t nil) - -(autoload 'org-gfm-convert-region-to-md "ox-gfm" "\ -Assume the current region has org-mode syntax, and convert it -to Github Flavored 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. - -\(fn)" t nil) - -(autoload 'org-gfm-export-to-markdown "ox-gfm" "\ -Export current buffer to a Github Flavored 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. - -\(fn &optional ASYNC SUBTREEP VISIBLE-ONLY)" t nil) - -;;;*** - -;;;### (autoloads (org-html-publish-to-html org-html-export-to-html -;;;;;; org-html-convert-region-to-html org-html-export-as-html org-html-htmlize-generate-css) -;;;;;; "ox-html" "ox-html.el" "81b0249afdb48b73f722cbd1706f327b") +;;;### (autoloads nil "ox-html" "ox-html.el" (22757 57238 0 0)) ;;; Generated autoloads from ox-html.el (put 'org-html-head-include-default-style 'safe-local-variable 'booleanp) @@ -3020,10 +3041,10 @@ is non-nil. \(fn &optional ASYNC SUBTREEP VISIBLE-ONLY BODY-ONLY EXT-PLIST)" t nil) (autoload 'org-html-convert-region-to-html "ox-html" "\ -Assume the current region has org-mode syntax, and convert it to HTML. +Assume the current region has Org 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. +itemized list in Org syntax in an HTML buffer and use this command +to convert it. \(fn)" t nil) @@ -3070,9 +3091,8 @@ Return output file name. ;;;*** -;;;### (autoloads (org-icalendar-combine-agenda-files org-icalendar-export-agenda-files -;;;;;; org-icalendar-export-to-ics) "ox-icalendar" "ox-icalendar.el" -;;;;;; "4642fe90a28b29fa605c841314e5cb39") +;;;### (autoloads nil "ox-icalendar" "ox-icalendar.el" (22757 57238 +;;;;;; 0 0)) ;;; Generated autoloads from ox-icalendar.el (autoload 'org-icalendar-export-to-ics "ox-icalendar" "\ @@ -3122,9 +3142,8 @@ The file is stored under the name chosen in ;;;*** -;;;### (autoloads (org-koma-letter-export-to-pdf org-koma-letter-export-to-latex -;;;;;; org-koma-letter-export-as-latex) "ox-koma-letter" "ox-koma-letter.el" -;;;;;; (21986 36918)) +;;;### (autoloads nil "ox-koma-letter" "ox-koma-letter.el" (22757 +;;;;;; 57238 0 0)) ;;; Generated autoloads from ox-koma-letter.el (autoload 'org-koma-letter-export-as-latex "ox-koma-letter" "\ @@ -3224,11 +3243,20 @@ Return PDF file's name. ;;;*** -;;;### (autoloads (org-latex-publish-to-pdf org-latex-publish-to-latex -;;;;;; org-latex-export-to-pdf org-latex-export-to-latex org-latex-convert-region-to-latex -;;;;;; org-latex-export-as-latex) "ox-latex" "ox-latex.el" "7ce9c61cc3277467543c0e9c3d19063a") +;;;### (autoloads nil "ox-latex" "ox-latex.el" (22757 57238 0 0)) ;;; Generated autoloads from ox-latex.el +(autoload 'org-latex-make-preamble "ox-latex" "\ +Return a formatted LaTeX preamble. +INFO is a plist used as a communication channel. Optional +argument TEMPLATE, when non-nil, is the header template string, +as expected by `org-splice-latex-header'. When SNIPPET? is +non-nil, only includes packages relevant to image generation, as +specified in `org-latex-default-packages-alist' or +`org-latex-packages-alist'. + +\(fn INFO &optional TEMPLATE SNIPPET\\=\\?)" nil nil) + (autoload 'org-latex-export-as-latex "ox-latex" "\ Export current buffer as a LaTeX buffer. @@ -3262,9 +3290,9 @@ is non-nil. \(fn &optional ASYNC SUBTREEP VISIBLE-ONLY BODY-ONLY EXT-PLIST)" t nil) (autoload 'org-latex-convert-region-to-latex "ox-latex" "\ -Assume the current region has org-mode syntax, and convert it to LaTeX. +Assume the current region has Org 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 +itemized list in Org syntax in an LaTeX buffer and use this command to convert it. \(fn)" t nil) @@ -3351,9 +3379,7 @@ Return output file name. ;;;*** -;;;### (autoloads (org-md-publish-to-md org-md-export-to-markdown -;;;;;; org-md-convert-region-to-md org-md-export-as-markdown) "ox-md" -;;;;;; "ox-md.el" "aed5f0514558ef19cd7d064500334fd9") +;;;### (autoloads nil "ox-md" "ox-md.el" (22757 57238 0 0)) ;;; Generated autoloads from ox-md.el (autoload 'org-md-export-as-markdown "ox-md" "\ @@ -3382,9 +3408,9 @@ non-nil. \(fn &optional ASYNC SUBTREEP VISIBLE-ONLY)" t nil) (autoload 'org-md-convert-region-to-md "ox-md" "\ -Assume the current region has org-mode syntax, and convert it to Markdown. +Assume the current region has Org 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 +itemized list in Org syntax in a Markdown buffer and use this command to convert it. \(fn)" t nil) @@ -3425,8 +3451,7 @@ Return output file name. ;;;*** -;;;### (autoloads (org-odt-convert org-odt-export-to-odt org-odt-export-as-odf-and-open -;;;;;; org-odt-export-as-odf) "ox-odt" "ox-odt.el" "8139d5d63ee223aef856a251ad8321d8") +;;;### (autoloads nil "ox-odt" "ox-odt.el" (22757 57238 0 0)) ;;; Generated autoloads from ox-odt.el (put 'org-odt-preferred-output-format 'safe-local-variable 'stringp) @@ -3480,16 +3505,15 @@ Return output file's name. 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'. +format. Use `org-odt-convert-process' as the converter. If OPEN +is non-nil then the newly converted file is opened using +`org-open-file'. -\(fn &optional IN-FILE OUT-FMT PREFIX-ARG)" t nil) +\(fn &optional IN-FILE OUT-FMT OPEN)" t nil) ;;;*** -;;;### (autoloads (org-org-publish-to-org org-org-export-to-org org-org-export-as-org) -;;;;;; "ox-org" "ox-org.el" "145aafa32bb230b10f3d751f58667b46") +;;;### (autoloads nil "ox-org" "ox-org.el" (22757 57238 0 0)) ;;; Generated autoloads from ox-org.el (autoload 'org-org-export-as-org "ox-org" "\ @@ -3567,9 +3591,8 @@ Return output file name. ;;;*** -;;;### (autoloads (org-publish-current-project org-publish-current-file -;;;;;; org-publish-all org-publish) "ox-publish" "ox-publish.el" -;;;;;; "00f9feea8a4428e599e429136e990d7b") +;;;### (autoloads nil "ox-publish" "ox-publish.el" (22757 57238 0 +;;;;;; 0)) ;;; Generated autoloads from ox-publish.el (defalias 'org-publish-project 'org-publish) @@ -3612,8 +3635,7 @@ the project. ;;;*** -;;;### (autoloads (org-rss-publish-to-rss org-rss-export-to-rss org-rss-export-as-rss) -;;;;;; "ox-rss" "ox-rss.el" (21953 19361)) +;;;### (autoloads nil "ox-rss" "ox-rss.el" (22757 57238 0 0)) ;;; Generated autoloads from ox-rss.el (autoload 'org-rss-export-as-rss "ox-rss" "\ @@ -3677,9 +3699,8 @@ Return output file name. ;;;*** -;;;### (autoloads (org-taskjuggler-export-process-and-open org-taskjuggler-export-and-process -;;;;;; org-taskjuggler-export) "ox-taskjuggler" "ox-taskjuggler.el" -;;;;;; (21953 19361)) +;;;### (autoloads nil "ox-taskjuggler" "ox-taskjuggler.el" (22757 +;;;;;; 57238 0 0)) ;;; Generated autoloads from ox-taskjuggler.el (autoload 'org-taskjuggler-export "ox-taskjuggler" "\ @@ -3765,8 +3786,8 @@ the reports is done using the TaskJuggler GUI. ;;;*** -;;;### (autoloads (org-texinfo-convert-region-to-texinfo org-texinfo-publish-to-texinfo) -;;;;;; "ox-texinfo" "ox-texinfo.el" "a14b42af7c17d29f19002fef18e3fae6") +;;;### (autoloads nil "ox-texinfo" "ox-texinfo.el" (22757 57238 0 +;;;;;; 0)) ;;; Generated autoloads from ox-texinfo.el (autoload 'org-texinfo-publish-to-texinfo "ox-texinfo" "\ @@ -3781,20 +3802,39 @@ Return output file name. \(fn PLIST FILENAME PUB-DIR)" nil nil) (autoload 'org-texinfo-convert-region-to-texinfo "ox-texinfo" "\ -Assume the current region has org-mode syntax, and convert it to Texinfo. +Assume the current region has Org 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. +itemized list in Org syntax in an Texinfo buffer and use this +command to convert it. \(fn)" t nil) ;;;*** -;;;### (autoloads (org-export-dispatch org-export-to-file org-export-to-buffer -;;;;;; org-export-insert-default-template org-export-replace-region-by -;;;;;; org-export-string-as org-export-as) "ox" "ox.el" "abc66ef82e22fc92b4296805fc5dc448") +;;;### (autoloads nil "ox" "ox.el" (22757 57238 0 0)) ;;; Generated autoloads from ox.el +(autoload 'org-export-get-backend "ox" "\ +Return export back-end named after NAME. +NAME is a symbol. Return nil if no such back-end is found. + +\(fn NAME)" nil nil) + +(autoload 'org-export-get-environment "ox" "\ +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. + +\(fn &optional BACKEND SUBTREEP EXT-PLIST)" nil nil) + (autoload 'org-export-as "ox" "\ Transcode current Org buffer into BACKEND code. @@ -3892,13 +3932,15 @@ 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*\" + (org-export-to-buffer \\='latex \"*Org LATEX Export*\" async subtreep visible-only body-only ext-plist (lambda () (LaTeX-mode)))) This function returns BUFFER. \(fn BACKEND BUFFER &optional ASYNC SUBTREEP VISIBLE-ONLY BODY-ONLY EXT-PLIST POST-PROCESS)" nil nil) +(function-put 'org-export-to-buffer 'lisp-indent-function '2) + (autoload 'org-export-to-file "ox" "\ Call `org-export-as' with output to a specified file. @@ -3924,7 +3966,7 @@ to send the output file through additional processing, e.g, (&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 + (org-export-to-file \\='latex outfile async subtreep visible-only body-only ext-plist (lambda (file) (org-latex-compile file))) @@ -3933,6 +3975,8 @@ or FILE. \(fn BACKEND FILE &optional ASYNC SUBTREEP VISIBLE-ONLY BODY-ONLY EXT-PLIST POST-PROCESS)" nil nil) +(function-put 'org-export-to-file 'lisp-indent-function '2) + (autoload 'org-export-dispatch "ox" "\ Export dispatcher for Org mode. @@ -3947,10 +3991,10 @@ 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]', 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. +When ARG is `\\[universal-argument] \\[universal-argument]', display the asynchronous export stack. \(fn &optional ARG)" t nil) diff --git a/elpa/org-plus-contrib-20150831/org-mac-iCal.el b/elpa/org-plus-contrib-20170407/org-mac-iCal.el similarity index 100% rename from elpa/org-plus-contrib-20150831/org-mac-iCal.el rename to elpa/org-plus-contrib-20170407/org-mac-iCal.el diff --git a/elpa/org-plus-contrib-20150831/org-mac-link.el b/elpa/org-plus-contrib-20170407/org-mac-link.el similarity index 79% rename from elpa/org-plus-contrib-20150831/org-mac-link.el rename to elpa/org-plus-contrib-20170407/org-mac-link.el index c991dfa4..8ba485d0 100644 --- a/elpa/org-plus-contrib-20150831/org-mac-link.el +++ b/elpa/org-plus-contrib-20170407/org-mac-link.el @@ -1,6 +1,6 @@ ;;; org-mac-link.el --- Insert org-mode links to items selected in various Mac apps ;; -;; Copyright (c) 2010-2014 Free Software Foundation, Inc. +;; Copyright (c) 2010-2017 Free Software Foundation, Inc. ;; ;; Author: Anthony Lander ;; John Wiegley @@ -18,6 +18,18 @@ ;; Author: Mike McLean ;; Add support for Microsoft Outlook for Mac as Org mode links ;; +;; Version: 1.3 +;; Author: Alan Schmitt +;; Consistently use `org-mac-paste-applescript-links' +;; +;; Version 1.4 +;; Author: Mike McLean +;; Make the path to Microsoft Outlook a `defcustom' +;; +;; Version 1.5 +;; Author: Mike McLean +;; Add Support for Evernote +;; ;; This file is not part of GNU Emacs. ;; ;; This program is free software; you can redistribute it and/or modify @@ -58,6 +70,7 @@ ;; Skim.app - Grab a link to the selected page in the topmost pdf document ;; Microsoft Outlook.app - Grab a link to the selected message in the message list ;; DEVONthink Pro Office.app - Grab a link to the selected DEVONthink item(s); open DEVONthink item by reference +;; Evernote.app - Grab a link to the selected Evernote item(s); open Evernote item by ID ;; ;; ;; Installation: @@ -109,6 +122,12 @@ :group 'org-mac-link :type 'boolean) +(defcustom org-mac-outlook-path "/Applications/Microsoft Outlook.app" + "The path to the installed copy of Microsoft Outlook.app. Do not escape spaces as the AppleScript call will quote this string." + :tag "Path to Microsoft Outlook" + :group 'org-mac-link + :type 'string) + (defcustom org-mac-grab-devonthink-app-p t "Add menu option [d]EVONthink to grab links from DEVONthink Pro Office.app." :tag "Grab DEVONthink Pro Office.app links" @@ -165,6 +184,12 @@ :group 'org-mac-link :type 'boolean) +(defcustom org-mac-grab-Acrobat-app-p t + "Add menu option [A]crobat to grab page links from Acrobat.app." + :tag "Grab Acrobat.app page links" + :group 'org-mac-link + :type 'boolean) + (defgroup org-mac-flagged-mail nil "Options foring linking to flagged Mail.app messages." :tag "Org Mail.app" @@ -175,6 +200,23 @@ :group 'org-mac-flagged-mail :type 'string) +(defcustom org-mac-grab-Evernote-app-p + (< 0 (length (shell-command-to-string + "mdfind kMDItemCFBundleIdentifier == 'com.evernote.Evernote'"))) + "Add menu option [e]vernote to grab note links from Evernote.app." + :tag "Grab Evernote.app note links" + :group 'org-mac-link + :type 'boolean) + +(defcustom org-mac-evernote-path (replace-regexp-in-string (rx (* (any " \t\n")) eos) + "" + (shell-command-to-string + "mdfind kMDItemCFBundleIdentifier == 'com.evernote.Evernote'")) + "The path to the installed copy of Evernote.app. Do not escape spaces as the AppleScript call will quote this string." + :tag "Path to Evernote" + :group 'org-mac-link + :type 'string) + ;; In mac.c, removed in Emacs 23. (declare-function do-applescript "org-mac-message" (script)) @@ -191,6 +233,7 @@ (setq return (shell-command-to-string cmd)) (concat "\"" (org-trim return) "\"")))) +;;;###autoload (defun org-mac-grab-link () "Prompt for an application to grab a link from. When done, go grab the link, and insert it at point." @@ -206,13 +249,15 @@ When done, go grab the link, and insert it at point." ("f" "irefox" org-mac-firefox-insert-frontmost-url ,org-mac-grab-Firefox-app-p) ("v" "imperator" org-mac-vimperator-insert-frontmost-url ,org-mac-grab-Firefox+Vimperator-p) ("c" "hrome" org-mac-chrome-insert-frontmost-url ,org-mac-grab-Chrome-app-p) + ("e" "evernote" org-mac-evernote-note-insert-selected ,org-mac-grab-Evernote-app-p) ("t" "ogether" org-mac-together-insert-selected ,org-mac-grab-Together-app-p) - ("S" "kim" org-mac-skim-insert-page ,org-mac-grab-Skim-app-p))) + ("S" "kim" org-mac-skim-insert-page ,org-mac-grab-Skim-app-p) + ("A" "crobat" org-mac-acrobat-insert-page ,org-mac-grab-Acrobat-app-p))) (menu-string (make-string 0 ?x)) input) ;; Create the menu string for the keymap - (mapc '(lambda (descriptor) + (mapc (lambda (descriptor) (when (elt descriptor 3) (setf menu-string (concat menu-string "[" (elt descriptor 0) "]" @@ -223,7 +268,7 @@ When done, go grab the link, and insert it at point." ;; Prompt the user, and grab the link (message menu-string) (setq input (read-char-exclusive)) - (mapc '(lambda (descriptor) + (mapc (lambda (descriptor) (let ((key (elt (elt descriptor 0) 0)) (active (elt descriptor 3)) (grab-function (elt descriptor 2))) @@ -296,19 +341,13 @@ The links are of the form ::split::." "return links as string\n")))) (car (split-string result "[\r\n]+" t)))) +;;;###autoload (defun org-mac-firefox-get-frontmost-url () (interactive) (message "Applescript: Getting Firefox url...") - (let* ((url-and-title (org-as-mac-firefox-get-frontmost-url)) - (split-link (split-string url-and-title "::split::")) - (URL (car split-link)) - (description (cadr split-link)) - (org-link)) - (when (not (string= URL "")) - (setq org-link (org-make-link-string URL description))) - (kill-new org-link) - org-link)) + (org-mac-paste-applescript-links (org-as-mac-firefox-get-frontmost-url))) +;;;###autoload (defun org-mac-firefox-insert-frontmost-url () (interactive) (insert (org-mac-firefox-get-frontmost-url))) @@ -342,19 +381,13 @@ The links are of the form ::split::." (replace-regexp-in-string "\s+-\s+Vimperator" "" (car (split-string result "[\r\n]+" t))))) +;;;###autoload (defun org-mac-vimperator-get-frontmost-url () (interactive) (message "Applescript: Getting Vimperator url...") - (let* ((url-and-title (org-as-mac-vimperator-get-frontmost-url)) - (split-link (split-string url-and-title "::split::")) - (URL (car split-link)) - (description (cadr split-link)) - (org-link)) - (when (not (string= URL "")) - (setq org-link (org-make-link-string URL description))) - (kill-new org-link) - org-link)) + (org-mac-paste-applescript-links (org-as-mac-vimperator-get-frontmost-url))) +;;;###autoload (defun org-mac-vimperator-insert-frontmost-url () (interactive) (insert (org-mac-vimperator-get-frontmost-url))) @@ -380,19 +413,13 @@ The links are of the form ::split::." (replace-regexp-in-string "^\"\\|\"$" "" (car (split-string result "[\r\n]+" t))))) +;;;###autoload (defun org-mac-chrome-get-frontmost-url () (interactive) (message "Applescript: Getting Chrome url...") - (let* ((url-and-title (org-as-mac-chrome-get-frontmost-url)) - (split-link (split-string url-and-title "::split::")) - (URL (car split-link)) - (description (cadr split-link)) - (org-link)) - (when (not (string= URL "")) - (setq org-link (org-make-link-string URL description))) - (kill-new org-link) - org-link)) + (org-mac-paste-applescript-links (org-as-mac-chrome-get-frontmost-url))) +;;;###autoload (defun org-mac-chrome-insert-frontmost-url () (interactive) (insert (org-mac-chrome-get-frontmost-url))) @@ -410,20 +437,21 @@ The links are of the form ::split::." " return theUrl & \"::split::\" & theName & \"\n\"\n" "end tell\n"))) +;;;###autoload (defun org-mac-safari-get-frontmost-url () (interactive) (message "Applescript: Getting Safari url...") (org-mac-paste-applescript-links (org-as-mac-safari-get-frontmost-url))) +;;;###autoload (defun org-mac-safari-insert-frontmost-url () (interactive) (insert (org-mac-safari-get-frontmost-url))) ;; Handle links from together.app - -(org-add-link-type "x-together-item" 'org-mac-together-item-open) +(org-link-set-parameters "x-together-item" :follow #'org-mac-together-item-open) (defun org-mac-together-item-open (uid) "Open UID, which is a reference to an item in Together." @@ -442,11 +470,13 @@ The links are of the form ::split::." " return theLinkList as string\n" "end tell"))) +;;;###autoload (defun org-mac-together-get-selected () (interactive) (message "Applescript: Getting Togther items...") (org-mac-paste-applescript-links (as-get-selected-together-items))) +;;;###autoload (defun org-mac-together-insert-selected () (interactive) (insert (org-mac-together-get-selected))) @@ -467,19 +497,20 @@ The links are of the form ::split::." " return links as string\n" "end tell\n"))) +;;;###autoload (defun org-mac-finder-item-get-selected () (interactive) (message "Applescript: Getting Finder items...") (org-mac-paste-applescript-links (as-get-selected-finder-items))) +;;;###autoload (defun org-mac-finder-insert-selected () (interactive) (insert (org-mac-finder-item-get-selected))) ;; Handle links from AddressBook.app - -(org-add-link-type "addressbook" 'org-mac-addressbook-item-open) +(org-link-set-parameters "addressbook" :follow #'org-mac-addressbook-item-open) (defun org-mac-addressbook-item-open (uid) "Open UID, which is a reference to an item in the addressbook." @@ -498,11 +529,13 @@ The links are of the form ::split::." " return links as string\n" "end tell\n"))) +;;;###autoload (defun org-mac-addressbook-item-get-selected () (interactive) (message "Applescript: Getting Address Book items...") (org-mac-paste-applescript-links (as-get-selected-addressbook-items))) +;;;###autoload (defun org-mac-addressbook-insert-selected () (interactive) (insert (org-mac-addressbook-item-get-selected))) @@ -512,7 +545,7 @@ The links are of the form ::split::." ;; ;; Original code & idea by Christopher Suckling (org-mac-protocol) -(org-add-link-type "skim" 'org-mac-skim-open) +(org-link-set-parameters "skim" :follow #'org-mac-skim-open) (defun org-mac-skim-open (uri) "Visit page of pdf in Skim" @@ -554,33 +587,80 @@ The links are of the form ::split::." "end tell\n" "return theLink as string\n"))) +;;;###autoload (defun org-mac-skim-get-page () (interactive) (message "Applescript: Getting Skim page link...") - (let* ((link-and-descr (as-get-skim-page-link)) - (split-link (split-string link-and-descr "::split::")) - (link (car split-link)) - (description (cadr split-link)) - (org-link)) - (when (not (string= link "")) - (setq org-link (org-make-link-string link description))) - (kill-new org-link) - org-link)) + (org-mac-paste-applescript-links (as-get-skim-page-link))) +;;;###autoload (defun org-mac-skim-insert-page () (interactive) (insert (org-mac-skim-get-page))) +;; Handle links from Adobe Acrobat Pro.app +;; +;; Original code & idea by Christopher Suckling (org-mac-protocol) +;; +;; The URI format is path_to_pdf_file::page_number + +(org-link-set-parameters "acrobat" :follow #'org-mac-acrobat-open) + +(defun org-mac-acrobat-open (uri) + "Visit page of pdf in Acrobat" + (let* ((page (when (string-match "::\\(.+\\)\\'" uri) + (match-string 1 uri))) + (document (substring uri 0 (match-beginning 0)))) + (do-applescript + (concat + "tell application \"Adobe Acrobat Pro\"\n" + " activate\n" + " set theDoc to \"" document "\"\n" + " set thePage to " page "\n" + " open theDoc\n" + " tell PDF Window 1\n" + " goto page thePage\n" + " end tell\n" + "end tell")))) + +;; The applescript returns link in the format +;; "adobe:path_to_pdf_file::page_number::split::document_title, p.page_label" + +(defun org-mac-as-get-acrobat-page-link () + (do-applescript + (concat + "tell application \"Adobe Acrobat Pro\"\n" + " set theDoc to active doc\n" + " set theWindow to (PDF Window 1 of theDoc)\n" + " set thePath to (file alias of theDoc)\n" + " set theTitle to (name of theWindow)\n" + " set thePage to (page number of theWindow)\n" + " set theLabel to (label text of (page thePage of theWindow))\n" + "end tell\n" + "set theResult to \"acrobat:\" & thePath & \"::\" & thePage & \"::split::\" & theTitle & \", p.\" & theLabel\n" + "return theResult as string\n"))) + +;;;###autoload +(defun org-mac-acrobat-get-page () + (interactive) + (message "Applescript: Getting Acrobat page link...") + (org-mac-paste-applescript-links (org-mac-as-get-acrobat-page-link))) + +;;;###autoload +(defun org-mac-acrobat-insert-page () + (interactive) + (insert (org-mac-acrobat-get-page))) + ;; Handle links from Microsoft Outlook.app -(org-add-link-type "mac-outlook" 'org-mac-outlook-message-open) +(org-link-set-parameters "mac-outlook" :follow #'org-mac-outlook-message-open) (defun org-mac-outlook-message-open (msgid) "Open a message in Outlook" (do-applescript (concat - "tell application \"/Applications/Microsoft Office 2011/Microsoft Outlook.app\"\n" + "tell application \"" org-mac-outlook-path "\"\n" (format "open message id %s\n" (substring-no-properties msgid)) "activate\n" "end tell"))) @@ -589,7 +669,7 @@ The links are of the form ::split::." "AppleScript to create links to selected messages in Microsoft Outlook.app." (do-applescript (concat - "tell application \"/Applications/Microsoft Office 2011/Microsoft Outlook.app\"\n" + "tell application \"" org-mac-outlook-path "\"\n" "set msgCount to count current messages\n" "if (msgCount < 1) then\n" "return\n" @@ -630,6 +710,7 @@ The links are of the form ::split::." (buffer-string) "\n" t)) "")) +;;;###autoload (defun org-mac-outlook-message-get-links (&optional select-or-flag) "Create links to the messages currently selected or flagged in Microsoft Outlook.app. This will use AppleScript to get the message-id and the subject of the @@ -640,28 +721,14 @@ 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 "Org Mac Outlook: searching mailboxes...") - (let* ((as-link-list - (if (string= select-or-flag "s") - (org-as-get-selected-outlook-mail) - (if (string= select-or-flag "f") - (org-sh-get-flagged-outlook-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)) + (org-mac-paste-applescript-links + (if (string= select-or-flag "s") + (org-as-get-selected-outlook-mail) + (if (string= select-or-flag "f") + (org-sh-get-flagged-outlook-mail) + (error "Please select \"s\" or \"f\""))))) +;;;###autoload (defun org-mac-outlook-message-insert-selected () "Insert a link to the messages currently selected in Microsoft Outlook.app. This will use AppleScript to get the message-id and the subject @@ -670,6 +737,7 @@ of it." (interactive) (insert (org-mac-outlook-message-get-links "s"))) +;;;###autoload (defun org-mac-outlook-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 mac-outlook:// links within @@ -695,11 +763,61 @@ after heading." (insert "\n") (org-insert-heading nil t) (insert org-heading "\n" (org-mac-outlook-message-get-links "f")))))) + +;; Handle links from Evernote.app + +(org-link-set-parameters "mac-evernote" :follow #'org-mac-evernote-note-open) + +(defun org-mac-evernote-note-open (noteid) + "Open a note in Evernote" + (do-applescript + (concat + "tell application \"" org-mac-evernote-path "\"\n" + " set theNotes to get every note of every notebook where its local id is \"" (substring-no-properties noteid) "\"\n" + " repeat with _note in theNotes\n" + " if length of _note is not 0 then\n" + " set _selectedNote to _note\n" + " end if\n" + " end repeat\n" + " open note window with item 1 of _selectedNote\n" + " activate\n" + "end tell"))) + +(defun org-as-get-selected-evernote-notes () + "AppleScript to create links to selected notes in Evernote.app." + (do-applescript + (concat + "tell application \"" org-mac-evernote-path "\"\n" + " set noteCount to count selection\n" + " if (noteCount < 1) then\n" + " return\n" + " end if\n" + " set theLinkList to {}\n" + " set theSelection to selection\n" + " repeat with theNote in theSelection\n" + " set theTitle to title of theNote\n" + " set theID to local id of theNote\n" + " set theURL to \"mac-evernote:\" & theID\n" + " set theLink to theURL & \"::split::\" & theTitle & \"\n\"\n" + " copy theLink to end of theLinkList\n" + " end repeat\n" + " return theLinkList as string\n" + "end tell\n"))) + +;;;###autoload +(defun org-mac-evernote-note-insert-selected () + "Insert a link to the notes currently selected in Evernote.app. +This will use AppleScript to get the note id and the title of the +note(s) in Evernote.app and make a link out of it/them." + (interactive) + (message "Org Mac Evernote: searching notes...") +(insert (org-mac-paste-applescript-links + (org-as-get-selected-evernote-notes)))) ;; Handle links from DEVONthink Pro Office.app -(org-add-link-type "x-devonthink-item" 'org-devonthink-item-open) +(org-link-set-parameters "x-devonthink-item" :follow #'org-devonthink-item-open) (defun org-devonthink-item-open (uid) "Open UID, which is a reference to an item in DEVONthink Pro Office." @@ -734,26 +852,9 @@ selected items in DEVONthink Pro Office.app and make links out of it/them. This function will push the Org-syntax text to the kill ring, and also return it." (message "Org Mac DEVONthink: looking for selected items...") - (let* ((as-link-list (org-as-get-selected-devonthink-item)) - (link-list (if as-link-list - (mapcar - (lambda (x) (if (string-match "\\`\"\\(.*\\)\"\\'" x) - (setq x (match-string 1 x))) - x) - (split-string as-link-list "[\r\n]+")) - nil)) - orglink-list) - (while link-list - (let* ((current-item (pop link-list))) - (message "current item: %s" current-item) - (when (and current-item (not (string= current-item ""))) - (let* ((split-link (split-string current-item "::split::")) - (orglink (org-make-link-string - (url-encode-url (car split-link)) - (cadr split-link)))) - (push orglink orglink-list))))) - (kill-new (mapconcat 'identity orglink-list "\n")))) + (org-mac-paste-applescript-links (org-as-get-selected-devonthink-item))) +;;;###autoload (defun org-mac-devonthink-item-insert-selected () "Insert a link to the item(s) currently selected in DEVONthink Pro Office. This will use AppleScript to get the `uuid'(s) and the name(s) of the @@ -764,7 +865,7 @@ selected items in DEVONthink Pro Office and make link(s) out of it/them." ;; Handle links from Mail.app -(org-add-link-type "message" 'org-mac-message-open) +(org-link-set-parameters "message" :follow #'org-mac-message-open) (defun org-mac-message-open (message-id) "Visit the message with MESSAGE-ID. @@ -813,6 +914,7 @@ This will use the command `open' with the message URL." "return theLinkList as string\n" "end tell"))) +;;;###autoload (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 @@ -829,6 +931,7 @@ The Org-syntax text will be pushed to the kill ring, and also returned." ((string= select-or-flag "f") (org-as-get-flagged-mail)) (t (error "Please select \"s\" or \"f\""))))) +;;;###autoload (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 @@ -839,6 +942,7 @@ active mail in Mail.app and make a link out of it." ;; The following line is for backward compatibility (defalias 'org-mac-message-insert-link 'org-mac-message-insert-selected) +;;;###autoload (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 diff --git a/elpa/org-plus-contrib-20150831/org-macro.el b/elpa/org-plus-contrib-20170407/org-macro.el similarity index 62% rename from elpa/org-plus-contrib-20150831/org-macro.el rename to elpa/org-plus-contrib-20170407/org-macro.el index 65795f63..71e917b7 100644 --- a/elpa/org-plus-contrib-20150831/org-macro.el +++ b/elpa/org-plus-contrib-20170407/org-macro.el @@ -1,6 +1,6 @@ -;;; org-macro.el --- Macro Replacement Code for Org Mode +;;; org-macro.el --- Macro Replacement Code for Org -*- lexical-binding: t; -*- -;; Copyright (C) 2013-2015 Free Software Foundation, Inc. +;; Copyright (C) 2013-2017 Free Software Foundation, Inc. ;; Author: Nicolas Goaziou ;; Keywords: outlines, hypermedia, calendar, wp @@ -43,6 +43,7 @@ ;; {{{email}}} and {{{title}}} macros. ;;; Code: +(require 'cl-lib) (require 'org-macs) (require 'org-compat) @@ -57,12 +58,13 @@ (declare-function org-element-type "org-element" (element)) (declare-function org-file-contents "org" (file &optional noerror)) (declare-function org-mode "org" ()) -(declare-function org-remove-double-quotes "org" (s)) -(declare-function org-with-wide-buffer "org-macs" (&rest body)) +(declare-function vc-backend "vc-hooks" (f)) +(declare-function vc-call "vc-hooks" (fun file &rest args) t) +(declare-function vc-exec-after "vc-dispatcher" (code)) ;;; Variables -(defvar org-macro-templates nil +(defvar-local 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, @@ -70,48 +72,48 @@ 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)))) + (letrec ((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-unbracket-string "\"" "\"" val)))) + (unless (member file files) + (with-temp-buffer + (setq default-directory + (file-name-directory file)) + (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 () @@ -146,7 +148,8 @@ function installs the following ones: \"property\", (mapc update-templates (list (cons "input-file" (file-name-nondirectory visited-file)) (cons "modification-time" - (format "(eval (format-time-string \"$1\" '%s))" + (format "(eval (format-time-string \"$1\" (or (and (org-string-nw-p \"$2\") (org-macro--vc-modified-time %s)) '%s)))" + (prin1-to-string visited-file) (prin1-to-string (nth 5 (file-attributes visited-file))))))))) (setq org-macro-templates templates))) @@ -186,55 +189,55 @@ found in the buffer with no definition in TEMPLATES. Optional argument KEYWORDS, when non-nil is a list of keywords, as strings, where macro expansion is allowed." - (save-excursion - (goto-char (point-min)) - (let ((properties-regexp - (format "\\`EXPORT_%s\\+?\\'" (regexp-opt keywords))) - record) - (while (re-search-forward "{{{[-A-Za-z0-9_]" nil t) - (let* ((datum (save-match-data (org-element-context))) - (type (org-element-type datum)) - (macro - (cond - ((eq type 'macro) datum) - ;; In parsed keywords and associated node properties, - ;; force macro recognition. - ((or (and (eq type 'keyword) - (member (org-element-property :key datum) keywords)) - (and (eq type 'node-property) - (org-string-match-p - properties-regexp - (org-element-property :key datum)))) - (save-restriction - (narrow-to-region (match-beginning 0) (line-end-position)) - (org-element-map (org-element-parse-buffer) 'macro - #'identity nil t)))))) - (when macro - (let* ((value (org-macro-expand macro templates)) - (begin (org-element-property :begin macro)) - (signature (list begin - macro - (org-element-property :args macro)))) - ;; Avoid circular dependencies by checking if the same - ;; macro with the same arguments is expanded at the same - ;; position twice. - (cond ((member signature record) - (error "Circular macro expansion: %s" - (org-element-property :key macro))) - (value - (push signature record) - (delete-region - begin - ;; Preserve white spaces after the macro. - (progn (goto-char (org-element-property :end macro)) - (skip-chars-backward " \t") - (point))) - ;; Leave point before replacement in case of - ;; recursive expansions. - (save-excursion (insert value))) - (finalize - (error "Undefined Org macro: %s; aborting" - (org-element-property :key macro))))))))))) + (org-with-wide-buffer + (goto-char (point-min)) + (let ((properties-regexp + (format "\\`EXPORT_%s\\+?\\'" (regexp-opt keywords))) + record) + (while (re-search-forward "{{{[-A-Za-z0-9_]" nil t) + (let* ((datum (save-match-data (org-element-context))) + (type (org-element-type datum)) + (macro + (cond + ((eq type 'macro) datum) + ;; In parsed keywords and associated node properties, + ;; force macro recognition. + ((or (and (eq type 'keyword) + (member (org-element-property :key datum) keywords)) + (and (eq type 'node-property) + (string-match-p + properties-regexp + (org-element-property :key datum)))) + (save-restriction + (narrow-to-region (match-beginning 0) (line-end-position)) + (org-element-map (org-element-parse-buffer) 'macro + #'identity nil t)))))) + (when macro + (let* ((value (org-macro-expand macro templates)) + (begin (org-element-property :begin macro)) + (signature (list begin + macro + (org-element-property :args macro)))) + ;; Avoid circular dependencies by checking if the same + ;; macro with the same arguments is expanded at the same + ;; position twice. + (cond ((member signature record) + (error "Circular macro expansion: %s" + (org-element-property :key macro))) + (value + (push signature record) + (delete-region + begin + ;; Preserve white spaces after the macro. + (progn (goto-char (org-element-property :end macro)) + (skip-chars-backward " \t") + (point))) + ;; Leave point before replacement in case of + ;; recursive expansions. + (save-excursion (insert value))) + (finalize + (error "Undefined Org macro: %s; aborting" + (org-element-property :key macro))))))))))) (defun org-macro-escape-arguments (&rest args) "Build macro's arguments string from ARGS. @@ -277,6 +280,30 @@ Return a list of arguments, as strings. This is the opposite of s nil t) "\000")) +(defun org-macro--vc-modified-time (file) + (save-window-excursion + (when (vc-backend file) + (let ((buf (get-buffer-create " *org-vc*")) + (case-fold-search t) + date) + (unwind-protect + (progn + (vc-call print-log file buf nil nil 1) + (with-current-buffer buf + (vc-exec-after + (lambda () + (goto-char (point-min)) + (when (re-search-forward "Date:?[ \t]*" nil t) + (let ((time (parse-time-string + (buffer-substring + (point) (line-end-position))))) + (when (cl-some #'identity time) + (setq date (apply #'encode-time time)))))))) + (let ((proc (get-buffer-process buf))) + (while (and proc (accept-process-output proc .5 nil t))))) + (kill-buffer buf)) + date)))) + (provide 'org-macro) ;;; org-macro.el ends here diff --git a/elpa/org-plus-contrib-20150831/org-macs.el b/elpa/org-plus-contrib-20170407/org-macs.el similarity index 64% rename from elpa/org-plus-contrib-20150831/org-macs.el rename to elpa/org-plus-contrib-20170407/org-macs.el index 821cfdaf..e4b39a2c 100644 --- a/elpa/org-plus-contrib-20150831/org-macs.el +++ b/elpa/org-plus-contrib-20170407/org-macs.el @@ -1,6 +1,6 @@ -;;; org-macs.el --- Top-level definitions for Org-mode +;;; org-macs.el --- Top-level Definitions for Org -*- lexical-binding: t; -*- -;; Copyright (C) 2004-2015 Free Software Foundation, Inc. +;; Copyright (C) 2004-2017 Free Software Foundation, Inc. ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp @@ -25,28 +25,12 @@ ;;; Commentary: ;; This file contains macro definitions, defsubst definitions, other -;; stuff needed for compilation and top-level forms in Org-mode, as well -;; lots of small functions that are not org-mode specific but simply -;; generally useful stuff. +;; stuff needed for compilation and top-level forms in Org mode, as +;; well lots of small functions that are not Org mode specific but +;; simply generally useful stuff. ;;; Code: -(eval-and-compile - (unless (fboundp 'declare-function) - (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." - (char-to-string c)) - (defsubst org-char-to-string (c) - "Defsubst to decode UTF-8 character values in emacs 22." - (string (decode-char 'ucs c))))) - -(declare-function org-add-props "org-compat" (string plist &rest props)) -(declare-function org-string-match-p "org-compat" (&rest args)) - (defmacro org-with-gensyms (symbols &rest body) (declare (debug (sexp body)) (indent 1)) `(let ,(mapcar (lambda (s) @@ -54,27 +38,11 @@ symbols) ,@body)) -(defmacro org-called-interactively-p (&optional kind) - (declare (debug (&optional ("quote" symbolp)))) ;Why not just t? - (if (featurep 'xemacs) - `(interactive-p) - (if (or (> emacs-major-version 23) - (and (>= emacs-major-version 23) - (>= emacs-minor-version 2))) - ;; defined with no argument in <=23.1 - `(with-no-warnings (called-interactively-p ,kind)) - `(interactive-p)))) - -(defmacro org-bound-and-true-p (var) - "Return the value of symbol VAR if it is bound, else nil." - (declare (debug (symbolp))) - `(and (boundp (quote ,var)) ,var)) - (defun org-string-nw-p (s) "Return S if S is a string containing a non-blank character. Otherwise, return nil." (and (stringp s) - (org-string-match-p "[^ \r\t\n]" s) + (string-match-p "[^ \r\t\n]" s) s)) (defun org-not-nil (v) @@ -82,25 +50,6 @@ Otherwise, return nil." Otherwise return nil." (and v (not (equal v "nil")) v)) -(defun org-substitute-posix-classes (re) - "Substitute posix classes in regular expression RE." - (let ((ss re)) - (save-match-data - (while (string-match "\\[:alnum:\\]" ss) - (setq ss (replace-match "a-zA-Z0-9" t t ss))) - (while (string-match "\\[:word:\\]" ss) - (setq ss (replace-match "a-zA-Z0-9" t t ss))) - (while (string-match "\\[:alpha:\\]" ss) - (setq ss (replace-match "a-zA-Z" t t ss))) - (while (string-match "\\[:punct:\\]" ss) - (setq ss (replace-match "\001-@[-`{-~" t t ss))) - ss))) - -(defmacro org-re (s) - "Replace posix classes in regular expression." - (declare (debug (form))) - (if (featurep 'xemacs) `(org-substitute-posix-classes ,s) s)) - (defmacro org-preserve-lc (&rest body) (declare (debug (body))) (org-with-gensyms (line col) @@ -136,19 +85,6 @@ Otherwise return nil." (partial-completion-mode 1)) ,@body)) -;; FIXME: Slated for removal. Current Org mode does not support Emacs < 22 -(defmacro org-maybe-intangible (props) - "Add '(intangible t) to PROPS if Emacs version is earlier than Emacs 22. -In Emacs 21, invisible text is not avoided by the command loop, so the -intangible property is needed to make sure point skips this text. -In Emacs 22, this is not necessary. The intangible text property has -led to problems with flyspell. These problems are fixed in flyspell.el, -but we still avoid setting the property in Emacs 22 and later. -We use a macro so that the test can happen at compilation time." - (if (< emacs-major-version 22) - `(append '(intangible t) ,props) - props)) - (defmacro org-with-point-at (pom &rest body) "Move to buffer and point of point-or-marker POM for the duration of BODY." (declare (debug (form body)) (indent 1)) @@ -160,10 +96,6 @@ We use a macro so that the test can happen at compilation time." (goto-char (or ,mpom (point))) ,@body))))) -(defmacro org-no-warnings (&rest body) - (declare (debug (body))) - (cons (if (fboundp 'with-no-warnings) 'with-no-warnings 'progn) body)) - (defmacro org-with-remote-undo (buffer &rest body) "Execute BODY while recording undo information in two buffers." (declare (debug (form body)) (indent 1)) @@ -199,22 +131,12 @@ We use a macro so that the test can happen at compilation time." org-emphasis t) "Properties to remove when a string without properties is wanted.") -(defsubst org-match-string-no-properties (num &optional string) - (if (featurep 'xemacs) - (let ((s (match-string num string))) - (and s (remove-text-properties 0 (length s) org-rm-props s)) - s) - (match-string-no-properties num string))) - (defsubst org-no-properties (s &optional restricted) "Remove all text properties from string S. When RESTRICTED is non-nil, only remove the properties listed in `org-rm-props'." - (if (fboundp 'set-text-properties) - (set-text-properties 0 (length s) nil s) - (if restricted - (remove-text-properties 0 (length s) org-rm-props s) - (set-text-properties 0 (length s) nil s))) + (if restricted (remove-text-properties 0 (length s) org-rm-props s) + (set-text-properties 0 (length s) nil s)) s) (defsubst org-get-alist-option (option key) @@ -236,16 +158,6 @@ program is needed for, so that the error message can be more informative." (error "Can't find `%s'%s" cmd (if use (format " (%s)" use) ""))))) -(defsubst org-inhibit-invisibility () - "Modified `buffer-invisibility-spec' for Emacs 21. -Some ops with invisible text do not work correctly on Emacs 21. For these -we turn off invisibility temporarily. Use this in a `let' form." - (if (< emacs-major-version 22) nil buffer-invisibility-spec)) - -(defsubst org-set-local (var value) - "Make VAR local in current buffer and set it to VALUE." - (set (make-local-variable var) value)) - (defsubst org-last (list) "Return the last element of LIST." (car (last list))) @@ -282,11 +194,11 @@ we turn off invisibility temporarily. Use this in a `let' form." (<= (match-beginning n) pos) (>= (match-end n) pos))) -(defun org-match-line (re) - "Looking-at at the beginning of the current line." +(defun org-match-line (regexp) + "Match REGEXP at the beginning of the current line." (save-excursion - (goto-char (point-at-bol)) - (looking-at re))) + (beginning-of-line) + (looking-at regexp))) (defun org-plist-delete (plist property) "Delete PROPERTY from PLIST. @@ -298,13 +210,6 @@ This is in contrast to merely setting it to 0." (setq plist (cddr plist))) p)) -(defun org-replace-match-keep-properties (newtext &optional fixedcase - literal string) - "Like `replace-match', but add the text properties found original text." - (setq newtext (org-add-props newtext (text-properties-at - (match-beginning 0) string))) - (replace-match newtext fixedcase literal string)) - (defmacro org-save-outline-visibility (use-markers &rest body) "Save and restore outline visibility around BODY. If USE-MARKERS is non-nil, use markers for the positions. @@ -313,19 +218,15 @@ but it also means that the buffer should stay alive during the operation, because otherwise all these markers will point nowhere." (declare (debug (form body)) (indent 1)) - (org-with-gensyms (data rtn) - `(let ((,data (org-outline-overlay-data ,use-markers)) - ,rtn) + (org-with-gensyms (data) + `(let ((,data (org-outline-overlay-data ,use-markers))) (unwind-protect - (progn - (setq ,rtn (progn ,@body)) + (prog1 (progn ,@body) (org-set-outline-overlay-data ,data)) (when ,use-markers - (mapc (lambda (c) - (and (markerp (car c)) (move-marker (car c) nil)) - (and (markerp (cdr c)) (move-marker (cdr c) nil))) - ,data))) - ,rtn))) + (dolist (c ,data) + (when (markerp (car c)) (move-marker (car c) nil)) + (when (markerp (cdr c)) (move-marker (cdr c) nil)))))))) (defmacro org-with-wide-buffer (&rest body) "Execute body while temporarily widening the buffer." @@ -366,12 +267,6 @@ The number of levels is controlled by `org-inlinetask-min-level'" limit-level))) (format "\\*\\{1,%d\\} " nstars))))) -(defun org-format-seconds (string seconds) - "Compatibility function replacing format-seconds." - (if (fboundp 'format-seconds) - (format-seconds string seconds) - (format-time-string string (seconds-to-time seconds)))) - (defmacro org-eval-in-environment (environment form) (declare (debug (form form)) (indent 1)) `(eval (list 'let ,environment ',form))) @@ -387,10 +282,17 @@ the value in cdr." ;;;###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))) + "Load FILE with optional arguments NOERROR and MUSTSUFFIX." + `(load ,file 'noerror nil nil 'mustsuffix)) + +(defun org-unbracket-string (pre post string) + "Remove PRE/POST from the beginning/end of STRING. +Both PRE and POST must be pre-/suffixes of STRING, or neither is +removed." + (if (and (string-prefix-p pre string) + (string-suffix-p post string)) + (substring string (length pre) (- (length post))) + string)) (provide 'org-macs) diff --git a/elpa/org-plus-contrib-20150831/org-mairix.el b/elpa/org-plus-contrib-20170407/org-mairix.el similarity index 98% rename from elpa/org-plus-contrib-20150831/org-mairix.el rename to elpa/org-plus-contrib-20170407/org-mairix.el index a19719ea..84c2dfd2 100644 --- a/elpa/org-plus-contrib-20150831/org-mairix.el +++ b/elpa/org-plus-contrib-20170407/org-mairix.el @@ -82,8 +82,9 @@ correctly, you should not need to change this. ;;; The hooks to integrate mairix into org -(org-add-link-type "mairix" 'org-mairix-open) -(add-hook 'org-store-link-functions 'org-mairix-store-gnus-link) +(org-link-set-parameters "mairix" + :follow #'org-mairix-open + :store #'org-mairix-store-gnus-link) ;;; Generic org-mairix functions @@ -93,7 +94,7 @@ correctly, you should not need to change this. (if org-mairix-threaded-links "t:") (if org-mairix-augmented-links "a:") "@@" - (org-remove-angle-brackets message-id))) + (org-unbracket-string "<" ">" message-id))) (defun org-store-mairix-link-props (&rest plist) "Take a property list describing a mail, and add mairix link diff --git a/elpa/org-plus-contrib-20150831/org-man.el b/elpa/org-plus-contrib-20170407/org-man.el similarity index 95% rename from elpa/org-plus-contrib-20150831/org-man.el rename to elpa/org-plus-contrib-20170407/org-man.el index a9db83d5..1ccd9428 100644 --- a/elpa/org-plus-contrib-20150831/org-man.el +++ b/elpa/org-plus-contrib-20170407/org-man.el @@ -25,8 +25,10 @@ (require 'org) -(org-add-link-type "man" 'org-man-open 'org-man-export) -(add-hook 'org-store-link-functions 'org-man-store-link) +(org-link-set-parameters "man" + :follow #'org-man-open + :export #'org-man-export + :store #'org-man-store-link) (defcustom org-man-command 'man "The Emacs command to be used to display a man page." diff --git a/elpa/org-plus-contrib-20150831/org-mew.el b/elpa/org-plus-contrib-20170407/org-mew.el similarity index 94% rename from elpa/org-plus-contrib-20150831/org-mew.el rename to elpa/org-plus-contrib-20170407/org-mew.el index eb0afc06..6dbc67cc 100644 --- a/elpa/org-plus-contrib-20150831/org-mew.el +++ b/elpa/org-plus-contrib-20170407/org-mew.el @@ -1,6 +1,6 @@ ;;; org-mew.el --- Support for links to Mew messages from within Org-mode -;; Copyright (C) 2008-2014 Free Software Foundation, Inc. +;; Copyright (C) 2008-2017 Free Software Foundation, Inc. ;; Author: Tokuya Kameshima ;; Keywords: outlines, hypermedia, calendar, wp @@ -148,8 +148,7 @@ with \"t\" key." (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) +(org-link-set-parameters "mew" :follow #'org-mew-open :store #'org-mew-store-link) ;; Implementation (defun org-mew-store-link () @@ -167,20 +166,11 @@ with \"t\" key." (from (mew-header-get-value "From:")) (to (mew-header-get-value "To:")) (date (mew-header-get-value "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)))) (subject (mew-header-get-value "Subject:")) desc link) - (org-store-link-props :type "mew" :from from :to to + (org-store-link-props :type "mew" :from from :to to :date date :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 message-id (org-unbracket-string "<" ">" message-id)) (setq desc (org-email-link-description)) (setq link (concat "mew:" folder-name "#" message-id)) (org-add-link-props :link link :description desc) @@ -290,12 +280,12 @@ the subject and the group number to extract. You can get rid of (setq subject (mew-header-get-value "Subject:")) (setq message-id (mew-header-get-value "Message-Id:")) (setq references (mew-header-get-value "References:"))) - (setq id-list (mapcar (lambda (id) (org-remove-angle-brackets id)) + (setq id-list (mapcar (lambda (id) (org-unbracket-string "<" ">" id)) (mew-idstr-to-id-list references))) (if last-reference-only (setq id-list (last id-list)) (if message-id - (setq id-list (cons (org-remove-angle-brackets message-id) + (setq id-list (cons (org-unbracket-string "<" ">" message-id) id-list)))) (when (and by-subject (stringp subject)) (catch 'matched diff --git a/elpa/org-plus-contrib-20150831/org-mhe.el b/elpa/org-plus-contrib-20170407/org-mhe.el similarity index 85% rename from elpa/org-plus-contrib-20150831/org-mhe.el rename to elpa/org-plus-contrib-20170407/org-mhe.el index e1844406..1c1c5ef9 100644 --- a/elpa/org-plus-contrib-20150831/org-mhe.el +++ b/elpa/org-plus-contrib-20170407/org-mhe.el @@ -1,6 +1,6 @@ -;;; org-mhe.el --- Support for links to MH-E messages from within Org-mode +;;; org-mhe.el --- Support for Links to MH-E Messages -*- lexical-binding: t; -*- -;; Copyright (C) 2004-2015 Free Software Foundation, Inc. +;; Copyright (C) 2004-2017 Free Software Foundation, Inc. ;; Author: Thomas Baumann ;; Keywords: outlines, hypermedia, calendar, wp @@ -24,8 +24,8 @@ ;; ;;; Commentary: -;; This file implements links to MH-E messages from within Org-mode. -;; Org-mode loads this module by default - if this is not what you want, +;; This file implements links to MH-E messages from within Org. +;; Org mode loads this module by default - if this is not what you want, ;; configure the variable `org-modules'. ;;; Code: @@ -74,34 +74,25 @@ supported by MH-E." (defvar mh-search-regexp-builder) ;; Install the link type -(org-add-link-type "mhe" 'org-mhe-open) -(add-hook 'org-store-link-functions 'org-mhe-store-link) +(org-link-set-parameters "mhe" :follow #'org-mhe-open :store #'org-mhe-store-link) ;; Implementation (defun org-mhe-store-link () "Store a link to an MH-E folder or message." - (when (or (equal major-mode 'mh-folder-mode) - (equal major-mode 'mh-show-mode)) + (when (or (eq major-mode 'mh-folder-mode) + (eq major-mode 'mh-show-mode)) (save-window-excursion (let* ((from (org-mhe-get-header "From:")) (to (org-mhe-get-header "To:")) (message-id (org-mhe-get-header "Message-Id:")) (subject (org-mhe-get-header "Subject:")) (date (org-mhe-get-header "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)))) link desc) - (org-store-link-props :type "mh" :from from :to to + (org-store-link-props :type "mh" :from from :to to :date date :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 "mhe:" (org-mhe-get-message-real-folder) "#" - (org-remove-angle-brackets message-id))) + (org-unbracket-string "<" ">" message-id))) (org-add-link-props :link link :description desc) link)))) @@ -120,7 +111,7 @@ supported by MH-E." So if you use sequences, it will now work." (save-excursion (let* ((folder - (if (equal major-mode 'mh-folder-mode) + (if (eq major-mode 'mh-folder-mode) mh-current-folder ;; Refer to the show buffer mh-show-folder-buffer)) @@ -132,7 +123,7 @@ So if you use sequences, it will now work." ;; mh-index-data is always nil in a show buffer. (if (and (boundp 'mh-index-folder) (string= mh-index-folder (substring folder 0 end-index))) - (if (equal major-mode 'mh-show-mode) + (if (eq major-mode 'mh-show-mode) (save-window-excursion (let (pop-up-frames) (when (buffer-live-p (get-buffer folder)) @@ -158,7 +149,7 @@ So if you use sequences, it will now work." "Return the name of the current message folder. Be careful if you use sequences." (save-excursion - (if (equal major-mode 'mh-folder-mode) + (if (eq major-mode 'mh-folder-mode) mh-current-folder ;; Refer to the show buffer mh-show-folder-buffer))) @@ -167,7 +158,7 @@ Be careful if you use sequences." "Return the number of the current message. Be careful if you use sequences." (save-excursion - (if (equal major-mode 'mh-folder-mode) + (if (eq major-mode 'mh-folder-mode) (mh-get-msg-num nil) ;; Refer to the show buffer (mh-show-buffer-message-number)))) @@ -182,12 +173,12 @@ you have a better idea of how to do this then please let us know." (header-field)) (with-current-buffer buffer (mh-display-msg num folder) - (if (equal major-mode 'mh-folder-mode) + (if (eq major-mode 'mh-folder-mode) (mh-header-display) (mh-show-header-display)) (set-buffer buffer) (setq header-field (mh-get-header-field header)) - (if (equal major-mode 'mh-folder-mode) + (if (eq major-mode 'mh-folder-mode) (mh-show) (mh-show-show)) (org-trim header-field)))) @@ -206,7 +197,7 @@ folders." (if (not article) (mh-visit-folder (mh-normalize-folder-name folder)) (mh-search-choose) - (if (equal mh-searcher 'pick) + (if (eq mh-searcher 'pick) (progn (setq article (org-add-angle-brackets article)) (mh-search folder (list "--message-id" article)) diff --git a/elpa/org-plus-contrib-20150831/org-mobile.el b/elpa/org-plus-contrib-20170407/org-mobile.el similarity index 85% rename from elpa/org-plus-contrib-20150831/org-mobile.el rename to elpa/org-plus-contrib-20170407/org-mobile.el index 6c7c8d03..f6ef18f1 100644 --- a/elpa/org-plus-contrib-20150831/org-mobile.el +++ b/elpa/org-plus-contrib-20170407/org-mobile.el @@ -1,5 +1,5 @@ -;;; org-mobile.el --- Code for asymmetric sync with a mobile device -;; Copyright (C) 2009-2015 Free Software Foundation, Inc. +;;; org-mobile.el --- Code for Asymmetric Sync With a Mobile Device -*- lexical-binding: t; -*- +;; Copyright (C) 2009-2017 Free Software Foundation, Inc. ;; ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp @@ -24,21 +24,20 @@ ;; ;;; Commentary: ;; -;; This file contains the code to interact with Richard Moreland's iPhone -;; application MobileOrg, as well as with the Android version by Matthew Jones. -;; This code is documented in Appendix B of the Org-mode manual. The code is -;; not specific for the iPhone and Android - any external -;; viewer/flagging/editing application that uses the same conventions could -;; be used. +;; This file contains the code to interact with Richard Moreland's +;; iPhone application MobileOrg, as well as with the Android version +;; by Matthew Jones. This code is documented in Appendix B of the Org +;; manual. The code is not specific for the iPhone and Android - any +;; external viewer/flagging/editing application that uses the same +;; conventions could be used. (require 'org) (require 'org-agenda) -;;; Code: +(require 'cl-lib) -(eval-when-compile (require 'cl)) +(defvar org-agenda-keep-restricted-file-list) -(declare-function org-pop-to-buffer-same-window - "org-compat" (&optional buffer-or-name norecord label)) +;;; Code: (defgroup org-mobile nil "Options concerning support for a viewer/editor on a mobile device." @@ -88,7 +87,7 @@ org-agenda-text-search-extra-files Encryption uses AES-256, with a password given in `org-mobile-encryption-password'. When nil, plain files are kept on the server. -Turning on encryption requires to set the same password in the MobileOrg +Turning on encryption requires setting the same password in the MobileOrg application. Before turning this on, check of MobileOrg does already support it - at the time of this writing it did not yet." :group 'org-mobile @@ -192,27 +191,6 @@ the editing types for which the mobile version should always dominate." (const heading) (const body)))) -(defcustom org-mobile-action-alist - '(("edit" . (org-mobile-edit data old new))) - "Alist with flags and actions for mobile sync. -When flagging an entry, MobileOrg will create entries that look like - - * F(action:data) [[id:entry-id][entry title]] - -This alist defines that the ACTION in the parentheses of F() should mean, -i.e. what action should be taken. The :data part in the parenthesis is -optional. If present, the string after the colon will be passed to the -action form as the `data' variable. -The car of each elements of the alist is an actions string. The cdr is -an Emacs Lisp form that will be evaluated with the cursor on the headline -of that entry. - -For now, it is not recommended to change this variable." - :group 'org-mobile - :type '(repeat - (cons (string :tag "Action flag") - (sexp :tag "Action form")))) - (defcustom org-mobile-checksum-binary (or (executable-find "shasum") (executable-find "sha1sum") (executable-find "md5sum") @@ -249,6 +227,23 @@ by the mobile device, this hook should be used to copy the emptied capture file `mobileorg.org' back to the WebDAV directory, for example using `rsync' or `scp'.") +(defconst org-mobile-action-alist '(("edit" . org-mobile-edit)) + "Alist with flags and actions for mobile sync. +When flagging an entry, MobileOrg will create entries that look like + + * F(action:data) [[id:entry-id][entry title]] + +This alist defines that the ACTION in the parentheses of F() +should mean, i.e. what action should be taken. The :data part in +the parenthesis is optional. If present, the string after the +colon will be passed to the action function as the first argument +variable. + +The car of each elements of the alist is an actions string. The +cdr is a function that is called with the cursor on the headline +of that entry. It should accept three arguments, the :data part, +the old and new values for the entry.") + (defvar org-mobile-last-flagged-files nil "List of files containing entries flagged in the latest pull.") @@ -313,40 +308,29 @@ Also exclude files matching `org-mobile-files-exclude-regexp'." This will create the index file, copy all agenda files there, and also create all custom agenda views, for upload to the mobile phone." (interactive) - (let ((a-buffer (get-buffer org-agenda-buffer-name))) - (let ((org-agenda-curbuf-name org-agenda-buffer-name) - (org-agenda-buffer-name "*SUMO*") - (org-agenda-tag-filter org-agenda-tag-filter) - (org-agenda-redo-command org-agenda-redo-command)) - (save-excursion - (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) - (when (buffer-live-p a-buffer) - (if (not (get-buffer-window a-buffer)) - (kill-buffer a-buffer) - (let ((cw (selected-window))) - (select-window (get-buffer-window a-buffer)) - (org-agenda-redo) - (select-window cw))))) + (let ((org-agenda-buffer-name "*SUMO*") + (org-agenda-tag-filter org-agenda-tag-filter) + (org-agenda-redo-command org-agenda-redo-command)) + (save-excursion + (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))))) + (org-agenda-maybe-redo) (message "Files for mobile viewer staged")) (defvar org-mobile-before-process-capture-hook nil @@ -422,10 +406,10 @@ agenda view showing the flagged items." (let ((files-alist (sort (copy-sequence org-mobile-files-alist) (lambda (a b) (string< (cdr a) (cdr b))))) (def-todo (default-value 'org-todo-keywords)) - (def-tags (default-value 'org-tag-alist)) + (def-tags org-tag-alist) (target-file (expand-file-name org-mobile-index-file org-mobile-directory)) - file link-name todo-kwds done-kwds tags entry kwds dwds twds) + todo-kwds done-kwds tags) (when (stringp (car def-todo)) (setq def-todo (list (cons 'sequence def-todo)))) (org-agenda-prepare-buffers (mapcar 'car files-alist)) @@ -435,35 +419,24 @@ agenda view showing the flagged items." (org-uniquify org-todo-keywords-for-agenda))) (setq tags (mapcar 'car (org-global-tags-completion-table (mapcar 'car files-alist)))) - (with-temp-file - (if org-mobile-use-encryption - org-mobile-encryption-tempfile - target-file) + (with-temp-file (if org-mobile-use-encryption org-mobile-encryption-tempfile + target-file) (insert "#+READONLY\n") - (while (setq entry (pop def-todo)) - (setq kwds (mapcar (lambda (x) (if (string-match "(" x) - (substring x 0 (match-beginning 0)) - x)) - (cdr entry))) - (insert "#+TODO: " (mapconcat 'identity kwds " ") "\n") - (setq dwds (or (member "|" kwds) (last kwds)) - twds (org-delete-all dwds kwds) - todo-kwds (org-delete-all twds todo-kwds) - done-kwds (org-delete-all dwds done-kwds))) + (dolist (entry def-todo) + (let ((kwds (mapcar (lambda (x) + (if (string-match "(" x) + (substring x 0 (match-beginning 0)) + x)) + (cdr entry)))) + (insert "#+TODO: " (mapconcat #'identity kwds " ") "\n") + (let* ((dwds (or (member "|" kwds) (last kwds))) + (twds (org-delete-all dwds kwds))) + (setq todo-kwds (org-delete-all twds todo-kwds)) + (setq done-kwds (org-delete-all dwds done-kwds))))) (when (or todo-kwds done-kwds) (insert "#+TODO: " (mapconcat 'identity todo-kwds " ") " | " (mapconcat 'identity done-kwds " ") "\n")) - (setq def-tags (mapcar - (lambda (x) - (cond ((null x) nil) - ((stringp x) x) - ((eq (car x) :startgroup) "{") - ((eq (car x) :endgroup) "}") - ((eq (car x) :grouptags) nil) - ((eq (car x) :newline) nil) - ((listp x) (car x)))) - def-tags)) - (setq def-tags (delq nil def-tags)) + (setq def-tags (split-string (org-tag-alist-to-string def-tags t))) (setq tags (org-delete-all def-tags tags)) (setq tags (sort tags (lambda (a b) (string< (downcase a) (downcase b))))) (setq tags (append def-tags tags nil)) @@ -472,11 +445,8 @@ agenda view showing the flagged items." (when (file-exists-p (expand-file-name org-mobile-directory "agendas.org")) (insert "* [[file:agendas.org][Agenda Views]]\n")) - (while (setq entry (pop files-alist)) - (setq file (car entry) - link-name (cdr entry)) - (insert (format "* [[file:%s][%s]]\n" - link-name link-name))) + (pcase-dolist (`(,_ . ,link-name) files-alist) + (insert (format "* [[file:%s][%s]]\n" link-name link-name))) (push (cons org-mobile-index-file (md5 (buffer-string))) org-mobile-checksum-files)) (when org-mobile-use-encryption @@ -662,7 +632,7 @@ The table of checksums is written to the file mobile-checksums." m 10 " " 'planning) "\n") (when (setq id - (if (org-bound-and-true-p + (if (bound-and-true-p org-mobile-force-id-on-agenda-items) (org-id-get m 'create) (or (org-entry-get m "ID") @@ -822,14 +792,14 @@ If BEG and END are given, only do this in that region." (cnt-flag 0) (cnt-error 0) buf-list - id-pos org-mobile-error) + org-mobile-error) ;; Count the new captures (goto-char beg) (while (re-search-forward "^\\* \\(.*\\)" end t) (and (>= (- (match-end 1) (match-beginning 1)) 2) (not (equal (downcase (substring (match-string 1) 0 2)) "f(")) - (incf cnt-new))) + (cl-incf cnt-new))) ;; Find and apply the edits (goto-char beg) @@ -841,19 +811,21 @@ If BEG and END are given, only do this in that region." (id-pos (condition-case msg (org-mobile-locate-entry (match-string 4)) (error (nth 1 msg)))) - (bos (point-at-bol)) + (bos (line-beginning-position)) (eos (save-excursion (org-end-of-subtree t t))) (cmd (if (equal action "") - '(progn - (incf cnt-flag) - (org-toggle-tag "FLAGGED" 'on) - (and note - (org-entry-put nil "THEFLAGGINGNOTE" note))) - (incf cnt-edit) + (let ((note (buffer-substring-no-properties + (line-beginning-position 2) eos))) + (lambda (_data _old _new) + (cl-incf cnt-flag) + (org-toggle-tag "FLAGGED" 'on) + (org-entry-put + nil "THEFLAGGINGNOTE" + (replace-regexp-in-string "\n" "\\\\n" note)))) + (cl-incf cnt-edit) (cdr (assoc action org-mobile-action-alist)))) - (note (and (equal action "") - (buffer-substring (1+ (point-at-eol)) eos))) - (org-inhibit-logging 'note) ;; Do not take notes interactively + ;; Do not take notes interactively. + (org-inhibit-logging 'note) old new) (goto-char bos) @@ -866,11 +838,11 @@ If BEG and END are given, only do this in that region." (if (stringp id-pos) (insert id-pos " ") (insert "BAD REFERENCE ")) - (incf cnt-error) + (cl-incf cnt-error) (throw 'next t)) (unless cmd (insert "BAD FLAG ") - (incf cnt-error) + (cl-incf cnt-error) (throw 'next t)) (move-marker bos-marker (point)) (if (re-search-forward "^** Old value[ \t]*$" eos t) @@ -883,34 +855,28 @@ If BEG and END are given, only do this in that region." (progn (outline-next-heading) (if (eobp) (org-back-over-empty-lines)) (point))))) - (setq old (and old (if (string-match "\\S-" old) old nil))) - (setq new (and new (if (string-match "\\S-" new) new nil))) - (if (and note (> (length note) 0)) - ;; Make Note into a single line, to fit into a property - (setq note (mapconcat 'identity - (org-split-string (org-trim note) "\n") - "\\n"))) + (setq old (org-string-nw-p old)) + (setq new (org-string-nw-p new)) (unless (equal data "body") - (setq new (and new (org-trim new)) - old (and old (org-trim old)))) + (setq new (and new (org-trim new))) + (setq old (and old (org-trim old)))) (goto-char (+ 2 bos-marker)) ;; Remember this place so that we can return (move-marker marker (point)) (setq org-mobile-error nil) - (save-excursion - (condition-case msg - (org-with-point-at id-pos - (progn - (eval cmd) - (unless (member data (list "delete" "archive" "archive-sibling" "addheading")) - (if (member "FLAGGED" (org-get-tags)) - (add-to-list 'org-mobile-last-flagged-files - (buffer-file-name (current-buffer))))))) - (error (setq org-mobile-error msg)))) + (condition-case msg + (org-with-point-at id-pos + (funcall cmd data old new) + (unless (member data '("delete" "archive" "archive-sibling" + "addheading")) + (when (member "FLAGGED" (org-get-tags)) + (add-to-list 'org-mobile-last-flagged-files + (buffer-file-name))))) + (error (setq org-mobile-error msg))) (when org-mobile-error - (org-pop-to-buffer-same-window (marker-buffer marker)) + (pop-to-buffer-same-window (marker-buffer marker)) (goto-char marker) - (incf cnt-error) + (cl-incf cnt-error) (insert (if (stringp (nth 1 org-mobile-error)) (nth 1 org-mobile-error) "EXECUTION FAILED") @@ -923,8 +889,8 @@ If BEG and END are given, only do this in that region." (save-buffer) (move-marker marker nil) (move-marker end nil) - (message "%d new, %d edits, %d flags, %d errors" cnt-new - cnt-edit cnt-flag cnt-error) + (message "%d new, %d edits, %d flags, %d errors" + cnt-new cnt-edit cnt-flag cnt-error) (sit-for 1))) (defun org-mobile-timestamp-buffer (buf) @@ -1019,7 +985,7 @@ be returned that indicates what went wrong." ((equal new "DONEARCHIVE") (org-todo 'done) (org-archive-subtree-default)) - ((equal new current) t) ; nothing needs to be done + ((equal new current) t) ; nothing needs to be done ((or (equal current old) (eq org-mobile-force-mobile-change t) (memq 'todo org-mobile-force-mobile-change)) @@ -1041,33 +1007,35 @@ be returned that indicates what went wrong." (or old "") (or current ""))))) ((eq what 'priority) - (when (looking-at org-complex-heading-regexp) - (setq current (and (match-end 3) (substring (match-string 3) 2 3))) - (cond - ((equal current new) t) ; no action required - ((or (equal current old) - (eq org-mobile-force-mobile-change t) - (memq 'tags org-mobile-force-mobile-change)) - (org-priority (and new (string-to-char new)))) - (t (error "Priority was expected to be %s, but is %s" - old current))))) + (let ((case-fold-search nil)) + (when (looking-at org-complex-heading-regexp) + (let ((current (and (match-end 3) (substring (match-string 3) 2 3)))) + (cond + ((equal current new) t) ;no action required + ((or (equal current old) + (eq org-mobile-force-mobile-change t) + (memq 'tags org-mobile-force-mobile-change)) + (org-priority (and new (string-to-char new)))) + (t (error "Priority was expected to be %s, but is %s" + old current))))))) ((eq what 'heading) - (when (looking-at org-complex-heading-regexp) - (setq current (match-string 4)) - (cond - ((equal current new) t) ; no action required - ((or (equal current old) - (eq org-mobile-force-mobile-change t) - (memq 'heading org-mobile-force-mobile-change)) - (goto-char (match-beginning 4)) - (insert new) - (delete-region (point) (+ (point) (length current))) - (org-set-tags nil 'align)) - (t (error "Heading changed in MobileOrg and on the computer"))))) + (let ((case-fold-search nil)) + (when (looking-at org-complex-heading-regexp) + (let ((current (match-string 4))) + (cond + ((equal current new) t) ;no action required + ((or (equal current old) + (eq org-mobile-force-mobile-change t) + (memq 'heading org-mobile-force-mobile-change)) + (goto-char (match-beginning 4)) + (insert new) + (delete-region (point) (+ (point) (length current))) + (org-set-tags nil 'align)) + (t (error "Heading changed in MobileOrg and on the computer"))))))) ((eq what 'addheading) - (if (org-at-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 @@ -1082,7 +1050,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-at-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) diff --git a/elpa/org-plus-contrib-20150831/org-mouse.el b/elpa/org-plus-contrib-20170407/org-mouse.el similarity index 91% rename from elpa/org-plus-contrib-20150831/org-mouse.el rename to elpa/org-plus-contrib-20170407/org-mouse.el index 3fe35bd1..34a57005 100644 --- a/elpa/org-plus-contrib-20150831/org-mouse.el +++ b/elpa/org-plus-contrib-20170407/org-mouse.el @@ -1,6 +1,6 @@ -;;; org-mouse.el --- Better mouse support for org-mode +;;; org-mouse.el --- Better mouse support for Org -*- lexical-binding: t; -*- -;; Copyright (C) 2006-2015 Free Software Foundation, Inc. +;; Copyright (C) 2006-2017 Free Software Foundation, Inc. ;; Author: Piotr Zielinski ;; Maintainer: Carsten Dominik @@ -26,8 +26,8 @@ ;; ;; http://orgmode.org ;; -;; Org-mouse implements the following features: -;; * following links with the left mouse button (in Emacs 22) +;; Org mouse implements the following features: +;; * following links with the left mouse button ;; * subtree expansion/collapse (org-cycle) with the left mouse button ;; * several context menus on the right mouse button: ;; + general text @@ -66,12 +66,12 @@ ;; History: ;; -;; Since version 5.10: Changes are listed in the general org-mode docs. +;; Since version 5.10: Changes are listed in the general Org docs. ;; -;; Version 5.09;; + Version number synchronization with Org-mode. +;; Version 5.09;; + Version number synchronization with Org mode. ;; ;; Version 0.25 -;; + made compatible with org-mode 4.70 (thanks to Carsten for the patch) +;; + made compatible with Org 4.70 (thanks to Carsten for the patch) ;; ;; Version 0.24 ;; + minor changes to the table menu @@ -81,7 +81,7 @@ ;; + context menu support for org-agenda-undo & org-sort-entries ;; ;; Version 0.22 -;; + handles undo support for the agenda buffer (requires org-mode >=4.58) +;; + handles undo support for the agenda buffer (requires Org >=4.58) ;; ;; Version 0.21 ;; + selected text activates its context menu @@ -105,7 +105,7 @@ ;; + added support for checkboxes ;; ;; Version 0.15 -;; + org-mode now works with the Agenda buffer as well +;; + Org now works with the Agenda buffer as well ;; ;; Version 0.14 ;; + added a menu option that converts plain list items to outline items @@ -125,7 +125,7 @@ ;; ;; Version 0.10 ;; + added a menu option to remove highlights -;; + compatible with org-mode 4.21 now +;; + compatible with Org 4.21 now ;; ;; Version 0.08: ;; + trees can be moved/promoted/demoted by dragging with the right @@ -136,8 +136,8 @@ ;;; Code: -(eval-when-compile (require 'cl)) (require 'org) +(require 'cl-lib) (defvar org-agenda-allow-remote-undo) (defvar org-agenda-undo-list) @@ -149,6 +149,8 @@ (declare-function org-agenda-earlier "org-agenda" (arg)) (declare-function org-agenda-later "org-agenda" (arg)) +(defvar org-mouse-main-buffer nil + "Active buffer for mouse operations.") (defvar org-mouse-plain-list-regexp "\\([ \t]*\\)\\([-+*]\\|[0-9]+[.)]\\) " "Regular expression that matches a plain list.") (defvar org-mouse-direct t @@ -191,15 +193,14 @@ Changing this variable requires a restart of Emacs to get activated." (interactive) (end-of-line) (skip-chars-backward "\t ") - (when (org-looking-back ":[A-Za-z]+:" (line-beginning-position)) + (when (looking-back ":[A-Za-z]+:" (line-beginning-position)) (skip-chars-backward ":A-Za-z") (skip-chars-backward "\t "))) -(defvar org-mouse-context-menu-function nil +(defvar-local org-mouse-context-menu-function nil "Function to create the context menu. The value of this variable is the function invoked by `org-mouse-context-menu' as the context menu.") -(make-variable-buffer-local 'org-mouse-context-menu-function) (defun org-mouse-show-context-menu (event prefix) "Invoke the context menu. @@ -220,7 +221,7 @@ this function is called. Otherwise, the current major mode menu is used." (funcall org-mouse-context-menu-function event) (if (fboundp 'mouse-menu-major-mode-map) (popup-menu (mouse-menu-major-mode-map) event prefix) - (org-no-warnings ; don't warn about fallback, obsolete since 23.1 + (with-no-warnings ; don't warn about fallback, obsolete since 23.1 (mouse-major-mode-menu event prefix))))) (setq this-command 'mouse-save-then-kill) (mouse-save-then-kill event))) @@ -257,7 +258,7 @@ If the point is at the :beginning (`org-mouse-line-position') of the line, insert the new heading before the current line. Otherwise, insert it after the current heading." (interactive) - (case (org-mouse-line-position) + (cl-case (org-mouse-line-position) (:beginning (beginning-of-line) (org-insert-heading)) (t (org-mouse-next-heading) @@ -313,10 +314,10 @@ nor a function, elements of KEYWORDS are used directly." (just-one-space)) (defvar org-mouse-rest) -(defun org-mouse-replace-match-and-surround (newtext &optional fixedcase - literal string subexp) +(defun org-mouse-replace-match-and-surround + (_newtext &optional _fixedcase _literal _string subexp) "The same as `replace-match', but surrounds the replacement with spaces." - (apply 'replace-match org-mouse-rest) + (apply #'replace-match org-mouse-rest) (save-excursion (goto-char (match-beginning (or subexp 0))) (just-one-space) @@ -377,7 +378,7 @@ nor a function, elements of KEYWORDS are used directly." (defvar org-mouse-priority-regexp "\\[#\\([A-Z]\\)\\]" "Regular expression matching the priority indicator. Differs from `org-priority-regexp' in that it doesn't contain the -leading '.*?'.") +leading `.*?'.") (defun org-mouse-get-priority (&optional default) "Return the priority of the current headline. @@ -406,8 +407,8 @@ SCHEDULED: or DEADLINE: or ANYTHINGLIKETHIS:" (> (match-end 0) point)))))) (defun org-mouse-priority-list () - (loop for priority from ?A to org-lowest-priority - collect (char-to-string priority))) + (cl-loop for priority from ?A to org-lowest-priority + collect (char-to-string priority))) (defun org-mouse-todo-menu (state) "Create the menu with TODO keywords." @@ -459,33 +460,33 @@ SCHEDULED: or DEADLINE: or ANYTHINGLIKETHIS:" (insert " [ ] ")))) (defun org-mouse-agenda-type (type) - (case type - ('tags "Tags: ") - ('todo "TODO: ") - ('tags-tree "Tags tree: ") - ('todo-tree "TODO tree: ") - ('occur-tree "Occur tree: ") - (t "Agenda command ???"))) + (pcase type + (`tags "Tags: ") + (`todo "TODO: ") + (`tags-tree "Tags tree: ") + (`todo-tree "TODO tree: ") + (`occur-tree "Occur tree: ") + (_ "Agenda command ???"))) (defun org-mouse-list-options-menu (alloptions &optional function) (let ((options (save-match-data (split-string (match-string-no-properties 1))))) (print options) - (loop for name in alloptions - collect - (vector name - `(progn - (replace-match - (mapconcat 'identity - (sort (if (member ',name ',options) - (delete ',name ',options) - (cons ',name ',options)) - 'string-lessp) - " ") - nil nil nil 1) - (when (functionp ',function) (funcall ',function))) - :style 'toggle - :selected (and (member name options) t))))) + (cl-loop for name in alloptions + collect + (vector name + `(progn + (replace-match + (mapconcat 'identity + (sort (if (member ',name ',options) + (delete ',name ',options) + (cons ',name ',options)) + 'string-lessp) + " ") + nil nil nil 1) + (when (functionp ',function) (funcall ',function))) + :style 'toggle + :selected (and (member name options) t))))) (defun org-mouse-clip-text (text maxlength) (if (> (length text) maxlength) @@ -497,7 +498,7 @@ SCHEDULED: or DEADLINE: or ANYTHINGLIKETHIS:" `("Main Menu" ["Show Overview" org-mouse-show-overview t] ["Show Headlines" org-mouse-show-headlines t] - ["Show All" show-all t] + ["Show All" outline-show-all t] ["Remove Highlights" org-remove-occur-highlights :visible org-occur-highlights] "--" @@ -515,7 +516,6 @@ SCHEDULED: or DEADLINE: or ANYTHINGLIKETHIS:" ["Check Phrase ..." org-occur] "--" ["Display Agenda" org-agenda-list t] - ["Display Timeline" org-timeline t] ["Display TODO List" org-todo-list t] ("Display Tags" ,@(org-mouse-keyword-menu @@ -538,7 +538,7 @@ SCHEDULED: or DEADLINE: or ANYTHINGLIKETHIS:" ((stringp (nth 2 entry)) (concat (org-mouse-agenda-type (nth 1 entry)) (nth 2 entry))) - (t "Agenda Command '%s'")) + (t "Agenda Command `%s'")) 30)))) "--" ["Delete Blank Lines" delete-blank-lines @@ -555,30 +555,30 @@ SCHEDULED: or DEADLINE: or ANYTHINGLIKETHIS:" (let ((contextdata (assq context contextlist))) (when contextdata (save-excursion - (goto-char (second contextdata)) - (re-search-forward ".*" (third contextdata)))))) + (goto-char (nth 1 contextdata)) + (re-search-forward ".*" (nth 2 contextdata)))))) (defun org-mouse-for-each-item (funct) - ;; Functions called by `org-apply-on-list' need an argument - (let ((wrap-fun (lambda (c) (funcall funct)))) + ;; Functions called by `org-apply-on-list' need an argument. + (let ((wrap-fun (lambda (_) (funcall funct)))) (when (ignore-errors (goto-char (org-in-item-p))) (save-excursion (org-apply-on-list wrap-fun nil))))) (defun org-mouse-bolp () - "Return true if there only spaces, tabs, and '*' before point. + "Return true if there only spaces, tabs, and `*' before point. This means, between the beginning of line and the point." (save-excursion (skip-chars-backward " \t*") (bolp))) (defun org-mouse-insert-item (text) - (case (org-mouse-line-position) - (:beginning ; insert before + (cl-case (org-mouse-line-position) + (:beginning ; insert before (beginning-of-line) (looking-at "[ \t]*") (open-line 1) - (org-indent-to-column (- (match-end 0) (match-beginning 0))) + (indent-to-column (- (match-end 0) (match-beginning 0))) (insert "+ ")) - (:middle ; insert after + (:middle ; insert after (end-of-line) (newline t) (indent-relative) @@ -586,7 +586,7 @@ This means, between the beginning of line and the point." (:end ; insert text here (skip-chars-backward " \t") (kill-region (point) (point-at-eol)) - (unless (org-looking-back org-mouse-punctuation) + (unless (looking-back org-mouse-punctuation (line-beginning-position)) (insert (concat org-mouse-punctuation " "))))) (insert text) (beginning-of-line)) @@ -644,7 +644,8 @@ This means, between the beginning of line and the point." 'org-mode-restart)))) ((or (eolp) (and (looking-at "\\( \\|\t\\)\\(+:[0-9a-zA-Z_:]+\\)?\\( \\|\t\\)+$") - (org-looking-back " \\|\t" (- (point) 2)))) + (looking-back " \\|\t" (- (point) 2) + (line-beginning-position)))) (org-mouse-popup-global-menu)) ((funcall get-context :checkbox) (popup-menu @@ -707,9 +708,9 @@ This means, between the beginning of line and the point." ((org-mouse-looking-at ":\\([A-Za-z0-9_]+\\):" "A-Za-z0-9_" -1) ;tags (popup-menu `(nil - [,(format "Display '%s'" (match-string 1)) + [,(format-message "Display `%s'" (match-string 1)) (org-tags-view nil ,(match-string 1))] - [,(format "Sparse Tree '%s'" (match-string 1)) + [,(format-message "Sparse Tree `%s'" (match-string 1)) (org-tags-sparse-tree nil ,(match-string 1))] "--" ,@(org-mouse-tag-menu)))) @@ -736,13 +737,13 @@ This means, between the beginning of line and the point." ["- 1 Month" (org-timestamp-change -1 'month)]))) ((funcall get-context :table-special) (let ((mdata (match-data))) - (incf (car mdata) 2) + (cl-incf (car mdata) 2) (store-match-data mdata)) (message "match: %S" (match-string 0)) (popup-menu `(nil ,@(org-mouse-keyword-replace-menu '(" " "!" "^" "_" "$" "#" "*" "'") 0 (lambda (mark) - (case (string-to-char mark) + (cl-case (string-to-char mark) (? "( ) Nothing Special") (?! "(!) Column Names") (?^ "(^) Field Names Above") @@ -913,7 +914,7 @@ This means, between the beginning of line and the point." ((org-footnote-at-reference-p) nil) (t ad-do-it)))))) -(defun org-mouse-move-tree-start (event) +(defun org-mouse-move-tree-start (_event) (interactive "e") (message "Same line: promote/demote, (***):move before, (text): make a child")) @@ -992,7 +993,7 @@ This means, between the beginning of line and the point." (defvar org-mouse-cmd) ;dynamically scoped from `org-with-remote-undo'. (defun org-mouse-do-remotely (command) - ; (org-agenda-check-no-diary) + ;; (org-agenda-check-no-diary) (when (get-text-property (point) 'org-marker) (let* ((anticol (- (point-at-eol) (point))) (marker (get-text-property (point) 'org-marker)) @@ -1030,7 +1031,7 @@ This means, between the beginning of line and the point." (org-agenda-change-all-lines newhead hdmarker 'fixface)))) t)))) -(defun org-mouse-agenda-context-menu (&optional event) +(defun org-mouse-agenda-context-menu (&optional _event) (or (org-mouse-do-remotely 'org-mouse-context-menu) (popup-menu '("Agenda" @@ -1092,17 +1093,17 @@ This means, between the beginning of line and the point." ; (setq org-agenda-mode-hook nil) (defvar org-agenda-mode-map) (add-hook 'org-agenda-mode-hook - #'(lambda () - (setq org-mouse-context-menu-function 'org-mouse-agenda-context-menu) - (org-defkey org-agenda-mode-map [mouse-3] 'org-mouse-show-context-menu) - (org-defkey org-agenda-mode-map [down-mouse-3] 'org-mouse-move-tree-start) - (org-defkey org-agenda-mode-map [C-mouse-4] 'org-agenda-earlier) - (org-defkey org-agenda-mode-map [C-mouse-5] 'org-agenda-later) - (org-defkey org-agenda-mode-map [drag-mouse-3] - #'(lambda (event) (interactive "e") - (case (org-mouse-get-gesture event) - (:left (org-agenda-earlier 1)) - (:right (org-agenda-later 1))))))) + (lambda () + (setq org-mouse-context-menu-function 'org-mouse-agenda-context-menu) + (org-defkey org-agenda-mode-map [mouse-3] 'org-mouse-show-context-menu) + (org-defkey org-agenda-mode-map [down-mouse-3] 'org-mouse-move-tree-start) + (org-defkey org-agenda-mode-map [C-mouse-4] 'org-agenda-earlier) + (org-defkey org-agenda-mode-map [C-mouse-5] 'org-agenda-later) + (org-defkey org-agenda-mode-map [drag-mouse-3] + (lambda (event) (interactive "e") + (cl-case (org-mouse-get-gesture event) + (:left (org-agenda-earlier 1)) + (:right (org-agenda-later 1))))))) (provide 'org-mouse) diff --git a/elpa/org-plus-contrib-20150831/org-notify.el b/elpa/org-plus-contrib-20170407/org-notify.el similarity index 98% rename from elpa/org-plus-contrib-20150831/org-notify.el rename to elpa/org-plus-contrib-20170407/org-notify.el index 8bcca9f4..1a1d5579 100644 --- a/elpa/org-plus-contrib-20150831/org-notify.el +++ b/elpa/org-plus-contrib-20170407/org-notify.el @@ -1,6 +1,6 @@ ;;; org-notify.el --- Notifications for Org-mode -;; Copyright (C) 2012, 2013, 2014 Free Software Foundation, Inc. +;; Copyright (C) 2012-2017 Free Software Foundation, Inc. ;; Author: Peter Münster ;; Keywords: notification, todo-list, alarm, reminder, pop-up @@ -130,7 +130,7 @@ simple timestamp string." (pr :file (nth org-notify-parse-file (org-agenda-files 'unrestricted))) (pr :timestamp deadline) (pr :uid (md5 (concat heading deadline))) (pr :deadline (- (org-time-string-to-seconds deadline) - (org-float-time)))) + (float-time)))) result))) (defun org-notify-todo-list () @@ -165,7 +165,7 @@ forgotten tasks." (dolist (prms (plist-get org-notify-map (td :notify))) (when (< deadline (org-notify-string->seconds (prm :time))) (let ((period (org-notify-string->seconds (prm :period))) - (last-run (prm last-run-sym)) (now (org-float-time)) + (last-run (prm last-run-sym)) (now (float-time)) (actions (prm :actions)) diff plist) (when (or (not last-run) (and period (< period (setq diff (- now last-run))) diff --git a/elpa/org-plus-contrib-20150831/org-notmuch.el b/elpa/org-plus-contrib-20170407/org-notmuch.el similarity index 89% rename from elpa/org-plus-contrib-20150831/org-notmuch.el rename to elpa/org-plus-contrib-20170407/org-notmuch.el index 712ec5a9..65d75506 100644 --- a/elpa/org-plus-contrib-20150831/org-notmuch.el +++ b/elpa/org-plus-contrib-20170407/org-notmuch.el @@ -65,21 +65,23 @@ Should accept a notmuch search string as the sole argument." ;; Install the link type -(org-add-link-type "notmuch" 'org-notmuch-open) -(add-hook 'org-store-link-functions 'org-notmuch-store-link) +(org-link-set-parameters "notmuch" + :follow #'org-notmuch-open + :store #'org-notmuch-store-link) (defun org-notmuch-store-link () "Store a link to a notmuch search or message." (when (eq major-mode 'notmuch-show-mode) - (let* ((message-id (notmuch-show-get-prop :id)) + (let* ((message-id (notmuch-show-get-message-id t)) (subject (notmuch-show-get-subject)) (to (notmuch-show-get-to)) (from (notmuch-show-get-from)) + (date (org-trim (notmuch-show-get-date))) desc link) - (org-store-link-props :type "notmuch" :from from :to to + (org-store-link-props :type "notmuch" :from from :to to :date date :subject subject :message-id message-id) (setq desc (org-email-link-description)) - (setq link (concat "notmuch:" "id:" message-id)) + (setq link (concat "notmuch:id:" message-id)) (org-add-link-props :link link :description desc) link))) @@ -92,13 +94,13 @@ Should accept a notmuch search string as the sole argument." Can link to more than one message, if so all matching messages are shown." (require 'notmuch) - (notmuch-show (org-link-unescape search))) - + (notmuch-show search)) -(org-add-link-type "notmuch-search" 'org-notmuch-search-open) -(add-hook 'org-store-link-functions 'org-notmuch-search-store-link) +(org-link-set-parameters "notmuch-search" + :follow #'org-notmuch-search-open + :store #'org-notmuch-search-store-link) (defun org-notmuch-search-store-link () "Store a link to a notmuch search or message." diff --git a/elpa/org-plus-contrib-20150831/org-panel.el b/elpa/org-plus-contrib-20170407/org-panel.el similarity index 100% rename from elpa/org-plus-contrib-20150831/org-panel.el rename to elpa/org-plus-contrib-20170407/org-panel.el diff --git a/elpa/org-plus-contrib-20150831/org-passwords.el b/elpa/org-plus-contrib-20170407/org-passwords.el similarity index 100% rename from elpa/org-plus-contrib-20150831/org-passwords.el rename to elpa/org-plus-contrib-20170407/org-passwords.el diff --git a/elpa/org-plus-contrib-20150831/org-pcomplete.el b/elpa/org-plus-contrib-20170407/org-pcomplete.el similarity index 86% rename from elpa/org-plus-contrib-20150831/org-pcomplete.el rename to elpa/org-plus-contrib-20170407/org-pcomplete.el index 05683fe8..61ec5fad 100644 --- a/elpa/org-plus-contrib-20150831/org-pcomplete.el +++ b/elpa/org-plus-contrib-20170407/org-pcomplete.el @@ -1,6 +1,6 @@ -;;; org-pcomplete.el --- In-buffer completion code +;;; org-pcomplete.el --- In-buffer Completion Code -*- lexical-binding: t; -*- -;; Copyright (C) 2004-2015 Free Software Foundation, Inc. +;; Copyright (C) 2004-2017 Free Software Foundation, Inc. ;; ;; Author: Carsten Dominik ;; John Wiegley @@ -27,21 +27,17 @@ ;;;; Require other packages -(eval-when-compile - (require 'cl)) - (require 'org-macs) (require 'org-compat) (require 'pcomplete) -(declare-function org-split-string "org" (string &optional separators)) -(declare-function org-make-org-heading-search-string "org" - (&optional string)) +(declare-function org-make-org-heading-search-string "org" (&optional string)) (declare-function org-get-buffer-tags "org" ()) (declare-function org-get-tags "org" ()) (declare-function org-buffer-property-keys "org" - (&optional include-specials include-defaults include-columns)) -(declare-function org-entry-properties "org" (&optional pom which specific)) + (&optional specials defaults columns ignore-malformed)) +(declare-function org-entry-properties "org" (&optional pom which)) +(declare-function org-tag-alist-to-string "org" (alist &optional skip-key)) ;;;; Customization variables @@ -52,12 +48,13 @@ (defvar org-drawer-regexp) (defvar org-property-re) +(defvar org-current-tag-alist) (defun org-thing-at-point () "Examine the thing at point and let the caller know what it is. The return value is a string naming the thing at point." (let ((beg1 (save-excursion - (skip-chars-backward (org-re "[:alnum:]-_@")) + (skip-chars-backward "[:alnum:]-_@") (point))) (beg (save-excursion (skip-chars-backward "a-zA-Z0-9-_:$") @@ -93,8 +90,10 @@ The return value is a string naming the thing at point." (skip-chars-backward "[ \t\n]") ;; org-drawer-regexp matches a whole line but while ;; looking-back, we just ignore trailing whitespaces - (or (org-looking-back (substring org-drawer-regexp 0 -1)) - (org-looking-back org-property-re)))) + (or (looking-back (substring org-drawer-regexp 0 -1) + (line-beginning-position)) + (looking-back org-property-re + (line-beginning-position))))) (cons "prop" nil)) ((and (equal (char-before beg1) ?:) (not (equal (char-after (point-at-bol)) ?*))) @@ -140,7 +139,6 @@ When completing for #+STARTUP, for example, this function returns pcomplete-default-completion-function)))) (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 () @@ -153,16 +151,19 @@ When completing for #+STARTUP, for example, this function returns (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)))) + (dolist (name + '("CENTER" "COMMENT" "EXAMPLE" "EXPORT" "QUOTE" "SRC" + "VERSE") + block-names) + (push (format "END_%s" name) block-names) + (push (concat "BEGIN_" + name + ;; Since language is compulsory in + ;; export blocks source blocks, add + ;; a space. + (and (member name '("EXPORT" "SRC")) " ")) + block-names) + (push (format "ATTR_%s: " name) block-names))) (mapcar (lambda (keyword) (concat keyword ": ")) (org-get-export-keywords)))) (substring pcomplete-stub 2))) @@ -233,20 +234,10 @@ When completing for #+STARTUP, for example, this function returns (setq opts (delete "showstars" opts))))) opts)))) -(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 " ")))) + (list (org-tag-alist-to-string org-current-tag-alist)))) (defun pcomplete/org-mode/file-option/title () "Complete arguments for the #+TITLE file option." @@ -258,7 +249,7 @@ When completing for #+STARTUP, for example, this function returns (buffer-name (buffer-base-buffer))))))) -(declare-function org-export-backend-options "org-export" (cl-x)) +(declare-function org-export-backend-options "ox" (cl-x) t) (defun pcomplete/org-mode/file-option/options () "Complete arguments for the #+OPTIONS file option." (while (pcomplete-here @@ -271,7 +262,7 @@ When completing for #+STARTUP, for example, this function returns "|:" "tags:" "tasks:" "<:" "todo:") ;; OPTION items from registered back-ends. (let (items) - (dolist (backend (org-bound-and-true-p + (dolist (backend (bound-and-true-p org-export-registered-backends)) (dolist (option (org-export-backend-options backend)) (let ((item (nth 2 option))) @@ -283,7 +274,7 @@ When completing for #+STARTUP, for example, this function returns (while (pcomplete-here (pcomplete-uniqify-list (mapcar (lambda (item) (format "%s:" (car item))) - (org-bound-and-true-p org-html-infojs-opts-table)))))) + (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." @@ -324,26 +315,24 @@ This needs more work, to handle headings with lots of spaces in them." (save-excursion (goto-char (point-min)) (let (tbl) - (while (re-search-forward org-todo-line-regexp nil t) - (push (org-make-org-heading-search-string - (match-string-no-properties 3)) - tbl)) + (let ((case-fold-search nil)) + (while (re-search-forward org-todo-line-regexp nil t) + (push (org-make-org-heading-search-string + (match-string-no-properties 3)) + tbl))) (pcomplete-uniqify-list tbl))) (substring pcomplete-stub 1)))) -(defvar org-tag-alist) (defun pcomplete/org-mode/tag () "Complete a tag name. Omit tags already set." (while (pcomplete-here - (mapcar (lambda (x) - (concat x ":")) + (mapcar (lambda (x) (concat x ":")) (let ((lst (pcomplete-uniqify-list - (or (remove + (or (remq nil - (mapcar (lambda (x) - (and (stringp (car x)) (car x))) - org-tag-alist)) - (mapcar 'car (org-get-buffer-tags)))))) + (mapcar (lambda (x) (org-string-nw-p (car x))) + org-current-tag-alist)) + (mapcar #'car (org-get-buffer-tags)))))) (dolist (tag (org-get-tags)) (setq lst (delete tag lst))) lst)) @@ -357,7 +346,7 @@ This needs more work, to handle headings with lots of spaces in them." (concat x ": ")) (let ((lst (pcomplete-uniqify-list (copy-sequence - (org-buffer-property-keys nil t t))))) + (org-buffer-property-keys nil t t t))))) (dolist (prop (org-entry-properties)) (setq lst (delete (car prop) lst))) lst)) diff --git a/elpa/org-plus-contrib-20150831/org-plot.el b/elpa/org-plus-contrib-20170407/org-plot.el similarity index 77% rename from elpa/org-plus-contrib-20150831/org-plot.el rename to elpa/org-plus-contrib-20170407/org-plot.el index a089f341..449143a4 100644 --- a/elpa/org-plus-contrib-20150831/org-plot.el +++ b/elpa/org-plus-contrib-20170407/org-plot.el @@ -1,6 +1,6 @@ -;;; org-plot.el --- Support for plotting from Org-mode +;;; org-plot.el --- Support for Plotting from Org -*- lexical-binding: t; -*- -;; Copyright (C) 2008-2015 Free Software Foundation, Inc. +;; Copyright (C) 2008-2017 Free Software Foundation, Inc. ;; ;; Author: Eric Schulte ;; Keywords: tables, plotting @@ -25,14 +25,14 @@ ;; Borrows ideas and a couple of lines of code from org-exp.el. -;; Thanks to the org-mode mailing list for testing and implementation -;; and feature suggestions +;; Thanks to the Org mailing list for testing and implementation and +;; feature suggestions ;;; Code: + +(require 'cl-lib) (require 'org) (require 'org-table) -(eval-when-compile - (require 'cl)) (declare-function gnuplot-delchar-or-maybe-eof "ext:gnuplot" (arg)) (declare-function gnuplot-mode "ext:gnuplot" ()) @@ -49,41 +49,39 @@ (defun org-plot/add-options-to-plist (p options) "Parse an OPTIONS line and set values in the property list P. Returns the resulting property list." - (let (o) - (when options - (let ((op '(("type" . :plot-type) - ("script" . :script) - ("line" . :line) - ("set" . :set) - ("title" . :title) - ("ind" . :ind) - ("deps" . :deps) - ("with" . :with) - ("file" . :file) - ("labels" . :labels) - ("map" . :map) - ("timeind" . :timeind) - ("timefmt" . :timefmt))) - (multiples '("set" "line")) - (regexp ":\\([\"][^\"]+?[\"]\\|[(][^)]+?[)]\\|[^ \t\n\r;,.]*\\)") - (start 0) - o) - (while (setq o (pop op)) - (if (member (car o) multiples) ;; keys with multiple values - (while (string-match - (concat (regexp-quote (car o)) regexp) - options start) - (setq start (match-end 0)) - (setq p (plist-put p (cdr o) - (cons (car (read-from-string - (match-string 1 options))) - (plist-get p (cdr o))))) - p) - (if (string-match (concat (regexp-quote (car o)) regexp) - options) - (setq p (plist-put p (cdr o) - (car (read-from-string - (match-string 1 options))))))))))) + (when options + (let ((op '(("type" . :plot-type) + ("script" . :script) + ("line" . :line) + ("set" . :set) + ("title" . :title) + ("ind" . :ind) + ("deps" . :deps) + ("with" . :with) + ("file" . :file) + ("labels" . :labels) + ("map" . :map) + ("timeind" . :timeind) + ("timefmt" . :timefmt))) + (multiples '("set" "line")) + (regexp ":\\([\"][^\"]+?[\"]\\|[(][^)]+?[)]\\|[^ \t\n\r;,.]*\\)") + (start 0)) + (dolist (o op) + (if (member (car o) multiples) ;; keys with multiple values + (while (string-match + (concat (regexp-quote (car o)) regexp) + options start) + (setq start (match-end 0)) + (setq p (plist-put p (cdr o) + (cons (car (read-from-string + (match-string 1 options))) + (plist-get p (cdr o))))) + p) + (if (string-match (concat (regexp-quote (car o)) regexp) + options) + (setq p (plist-put p (cdr o) + (car (read-from-string + (match-string 1 options)))))))))) p) (defun org-plot/goto-nearest-table () @@ -94,7 +92,7 @@ Return value is the point at the beginning of the table." (goto-char (org-table-begin))) (defun org-plot/collect-options (&optional params) - "Collect options from an org-plot '#+Plot:' line. + "Collect options from an org-plot `#+Plot:' line. Accepts an optional property list PARAMS, to which the options will be added. Returns the resulting property list." (interactive) @@ -119,10 +117,9 @@ will be added. Returns the resulting property list." Pass PARAMS through to `orgtbl-to-generic' when exporting TABLE." (with-temp-file data-file - (make-local-variable 'org-plot-timestamp-fmt) - (setq org-plot-timestamp-fmt (or - (plist-get params :timefmt) - "%Y-%m-%d-%H:%M:%S")) + (setq-local org-plot-timestamp-fmt (or + (plist-get params :timefmt) + "%Y-%m-%d-%H:%M:%S")) (insert (orgtbl-to-generic table (org-combine-plists @@ -140,7 +137,7 @@ and dependant variables." (deps (if (plist-member params :deps) (mapcar (lambda (val) (- val 1)) (plist-get params :deps)) (let (collector) - (dotimes (col (length (first table))) + (dotimes (col (length (nth 0 table))) (setf collector (cons col collector))) collector))) (counter 0) @@ -158,7 +155,7 @@ and dependant variables." table))) ;; write table to gnuplot grid datafile format (with-temp-file data-file - (let ((num-rows (length table)) (num-cols (length (first table))) + (let ((num-rows (length table)) (num-cols (length (nth 0 table))) (gnuplot-row (lambda (col row value) (setf col (+ 1 col)) (setf row (+ 1 row)) (format "%f %f %f\n%f %f %f\n" @@ -202,10 +199,10 @@ manner suitable for prepending to a user-specified script." (x-labels (plist-get params :xlabels)) (y-labels (plist-get params :ylabels)) (plot-str "'%s' using %s%d%s with %s title '%s'") - (plot-cmd (case type - ('2d "plot") - ('3d "splot") - ('grid "splot"))) + (plot-cmd (pcase type + (`2d "plot") + (`3d "splot") + (`grid "splot"))) (script "reset") ;; ats = add-to-script (ats (lambda (line) (setf script (concat script "\n" line)))) @@ -213,15 +210,15 @@ manner suitable for prepending to a user-specified script." (when file ; output file (funcall ats (format "set term %s" (file-name-extension file))) (funcall ats (format "set output '%s'" file))) - (case type ; type - (2d ()) - (3d (when map (funcall ats "set map"))) - (grid (if map (funcall ats "set pm3d map") (funcall ats "set pm3d")))) + (pcase type ; type + (`2d ()) + (`3d (when map (funcall ats "set map"))) + (`grid (funcall ats (if map "set pm3d map" "set pm3d")))) (when title (funcall ats (format "set title '%s'" title))) ; title (mapc ats lines) ; line (dolist (el sets) (funcall ats (format "set %s" el))) ; set ;; Unless specified otherwise, values are TAB separated. - (unless (org-string-match-p "^set datafile separator" script) + (unless (string-match-p "^set datafile separator" script) (funcall ats "set datafile separator \"\\t\"")) (when x-labels ; x labels (xtics) (funcall ats @@ -241,26 +238,27 @@ manner suitable for prepending to a user-specified script." (or timefmt ; timefmt passed to gnuplot "%Y-%m-%d-%H:%M:%S") "\""))) (unless preface - (case type ; plot command - (2d (dotimes (col num-cols) - (unless (and (eq type '2d) - (or (and ind (equal (1+ col) ind)) - (and deps (not (member (1+ col) deps))))) - (setf plot-lines - (cons - (format plot-str data-file - (or (and ind (> ind 0) - (not text-ind) - (format "%d:" ind)) "") - (1+ col) - (if text-ind (format ":xticlabel(%d)" ind) "") - with - (or (nth col col-labels) (format "%d" (1+ col)))) - plot-lines))))) - (3d + (pcase type ; plot command + (`2d (dotimes (col num-cols) + (unless (and (eq type '2d) + (or (and ind (equal (1+ col) ind)) + (and deps (not (member (1+ col) deps))))) + (setf plot-lines + (cons + (format plot-str data-file + (or (and ind (> ind 0) + (not text-ind) + (format "%d:" ind)) "") + (1+ col) + (if text-ind (format ":xticlabel(%d)" ind) "") + with + (or (nth col col-labels) + (format "%d" (1+ col)))) + plot-lines))))) + (`3d (setq plot-lines (list (format "'%s' matrix with %s title ''" data-file with)))) - (grid + (`grid (setq plot-lines (list (format "'%s' with %s title ''" data-file with))))) (funcall ats @@ -291,24 +289,25 @@ line directly before or after the table." ;; collect table and table information (let* ((data-file (make-temp-file "org-plot")) (table (org-table-to-lisp)) - (num-cols (length (if (eq (first table) 'hline) (second table) - (first table))))) + (num-cols (length (if (eq (nth 0 table) 'hline) (nth 1 table) + (nth 0 table))))) (run-with-idle-timer 0.1 nil #'delete-file data-file) (while (eq 'hline (car table)) (setf table (cdr table))) (when (eq (cadr table) 'hline) - (setf params (plist-put params :labels (first table))) ; headers to labels + (setf params + (plist-put params :labels (nth 0 table))) ; headers to labels (setf table (delq 'hline (cdr table)))) ; clean non-data from table ;; Collect options. (save-excursion (while (and (equal 0 (forward-line -1)) (looking-at "[[:space:]]*#\\+")) (setf params (org-plot/collect-options params)))) ;; Dump table to datafile (very different for grid). - (case (plist-get params :plot-type) - (2d (org-plot/gnuplot-to-data table data-file params)) - (3d (org-plot/gnuplot-to-data table data-file params)) - (grid (let ((y-labels (org-plot/gnuplot-to-grid-data - table data-file params))) - (when y-labels (plist-put params :ylabels y-labels))))) + (pcase (plist-get params :plot-type) + (`2d (org-plot/gnuplot-to-data table data-file params)) + (`3d (org-plot/gnuplot-to-data table data-file params)) + (`grid (let ((y-labels (org-plot/gnuplot-to-grid-data + table data-file params))) + (when y-labels (plist-put params :ylabels y-labels))))) ;; Check for timestamp ind column. (let ((ind (1- (plist-get params :ind)))) (when (and (>= ind 0) (eq '2d (plist-get params :plot-type))) diff --git a/elpa/org-plus-contrib-20170407/org-plus-contrib-pkg.el b/elpa/org-plus-contrib-20170407/org-plus-contrib-pkg.el new file mode 100644 index 00000000..3b20388f --- /dev/null +++ b/elpa/org-plus-contrib-20170407/org-plus-contrib-pkg.el @@ -0,0 +1,5 @@ +(define-package "org-plus-contrib" + "20170407" "Outline-based notes management and organizer" ( )) +;; Local Variables: +;; no-byte-compile: t +;; End: diff --git a/elpa/org-plus-contrib-20150831/org-protocol.el b/elpa/org-plus-contrib-20170407/org-protocol.el similarity index 64% rename from elpa/org-plus-contrib-20150831/org-protocol.el rename to elpa/org-plus-contrib-20170407/org-protocol.el index d0750f7d..a031d51d 100644 --- a/elpa/org-plus-contrib-20150831/org-protocol.el +++ b/elpa/org-plus-contrib-20170407/org-protocol.el @@ -1,6 +1,6 @@ -;;; org-protocol.el --- Intercept calls from emacsclient to trigger custom actions. +;;; org-protocol.el --- Intercept Calls from Emacsclient to Trigger Custom Actions -*- lexical-binding: t; -*- ;; -;; Copyright (C) 2008-2015 Free Software Foundation, Inc. +;; Copyright (C) 2008-2017 Free Software Foundation, Inc. ;; ;; Authors: Bastien Guerry ;; Daniel M German @@ -49,7 +49,7 @@ ;; 4.) Try this from the command line (adjust the URL as needed): ;; ;; $ emacsclient \ -;; org-protocol://store-link://http:%2F%2Flocalhost%2Findex.html/The%20title +;; org-protocol://store-link?url=http:%2F%2Flocalhost%2Findex.html&title=The%20title ;; ;; 5.) Optionally add custom sub-protocols and handlers: ;; @@ -60,7 +60,7 @@ ;; ;; A "sub-protocol" will be found in URLs like this: ;; -;; org-protocol://sub-protocol://data +;; org-protocol://sub-protocol?key=val&key2=val2 ;; ;; If it works, you can now setup other applications for using this feature. ;; @@ -81,12 +81,12 @@ ;; * `org-protocol-open-source' uses the sub-protocol \"open-source\" and maps ;; URLs to local filenames defined in `org-protocol-project-alist'. ;; -;; * `org-protocol-store-link' stores an Org-link (if Org-mode is present) and +;; * `org-protocol-store-link' stores an Org link (if Org is present) and ;; pushes the browsers URL to the `kill-ring' for yanking. This handler is ;; triggered through the sub-protocol \"store-link\". ;; ;; * Call `org-protocol-capture' by using the sub-protocol \"capture\". If -;; Org-mode is loaded, Emacs will pop-up a capture buffer and fill the +;; Org is loaded, Emacs will pop-up a capture buffer and fill the ;; template with the data provided. I.e. the browser's URL is inserted as an ;; 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. @@ -94,20 +94,20 @@ ;; You may use the same bookmark URL for all those standard handlers and just ;; adjust the sub-protocol used: ;; -;; location.href='org-protocol://sub-protocol://'+ -;; encodeURIComponent(location.href)+'/'+ -;; encodeURIComponent(document.title)+'/'+ +;; location.href='org-protocol://sub-protocol?url='+ +;; encodeURIComponent(location.href)+'&title='+ +;; encodeURIComponent(document.title)+'&body='+ ;; encodeURIComponent(window.getSelection()) ;; ;; The handler for the sub-protocol \"capture\" detects an optional template ;; char that, if present, triggers the use of a special template. ;; Example: ;; -;; location.href='org-protocol://sub-protocol://x/'+ ... +;; location.href='org-protocol://capture?template=x'+ ... ;; -;; use template ?x. +;; uses template ?x. ;; -;; Note, that using double slashes is optional from org-protocol.el's point of +;; Note that using double slashes is optional from org-protocol.el's point of ;; view because emacsclient squashes the slashes to one. ;; ;; @@ -116,25 +116,12 @@ ;;; Code: (require 'org) -(eval-when-compile - (require 'cl)) -(declare-function org-publish-get-project-from-filename "org-publish" +(declare-function org-publish-get-project-from-filename "ox-publish" (filename &optional up)) (declare-function server-edit "server" (&optional arg)) -(define-obsolete-function-alias - 'org-protocol-unhex-compound 'org-link-unescape-compound - "2011-02-17") - -(define-obsolete-function-alias - 'org-protocol-unhex-string 'org-link-unescape - "2011-02-17") - -(define-obsolete-function-alias - 'org-protocol-unhex-single-byte-sequence - 'org-link-unescape-single-byte-sequence - "2011-02-17") +(defvar org-capture-link-is-already-stored) (defgroup org-protocol nil "Intercept calls from emacsclient to trigger custom actions. @@ -197,7 +184,7 @@ Possible properties are: Example: (setq org-protocol-project-alist - '((\"http://orgmode.org/worg/\" + \\='((\"http://orgmode.org/worg/\" :online-suffix \".php\" :working-suffix \".org\" :base-url \"http://orgmode.org/worg/\" @@ -225,33 +212,42 @@ Each element of this list must be of the form: (module-name :protocol protocol :function func :kill-client nil) -protocol - protocol to detect in a filename without trailing colon and slashes. - See rfc1738 section 2.1 for more on this. - If you define a protocol \"my-protocol\", `org-protocol-check-filename-for-protocol' - will search filenames for \"org-protocol:/my-protocol:/\" - and trigger your action for every match. `org-protocol' is defined in - `org-protocol-the-protocol'. Double and triple slashes are compressed - to one by emacsclient. - -function - function that handles requests with protocol and takes exactly one - argument: the filename with all protocols stripped. If the function - returns nil, emacsclient and -server do nothing. Any non-nil return - value is considered a valid filename and thus passed to the server. - - `org-protocol.el provides some support for handling those filenames, - if you stay with the conventions used for the standard handlers in - `org-protocol-protocol-alist-default'. See `org-protocol-split-data'. +protocol - protocol to detect in a filename without trailing + colon and slashes. See rfc1738 section 2.1 for more + on this. If you define a protocol \"my-protocol\", + `org-protocol-check-filename-for-protocol' will search + filenames for \"org-protocol:/my-protocol\" and + trigger your action for every match. `org-protocol' + is defined in `org-protocol-the-protocol'. Double and + triple slashes are compressed to one by emacsclient. + +function - function that handles requests with protocol and takes + one argument. If a new-style link (key=val&key2=val2) + is given, the argument will be a property list with + the values from the link. If an old-style link is + given (val1/val2), the argument will be the filename + with all protocols stripped. + + If the function returns nil, emacsclient and -server + do nothing. Any non-nil return value is considered a + valid filename and thus passed to the server. + + `org-protocol.el' provides some support for handling + old-style filenames, if you follow the conventions + used for the standard handlers in + `org-protocol-protocol-alist-default'. See + `org-protocol-parse-parameters'. kill-client - If t, kill the client immediately, once the sub-protocol is detected. This is necessary for actions that can be interrupted by - `C-g' to avoid dangling emacsclients. Note, that all other command - line arguments but the this one will be discarded, greedy handlers + `C-g' to avoid dangling emacsclients. Note that all other command + line arguments but the this one will be discarded. Greedy handlers still receive the whole list of arguments though. Here is an example: (setq org-protocol-protocol-alist - '((\"my-protocol\" + \\='((\"my-protocol\" :protocol \"my-protocol\" :function my-protocol-handler-function) (\"your-protocol\" @@ -269,7 +265,7 @@ string with two characters." (defcustom org-protocol-data-separator "/+\\|\\?" "The default data separator to use. - This should be a single regexp string." +This should be a single regexp string." :group 'org-protocol :version "24.4" :package-version '(Org . "8.0") @@ -278,21 +274,20 @@ string with two characters." ;;; Helper functions: (defun org-protocol-sanitize-uri (uri) - "emacsclient compresses double and triple slashes. -Slashes are sanitized to double slashes here." + "Sanitize slashes to double-slashes in URI. +Emacsclient compresses double and triple slashes." (when (string-match "^\\([a-z]+\\):/" uri) (let* ((splitparts (split-string uri "/+"))) (setq uri (concat (car splitparts) "//" (mapconcat 'identity (cdr splitparts) "/"))))) uri) (defun org-protocol-split-data (data &optional unhexify separator) - "Split what an org-protocol handler function gets as only argument. -DATA is that one argument. DATA is split at each occurrence of -SEPARATOR (regexp). If no SEPARATOR is specified or SEPARATOR is -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." + "Split the DATA argument for an org-protocol handler function. +If UNHEXIFY is non-nil, hex-decode each split part. If UNHEXIFY +is a function, use that function to decode each split part. The +string is split at each occurrence of SEPARATOR (regexp). If no +SEPARATOR is specified or SEPARATOR is nil, assume \"/+\". The +results of that splitting are returned as a list." (let* ((sep (or separator "/+\\|\\?")) (split-parts (split-string data sep))) (if unhexify @@ -302,23 +297,25 @@ part." split-parts))) (defun org-protocol-flatten-greedy (param-list &optional strip-path replacement) - "Greedy handlers might receive a list like this from emacsclient: - '((\"/dir/org-protocol:/greedy:/~/path1\" (23 . 12)) (\"/dir/param\") -where \"/dir/\" is the absolute path to emacsclients working directory. This + "Transform PARAM-LIST into a flat list for greedy handlers. + +Greedy handlers might receive a list like this from emacsclient: +\((\"/dir/org-protocol:/greedy:/~/path1\" (23 . 12)) (\"/dir/param\")) +where \"/dir/\" is the absolute path to emacsclient's working directory. This function transforms it into a flat list using `org-protocol-flatten' and transforms the elements of that list as follows: -If strip-path is non-nil, remove the \"/dir/\" prefix from all members of +If STRIP-PATH is non-nil, remove the \"/dir/\" prefix from all members of param-list. -If replacement is string, replace the \"/dir/\" prefix with it. +If REPLACEMENT is string, replace the \"/dir/\" prefix with it. The first parameter, the one that contains the protocols, is always changed. Everything up to the end of the protocols is stripped. Note, that this function will always behave as if `org-protocol-reverse-list-of-files' was set to t and the returned list will -reflect that. I.e. emacsclients first parameter will be the first one in the +reflect that. emacsclient's first parameter will be the first one in the returned list." (let* ((l (org-protocol-flatten (if org-protocol-reverse-list-of-files param-list @@ -345,67 +342,123 @@ returned list." ret) l))) -(defun org-protocol-flatten (l) - "Greedy handlers might receive a list like this from emacsclient: - '( (\"/dir/org-protocol:/greedy:/~/path1\" (23 . 12)) (\"/dir/param\") +(defun org-protocol-flatten (list) + "Transform LIST into a flat list. + +Greedy handlers might receive a list like this from emacsclient: +\((\"/dir/org-protocol:/greedy:/~/path1\" (23 . 12)) (\"/dir/param\")) where \"/dir/\" is the absolute path to emacsclients working directory. This function transforms it into a flat list." - (if (null l) () - (if (listp l) - (append (org-protocol-flatten (car l)) (org-protocol-flatten (cdr l))) - (list l)))) - + (if (null list) () + (if (listp list) + (append (org-protocol-flatten (car list)) (org-protocol-flatten (cdr list))) + (list list)))) + +(defun org-protocol-parse-parameters (info &optional new-style default-order) + "Return a property list of parameters from INFO. +If NEW-STYLE is non-nil, treat INFO as a query string (ex: +url=URL&title=TITLE). If old-style links are used (ex: +org-protocol://store-link/url/title), assign them to attributes +following DEFAULT-ORDER. + +If no DEFAULT-ORDER is specified, return the list of values. + +If INFO is already a property list, return it unchanged." + (if (listp info) + info + (if new-style + (let ((data (org-protocol-convert-query-to-plist info)) + result) + (while data + (setq result + (append + result + (list + (pop data) + (org-link-unescape (pop data)))))) + result) + (let ((data (org-protocol-split-data info t org-protocol-data-separator))) + (if default-order + (org-protocol-assign-parameters data default-order) + data))))) + +(defun org-protocol-assign-parameters (data default-order) + "Return a property list of parameters from DATA. +Key names are taken from DEFAULT-ORDER, which should be a list of +symbols. If DEFAULT-ORDER is shorter than the number of values +specified, the rest of the values are treated as :key value pairs." + (let (result) + (while default-order + (setq result + (append result + (list (pop default-order) + (pop data))))) + (while data + (setq result + (append result + (list (intern (concat ":" (pop data))) + (pop data))))) + result)) ;;; Standard protocol handlers: (defun org-protocol-store-link (fname) - "Process an org-protocol://store-link:// style url. + "Process an org-protocol://store-link style url. Additionally store a browser URL as an org link. Also pushes the link's URL to the `kill-ring'. +Parameters: url, title (optional), body (optional) + +Old-style links such as org-protocol://store-link://URL/TITLE are +also recognized. + The location for a browser's bookmark has to look like this: - javascript:location.href='org-protocol://store-link://'+ \\ - encodeURIComponent(location.href) - encodeURIComponent(document.title)+'/'+ \\ + javascript:location.href = \\ + \\='org-protocol://store-link?url=\\=' + \\ + encodeURIComponent(location.href) + \\='&title=\\=' + \\ + encodeURIComponent(document.title); -Don't use `escape()'! Use `encodeURIComponent()' instead. The title of the page -could contain slashes and the location definitely will. +Don't use `escape()'! Use `encodeURIComponent()' instead. The +title of the page could contain slashes and the location +definitely will. The sub-protocol used to reach this function is set in -`org-protocol-protocol-alist'." - (let* ((splitparts (org-protocol-split-data fname t org-protocol-data-separator)) - (uri (org-protocol-sanitize-uri (car splitparts))) - (title (cadr splitparts)) - orglink) - (if (boundp 'org-stored-links) - (setq org-stored-links (cons (list uri title) org-stored-links))) +`org-protocol-protocol-alist'. + +FNAME should be a property list. If not, an old-style link of the +form URL/TITLE can also be used." + (let* ((splitparts (org-protocol-parse-parameters fname nil '(:url :title))) + (uri (org-protocol-sanitize-uri (plist-get splitparts :url))) + (title (plist-get splitparts :title))) + (when (boundp 'org-stored-links) + (push (list uri title) org-stored-links)) (kill-new uri) (message "`%s' to insert new org-link, `%s' to insert `%s'" - (substitute-command-keys"\\[org-insert-link]") - (substitute-command-keys"\\[yank]") + (substitute-command-keys "`\\[org-insert-link]'") + (substitute-command-keys "`\\[yank]'") uri)) nil) (defun org-protocol-capture (info) - "Process an org-protocol://capture:// style url. + "Process an org-protocol://capture style url with INFO. 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 looks like this: +by `/'. The location for a browser's bookmark looks like this: - javascript:location.href='org-protocol://capture://'+ \\ - encodeURIComponent(location.href)+'/' \\ - encodeURIComponent(document.title)+'/'+ \\ + javascript:location.href = \\='org-protocol://capture?url=\\='+ \\ + encodeURIComponent(location.href) + \\='&title=\\=' \\ + encodeURIComponent(document.title) + \\='&body=\\=' + \\ encodeURIComponent(window.getSelection()) By default, it uses the character `org-protocol-default-template-key', which should be associated with a template in `org-capture-templates'. -But you may prepend the encoded URL with a character and a slash like so: +You may specify the template with a template= query parameter, like this: - javascript:location.href='org-protocol://capture://b/'+ ... + javascript:location.href = \\='org-protocol://capture?template=b\\='+ ... Now template ?b will be used." (if (and (boundp 'org-stored-links) @@ -414,7 +467,7 @@ Now template ?b will be used." nil) (defun org-protocol-convert-query-to-plist (query) - "Convert query string that is part of url to property list." + "Convert QUERY key=value pairs in the URL to a property list." (if query (apply 'append (mapcar (lambda (x) (let ((c (split-string x "="))) @@ -422,18 +475,26 @@ Now template ?b will be used." (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)) + "Perform the actual capture based on INFO." + (let* ((temp-parts (org-protocol-parse-parameters info)) + (parts + (cond + ((and (listp info) (symbolp (car info))) info) + ((= (length (car temp-parts)) 1) ;; First parameter is exactly one character long + (org-protocol-assign-parameters temp-parts '(:template :url :title :body))) + (t + (org-protocol-assign-parameters temp-parts '(:url :title :body))))) + (template (or (plist-get parts :template) org-protocol-default-template-key)) - (url (org-protocol-sanitize-uri (car parts))) - (type (if (string-match "^\\([a-z]+\\):" url) - (match-string 1 url))) - (title (or (cadr parts) "")) - (region (or (caddr parts) "")) - (orglink (org-make-link-string - url (if (string-match "[^[:space:]]" title) title url))) - (query (or (org-protocol-convert-query-to-plist (cadddr parts)) "")) + (url (and (plist-get parts :url) (org-protocol-sanitize-uri (plist-get parts :url)))) + (type (and url (if (string-match "^\\([a-z]+\\):" url) + (match-string 1 url)))) + (title (or (plist-get parts :title) "")) + (region (or (plist-get parts :body) "")) + (orglink (if url + (org-make-link-string + url (if (string-match "[^[:space:]]" title) title url)) + title)) (org-capture-link-is-already-stored t)) ;; avoid call to org-store-link (setq org-stored-links (cons (list url title) org-stored-links)) @@ -443,24 +504,24 @@ Now template ?b will be used." :description title :annotation orglink :initial region - :query query) + :query parts) (raise-frame) (funcall 'org-capture nil template))) (defun org-protocol-open-source (fname) - "Process an org-protocol://open-source:// style url. + "Process an org-protocol://open-source?url= style URL with FNAME. Change a filename by mapping URLs to local filenames as set in `org-protocol-project-alist'. The location for a browser's bookmark should look like this: - javascript:location.href='org-protocol://open-source://'+ \\ + javascript:location.href = \\='org-protocol://open-source?url=\\=' + \\ encodeURIComponent(location.href)" ;; As we enter this function for a match on our protocol, the return value ;; defaults to nil. (let ((result nil) - (f (org-link-unescape fname))) + (f (plist-get (org-protocol-parse-parameters fname nil '(:url)) :url))) (catch 'result (dolist (prolist org-protocol-project-alist) (let* ((base-url (plist-get (cdr prolist) :base-url)) @@ -490,13 +551,12 @@ The location for a browser's bookmark should look like this: (let ((rewrites (plist-get (cdr prolist) :rewrites))) (when rewrites (message "Rewrites found: %S" rewrites) - (mapc - (lambda (rewrite) - "Try to match a rewritten URL and map it to a real file." - ;; Compare redirects without suffix: - (if (string-match (car rewrite) f2) - (throw 'result (concat wdir (cdr rewrite))))) - rewrites)))) + (dolist (rewrite rewrites) + ;; Try to match a rewritten URL and map it to + ;; a real file. Compare redirects without + ;; suffix. + (when (string-match-p (car rewrite) f2) + (throw 'result (concat wdir (cdr rewrite)))))))) ;; -- end of redirects -- (if (file-readable-p the-file) @@ -509,22 +569,30 @@ The location for a browser's bookmark should look like this: ;;; Core functions: -(defun org-protocol-check-filename-for-protocol (fname restoffiles client) - "Detect if `org-protocol-the-protocol' and a known sub-protocol is used in fname. +(defun org-protocol-check-filename-for-protocol (fname restoffiles _client) + "Check if `org-protocol-the-protocol' and a valid protocol are used in FNAME. Sub-protocols are registered in `org-protocol-protocol-alist' and -`org-protocol-protocol-alist-default'. -This is, how the matching is done: +`org-protocol-protocol-alist-default'. This is how the matching is done: - (string-match \"protocol:/+sub-protocol:/+\" ...) + (string-match \"protocol:/+sub-protocol\\\\(://\\\\|\\\\?\\\\)\" ...) protocol and sub-protocol are regexp-quoted. -If a matching protocol is found, the protocol is stripped from fname and the -result is passed to the protocols function as the only parameter. If the -function returns nil, the filename is removed from the list of filenames -passed from emacsclient to the server. -If the function returns a non nil value, that value is passed to the server -as filename." +Old-style links such as \"protocol://sub-protocol://param1/param2\" are +also recognized. + +If a matching protocol is found, the protocol is stripped from +fname and the result is passed to the protocol function as the +first parameter. The second parameter will be non-nil if FNAME +uses key=val&key2=val2-type arguments, or nil if FNAME uses +val/val2-type arguments. If the function returns nil, the +filename is removed from the list of filenames passed from +emacsclient to the server. If the function returns a non-nil +value, that value is passed to the server as filename. + +If the handler function is greedy, RESTOFFILES will also be passed to it. + +CLIENT is ignored." (let ((sub-protocols (append org-protocol-protocol-alist org-protocol-protocol-alist-default))) (catch 'fname @@ -532,21 +600,27 @@ as filename." (when (string-match the-protocol fname) (dolist (prolist sub-protocols) (let ((proto (concat the-protocol - (regexp-quote (plist-get (cdr prolist) :protocol)) ":/+"))) + (regexp-quote (plist-get (cdr prolist) :protocol)) "\\(:/+\\|\\?\\)"))) (when (string-match proto fname) (let* ((func (plist-get (cdr prolist) :function)) (greedy (plist-get (cdr prolist) :greedy)) (split (split-string fname proto)) - (result (if greedy restoffiles (cadr split)))) + (result (if greedy restoffiles (cadr split))) + (new-style (string= (match-string 1 fname) "?"))) (when (plist-get (cdr prolist) :kill-client) (message "Greedy org-protocol handler. Killing client.") (server-edit)) (when (fboundp func) (unless greedy - (throw 'fname (funcall func result))) - (funcall func result) + (throw 'fname + (condition-case nil + (funcall func (org-protocol-parse-parameters result new-style)) + (error + (warn "Please update your org protocol handler to deal with new-style links.") + (funcall func result))))) + ;; Greedy protocol handlers are responsible for parsing their own filenames + (funcall func result) (throw 'fname t)))))))) - ;; (message "fname: %s" fname) fname))) (defadvice server-visit-files (before org-protocol-detect-protocol-server activate) @@ -572,16 +646,18 @@ as filename." ;;; Org specific functions: (defun org-protocol-create-for-org () - "Create a org-protocol project for the current file's Org-mode project. + "Create a Org protocol project for the current file's project. 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) + (require 'ox-publish) (let ((all (or (org-publish-get-project-from-filename buffer-file-name)))) (if all (org-protocol-create (cdr all)) - (message "Not in an org-project. Did mean %s?" - (substitute-command-keys"\\[org-protocol-create]"))))) + (message "%s" + (substitute-command-keys + "Not in an Org project. \ +Did you mean `\\[org-protocol-create]'?"))))) (defun org-protocol-create (&optional project-plist) "Create a new org-protocol project interactively. @@ -600,19 +676,18 @@ the cdr of an element in `org-publish-project-alist', reuse (working-suffix (if (plist-get project-plist :base-extension) (concat "." (plist-get project-plist :base-extension)) ".org")) - (worglet-buffer nil) (insert-default-directory t) (minibuffer-allow-text-properties nil)) (setq base-url (read-string "Base URL of published content: " base-url nil base-url t)) - (if (not (string-match "\\/$" base-url)) - (setq base-url (concat base-url "/"))) + (or (string-suffix-p "/" base-url) + (setq base-url (concat base-url "/"))) (setq working-dir (expand-file-name (read-directory-name "Local working directory: " working-dir working-dir t))) - (if (not (string-match "\\/$" working-dir)) - (setq working-dir (concat working-dir "/"))) + (or (string-suffix-p "/" working-dir) + (setq working-dir (concat working-dir "/"))) (setq strip-suffix (read-string diff --git a/elpa/org-plus-contrib-20150831/org-registry.el b/elpa/org-plus-contrib-20170407/org-registry.el similarity index 100% rename from elpa/org-plus-contrib-20150831/org-registry.el rename to elpa/org-plus-contrib-20170407/org-registry.el diff --git a/elpa/org-plus-contrib-20150831/org-rmail.el b/elpa/org-plus-contrib-20170407/org-rmail.el similarity index 81% rename from elpa/org-plus-contrib-20150831/org-rmail.el rename to elpa/org-plus-contrib-20170407/org-rmail.el index af47e0f5..31c59a13 100644 --- a/elpa/org-plus-contrib-20150831/org-rmail.el +++ b/elpa/org-plus-contrib-20170407/org-rmail.el @@ -1,6 +1,6 @@ -;;; org-rmail.el --- Support for links to Rmail messages from within Org-mode +;;; org-rmail.el --- Support for Links to Rmail Messages -*- lexical-binding: t; -*- -;; Copyright (C) 2004-2015 Free Software Foundation, Inc. +;; Copyright (C) 2004-2017 Free Software Foundation, Inc. ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp @@ -24,9 +24,9 @@ ;; ;;; Commentary: -;; This file implements links to Rmail messages from within Org-mode. -;; Org-mode loads this module by default - if this is not what you want, -;; configure the variable `org-modules'. +;; This file implements links to Rmail 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: @@ -43,8 +43,7 @@ (defvar rmail-file-name) ; From rmail.el ;; Install the link type -(org-add-link-type "rmail" 'org-rmail-open) -(add-hook 'org-store-link-functions 'org-rmail-store-link) +(org-link-set-parameters "rmail" :follow #'org-rmail-open :store #'org-rmail-store-link) ;; Implementation (defun org-rmail-store-link () @@ -65,20 +64,11 @@ (to (mail-fetch-field "to")) (subject (mail-fetch-field "subject")) (date (mail-fetch-field "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)))) desc link) (org-store-link-props - :type "rmail" :from from :to to + :type "rmail" :from from :to to :date date :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 message-id (org-unbracket-string "<" ">" message-id)) (setq desc (org-email-link-description)) (setq link (concat "rmail:" folder "#" message-id)) (org-add-link-props :link link :description desc) diff --git a/elpa/org-plus-contrib-20150831/org-screen.el b/elpa/org-plus-contrib-20170407/org-screen.el similarity index 100% rename from elpa/org-plus-contrib-20150831/org-screen.el rename to elpa/org-plus-contrib-20170407/org-screen.el diff --git a/elpa/org-plus-contrib-20150831/org-screenshot.el b/elpa/org-plus-contrib-20170407/org-screenshot.el similarity index 98% rename from elpa/org-plus-contrib-20150831/org-screenshot.el rename to elpa/org-plus-contrib-20170407/org-screenshot.el index 6d107837..1cf69116 100644 --- a/elpa/org-plus-contrib-20150831/org-screenshot.el +++ b/elpa/org-plus-contrib-20170407/org-screenshot.el @@ -1,7 +1,6 @@ ;;; org-screenshot.el --- Take and manage screenshots in Org-mode files ;; -;; Copyright (C) 2009-2014 -;; Free Software Foundation, Inc. +;; Copyright (C) 2009-2017 Free Software Foundation, Inc. ;; ;; Author: Max Mikhanosha ;; Keywords: outlines, hypermedia, calendar, wp @@ -339,8 +338,8 @@ by most recent first" org-screenshot-rotation-index -1 org-screenshot-file-list (let ((files (directory-files org-screenshot-image-directory - t (org-image-file-name-regexp) t))) - (mapcar 'file-name-nondirectory + t (image-file-name-regexp) t))) + (mapcar 'file-name-nondirectory (sort files (lambda (file1 file2) (let ((mtime1 (nth 5 (file-attributes file1))) @@ -365,7 +364,7 @@ other direction" (link-re ;; taken from `org-display-inline-images' (concat "\\[\\[\\(\\(file:\\)\\|\\([./~]\\)\\)\\([^]\n]+?" - (substring (org-image-file-name-regexp) 0 -2) + (substring (image-file-name-regexp) 0 -2) "\\)\\]")) newfile oldfile) (save-excursion @@ -497,7 +496,7 @@ entered, at which point event will be unread" (let ((files-in-buffer) dired-buffer had-any - (image-re (org-image-file-name-regexp)) + (image-re (image-file-name-regexp)) beg end) (save-excursion (save-restriction @@ -505,7 +504,7 @@ entered, at which point event will be unread" (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) + (substring (image-file-name-regexp) 0 -2) "\\)\\]")) (case-fold-search t) old file ov img type attrwidth width) diff --git a/elpa/org-plus-contrib-20150831/org-secretary.el b/elpa/org-plus-contrib-20170407/org-secretary.el similarity index 100% rename from elpa/org-plus-contrib-20150831/org-secretary.el rename to elpa/org-plus-contrib-20170407/org-secretary.el diff --git a/elpa/org-plus-contrib-20150831/org-src.el b/elpa/org-plus-contrib-20170407/org-src.el similarity index 78% rename from elpa/org-plus-contrib-20150831/org-src.el rename to elpa/org-plus-contrib-20170407/org-src.el index 163d7268..b0f952fa 100644 --- a/elpa/org-plus-contrib-20150831/org-src.el +++ b/elpa/org-plus-contrib-20170407/org-src.el @@ -1,6 +1,6 @@ -;;; org-src.el --- Source code examples in Org +;;; org-src.el --- Source code examples in Org -*- lexical-binding: t; -*- ;; -;; Copyright (C) 2004-2015 Free Software Foundation, Inc. +;; Copyright (C) 2004-2017 Free Software Foundation, Inc. ;; ;; Author: Carsten Dominik ;; Bastien Guerry @@ -26,19 +26,21 @@ ;; ;;; Commentary: -;; This file contains the code dealing with source code examples in Org-mode. +;; This file contains the code dealing with source code examples in +;; Org mode. ;;; Code: +(require 'cl-lib) (require 'org-macs) (require 'org-compat) (require 'ob-keys) (require 'ob-comint) -(eval-when-compile (require 'cl)) (declare-function org-base-buffer "org" (buffer)) (declare-function org-do-remove-indentation "org" (&optional n)) (declare-function org-element-at-point "org-element" ()) +(declare-function org-element-class "org-element" (datum &optional parent)) (declare-function org-element-context "org-element" (&optional element)) (declare-function org-element-lineage "org-element" (blob &optional types with-self)) @@ -47,13 +49,10 @@ (declare-function org-footnote-goto-definition "org-footnote" (label &optional location)) (declare-function org-get-indentation "org" (&optional line)) -(declare-function org-pop-to-buffer-same-window "org-compat" - (&optional buffer-or-name norecord label)) -(declare-function org-some "org" (pred seq)) (declare-function org-switch-to-buffer-other-window "org" (&rest args)) -(declare-function org-trim "org" (s)) +(declare-function org-trim "org" (s &optional keep-lead)) -(defvar org-element-all-elements) +(defvar org-inhibit-startup) (defcustom org-edit-src-turn-on-auto-save nil "Non-nil means turn `auto-save-mode' on when editing a source block. @@ -108,11 +107,12 @@ These are the regions where each line starts with a colon." (defcustom org-src-preserve-indentation nil "If non-nil preserve leading whitespace characters on export. +\\ If non-nil leading whitespace characters in source code blocks are preserved on export, and when switching between the org buffer and the language mode edit buffer. -When this variable is nil, after editing with \\[org-edit-src-code], +When this variable is nil, after editing with `\\[org-edit-src-code]', the minimum (across-lines) number of leading whitespace characters are removed from all lines, and the code block is uniformly indented according to the value of `org-edit-src-content-indentation'." @@ -121,10 +121,12 @@ according to the value of `org-edit-src-content-indentation'." (defcustom org-edit-src-content-indentation 2 "Indentation for the content of a source code block. + This should be the number of spaces added to the indentation of the #+begin line in order to compute the indentation of the block content after -editing it with \\[org-edit-src-code]. Has no effect if -`org-src-preserve-indentation' is non-nil." +editing it with `\\[org-edit-src-code]'. + +It has no effect if `org-src-preserve-indentation' is non-nil." :group 'org-edit-structure :type 'integer) @@ -169,7 +171,7 @@ other-frame Use `switch-to-buffer-other-frame' to display edit buffer. "Hook run after Org switched a source code snippet to its Emacs mode. \\ This hook will run: -- when editing a source code snippet with \\[org-edit-special] +- when editing a source code snippet with `\\[org-edit-special]' - when formatting a source code snippet for export with htmlize. You may want to use this hook for example to turn off `outline-minor-mode' @@ -194,6 +196,28 @@ For example, there is no ocaml-mode in Emacs, but the mode to use is (string "Language name") (symbol "Major mode")))) +(defcustom org-src-block-faces nil + "Alist of faces to be used for source-block. +Each element is a cell of the format + + (\"language\" FACE) + +Where FACE is either a defined face or an anonymous face. + +For instance, the following value would color the background of +emacs-lisp source blocks and python source blocks in purple and +green, respectability. + + \\='((\"emacs-lisp\" (:background \"#EEE2FF\")) + (\"python\" (:background \"#e5ffb8\")))" + :group 'org-edit-structure + :type '(repeat (list (string :tag "language") + (choice + (face :tag "Face") + (sexp :tag "Anonymous face")))) + :version "26.1" + :package-version '(Org . "9.0")) + (defcustom org-src-tab-acts-natively nil "If non-nil, the effect of TAB in a code block is as if it were issued in the language major mode buffer." @@ -291,6 +315,12 @@ where BEG and END are buffer positions and CONTENTS is a string." (search-forward "]"))) (end (or (org-element-property :contents-end datum) beg))) (list beg end (buffer-substring-no-properties beg end)))) + ((eq type 'inline-src-block) + (let ((beg (progn (goto-char (org-element-property :begin datum)) + (search-forward "{" (line-end-position) t))) + (end (progn (goto-char (org-element-property :end datum)) + (search-backward "}" (line-beginning-position) t)))) + (list beg end (buffer-substring-no-properties beg end)))) ((org-element-property :contents-begin datum) (let ((beg (org-element-property :contents-begin datum)) (end (org-element-property :contents-end datum))) @@ -302,7 +332,7 @@ where BEG and END are buffer positions and CONTENTS is a string." (skip-chars-backward " \r\t\n") (line-beginning-position 1)) (org-element-property :value datum))) - ((memq type '(fixed-width table)) + ((memq type '(fixed-width latex-environment table)) (let ((beg (org-element-property :post-affiliated datum)) (end (progn (goto-char (org-element-property :end datum)) (skip-chars-backward " \r\t\n") @@ -350,7 +380,7 @@ spaces after it as being outside." (org-with-wide-buffer (goto-char (org-element-property :end datum)) (skip-chars-backward " \r\t\n") - (if (memq (org-element-type datum) org-element-all-elements) + (if (eq (org-element-class datum) 'element) (line-end-position) (point)))))) @@ -369,7 +399,7 @@ Assume point is in the corresponding edit buffer." (let ((ind (make-string indentation ?\s))) (goto-char (point-min)) (while (not (eobp)) - (when (org-looking-at-p "[ \t]*\\S-") (insert ind)) + (when (looking-at-p "[ \t]*\\S-") (insert ind)) (forward-line)))) (buffer-string)))) @@ -447,14 +477,14 @@ Leave point in edit buffer." ;; Transmit buffer-local variables for exit function. It must ;; be done after initializing major mode, as this operation ;; may reset them otherwise. - (org-set-local 'org-src--from-org-mode org-mode-p) - (org-set-local 'org-src--beg-marker beg) - (org-set-local 'org-src--end-marker end) - (org-set-local 'org-src--remote remote) - (org-set-local 'org-src--block-indentation ind) - (org-set-local 'org-src--preserve-indentation preserve-ind) - (org-set-local 'org-src--overlay overlay) - (org-set-local 'org-src--allow-write-back write-back) + (setq-local org-src--from-org-mode org-mode-p) + (setq-local org-src--beg-marker beg) + (setq-local org-src--end-marker end) + (setq-local org-src--remote remote) + (setq-local org-src--block-indentation ind) + (setq-local org-src--preserve-indentation preserve-ind) + (setq-local org-src--overlay overlay) + (setq-local org-src--allow-write-back write-back) ;; Start minor mode. (org-src-mode) ;; Move mark and point in edit buffer to the corresponding @@ -487,29 +517,37 @@ as `org-src-fontify-natively' is non-nil." (when (fboundp lang-mode) (let ((string (buffer-substring-no-properties start end)) (modified (buffer-modified-p)) - (org-buffer (current-buffer)) pos next) + (org-buffer (current-buffer))) (remove-text-properties start end '(face nil)) (with-current-buffer (get-buffer-create - (concat " org-src-fontification:" (symbol-name lang-mode))) - (delete-region (point-min) (point-max)) - (insert string " ") ;; so there's a final property change + (format " *org-src-fontification:%s*" lang-mode)) + (let ((inhibit-modification-hooks nil)) + (erase-buffer) + ;; Add string and a final space to ensure property change. + (insert string " ")) (unless (eq major-mode lang-mode) (funcall lang-mode)) - ;; Avoid `font-lock-ensure', which does not display fonts in - ;; source block. - (font-lock-fontify-buffer) - (setq pos (point-min)) - (while (setq next (next-single-property-change pos 'face)) - (put-text-property - (+ start (1- pos)) (1- (+ start next)) 'face - (get-text-property pos 'face) org-buffer) - (setq pos next))) + (org-font-lock-ensure) + (let ((pos (point-min)) next) + (while (setq next (next-property-change pos)) + ;; Handle additional properties from font-lock, so as to + ;; preserve, e.g., composition. + (dolist (prop (cons 'face font-lock-extra-managed-props)) + (let ((new-prop (get-text-property pos prop))) + (put-text-property + (+ start (1- pos)) (1- (+ start next)) prop new-prop + org-buffer))) + (setq pos next)))) + ;; Add Org faces. + (let ((src-face (nth 1 (assoc-string lang org-src-block-faces t)))) + (when (or (facep src-face) (listp src-face)) + (font-lock-append-text-property start end 'face src-face)) + (font-lock-append-text-property start end 'face 'org-block)) (add-text-properties start end '(font-lock-fontified t fontified t font-lock-multiline t)) (set-buffer-modified-p modified))))) - ;;; Escape contents @@ -561,7 +599,7 @@ with \",*\", \",#+\", \",,*\" and \",,#+\"." "Minor mode for language major mode buffers generated by Org. \\ This minor mode is turned on in two situations: - - when editing a source code snippet with \\[org-edit-special] + - when editing a source code snippet with `\\[org-edit-special]' - when formatting a source code snippet for export with htmlize. \\{org-src-mode-map} @@ -569,14 +607,14 @@ This minor mode is turned on in two situations: See also `org-src-mode-hook'." nil " OrgSrc" nil (when org-edit-src-persistent-message - (org-set-local - 'header-line-format + (setq-local + header-line-format (substitute-command-keys (if org-src--allow-write-back - "Edit, then exit with \\[org-edit-src-exit] or abort with \ -\\[org-edit-src-abort]" - "Exit with \\[org-edit-src-exit] or abort with \ -\\[org-edit-src-abort]")))) + "Edit, then exit with `\\[org-edit-src-exit]' or abort with \ +`\\[org-edit-src-abort]'" + "Exit with `\\[org-edit-src-exit]' or abort with \ +`\\[org-edit-src-abort]'")))) ;; Possibly activate various auto-save features (for the edit buffer ;; or the source buffer). (when org-edit-src-turn-on-auto-save @@ -601,22 +639,18 @@ See also `org-src-mode-hook'." (setq org-src--auto-save-timer nil))))))))) (defun org-src-mode-configure-edit-buffer () - (when (org-bound-and-true-p org-src--from-org-mode) - (org-add-hook 'kill-buffer-hook #'org-src--remove-overlay nil 'local) - (if (org-bound-and-true-p org-src--allow-write-back) + (when (bound-and-true-p org-src--from-org-mode) + (add-hook 'kill-buffer-hook #'org-src--remove-overlay nil 'local) + (if (bound-and-true-p org-src--allow-write-back) (progn (setq buffer-offer-save t) (setq buffer-file-name (concat (buffer-file-name (marker-buffer org-src--beg-marker)) "[" (buffer-name) "]")) - (if (featurep 'xemacs) - (progn - (make-variable-buffer-local 'write-contents-hooks) ; needed only for 21.4 - (setq write-contents-hooks '(org-edit-src-save))) - (setq write-contents-functions '(org-edit-src-save)))) + (setq-local write-contents-functions '(org-edit-src-save))) (setq buffer-read-only t)))) -(org-add-hook 'org-src-mode-hook #'org-src-mode-configure-edit-buffer) +(add-hook 'org-src-mode-hook #'org-src-mode-configure-edit-buffer) @@ -625,7 +659,7 @@ See also `org-src-mode-hook'." (defun org-src-associate-babel-session (info) "Associate edit buffer with comint session." (interactive) - (let ((session (cdr (assoc :session (nth 2 info))))) + (let ((session (cdr (assq :session (nth 2 info))))) (and session (not (string= session "none")) (org-babel-comint-buffer-livep session) (let ((f (intern (format "org-babel-%s-associate-session" @@ -636,16 +670,19 @@ See also `org-src-mode-hook'." (when org-src--babel-info (org-src-associate-babel-session org-src--babel-info))) -(org-add-hook 'org-src-mode-hook #'org-src-babel-configure-edit-buffer) +(add-hook 'org-src-mode-hook #'org-src-babel-configure-edit-buffer) + + +;;; Public API (defmacro org-src-do-at-code-block (&rest body) - "Execute a command from an edit buffer in the Org mode buffer." + "Execute BODY from an edit buffer in the Org mode buffer." + (declare (debug (body))) `(let ((beg-marker org-src--beg-marker)) (when beg-marker (with-current-buffer (marker-buffer beg-marker) (goto-char beg-marker) ,@body)))) -(def-edebug-spec org-src-do-at-code-block (body)) (defun org-src-do-key-sequence-at-code-block (&optional key) "Execute key sequence at code block in the source Org buffer. @@ -657,9 +694,9 @@ This command is not bound to a key by default, to avoid conflicts with language major mode bindings. To bind it to C-c @ in all language major modes, you could use - (add-hook 'org-src-mode-hook + (add-hook \\='org-src-mode-hook (lambda () (define-key org-src-mode-map \"\\C-c@\" - 'org-src-do-key-sequence-at-code-block))) + \\='org-src-do-key-sequence-at-code-block))) In that case, for example, C-c @ t issued in code edit buffers would tangle the current Org code block, C-c @ e would execute @@ -671,10 +708,6 @@ Org-babel commands." (org-src-do-at-code-block (call-interactively (lookup-key org-babel-map key))))) - - -;;; Public functions - (defun org-src-edit-buffer-p (&optional buffer) "Non-nil when current buffer is a source editing buffer. If BUFFER is non-nil, test it instead." @@ -684,29 +717,62 @@ If BUFFER is non-nil, test it instead." (local-variable-p 'org-src--end-marker buffer)))) (defun org-src-switch-to-buffer (buffer context) - (case org-src-window-setup - (current-window (org-pop-to-buffer-same-window buffer)) - (other-window + (pcase org-src-window-setup + (`current-window (pop-to-buffer-same-window buffer)) + (`other-window (switch-to-buffer-other-window buffer)) - (other-frame - (case context - (exit + (`other-frame + (pcase context + (`exit (let ((frame (selected-frame))) (switch-to-buffer-other-frame buffer) (delete-frame frame))) - (save + (`save (kill-buffer (current-buffer)) - (org-pop-to-buffer-same-window buffer)) - (t (switch-to-buffer-other-frame buffer)))) - (reorganize-frame + (pop-to-buffer-same-window buffer)) + (_ (switch-to-buffer-other-frame buffer)))) + (`reorganize-frame (when (eq context 'edit) (delete-other-windows)) (org-switch-to-buffer-other-window buffer) (when (eq context 'exit) (delete-other-windows))) - (switch-invisibly (set-buffer buffer)) - (t + (`switch-invisibly (set-buffer buffer)) + (_ (message "Invalid value %s for `org-src-window-setup'" org-src-window-setup) - (org-pop-to-buffer-same-window buffer)))) + (pop-to-buffer-same-window buffer)))) + +(defun org-src-coderef-format (&optional element) + "Return format string for block at point. + +When optional argument ELEMENT is provided, use that block. +Otherwise, assume point is either at a source block, at an +example block. + +If point is in an edit buffer, retrieve format string associated +to the remote source block." + (cond + ((and element (org-element-property :label-fmt element))) + ((org-src-edit-buffer-p) (org-src-do-at-code-block (org-src-coderef-format))) + ((org-element-property :label-fmt (org-element-at-point))) + (t org-coderef-label-format))) + +(defun org-src-coderef-regexp (fmt &optional label) + "Return regexp matching a coderef format string FMT. + +When optional argument LABEL is non-nil, match coderef for that +label only. + +Match group 1 contains the full coderef string with surrounding +white spaces. Match group 2 contains the same string without any +surrounding space. Match group 3 contains the label. + +A coderef format regexp can only match at the end of a line." + (format "\\([ \t]*\\(%s\\)[ \t]*\\)$" + (replace-regexp-in-string + "%s" + (if label (regexp-quote label) "\\([-a-zA-Z0-9_][-a-zA-Z0-9_ ]*\\)") + (regexp-quote fmt) + nil t))) (defun org-edit-footnote-reference () "Edit definition of footnote reference at point." @@ -766,11 +832,12 @@ If BUFFER is non-nil, test it instead." (defun org-edit-table.el () "Edit \"table.el\" table at point. - +\\ A new buffer is created and the table is copied into it. Then the table is recognized with `table-recognize'. When done -editing, exit with \\[org-edit-src-exit]. The edited text will -then replace the area in the Org mode buffer. +editing, exit with `\\[org-edit-src-exit]'. The edited text will \ +then replace +the area in the Org mode buffer. Throw an error when not at such a table." (interactive) @@ -783,18 +850,42 @@ Throw an error when not at such a table." element (org-src--construct-edit-buffer-name (buffer-name) "Table") #'text-mode t) - (when (org-bound-and-true-p flyspell-mode) (flyspell-mode -1)) + (when (bound-and-true-p flyspell-mode) (flyspell-mode -1)) (table-recognize) t)) +(defun org-edit-latex-environment () + "Edit LaTeX environment at point. +\\ +The LaTeX environment is copied into a new buffer. Major mode is +set to the one associated to \"latex\" in `org-src-lang-modes', +or to `latex-mode' if there is none. + +When done, exit with `\\[org-edit-src-exit]'. The edited text \ +will then replace +the LaTeX environment in the Org mode buffer." + (interactive) + (let ((element (org-element-at-point))) + (unless (and (eq (org-element-type element) 'latex-environment) + (org-src--on-datum-p element)) + (user-error "Not in a LaTeX environment")) + (org-src--edit-element + element + (org-src--construct-edit-buffer-name (buffer-name) "LaTeX environment") + (org-src--get-lang-mode "latex") + t) + t)) + (defun org-edit-export-block () "Edit export block at point. - +\\ A new buffer is created and the block is copied into it, and the buffer is switched into an appropriate major mode. See also -`org-src-lang-modes'. When done, exit with -\\[org-edit-src-exit]. The edited text will then replace the -area in the Org mode buffer. +`org-src-lang-modes'. + +When done, exit with `\\[org-edit-src-exit]'. The edited text \ +will then replace +the area in the Org mode buffer. Throw an error when not at an export block." (interactive) @@ -816,7 +907,7 @@ Throw an error when not at an export block." "Edit the source or example block at point. \\ The code is copied to a separate buffer and the appropriate mode -is turned on. When done, exit with \\[org-edit-src-exit]. This \ +is turned on. When done, exit with `\\[org-edit-src-exit]'. This \ will remove the original code in the Org buffer, and replace it with the edited version. See `org-src-window-setup' to configure the display of @@ -851,36 +942,71 @@ name of the sub-editing buffer." `(lambda () (unless ,(or org-src-preserve-indentation (org-element-property :preserve-indent element)) - (untabify (point-min) (point-max)) (when (> org-edit-src-content-indentation 0) - (let ((ind (make-string org-edit-src-content-indentation - ?\s))) - (while (not (eobp)) - (unless (looking-at "[ \t]*$") (insert ind)) - (forward-line))))) + (while (not (eobp)) + (unless (looking-at "[ \t]*$") + (indent-line-to (+ (org-get-indentation) + org-edit-src-content-indentation))) + (forward-line)))) (org-escape-code-in-region (point-min) (point-max)))) (and code (org-unescape-code-in-string code))) ;; Finalize buffer. - (org-set-local 'org-coderef-label-format - (or (org-element-property :label-fmt element) - org-coderef-label-format)) + (setq-local org-coderef-label-format + (or (org-element-property :label-fmt element) + org-coderef-label-format)) (when (eq type 'src-block) - (org-set-local 'org-src--babel-info babel-info) + (setq-local org-src--babel-info babel-info) (let ((edit-prep-func (intern (concat "org-babel-edit-prep:" lang)))) (when (fboundp edit-prep-func) (funcall edit-prep-func babel-info)))) t))) +(defun org-edit-inline-src-code () + "Edit inline source code at point." + (interactive) + (let ((context (org-element-context))) + (unless (and (eq (org-element-type context) 'inline-src-block) + (org-src--on-datum-p context)) + (user-error "Not on inline source code")) + (let* ((lang (org-element-property :language context)) + (lang-f (org-src--get-lang-mode lang)) + (babel-info (org-babel-get-src-block-info 'light)) + deactivate-mark) + (unless (functionp lang-f) (error "No such language mode: %s" lang-f)) + (org-src--edit-element + context + (org-src--construct-edit-buffer-name (buffer-name) lang) + lang-f + (lambda () + ;; Inline src blocks are limited to one line. + (while (re-search-forward "\n[ \t]*" nil t) (replace-match " ")) + ;; Trim contents. + (goto-char (point-min)) + (skip-chars-forward " \t") + (delete-region (point-min) (point)) + (goto-char (point-max)) + (skip-chars-backward " \t") + (delete-region (point) (point-max)))) + ;; Finalize buffer. + (setq-local org-src--babel-info babel-info) + (setq-local org-src--preserve-indentation t) + (let ((edit-prep-func (intern (concat "org-babel-edit-prep:" lang)))) + (when (fboundp edit-prep-func) (funcall edit-prep-func babel-info))) + ;; Return success. + t))) + (defun org-edit-fixed-width-region () "Edit the fixed-width ASCII drawing at point. - +\\ This must be a region where each line starts with a colon followed by a space or a newline character. A new buffer is created and the fixed-width region is copied into it, and the buffer is switched into the major mode defined in -`org-edit-fixed-width-region-mode', which see. When done, exit -with \\[org-edit-src-exit]. The edited text will then replace +`org-edit-fixed-width-region-mode', which see. + +When done, exit with `\\[org-edit-src-exit]'. The edited text \ +will then replace the area in the Org mode buffer." (interactive) (let ((element (org-element-at-point))) @@ -929,7 +1055,10 @@ Throw an error if there is no such buffer." (insert edited-code) (when (and expecting-bol (not (bolp))) (insert "\n"))) (save-buffer) - (move-overlay overlay beg (point))))) + (move-overlay overlay beg (point)))) + ;; `write-contents-functions' requires the function to return + ;; a non-nil value so that other functions are not called. + t) (defun org-edit-src-exit () "Kill current sub-editing buffer and return to source buffer." @@ -963,7 +1092,7 @@ Throw an error if there is no such buffer." (goto-char beg) (cond ;; Block is hidden; move at start of block. - ((org-some (lambda (o) (eq (overlay-get o 'invisible) 'org-hide-block)) + ((cl-some (lambda (o) (eq (overlay-get o 'invisible) 'org-hide-block)) (overlays-at (point))) (beginning-of-line 0)) (write-back (org-src--goto-coordinates coordinates beg end)))) diff --git a/elpa/org-plus-contrib-20150831/org-static-mathjax.el b/elpa/org-plus-contrib-20170407/org-static-mathjax.el similarity index 100% rename from elpa/org-plus-contrib-20150831/org-static-mathjax.el rename to elpa/org-plus-contrib-20170407/org-static-mathjax.el diff --git a/elpa/org-plus-contrib-20150831/org-sudoku.el b/elpa/org-plus-contrib-20170407/org-sudoku.el similarity index 99% rename from elpa/org-plus-contrib-20150831/org-sudoku.el rename to elpa/org-plus-contrib-20170407/org-sudoku.el index 4b4a3ac5..baa9fcdf 100644 --- a/elpa/org-plus-contrib-20150831/org-sudoku.el +++ b/elpa/org-plus-contrib-20170407/org-sudoku.el @@ -1,6 +1,6 @@ ;;; org-sudoku.el --- Greate and solve SUDOKU games in Org tables -;; Copyright (C) 2012, 2013, 2014 Free Software Foundation, Inc. +;; Copyright (C) 2012-2017 Free Software Foundation, Inc. ;; ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp, games diff --git a/elpa/org-plus-contrib-20150831/org-table.el b/elpa/org-plus-contrib-20170407/org-table.el similarity index 84% rename from elpa/org-plus-contrib-20150831/org-table.el rename to elpa/org-plus-contrib-20170407/org-table.el index b6d59f1b..488762f1 100644 --- a/elpa/org-plus-contrib-20150831/org-table.el +++ b/elpa/org-plus-contrib-20170407/org-table.el @@ -1,6 +1,6 @@ -;;; org-table.el --- The table editor for Org mode +;;; org-table.el --- The Table Editor for Org -*- lexical-binding: t; -*- -;; Copyright (C) 2004-2015 Free Software Foundation, Inc. +;; Copyright (C) 2004-2017 Free Software Foundation, Inc. ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp @@ -34,8 +34,7 @@ ;;; Code: -(eval-when-compile - (require 'cl)) +(require 'cl-lib) (require 'org) (declare-function org-element-at-point "org-element" ()) @@ -47,19 +46,32 @@ (declare-function org-element-map "org-element" (data types fun &optional info first-match no-recursion with-affiliated)) +(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-type "org-element" (element)) -(declare-function org-export-string-as "ox" - (string backend &optional body-only ext-plist)) -(declare-function org-export-create-backend "ox") +(declare-function org-export-create-backend "ox" (&rest rest) t) +(declare-function org-export-data-with-backend "ox" (data backend info)) +(declare-function org-export-filter-apply-functions "ox" + (filters value info)) +(declare-function org-export-first-sibling-p "ox" (blob info)) (declare-function org-export-get-backend "ox" (name)) +(declare-function org-export-get-environment "ox" + (&optional backend subtreep ext-plist)) +(declare-function org-export-install-filters "ox" (info)) +(declare-function org-export-table-has-special-column-p "ox" (table)) +(declare-function org-export-table-row-is-special-p "ox" (table-row info)) (declare-function calc-eval "calc" (str &optional separator &rest args)) -(defvar orgtbl-mode) ; defined below -(defvar orgtbl-mode-menu) ; defined when orgtbl mode get initialized (defvar constants-unit-system) +(defvar org-element-use-cache) +(defvar org-export-filters-alist) (defvar org-table-follow-field-mode) +(defvar orgtbl-mode) ; defined below +(defvar orgtbl-mode-menu) ; defined when orgtbl mode get initialized +(defvar sort-fold-case) (defvar orgtbl-after-send-table-hook nil "Hook for functions attaching to `C-c C-c', if the table is sent. @@ -78,7 +90,7 @@ for empty fields). Outside tables, the correct binding of the keys is restored. The default for this option is t if the optimized version is also used in -Org-mode. See the variable `org-enable-table-editor' for details. Changing +Org mode. See the variable `org-enable-table-editor' for details. Changing this variable requires a restart of Emacs to become effective." :group 'org-table :type 'boolean) @@ -133,7 +145,7 @@ table, obtained by prompting the user." (string :tag "Format")))) (defgroup org-table-settings nil - "Settings for tables in Org-mode." + "Settings for tables in Org mode." :tag "Org Table Settings" :group 'org-table) @@ -182,13 +194,13 @@ alignment to the right border applies." :type 'number) (defgroup org-table-editing nil - "Behavior of tables during editing in Org-mode." + "Behavior of tables during editing in Org mode." :tag "Org Table Editing" :group 'org-table) (defcustom org-table-automatic-realign t "Non-nil means automatically re-align table when pressing TAB or RETURN. -When nil, aligning is only done with \\[org-table-align], or after column +When nil, aligning is only done with `\\[org-table-align]', or after column removal/insertion." :group 'org-table-editing :type 'boolean) @@ -234,12 +246,12 @@ this line." :type 'boolean) (defgroup org-table-calculation nil - "Options concerning tables in Org-mode." + "Options concerning tables in Org mode." :tag "Org Table Calculation" :group 'org-table) (defcustom org-table-use-standard-references 'from - "Should org-mode work with table references like B3 instead of @3$2? + "Non-nil means using table references like B3 instead of @3$2. Possible values are: nil never use them from accept as input, do not present for editing @@ -251,9 +263,10 @@ t accept as input and present for editing" (const :tag "Convert user input, don't offer during editing" from))) (defcustom org-table-copy-increment t - "Non-nil means increment when copying current field with \\[org-table-copy-down]." + "Non-nil means increment when copying current field with \ +`\\[org-table-copy-down]'." :group 'org-table-calculation - :version "25.1" + :version "26.1" :package-version '(Org . "8.3") :type '(choice (const :tag "Use the difference between the current and the above fields" t) @@ -271,16 +284,16 @@ t accept as input and present for editing" ) "List with Calc mode settings for use in `calc-eval' for table formulas. The list must contain alternating symbols (Calc modes variables and values). -Don't remove any of the default settings, just change the values. Org-mode +Don't remove any of the default settings, just change the values. Org mode relies on the variables to be present in the list." :group 'org-table-calculation :type 'plist) (defcustom org-table-duration-custom-format 'hours "Format for the output of calc computations like $1+$2;t. -The default value is 'hours, and will output the results as a -number of hours. Other allowed values are 'seconds, 'minutes and -'days, and the output will be a fraction of seconds, minutes or +The default value is `hours', and will output the results as a +number of hours. Other allowed values are `seconds', `minutes' and +`days', and the output will be a fraction of seconds, minutes or days." :group 'org-table-calculation :version "24.1" @@ -305,7 +318,7 @@ which should be evaluated as described in the manual and in the documentation string of the command `org-table-eval-formula'. This feature requires the Emacs calc package. When this variable is nil, formula calculation is only available through -the command \\[org-table-eval-formula]." +the command `\\[org-table-eval-formula]'." :group 'org-table-calculation :type 'boolean) @@ -323,7 +336,7 @@ The car of each element is a name of a constant, without the `$' before it. The cdr is the value as a string. For example, if you'd like to use the speed of light in a formula, you would configure - (setq org-table-formula-constants '((\"c\" . \"299792458.\"))) + (setq org-table-formula-constants \\='((\"c\" . \"299792458.\"))) and then use it in an equation like `$1*$c'. @@ -337,7 +350,9 @@ Constants can also be defined on a per-file basis using a line like (defcustom org-table-allow-automatic-line-recalculation t "Non-nil means lines marked with |#| or |*| will be recomputed automatically. -Automatically means when TAB or RET or C-c C-c are pressed in the line." +\\\ +Automatically means when `TAB' or `RET' or `\\[org-ctrl-c-ctrl-c]' \ +are pressed in the line." :group 'org-table-calculation :type 'boolean) @@ -364,7 +379,7 @@ portability of tables." "Non-nil means that evaluation of a field formula can add new columns if an out-of-bounds field is being set." :group 'org-table-calculation - :version "25.1" + :version "26.1" :package-version '(Org . "8.3") :type '(choice (const :tag "Setting an out-of-bounds field generates an error (default)" nil) @@ -373,7 +388,7 @@ columns if an out-of-bounds field is being set." (const :tag "When setting an out-of-bounds field, the user is prompted" prompt))) (defgroup org-table-import-export nil - "Options concerning table import and export in Org-mode." + "Options concerning table import and export in Org mode." :tag "Org Table Import Export" :group 'org-table) @@ -393,7 +408,7 @@ The function can be slow on larger regions; this safety feature prevents it from hanging emacs." :group 'org-table-import-export :type 'integer - :version "25.1" + :version "26.1" :package-version '(Org . "8.3")) (defconst org-table-auto-recalculate-regexp "^[ \t]*| *# *\\(|\\|$\\)" @@ -486,13 +501,13 @@ Field is restored even in case of abnormal exit." ;;;###autoload (defun org-table-create-with-table.el () "Use the table.el package to insert a new table. -If there is already a table at point, convert between Org-mode tables +If there is already a table at point, convert between Org tables and table.el tables." (interactive) (require 'table) (cond ((org-at-table.el-p) - (if (y-or-n-p "Convert table to Org-mode table? ") + (if (y-or-n-p "Convert table to Org table? ") (org-table-convert))) ((org-at-table-p) (when (y-or-n-p "Convert table to table.el table? ") @@ -536,7 +551,7 @@ SIZE is a string Columns x Rows like for example \"3x2\"." (beginning-of-line 1) (newline)) ;; (mapcar (lambda (x) (insert line)) (make-list rows t)) - (dotimes (i rows) (insert line)) + (dotimes (_ rows) (insert line)) (goto-char pos) (if (> rows 1) ;; Insert a hline after the first row. @@ -549,16 +564,17 @@ SIZE is a string Columns x Rows like for example \"3x2\"." ;;;###autoload (defun org-table-convert-region (beg0 end0 &optional separator) "Convert region to a table. + The region goes from BEG0 to END0, but these borders will be moved slightly, to make sure a beginning of line in the first line is included. SEPARATOR specifies the field separator in the lines. It can have the following values: -'(4) Use the comma as a field separator -'(16) Use a TAB as field separator -'(64) Prompt for a regular expression as field separator -integer When a number, use that many spaces as field separator +(4) Use the comma as a field separator +(16) Use a TAB as field separator +(64) Prompt for a regular expression as field separator +integer When a number, use that many spaces, or a TAB, as field separator regexp When a regular expression, use it to match the separator nil When nil, the command tries to be smart and figure out the separator in the following way: @@ -657,7 +673,7 @@ extension of the given file name, and finally on the variable (when (file-directory-p file) (user-error "This is a directory path, not a file")) (when (and (buffer-file-name (buffer-base-buffer)) - (org-file-equal-p + (file-equal-p (file-truename file) (file-truename (buffer-file-name (buffer-base-buffer))))) (user-error "Please specify a file name that is different from current")) @@ -676,7 +692,7 @@ extension of the given file name, and finally on the variable (or (car (delq nil (mapcar (lambda (f) - (and (org-string-match-p fileext f) f)) + (and (string-match-p fileext f) f)) formats))) org-table-export-default-format) t t) t t))) @@ -715,13 +731,11 @@ This is being used to correctly align a single field after TAB or RET.") (defvar org-table-last-column-widths nil "List of max width of fields in each column. This is being used to correctly align a single field after TAB or RET.") -(defvar org-table-formula-debug nil +(defvar-local org-table-formula-debug nil "Non-nil means debug table formulas. When nil, simply write \"#ERROR\" in corrupted fields.") -(make-variable-buffer-local 'org-table-formula-debug) -(defvar org-table-overlay-coordinates nil +(defvar-local org-table-overlay-coordinates nil "Overlay coordinates after each align of a table.") -(make-variable-buffer-local 'org-table-overlay-coordinates) (defvar org-last-recalc-line nil) (defvar org-table-do-narrow t) ; for dynamic scoping @@ -745,7 +759,7 @@ When nil, simply write \"#ERROR\" in corrupted fields.") ;; Table's rows. Separators are replaced by nil. Trailing ;; spaces are also removed. (lines (mapcar (lambda (l) - (and (not (org-string-match-p "\\`[ \t]*|-" l)) + (and (not (string-match-p "\\`[ \t]*|-" l)) (let ((l (org-trim l))) (remove-text-properties 0 (length l) '(display t org-cwidth t) l) @@ -787,9 +801,8 @@ When nil, simply write \"#ERROR\" in corrupted fields.") (org-add-props x nil 'help-echo (concat - (substitute-command-keys - "Clipped table field, use \\[org-table-edit-field] to \ -edit. Full value is:\n") + "Clipped table field, use `\\[org-table-edit-field]' to \ +edit. Full value is:\n" (substring-no-properties x))) (let ((l (length x)) (f1 (min fmax @@ -803,7 +816,7 @@ edit. Full value is:\n") (if (= (org-string-width x) l) (setq f2 f1) (setq f2 1) (while (< (org-string-width (substring x 0 f2)) f1) - (incf f2))) + (cl-incf f2))) (add-text-properties f2 l (list 'org-cwidth t) x) (add-text-properties (if (>= (string-width (substring x (1- f2) f2)) 2) (1- f2) @@ -823,10 +836,10 @@ edit. Full value is:\n") (unless (equal x "") (setq frac (/ (+ (* frac cnt) - (if (org-string-match-p org-table-number-regexp x) + (if (string-match-p org-table-number-regexp x) 1 0)) - (incf cnt))))) + (cl-incf cnt))))) (push (>= frac org-table-number-fraction) typenums))))) (setq lengths (nreverse lengths)) (setq typenums (nreverse typenums)) @@ -919,9 +932,9 @@ a table." (match-beginning 0)) ;; When the line right after the table is the last line in ;; the buffer with trailing spaces but no final newline - ;; character, trailing spaces, be sure to catch the correct - ;; ending at its beginning. In any other case, ending is - ;; expected to be at point max. + ;; character, be sure to catch the correct ending at its + ;; beginning. In any other case, ending is expected to be + ;; at point max. (t (goto-char (point-max)) (skip-chars-backward " \t") (if (bolp) (point) (line-end-position)))))) @@ -934,41 +947,40 @@ Optional argument NEW may specify text to replace the current field content." ((and (not new) org-table-may-need-update)) ; Realignment will happen anyway ((org-at-table-hline-p)) ((and (not new) - (or (not (equal (marker-buffer org-table-aligned-begin-marker) - (current-buffer))) + (or (not (eq (marker-buffer org-table-aligned-begin-marker) + (current-buffer))) (< (point) org-table-aligned-begin-marker) (>= (point) org-table-aligned-end-marker))) - ;; This is not the same table, force a full re-align + ;; This is not the same table, force a full re-align. (setq org-table-may-need-update t)) - (t ;; realign the current field, based on previous full realign - (let* ((pos (point)) s - (col (org-table-current-column)) - (num (if (> col 0) (nth (1- col) org-table-last-alignment))) - l f n o e) + (t + ;; Realign the current field, based on previous full realign. + (let ((pos (point)) + (col (org-table-current-column))) (when (> col 0) - (skip-chars-backward "^|\n") - (if (looking-at " *\\([^|\n]*?\\) *\\(|\\|$\\)") - (progn - (setq s (match-string 1) - o (match-string 0) - l (max 1 - (- (org-string-width - (buffer-substring-no-properties - (match-end 0) (match-beginning 0))) 3)) - e (not (= (match-beginning 2) (match-end 2)))) - (setq f (format (if num " %%%ds %s" " %%-%ds %s") - l (if e "|" (setq org-table-may-need-update t) "")) - n (format f s)) - (if new - (if (<= (org-string-width new) l) - (setq n (format f new)) - (setq n (concat new "|") org-table-may-need-update t))) - (if (equal (string-to-char n) ?-) (setq n (concat " " n))) - (or (equal n o) - (let (org-table-may-need-update) - (replace-match n t t)))) - (setq org-table-may-need-update t)) - (goto-char pos)))))) + (skip-chars-backward "^|") + (if (not (looking-at " *\\([^|\n]*?\\) *\\(|\\|$\\)")) + (setq org-table-may-need-update t) + (let* ((numbers? (nth (1- col) org-table-last-alignment)) + (cell (match-string 0)) + (field (match-string 1)) + (len (max 1 (- (org-string-width cell) 3))) + (properly-closed? (/= (match-beginning 2) (match-end 2))) + (fmt (format (if numbers? " %%%ds %s" " %%-%ds %s") + len + (if properly-closed? "|" + (setq org-table-may-need-update t) + ""))) + (new-cell + (cond ((not new) (format fmt field)) + ((<= (org-string-width new) len) (format fmt new)) + (t + (setq org-table-may-need-update t) + (format " %s |" new))))) + (unless (equal new-cell cell) + (let (org-table-may-need-update) + (replace-match new-cell t t))) + (goto-char pos)))))))) ;;;###autoload (defun org-table-next-field () @@ -1144,7 +1156,7 @@ to a number. In the case of a timestamp, increment by days." (- (org-time-string-to-absolute txt) (org-time-string-to-absolute txt-up))) ((string-match org-ts-regexp3 txt) 1) - ((string-match "^[0-9]+\\(\.[0-9]+\\)?" txt-up) + ((string-match "\\([-+]\\)?[0-9]+\\(?:\.[0-9]+\\)?" txt-up) (- (string-to-number txt) (string-to-number (match-string 0 txt-up)))) (t 1))) @@ -1153,7 +1165,7 @@ to a number. In the case of a timestamp, increment by days." (user-error "No non-empty field found") (if (and org-table-copy-increment (not (equal orig-n 0)) - (string-match "^[-+^/*0-9eE.]+$" txt) + (string-match-p "^[-+^/*0-9eE.]+$" txt) (< (string-to-number txt) 100000000)) (setq txt (calc-eval (concat txt "+" (number-to-string inc))))) (insert txt) @@ -1224,7 +1236,7 @@ Return t when the line exists, nil if it does not exist." "Blank the current table field or active region." (interactive) (org-table-check-inside-data-field) - (if (and (org-called-interactively-p 'any) (org-region-active-p)) + (if (and (called-interactively-p 'any) (org-region-active-p)) (let (org-table-clip) (org-table-cut-region (region-beginning) (region-end))) (skip-chars-backward "^|") @@ -1239,24 +1251,24 @@ Return t when the line exists, nil if it does not exist." (defun org-table-get-field (&optional n replace) "Return the value of the field in column N of current row. -N defaults to current field. -If REPLACE is a string, replace field with this value. The return value -is always the old value." - (and n (org-table-goto-column n)) +N defaults to current column. If REPLACE is a string, replace +field with this value. The return value is always the old +value." + (when n (org-table-goto-column n)) (skip-chars-backward "^|\n") - (backward-char 1) - (if (looking-at "|[^|\r\n]*") - (let* ((pos (match-beginning 0)) - (val (buffer-substring (1+ pos) (match-end 0)))) - (if replace - (replace-match (concat "|" (if (equal replace "") " " replace)) - t t)) - (goto-char (min (point-at-eol) (+ 2 pos))) - val) - (forward-char 1) "")) + (if (or (bolp) (looking-at-p "[ \t]*$")) + ;; Before first column or after last one. + "" + (looking-at "[^|\r\n]*") + (let* ((pos (match-beginning 0)) + (val (buffer-substring pos (match-end 0)))) + (when replace + (replace-match (if (equal replace "") " " replace) t t)) + (goto-char (min (line-end-position) (1+ pos))) + val))) ;;;###autoload -(defun org-table-field-info (arg) +(defun org-table-field-info (_arg) "Show info about the current field, and highlight any reference at point." (interactive "P") (unless (org-at-table-p) (user-error "Not at a table")) @@ -1278,8 +1290,9 @@ is always the old value." (dline (org-table-current-dline)) (ref (format "@%d$%d" dline col)) (ref1 (org-table-convert-refs-to-an ref)) + ;; Prioritize field formulas over column formulas. (fequation (or (assoc name eql) (assoc ref eql))) - (cequation (assoc (int-to-string col) eql)) + (cequation (assoc (format "$%d" col) eql)) (eqn (or fequation cequation))) (let ((p (and eqn (get-text-property 0 :orig-eqn (car eqn))))) (when p (setq eqn p))) @@ -1295,38 +1308,32 @@ is always the old value." (concat ", formula: " (org-table-formula-to-user (concat - (if (string-match "^[$@]"(car eqn)) "" "$") + (if (or (string-prefix-p "$" (car eqn)) + (string-prefix-p "@" (car eqn))) + "" + "$") (car eqn) "=" (cdr eqn)))) ""))))) (defun org-table-current-column () "Find out which column we are in." (interactive) - (when (org-called-interactively-p 'any) (org-table-check-inside-data-field)) (save-excursion (let ((column 0) (pos (point))) (beginning-of-line) - (while (search-forward "|" pos t) (incf column)) - (when (org-called-interactively-p 'interactive) - (message "In table column %d" column)) + (while (search-forward "|" pos t) (cl-incf column)) column))) -;;;###autoload (defun org-table-current-dline () "Find out what table data line we are in. Only data lines count for this." - (interactive) - (when (org-called-interactively-p 'any) - (org-table-check-inside-data-field)) (save-excursion (let ((c 0) (pos (point))) (goto-char (org-table-begin)) (while (<= (point) pos) - (when (looking-at org-table-dataline-regexp) (incf c)) + (when (looking-at org-table-dataline-regexp) (cl-incf c)) (forward-line)) - (when (org-called-interactively-p 'any) - (message "This is table line %d" c)) c))) ;;;###autoload @@ -1479,7 +1486,9 @@ non-nil, the one above is used." (unless (org-at-table-hline-p) (org-table-goto-column col1 t) (when (looking-at "|\\([^|\n]+\\)|\\([^|\n]+\\)|") - (replace-match "|\\2|\\1|"))) + (transpose-regions + (match-beginning 1) (match-end 1) + (match-beginning 2) (match-end 2)))) (forward-line))) (set-marker end nil) (org-table-goto-column colpos) @@ -1543,19 +1552,21 @@ non-nil, the one above is used." "Insert a new row above the current line into the table. With prefix ARG, insert below the current line." (interactive "P") - (if (not (org-at-table-p)) - (user-error "Not at a table")) - (let* ((line (buffer-substring (point-at-bol) (point-at-eol))) + (unless (org-at-table-p) (user-error "Not at a table")) + (let* ((line (buffer-substring (line-beginning-position) (line-end-position))) (new (org-table-clean-line line))) ;; Fix the first field if necessary (if (string-match "^[ \t]*| *[#$] *|" line) (setq new (replace-match (match-string 0 line) t t new))) (beginning-of-line (if arg 2 1)) + ;; Buffer may not end of a newline character, so ensure + ;; (beginning-of-line 2) moves point to a new line. + (unless (bolp) (insert "\n")) (let (org-table-may-need-update) (insert-before-markers new "\n")) (beginning-of-line 0) - (re-search-forward "| ?" (point-at-eol) t) - (and (or org-table-may-need-update org-table-overlay-coordinates) - (org-table-align)) + (re-search-forward "| ?" (line-end-position) t) + (when (or org-table-may-need-update org-table-overlay-coordinates) + (org-table-align)) (when (or (not org-table-fix-formulas-confirm) (funcall org-table-fix-formulas-confirm "Fix formulas? ")) (org-table-fix-formulas "@" nil (1- (org-table-current-dline)) 1)))) @@ -1568,7 +1579,7 @@ With prefix ABOVE, insert above the current line." (if (not (org-at-table-p)) (user-error "Not at a table")) (when (eobp) (insert "\n") (backward-char 1)) - (if (not (string-match "|[ \t]*$" (org-current-line-string))) + (if (not (string-match-p "|[ \t]*$" (org-current-line-string))) (org-table-align)) (let ((line (org-table-clean-line (buffer-substring (point-at-bol) (point-at-eol)))) @@ -1667,7 +1678,7 @@ numeric compare based on the type of the first key in the table." ;; Set appropriate case sensitivity and column used for sorting. (let ((column (let ((c (org-table-current-column))) (cond ((> c 0) c) - ((org-called-interactively-p 'any) + ((called-interactively-p 'any) (read-number "Use column N for sorting: ")) (t 1)))) (sorting-type @@ -1702,27 +1713,27 @@ numeric compare based on the type of the first key in the table." (extract-key-from-field ;; Function to be called on the contents of the field ;; used for sorting in the current row. - (case sorting-type + (cl-case sorting-type ((?n ?N) #'string-to-number) ((?a ?A) #'org-sort-remove-invisible) ((?t ?T) (lambda (f) (cond ((string-match org-ts-regexp-both f) - (org-float-time + (float-time (org-time-string-to-time (match-string 0 f)))) ((string-match "[0-9]\\{1,2\\}:[0-9]\\{2\\}" f) - (org-hh:mm-string-to-minutes f)) + (org-duration-to-minutes (match-string 0 f))) (t 0)))) ((?f ?F) (or getkey-func - (and (org-called-interactively-p 'any) + (and (called-interactively-p 'any) (intern (completing-read "Sort using function: " obarray #'fboundp t))) (error "Missing key extractor to sort rows"))) (t (user-error "Invalid sorting type `%c'" sorting-type)))) (predicate - (case sorting-type + (cl-case sorting-type ((?n ?N ?t ?T) #'<) ((?a ?A) #'string<) ((?f ?F) compare-func)))) @@ -1812,24 +1823,24 @@ lines." (dolist (field row) (org-table-goto-column c nil 'force) (org-table-get-field nil field) - (incf c))) + (cl-incf c))) (forward-line))) (org-table-align))) ;;;###autoload (defun org-table-convert () "Convert from `org-mode' table to table.el and back. -Obviously, this only works within limits. When an Org-mode table is -converted to table.el, all horizontal separator lines get lost, because -table.el uses these as cell boundaries and has no notion of horizontal lines. -A table.el table can be converted to an Org-mode table only if it does not -do row or column spanning. Multiline cells will become multiple cells. -Beware, Org-mode does not test if the table can be successfully converted - it -blindly applies a recipe that works for simple tables." +Obviously, this only works within limits. When an Org table is converted +to table.el, all horizontal separator lines get lost, because table.el uses +these as cell boundaries and has no notion of horizontal lines. A table.el +table can be converted to an Org table only if it does not do row or column +spanning. Multiline cells will become multiple cells. Beware, Org mode +does not test if the table can be successfully converted - it blindly +applies a recipe that works for simple tables." (interactive) (require 'table) (if (org-at-table.el-p) - ;; convert to Org-mode table + ;; convert to Org table (let ((beg (copy-marker (org-table-begin t))) (end (copy-marker (org-table-end t)))) (table-unrecognize-region beg end) @@ -1883,10 +1894,10 @@ Note that horizontal lines disappear." (let* ((table (delete 'hline (org-table-to-lisp))) (dline_old (org-table-current-line)) (col_old (org-table-current-column)) - (contents (mapcar (lambda (p) + (contents (mapcar (lambda (_) (let ((tp table)) (mapcar - (lambda (rown) + (lambda (_) (prog1 (pop (car tp)) (setq tp (cdr tp)))) @@ -1975,9 +1986,14 @@ blank, and the content is appended to the field above." (defun org-table-edit-field (arg) "Edit table field in a different window. This is mainly useful for fields that contain hidden parts. -When called with a \\[universal-argument] prefix, just make the full field visible so that -it can be edited in place." + +When called with a `\\[universal-argument]' prefix, just make the full field +visible so that it can be edited in place. + +When called with a `\\[universal-argument] \\[universal-argument]' prefix, \ +toggle `org-table-follow-field-mode'." (interactive "P") + (unless (org-at-table-p) (user-error "Not at a table")) (cond ((equal arg '(16)) (org-table-follow-field-mode (if org-table-follow-field-mode -1 1))) @@ -2016,9 +2032,9 @@ it can be edited in place." '(invisible t org-cwidth t display t intangible t)) (goto-char p) - (org-set-local 'org-finish-function 'org-table-finish-edit-field) - (org-set-local 'org-window-configuration cw) - (org-set-local 'org-field-marker pos) + (setq-local org-finish-function 'org-table-finish-edit-field) + (setq-local org-window-configuration cw) + (setq-local org-field-marker pos) (message "Edit and finish with C-c C-c"))))) (defun org-table-finish-edit-field () @@ -2051,8 +2067,8 @@ current field. The mode exits automatically when the cursor leaves the table (but see `org-table-exit-follow-field-mode-when-leaving-table')." nil " TblFollow" nil (if org-table-follow-field-mode - (org-add-hook 'post-command-hook 'org-table-follow-fields-with-editor - 'append 'local) + (add-hook 'post-command-hook 'org-table-follow-fields-with-editor + 'append 'local) (remove-hook 'post-command-hook 'org-table-follow-fields-with-editor 'local) (let* ((buf (get-buffer "*Org Table Edit Field*")) (win (and buf (get-buffer-window buf)))) @@ -2127,11 +2143,10 @@ If NLAST is a number, only the NLAST fields will actually be summed." s diff) (format "%.0f:%02.0f:%02.0f" h m s)))) (kill-new sres) - (if (org-called-interactively-p 'interactive) - (message "%s" - (substitute-command-keys - (format "Sum of %d items: %-20s (\\[yank] will insert result into buffer)" - (length numbers) sres)))) + (when (called-interactively-p 'interactive) + (message "%s" (substitute-command-keys + (format "Sum of %d items: %-20s \ +\(\\[yank] will insert result into buffer)" (length numbers) sres)))) sres)))) (defun org-table-get-number-for-summing (s) @@ -2160,20 +2175,25 @@ If NLAST is a number, only the NLAST fields will actually be summed." Assumes that table is already analyzed. If KEY is given, return the key to this formula. Otherwise return the formula preceded with \"=\" or \":=\"." - (let* ((col (org-table-current-column)) - (name (car (rassoc (list (count-lines org-table-current-begin-pos - (line-beginning-position)) - col) - org-table-named-field-locations))) - (scol (int-to-string col)) - (ref (format "@%d$%d" (org-table-current-dline) col)) - (stored-list (org-table-get-stored-formulas noerror)) - (ass (or (assoc name stored-list) - (assoc ref stored-list) - (assoc scol stored-list)))) - (cond (key (car ass)) - (ass (concat (if (string-match "^[0-9]+$" (car ass)) "=" ":=") - (cdr ass)))))) + (let* ((line (count-lines org-table-current-begin-pos + (line-beginning-position))) + (row (org-table-line-to-dline line))) + (cond + (row + (let* ((col (org-table-current-column)) + (name (car (rassoc (list line col) + org-table-named-field-locations))) + (scol (format "$%d" col)) + (ref (format "@%d$%d" (org-table-current-dline) col)) + (stored-list (org-table-get-stored-formulas noerror)) + (ass (or (assoc name stored-list) + (assoc ref stored-list) + (assoc scol stored-list)))) + (cond (key (car ass)) + (ass (concat (if (string-match-p "^[0-9]+$" (car ass)) "=" ":=") + (cdr ass)))))) + (noerror nil) + (t (error "No formula active for the current field"))))) (defun org-table-get-formula (&optional equation named) "Read a formula from the minibuffer, offer stored formula as default. @@ -2183,32 +2203,26 @@ When NAMED is non-nil, look for a named equation." (line-beginning-position)) (org-table-current-column)) org-table-named-field-locations))) - (ref (format "@%d$%d" (org-table-current-dline) + (ref (format "@%d$%d" + (org-table-current-dline) (org-table-current-column))) - (refass (assoc ref stored-list)) - (nameass (assoc name stored-list)) - (scol (if named - (if (and name (not (string-match "^LR[0-9]+$" name))) - name - ref) - (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? " )) - (message "Formula not replaced"))) + (scol (cond + ((not named) (format "$%d" (org-table-current-column))) + ((and name (not (string-match "\\`LR[0-9]+\\'" name))) name) + (t ref))) (name (or name ref)) (org-table-may-need-update nil) (stored (cdr (assoc scol stored-list))) (eq (cond - ((and stored equation (string-match "^ *=? *$" equation)) + ((and stored equation (string-match-p "^ *=? *$" equation)) stored) ((stringp equation) equation) (t (org-table-formula-from-user (read-string (org-table-formula-to-user - (format "%s formula %s%s=" + (format "%s formula %s=" (if named "Field" "Column") - (if (member (string-to-char scol) '(?$ ?@)) "" "$") scol)) (if stored (org-table-formula-to-user stored) "") 'org-table-formula-history @@ -2232,25 +2246,27 @@ When NAMED is non-nil, look for a named equation." (org-table-store-formulas stored-list)) eq)) -(defun org-table-store-formulas (alist) - "Store the list of formulas below the current table." - (setq alist (sort alist 'org-table-formula-less-p)) - (let ((case-fold-search t)) - (save-excursion - (goto-char (org-table-end)) - (if (looking-at "\\([ \t]*\n\\)*[ \t]*\\(#\\+tblfm:\\)\\(.*\n?\\)") +(defun org-table-store-formulas (alist &optional location) + "Store the list of formulas below the current table. +If optional argument LOCATION is a buffer position, insert it at +LOCATION instead." + (save-excursion + (if location + (progn (goto-char location) (beginning-of-line)) + (goto-char (org-table-end))) + (let ((case-fold-search t)) + (if (looking-at "\\([ \t]*\n\\)*[ \t]*\\(#\\+TBLFM:\\)\\(.*\n?\\)") (progn - ;; don't overwrite TBLFM, we might use text properties to store stuff + ;; Don't overwrite TBLFM, we might use text properties to + ;; store stuff. (goto-char (match-beginning 3)) (delete-region (match-beginning 3) (match-end 0))) (org-indent-line) (insert (or (match-string 2) "#+TBLFM:"))) (insert " " - (mapconcat (lambda (x) - (concat - (if (equal (string-to-char (car x)) ?@) "" "$") - (car x) "=" (cdr x))) - alist "::") + (mapconcat (lambda (x) (concat (car x) "=" (cdr x))) + (sort alist #'org-table-formula-less-p) + "::") "\n")))) (defsubst org-table-formula-make-cmp-string (a) @@ -2279,33 +2295,47 @@ When NAMED is non-nil, look for a named equation." (and as bs (string< as bs)))) ;;;###autoload -(defun org-table-get-stored-formulas (&optional noerror) - "Return an alist with the stored formulas directly after current table." - (interactive) ;; FIXME interactive? - (let ((case-fold-search t) scol eq eq-alist strings string seen) - (save-excursion - (goto-char (org-table-end)) - (when (looking-at "\\([ \t]*\n\\)*[ \t]*#\\+tblfm: *\\(.*\\)") - (setq strings (org-split-string (org-match-string-no-properties 2) - " *:: *")) - (while (setq string (pop strings)) - (when (string-match "\\`\\(@[-+I<>0-9.$@]+\\|@?[0-9]+\\|\\$\\([a-zA-Z0-9]+\\|[<>]+\\)\\) *= *\\(.*[^ \t]\\)" string) - (setq scol (if (match-end 2) - (match-string 2 string) - (match-string 1 string)) - scol (if (member (string-to-char scol) '(?< ?>)) - (concat "$" scol) scol) - eq (match-string 3 string) - eq-alist (cons (cons scol eq) eq-alist)) - (if (member scol seen) - (if noerror - (progn - (message "Double definition `$%s=' in TBLFM line, please fix by hand" scol) - (ding) - (sit-for 2)) - (user-error "Double definition `$%s=' in TBLFM line, please fix by hand" scol)) - (push scol seen)))))) - (nreverse eq-alist))) +(defun org-table-get-stored-formulas (&optional noerror location) + "Return an alist with the stored formulas directly after current table. +By default, only return active formulas, i.e., formulas located +on the first line after the table. However, if optional argument +LOCATION is a buffer position, consider the formulas there." + (save-excursion + (if location + (progn (goto-char location) (beginning-of-line)) + (goto-char (org-table-end))) + (let ((case-fold-search t)) + (when (looking-at "\\([ \t]*\n\\)*[ \t]*#\\+TBLFM: *\\(.*\\)") + (let ((strings (org-split-string (match-string-no-properties 2) + " *:: *")) + eq-alist seen) + (dolist (string strings (nreverse eq-alist)) + (when (string-match "\\`\\(@[-+I<>0-9.$@]+\\|\\$\\([_a-zA-Z0-9]+\\|\ +[<>]+\\)\\) *= *\\(.*[^ \t]\\)" + string) + (let ((lhs + (let ((m (match-string 1 string))) + (cond + ((not (match-end 2)) m) + ;; Is it a column reference? + ((string-match-p "\\`$\\([0-9]+\\|[<>]+\\)\\'" m) m) + ;; Since named columns are not possible in + ;; LHS, assume this is a named field. + (t (match-string 2 string))))) + (rhs (match-string 3 string))) + (push (cons lhs rhs) eq-alist) + (cond + ((not (member lhs seen)) (push lhs seen)) + (noerror + (message + "Double definition `%s=' in TBLFM line, please fix by hand" + lhs) + (ding) + (sit-for 2)) + (t + (user-error + "Double definition `%s=' in TBLFM line, please fix by hand" + lhs))))))))))) (defun org-table-fix-formulas (key replace &optional limit delta remove) "Modify the equations after the table structure has been edited. @@ -2355,11 +2385,8 @@ If yes, store the formula and apply it." (when (string-match "^:?=\\(.*[^=]\\)$" field) (setq named (equal (string-to-char field) ?:) eq (match-string 1 field)) - (if (or (fboundp 'calc-eval) - (equal (substring eq 0 (min 2 (length eq))) "'(")) - (org-table-eval-formula (if named '(4) nil) - (org-table-formula-from-user eq)) - (user-error "Calc does not seem to be installed, and is needed to evaluate the formula")))))) + (org-table-eval-formula (and named '(4)) + (org-table-formula-from-user eq)))))) (defvar org-recalc-commands nil "List of commands triggering the recalculation of a line. @@ -2441,7 +2468,7 @@ of the new mark." (when l1 (set-marker l1 nil)) (when l2 (set-marker l2 nil)) (set-marker l nil) - (when (org-called-interactively-p 'interactive) + (when (called-interactively-p 'interactive) (message "%s" (cdr (assoc newchar org-recalc-marks)))))) ;;;###autoload @@ -2469,7 +2496,7 @@ This function sets up the following dynamically scoped variables: (re-search-forward "^[ \t]*| *! *\\(|.*\\)" end t)) (let ((c 1)) (dolist (name (org-split-string (match-string 1) " *| *")) - (incf c) + (cl-incf c) (when (string-match "\\`[a-zA-Z][_a-zA-Z0-9]*\\'" name) (push (cons name (int-to-string c)) org-table-column-names))))) (setq org-table-column-names (nreverse org-table-column-names)) @@ -2498,13 +2525,13 @@ This function sets up the following dynamically scoped variables: (let ((fields1 (and (looking-at "^[ \t]*|[^|]*\\(|.*\\)") (org-split-string (match-string 1) " *| *"))) - (line (incf (cdr last) (count-lines (car last) (point)))) + (line (cl-incf (cdr last) (count-lines (car last) (point)))) (col 1)) (setcar last (point)) ; Update last known position. (while (and fields fields1) (let ((field (pop fields)) (v (pop fields1))) - (incf col) + (cl-incf col) (when (and (stringp field) (stringp v) (string-match "\\`[a-zA-Z][_a-zA-Z0-9]*\\'" @@ -2522,28 +2549,31 @@ This function sets up the following dynamically scoped variables: (push (if (match-end 1) 'hline 'dline) types) (if (match-end 1) (push l hlines) (push l dlines)) (forward-line) - (incf l)) + (cl-incf l)) (push 'hline types) ; Add an imaginary extra hline to the end. (setq org-table-current-line-types (apply #'vector (nreverse types))) (setq org-table-dlines (apply #'vector (cons nil (nreverse dlines)))) - (setq org-table-hlines (apply #'vector (cons nil (nreverse hlines)))) - (forward-line -1) - (let* ((last-dline (car dlines)) - (fields (org-split-string - (buffer-substring (line-beginning-position) - (line-end-position)) - "[ \t]*|[ \t]*")) - (nfields (length fields)) - al al2) - (setq org-table-current-ncol nfields) + (setq org-table-hlines (apply #'vector (cons nil (nreverse hlines))))) + ;; Get the number of columns from the first data line in table. + (goto-char beg) + (forward-line (aref org-table-dlines 1)) + (let* ((fields + (org-split-string + (buffer-substring (line-beginning-position) (line-end-position)) + "[ \t]*|[ \t]*")) + (nfields (length fields)) + al al2) + (setq org-table-current-ncol nfields) + (let ((last-dline + (aref org-table-dlines (1- (length org-table-dlines))))) (dotimes (i nfields) (let ((column (1+ i))) (push (list (format "LR%d" column) last-dline column) al) - (push (cons (format "LR%d" column) (nth i fields)) al2))) - (setq org-table-named-field-locations - (append org-table-named-field-locations al)) - (setq org-table-local-parameters - (append org-table-local-parameters al2))))))) + (push (cons (format "LR%d" column) (nth i fields)) al2)))) + (setq org-table-named-field-locations + (append org-table-named-field-locations al)) + (setq org-table-local-parameters + (append org-table-local-parameters al2)))))) (defun org-table-goto-field (ref &optional create-column-p) "Move point to a specific field in the current table. @@ -2606,20 +2636,18 @@ This function assumes the table is already analyzed (i.e., using suppress-store suppress-analysis) "Replace the table field value at the cursor by the result of a calculation. -This function makes use of Dave Gillespie's Calc package, in my view the -most exciting program ever written for GNU Emacs. So you need to have Calc -installed in order to use this function. - In a table, this command replaces the value in the current field with the result of a formula. It also installs the formula as the \"current\" column formula, by storing it in a special line below the table. When called -with a `C-u' prefix, the current field must be a named field, and the -formula is installed as valid in only this specific field. +with a `\\[universal-argument]' prefix the formula is installed as a \ +field formula. -When called with two `C-u' prefixes, insert the active equation -for the field back into the current field, so that it can be -edited there. This is useful in order to use \\[org-table-show-reference] -to check the referenced fields. +When called with a `\\[universal-argument] \\[universal-argument]' prefix, \ +insert the active equation for the field +back into the current field, so that it can be edited there. This is \ +useful +in order to use \\`\\[org-table-show-reference]' to \ +check the referenced fields. When called, the command first prompts for a formula, which is read in the minibuffer. Previously entered formulas are available through the @@ -2628,23 +2656,31 @@ These stored formulas are adapted correctly when moving, inserting, or deleting columns with the corresponding commands. The formula can be any algebraic expression understood by the Calc package. -For details, see the Org-mode manual. +For details, see the Org mode manual. This function can also be called from Lisp programs and offers additional arguments: EQUATION can be the formula to apply. If this -argument is given, the user will not be prompted. SUPPRESS-ALIGN is -used to speed-up recursive calls by by-passing unnecessary aligns. +argument is given, the user will not be prompted. + +SUPPRESS-ALIGN is used to speed-up recursive calls by by-passing +unnecessary aligns. + SUPPRESS-CONST suppresses the interpretation of constants in the -formula, assuming that this has been done already outside the function. -SUPPRESS-STORE means the formula should not be stored, either because -it is already stored, or because it is a modified equation that should -not overwrite the stored one." +formula, assuming that this has been done already outside the +function. + +SUPPRESS-STORE means the formula should not be stored, either +because it is already stored, or because it is a modified +equation that should not overwrite the stored one. + +SUPPRESS-ANALYSIS prevents analyzing the table and checking +location of point." (interactive "P") - (org-table-check-inside-data-field) - (or suppress-analysis (org-table-analyze)) + (unless suppress-analysis + (org-table-check-inside-data-field) + (org-table-analyze)) (if (equal arg '(16)) (let ((eq (org-table-current-field-formula))) - (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)) @@ -2704,12 +2740,15 @@ not overwrite the stored one." (setq fmt (replace-match "" t t fmt))) (unless (string-match "\\S-" fmt) (setq fmt nil)))) - (if (and (not suppress-const) org-table-formula-use-constants) - (setq formula (org-table-formula-substitute-names formula))) + (when (and (not suppress-const) org-table-formula-use-constants) + (setq formula (org-table-formula-substitute-names formula))) (setq orig (or (get-text-property 1 :orig-formula formula) "?")) + (setq formula (org-table-formula-handle-first/last-rc formula)) (while (> ndown 0) (setq fields (org-split-string - (buffer-substring-no-properties (point-at-bol) (point-at-eol)) + (org-trim + (buffer-substring-no-properties + (line-beginning-position) (line-end-position))) " *| *")) ;; replace fields with duration values if relevant (if duration @@ -2788,11 +2827,12 @@ not overwrite the stored one." (replace-match (save-match-data (org-table-make-reference - (org-sublist fields - (+ (if (match-end 2) n0 0) - (string-to-number (match-string 1 form))) - (+ (if (match-end 4) n0 0) - (string-to-number (match-string 3 form)))) + (cl-subseq fields + (+ (if (match-end 2) n0 0) + (string-to-number (match-string 1 form)) + -1) + (+ (if (match-end 4) n0 0) + (string-to-number (match-string 3 form)))) keep-empty numbers lispp)) t t form))) (setq form0 form) @@ -2819,20 +2859,23 @@ not overwrite the stored one." ev (if duration (org-table-time-seconds-to-string (string-to-number ev) duration-output-format) ev)) - (or (fboundp 'calc-eval) - (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 - (while (string-match (concat "\\[" org-ts-regexp1 "\\]") form) - (setq form (replace-match "<\\1>" nil nil 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)))) + + ;; Use <...> time-stamps so that Calc can handle them. + (setq form + (replace-regexp-in-string org-ts-regexp-inactive "<\\1>" form)) + ;; Internationalize local time-stamps by setting locale to + ;; "C". + (setq form + (replace-regexp-in-string + org-ts-regexp + (lambda (ts) + (let ((system-time-locale "C")) + (format-time-string + (org-time-stamp-format + (string-match-p "[0-9]\\{1,2\\}:[0-9]\\{2\\}" ts)) + (apply #'encode-time + (save-match-data (org-parse-time-string ts)))))) + form t t)) (setq ev (if (and duration (string-match "^[0-9]+:[0-9]+\\(?::[0-9]+\\)?$" form)) form @@ -2860,7 +2903,7 @@ $1-> %s\n" orig formula form0 form)) (if fmt (format fmt (string-to-number ev)) ev))))) (setq bw (get-buffer-window "*Substitution History*")) (org-fit-window-to-buffer bw) - (unless (and (org-called-interactively-p 'any) (not ndown)) + (unless (and (called-interactively-p 'any) (not ndown)) (unless (let (inhibit-redisplay) (y-or-n-p "Debugging Formula. Continue to next? ")) (org-table-align) @@ -2870,7 +2913,14 @@ $1-> %s\n" orig formula form0 form)) (when (consp ev) (setq fmt nil ev "#ERROR")) (org-table-justify-field-maybe (format org-table-formula-field-format - (if fmt (format fmt (string-to-number ev)) ev))) + (cond + ((not (stringp ev)) ev) + (fmt (format fmt (string-to-number ev))) + ;; Replace any active time stamp in the result with + ;; an inactive one. Dates in tables are likely + ;; piece of regular data, not meant to appear in the + ;; agenda. + (t (replace-regexp-in-string org-ts-regexp "[\\1]" ev))))) (if (and down (> ndown 0) (looking-at ".*\n[ \t]*|[^-]")) (call-interactively 'org-return) (setq ndown 0))) @@ -2896,7 +2946,9 @@ When CORNERS-ONLY is set, only return the corners of the range as a list (line1 column1 line2 column2) where line1 and line2 are line numbers relative to beginning of table, or TBEG, and column1 and column2 are table column numbers." - (let* ((desc (if (eq (string-to-char desc) ?@) desc (concat "@" desc))) + (let* ((desc (if (string-match-p "\\`\\$[0-9]+\\.\\.\\$[0-9]+\\'" desc) + (replace-regexp-in-string "\\$" "@0$" desc) + desc)) (col (or col (org-table-current-column))) (tbeg (or tbeg (org-table-begin))) (thisline (count-lines tbeg (line-beginning-position)))) @@ -2942,7 +2994,7 @@ and column2 are table column numbers." (forward-line (- first-row thisline)) (while (not (looking-at org-table-dataline-regexp)) (forward-line) - (incf first-row)) + (cl-incf first-row)) (org-table-goto-column first-column) (let ((beg (point))) (forward-line (- last-row first-row)) @@ -2980,7 +3032,7 @@ The cursor is currently in relative line number CLINE." (when (and hn (not hdir)) (setq cline 0) (setq hdir "+") - (when (eq (aref org-table-current-line-types 0) 'hline) (decf hn))) + (when (eq (aref org-table-current-line-types 0) 'hline) (cl-decf hn))) (when (and (not hn) on (not odir)) (user-error "Should never happen")) (when hn (setq cline @@ -2999,7 +3051,7 @@ search, as a string." (let ((l (length org-table-current-line-types))) (catch :exit (dotimes (_ n) - (while (and (incf i (if backwards -1 1)) + (while (and (cl-incf i (if backwards -1 1)) (>= i 0) (< i l) (not (eq (aref org-table-current-line-types i) type)) @@ -3011,7 +3063,7 @@ search, as a string." ((eq org-table-relative-ref-may-cross-hline t)) ((eq org-table-relative-ref-may-cross-hline 'error) (user-error "Row descriptor %s crosses hline" desc)) - (t (decf i (if backwards -1 1)) ; Step back. + (t (cl-decf i (if backwards -1 1)) ; Step back. (throw :exit nil))))))) (cond ((or (< i 0) (>= i l)) (user-error "Row descriptor %s leads outside table" desc)) @@ -3029,7 +3081,7 @@ search, as a string." KEEP-EMPTY indicated to keep empty fields, default is to skip them. NUMBERS indicates that everything should be converted to numbers. LISPP non-nil means to return something appropriate for a Lisp -list, 'literal is for the format specifier L." +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). @@ -3089,10 +3141,13 @@ T1 is nil, always messages." ;;;###autoload (defun org-table-recalculate (&optional all noalign) "Recalculate the current table line by applying all stored formulas. + With prefix arg ALL, do this for all lines in the table. -With the prefix argument ALL is `(16)' \ -\(a double \\[universal-prefix] \\[universal-prefix] prefix), or if -it is the symbol `iterate', recompute the table until it no longer changes. + +When called with a `\\[universal-argument] \\[universal-argument]' prefix, or \ +if ALL is the symbol `iterate', +recompute the table until it no longer changes. + If NOALIGN is not nil, do not re-align the table after the computations are done. This is typically used internally to save time, if it is known that the table will be realigned a little later anyway." @@ -3105,47 +3160,43 @@ known that the table will be realigned a little later anyway." (org-table-analyze) (let* ((eqlist (sort (org-table-get-stored-formulas) (lambda (a b) (string< (car a) (car b))))) - (eqlist1 (copy-sequence eqlist)) (inhibit-redisplay (not debug-on-error)) (line-re org-table-dataline-regexp) (log-first-time (current-time)) (log-last-time log-first-time) (cnt 0) - beg end eqlnum eqlname) - ;; Insert constants in all formulas + beg end eqlcol eqlfield) + ;; Insert constants in all formulas. (when eqlist (org-table-save-field - (setq eqlist - (mapcar - (lambda (x) - (when (string-match "\\`@-?I+" (car x)) - (user-error "Can't assign to hline relative reference")) - (when (string-match "\\`$[<>]" (car x)) - (let ((old-lhs (car x))) - (setq x - (cons - (substring - (org-table-formula-handle-first/last-rc old-lhs) - 1) - (cdr x))) - (when (assoc (car x) eqlist1) - (user-error "\"%s=\" formula tries to overwrite \ -existing formula for column %s" - old-lhs - (car x))))) - (cons (org-table-formula-handle-first/last-rc (car x)) - (org-table-formula-substitute-names - (org-table-formula-handle-first/last-rc (cdr x))))) - eqlist)) - ;; Split the equation list. + ;; Expand equations, then split the equation list between + ;; column formulas and field formulas. (dolist (eq eqlist) - (if (<= (string-to-char (car eq)) ?9) - (push eq eqlnum) - (push eq eqlname))) - (setq eqlnum (nreverse eqlnum)) + (let* ((rhs (org-table-formula-substitute-names + (org-table-formula-handle-first/last-rc (cdr eq)))) + (old-lhs (car eq)) + (lhs + (org-table-formula-handle-first/last-rc + (cond + ((string-match "\\`@-?I+" old-lhs) + (user-error "Can't assign to hline relative reference")) + ((string-match "\\`$[<>]" old-lhs) + (let ((new (org-table-formula-handle-first/last-rc + old-lhs))) + (when (assoc new eqlist) + (user-error "\"%s=\" formula tries to overwrite \ +existing formula for column %s" + old-lhs + new)) + new)) + (t old-lhs))))) + (if (string-match-p "\\`\\$[0-9]+\\'" lhs) + (push (cons lhs rhs) eqlcol) + (push (cons lhs rhs) eqlfield)))) + (setq eqlcol (nreverse eqlcol)) ;; Expand ranges in lhs of formulas - (setq eqlname (org-table-expand-lhs-ranges (nreverse eqlname))) - ;; Get the correct line range to process + (setq eqlfield (org-table-expand-lhs-ranges (nreverse eqlfield))) + ;; Get the correct line range to process. (if all (progn (setq end (copy-marker (org-table-end))) @@ -3160,7 +3211,7 @@ existing formula for column %s" (re-search-forward org-table-hline-regexp end t) (re-search-forward org-table-dataline-regexp end t)) (setq beg (match-beginning 0))) - ;; Just leave BEG where it is. + ;; Just leave BEG at the start of the table. (t nil))) (setq beg (line-beginning-position) end (copy-marker (line-beginning-position 2)))) @@ -3171,7 +3222,7 @@ existing formula for column %s" (let ((current-line (count-lines org-table-current-begin-pos (line-beginning-position))) seen-fields) - (dolist (eq eqlname) + (dolist (eq eqlfield) (let* ((name (car eq)) (location (assoc name org-table-named-field-locations)) (eq-line (or (nth 1 location) @@ -3200,7 +3251,7 @@ existing formula for column %s" (while (re-search-forward line-re end t) (unless (string-match "\\` *[_^!$/] *\\'" (org-table-get-field 1)) ;; Unprotected line, recalculate. - (incf cnt) + (cl-incf cnt) (when all (setq log-last-time (org-table-message-once-per-second @@ -3210,14 +3261,15 @@ existing formula for column %s" (move-marker org-last-recalc-line (line-beginning-position)) (setq org-last-recalc-line (copy-marker (line-beginning-position)))) - (dolist (entry eqlnum) + (dolist (entry eqlcol) (goto-char org-last-recalc-line) - (org-table-goto-column (string-to-number (car entry)) nil 'force) + (org-table-goto-column + (string-to-number (substring (car entry) 1)) nil 'force) (unless (get-text-property (point) :org-untouchable) (org-table-eval-formula nil (cdr entry) 'noalign 'nocst 'nostore 'noanalysis))))) ;; Evaluate the field formulas. - (dolist (eq eqlname) + (dolist (eq eqlfield) (let ((reference (car eq)) (formula (cdr eq))) (setq log-last-time @@ -3230,19 +3282,19 @@ existing formula for column %s" ;; `org-table-formula-create-columns' allows it. (let ((column-count (progn (end-of-line) (1- (org-table-current-column))))) - `(lambda (column) - (when (> column 1000) - (user-error "Formula column target too large")) - (and (> column ,column-count) - (or (eq org-table-formula-create-columns t) - (and (eq org-table-formula-create-columns 'warn) - (progn - (org-display-warning - "Out-of-bounds formula added columns") - t)) - (and (eq org-table-formula-create-columns 'prompt) - (yes-or-no-p - "Out-of-bounds formula. Add columns? "))))))) + (lambda (column) + (when (> column 1000) + (user-error "Formula column target too large")) + (and (> column column-count) + (or (eq org-table-formula-create-columns t) + (and (eq org-table-formula-create-columns 'warn) + (progn + (org-display-warning + "Out-of-bounds formula added columns") + t)) + (and (eq org-table-formula-create-columns 'prompt) + (yes-or-no-p + "Out-of-bounds formula. Add columns? "))))))) (org-table-eval-formula nil formula t t t t)))) ;; Clean up markers and internal text property. (remove-text-properties (point-min) (point-max) '(org-untouchable t)) @@ -3282,10 +3334,15 @@ with the prefix ARG." (defun org-table-recalculate-buffer-tables () "Recalculate all tables in the current buffer." (interactive) - (save-excursion - (save-restriction - (widen) - (org-table-map-tables (lambda () (org-table-recalculate t)) t)))) + (org-with-wide-buffer + (org-table-map-tables + (lambda () + ;; Reason for separate `org-table-align': When repeating + ;; (org-table-recalculate t) `org-table-may-need-update' gets in + ;; the way. + (org-table-recalculate t t) + (org-table-align)) + t))) ;;;###autoload (defun org-table-iterate-buffer-tables () @@ -3295,19 +3352,19 @@ with the prefix ARG." (i imax) (checksum (md5 (buffer-string))) c1) - (save-excursion - (save-restriction - (widen) - (catch 'exit - (while (> i 0) - (setq i (1- i)) - (org-table-map-tables (lambda () (org-table-recalculate t)) t) - (if (equal checksum (setq c1 (md5 (buffer-string)))) - (progn - (message "Convergence after %d iterations" (- imax i)) - (throw 'exit t)) - (setq checksum c1))) - (user-error "No convergence after %d iterations" imax)))))) + (org-with-wide-buffer + (catch 'exit + (while (> i 0) + (setq i (1- i)) + (org-table-map-tables (lambda () (org-table-recalculate t t)) t) + (if (equal checksum (setq c1 (md5 (buffer-string)))) + (progn + (org-table-map-tables #'org-table-align t) + (message "Convergence after %d iterations" (- imax i)) + (throw 'exit t)) + (setq checksum c1))) + (org-table-map-tables #'org-table-align t) + (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." @@ -3342,19 +3399,25 @@ Return nil when the beginning of TBLFM line was not found." (defun org-table-expand-lhs-ranges (equations) "Expand list of formulas. -If some of the RHS in the formulas are ranges or a row reference, expand -them to individual field equations for each field." +If some of the RHS in the formulas are ranges or a row reference, +expand them to individual field equations for each field. This +function assumes the table is already analyzed (i.e., using +`org-table-analyze')." (let (res) (dolist (e equations (nreverse res)) (let ((lhs (car e)) (rhs (cdr e))) (cond - ((string-match "\\`@-?[-+0-9]+\\$-?[0-9]+\\'" lhs) + ((string-match-p "\\`@-?[-+0-9]+\\$-?[0-9]+\\'" lhs) ;; This just refers to one fixed field. (push e res)) - ((string-match "\\`[a-zA-Z][_a-zA-Z0-9]*\\'" lhs) + ((string-match-p "\\`[a-zA-Z][_a-zA-Z0-9]*\\'" lhs) ;; This just refers to one fixed named field. (push e res)) + ((string-match-p "\\`\\$[0-9]+\\'" lhs) + ;; Column formulas are treated specially and are not + ;; expanded. + (push e res)) ((string-match "\\`@[0-9]+\\'" lhs) (dotimes (ic org-table-current-ncol) (push (cons (propertize (format "%s$%d" lhs (1+ ic)) :orig-eqn e) @@ -3367,12 +3430,12 @@ them to individual field equations for each field." (c1 (nth 1 range)) (r2 (org-table-line-to-dline (nth 2 range) 'above)) (c2 (nth 3 range))) - (loop for ir from r1 to r2 do - (loop for ic from c1 to c2 do - (push - (cons (propertize (format "@%d$%d" ir ic) :orig-eqn e) - rhs) - res)))))))))) + (cl-loop for ir from r1 to r2 do + (cl-loop for ic from c1 to c2 do + (push (cons (propertize + (format "@%d$%d" ir ic) :orig-eqn e) + rhs) + res)))))))))) (defun org-table-formula-handle-first/last-rc (s) "Replace @<, @>, $<, $> with first/last row/column of the table. @@ -3384,7 +3447,7 @@ formulas that use a range of rows or columns, it may often be better to anchor the formula with \"I\" row markers, or to offset from the borders of the table using the @< @> $< $> makers." (let (n nmax len char (start 0)) - (while (string-match "\\([@$]\\)\\(<+\\|>+\\)\\|\\(remote([^\)]+)\\)" + (while (string-match "\\([@$]\\)\\(<+\\|>+\\)\\|\\(remote([^)]+)\\)" s start) (if (match-end 3) (setq start (match-end 3)) @@ -3398,7 +3461,7 @@ borders of the table using the @< @> $< $> makers." (- nmax len -1))) (if (or (< n 1) (> n nmax)) (user-error "Reference \"%s\" in expression \"%s\" points outside table" - (match-string 0 s) s)) + (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))))) s) @@ -3407,7 +3470,7 @@ borders of the table using the @< @> $< $> makers." "Replace $const with values in string F." (let ((start 0) (pp (/= (string-to-char f) ?')) - (duration (org-string-match-p ";.*[Tt].*\\'" f)) + (duration (string-match-p ";.*[Tt].*\\'" f)) (new (replace-regexp-in-string ; Check for column names. org-table-column-name-regexp (lambda (m) @@ -3420,7 +3483,7 @@ borders of the table using the @< @> $< $> makers." "\\$\\([a-zA-Z][_a-zA-Z0-9]*\\)\\|\\(\\ $< $> makers." (when value (setq new (replace-match (concat (and pp "(") value (and pp ")")) t t new)))))) - (if org-table-formula-debug (org-propertize new :orig-formula f)) new)) + (if org-table-formula-debug (propertize new :orig-formula f) new))) (defun org-table-get-constant (const) "Find the value for a parameter or constant in a formula. @@ -3497,60 +3560,69 @@ Parameters get priority." :style toggle :selected org-table-buffer-is-an])) (defvar org-pos) +(defvar org-table--fedit-source nil + "Position of the TBLFM line being edited.") ;;;###autoload (defun org-table-edit-formulas () "Edit the formulas of the current table in a separate buffer." (interactive) - (when (save-excursion (beginning-of-line) - (let ((case-fold-search t)) (looking-at "[ \t]*#\\+TBLFM"))) - (beginning-of-line 0)) - (unless (org-at-table-p) (user-error "Not at a table")) - (org-table-analyze) - (let ((key (org-table-current-field-formula 'key 'noerror)) - (eql (sort (org-table-get-stored-formulas 'noerror) - #'org-table-formula-less-p)) - (pos (point-marker)) - (startline 1) - (wc (current-window-configuration)) - (sel-win (selected-window)) - (titles '((column . "# Column Formulas\n") - (field . "# Field and Range Formulas\n") - (named . "# Named Field Formulas\n")))) - (org-switch-to-buffer-other-window "*Edit Formulas*") - (erase-buffer) - ;; Keep global-font-lock-mode from turning on font-lock-mode - (let ((font-lock-global-modes '(not fundamental-mode))) - (fundamental-mode)) - (org-set-local 'font-lock-global-modes (list 'not major-mode)) - (org-set-local 'org-pos pos) - (org-set-local 'org-window-configuration wc) - (org-set-local 'org-selected-window sel-win) - (use-local-map org-table-fedit-map) - (org-add-hook 'post-command-hook #'org-table-fedit-post-command t t) - (easy-menu-add org-table-fedit-menu) - (setq startline (org-current-line)) - (dolist (entry eql) - (let* ((type (cond - ((string-match "\\`$[<>]" (car entry)) 'column) - ((equal (string-to-char (car entry)) ?@) 'field) - ((string-match "\\'[0-9]" (car entry)) 'column) - (t 'named))) - (title (assq type titles))) - (when title - (unless (bobp) (insert "\n")) - (insert (org-add-props (cdr title) nil 'face font-lock-comment-face)) - (setq titles (remove title titles))) - (when (equal key (car entry)) (setq startline (org-current-line))) - (let ((s (concat (if (member (string-to-char (car entry)) '(?@ ?$)) "" "$") - (car entry) " = " (cdr entry) "\n"))) - (remove-text-properties 0 (length s) '(face nil) s) - (insert s)))) - (when (eq org-table-use-standard-references t) - (org-table-fedit-toggle-ref-type)) - (org-goto-line startline) - (message "Edit formulas, finish with `C-c C-c' or `C-c ' '. \ -See menu for more commands."))) + (let ((at-tblfm (org-at-TBLFM-p))) + (unless (or at-tblfm (org-at-table-p)) + (user-error "Not at a table")) + (save-excursion + ;; Move point within the table before analyzing it. + (when at-tblfm (re-search-backward "^[ \t]*|")) + (org-table-analyze)) + (let ((key (org-table-current-field-formula 'key 'noerror)) + (eql (sort (org-table-get-stored-formulas t (and at-tblfm (point))) + #'org-table-formula-less-p)) + (pos (point-marker)) + (source (copy-marker (line-beginning-position))) + (startline 1) + (wc (current-window-configuration)) + (sel-win (selected-window)) + (titles '((column . "# Column Formulas\n") + (field . "# Field and Range Formulas\n") + (named . "# Named Field Formulas\n")))) + (org-switch-to-buffer-other-window "*Edit Formulas*") + (erase-buffer) + ;; Keep global-font-lock-mode from turning on font-lock-mode + (let ((font-lock-global-modes '(not fundamental-mode))) + (fundamental-mode)) + (setq-local font-lock-global-modes (list 'not major-mode)) + (setq-local org-pos pos) + (setq-local org-table--fedit-source source) + (setq-local org-window-configuration wc) + (setq-local org-selected-window sel-win) + (use-local-map org-table-fedit-map) + (add-hook 'post-command-hook #'org-table-fedit-post-command t t) + (easy-menu-add org-table-fedit-menu) + (setq startline (org-current-line)) + (dolist (entry eql) + (let* ((type (cond + ((string-match "\\`$\\([0-9]+\\|[<>]+\\)\\'" (car entry)) + 'column) + ((equal (string-to-char (car entry)) ?@) 'field) + (t 'named))) + (title (assq type titles))) + (when title + (unless (bobp) (insert "\n")) + (insert + (org-add-props (cdr title) nil 'face font-lock-comment-face)) + (setq titles (remove title titles))) + (when (equal key (car entry)) (setq startline (org-current-line))) + (let ((s (concat + (if (memq (string-to-char (car entry)) '(?@ ?$)) "" "$") + (car entry) " = " (cdr entry) "\n"))) + (remove-text-properties 0 (length s) '(face nil) s) + (insert s)))) + (when (eq org-table-use-standard-references t) + (org-table-fedit-toggle-ref-type)) + (org-goto-line startline) + (message "%s" (substitute-command-keys "\\\ +Edit formulas, finish with `\\[org-ctrl-c-ctrl-c]' or `\\[org-edit-special]'. \ +See menu for more commands."))))) (defun org-table-fedit-post-command () (when (not (memq this-command '(lisp-complete-symbol))) @@ -3681,7 +3753,7 @@ minutes or seconds." (format "%.1f" (/ (float secs0) 60))) ((eq output-format 'seconds) (format "%d" secs0)) - (t (org-format-seconds "%.2h:%.2m:%.2s" secs0))))) + (t (format-seconds "%.2h:%.2m:%.2s" secs0))))) (if (< secs 0) (concat "-" res) res))) (defun org-table-fedit-convert-buffer (function) @@ -3698,7 +3770,7 @@ minutes or seconds." (defun org-table-fedit-toggle-ref-type () "Convert all references in the buffer from B3 to @3$2 and back." (interactive) - (org-set-local 'org-table-buffer-is-an (not org-table-buffer-is-an)) + (setq-local org-table-buffer-is-an (not org-table-buffer-is-an)) (org-table-fedit-convert-buffer (if org-table-buffer-is-an 'org-table-convert-refs-to-an 'org-table-convert-refs-to-rc)) @@ -3794,32 +3866,31 @@ a translation reference." With prefix ARG, apply the new formulas to the table." (interactive "P") (org-table-remove-rectangle-highlight) - (if org-table-use-standard-references - (progn - (org-table-fedit-convert-buffer 'org-table-convert-refs-to-rc) - (setq org-table-buffer-is-an nil))) - (let ((pos org-pos) (sel-win org-selected-window) eql var form) + (when org-table-use-standard-references + (org-table-fedit-convert-buffer 'org-table-convert-refs-to-rc) + (setq org-table-buffer-is-an nil)) + (let ((pos org-pos) + (sel-win org-selected-window) + (source org-table--fedit-source) + eql) (goto-char (point-min)) (while (re-search-forward "^\\(@[-+I<>0-9.$@]+\\|@?[0-9]+\\|\\$\\([a-zA-Z0-9]+\\|[<>]+\\)\\) *= *\\(.*\\(\n[ \t]+.*$\\)*\\)" nil t) - (setq var (if (match-end 2) (match-string 2) (match-string 1)) - form (match-string 3)) - (setq form (org-trim form)) - (when (not (equal form "")) - (while (string-match "[ \t]*\n[ \t]*" form) - (setq form (replace-match " " t t form))) - (when (assoc var eql) - (user-error "Double formulas for %s" var)) - (push (cons var form) eql))) - (setq org-pos nil) + (let ((var (match-string 1)) + (form (org-trim (match-string 3)))) + (unless (equal form "") + (while (string-match "[ \t]*\n[ \t]*" form) + (setq form (replace-match " " t t form))) + (when (assoc var eql) + (user-error "Double formulas for %s" var)) + (push (cons var form) eql)))) (set-window-configuration org-window-configuration) (select-window sel-win) - (goto-char pos) - (unless (org-at-table-p) - (user-error "Lost table position - cannot install formulas")) + (goto-char source) (org-table-store-formulas eql) - (move-marker pos nil) + (set-marker pos nil) + (set-marker source nil) (kill-buffer "*Edit Formulas*") (if arg (org-table-recalculate 'all) @@ -3878,13 +3949,13 @@ With prefix ARG, apply the new formulas to the table." (defvar org-show-positions nil) (defun org-table-show-reference (&optional local) - "Show the location/value of the $ expression at point." + "Show the location/value of the $ expression at point. +When LOCAL is non-nil, show references for the table at point." (interactive) (org-table-remove-rectangle-highlight) (when local (org-table-analyze)) (catch 'exit (let ((pos (if local (point) org-pos)) - (table-start (if local org-table-current-begin-pos (org-table-begin))) (face2 'highlight) (org-inhibit-highlight-removal t) (win (selected-window)) @@ -3912,8 +3983,8 @@ With prefix ARG, apply the new formulas to the table." (when (and match (not (equal (match-beginning 0) (point-at-bol)))) (org-table-add-rectangle-overlay (match-beginning 0) (match-end 0) 'secondary-selection)) - (org-add-hook 'before-change-functions - #'org-table-remove-rectangle-highlight) + (add-hook 'before-change-functions + #'org-table-remove-rectangle-highlight) (when (eq what 'name) (setq var (substring match 1))) (when (eq what 'range) (unless (eq (string-to-char match) ?@) (setq match (concat "@" match))) @@ -3937,73 +4008,75 @@ With prefix ARG, apply the new formulas to the table." (marker-buffer pos))))) (goto-char pos) (org-table-force-dataline) - (when dest - (setq name (substring dest 1)) + (let ((table-start + (if local org-table-current-begin-pos (org-table-begin)))) + (when dest + (setq name (substring dest 1)) + (cond + ((string-match-p "\\`\\$[a-zA-Z][a-zA-Z0-9]*" dest) + (org-table-goto-field dest)) + ((string-match-p "\\`@\\([1-9][0-9]*\\)\\$\\([1-9][0-9]*\\)\\'" + dest) + (org-table-goto-field dest)) + (t (org-table-goto-column (string-to-number name)))) + (move-marker pos (point)) + (org-table-highlight-rectangle nil nil face2)) (cond - ((org-string-match-p "\\`\\$[a-zA-Z][a-zA-Z0-9]*" dest) - (org-table-goto-field dest)) - ((org-string-match-p "\\`@\\([1-9][0-9]*\\)\\$\\([1-9][0-9]*\\)\\'" - dest) - (org-table-goto-field dest)) - (t (org-table-goto-column (string-to-number name)))) - (move-marker pos (point)) - (org-table-highlight-rectangle nil nil face2)) - (cond - ((equal dest match)) - ((not match)) - ((eq what 'range) - (ignore-errors (org-table-get-range match table-start nil 'highlight))) - ((setq e (assoc var org-table-named-field-locations)) - (org-table-goto-field var) - (org-table-highlight-rectangle) - (message "Named field, column %d of line %d" (nth 2 e) (nth 1 e))) - ((setq e (assoc var org-table-column-names)) - (org-table-goto-column (string-to-number (cdr e))) - (org-table-highlight-rectangle) - (goto-char table-start) - (if (re-search-forward (concat "^[ \t]*| *! *.*?| *\\(" var "\\) *|") - (org-table-end) t) - (progn - (goto-char (match-beginning 1)) - (org-table-highlight-rectangle) - (message "Named column (column %s)" (cdr e))) - (user-error "Column name not found"))) - ((eq what 'column) - ;; Column number. - (org-table-goto-column (string-to-number (substring match 1))) - (org-table-highlight-rectangle) - (message "Column %s" (substring match 1))) - ((setq e (assoc var org-table-local-parameters)) - (goto-char table-start) - (if (re-search-forward (concat "^[ \t]*| *\\$ *.*?| *\\(" var "=\\)") nil t) - (progn - (goto-char (match-beginning 1)) - (org-table-highlight-rectangle) - (message "Local parameter.")) - (user-error "Parameter not found"))) - ((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))) - ((setq e (assoc var org-table-formula-constants)) - (message "Constant: $%s=%s in `org-table-formula-constants'." - var (cdr e))) - ((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 (user-error "Undefined name $%s" var))) - (goto-char pos) - (when (and org-show-positions - (not (memq this-command '(org-table-fedit-scroll - org-table-fedit-scroll-down)))) - (push pos org-show-positions) - (push table-start org-show-positions) - (let ((min (apply 'min org-show-positions)) - (max (apply 'max org-show-positions))) - (set-window-start (selected-window) min) - (goto-char max) - (or (pos-visible-in-window-p max) - (set-window-start (selected-window) max)))) + ((equal dest match)) + ((not match)) + ((eq what 'range) + (ignore-errors (org-table-get-range match table-start nil 'highlight))) + ((setq e (assoc var org-table-named-field-locations)) + (org-table-goto-field var) + (org-table-highlight-rectangle) + (message "Named field, column %d of line %d" (nth 2 e) (nth 1 e))) + ((setq e (assoc var org-table-column-names)) + (org-table-goto-column (string-to-number (cdr e))) + (org-table-highlight-rectangle) + (goto-char table-start) + (if (re-search-forward (concat "^[ \t]*| *! *.*?| *\\(" var "\\) *|") + (org-table-end) t) + (progn + (goto-char (match-beginning 1)) + (org-table-highlight-rectangle) + (message "Named column (column %s)" (cdr e))) + (user-error "Column name not found"))) + ((eq what 'column) + ;; Column number. + (org-table-goto-column (string-to-number (substring match 1))) + (org-table-highlight-rectangle) + (message "Column %s" (substring match 1))) + ((setq e (assoc var org-table-local-parameters)) + (goto-char table-start) + (if (re-search-forward (concat "^[ \t]*| *\\$ *.*?| *\\(" var "=\\)") nil t) + (progn + (goto-char (match-beginning 1)) + (org-table-highlight-rectangle) + (message "Local parameter.")) + (user-error "Parameter not found"))) + ((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))) + ((setq e (assoc var org-table-formula-constants)) + (message "Constant: $%s=%s in `org-table-formula-constants'." + var (cdr e))) + ((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 (user-error "Undefined name $%s" var))) + (goto-char pos) + (when (and org-show-positions + (not (memq this-command '(org-table-fedit-scroll + org-table-fedit-scroll-down)))) + (push pos org-show-positions) + (push table-start org-show-positions) + (let ((min (apply 'min org-show-positions)) + (max (apply 'max org-show-positions))) + (set-window-start (selected-window) min) + (goto-char max) + (or (pos-visible-in-window-p max) + (set-window-start (selected-window) max))))) (select-window win)))) (defun org-table-force-dataline () @@ -4097,16 +4170,15 @@ FACE, when non-nil, for the highlight." (goto-char (car start-coordinates))) (add-hook 'before-change-functions #'org-table-remove-rectangle-highlight)) -(defun org-table-remove-rectangle-highlight (&rest ignore) +(defun org-table-remove-rectangle-highlight (&rest _ignore) "Remove the rectangle overlays." (unless org-inhibit-highlight-removal (remove-hook 'before-change-functions 'org-table-remove-rectangle-highlight) (mapc 'delete-overlay org-table-rectangle-overlays) (setq org-table-rectangle-overlays nil))) -(defvar org-table-coordinate-overlays nil +(defvar-local org-table-coordinate-overlays nil "Collects the coordinate grid overlays, so that they can be removed.") -(make-variable-buffer-local 'org-table-coordinate-overlays) (defun org-table-overlay-coordinates () "Add overlays to the table at point, to show row/column coordinates." @@ -4161,19 +4233,20 @@ FACE, when non-nil, for the highlight." ;;; The orgtbl minor mode ;; Define a minor mode which can be used in other modes in order to -;; integrate the org-mode table editor. - -;; This is really a hack, because the org-mode table editor uses several -;; keys which normally belong to the major mode, for example the TAB and -;; RET keys. Here is how it works: The minor mode defines all the keys -;; necessary to operate the table editor, but wraps the commands into a -;; function which tests if the cursor is currently inside a table. If that -;; is the case, the table editor command is executed. However, when any of -;; those keys is used outside a table, the function uses `key-binding' to -;; look up if the key has an associated command in another currently active -;; keymap (minor modes, major mode, global), and executes that command. -;; There might be problems if any of the keys used by the table editor is -;; otherwise used as a prefix key. +;; integrate the Org table editor. + +;; This is really a hack, because the Org table editor uses several +;; keys which normally belong to the major mode, for example the TAB +;; and RET keys. Here is how it works: The minor mode defines all the +;; keys necessary to operate the table editor, but wraps the commands +;; into a function which tests if the cursor is currently inside +;; a table. If that is the case, the table editor command is +;; executed. However, when any of those keys is used outside a table, +;; the function uses `key-binding' to look up if the key has an +;; associated command in another currently active keymap (minor modes, +;; major mode, global), and executes that command. There might be +;; problems if any of the keys used by the table editor 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 @@ -4223,16 +4296,16 @@ FACE, when non-nil, for the highlight." ;; FIXME: maybe it should use emulation-mode-map-alists? (and c (setq minor-mode-map-alist (cons c (delq c minor-mode-map-alist))))) - (org-set-local (quote org-table-may-need-update) t) - (org-add-hook 'before-change-functions 'org-before-change-function - nil 'local) - (org-set-local 'org-old-auto-fill-inhibit-regexp - auto-fill-inhibit-regexp) - (org-set-local 'auto-fill-inhibit-regexp - (if auto-fill-inhibit-regexp - (concat orgtbl-line-start-regexp "\\|" - auto-fill-inhibit-regexp) - orgtbl-line-start-regexp)) + (setq-local org-table-may-need-update t) + (add-hook 'before-change-functions 'org-before-change-function + nil 'local) + (setq-local org-old-auto-fill-inhibit-regexp + auto-fill-inhibit-regexp) + (setq-local auto-fill-inhibit-regexp + (if auto-fill-inhibit-regexp + (concat orgtbl-line-start-regexp "\\|" + auto-fill-inhibit-regexp) + orgtbl-line-start-regexp)) (add-to-invisibility-spec '(org-cwidth)) (when (fboundp 'font-lock-add-keywords) (font-lock-add-keywords nil orgtbl-extra-font-lock-keywords) @@ -4332,27 +4405,26 @@ to execute outside of tables." cmd (orgtbl-make-binding fun nfunc key)) (org-defkey orgtbl-mode-map key cmd)) - ;; Special treatment needed for TAB and RET + ;; Special treatment needed for TAB, RET and DEL (org-defkey orgtbl-mode-map [(return)] (orgtbl-make-binding 'orgtbl-ret 100 [(return)] "\C-m")) (org-defkey orgtbl-mode-map "\C-m" (orgtbl-make-binding 'orgtbl-ret 101 "\C-m" [(return)])) - (org-defkey orgtbl-mode-map [(tab)] (orgtbl-make-binding 'orgtbl-tab 102 [(tab)] "\C-i")) (org-defkey orgtbl-mode-map "\C-i" (orgtbl-make-binding 'orgtbl-tab 103 "\C-i" [(tab)])) - (org-defkey orgtbl-mode-map [(shift tab)] (orgtbl-make-binding 'org-table-previous-field 104 [(shift tab)] [(tab)] "\C-i")) + (org-defkey orgtbl-mode-map [backspace] + (orgtbl-make-binding 'org-delete-backward-char 109 + [backspace] (kbd "DEL"))) - - (unless (featurep 'xemacs) - (org-defkey orgtbl-mode-map [S-iso-lefttab] - (orgtbl-make-binding 'org-table-previous-field 107 - [S-iso-lefttab] [backtab] [(shift tab)] - [(tab)] "\C-i"))) + (org-defkey orgtbl-mode-map [S-iso-lefttab] + (orgtbl-make-binding 'org-table-previous-field 107 + [S-iso-lefttab] [backtab] [(shift tab)] + [(tab)] "\C-i")) (org-defkey orgtbl-mode-map [backtab] (orgtbl-make-binding 'org-table-previous-field 108 @@ -4471,7 +4543,7 @@ With prefix arg, also recompute table." (t (let (orgtbl-mode) (call-interactively (key-binding "\C-c\C-c"))))))) -(defun orgtbl-create-or-convert-from-region (arg) +(defun orgtbl-create-or-convert-from-region (_arg) "Create table or convert region to table, if no conflicting binding. This installs the table binding `C-c |', but only if there is no conflicting binding to this key outside orgtbl-mode." @@ -4515,11 +4587,9 @@ overwritten, and the table is not marked as requiring realignment." (org-table-blank-field)) t) (eq N 1) - (looking-at "[^|\n]* +|")) + (looking-at "[^|\n]* \\( \\)|")) (let (org-table-may-need-update) - (goto-char (1- (match-end 0))) - (org-delete-backward-char 1) - (goto-char (match-beginning 0)) + (delete-region (match-beginning 1) (match-end 1)) (self-insert-command N)) (setq org-table-may-need-update t) (let* (orgtbl-mode @@ -4565,20 +4635,24 @@ a radio table." (beginning-of-line 0))) rtn))) -(defun orgtbl-send-replace-tbl (name txt) - "Find and replace table NAME with TXT." +(defun orgtbl-send-replace-tbl (name text) + "Find and replace table NAME with TEXT." (save-excursion (goto-char (point-min)) - (unless (re-search-forward - (concat "BEGIN +RECEIVE +ORGTBL +" name "\\([ \t]\\|$\\)") nil t) - (user-error "Don't know where to insert translated table")) - (let ((beg (line-beginning-position 2))) - (unless (re-search-forward - (concat "END +RECEIVE +ORGTBL +" name) nil t) - (user-error "Cannot find end of insertion region")) - (beginning-of-line) - (delete-region beg (point))) - (insert txt "\n"))) + (let* ((location-flag nil) + (name (regexp-quote name)) + (begin-re (format "BEGIN +RECEIVE +ORGTBL +%s\\([ \t]\\|$\\)" name)) + (end-re (format "END +RECEIVE +ORGTBL +%s\\([ \t]\\|$\\)" name))) + (while (re-search-forward begin-re nil t) + (unless location-flag (setq location-flag t)) + (let ((beg (line-beginning-position 2))) + (unless (re-search-forward end-re nil t) + (user-error "Cannot find end of receiver location at %d" beg)) + (beginning-of-line) + (delete-region beg (point)) + (insert text "\n"))) + (unless location-flag + (user-error "No valid receiver location found in the buffer"))))) ;;;###autoload (defun org-table-to-lisp (&optional txt) @@ -4603,7 +4677,7 @@ for this table." (catch 'exit (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)) + (when (called-interactively-p 'any) (org-table-align)) (let ((dests (orgtbl-gather-send-defs)) (table (org-table-to-lisp (buffer-substring-no-properties (org-table-begin) @@ -4619,7 +4693,7 @@ for this table." (unless (fboundp transform) (user-error "No such transformation function %s" transform)) (orgtbl-send-replace-tbl name (funcall transform table params))) - (incf ntbl)) + (cl-incf ntbl)) (message "Table converted and installed at %d receiver location%s" ntbl (if (> ntbl 1) "s" "")) (and (> ntbl 0) ntbl)))) @@ -4755,7 +4829,7 @@ strings, or the current cell) returning a string: a property list with column numbers and format strings, or functions, e.g., - \(:fmt (2 \"$%s$\" 4 (lambda (c) (format \"$%s$\" c)))) + (:fmt (2 \"$%s$\" 4 (lambda (c) (format \"$%s$\" c)))) :hlstart :hllstart :hlend :hllend :hsep :hlfmt :hllfmt :hfmt @@ -4772,72 +4846,99 @@ This may be either a string or a function of two arguments: example \"%s\\\\times10^{%s}\". This may also be a property list with column numbers and format strings or functions. :fmt will still be applied after :efmt." - (let ((backend (plist-get params :backend)) - ;; Disable user-defined export filters and hooks. - (org-export-filters-alist nil) - (org-export-before-parsing-hook nil) - (org-export-before-processing-hook nil)) - (when (and backend (symbolp backend) (not (org-export-get-backend backend))) - (user-error "Unknown :backend value")) - (when (or (not backend) (plist-get params :raw)) (require 'ox-org)) - ;; Remove final newline. - (substring - (org-export-string-as - ;; Return TABLE as Org syntax. Tolerate non-string cells. - (with-output-to-string + ;; Make sure `org-export-create-backend' is available. + (require 'ox) + (let* ((backend (plist-get params :backend)) + (custom-backend + ;; Build a custom back-end according to PARAMS. Before + ;; defining a translator, check if there is anything to do. + ;; When there isn't, let BACKEND handle the element. + (org-export-create-backend + :parent (or backend 'org) + :transcoders + `((table . ,(org-table--to-generic-table params)) + (table-row . ,(org-table--to-generic-row params)) + (table-cell . ,(org-table--to-generic-cell params)) + ;; Macros are not going to be expanded. However, no + ;; regular back-end has a transcoder for them. We + ;; provide one so they are not ignored, but displayed + ;; as-is instead. + (macro . (lambda (m c i) (org-element-macro-interpreter m nil)))))) + data info) + ;; Store TABLE as Org syntax in DATA. Tolerate non-string cells. + ;; Initialize communication channel in INFO. + (with-temp-buffer + (let ((org-inhibit-startup t)) (org-mode)) + (let ((standard-output (current-buffer)) + (org-element-use-cache nil)) (dolist (e table) (cond ((eq e 'hline) (princ "|--\n")) ((consp e) (princ "| ") (dolist (c e) (princ c) (princ " |")) (princ "\n"))))) - ;; Build a custom back-end according to PARAMS. Before defining - ;; a translator, check if there is anything to do. When there - ;; isn't, let BACKEND handle the element. - (org-export-create-backend - :parent (or backend 'org) - :filters - '((:filter-parse-tree - ;; Handle :skip parameter. - (lambda (tree backend info) - (let ((skip (plist-get info :skip))) - (when skip - (unless (wholenump skip) (user-error "Wrong :skip value")) - (let ((n 0)) - (org-element-map tree 'table-row - (lambda (row) - (if (>= n skip) t - (org-element-extract-element row) - (incf n) - nil)) - info t)) - tree))) - ;; Handle :skipcols parameter. - (lambda (tree backend info) - (let ((skipcols (plist-get info :skipcols))) - (when skipcols - (unless (consp skipcols) (user-error "Wrong :skipcols value")) - (org-element-map tree 'table - (lambda (table) - (let ((specialp - (org-export-table-has-special-column-p table))) - (dolist (row (org-element-contents table)) - (when (eq (org-element-property :type row) 'standard) - (let ((c 1)) - (dolist (cell (nthcdr (if specialp 1 0) - (org-element-contents row))) - (when (memq c skipcols) - (org-element-extract-element cell)) - (incf c))))))) - info) - tree))))) - :transcoders - `((table . ,(org-table--to-generic-table params)) - (table-row . ,(org-table--to-generic-row params)) - (table-cell . ,(org-table--to-generic-cell params)) - ;; Section. Return contents to avoid garbage around table. - (section . (lambda (s c i) c)))) - 'body-only (org-combine-plists params '(:with-tables t))) - 0 -1))) + ;; Add back-end specific filters, but not user-defined ones. In + ;; particular, make sure to call parse-tree filters on the + ;; table. + (setq info + (let ((org-export-filters-alist nil)) + (org-export-install-filters + (org-combine-plists + (org-export-get-environment backend nil params) + `(:back-end ,(org-export-get-backend backend)))))) + (setq data + (org-export-filter-apply-functions + (plist-get info :filter-parse-tree) + (org-element-map (org-element-parse-buffer) 'table + #'identity nil t) + info))) + (when (and backend (symbolp backend) (not (org-export-get-backend backend))) + (user-error "Unknown :backend value")) + (when (or (not backend) (plist-get info :raw)) (require 'ox-org)) + ;; Handle :skip parameter. + (let ((skip (plist-get info :skip))) + (when skip + (unless (wholenump skip) (user-error "Wrong :skip value")) + (let ((n 0)) + (org-element-map data 'table-row + (lambda (row) + (if (>= n skip) t + (org-element-extract-element row) + (cl-incf n) + nil)) + nil t)))) + ;; Handle :skipcols parameter. + (let ((skipcols (plist-get info :skipcols))) + (when skipcols + (unless (consp skipcols) (user-error "Wrong :skipcols value")) + (org-element-map data 'table + (lambda (table) + (let ((specialp (org-export-table-has-special-column-p table))) + (dolist (row (org-element-contents table)) + (when (eq (org-element-property :type row) 'standard) + (let ((c 1)) + (dolist (cell (nthcdr (if specialp 1 0) + (org-element-contents row))) + (when (memq c skipcols) + (org-element-extract-element cell)) + (cl-incf c)))))))))) + ;; Since we are going to export using a low-level mechanism, + ;; ignore special column and special rows manually. + (let ((special? (org-export-table-has-special-column-p data)) + ignore) + (org-element-map data (if special? '(table-cell table-row) 'table-row) + (lambda (datum) + (when (if (eq (org-element-type datum) 'table-row) + (org-export-table-row-is-special-p datum nil) + (org-export-first-sibling-p datum nil)) + (push datum ignore)))) + (setq info (plist-put info :ignore-list ignore))) + ;; We use a low-level mechanism to export DATA so as to skip all + ;; usual pre-processing and post-processing, i.e., hooks, Babel + ;; code evaluation, include keywords and macro expansion. Only + ;; back-end specific filters are retained. + (let ((output (org-export-data-with-backend data custom-backend info))) + ;; Remove final newline. + (if (org-string-nw-p output) (substring-no-properties output 0 -1) "")))) (defun org-table--generic-apply (value name &optional with-cons &rest args) (cond ((null value) nil) @@ -4893,9 +4994,12 @@ information." ((plist-member params :hline) (org-table--generic-apply (plist-get params :hline) ":hline")) (backend `(org-export-with-backend ',backend row nil info))) - (let ((headerp (org-export-table-row-in-header-p row info)) - (lastp (not (org-export-get-next-element row info))) - (last-header-p (org-export-table-row-ends-header-p row info))) + (let ((headerp ,(and (or hlfmt hlstart hlend) + '(org-export-table-row-in-header-p row info))) + (last-header-p + ,(and (or hllfmt hllstart hllend) + '(org-export-table-row-ends-header-p row info))) + (lastp (not (org-export-get-next-element row info)))) (when contents ;; Check if we can apply `:lfmt', `:llfmt', `:hlfmt', or ;; `:hllfmt' to CONTENTS. Otherwise, fallback on @@ -4972,25 +5076,33 @@ information." (sep (plist-get params :sep)) (hsep (plist-get params :hsep))) `(lambda (cell contents info) - (let ((headerp (org-export-table-row-in-header-p - (org-export-get-parent-element cell) info)) - (column (1+ (cdr (org-export-table-cell-address cell info))))) - ;; Make sure that contents are exported as Org data when :raw - ;; parameter is non-nil. - ,(when (and backend (plist-get params :raw)) - `(setq contents - ;; Since we don't know what are the pseudo object - ;; types defined in backend, we cannot pass them to - ;; `org-element-interpret-data'. As a consequence, - ;; they will be treated as pseudo elements, and - ;; will have newlines appended instead of spaces. - ;; Therefore, we must make sure :post-blank value - ;; is really turned into spaces. - (replace-regexp-in-string - "\n" " " - (org-trim - (org-element-interpret-data - (org-element-contents cell)))))) + ;; Make sure that contents are exported as Org data when :raw + ;; parameter is non-nil. + ,(when (and backend (plist-get params :raw)) + `(setq contents + ;; Since we don't know what are the pseudo object + ;; types defined in backend, we cannot pass them to + ;; `org-element-interpret-data'. As a consequence, + ;; they will be treated as pseudo elements, and will + ;; have newlines appended instead of spaces. + ;; Therefore, we must make sure :post-blank value is + ;; really turned into spaces. + (replace-regexp-in-string + "\n" " " + (org-trim + (org-element-interpret-data + (org-element-contents cell)))))) + + (let ((headerp ,(and (or hfmt hsep) + '(org-export-table-row-in-header-p + (org-export-get-parent-element cell) info))) + (column + ;; Call costly `org-export-table-cell-address' only if + ;; absolutely necessary, i.e., if one + ;; of :fmt :efmt :hmft has a "plist type" value. + ,(and (cl-some (lambda (v) (integerp (car-safe v))) + (list efmt hfmt fmt)) + '(1+ (cdr (org-export-table-cell-address cell info)))))) (when contents ;; Check if we can apply `:efmt' on CONTENTS. ,(when efmt @@ -5123,7 +5235,7 @@ supported. It is also possible to use the following one: params))) (columns (let ((w (plist-get params :columns))) (cond ((not w) nil) - ((org-string-match-p "{\\|@columnfractions " w) w) + ((string-match-p "{\\|@columnfractions " w) w) (t (concat "@columnfractions " w)))))) (if (not columns) output (replace-regexp-in-string @@ -5189,7 +5301,7 @@ supported. It is also possible to use the following ones: params))) ;; Put the cursor in a column containing numerical values -;; of an Org-Mode table, +;; of an Org table, ;; type C-c " a ;; A new column is added with a bar plot. ;; When the table is refreshed (C-u C-c *), @@ -5197,35 +5309,38 @@ supported. It is also possible to use the following ones: (defun orgtbl-ascii-draw (value min max &optional width characters) "Draw an ascii bar in a table. -VALUE is a the value to plot, the width of the bar to draw. A -value equal to MIN will be displayed as empty (zero width bar). -A value equal to MAX will draw a bar filling all the WIDTH. -WIDTH is the expected width in characters of the column. -CHARACTERS is a string that will compose the bar, with shades of -grey from pure white to pure black. It defaults to a 10 -characters string of regular ascii characters." - (let* ((characters (or characters " .:;c!lhVHW")) - (width (or width 12)) - (value (if (numberp value) value (string-to-number value))) - (value (* (/ (- (+ value 0.0) min) (- max min)) width))) - (cond - ((< value 0) "too small") - ((> value width) "too large") - (t - (let ((len (1- (length characters)))) - (concat - (make-string (floor value) (elt characters len)) - (string (elt characters - (floor (* (- value (floor value)) len)))))))))) +VALUE is the value to plot, it determines the width of the bar to draw. +MIN is the value that will be displayed as empty (zero width bar). +MAX is the value that will draw a bar filling all the WIDTH. +WIDTH is the span in characters from MIN to MAX. +CHARACTERS is a string that will compose the bar, with shades of grey +from pure white to pure black. It defaults to a 10 characters string +of regular ascii characters." + (let* ((width (ceiling (or width 12))) + (characters (or characters " .:;c!lhVHW")) + (len (1- (length characters))) + (value (float (if (numberp value) + value (string-to-number value)))) + (relative (/ (- value min) (- max min))) + (steps (round (* relative width len)))) + (cond ((< steps 0) "too small") + ((> steps (* width len)) "too large") + (t (let* ((int-division (/ steps len)) + (remainder (- steps (* int-division len)))) + (concat (make-string int-division (elt characters len)) + (string (elt characters remainder)))))))) ;;;###autoload (defun orgtbl-ascii-plot (&optional ask) - "Draw an ascii bar plot in a column. -With cursor in a column containing numerical values, this -function will draw a plot in a new column. + "Draw an ASCII bar plot in a column. + +With cursor in a column containing numerical values, this function +will draw a plot in a new column. + ASK, if given, is a numeric prefix to override the default 12 -characters width of the plot. ASK may also be the -\\[universal-argument] prefix, which will prompt for the width." +characters width of the plot. ASK may also be the `\\[universal-argument]' \ +prefix, +which will prompt for the width." (interactive "P") (let ((col (org-table-current-column)) (min 1e999) ; 1e999 will be converted to infinity @@ -5253,7 +5368,7 @@ characters width of the plot. ASK may also be the (org-table-store-formulas (cons (cons - (number-to-string (1+ col)) + (concat "$" (number-to-string (1+ col))) (format "'(%s $%s %s %s %s)" "orgtbl-ascii-draw" col min max length)) (org-table-get-stored-formulas))) @@ -5352,34 +5467,27 @@ For example \"remote($1, @>$2)\" => \"remote(year_2013, @>$1)\". This indirection works only with the format @ROW$COLUMN. The format \"B3\" is not supported because it can not be distinguished from a plain table name or ID." - (let ((start 0)) - (while (string-match (concat - ;; Same as in `org-table-eval-formula'. - "\\ ;; Keywords: outlines, hypermedia, calendar, wp @@ -35,7 +35,7 @@ ;;; Code: -(require 'org) +(require 'cl-lib) (require 'org-clock) (declare-function org-agenda-error "org-agenda" ()) @@ -49,7 +49,7 @@ (defvar org-timer-countdown-timer nil "Current countdown timer. This is a timer object if there is an active countdown timer, -'paused' if there is a paused countdown timer, and nil +`paused' if there is a paused countdown timer, and nil otherwise.") (defvar org-timer-countdown-timer-title nil @@ -69,14 +69,14 @@ the value of the timer." "The default timer when a timer is set, in minutes or hh:mm:ss format. When 0, the user is prompted for a value." :group 'org-time - :version "25.1" + :version "26.1" :package-version '(Org . "8.3") :type 'string) (defcustom org-timer-display 'mode-line - "When a timer is running, org-mode can display it in the mode -line and/or frame title. -Allowed values are: + "Define where running timer is displayed, if at all. +When a timer is running, Org can display it in the mode line +and/or frame title. Allowed values are: both displays in both mode line and frame title mode-line displays only in mode line (default) @@ -141,10 +141,10 @@ the region 0:00:00." (setq delta (org-timer-hms-to-secs (org-timer-fix-incomplete s))))) (setq org-timer-start-time (seconds-to-time - ;; Pass `current-time' result to `org-float-time' - ;; (instead of calling without arguments) so that only + ;; Pass `current-time' result to `float-time' (instead + ;; of calling without arguments) so that only ;; `current-time' has to be overriden in tests. - (- (org-float-time (current-time)) delta)))) + (- (float-time (current-time)) delta)))) (setq org-timer-pause-time nil) (org-timer-set-mode-line 'on) (message "Timer start time set to %s, current value is %s" @@ -160,21 +160,20 @@ With prefix arg STOP, stop it entirely." (stop (org-timer-stop)) ((not org-timer-start-time) (error "No timer is running")) (org-timer-pause-time - (let ((start-secs (org-float-time org-timer-start-time)) - (pause-secs (org-float-time org-timer-pause-time))) + (let ((start-secs (float-time org-timer-start-time)) + (pause-secs (float-time org-timer-pause-time))) (if org-timer-countdown-timer - (progn - (let ((new-secs (- start-secs pause-secs))) - (setq org-timer-countdown-timer - (org-timer--run-countdown-timer - new-secs org-timer-countdown-timer-title)) - (setq org-timer-start-time - (time-add (current-time) (seconds-to-time new-secs))))) + (let ((new-secs (- start-secs pause-secs))) + (setq org-timer-countdown-timer + (org-timer--run-countdown-timer + new-secs org-timer-countdown-timer-title)) + (setq org-timer-start-time + (time-add (current-time) (seconds-to-time new-secs)))) (setq org-timer-start-time - ;; Pass `current-time' result to `org-float-time' - ;; (instead of calling without arguments) so that only + ;; Pass `current-time' result to `float-time' (instead + ;; of calling without arguments) so that only ;; `current-time' has to be overriden in tests. - (seconds-to-time (- (org-float-time (current-time)) + (seconds-to-time (- (float-time (current-time)) (- pause-secs start-secs))))) (setq org-timer-pause-time nil) (org-timer-set-mode-line 'on) @@ -184,10 +183,10 @@ With prefix arg STOP, stop it entirely." ;; pause timer (when org-timer-countdown-timer (cancel-timer org-timer-countdown-timer) - (setq org-timer-countdown-timer 'pause)) + (setq org-timer-countdown-timer 'paused)) (run-hooks 'org-timer-pause-hook) (setq org-timer-pause-time (current-time)) - (org-timer-set-mode-line 'pause) + (org-timer-set-mode-line 'paused) (message "Timer paused at %s" (org-timer-value-string))))) (defun org-timer-stop () @@ -205,22 +204,25 @@ With prefix arg STOP, stop it entirely." (message "Timer stopped")) ;;;###autoload -(defun org-timer (&optional restart no-insert-p) +(defun org-timer (&optional restart no-insert) "Insert a H:MM:SS string from the timer into the buffer. -The first time this command is used, the timer is started. When used with -a \\[universal-argument] prefix, force restarting the timer. -When used with a double prefix argument \\[universal-argument], change all the timer string -in the region by a fixed amount. This can be used to recalibrate a timer -that was not started at the correct moment. +The first time this command is used, the timer is started. -If NO-INSERT-P is non-nil, return the string instead of inserting +When used with a `\\[universal-argument]' prefix, force restarting the timer. + +When used with a `\\[universal-argument] \\[universal-argument]' \ +prefix, change all the timer strings +in the region by a fixed amount. This can be used to re-calibrate +a timer that was not started at the correct moment. + +If NO-INSERT is non-nil, return the string instead of inserting it in the buffer." (interactive "P") (if (equal restart '(16)) (org-timer-start restart) (when (or (equal restart '(4)) (not org-timer-start-time)) (org-timer-start)) - (if no-insert-p + (if no-insert (org-timer-value-string) (insert (org-timer-value-string))))) @@ -231,14 +233,14 @@ it in the buffer." (abs (floor (org-timer-seconds)))))) (defun org-timer-seconds () - ;; Pass `current-time' result to `org-float-time' (instead of - ;; calling without arguments) so that only `current-time' has to be + ;; Pass `current-time' result to `float-time' (instead of calling + ;; without arguments) so that only `current-time' has to be ;; overriden in tests. (if org-timer-countdown-timer - (- (org-float-time org-timer-start-time) - (org-float-time (or org-timer-pause-time (current-time)))) - (- (org-float-time (or org-timer-pause-time (current-time))) - (org-float-time org-timer-start-time)))) + (- (float-time org-timer-start-time) + (float-time (or org-timer-pause-time (current-time)))) + (- (float-time (or org-timer-pause-time (current-time))) + (float-time org-timer-start-time)))) ;;;###autoload (defun org-timer-change-times-in-region (beg end delta) @@ -332,7 +334,7 @@ If the integer is negative, the string will start with \"-\"." (defun org-timer-set-mode-line (value) "Set the mode-line display for relative or countdown timer. -VALUE can be `on', `off', or `pause'." +VALUE can be `on', `off', or `paused'." (when (or (eq org-timer-display 'mode-line) (eq org-timer-display 'both)) (or global-mode-string (setq global-mode-string '(""))) @@ -344,43 +346,43 @@ VALUE can be `on', `off', or `pause'." (or (memq 'org-timer-mode-line-string frame-title-format) (setq frame-title-format (append frame-title-format '(org-timer-mode-line-string))))) - (cond - ((equal value 'off) - (when org-timer-mode-line-timer - (cancel-timer org-timer-mode-line-timer) - (setq org-timer-mode-line-timer nil)) - (when (or (eq org-timer-display 'mode-line) - (eq org-timer-display 'both)) - (setq global-mode-string - (delq 'org-timer-mode-line-string global-mode-string))) - (when (or (eq org-timer-display 'frame-title) - (eq org-timer-display 'both)) - (setq frame-title-format - (delq 'org-timer-mode-line-string frame-title-format))) - (force-mode-line-update)) - ((equal value 'pause) - (when org-timer-mode-line-timer - (cancel-timer org-timer-mode-line-timer) - (setq org-timer-mode-line-timer nil))) - ((equal value 'on) - (when (or (eq org-timer-display 'mode-line) - (eq org-timer-display 'both)) - (or global-mode-string (setq global-mode-string '(""))) - (or (memq 'org-timer-mode-line-string global-mode-string) - (setq global-mode-string - (append global-mode-string '(org-timer-mode-line-string))))) - (when (or (eq org-timer-display 'frame-title) - (eq org-timer-display 'both)) - (or (memq 'org-timer-mode-line-string frame-title-format) - (setq frame-title-format - (append frame-title-format '(org-timer-mode-line-string))))) - (org-timer-update-mode-line) - (when org-timer-mode-line-timer - (cancel-timer org-timer-mode-line-timer) - (setq org-timer-mode-line-timer nil)) - (when org-timer-display - (setq org-timer-mode-line-timer - (run-with-timer 1 1 'org-timer-update-mode-line)))))) + (cl-case value + (off + (when org-timer-mode-line-timer + (cancel-timer org-timer-mode-line-timer) + (setq org-timer-mode-line-timer nil)) + (when (or (eq org-timer-display 'mode-line) + (eq org-timer-display 'both)) + (setq global-mode-string + (delq 'org-timer-mode-line-string global-mode-string))) + (when (or (eq org-timer-display 'frame-title) + (eq org-timer-display 'both)) + (setq frame-title-format + (delq 'org-timer-mode-line-string frame-title-format))) + (force-mode-line-update)) + (paused + (when org-timer-mode-line-timer + (cancel-timer org-timer-mode-line-timer) + (setq org-timer-mode-line-timer nil))) + (on + (when (or (eq org-timer-display 'mode-line) + (eq org-timer-display 'both)) + (or global-mode-string (setq global-mode-string '(""))) + (or (memq 'org-timer-mode-line-string global-mode-string) + (setq global-mode-string + (append global-mode-string '(org-timer-mode-line-string))))) + (when (or (eq org-timer-display 'frame-title) + (eq org-timer-display 'both)) + (or (memq 'org-timer-mode-line-string frame-title-format) + (setq frame-title-format + (append frame-title-format '(org-timer-mode-line-string))))) + (org-timer-update-mode-line) + (when org-timer-mode-line-timer + (cancel-timer org-timer-mode-line-timer) + (setq org-timer-mode-line-timer nil)) + (when org-timer-display + (setq org-timer-mode-line-timer + (run-with-timer 1 1 'org-timer-update-mode-line)))))) (defun org-timer-update-mode-line () "Update the timer time in the mode line." @@ -435,10 +437,10 @@ using three `C-u' prefix arguments." (number-to-string org-timer-default-timer) org-timer-default-timer)) (effort-minutes (ignore-errors (org-get-at-eol 'effort-minutes 1))) - (minutes (or (and (not (equal opt '(64))) + (minutes (or (and (numberp opt) (number-to-string opt)) + (and (not (equal opt '(64))) effort-minutes (number-to-string effort-minutes)) - (and (numberp opt) (number-to-string opt)) (and (consp opt) default-timer) (and (stringp opt) opt) (read-from-minibuffer @@ -448,25 +450,23 @@ using three `C-u' prefix arguments." (setq minutes (concat minutes ":00"))) (if (not (string-match "[0-9]+" minutes)) (org-timer-show-remaining-time) - (let ((secs (org-timer-hms-to-secs (org-timer-fix-incomplete minutes))) - (hl (org-timer--get-timer-title))) - (if (or (not org-timer-countdown-timer) - (equal opt '(16)) - (y-or-n-p "Replace current timer? ")) - (progn - (when (timerp org-timer-countdown-timer) - (cancel-timer org-timer-countdown-timer)) - (setq org-timer-countdown-timer-title - (org-timer--get-timer-title)) - (setq org-timer-countdown-timer - (org-timer--run-countdown-timer - secs org-timer-countdown-timer-title)) - (run-hooks 'org-timer-set-hook) - (setq org-timer-start-time - (time-add (current-time) (seconds-to-time secs))) - (setq org-timer-pause-time nil) - (org-timer-set-mode-line 'on)) - (message "No timer set")))))) + (let ((secs (org-timer-hms-to-secs (org-timer-fix-incomplete minutes)))) + (if (and org-timer-countdown-timer + (not (or (equal opt '(16)) + (y-or-n-p "Replace current timer? ")))) + (message "No timer set") + (when (timerp org-timer-countdown-timer) + (cancel-timer org-timer-countdown-timer)) + (setq org-timer-countdown-timer-title + (org-timer--get-timer-title)) + (setq org-timer-countdown-timer + (org-timer--run-countdown-timer + secs org-timer-countdown-timer-title)) + (run-hooks 'org-timer-set-hook) + (setq org-timer-start-time + (time-add (current-time) (seconds-to-time secs))) + (setq org-timer-pause-time nil) + (org-timer-set-mode-line 'on)))))) (defun org-timer--run-countdown-timer (secs title) "Start countdown timer that will last SECS. diff --git a/elpa/org-plus-contrib-20150831/org-toc.el b/elpa/org-plus-contrib-20170407/org-toc.el similarity index 99% rename from elpa/org-plus-contrib-20150831/org-toc.el rename to elpa/org-plus-contrib-20170407/org-toc.el index 622cc028..8b4c36c6 100644 --- a/elpa/org-plus-contrib-20150831/org-toc.el +++ b/elpa/org-plus-contrib-20170407/org-toc.el @@ -1,6 +1,6 @@ ;;; org-toc.el --- Table of contents for Org-mode buffer -;; Copyright 2007-2014 Free Software Foundation, Inc. +;; Copyright 2007-2017 Free Software Foundation, Inc. ;; ;; Author: Bastien Guerry ;; Keywords: Org table of contents @@ -197,7 +197,7 @@ specified, then make `org-toc-recenter' use this value." (setq ov (make-overlay beg end))) ;; change the folding status of this headline (cond ((or (null status) (eq status 'folded)) - (show-children) + (org-show-children) (message "CHILDREN") (overlay-put ov 'status 'children)) ((eq status 'children) @@ -441,7 +441,7 @@ current table of contents to it." (setq ov (make-overlay (match-beginning 0) (match-end 0)))) (cond ((eq (cdr hlcfg0) 'children) - (show-children) + (org-show-children) (message "CHILDREN") (overlay-put ov 'status 'children)) ((eq (cdr hlcfg0) 'branches) diff --git a/elpa/org-plus-contrib-20150831/org-track.el b/elpa/org-plus-contrib-20170407/org-track.el similarity index 99% rename from elpa/org-plus-contrib-20150831/org-track.el rename to elpa/org-plus-contrib-20170407/org-track.el index 434060b6..36724dec 100644 --- a/elpa/org-plus-contrib-20150831/org-track.el +++ b/elpa/org-plus-contrib-20170407/org-track.el @@ -1,7 +1,6 @@ ;;; org-track.el --- Track the most recent Org-mode version available. ;; -;; Copyright (C) 2009-2014 -;; Free Software Foundation, Inc. +;; Copyright (C) 2009-2017 Free Software Foundation, Inc. ;; ;; Author: Bastien Guerry ;; Eric S Fraga diff --git a/elpa/org-plus-contrib-20150831/org-velocity.el b/elpa/org-plus-contrib-20170407/org-velocity.el similarity index 68% rename from elpa/org-plus-contrib-20150831/org-velocity.el rename to elpa/org-plus-contrib-20170407/org-velocity.el index a7820f18..bfc4d6c3 100644 --- a/elpa/org-plus-contrib-20150831/org-velocity.el +++ b/elpa/org-plus-contrib-20170407/org-velocity.el @@ -4,7 +4,7 @@ ;; Author: Paul M. Rodriguez ;; Created: 2010-05-05 -;; Version: 4.0 +;; Version: 4.1 ;; This file is not part of GNU Emacs. @@ -78,12 +78,6 @@ :group 'org-velocity :type 'file) -(defcustom org-velocity-search-is-incremental t - "Show results incrementally when possible?" - :group 'org-velocity - :type 'boolean - :safe 'booleanp) - (defcustom org-velocity-show-previews t "Show previews of the text of each heading?" :group 'velocity @@ -168,20 +162,27 @@ See the documentation for `org-capture-templates'." The length of the preview is determined by `window-width'. Replace all contiguous whitespace with single spaces." - (let ((start (progn - (forward-line 1) - (if (looking-at org-property-start-re) - (re-search-forward org-property-end-re) - (1- (point)))))) - (mapconcat - #'identity - (split-string - (buffer-substring-no-properties - start - (min - (+ start (window-width)) - (point-max)))) - " "))) + (let* ((start (progn + (forward-line 1) + (if (looking-at org-property-start-re) + (re-search-forward org-property-end-re) + (1- (point))))) + (string+props (buffer-substring + start + (min + (+ start (window-width)) + (point-max))))) + ;; We want to preserve the text properties so that, for example, + ;; we don't end up with the raw text of links in the preview. + (with-temp-buffer + (insert string+props) + (goto-char (point-min)) + (save-match-data + (while (re-search-forward split-string-default-separators + (point-max) + t) + (replace-match " "))) + (buffer-string)))) (cl-defstruct org-velocity-heading buffer position name level preview) @@ -233,9 +234,16 @@ of the base buffer; in the latter, return the file name of (defun org-velocity-minibuffer-contents () "Return the contents of the minibuffer when it is active." - (if (active-minibuffer-window) - (with-current-buffer (window-buffer (active-minibuffer-window)) - (minibuffer-contents)))) + (when (active-minibuffer-window) + (with-current-buffer (window-buffer (active-minibuffer-window)) + (minibuffer-contents)))) + +(defun org-velocity-nix-minibuffer () + "Return the contents of the minibuffer and clear it." + (when (active-minibuffer-window) + (with-current-buffer (window-buffer (active-minibuffer-window)) + (prog1 (minibuffer-contents) + (delete-minibuffer-contents))))) (defun org-velocity-bucket-file () "Return the proper file for Org-Velocity to search. @@ -259,6 +267,7 @@ use it." (error "No bucket and not an Org file")))))) (defvar org-velocity-bucket-buffer nil) +(defvar org-velocity-navigating nil) (defsubst org-velocity-bucket-buffer () (or org-velocity-bucket-buffer @@ -271,9 +280,6 @@ use it." (defsubst org-velocity-match-window () (get-buffer-window (org-velocity-match-buffer))) -(defsubst org-velocity-match-staging-buffer () - (get-buffer-create " Velocity matches")) - (defun org-velocity-beginning-of-headings () "Goto the start of the first heading." (goto-char (point-min)) @@ -310,29 +316,47 @@ use it." (make-variable-buffer-local 'org-velocity-saved-winconf) (defun org-velocity-edit-entry (heading) + (if org-velocity-navigating + (org-velocity-edit-entry/inline heading) + (org-velocity-edit-entry/indirect heading))) + +(cl-defun org-velocity-goto-entry (heading &key narrow) + (goto-char (org-velocity-heading-position heading)) + (save-excursion + (when narrow + (org-narrow-to-subtree)) + (outline-show-all))) + +(defun org-velocity-edit-entry/inline (heading) + "Edit entry at HEADING in the original buffer." + (let ((buffer (org-velocity-heading-buffer heading))) + (pop-to-buffer buffer) + (with-current-buffer buffer + (org-velocity-goto-entry heading)))) + +(defun org-velocity-format-header-line (control-string &rest args) + (set (make-local-variable 'header-line-format) + (apply #'format control-string args))) + +(defun org-velocity-edit-entry/indirect (heading) "Edit entry at HEADING in an indirect buffer." (let ((winconf (current-window-configuration)) + (dd default-directory) (buffer (org-velocity-make-indirect-buffer heading)) (inhibit-point-motion-hooks t) (inhibit-field-text-motion t)) (with-current-buffer buffer + (setq default-directory dd) ;Inherit default directory. (setq org-velocity-saved-winconf winconf) - (goto-char (org-velocity-heading-position heading)) - (let ((start (point)) - (end (save-excursion - (org-end-of-subtree t) - (point)))) - ;; Outline view and narrow-to-region interact poorly. - (outline-flag-region start end nil) - (narrow-to-region start end)) + (org-velocity-goto-entry heading :narrow t) (goto-char (point-max)) (add-hook 'org-ctrl-c-ctrl-c-hook 'org-velocity-dismiss nil t)) (pop-to-buffer buffer) - (set (make-local-variable 'header-line-format) - (format "%s Use C-c C-c to finish." - (abbreviate-file-name - (buffer-file-name - (org-velocity-heading-buffer heading))))))) + (org-velocity-format-header-line + "%s Use C-c C-c to finish." + (abbreviate-file-name + (buffer-file-name + (org-velocity-heading-buffer heading)))))) (defun org-velocity-dismiss () "Save current entry and close indirect buffer." @@ -350,9 +374,7 @@ use it." (button-get button 'search) search-ring-max)) (let ((match (button-get button 'match))) - (throw 'org-velocity-done - (lambda () - (org-velocity-edit-entry match))))) + (throw 'org-velocity-done match))) (define-button-type 'org-velocity-button 'action #'org-velocity-visit-button @@ -374,57 +396,113 @@ use it." (org-velocity-heading-preview heading) 'face 'shadow)))) +(defvar org-velocity-recursive-headings nil) +(defvar org-velocity-recursive-search nil) + +(cl-defun org-velocity-search-with (fun style search + &key (headings org-velocity-recursive-headings)) + (if headings + (save-restriction + (dolist (heading headings) + (widen) + (let ((start (org-velocity-heading-position heading))) + (goto-char start) + (let ((end (save-excursion + (org-end-of-subtree) + (point)))) + (narrow-to-region start end) + (org-velocity-search-with fun style search + :headings nil))))) + (cl-ecase style + ((phrase any regexp) + (cl-block nil + (while (re-search-forward search nil t) + (let ((match (org-velocity-nearest-heading (point)))) + (funcall fun match)) + ;; Skip to the next heading. + (unless (re-search-forward (org-velocity-heading-regexp) nil t) + (cl-return))))) + ((all) + (let ((keywords + (cl-loop for word in (split-string search) + collect (concat "\\<" (regexp-quote word) "\\>")))) + (org-map-entries + (lambda () + ;; Only search the subtree once. + (setq org-map-continue-from + (save-excursion + (org-end-of-subtree) + (point))) + (when (cl-loop for word in keywords + always (save-excursion + (re-search-forward word org-map-continue-from t))) + (let ((match (org-velocity-nearest-heading (match-end 0)))) + (funcall fun match)))))))))) + +(defun org-velocity-all-results (style search) + (with-current-buffer (org-velocity-bucket-buffer) + (save-excursion + (goto-char (point-min)) + (let (matches) + (org-velocity-search-with (lambda (match) + (push match matches)) + style + search) + (nreverse matches))))) + (defsubst org-velocity-present-match (hint match) - (with-current-buffer (org-velocity-match-staging-buffer) + (with-current-buffer (org-velocity-match-buffer) (when hint (insert "#" hint " ")) (org-velocity-buttonize match) (org-velocity-insert-preview match) (newline))) -(defun org-velocity-generic-search (search &optional hide-hints) - "Display any entry containing SEARCH." +(defun org-velocity-present-search (style search hide-hints) (let ((hints org-velocity-index) matches) (cl-block nil - (while (and hints (re-search-forward search nil t)) - (let ((match (org-velocity-nearest-heading (point)))) - (org-velocity-present-match - (unless hide-hints (car hints)) - match) - (push match matches)) - (setq hints (cdr hints)) - (unless (re-search-forward (org-velocity-heading-regexp) nil t) - (return)))) + (org-velocity-search-with (lambda (match) + (unless hints + (cl-return)) + (let ((hint (if hide-hints + nil + (car hints)))) + (org-velocity-present-match hint match)) + (pop hints) + (push match matches)) + style + search)) (nreverse matches))) -(cl-defun org-velocity-all-search (search &optional hide-hints) - "Display only entries containing every word in SEARCH." - (let ((keywords (mapcar 'regexp-quote (split-string search))) - (hints org-velocity-index) - matches) - (org-map-entries - (lambda () - ;; Return if we've run out of hints. - (when (null hints) - (return-from org-velocity-all-search (nreverse matches))) - ;; Only search the subtree once. - (setq org-map-continue-from - (save-excursion - (goto-char (line-end-position)) - (if (re-search-forward (org-velocity-heading-regexp) nil t) - (line-end-position) - (point-max)))) - (when (cl-loop for word in keywords - always (save-excursion - (re-search-forward - (concat "\\<" word "\\>") - org-map-continue-from t))) - (let ((match (org-velocity-nearest-heading (match-end 0)))) - (org-velocity-present-match - (unless hide-hints (car hints)) - match) - (push match matches) - (setq hints (cdr hints)))))) - (nreverse matches))) +(defun org-velocity-restrict-search () + (interactive) + (let ((search (org-velocity-nix-minibuffer))) + (when (equal search "") + (error "No search to restrict to")) + (push search org-velocity-recursive-search) + (setq org-velocity-recursive-headings + (org-velocity-all-results + org-velocity-search-method + search)) + ;; TODO We could extend the current search instead of starting + ;; over. + (org-velocity-update-match-header) + (minibuffer-message "Restricting search to %s" search))) + +(cl-defun org-velocity-update-match-header (&key (match-buffer (org-velocity-match-buffer)) + (bucket-buffer (org-velocity-bucket-buffer)) + (search-method org-velocity-search-method)) + (let ((navigating? org-velocity-navigating) + (recursive? org-velocity-recursive-search)) + (with-current-buffer match-buffer + (org-velocity-format-header-line + "%s search in %s%s (%s mode)" + (capitalize (symbol-name search-method)) + (abbreviate-file-name (buffer-file-name bucket-buffer)) + (if (not recursive?) + "" + (let ((sep " > ")) + (concat sep (string-join (reverse recursive?) sep)))) + (if navigating? "nav" "notes"))))) (cl-defun org-velocity-present (search &key hide-hints) "Buttonize matches for SEARCH in `org-velocity-match-buffer'. @@ -432,40 +510,49 @@ If HIDE-HINTS is non-nil, display entries without indices. SEARCH binds `org-velocity-search'. Return matches." - (if (and (stringp search) (not (string= "" search))) - ;; Fold case when the search string is all lowercase. - (let ((case-fold-search (equal search (downcase search))) - (truncate-partial-width-windows t)) - (with-current-buffer (org-velocity-match-buffer) - (erase-buffer) - ;; Permanent locals. - (setq cursor-type nil - truncate-lines t)) - (prog1 - (with-current-buffer (org-velocity-bucket-buffer) - (let ((inhibit-point-motion-hooks t) - (inhibit-field-text-motion t)) - (save-excursion - (org-velocity-beginning-of-headings) - (cl-case org-velocity-search-method - (all (org-velocity-all-search search hide-hints)) - (phrase (org-velocity-generic-search - (concat "\\<" (regexp-quote search)) - hide-hints)) - (any (org-velocity-generic-search - (concat "\\<" - (regexp-opt (split-string search))) - hide-hints)) - (regexp (condition-case lossage - (org-velocity-generic-search - search hide-hints) - (invalid-regexp - (minibuffer-message "%s" lossage)))))))) - (with-current-buffer (org-velocity-match-buffer) - (buffer-swap-text (org-velocity-match-staging-buffer)) - (goto-char (point-min))))) - (with-current-buffer (org-velocity-match-buffer) - (erase-buffer)))) + (let ((match-buffer (org-velocity-match-buffer)) + (bucket-buffer (org-velocity-bucket-buffer)) + (search-method org-velocity-search-method)) + (if (and (stringp search) (not (string= "" search))) + ;; Fold case when the search string is all lowercase. + (let ((case-fold-search (equal search (downcase search))) + (truncate-partial-width-windows t)) + (with-current-buffer match-buffer + (erase-buffer) + ;; Permanent locals. + (setq cursor-type nil + truncate-lines t) + (org-velocity-update-match-header + :match-buffer match-buffer + :bucket-buffer bucket-buffer + :search-method search-method)) + (prog1 + (with-current-buffer bucket-buffer + (widen) + (let* ((inhibit-point-motion-hooks t) + (inhibit-field-text-motion t) + (anchored? (string-match-p "^\\s-" search)) + (search + (cl-ecase search-method + (all search) + (phrase + (if anchored? + (regexp-quote search) + ;; Anchor the search to the start of a word. + (concat "\\<" (regexp-quote search)))) + (any + (concat "\\<" (regexp-opt (split-string search)))) + (regexp search)))) + (save-excursion + (org-velocity-beginning-of-headings) + (condition-case lossage + (org-velocity-present-search search-method search hide-hints) + (invalid-regexp + (minibuffer-message "%s" lossage)))))) + (with-current-buffer match-buffer + (goto-char (point-min))))) + (with-current-buffer match-buffer + (erase-buffer))))) (defun org-velocity-store-link () "Function for `org-store-link-functions'." @@ -603,7 +690,7 @@ If ASK is non-nil, ask first." (matches (org-velocity-present search :hide-hints t))) (cond ((null matches) (select-window (active-minibuffer-window)) - (unless (or (null search) (string= "" search)) + (unless (or (null search) (= (length search) 0)) (minibuffer-message "No match; RET to create"))) ((and (null (cdr matches)) org-velocity-exit-on-match) @@ -625,7 +712,10 @@ If ASK is non-nil, ask first." (let ((map (make-sparse-keymap))) (set-keymap-parent map minibuffer-local-completion-map) (define-key map " " 'self-insert-command) + (define-key map "?" 'self-insert-command) (define-key map [remap minibuffer-complete] 'minibuffer-complete-word) + (define-key map [(control ?@)] 'org-velocity-restrict-search) + (define-key map [(control ?\s)] 'org-velocity-restrict-search) map) "Keymap for completion with `completing-read'.") @@ -635,30 +725,9 @@ If ASK is non-nil, ask first." org-velocity-local-completion-map) (completion-no-auto-exit t) (crm-separator " ")) - (funcall - (cl-case org-velocity-search-method - (phrase #'completing-read) - (any #'completing-read-multiple) - (all #'completing-read-multiple)) - prompt - (completion-table-dynamic - 'org-velocity-dabbrev-completion-list)))) - -(defun org-velocity-read-string (prompt &optional initial-input) - "Read string with PROMPT followed by INITIAL-INPUT." - ;; The use of initial inputs to the minibuffer is deprecated (see - ;; `read-from-minibuffer'), but in this case it is the user-friendly - ;; thing to do. - (minibuffer-with-setup-hook - (let ((initial-input initial-input)) - (lambda () - (and initial-input (insert initial-input)) - (goto-char (point-max)))) - (if (eq org-velocity-search-method 'regexp) - (read-regexp prompt) - (if org-velocity-use-completion - (org-velocity-read-with-completion prompt) - (read-string prompt))))) + (completing-read prompt + (completion-table-dynamic + 'org-velocity-dabbrev-completion-list)))) (cl-defun org-velocity-adjust-index (&optional (match-window (org-velocity-match-window))) @@ -719,18 +788,28 @@ then the current file is used instead, and vice versa." arg))) ;; complain if inappropriate (cl-assert (org-velocity-bucket-file)) - (let ((org-velocity-bucket-buffer - (find-file-noselect (org-velocity-bucket-file)))) + (let* ((starting-buffer (current-buffer)) + (org-velocity-bucket-buffer + (find-file-noselect (org-velocity-bucket-file))) + (org-velocity-navigating + (eq starting-buffer org-velocity-bucket-buffer)) + (org-velocity-recursive-headings '()) + (org-velocity-recursive-search '()) + (org-velocity-heading-level + (if org-velocity-navigating + 0 + org-velocity-heading-level)) + (dabbrev-search-these-buffers-only + (list org-velocity-bucket-buffer))) (unwind-protect - (let ((dabbrev-search-these-buffers-only - (list (org-velocity-bucket-buffer)))) - (funcall - (catch 'org-velocity-done - (org-velocity-engine - (if org-velocity-search-is-incremental - (org-velocity-incremental-read "Velocity search: ") - (org-velocity-read-string "Velocity search: " search))) - #'ignore))) + (let ((match + (catch 'org-velocity-done + (org-velocity-engine + (or search + (org-velocity-incremental-read "Velocity search: "))) + nil))) + (when (org-velocity-heading-p match) + (org-velocity-edit-entry match))) (kill-buffer (org-velocity-match-buffer)))))) (defalias 'org-velocity-read 'org-velocity) diff --git a/elpa/org-plus-contrib-20150831/org-version.el b/elpa/org-plus-contrib-20170407/org-version.el similarity index 65% rename from elpa/org-plus-contrib-20150831/org-version.el rename to elpa/org-plus-contrib-20170407/org-version.el index 234905fd..ad22b757 100644 --- a/elpa/org-plus-contrib-20150831/org-version.el +++ b/elpa/org-plus-contrib-20170407/org-version.el @@ -3,15 +3,15 @@ ;;; Code: ;;;###autoload (defun org-release () - "The release version of org-mode. - Inserted by installing org-mode or when a release is made." - (let ((org-release "8.3.1")) + "The release version of Org. +Inserted by installing Org mode or when a release is made." + (let ((org-release "9.0.5")) 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 "8.3.1-95-g1dbb25-elpaplus")) +Inserted by installing Org or when a release is made." + (let ((org-git-version "9.0.5-436-g8ba336.dirty-elpaplus")) org-git-version)) ;;;###autoload (defvar org-odt-data-dir "/usr/share/emacs/etc/org" diff --git a/elpa/org-plus-contrib-20150831/org-vm.el b/elpa/org-plus-contrib-20170407/org-vm.el similarity index 88% rename from elpa/org-plus-contrib-20150831/org-vm.el rename to elpa/org-plus-contrib-20170407/org-vm.el index 5d30f647..4deca8fb 100644 --- a/elpa/org-plus-contrib-20150831/org-vm.el +++ b/elpa/org-plus-contrib-20170407/org-vm.el @@ -1,6 +1,6 @@ ;;; org-vm.el --- Support for links to VM messages from within Org-mode -;; Copyright (C) 2004-2014 Free Software Foundation, Inc. +;; Copyright (C) 2004-2017 Free Software Foundation, Inc. ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp @@ -55,9 +55,8 @@ (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) +(org-link-set-parameters "vm" :follow #'org-vm-open :store #'org-vm-store-link) +(org-link-set-parameters "vm-imap" :follow #'org-vm-imap-open) ;; Implementation (defun org-vm-store-link () @@ -77,12 +76,6 @@ (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)))) @@ -93,12 +86,9 @@ (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)) + (setq message-id (org-unbracket-string "<" ">" 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)) + :message-id message-id :date date) (setq desc (org-email-link-description)) (setq link (concat (concat link-type ":") folder "#" message-id)) (org-add-link-props :link link :description desc) @@ -126,12 +116,10 @@ (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)))) + (setq folder (format "/%s@%s:%s" user host file))) (t ;; use ange-ftp or efs - (require (if (featurep 'xemacs) 'efs 'ange-ftp)) + (require 'ange-ftp) (setq folder (format "/%s@%s:%s" user host file)))))) (when folder (funcall (cdr (assq 'vm org-link-frame-setup)) folder readonly) diff --git a/elpa/org-plus-contrib-20150831/org-w3m.el b/elpa/org-plus-contrib-20170407/org-w3m.el similarity index 93% rename from elpa/org-plus-contrib-20150831/org-w3m.el rename to elpa/org-plus-contrib-20170407/org-w3m.el index 24693de8..e9bbeff3 100644 --- a/elpa/org-plus-contrib-20150831/org-w3m.el +++ b/elpa/org-plus-contrib-20170407/org-w3m.el @@ -1,6 +1,6 @@ -;;; org-w3m.el --- Support from copy and paste from w3m to Org-mode +;;; org-w3m.el --- Support from Copy and Paste From w3m -*- lexical-binding: t; -*- -;; Copyright (C) 2008-2015 Free Software Foundation, Inc. +;; Copyright (C) 2008-2017 Free Software Foundation, Inc. ;; Author: Andy Stewart ;; Keywords: outlines, hypermedia, calendar, wp @@ -25,9 +25,9 @@ ;;; Commentary: ;; This file implements copying HTML content from a w3m buffer and -;; transforming the text on the fly so that it can be pasted into -;; an org-mode buffer with hot links. It will also work for regions -;; in gnus buffers that have been washed with w3m. +;; transforming the text on the fly so that it can be pasted into an +;; Org buffer with hot links. It will also work for regions in gnus +;; buffers that have been washed with w3m. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; @@ -35,7 +35,7 @@ ;; Richard Riley ;; -;; The idea of transforming the HTML content with org-mode style is +;; The idea of transforming the HTML content with Org syntax is ;; proposed by Richard, I'm just coding it. ;; @@ -46,7 +46,7 @@ (defvar w3m-current-url) (defvar w3m-current-title) -(add-hook 'org-store-link-functions 'org-w3m-store-link) +(org-link-set-parameters "w3m" :store #'org-w3m-store-link) (defun org-w3m-store-link () "Store a link to a w3m buffer." (when (eq major-mode 'w3m-mode) @@ -60,7 +60,7 @@ "Copy current buffer content or active region with `org-mode' style links. This will encode `link-title' and `link-location' with `org-make-link-string', and insert the transformed test into the kill ring, -so that it can be yanked into an Org-mode buffer with links working correctly." +so that it can be yanked into an Org buffer with links working correctly." (interactive) (let* ((regionp (org-region-active-p)) (transform-start (point-min)) @@ -107,7 +107,7 @@ so that it can be yanked into an Org-mode buffer with links working correctly." (concat return-content (buffer-substring (point) transform-end)))) (org-kill-new return-content) - (message "Transforming links...done, use C-y to insert text into Org-mode file") + (message "Transforming links...done, use C-y to insert text into Org file") (message "Copy with link transformation complete.")))) (defun org-w3m-get-anchor-start () diff --git a/elpa/org-plus-contrib-20150831/org-wikinodes.el b/elpa/org-plus-contrib-20170407/org-wikinodes.el similarity index 99% rename from elpa/org-plus-contrib-20150831/org-wikinodes.el rename to elpa/org-plus-contrib-20170407/org-wikinodes.el index ff2d55ae..53f7e2b6 100644 --- a/elpa/org-plus-contrib-20150831/org-wikinodes.el +++ b/elpa/org-plus-contrib-20170407/org-wikinodes.el @@ -1,6 +1,6 @@ ;;; org-wikinodes.el --- Wiki-like CamelCase links to outline nodes -;; Copyright (C) 2010-2014 Free Software Foundation, Inc. +;; Copyright (C) 2010-2017 Free Software Foundation, Inc. ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp @@ -203,7 +203,7 @@ setting of `org-wikinodes-create-targets'." (widen) (goto-char (point-min)) (while (re-search-forward re nil t) - (push (org-match-string-no-properties 4) targets)))) + (push (match-string-no-properties 4) targets)))) (nreverse targets))) (defun org-wikinodes-get-links-for-directory (dir) diff --git a/elpa/org-plus-contrib-20150831/org-wl.el b/elpa/org-plus-contrib-20170407/org-wl.el similarity index 94% rename from elpa/org-plus-contrib-20150831/org-wl.el rename to elpa/org-plus-contrib-20170407/org-wl.el index 632c9e37..4f74d479 100644 --- a/elpa/org-plus-contrib-20150831/org-wl.el +++ b/elpa/org-plus-contrib-20170407/org-wl.el @@ -1,6 +1,6 @@ ;;; org-wl.el --- Support for links to Wanderlust messages from within Org-mode -;; Copyright (C) 2004-2014 Free Software Foundation, Inc. +;; Copyright (C) 2004-2017 Free Software Foundation, Inc. ;; Author: Tokuya Kameshima ;; David Maus @@ -109,8 +109,7 @@ googlegroups otherwise." "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) +(org-link-set-parameters "wl" :follow #'org-wl-open :store #'org-wl-store-link) ;; Implementation @@ -192,18 +191,12 @@ ENTITY is a message entity." (message-id (org-wl-message-field 'message-id wl-message-entity)) (message-id-no-brackets - (org-remove-angle-brackets message-id)) + (org-unbracket-string "<" ">" 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 @@ -243,9 +236,7 @@ ENTITY is a message entity." (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)) + (org-add-link-props :date date) (or link xref))))))) (defun org-wl-open-nntp (path) @@ -287,8 +278,8 @@ for namazu index." 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)))) + (if (not (elmo-folder-exists-p (with-no-warnings + (wl-folder-get-elmo-folder folder)))) (error "No such folder: %s" folder)) (let ((old-buf (current-buffer)) (old-point (point-marker))) @@ -299,7 +290,7 @@ for namazu index." ;; in the old buffer. (goto-char old-point)) (when article - (if (org-string-match-p "@" article) + (if (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)) diff --git a/elpa/org-plus-contrib-20150831/org.el b/elpa/org-plus-contrib-20170407/org.el old mode 100755 new mode 100644 similarity index 75% rename from elpa/org-plus-contrib-20150831/org.el rename to elpa/org-plus-contrib-20170407/org.el index 161e8518..b73f9091 --- a/elpa/org-plus-contrib-20150831/org.el +++ b/elpa/org-plus-contrib-20170407/org.el @@ -1,7 +1,7 @@ -;;; org.el --- Outline-based notes management and organizer +;;; org.el --- Outline-based notes management and organizer -*- lexical-binding: t; -*- ;; Carstens outline-mode for keeping track of everything. -;; Copyright (C) 2004-2015 Free Software Foundation, Inc. +;; Copyright (C) 2004-2017 Free Software Foundation, Inc. ;; ;; Author: Carsten Dominik ;; Maintainer: Carsten Dominik @@ -25,23 +25,24 @@ ;; ;;; Commentary: ;; -;; Org-mode is a mode for keeping notes, maintaining ToDo lists, and doing +;; Org is a mode for keeping notes, maintaining ToDo lists, and doing ;; project planning with a fast and effective plain-text system. ;; -;; Org-mode develops organizational tasks around NOTES files that contain -;; information about projects as plain text. Org-mode is implemented on -;; top of outline-mode, which makes it possible to keep the content of -;; large files well structured. Visibility cycling and structure editing -;; help to work with the tree. Tables are easily created with a built-in -;; table editor. Org-mode supports ToDo items, deadlines, time stamps, -;; 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-mode 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 webpages. +;; Org mode develops organizational tasks around NOTES files that +;; contain information about projects as plain text. Org mode is +;; implemented on top of outline-mode, which makes it possible to keep +;; the content of large files well structured. Visibility cycling and +;; structure editing help to work with the tree. Tables are easily +;; created with a built-in table editor. Org mode supports ToDo +;; items, deadlines, time stamps, 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 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 +;; webpages. ;; ;; Installation and Activation ;; --------------------------- @@ -51,11 +52,11 @@ ;; ;; Documentation ;; ------------- -;; The documentation of Org-mode can be found in the TeXInfo file. The +;; The documentation of Org mode can be found in the TeXInfo file. The ;; distribution also contains a PDF version of it. At the homepage of -;; Org-mode, you can read the same text online as HTML. There is also an +;; Org mode, you can read the same text online as HTML. There is also an ;; excellent reference card made by Philip Rooke. This card can be found -;; in the etc/ directory of Emacs 22. +;; in the doc/ directory. ;; ;; A list of recent changes can be found at ;; http://orgmode.org/Changes.html @@ -63,21 +64,20 @@ ;;; Code: (defvar org-inhibit-highlight-removal nil) ; dynamically scoped param -(defvar org-table-formula-constants-local nil +(defvar-local org-table-formula-constants-local nil "Local version of `org-table-formula-constants'.") -(make-variable-buffer-local 'org-table-formula-constants-local) ;;;; Require other packages -(eval-when-compile - (require 'cl) - (require 'gnus-sum)) +(require 'cl-lib) + +(eval-when-compile (require 'gnus-sum)) (require 'calendar) (require 'find-func) (require 'format-spec) -(or (equal this-command 'eval-buffer) +(or (eq this-command 'eval-buffer) (condition-case nil (load (concat (file-name-directory load-file-name) "org-loaddefs.el") @@ -110,24 +110,16 @@ sure that we are at the beginning of the line.") "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 -(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 calendar-check-holidays "holidays" (date)) (declare-function cdlatex-environment "ext:cdlatex" (environment item)) +(declare-function isearch-no-upper-case-p "isearch" (string regexp-flag)) (declare-function org-add-archive-files "org-archive" (files)) (declare-function org-agenda-entry-get-agenda-timestamp "org-agenda" (pom)) -(declare-function org-agenda-list "org-agenda" (&optional arg start-day span)) +(declare-function org-agenda-list "org-agenda" (&optional arg start-day span with-hour)) (declare-function org-agenda-redo "org-agenda" (&optional all)) -(declare-function org-babel-do-in-edit-buffer "ob-core" (&rest body)) +(declare-function org-babel-do-in-edit-buffer "ob-core" (&rest body) t) (declare-function org-babel-tangle-file "ob-tangle" (file &optional target-file lang)) -(declare-function org-beamer-mode "ox-beamer" ()) +(declare-function org-beamer-mode "ox-beamer" (&optional prefix) t) (declare-function org-clock-get-last-clock-out-time "org-clock" ()) (declare-function org-clock-out "org-clock" (&optional switch-to-state fail-quietly at-time)) (declare-function org-clock-remove-overlays "org-clock" (&optional beg end noremove)) @@ -143,7 +135,7 @@ Stars are put in group 1 and the trimmed body in group 2.") (declare-function org-element-contents "org-element" (element)) (declare-function org-element-context "org-element" (&optional element)) (declare-function org-element-copy "org-element" (datum)) -(declare-function org-element-interpret-data "org-element" (data &optional parent)) +(declare-function org-element-interpret-data "org-element" (data)) (declare-function org-element-lineage "org-element" (blob &optional types with-self)) (declare-function org-element-nested-p "org-element" (elem-a elem-b)) (declare-function org-element-parse-buffer "org-element" (&optional granularity visible-only)) @@ -158,12 +150,13 @@ Stars are put in group 1 and the trimmed body in group 2.") (declare-function org-inlinetask-outline-regexp "org-inlinetask" ()) (declare-function org-inlinetask-toggle-visibility "org-inlinetask" ()) (declare-function org-plot/gnuplot "org-plot" (&optional params)) -(declare-function org-pop-to-buffer-same-window "org-compat" (&optional buffer-or-name norecord label)) (declare-function org-table-align "org-table" ()) (declare-function org-table-begin "org-table" (&optional table-type)) (declare-function org-table-beginning-of-field "org-table" (&optional n)) (declare-function org-table-blank-field "org-table" ()) (declare-function org-table-calc-current-TBLFM "org-table" (&optional arg)) +(declare-function org-table-copy-region "org-table" (beg end &optional cut)) +(declare-function org-table-cut-region "org-table" (beg end)) (declare-function org-table-edit-field "org-table" (arg)) (declare-function org-table-end "org-table" (&optional table-type)) (declare-function org-table-end-of-field "org-table" (&optional n)) @@ -173,10 +166,14 @@ Stars are put in group 1 and the trimmed body in group 2.") (declare-function org-table-maybe-recalculate-line "org-table" ()) (declare-function org-table-next-row "org-table" ()) (declare-function org-table-paste-rectangle "org-table" ()) +(declare-function org-table-recalculate "org-table" (&optional all noalign)) (declare-function org-table-wrap-region "org-table" (arg)) (declare-function org-tags-view "org-agenda" (&optional todo-only match)) (declare-function orgtbl-ascii-plot "org-table" (&optional ask)) (declare-function orgtbl-mode "org-table" (&optional arg)) +(declare-function org-export-get-backend "ox" (name)) +(declare-function org-export-get-environment "ox" (&optional backend subtreep ext-plist)) +(declare-function org-latex-make-preamble "ox-latex" (info &optional template snippet?)) (defsubst org-uniquify (list) "Non-destructively remove duplicate elements from LIST." @@ -186,10 +183,12 @@ Stars are put in group 1 and the trimmed body in group 2.") "Get text property PROPERTY at the beginning of line." (get-text-property (point-at-bol) property)) -(defsubst org-trim (s) - "Remove whitespace at the beginning and the end of string S." +(defsubst org-trim (s &optional keep-lead) + "Remove whitespace at the beginning and the end of string S. +When optional argument KEEP-LEAD is non-nil, removing blank lines +at the beginning of the string does not affect leading indentation." (replace-regexp-in-string - "\\`[ \t\n\r]+" "" + (if keep-lead "\\`\\([ \t]*\n\\)+" "\\`[ \t\n\r]+") "" (replace-regexp-in-string "[ \t\n\r]+\\'" "" s))) ;; load languages based on value of `org-babel-load-languages' @@ -199,22 +198,19 @@ Stars are put in group 1 and the trimmed body in group 2.") (defun org-babel-do-load-languages (sym value) "Load the languages defined in `org-babel-load-languages'." (set-default sym value) - (mapc (lambda (pair) - (let ((active (cdr pair)) (lang (symbol-name (car pair)))) - (if active - (progn - (require (intern (concat "ob-" lang)))) - (progn - (funcall 'fmakunbound - (intern (concat "org-babel-execute:" lang))) - (funcall 'fmakunbound - (intern (concat "org-babel-expand-body:" lang))))))) - org-babel-load-languages)) + (dolist (pair org-babel-load-languages) + (let ((active (cdr pair)) (lang (symbol-name (car pair)))) + (if active + (require (intern (concat "ob-" lang))) + (funcall 'fmakunbound + (intern (concat "org-babel-execute:" lang))) + (funcall 'fmakunbound + (intern (concat "org-babel-expand-body:" lang))))))) (declare-function org-babel-tangle-file "ob-tangle" (file &optional target-file lang)) ;;;###autoload (defun org-babel-load-file (file &optional compile) - "Load Emacs Lisp source code blocks in the Org-mode FILE. + "Load Emacs Lisp source code blocks in the Org 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 @@ -227,7 +223,7 @@ file to byte-code before it is loaded." (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 + ;; tangle if the Org file is newer than the elisp file (unless (and (file-exists-p exported-file) (> (funcall age file) (funcall age exported-file))) ;; Tangle-file traversal returns reversed list of tangled files @@ -242,7 +238,7 @@ file to byte-code before it is loaded." exported-file))) (defcustom org-babel-load-languages '((emacs-lisp . t)) - "Languages which can be evaluated in Org-mode buffers. + "Languages which can be evaluated in Org buffers. This list can be used to load support for any of the languages below, note that each language will depend on a different set of system executables and/or Emacs modes. When a language is @@ -272,6 +268,7 @@ requirements) is loaded." (const :tag "Fortran" fortran) (const :tag "Gnuplot" gnuplot) (const :tag "Haskell" haskell) + (const :tag "hledger" hledger) (const :tag "IO" io) (const :tag "J" J) (const :tag "Java" java) @@ -300,6 +297,7 @@ requirements) is loaded." (const :tag "Shen" shen) (const :tag "Sql" sql) (const :tag "Sqlite" sqlite) + (const :tag "Stan" stan) (const :tag "ebnf2ps" ebnf2ps)) :value-type (boolean :tag "Activate" :value t))) @@ -318,34 +316,37 @@ identifier." ;;;###autoload (defun org-version (&optional here full message) - "Show the org-mode version. + "Show the Org version. Interactively, or when MESSAGE is non-nil, show it in echo area. With prefix argument, or when HERE is non-nil, insert it at point. In non-interactive uses, a reduced version string is output unless FULL is given." (interactive (list current-prefix-arg t (not current-prefix-arg))) - (let* ((org-dir (ignore-errors (org-find-library-dir "org"))) - (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)) - (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)" - org-version - git-version - (if org-install-dir - (if (string= org-dir org-install-dir) - org-install-dir - (concat "mixed installation! " org-install-dir " and " org-dir)) - "org-loaddefs.el can not be found!"))) - (version1 (if full version org-version))) - (when here (insert version1)) - (when message (message "%s" version1)) - version1)) + (let ((org-dir (ignore-errors (org-find-library-dir "org"))) + (save-load-suffixes (when (boundp 'load-suffixes) load-suffixes)) + (load-suffixes (list ".el")) + (org-install-dir + (ignore-errors (org-find-library-dir "org-loaddefs")))) + (unless (and (fboundp 'org-release) (fboundp 'org-git-version)) + (org-load-noerror-mustsuffix (concat org-dir "org-version"))) + (let* ((load-suffixes save-load-suffixes) + (release (org-release)) + (git-version (org-git-version)) + (version (format "Org mode version %s (%s @ %s)" + release + git-version + (if org-install-dir + (if (string= org-dir org-install-dir) + org-install-dir + (concat "mixed installation! " + org-install-dir + " and " + org-dir)) + "org-loaddefs.el can not be found!"))) + (version1 (if full version release))) + (when here (insert version1)) + (when message (message "%s" version1)) + version1))) (defconst org-version (org-version)) @@ -375,15 +376,17 @@ FULL is given." (defvar org-deadline-string "DEADLINE:" "String to mark deadline entries. -A deadline is this string, followed by a time stamp. Should be a word, -terminated by a colon. You can insert a schedule keyword and -a timestamp with \\[org-deadline].") +\\ +A deadline is this string, followed by a time stamp. It must be +a word, terminated by a colon. You can insert a schedule keyword +and a timestamp with `\\[org-deadline]'.") (defvar org-scheduled-string "SCHEDULED:" "String to mark scheduled TODO entries. -A schedule is this string, followed by a time stamp. Should be a word, -terminated by a colon. You can insert a schedule keyword and -a timestamp with \\[org-schedule].") +\\ +A schedule is this string, followed by a time stamp. It must be +a word, terminated by a colon. You can insert a schedule keyword +and a timestamp with `\\[org-schedule]'.") (defconst org-ds-keyword-length (+ 2 @@ -492,7 +495,7 @@ Group 1 contains drawer's name or \"END\".") (defconst org-property-drawer-re (concat "^[ \t]*:PROPERTIES:[ \t]*\n" - "\\(?:[ \t]*:\\S-+:\\(?: .*\\)?[ \t]*\n\\)*" + "\\(?:[ \t]*:\\S-+:\\(?: .*\\)?[ \t]*\n\\)*?" "[ \t]*:END:[ \t]*$") "Matches an entire property drawer.") @@ -524,8 +527,9 @@ not contribute to the agenda listings.") (defconst org-comment-string "COMMENT" "Entries starting with this keyword will never be exported. +\\ An entry can be toggled between COMMENT and normal with -\\[org-toggle-comment].") +`\\[org-toggle-comment]'.") ;;;; LaTeX Environments and Fragments @@ -633,7 +637,7 @@ After a match, group 1 contains the repeat expression.") :group 'calendar) (defcustom org-mode-hook nil - "Mode hook for Org-mode, run after the mode was turned on." + "Mode hook for Org mode, run after the mode was turned on." :group 'org :type 'hook) @@ -655,10 +659,9 @@ After a match, group 1 contains the repeat expression.") (defun org-load-modules-maybe (&optional force) "Load all extensions listed in `org-modules'." (when (or force (not org-modules-loaded)) - (mapc (lambda (ext) - (condition-case nil (require ext) - (error (message "Problems while trying to load feature `%s'" ext)))) - org-modules) + (dolist (ext org-modules) + (condition-case nil (require ext) + (error (message "Problems while trying to load feature `%s'" ext)))) (setq org-modules-loaded t))) (defun org-set-modules (var value) @@ -680,7 +683,7 @@ 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: - \(provide 'org-xyz) + (provide \\='org-xyz) For export specific modules, see also `org-export-backends'." :group 'org @@ -694,6 +697,7 @@ For export specific modules, see also `org-export-backends'." (const :tag " crypt: Encryption of subtrees" org-crypt) (const :tag " ctags: Access to Emacs tags with links" org-ctags) (const :tag " docview: Links to doc-view buffers" org-docview) + (const :tag " eww: Store link to url of eww" org-eww) (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) @@ -704,41 +708,39 @@ For export specific modules, see also `org-export-backends'." (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 " w3m: Special cut/paste from w3m to Org-mode." org-w3m) + (const :tag " w3m: Special cut/paste from w3m to Org mode." org-w3m) (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 bookmark: Org links to bookmarks" org-bookmark) (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) - (const :tag "C depend: TODO dependencies for Org-mode\n\t\t\t(PARTIALLY OBSOLETE, see built-in dependency support))" org-depend) - (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 depend: TODO dependencies for Org mode\n\t\t\t(PARTIALLY OBSOLETE, see built-in dependency support))" org-depend) + (const :tag "C drill: Flashcards and spaced repetition for Org mode" org-drill) + (const :tag "C elisp-symbol: Org 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-light: Evaluate inbuffer-code on demand" org-eval-light) (const :tag "C eval: Include command output as text" org-eval) - (const :tag "C eww: Store link to url of eww" org-eww) - (const :tag "C expiry: Expiry mechanism for Org-mode entries" org-expiry) + (const :tag "C expiry: Expiry mechanism for Org entries" org-expiry) (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 invoice: Help manage client invoices in Org mode" org-invoice) (const :tag "C learn: SuperMemo's incremental learning algorithm" org-learn) (const :tag "C mac-iCal Imports events from iCal.app to the Emacs diary" org-mac-iCal) (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 mairix: Hook mairix search into Org 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 screen: Visit screen sessions through Org-mode links" org-screen) + (const :tag "C registry: A registry for Org links" org-registry) + (const :tag "C screen: Visit screen sessions through Org 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 sqlinsert: Convert Org tables to SQL insertions" orgtbl-sqlinsert) + (const :tag "C toc: Table of contents for Org 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) @@ -747,8 +749,8 @@ For export specific modules, see also `org-export-backends'." (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) +(declare-function org-export-backend-name "ox" (backend) t) +(defcustom org-export-backends '(ascii html icalendar latex odt) "List of export back-ends that should be always available. If a description starts with , the file is not part of Emacs @@ -764,33 +766,33 @@ 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))))))) + (progn + (setq org-export-registered-backends + (cl-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 + (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'\" + (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))) + ((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") + :version "26.1" + :package-version '(Org . "9.0") :initialize 'custom-initialize-set :set (lambda (var val) (if (not (featurep 'ox)) (set-default var val) @@ -798,7 +800,7 @@ depends on, if any." ;; 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 + (cl-remove-if-not (lambda (backend) (let ((name (org-export-backend-name backend))) (or (memq name val) @@ -840,19 +842,18 @@ depends on, if any." (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)) + '(dolist (backend org-export-backends) + (condition-case nil (require (intern (format "ox-%s" backend))) + (error (message "Problems while trying to load export back-end `%s'" + backend))))) (defcustom org-support-shift-select nil "Non-nil means make shift-cursor commands select text when possible. +\\\ In Emacs 23, when `shift-select-mode' is on, shifted cursor keys start selecting a region, or enlarge regions started in this way. -In Org-mode, in special contexts, these same keys are used for +In Org mode, in special contexts, these same keys are used for other purposes, important enough to compete with shift selection. Org tries to balance these needs by supporting `shift-select-mode' outside these special contexts, under control of this variable. @@ -867,7 +868,7 @@ cursor keys will then execute Org commands in the following contexts: Outside these contexts, the commands will throw an error. When this variable is t and the cursor is not in a special -context, Org-mode will support shift-selection for making and +context, Org mode will support shift-selection for making and enlarging regions. To make this more effective, the bullet cycling will no longer happen anywhere in an item line, but only if the cursor is exactly on the bullet. @@ -875,16 +876,16 @@ if the cursor is exactly on the bullet. If you set this variable to the symbol `always', then the keys will not be special in headlines, property lines, and item lines, to make shift selection work there as well. If this is what you -want, you can use the following alternative commands: `C-c C-t' -and `C-c ,' to change TODO state and priority, `C-u C-u C-c C-t' -can be used to switch TODO sets, `C-c -' to cycle item bullet -types, and properties can be edited by hand or in column view. +want, you can use the following alternative commands: +`\\[org-todo]' and `\\[org-priority]' \ +to change TODO state and priority, +`\\[universal-argument] \\[universal-argument] \\[org-todo]' \ +can be used to switch TODO sets, +`\\[org-ctrl-c-minus]' to cycle item bullet types, +and properties can be edited by hand or in column view. However, when the cursor is on a timestamp, shift-cursor commands -will still edit the time stamp - this is just too good to give up. - -XEmacs user should have this variable set to nil, because -`shift-select-mode' is in Emacs 23 or later only." +will still edit the time stamp - this is just too good to give up." :group 'org :type '(choice (const :tag "Never" nil) @@ -918,12 +919,13 @@ already archived entries." :group 'org-archive) (defgroup org-startup nil - "Options concerning startup of Org-mode." + "Options concerning startup of Org mode." :tag "Org Startup" :group 'org) (defcustom org-startup-folded t - "Non-nil means entering Org-mode will switch to OVERVIEW. + "Non-nil means entering Org mode will switch to OVERVIEW. + This can also be configured on a per-file basis by adding one of the following lines anywhere in the buffer: @@ -932,9 +934,9 @@ the following lines anywhere in the buffer: #+STARTUP: content #+STARTUP: showeverything -By default, this option is ignored when Org opens agenda files -for the first time. If you want the agenda to honor the startup -option, set `org-agenda-inhibit-startup' to nil." +Set `org-agenda-inhibit-startup' to a non-nil value if you want +to ignore this option when Org opens agenda files for the first +time." :group 'org-startup :type '(choice (const :tag "nofold: show all" nil) @@ -943,9 +945,18 @@ option, set `org-agenda-inhibit-startup' to nil." (const :tag "show everything, even drawers" showeverything))) (defcustom org-startup-truncated t - "Non-nil means entering Org-mode will set `truncate-lines'. + "Non-nil means entering Org mode will set `truncate-lines'. This is useful since some lines containing links can be very long and -uninteresting. Also tables look terrible when wrapped." +uninteresting. Also tables look terrible when wrapped. + +The variable `org-startup-truncated' allows to configure +truncation for Org mode different to the other modes that use the +variable `truncate-lines' and as a shortcut instead of putting +the variable `truncate-lines' into the `org-mode-hook'. If one +wants to configure truncation for Org mode not statically but +dynamically e. g. in a hook like `ediff-prepare-buffer-hook' then +the variable `truncate-lines' has to be used because in such a +case it is too late to set the variable `org-startup-truncated'." :group 'org-startup :type 'boolean) @@ -1038,26 +1049,26 @@ the following lines anywhere in the buffer: :type 'boolean) (defcustom org-insert-mode-line-in-empty-file nil - "Non-nil means insert the first line setting Org-mode in empty files. + "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 -normally means that the file name does not automatically trigger Org-mode. -To ensure that the file will always be in Org-mode in the future, a -line enforcing Org-mode will be inserted into the buffer, if this option +normally means that the file name does not automatically trigger Org mode. +To ensure that the file will always be in Org mode in the future, a +line enforcing Org mode will be inserted into the buffer, if this option has been set." :group 'org-startup :type 'boolean) (defcustom org-replace-disputed-keys nil "Non-nil means use alternative key bindings for some keys. -Org-mode uses S- keys for changing timestamps and priorities. +Org mode uses S- keys for changing timestamps and priorities. These keys are also used by other packages like shift-selection-mode' \(built into Emacs 23), `CUA-mode' or `windmove.el'. -If you want to use Org-mode together with one of these other modes, -or more generally if you would like to move some Org-mode commands to +If you want to use Org mode together with one of these other modes, +or more generally if you would like to move some Org mode commands to other keys, set this variable and configure the keys with the variable `org-disputed-keys'. -This option is only relevant at load-time of Org-mode, and must be set +This option is only relevant at load-time of Org mode, and must be set *before* org.el is loaded. Changing it requires a restart of Emacs to become effective." :group 'org-startup @@ -1065,18 +1076,13 @@ become effective." (defcustom org-use-extra-keys nil "Non-nil means use extra key sequence definitions for certain commands. -This happens automatically if you run XEmacs or if `window-system' -is nil. This variable lets you do the same manually. You must -set it before loading org. - -Example: on Carbon Emacs 22 running graphically, with an external -keyboard on a Powerbook, the default way of setting M-left might -not work for either Alt or ESC. Setting this variable will make -it work for ESC." +This happens automatically if `window-system' is nil. This +variable lets you do the same manually. You must set it before +loading Org." :group 'org-startup :type 'boolean) -(org-defvaralias 'org-CUA-compatible 'org-replace-disputed-keys) +(defvaralias 'org-CUA-compatible 'org-replace-disputed-keys) (defcustom org-disputed-keys '(([(shift up)] . [(meta p)]) @@ -1085,59 +1091,49 @@ it work for ESC." ([(shift right)] . [(meta +)]) ([(control shift right)] . [(meta shift +)]) ([(control shift left)] . [(meta shift -)])) - "Keys for which Org-mode and other modes compete. + "Keys for which Org mode and other modes compete. This is an alist, cars are the default keys, second element specifies the alternative to use when `org-replace-disputed-keys' is t. Keys can be specified in any syntax supported by `define-key'. -The value of this option takes effect only at Org-mode's startup, +The value of this option takes effect only at Org mode startup, therefore you'll have to restart Emacs to apply it after changing." :group 'org-startup :type 'alist) (defun org-key (key) "Select key according to `org-replace-disputed-keys' and `org-disputed-keys'. -Or return the original if not disputed. -Also apply the translations defined in `org-xemacs-key-equivalents'." +Or return the original if not disputed." (when org-replace-disputed-keys (let* ((nkey (key-description key)) - (x (org-find-if (lambda (x) - (equal (key-description (car x)) nkey)) - org-disputed-keys))) + (x (cl-find-if (lambda (x) (equal (key-description (car x)) nkey)) + org-disputed-keys))) (setq key (if x (cdr x) key)))) - (when (featurep 'xemacs) - (setq key (or (cdr (assoc key org-xemacs-key-equivalents)) key))) key) -(defun org-find-if (predicate seq) - (catch 'exit - (while seq - (if (funcall predicate (car seq)) - (throw 'exit (car seq)) - (pop seq))))) - (defun org-defkey (keymap key def) "Define a key, possibly translated, as returned by `org-key'." (define-key keymap (org-key key) def)) (defcustom org-ellipsis nil - "The ellipsis to use in the Org-mode outline. + "The ellipsis to use in the Org mode outline. + When nil, just use the standard three dots. When a string, use that string instead. -When a face, use the standard 3 dots, but with the specified face. -The change affects only Org-mode (which will then use its own display table). -Changing this requires executing \\[org-mode] in a buffer to become + +The change affects only Org mode (which will then use its own display table). +Changing this requires executing `\\[org-mode]' in a buffer to become effective." :group 'org-startup :type '(choice (const :tag "Default" nil) - (face :tag "Face" :value org-warning) - (string :tag "String" :value "...#"))) + (string :tag "String" :value "...#")) + :safe #'string-or-null-p) (defvar org-display-table nil "The display table for org-mode, in case `org-ellipsis' is non-nil.") (defgroup org-keywords nil - "Keywords in Org-mode." + "Keywords in Org mode." :tag "Org Keywords" :group 'org) @@ -1150,7 +1146,7 @@ effective." :type 'boolean) (defgroup org-structure nil - "Options concerning the general structure of Org-mode files." + "Options concerning the general structure of Org files." :tag "Org Structure" :group 'org) @@ -1159,8 +1155,9 @@ effective." :tag "Org Reveal Location" :group 'org-structure) -(defcustom org-show-context-detail '((isearch . lineage) +(defcustom org-show-context-detail '((agenda . local) (bookmark-jump . lineage) + (isearch . lineage) (default . ancestors)) "Alist between context and visibility span when revealing a location. @@ -1170,8 +1167,8 @@ around point. How much is shown depends on the initial action, or context. Valid contexts are agenda when exposing an entry from the agenda - org-goto when using the command `org-goto' (\\[org-goto]) - occur-tree when using the command `org-occur' (\\[org-sparse-tree] /) + org-goto when using the command `org-goto' (`\\[org-goto]') + occur-tree when using the command `org-occur' (`\\[org-sparse-tree] /') tags-tree when constructing a sparse tree based on tags matches link-search when exposing search matches associated with a link mark-goto when exposing the jump goal of a mark @@ -1206,11 +1203,11 @@ As special cases, a nil or t value means show all contexts in Some views can make displayed information very compact, but also make it harder to edit the location of the match. In such -a case, use the command `org-reveal' (\\[org-reveal]) to show +a case, use the command `org-reveal' (`\\[org-reveal]') to show more context." :group 'org-reveal-location - :version "25.1" - :package-version '(Org . "8.3") + :version "26.1" + :package-version '(Org . "9.0") :type '(choice (const :tag "Canonical" t) (const :tag "Minimal" nil) @@ -1236,8 +1233,10 @@ more context." (defcustom org-indirect-buffer-display 'other-window "How should indirect tree buffers be displayed? + This applies to indirect buffers created with the commands -\\[org-tree-to-indirect-buffer] and \\[org-agenda-tree-to-indirect-buffer]. +`org-tree-to-indirect-buffer' and `org-agenda-tree-to-indirect-buffer'. + Valid values are: current-window Display in the current window other-window Just display in another window. @@ -1307,7 +1306,7 @@ is not set." :type 'plist) (defgroup org-cycle nil - "Options concerning visibility cycling in Org-mode." + "Options concerning visibility cycling in Org mode." :tag "Org Cycle" :group 'org-structure) @@ -1332,7 +1331,7 @@ than its value." (integer :tag "Maximum level"))) (defcustom org-hide-block-startup nil - "Non-nil means entering Org-mode will fold all blocks. + "Non-nil means entering Org mode will fold all blocks. This can also be set in on a per-file basis with #+STARTUP: hideblocks @@ -1343,12 +1342,17 @@ This can also be set in on a per-file basis with (defcustom org-cycle-global-at-bob nil "Cycle globally if cursor is at beginning of buffer and not at a headline. -This makes it possible to do global cycling without having to use S-TAB or -\\[universal-argument] TAB. For this special case to work, the first line -of the buffer must not be a headline -- it may be empty or some other text. + +This makes it possible to do global cycling without having to use `S-TAB' +or `\\[universal-argument] TAB'. For this special case to work, the first \ +line of the buffer +must not be a headline -- it may be empty or some other text. + When used in this way, `org-cycle-hook' is disabled temporarily to make -sure the cursor stays at the beginning of the buffer. When this option is -nil, don't do anything special at the beginning of the buffer." +sure the cursor stays at the beginning of the buffer. + +When this option is nil, don't do anything special at the beginning of +the buffer." :group 'org-cycle :type 'boolean) @@ -1387,7 +1391,7 @@ visibility is cycled." "Number of empty lines needed to keep an empty line between collapsed trees. If you leave an empty line between the end of a subtree and the following headline, this empty line is hidden when the subtree is folded. -Org-mode will leave (exactly) one empty line visible if the number of +Org mode will leave (exactly) one empty line visible if the number of empty lines is equal or larger to the number given in this variable. So the default 2 means at least 2 empty lines after the end of a subtree are needed to produce free space between a collapsed subtree and the @@ -1423,11 +1427,11 @@ argument is a symbol. After a global state change, it can have the values the values `folded', `children', or `subtree'." :group 'org-cycle :type 'hook - :version "25.1" + :version "26.1" :package-version '(Org . "8.3")) (defgroup org-edit-structure nil - "Options concerning structure editing in Org-mode." + "Options concerning structure editing in Org mode." :tag "Org Edit Structure" :group 'org-structure) @@ -1510,7 +1514,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))))) -(org-defvaralias 'org-special-ctrl-a 'org-special-ctrl-a/e) +(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. @@ -1610,9 +1614,11 @@ 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) @@ -1622,11 +1628,7 @@ this variable on for the duration of the command." The value is an alist, with `heading' and `plain-list-item' as CAR, 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 `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." +make an intelligent decision whether to insert a blank line or not." :group 'org-edit-structure :type '(list (cons (const heading) @@ -1664,7 +1666,7 @@ When nil, you can use these keybindings to navigate the buffer: :type 'boolean) (defgroup org-sparse-trees nil - "Options concerning sparse trees in Org-mode." + "Options concerning sparse trees in Org mode." :tag "Org Sparse Trees" :group 'org-structure) @@ -1677,14 +1679,26 @@ changed by an edit command." (defcustom org-remove-highlights-with-change t "Non-nil means any change to the buffer will remove temporary highlights. +\\\ Such highlights are created by `org-occur' and `org-clock-display'. -When nil, `C-c C-c' needs to be used to get rid of the highlights. +When nil, `\\[org-ctrl-c-ctrl-c]' needs to be used \ +to get rid of the highlights. The highlights created by `org-toggle-latex-fragment' always need -`C-c C-x C-l' to be removed." +`\\[org-toggle-latex-fragment]' to be removed." :group 'org-sparse-trees :group 'org-time :type 'boolean) +(defcustom org-occur-case-fold-search t + "Non-nil means `org-occur' should be case-insensitive. +If set to `smart' the search will be case-insensitive only if it +doesn't specify any upper case character." + :group 'org-sparse-trees + :version "26.1" + :type '(choice + (const :tag "Case-sensitive" nil) + (const :tag "Case-insensitive" t) + (const :tag "Case-insensitive for lower case searches only" 'smart))) (defcustom org-occur-hook '(org-first-headline-recenter) "Hook that is run after `org-occur' has constructed a sparse tree. @@ -1694,18 +1708,18 @@ as possible." :type 'hook) (defgroup org-imenu-and-speedbar nil - "Options concerning imenu and speedbar in Org-mode." + "Options concerning imenu and speedbar in Org mode." :tag "Org Imenu and Speedbar" :group 'org-structure) (defcustom org-imenu-depth 2 - "The maximum level for Imenu access to Org-mode headlines. + "The maximum level for Imenu access to Org headlines. This also applied for speedbar access." :group 'org-imenu-and-speedbar :type 'integer) (defgroup org-table nil - "Options concerning tables in Org-mode." + "Options concerning tables in Org mode." :tag "Org Table" :group 'org) @@ -1722,12 +1736,12 @@ do the following: TAB or RET are pressed to move to another field. With optimization this happens only if changes to a field might have changed the column width. Optimization requires replacing the functions `self-insert-command', -`delete-char', and `backward-delete-char' in Org-mode buffers, with a -slight (in fact: unnoticeable) speed impact for normal typing. Org-mode is -very good at guessing when a re-align will be necessary, but you can always -force one with \\[org-ctrl-c-ctrl-c]. +`delete-char', and `backward-delete-char' in Org buffers, with a +slight (in fact: unnoticeable) speed impact for normal typing. Org is very +good at guessing when a re-align will be necessary, but you can always +force one with `\\[org-ctrl-c-ctrl-c]'. -If you would like to use the optimized version in Org-mode, but the +If you would like to use the optimized version in Org mode, but the un-optimized version in OrgTbl-mode, see the variable `orgtbl-optimized'. This variable can be used to turn on and off the table editor during a session, @@ -1740,8 +1754,7 @@ See also the variable `org-table-auto-blank-field'." (const :tag "on" t) (const :tag "on, optimized" optimized))) -(defcustom org-self-insert-cluster-for-undo (or (featurep 'xemacs) - (version<= emacs-version "24.1")) +(defcustom org-self-insert-cluster-for-undo nil "Non-nil means cluster self-insert commands for undo when possible. If this is set, then, like in the Emacs command loop, 20 consecutive characters will be undone together. @@ -1757,25 +1770,97 @@ calls `table-recognize-table'." :type 'boolean) (defgroup org-link nil - "Options concerning links in Org-mode." + "Options concerning links in Org mode." :tag "Org Link" :group 'org) -(defvar org-link-abbrev-alist-local nil +(defvar-local org-link-abbrev-alist-local nil "Buffer-local version of `org-link-abbrev-alist', which see. The value of this is taken from the #+LINK lines.") -(make-variable-buffer-local 'org-link-abbrev-alist-local) + +(defcustom org-link-parameters + '(("doi" :follow org--open-doi-link) + ("elisp" :follow org--open-elisp-link) + ("file" :complete org-file-complete-link) + ("ftp" :follow (lambda (path) (browse-url (concat "ftp:" path)))) + ("help" :follow org--open-help-link) + ("http" :follow (lambda (path) (browse-url (concat "http:" path)))) + ("https" :follow (lambda (path) (browse-url (concat "https:" path)))) + ("mailto" :follow (lambda (path) (browse-url (concat "mailto:" path)))) + ("news" :follow (lambda (path) (browse-url (concat "news:" path)))) + ("shell" :follow org--open-shell-link)) + "An alist of properties that defines all the links in Org mode. +The key in each association is a string of the link type. +Subsequent optional elements make up a p-list of link properties. + +:follow - A function that takes the link path as an argument. + +:export - A function that takes the link path, description and +export-backend as arguments. + +:store - A function responsible for storing the link. See the +function `org-store-link-functions'. + +:complete - A function that inserts a link with completion. The +function takes one optional prefix arg. + +:face - A face for the link, or a function that returns a face. +The function takes one argument which is the link path. The +default face is `org-link'. + +:mouse-face - The mouse-face. The default is `highlight'. + +:display - `full' will not fold the link in descriptive +display. Default is `org-link'. + +:help-echo - A string or function that takes (window object position) +as arguments and returns a string. + +:keymap - A keymap that is active on the link. The default is +`org-mouse-map'. + +:htmlize-link - A function for the htmlize-link. Defaults +to (list :uri \"type:path\") + +:activate-func - A function to run at the end of font-lock +activation. The function must accept (link-start link-end path bracketp) +as arguments." + :group 'org-link + :type '(alist :tag "Link display parameters" + :value-type plist) + :version "26.1" + :package-version '(Org . "9.1")) + +(defun org-link-get-parameter (type key) + "Get TYPE link property for KEY. +TYPE is a string and KEY is a plist keyword." + (plist-get + (cdr (assoc type org-link-parameters)) + key)) + +(defun org-link-set-parameters (type &rest parameters) + "Set link TYPE properties to PARAMETERS. + PARAMETERS should be :key val pairs." + (let ((data (assoc type org-link-parameters))) + (if data (setcdr data (org-combine-plists (cdr data) parameters)) + (push (cons type parameters) org-link-parameters) + (org-make-link-regexps) + (org-element-update-syntax)))) + +(defun org-link-types () + "Return a list of known link types." + (mapcar #'car org-link-parameters)) (defcustom org-link-abbrev-alist nil "Alist of link abbreviations. The car of each element is a string, to be replaced at the start of a link. The cdrs are replacement values, like (\"linkkey\" . REPLACE). Abbreviated -links in Org-mode buffers can have an optional tag after a double colon, e.g. +links in Org buffers can have an optional tag after a double colon, e.g., [[linkkey:tag][description]] -The 'linkkey' must be a word word, starting with a letter, followed -by letters, numbers, '-' or '_'. +The `linkkey' must be a single word, starting with a letter, followed +by letters, numbers, `-' or `_'. If REPLACE is a string, the tag will simply be appended to create the link. If the string contains \"%s\", the tag will be inserted there. If the string @@ -1828,7 +1913,7 @@ adaptive Use relative path for files in the current directory and sub- (defvaralias 'org-activate-links 'org-highlight-links) (defcustom org-highlight-links '(bracket angle plain radio tag date footnote) - "Types of links that should be highlighted in Org-mode files. + "Types of links that should be highlighted in Org files. This is a list of symbols, each one of them leading to the highlighting of a certain link type. @@ -1871,7 +1956,7 @@ return the description to use." :type '(choice (const nil) (function))) (defgroup org-link-store nil - "Options concerning storing links in Org-mode." + "Options concerning storing links in Org mode." :tag "Org Store Link" :group 'org-link) @@ -1916,32 +2001,36 @@ It should match if the message is from the user him/herself." (defcustom org-context-in-file-links t "Non-nil means file links from `org-store-link' contain context. -A search string will be added to the file name with :: as separator and -used to find the context when the link is activated by the command +\\ +A search string will be added to the file name with :: as separator +and used to find the context when the link is activated by the command `org-open-at-point'. When this option is t, the entire active region will be placed in the search string of the file link. If set to a positive integer, only the first n lines of context will be stored. -Using a prefix arg to the command \\[org-store-link] (`org-store-link') +Using a prefix arg to the command `org-store-link' (`\\[universal-argument] \ +\\[org-store-link]') negates this setting for the duration of the command." :group 'org-link-store :type '(choice boolean integer)) (defcustom org-keep-stored-link-after-insertion nil "Non-nil means keep link in list for entire session. - +\\ The command `org-store-link' adds a link pointing to the current location to an internal list. These links accumulate during a session. The command `org-insert-link' can be used to insert links into any -Org-mode file (offering completion for all stored links). When this -option is nil, every link which has been inserted once using \\[org-insert-link] -will be removed from the list, to make completing the unused links -more efficient." +Org file (offering completion for all stored links). + +When this option is nil, every link which has been inserted once using +`\\[org-insert-link]' will be removed from the list, to make completing the \ +unused +links more efficient." :group 'org-link-store :type 'boolean) (defgroup org-link-follow nil - "Options concerning following links in Org-mode." + "Options concerning following links in Org mode." :tag "Org Follow Link" :group 'org-link) @@ -1981,8 +2070,8 @@ In tables, the special behavior of RET has precedence." (defcustom org-mouse-1-follows-link (if (boundp 'mouse-1-click-follows-link) mouse-1-click-follows-link t) "Non-nil means mouse-1 on a link will follow the link. -A longer mouse click will still set point. Does not work on XEmacs. -Needs to be set before org.el is loaded." +A longer mouse click will still set point. Needs to be set +before org.el is loaded." :group 'org-link-follow :version "24.4" :package-version '(Org . "8.3") @@ -1998,16 +2087,22 @@ Changing this requires a restart of Emacs to work correctly." :type 'integer) (defcustom org-link-search-must-match-exact-headline 'query-to-create - "Non-nil means internal links in Org files must exactly match a headline. -When nil, the link search tries to match a phrase with all words -in the search text." + "Non-nil means internal fuzzy links can only match headlines. + +When nil, the a fuzzy link may point to a target or a named +construct in the document. When set to the special value +`query-to-create', offer to create a new headline when none +matched. + +Spaces and statistics cookies are ignored during heading searches." :group 'org-link-follow :version "24.1" :type '(choice (const :tag "Use fuzzy text search" nil) (const :tag "Match only exact headline" t) (const :tag "Match exact headline or query to create it" - query-to-create))) + query-to-create)) + :safe #'symbolp) (defcustom org-link-frame-setup '((vm . vm-visit-folder-other-frame) @@ -2068,7 +2163,7 @@ another window." "Non-nil means use indirect buffer to display infile links. Activating internal links (from one location in a file to another location in the same file) normally just jumps to the location. When the link is -activated with a \\[universal-argument] prefix (or with mouse-3), the link \ +activated with a `\\[universal-argument]' prefix (or with mouse-3), the link \ is displayed in another window. When this option is set, the other window actually displays an indirect buffer clone of the current buffer, to avoid any visibility @@ -2098,7 +2193,7 @@ Shell links can be dangerous: just think about a link [[shell:rm -rf ~/*][Google Search]] -This link would show up in your Org-mode document as \"Google Search\", +This link would show up in your Org document as \"Google Search\", but really it would remove your entire home directory. Therefore we advise against setting this variable to nil. Just change it to `y-or-n-p' if you want to confirm with a @@ -2124,7 +2219,7 @@ Elisp links can be dangerous: just think about a link [[elisp:(shell-command \"rm -rf ~/*\")][Google Search]] -This link would show up in your Org-mode document as \"Google Search\", +This link would show up in your Org document as \"Google Search\", but really it would remove your entire home directory. Therefore we advise against setting this variable to nil. Just change it to `y-or-n-p' if you want to confirm with a @@ -2153,30 +2248,23 @@ See `org-file-apps'.") (defconst org-file-apps-defaults-macosx '((remote . emacs) - (t . "open %s") (system . "open %s") ("ps.gz" . "gv %s") ("eps.gz" . "gv %s") ("dvi" . "xdvi %s") - ("fig" . "xfig %s")) - "Default file applications on a MacOS X system. + ("fig" . "xfig %s") + (t . "open %s")) + "Default file applications on a macOS system. The system \"open\" is known as a default, but we use X11 applications for some files for which the OS does not have a good default. See `org-file-apps'.") (defconst org-file-apps-defaults-windowsnt - (list - '(remote . emacs) - (cons t - (list (if (featurep 'xemacs) - 'mswindows-shell-execute - 'w32-shell-execute) - "open" 'file)) - (cons 'system - (list (if (featurep 'xemacs) - 'mswindows-shell-execute - 'w32-shell-execute) - "open" 'file))) + (list '(remote . emacs) + (cons 'system (lambda (file _path) + (with-no-warnings (w32-shell-execute "open" file)))) + (cons t (lambda (file _path) + (with-no-warnings (w32-shell-execute "open" file))))) "Default file applications on a Windows NT system. The system \"open\" is used for most files. See `org-file-apps'.") @@ -2187,11 +2275,15 @@ See `org-file-apps'.") ("\\.x?html?\\'" . default) ("\\.pdf\\'" . default)) "External applications for opening `file:path' items in a document. -Org-mode uses system defaults for different file types, but +\\\ + +Org mode uses system defaults for different file types, but you can use this variable to set the application for a given file extension. The entries in this list are cons cells where the car identifies -files and the cdr the corresponding command. Possible values for the -file identifier are +files and the cdr the corresponding command. + +Possible values for the file identifier are: + \"string\" A string as a file identifier can be interpreted in different ways, depending on its contents: @@ -2204,8 +2296,8 @@ file identifier are filename matches the regexp. If you want to use groups here, use shy groups. - Example: (\"\\.x?html\\'\" . \"firefox %s\") - (\"\\(?:xhtml\\|html\\)\" . \"firefox %s\") + Example: (\"\\\\.x?html\\\\\\='\" . \"firefox %s\") + (\"\\\\(?:xhtml\\\\|html\\\\)\\\\\\='\" . \"firefox %s\") to open *.html and *.xhtml with firefox. - Regular expression which contains (non-shy) groups: @@ -2217,10 +2309,11 @@ file identifier are that does not use any of the group matches, this case is handled identically to the second one (i.e. match against file name only). - In a custom lisp form, you can access the group matches with + In a custom function, you can access the group matches with (match-string n link). - Example: (\"\\.pdf::\\(\\d+\\)\\'\" . \"evince -p %1 %s\") + Example: (\"\\\\.pdf::\\\\(\\\\d+\\\\)\\\\\\='\" . \ +\"evince -p %1 %s\") to open [[file:document.pdf::5]] with evince at page 5. `directory' Matches a directory @@ -2232,28 +2325,32 @@ file identifier are command `emacs' will open most files in Emacs. Beware that this will also open html files inside Emacs, unless you add (\"html\" . default) to the list as well. - t Default for files not matched by any of the other options. `system' The system command to open files, like `open' on Windows - and Mac OS X, and mailcap under GNU/Linux. This is the command - that will be selected if you call `C-c C-o' with a double - \\[universal-argument] \\[universal-argument] prefix. + and macOS, and mailcap under GNU/Linux. This is the command + that will be selected if you call `org-open-at-point' with a + double prefix argument (`\\[universal-argument] \ +\\[universal-argument] \\[org-open-at-point]'). + t Default for files not matched by any of the other options. Possible values for the command are: + `emacs' The file will be visited by the current Emacs process. `default' Use the default application for this file type, which is the association for t in the list, most likely in the system-specific - part. - This can be used to overrule an unwanted setting in the + part. This can be used to overrule an unwanted setting in the system-specific variable. `system' Use the system command for opening files, like \"open\". This command is specified by the entry whose car is `system'. Most likely, the system-specific version of this variable does define this command, but you can overrule/replace it here. +`mailcap' Use command specified in the mailcaps. string A command to be executed by a shell; %s will be replaced by the path to the file. - sexp A Lisp form which will be evaluated. The file path will - be available in the Lisp variable `file'. + function A Lisp function, which will be called with two arguments: + the file path and the original link string, without the + \"file:\" prefix. + For more examples, see the system specific constants `org-file-apps-defaults-macosx' `org-file-apps-defaults-windowsnt' @@ -2273,7 +2370,7 @@ For more examples, see the system specific constants (const :tag "Use default" default) (const :tag "Use the system command" system) (string :tag "Command") - (sexp :tag "Lisp form"))))) + (function :tag "Function"))))) (defcustom org-doi-server-url "http://dx.doi.org/" "The URL of the DOI server." @@ -2282,22 +2379,22 @@ For more examples, see the system specific constants :group 'org-link-follow) (defgroup org-refile nil - "Options concerning refiling entries in Org-mode." + "Options concerning refiling entries in Org mode." :tag "Org Refile" :group 'org) (defcustom org-directory "~/org" - "Directory with org files. + "Directory with Org files. This is just a default location to look for Org files. There is no need -at all to put your files into this directory. It is only used in the +at all to put your files into this directory. It is used in the following situations: 1. When a capture template specifies a target file that is not an absolute path. The path will then be interpreted relative to `org-directory' -2. When a capture note is filed away in an interactive way (when exiting the - note buffer with `C-1 C-c C-c'. The user is prompted for an org file, - with `org-directory' as the default path." +2. When the value of variable `org-agenda-files' is a single file, any + relative paths in this file will be taken as relative to + `org-directory'." :group 'org-refile :group 'org-capture :type 'directory) @@ -2371,7 +2468,7 @@ will temporarily be changed to `time'." (const :tag "Record timestamp with note." note))) (defcustom org-refile-targets nil - "Targets for refiling entries with \\[org-refile]. + "Targets for refiling entries with `\\[org-refile]'. This is a list of cons cells. Each cell contains: - a specification of the files to be considered, either a list of files, or a symbol whose function or variable value will be used to retrieve @@ -2435,12 +2532,15 @@ of the subtree." (defcustom org-refile-use-cache nil "Non-nil means cache refile targets to speed up the process. +\\\ The cache for a particular file will be updated automatically when the buffer has been killed, or when any of the marker used for flagging refile targets no longer points at a live buffer. If you have added new entries to a buffer that might themselves be targets, -you need to clear the cache manually by pressing `C-0 C-c C-w' or, if you -find that easier, `C-u C-u C-u C-c C-w'." +you need to clear the cache manually by pressing `C-0 \\[org-refile]' or, +if you find that easier, \ +`\\[universal-argument] \\[universal-argument] \\[universal-argument] \ +\\[org-refile]'." :group 'org-refile :version "24.1" :type 'boolean) @@ -2463,18 +2563,18 @@ When `full-file-path', include the full file path." (defcustom org-outline-path-complete-in-steps t "Non-nil means complete the outline path in hierarchical steps. -When Org-mode uses the refile interface to select an outline path -\(see variable `org-refile-use-outline-path'), the completion of -the path can be done in a single go, or it can be done in steps down -the headline hierarchy. Going in steps is probably the best if you -do not use a special completion package like `ido' or `icicles'. -However, when using these packages, going in one step can be very -fast, while still showing the whole path to the entry." +When Org uses the refile interface to select an outline path (see +`org-refile-use-outline-path'), the completion of the path can be +done in a single go, or it can be done in steps down the headline +hierarchy. Going in steps is probably the best if you do not use +a special completion package like `ido' or `icicles'. However, +when using these packages, going in one step can be very fast, +while still showing the whole path to the entry." :group 'org-refile :type 'boolean) (defcustom org-refile-allow-creating-parent-nodes nil - "Non-nil means allow to create new nodes as refile targets. + "Non-nil means allow the creation of new nodes as refile targets. New nodes are then created by adding \"/new node name\" to the completion of an existing node. When the value of this variable is `confirm', new node creation must be confirmed by the user (recommended). @@ -2502,12 +2602,12 @@ converted to a headline before refiling." :type 'boolean) (defgroup org-todo nil - "Options concerning TODO items in Org-mode." + "Options concerning TODO items in Org mode." :tag "Org TODO" :group 'org) (defgroup org-progress nil - "Options concerning Progress logging in Org-mode." + "Options concerning Progress logging in Org mode." :tag "Org Progress" :group 'org-time) @@ -2525,12 +2625,12 @@ Each sequence starts with a symbol, either `sequence' or `type', indicating if the keywords should be interpreted as a sequence of action steps, or as different types of TODO items. The first keywords are states requiring action - these states will select a headline -for inclusion into the global TODO list Org-mode produces. If one of -the \"keywords\" is the vertical bar, \"|\", the remaining keywords +for inclusion into the global TODO list Org produces. If one of the +\"keywords\" is the vertical bar, \"|\", the remaining keywords signify that no further action is necessary. If \"|\" is not found, the last keyword is treated as the only DONE state of the sequence. -The command \\[org-todo] cycles an entry through these states, and one +The command `\\[org-todo]' cycles an entry through these states, and one additional state where no keyword is present. For details about this cycling, see the manual. @@ -2581,9 +2681,8 @@ taken from the (otherwise obsolete) variable `org-todo-interpretation'." (repeat (string :tag "Keyword")))))) -(defvar org-todo-keywords-1 nil +(defvar-local org-todo-keywords-1 nil "All TODO and DONE keywords active in a buffer.") -(make-variable-buffer-local 'org-todo-keywords-1) (defvar org-todo-keywords-for-agenda nil) (defvar org-done-keywords-for-agenda nil) (defvar org-todo-keyword-alist-for-agenda nil) @@ -2591,25 +2690,20 @@ taken from the (otherwise obsolete) variable `org-todo-interpretation'." "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-local org-tag-groups-alist nil) (defvar org-agenda-contributing-files nil) -(defvar org-not-done-keywords nil) -(make-variable-buffer-local 'org-not-done-keywords) -(defvar org-done-keywords nil) -(make-variable-buffer-local 'org-done-keywords) -(defvar org-todo-heads nil) -(make-variable-buffer-local 'org-todo-heads) -(defvar org-todo-sets nil) -(make-variable-buffer-local 'org-todo-sets) -(defvar org-todo-log-states nil) -(make-variable-buffer-local 'org-todo-log-states) -(defvar org-todo-kwd-alist nil) -(make-variable-buffer-local 'org-todo-kwd-alist) -(defvar org-todo-key-alist nil) -(make-variable-buffer-local 'org-todo-key-alist) -(defvar org-todo-key-trigger nil) -(make-variable-buffer-local 'org-todo-key-trigger) +(defvar-local org-current-tag-alist nil + "Alist of all tag groups in current buffer. +This variable takes into consideration `org-tag-alist', +`org-tag-persistent-alist' and TAGS keywords in the buffer.") +(defvar-local org-not-done-keywords nil) +(defvar-local org-done-keywords nil) +(defvar-local org-todo-heads nil) +(defvar-local org-todo-sets nil) +(defvar-local org-todo-log-states nil) +(defvar-local org-todo-kwd-alist nil) +(defvar-local org-todo-key-alist nil) +(defvar-local org-todo-key-trigger nil) (defcustom org-todo-interpretation 'sequence "Controls how TODO keywords are interpreted. @@ -2623,7 +2717,8 @@ more information." (const type))) (defcustom org-use-fast-todo-selection t - "Non-nil means use the fast todo selection scheme with C-c C-t. + "\\\ +Non-nil means use the fast todo selection scheme with `\\[org-todo]'. This variable describes if and under what circumstances the cycling mechanism for TODO keywords will be replaced by a single-key, direct selection scheme. @@ -2631,8 +2726,9 @@ selection scheme. When nil, fast selection is never used. When the symbol `prefix', it will be used when `org-todo' is called -with a prefix argument, i.e. `C-u C-c C-t' in an Org-mode buffer, and -`C-u t' in an agenda buffer. +with a prefix argument, i.e. `\\[universal-argument] \\[org-todo]' \ +in an Org buffer, and +`\\[universal-argument] t' in an agenda buffer. When t, fast selection is used by default. In this case, the prefix argument forces cycling instead. @@ -2712,7 +2808,7 @@ TODO state changes ------------------ :type todo-state-change :from previous state (keyword as a string), or nil, or a symbol - 'todo' or 'done', to indicate the general type of state. + `todo' or `done', to indicate the general type of state. :to new state, like in :from") (defcustom org-enforce-todo-dependencies nil @@ -2751,7 +2847,7 @@ to change is while Emacs is running is through the customize interface." (defcustom org-treat-insert-todo-heading-as-state-change nil "Non-nil means inserting a TODO heading is treated as state change. -So when the command \\[org-insert-todo-heading] is used, state change +So when the command `\\[org-insert-todo-heading]' is used, state change logging will apply if appropriate. When nil, the new TODO item will be inserted directly, and no logging will take place." :group 'org-todo @@ -2955,7 +3051,7 @@ function `org-log-into-drawer' instead." (const :tag "LOGBOOK" t) (string :tag "Other"))) -(org-defvaralias 'org-log-state-notes-into-drawer 'org-log-into-drawer) +(defvaralias 'org-log-state-notes-into-drawer 'org-log-into-drawer) (defun org-log-into-drawer () "Name of the log drawer, as a string, or nil. @@ -3034,7 +3130,7 @@ property to one or more of these keywords." (defgroup org-priorities nil - "Priorities in Org-mode." + "Priorities in Org mode." :tag "Org Priorities" :group 'org-todo) @@ -3092,12 +3188,13 @@ as an argument and return the numeric priority." (function))) (defgroup org-time nil - "Options concerning time stamps and deadlines in Org-mode." + "Options concerning time stamps and deadlines in Org mode." :tag "Org Time" :group 'org) (defcustom org-time-stamp-rounding-minutes '(0 5) "Number of minutes to round time stamps to. +\\\ These are two values, the first applies when first creating a time stamp. The second applies when changing it with the commands `S-up' and `S-down'. When changing the time stamp, this means that it will change in steps @@ -3107,7 +3204,8 @@ When a setting is 0 or 1, insert the time unmodified. Useful rounding numbers should be factors of 60, so for example 5, 10, 15. When this is larger than 1, you can still force an exact time stamp by using -a double prefix argument to a time stamp command like `C-c .' or `C-c !', +a double prefix argument to a time stamp command like \ +`\\[org-time-stamp]' or `\\[org-time-stamp-inactive], and by using a prefix arg to `S-up/down' to specify the exact number of minutes to shift." :group 'org-time @@ -3153,135 +3251,6 @@ commands, if custom time display is turned on at the time of export." (concat "[" (substring f 1 -1) "]") f))) -(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. - -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 - :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 - "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, 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 '(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 "Number of days before expiration during which a deadline becomes active. This variable governs the display in sparse trees and in the agenda. @@ -3315,8 +3284,8 @@ This affects the following situations: For example, if it is April and you enter \"feb 2\", this will be read as Feb 2, *next* year. \"May 5\", however, will be this year. 2. The user gives a day, but no month. - For example, if today is the 15th, and you enter \"3\", Org-mode will - read this as the third of *next* month. However, if you enter \"17\", + For example, if today is the 15th, and you enter \"3\", Org will read + this as the third of *next* month. However, if you enter \"17\", it will be considered as *this* month. If you set this variable to the symbol `time', then also the following @@ -3395,22 +3364,9 @@ 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) -(org-defvaralias 'org-popup-calendar-for-date-prompt +(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. - -WARNING: This option is obsolete, you should use -`org-read-date-minibuffer-local-map' to set up keys." - :group 'org-time - :type 'hook) - (defcustom org-extend-today-until 0 "The hour when your day really ends. Must be an integer. This has influence for the following applications: @@ -3458,58 +3414,76 @@ moved to the new date." :type 'boolean) (defgroup org-tags nil - "Options concerning tags in Org-mode." + "Options concerning tags in Org mode." :tag "Org Tags" :group 'org) (defcustom org-tag-alist nil - "List of tags allowed in Org-mode files. -When this list is nil, Org-mode will base TAG input on what is already in the -buffer. -The value of this variable is an alist, the car of each entry must be a -keyword as a string, the cdr may be a character that is used to select -that tag through the fast-tag-selection interface. -See the manual for details." + "Default tags available in Org files. + +The value of this variable is an alist. Associations either: + + (TAG) + (TAG . SELECT) + (SPECIAL) + +where TAG is a tag as a string, SELECT is character, used to +select that tag through the fast tag selection interface, and +SPECIAL is one of the following keywords: `:startgroup', +`:startgrouptag', `:grouptags', `:engroup', `:endgrouptag' or +`:newline'. These keywords are used to define a hierarchy of +tags. See manual for details. + +When this variable is nil, Org mode bases tag input on what is +already in the buffer. The value can be overridden locally by +using a TAGS keyword, e.g., + + #+TAGS: tag1 tag2 + +See also `org-tag-persistent-alist' to sidestep this behavior." :group 'org-tags :type '(repeat (choice (cons (string :tag "Tag name") (character :tag "Access char")) - (list :tag "Start radio group" - (const :startgroup) - (option (string :tag "Group description"))) - (list :tag "Start tag group, non distinct" - (const :startgrouptag) - (option (string :tag "Group description"))) - (list :tag "Group tags delimiter" - (const :grouptags)) - (list :tag "End radio group" - (const :endgroup) - (option (string :tag "Group description"))) - (list :tag "End tag group, non distinct" - (const :endgrouptag) - (option (string :tag "Group description"))) + (const :tag "Start radio group" (:startgroup)) + (const :tag "Start tag group, non distinct" (:startgrouptag)) + (const :tag "Group tags delimiter" (:grouptags)) + (const :tag "End radio group" (:endgroup)) + (const :tag "End tag group, non distinct" (:endgrouptag)) (const :tag "New line" (:newline))))) (defcustom org-tag-persistent-alist nil - "List of tags that will always appear in all Org-mode files. -This is in addition to any in buffer settings or customizations -of `org-tag-alist'. -When this list is nil, Org-mode will base TAG input on `org-tag-alist'. -The value of this variable is an alist, the car of each entry must be a -keyword as a string, the cdr may be a character that is used to select -that tag through the fast-tag-selection interface. -See the manual for details. -To disable these tags on a per-file basis, insert anywhere in the file: - #+STARTUP: noptag" + "Tags always available in Org files. + +The value of this variable is an alist. Associations either: + + (TAG) + (TAG . SELECT) + (SPECIAL) + +where TAG is a tag as a string, SELECT is a character, used to +select that tag through the fast tag selection interface, and +SPECIAL is one of the following keywords: `:startgroup', +`:startgrouptag', `:grouptags', `:engroup', `:endgrouptag' or +`:newline'. These keywords are used to define a hierarchy of +tags. See manual for details. + +Unlike to `org-tag-alist', tags defined in this variable do not +depend on a local TAGS keyword. Instead, to disable these tags +on a per-file basis, insert anywhere in the file: + + #+STARTUP: noptag" :group 'org-tags :type '(repeat (choice - (cons (string :tag "Tag name") - (character :tag "Access char")) + (cons (string :tag "Tag name") + (character :tag "Access char")) (const :tag "Start radio group" (:startgroup)) + (const :tag "Start tag group, non distinct" (:startgrouptag)) (const :tag "Group tags delimiter" (:grouptags)) (const :tag "End radio group" (:endgroup)) + (const :tag "End tag group, non distinct" (:endgrouptag)) (const :tag "New line" (:newline))))) (defcustom org-complete-tags-always-offer-all-agenda-tags nil @@ -3518,11 +3492,9 @@ Instead of customizing this variable directly, you might want to set it locally for capture buffers, because there no list of tags in that file can be created dynamically (there are none). - (add-hook 'org-capture-mode-hook + (add-hook \\='org-capture-mode-hook (lambda () - (set (make-local-variable - 'org-complete-tags-always-offer-all-agenda-tags) - t)))" + (setq-local org-complete-tags-always-offer-all-agenda-tags t)))" :group 'org-tags :version "24.1" :type 'boolean) @@ -3564,7 +3536,7 @@ displaying the tags menu is not even shown, until you press C-c again." "Non-nil means fast tags selection interface will also offer TODO states. This is an undocumented feature, you should not rely on it.") -(defcustom org-tags-column (if (featurep 'xemacs) -76 -77) +(defcustom org-tags-column -77 "The column to which tags should be indented in a headline. If this number is positive, it specifies the column. If it is negative, it means that the tags should be flushright to that column. For example, @@ -3661,7 +3633,7 @@ is better to limit inheritance to certain tags using the variables "Hook that is run after the tags in a line have changed.") (defgroup org-properties nil - "Options concerning properties in Org-mode." + "Options concerning properties in Org mode." :tag "Org Properties" :group 'org) @@ -3689,7 +3661,7 @@ and the clock summary: ((\"Remaining\" (lambda(value) (let ((clocksum (org-clock-sum-current-item)) - (effort (org-duration-string-to-minutes + (effort (org-duration-to-minutes (org-entry-get (point) \"Effort\")))) (org-minutes-to-clocksum-string (- effort clocksum))))))" :group 'org-properties @@ -3728,14 +3700,14 @@ in this variable)." (regexp :tag "Properties matched by regexp"))) (defun org-property-inherit-p (property) - "Check if PROPERTY is one that should be inherited." + "Return a non-nil value if PROPERTY should be inherited." (cond ((eq org-use-property-inheritance t) t) ((not org-use-property-inheritance) nil) ((stringp org-use-property-inheritance) (string-match org-use-property-inheritance property)) ((listp org-use-property-inheritance) - (member property org-use-property-inheritance)) + (member-ignore-case property org-use-property-inheritance)) (t (error "Invalid setting of `org-use-property-inheritance'")))) (defcustom org-columns-default-format "%25ITEM %TODO %3PRIORITY %TAGS" @@ -3756,19 +3728,6 @@ ellipses string, only part of the ellipses string will be shown." :group 'org-properties :type 'string) -(defcustom org-columns-modify-value-for-display-function nil - "Function that modifies values for display in column view. -For example, it can be used to cut out a certain part from a time stamp. -The function must take 2 arguments: - -column-title The title of the column (*not* the property name) -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 '(choice (const nil) (function))) - (defconst org-global-properties-fixed '(("VISIBILITY_ALL" . "folded children content all") ("CLOCK_MODELINE_TOTAL_ALL" . "current today repeat all auto")) @@ -3799,18 +3758,17 @@ You can set buffer-local values for the same purpose in the variable (cons (string :tag "Property") (string :tag "Value")))) -(defvar org-file-properties nil +(defvar-local org-file-properties nil "List of property/value pairs that can be inherited by any entry. Valid for the current buffer. This variable is populated from #+PROPERTY lines.") -(make-variable-buffer-local 'org-file-properties) (defgroup org-agenda nil - "Options concerning agenda views in Org-mode." + "Options concerning agenda views in Org mode." :tag "Org Agenda" :group 'org) -(defvar org-category nil +(defvar-local org-category nil "Variable used by org files to set a category for agenda display. Such files should use a file variable to set it, for example @@ -3822,22 +3780,22 @@ or contain a special line If the file does not specify a category, then file's base name is used instead.") -(make-variable-buffer-local 'org-category) (put 'org-category 'safe-local-variable (lambda (x) (or (symbolp x) (stringp x)))) (defcustom org-agenda-files nil "The files to be used for agenda display. -Entries may be added to this list with \\[org-agenda-file-to-front] and removed with -\\[org-remove-file]. You can also use customize to edit the list. -If an entry is a directory, all files in that directory that are matched by -`org-agenda-file-regexp' will be part of the file list. +If an entry is a directory, all files in that directory that are matched +by `org-agenda-file-regexp' will be part of the file list. If the value of the variable is not a list but a single file name, then -the list of agenda files is actually stored and maintained in that file, one -agenda file per line. In this file paths can be given relative to +the list of agenda files is actually stored and maintained in that file, +one agenda file per line. In this file paths can be given relative to `org-directory'. Tilde expansion and environment variable substitution -are also made." +are also made. + +Entries may be added to this list with `\\[org-agenda-file-to-front]' +and removed with `\\[org-remove-file]'." :group 'org-agenda :type '(choice (repeat :tag "List of files and directories" file) @@ -3854,7 +3812,8 @@ 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 searched in addition to the agenda files by the -commands `org-search-view' (`C-c a s') and `org-occur-in-agenda-files'. +commands `org-search-view' (`\\[org-agenda] 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 @@ -3867,7 +3826,7 @@ scope." (const :tag "Agenda Archives" agenda-archives) (repeat :inline t (file)))) -(org-defvaralias 'org-agenda-multi-occur-extra-files +(defvaralias 'org-agenda-multi-occur-extra-files 'org-agenda-text-search-extra-files) (defcustom org-agenda-skip-unavailable-files nil @@ -3887,7 +3846,7 @@ forth between agenda and calendar." (defcustom org-calendar-insert-diary-entry-key [?i] "The key to be installed in `calendar-mode-map' for adding diary entries. This option is irrelevant until `org-agenda-diary-file' has been configured -to point to an Org-mode file. When that is the case, the command +to point to an Org file. When that is the case, the command `org-agenda-diary-entry' will be bound to the key given here, by default `i'. In the calendar, `i' normally adds entries to `diary-file'. So if you want to continue doing this, you need to change this to a different @@ -3917,7 +3876,7 @@ points to a file, `org-agenda-diary-entry' will be used instead." 'org-agenda-diary-entry)))))) (defgroup org-latex nil - "Options for embedding LaTeX code into Org-mode." + "Options for embedding LaTeX code into Org mode." :tag "Org LaTeX" :group 'org) @@ -3989,27 +3948,114 @@ When using LaTeXML set this option to (const :tag "None" nil) (string :tag "\nShell command"))) -(defcustom org-latex-create-formula-image-program 'dvipng - "Program to convert LaTeX fragments with. - -dvipng Process the LaTeX fragments to dvi file, then convert - dvi files to png files using dvipng. - 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" +(defcustom org-preview-latex-default-process 'dvipng + "The default process to convert LaTeX fragments to image files. +All available processes and theirs documents can be found in +`org-preview-latex-process-alist', which see." :group 'org-latex - :version "24.1" - :type '(choice - (const :tag "dvipng" dvipng) - (const :tag "imagemagick" imagemagick))) + :version "26.1" + :package-version '(Org . "9.0") + :type 'symbol) + +(defcustom org-preview-latex-process-alist + '((dvipng + :programs ("latex" "dvipng") + :description "dvi > png" + :message "you need to install the programs: latex and dvipng." + :image-input-type "dvi" + :image-output-type "png" + :image-size-adjust (1.0 . 1.0) + :latex-compiler ("latex -interaction nonstopmode -output-directory %o %f") + :image-converter ("dvipng -fg %F -bg %B -D %D -T tight -o %O %f")) + (dvisvgm + :programs ("latex" "dvisvgm") + :description "dvi > svg" + :message "you need to install the programs: latex and dvisvgm." + :use-xcolor t + :image-input-type "dvi" + :image-output-type "svg" + :image-size-adjust (1.7 . 1.5) + :latex-compiler ("latex -interaction nonstopmode -output-directory %o %f") + :image-converter ("dvisvgm %f -n -b min -c %S -o %O")) + (imagemagick + :programs ("latex" "convert") + :description "pdf > png" + :message "you need to install the programs: latex and imagemagick." + :use-xcolor t + :image-input-type "pdf" + :image-output-type "png" + :image-size-adjust (1.0 . 1.0) + :latex-compiler ("pdflatex -interaction nonstopmode -output-directory %o %f") + :image-converter + ("convert -density %D -trim -antialias %f -quality 100 %O"))) + "Definitions of external processes for LaTeX previewing. +Org mode can use some external commands to generate TeX snippet's images for +previewing or inserting into HTML files, e.g., \"dvipng\". This variable tells +`org-create-formula-image' how to call them. + +The value is an alist with the pattern (NAME . PROPERTIES). NAME is a symbol. +PROPERTIES accepts the following attributes: + + :programs list of strings, required programs. + :description string, describe the process. + :message string, message it when required programs cannot be found. + :image-input-type string, input file type of image converter (e.g., \"dvi\"). + :image-output-type string, output file type of image converter (e.g., \"png\"). + :use-xcolor boolean, when non-nil, LaTeX \"xcolor\" macro is used to + deal with background and foreground color of image. + Otherwise, dvipng style background and foregroud color + format are generated. You may then refer to them in + command options with \"%F\" and \"%B\". + :image-size-adjust cons of numbers, the car element is used to adjust LaTeX + image size showed in buffer and the cdr element is for + HTML file. This option is only useful for process + developers, users should use variable + `org-format-latex-options' instead. + :post-clean list of strings, files matched are to be cleaned up once + the image is generated. When nil, the files with \".dvi\", + \".xdv\", \".pdf\", \".tex\", \".aux\", \".log\", \".svg\", + \".png\", \".jpg\", \".jpeg\" or \".out\" extension will + be cleaned up. + :latex-header list of strings, the LaTeX header of the snippet file. + When nil, the fallback value is used instead, which is + controlled by `org-format-latex-header', + `org-latex-default-packages-alist' and + `org-latex-packages-alist', which see. + :latex-compiler list of LaTeX commands, as strings. Each of them is given + to the shell. Place-holders \"%t\", \"%b\" and \"%o\" are + replaced with values defined below. + :image-converter list of image converter commands strings. Each of them is + given to the shell and supports any of the following + place-holders defined below. + +Place-holders used by `:image-converter' and `:latex-compiler': + + %f input file name + %b base name of input file + %o base directory of input file + %O absolute output file name + +Place-holders only used by `:image-converter': + + %F foreground of image + %B background of image + %D dpi, which is used to adjust image size by some processing commands. + %S the image size scale ratio, which is used to adjust image size by some + processing commands." + :group 'org-latex + :version "26.1" + :package-version '(Org . "9.0") + :type '(alist :tag "LaTeX to image backends" + :value-type (plist))) -(defcustom org-latex-preview-ltxpng-directory "ltxpng/" +(defcustom org-preview-latex-image-directory "ltximg/" "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" + :version "26.1" + :package-version '(Org . "9.0") :type 'string) (defun org-format-latex-mathml-available-p () @@ -4069,9 +4115,8 @@ header, or they will be appended." (default-value var))) (defcustom org-latex-default-packages-alist - '(("AUTO" "inputenc" t) - ("T1" "fontenc" t) - ("" "fixltx2e" nil) + '(("AUTO" "inputenc" t ("pdflatex")) + ("T1" "fontenc" t ("pdflatex")) ("" "graphicx" t) ("" "grffile" t) ("" "longtable" nil) @@ -4092,7 +4137,6 @@ 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 -- fixltx2e: Important patches of LaTeX itself - graphicx: for including images - grffile: allow periods and spaces in graphics file names - longtable: For multipage tables @@ -4114,18 +4158,21 @@ a string. A cell is of the format - \(\"options\" \"package\" SNIPPET-FLAG) + (\"options\" \"package\" SNIPPET-FLAG COMPILERS) If SNIPPET-FLAG is non-nil, the package also needs to be included when compiling LaTeX snippets into images for inclusion into -non-LaTeX output. +non-LaTeX output. COMPILERS is a list of compilers that should +include the package, see `org-latex-compiler'. If the document +compiler is not in the list, and the list is non-nil, the package +will not be inserted in the final document. A string will be inserted as-is in the header of the document." :group 'org-latex :group 'org-export-latex :set 'org-set-packages-alist :get 'org-get-packages-alist - :version "25.1" + :version "26.1" :package-version '(Org . "8.3") :type '(repeat (choice @@ -4143,7 +4190,7 @@ Each element is either a cell or a string. A cell is of the format: - \(\"options\" \"package\" SNIPPET-FLAG) + (\"options\" \"package\" SNIPPET-FLAG) SNIPPET-FLAG, when non-nil, indicates that this package is also needed when turning LaTeX snippets into images for inclusion into @@ -4170,7 +4217,7 @@ Make sure that you only list packages here which: (string :tag "A line of LaTeX")))) (defgroup org-appearance nil - "Settings for Org-mode appearance." + "Settings for Org mode appearance." :tag "Org Appearance" :group 'org) @@ -4200,7 +4247,7 @@ lines to the buffer: (defcustom org-hidden-keywords nil "List of symbols corresponding to keywords to be hidden the org buffer. -For example, a value '(title) for this list will make the document's title +For example, a value \\='(title) for this list will make the document's title appear in the buffer without the initial #+TITLE: keyword." :group 'org-appearance :version "24.1" @@ -4289,8 +4336,10 @@ After a match, the match groups contain these elements: 3 The leading marker like * or /, indicating the type of highlighting 4 The text between the emphasis markers, not including the markers 5 The character after the match, empty at the end of a line") + (defvar org-verbatim-re nil "Regular expression for matching verbatim text.") + (defvar org-emphasis-regexp-components) ; defined just below (defvar org-emphasis-alist) ; defined just below (defun org-set-emph-re (var val) @@ -4299,60 +4348,23 @@ After a match, the match groups contain these elements: (when (and (boundp 'org-emphasis-alist) (boundp 'org-emphasis-regexp-components) org-emphasis-alist org-emphasis-regexp-components) - (let* ((e org-emphasis-regexp-components) - (pre (car e)) - (post (nth 1 e)) - (border (nth 2 e)) - (body (nth 3 e)) - (nl (nth 4 e)) - (body1 (concat body "*?")) - (markers (mapconcat 'car org-emphasis-alist "")) - (vmarkers (mapconcat - (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) - (setq markers (concat (replace-match "" t t markers) "^"))) - (if (string-match "-" markers) - (setq markers (concat (replace-match "" t t markers) "-"))) - (if (string-match "\\^" vmarkers) - (setq vmarkers (concat (replace-match "" t t vmarkers) "^"))) - (if (string-match "-" vmarkers) - (setq vmarkers (concat (replace-match "" t t vmarkers) "-"))) - (if (> nl 0) - (setq body1 (concat body1 "\\(?:\n" body "*?\\)\\{0," - (int-to-string nl) "\\}"))) - ;; Make the regexp - (setq org-emph-re - (concat "\\([" pre "]\\|^\\)" - "\\(" - "\\([" markers "]\\)" - "\\(" - "[^" border "]\\|" - "[^" border "]" - body1 - "[^" border "]" - "\\)" - "\\3\\)" - "\\([" post "]\\|$\\)")) - (setq org-verbatim-re - (concat "\\([" pre "]\\|^\\)" - "\\(" - "\\([" vmarkers "]\\)" - "\\(" - "[^" border "]\\|" - "[^" border "]" - body1 - "[^" border "]" - "\\)" - "\\3\\)" - "\\([" post "]\\|$\\)"))))) + (pcase-let* + ((`(,pre ,post ,border ,body ,nl) org-emphasis-regexp-components) + (body (if (<= nl 0) body + (format "%s*?\\(?:\n%s*?\\)\\{0,%d\\}" body body nl))) + (template + (format (concat "\\([%s]\\|^\\)" ;before markers + "\\(\\([%%s]\\)\\([^%s]\\|[^%s]%s[^%s]\\)\\3\\)" + "\\([%s]\\|$\\)") ;after markers + pre border border body border post))) + (setq org-emph-re (format template "*/_+")) + (setq org-verbatim-re (format template "=~"))))) ;; 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) + '(" \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 like \" *strong word* \", we call the initial space PREMATCH, the final @@ -4370,17 +4382,17 @@ newline The maximum number of newlines allowed in an emphasis exp. You need to reload Org or to restart Emacs after customizing this.") (defcustom org-emphasis-alist - `(("*" bold) + '(("*" bold) ("/" italic) ("_" underline) ("=" org-verbatim verbatim) ("~" org-code verbatim) - ("+" ,(if (featurep 'xemacs) 'org-table '(:strike-through t)))) + ("+" (: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. +in Org buffers. You need to reload Org or to restart Emacs after customizing this." :group 'org-appearance @@ -4395,98 +4407,68 @@ You need to reload Org or to restart Emacs after customizing this." (plist :tag "Face property list")) (option (const verbatim))))) -(defvar org-protecting-blocks - '("src" "example" "latex" "ascii" "html" "ditaa" "dot" "r" "R") +(defvar org-protecting-blocks '("src" "example" "export") "Blocks that contain text that is quoted, i.e. not processed as Org syntax. This is needed for font-lock setup.") -;;; Miscellaneous options - -(defgroup org-completion nil - "Completion in Org-mode." - :tag "Org Completion" - :group 'org) - -(defcustom org-completion-use-ido nil - "Non-nil means use ido completion wherever possible. -Note that `ido-mode' must be active for this variable to be relevant. -If you decide to turn this variable on, you might well want to turn off -`org-outline-path-complete-in-steps'. -See also `org-completion-use-iswitchb'." - :group 'org-completion - :type 'boolean) - -(defcustom org-completion-use-iswitchb nil - "Non-nil means use iswitchb completion wherever possible. -Note that `iswitchb-mode' must be active for this variable to be relevant. -If you decide to turn this variable on, you might well want to turn off -`org-outline-path-complete-in-steps'. -Note that this variable has only an effect if `org-completion-use-ido' is nil." - :group 'org-completion - :type 'boolean) - -(defcustom org-completion-fallback-command 'hippie-expand - "The expansion command called by \\[pcomplete] in normal context. -Normal means, no org-mode-specific context." - :group 'org-completion - :type 'function) - ;;; Functions and variables from their packages ;; Declared here to avoid compiler warnings - -;; XEmacs only -(defvar outline-mode-menu-heading) -(defvar outline-mode-menu-show) -(defvar outline-mode-menu-hide) -(defvar zmacs-regions) ; XEmacs regions - -;; Emacs only (defvar mark-active) ;; Various packages -(declare-function calendar-iso-to-absolute "cal-iso" (date)) -(declare-function calendar-forward-day "cal-move" (arg)) -(declare-function calendar-goto-date "cal-move" (date)) -(declare-function calendar-goto-today "cal-move" ()) -(declare-function calendar-iso-from-absolute "cal-iso" (date)) -(defvar calc-embedded-close-formula) -(defvar calc-embedded-open-formula) -(declare-function cdlatex-tab "ext:cdlatex" ()) +(declare-function calc-eval "calc" (str &optional separator &rest args)) +(declare-function calendar-forward-day "cal-move" (arg)) +(declare-function calendar-goto-date "cal-move" (date)) +(declare-function calendar-goto-today "cal-move" ()) +(declare-function calendar-iso-from-absolute "cal-iso" (date)) +(declare-function calendar-iso-to-absolute "cal-iso" (date)) (declare-function cdlatex-compute-tables "ext:cdlatex" ()) -(declare-function dired-get-filename "dired" (&optional localp no-error-if-not-filep)) -(defvar font-lock-unfontify-region-function) -(declare-function iswitchb-read-buffer "iswitchb" - (prompt &optional default require-match start matches-set)) -(defvar iswitchb-temp-buflist) -(declare-function org-gnus-follow-link "org-gnus" (&optional group article)) -(defvar org-agenda-tags-todo-honor-ignore-options) -(declare-function org-agenda-skip "org-agenda" ()) -(declare-function - org-agenda-format-item "org-agenda" - (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" +(declare-function cdlatex-tab "ext:cdlatex" ()) +(declare-function dired-get-filename + "dired" + (&optional localp no-error-if-not-filep)) +(declare-function iswitchb-read-buffer + "iswitchb" + (prompt &optional + default require-match _predicate start matches-set)) +(declare-function org-agenda-change-all-lines + "org-agenda" (newhead hdmarker &optional fixface just-this)) -(declare-function org-agenda-set-restriction-lock "org-agenda" (&optional type)) +(declare-function org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item + "org-agenda" + (&optional end)) +(declare-function org-agenda-copy-local-variable "org-agenda" (var)) +(declare-function org-agenda-format-item + "org-agenda" + (extra txt &optional level category tags dotime + remove-re habitp)) (declare-function org-agenda-maybe-redo "org-agenda" ()) -(declare-function org-agenda-save-markers-for-cut-and-paste "org-agenda" +(declare-function org-agenda-new-marker "org-agenda" (&optional pos)) +(declare-function org-agenda-save-markers-for-cut-and-paste + "org-agenda" (beg end)) -(declare-function org-agenda-copy-local-variable "org-agenda" (var)) -(declare-function org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item - "org-agenda" (&optional end)) -(declare-function org-inlinetask-remove-END-maybe "org-inlinetask" ()) -(declare-function org-inlinetask-in-task-p "org-inlinetask" ()) +(declare-function org-agenda-set-restriction-lock "org-agenda" (&optional type)) +(declare-function org-agenda-skip "org-agenda" ()) +(declare-function org-attach-reveal "org-attach" (&optional if-exists)) +(declare-function org-gnus-follow-link "org-gnus" (&optional group article)) +(declare-function org-indent-mode "org-indent" (&optional arg)) (declare-function org-inlinetask-goto-beginning "org-inlinetask" ()) (declare-function org-inlinetask-goto-end "org-inlinetask" ()) -(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-inlinetask-in-task-p "org-inlinetask" ()) +(declare-function org-inlinetask-remove-END-maybe "org-inlinetask" ()) (declare-function orgtbl-send-table "org-table" (&optional maybe)) +(declare-function parse-time-string "parse-time" (string)) +(declare-function speedbar-line-directory "speedbar" (&optional depth)) + +(defvar align-mode-rules-list) +(defvar calc-embedded-close-formula) +(defvar calc-embedded-open-formula) +(defvar calc-embedded-open-mode) +(defvar font-lock-unfontify-region-function) +(defvar iswitchb-temp-buflist) +(defvar org-agenda-tags-todo-honor-ignore-options) (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)) -(declare-function calc-eval "calc" (str &optional separator &rest args)) ;;;###autoload (defun turn-on-orgtbl () @@ -4502,11 +4484,10 @@ If `org-enable-table-editor' is nil, return nil unconditionally." org-enable-table-editor (save-excursion (beginning-of-line) - (org-looking-at-p (if table-type "[ \t]*[|+]" "[ \t]*|"))) + (looking-at-p (if table-type "[ \t]*[|+]" "[ \t]*|"))) (or (not (derived-mode-p 'org-mode)) (let ((e (org-element-lineage (org-element-at-point) '(table) t))) (and e (or table-type (eq (org-element-property :type e) 'org))))))) -(defsubst org-table-p () (org-at-table-p)) (defun org-at-table.el-p () "Non-nil when point is at a table.el table." @@ -4515,24 +4496,6 @@ If `org-enable-table-editor' is nil, return nil unconditionally." (and (eq (org-element-type element) 'table) (eq (org-element-property :type element) 'table.el))))) -(defun org-table-recognize-table.el () - "If there is a table.el table nearby, recognize it and move into it." - (when (and org-table-tab-recognizes-table.el (org-at-table.el-p)) - (beginning-of-line) - (unless (or (looking-at org-table-dataline-regexp) - (not (looking-at org-table1-hline-regexp))) - (forward-line) - (when (looking-at org-table-any-border-regexp) - (forward-line -2))) - (if (re-search-forward "|" (org-table-end t) t) - (progn - (require 'table) - (if (table--at-cell-p (point)) t - (message "recognizing table.el table...") - (table-recognize-table) - (message "recognizing table.el table...done"))) - (error "This should not happen")))) - (defun org-at-table-hline-p () "Non-nil when point is inside a hline in a table. Assume point is already in a table. If `org-enable-table-editor' @@ -4544,22 +4507,20 @@ is nil, return nil unconditionally." (defun org-table-map-tables (function &optional quietly) "Apply FUNCTION to the start of all tables in the buffer." - (save-excursion - (save-restriction - (widen) - (goto-char (point-min)) - (while (re-search-forward org-table-any-line-regexp nil t) - (unless quietly - (message "Mapping tables: %d%%" - (floor (* 100.0 (point)) (buffer-size)))) - (beginning-of-line 1) - (when (and (looking-at org-table-line-regexp) - ;; Exclude tables in src/example/verbatim/clocktable blocks - (not (org-in-block-p '("src" "example" "verbatim" "clocktable")))) - (save-excursion (funcall function)) - (or (looking-at org-table-line-regexp) - (forward-char 1))) - (re-search-forward org-table-any-border-regexp nil 1)))) + (org-with-wide-buffer + (goto-char (point-min)) + (while (re-search-forward org-table-any-line-regexp nil t) + (unless quietly + (message "Mapping tables: %d%%" + (floor (* 100.0 (point)) (buffer-size)))) + (beginning-of-line 1) + (when (and (looking-at org-table-line-regexp) + ;; Exclude tables in src/example/verbatim/clocktable blocks + (not (org-in-block-p '("src" "example" "verbatim" "clocktable")))) + (save-excursion (funcall function)) + (or (looking-at org-table-line-regexp) + (forward-char 1))) + (re-search-forward org-table-any-border-regexp nil 1))) (unless quietly (message "Mapping tables: done"))) (declare-function org-clock-save-markers-for-cut-and-paste "org-clock" (beg end)) @@ -4610,7 +4571,7 @@ If yes, offer to stop it and to save the buffer with the changes." (add-hook 'kill-emacs-hook 'org-clock-save)) (defgroup org-archive nil - "Options concerning archiving in Org-mode." + "Options concerning archiving in Org mode." :tag "Org Archive" :group 'org-structure) @@ -4625,7 +4586,7 @@ When the filename is omitted, archiving happens in the same file. %s in the filename will be replaced by the current file name (without the directory part). Archiving to a different file is useful to keep archived entries from contributing to the -Org-mode Agenda. +Org Agenda. The archived entries will be filed as subtrees of the specified headline. When the headline is omitted, the subtrees are simply @@ -4722,7 +4683,7 @@ Otherwise, these types are allowed: (const :tag "Only scheduled timestamps" scheduled) (const :tag "Only deadline timestamps" deadline) (const :tag "Only closed timestamps" closed)) - :version "25.1" + :version "26.1" :package-version '(Org . "8.3") :group 'org-sparse-trees) @@ -4736,9 +4697,10 @@ Otherwise, these types are allowed: (end (if globalp (point-max) (org-end-of-subtree t)))) (org-hide-archived-subtrees beg end) (goto-char beg) - (if (looking-at (concat ".*:" org-archive-tag ":")) - (message "%s" (substitute-command-keys - "Subtree is archived and stays closed. Use \\[org-force-cycle-archived] to cycle it anyway."))))))) + (when (looking-at-p (concat ".*:" org-archive-tag ":")) + (message "%s" (substitute-command-keys + "Subtree is archived and stays closed. Use \ +`\\[org-force-cycle-archived]' to cycle it anyway."))))))) (defun org-force-cycle-archived () "Cycle subtree even if it is archived." @@ -4774,7 +4736,6 @@ Otherwise, these types are allowed: ;; Declare Column View Code -(declare-function org-columns-number-to-string "org-colview" (n fmt &optional printf)) (declare-function org-columns-get-format-and-top-level "org-colview" ()) (declare-function org-columns-compute "org-colview" (property)) @@ -4787,36 +4748,47 @@ Otherwise, these types are allowed: ;;; Variables for pre-computed regular expressions, all buffer local -(defvar org-todo-regexp nil - "Matches any of the TODO state keywords.") -(make-variable-buffer-local 'org-todo-regexp) -(defvar org-not-done-regexp nil - "Matches any of the TODO state keywords except the last one.") -(make-variable-buffer-local 'org-not-done-regexp) -(defvar org-not-done-heading-regexp nil - "Matches a TODO headline that is not done.") -(make-variable-buffer-local 'org-not-done-heading-regexp) -(defvar org-todo-line-regexp nil - "Matches a headline and puts TODO state into group 2 if present.") -(make-variable-buffer-local 'org-todo-line-regexp) -(defvar org-complex-heading-regexp nil +(defvar-local org-todo-regexp nil + "Matches any of the TODO state keywords. +Since TODO keywords are case-sensitive, `case-fold-search' is +expected to be bound to nil when matching against this regexp.") + +(defvar-local org-not-done-regexp nil + "Matches any of the TODO state keywords except the last one. +Since TODO keywords are case-sensitive, `case-fold-search' is +expected to be bound to nil when matching against this regexp.") + +(defvar-local org-not-done-heading-regexp nil + "Matches a TODO headline that is not done. +Since TODO keywords are case-sensitive, `case-fold-search' is +expected to be bound to nil when matching against this regexp.") + +(defvar-local org-todo-line-regexp nil + "Matches a headline and puts TODO state into group 2 if present. +Since TODO keywords are case-sensitive, `case-fold-search' is +expected to be bound to nil when matching against this regexp.") + +(defvar-local org-complex-heading-regexp nil "Matches a headline and puts everything into groups: -group 1: the stars -group 2: The todo keyword, maybe + +group 1: Stars +group 2: The TODO keyword, maybe group 3: Priority cookie group 4: True headline -group 5: Tags") -(make-variable-buffer-local 'org-complex-heading-regexp) -(defvar org-complex-heading-regexp-format nil +group 5: Tags + +Since TODO keywords are case-sensitive, `case-fold-search' is +expected to be bound to nil when matching against this regexp.") + +(defvar-local org-complex-heading-regexp-format nil "Printf format to make regexp to match an exact headline. This regexp will match the headline of any node which has the exact headline text that is put into the format, but may have any TODO state, priority and tags.") -(make-variable-buffer-local 'org-complex-heading-regexp-format) -(defvar org-todo-line-tags-regexp nil + +(defvar-local org-todo-line-tags-regexp nil "Matches a headline and puts TODO state into group 2 if present. Also put tags into group 4 if tags are present.") -(make-variable-buffer-local 'org-todo-line-tags-regexp) (defconst org-plain-time-of-day-regexp (concat @@ -4957,24 +4929,44 @@ related expressions." '("ARCHIVE" "CATEGORY" "COLUMNS" "CONSTANTS" "LINK" "OPTIONS" "PRIORITIES" "PROPERTY" "SEQ_TODO" "STARTUP" "TODO" "TYP_TODO"))))))) - (org--setup-process-tags - (cdr (assq 'tags alist)) (cdr (assq 'filetags alist))) + ;; Startup options. Get this early since it does change + ;; behavior for other options (e.g., tags). + (let ((startup (cdr (assq 'startup alist)))) + (dolist (option startup) + (let ((entry (assoc-string option org-startup-options t))) + (when entry + (let ((var (nth 1 entry)) + (val (nth 2 entry))) + (if (not (nth 3 entry)) (set (make-local-variable var) val) + (unless (listp (symbol-value var)) + (set (make-local-variable var) nil)) + (add-to-list var val))))))) + (setq-local org-file-tags + (mapcar #'org-add-prop-inherited + (cdr (assq 'filetags alist)))) + (setq org-current-tag-alist + (append org-tag-persistent-alist + (let ((tags (cdr (assq 'tags alist)))) + (if tags (org-tag-string-to-alist tags) + org-tag-alist)))) + (setq org-tag-groups-alist + (org-tag-alist-to-groups org-current-tag-alist)) (unless tags-only ;; File properties. - (org-set-local 'org-file-properties (cdr (assq 'property alist))) + (setq-local org-file-properties (cdr (assq 'property alist))) ;; Archive location. (let ((archive (cdr (assq 'archive alist)))) - (when archive (org-set-local 'org-archive-location archive))) + (when archive (setq-local org-archive-location archive))) ;; Category. (let ((cat (org-string-nw-p (cdr (assq 'category alist))))) (when cat - (org-set-local 'org-category (intern cat)) - (org-set-local 'org-file-properties - (org--update-property-plist - "CATEGORY" cat org-file-properties)))) + (setq-local org-category (intern cat)) + (setq-local org-file-properties + (org--update-property-plist + "CATEGORY" cat org-file-properties)))) ;; Columns. (let ((column (cdr (assq 'columns alist)))) - (when column (org-set-local 'org-columns-default-format column))) + (when column (setq-local org-columns-default-format column))) ;; Constants. (setq org-table-formula-constants-local (cdr (assq 'constants alist))) ;; Link abbreviations. @@ -4983,33 +4975,22 @@ related expressions." ;; Priorities. (let ((priorities (cdr (assq 'priorities alist)))) (when priorities - (org-set-local 'org-highest-priority (nth 0 priorities)) - (org-set-local 'org-lowest-priority (nth 1 priorities)) - (org-set-local 'org-default-priority (nth 2 priorities)))) + (setq-local org-highest-priority (nth 0 priorities)) + (setq-local org-lowest-priority (nth 1 priorities)) + (setq-local org-default-priority (nth 2 priorities)))) ;; Scripts. (let ((scripts (assq 'scripts alist))) (when scripts - (org-set-local 'org-use-sub-superscripts (cdr scripts)))) - ;; Startup options. - (let ((startup (cdr (assq 'startup alist)))) - (dolist (option startup) - (let ((entry (assoc-string option org-startup-options t))) - (when entry - (let ((var (nth 1 entry)) - (val (nth 2 entry))) - (if (not (nth 3 entry)) (org-set-local var val) - (unless (listp (symbol-value var)) - (org-set-local var nil)) - (add-to-list var val))))))) + (setq-local org-use-sub-superscripts (cdr scripts)))) ;; TODO keywords. - (org-set-local 'org-todo-kwd-alist nil) - (org-set-local 'org-todo-key-alist nil) - (org-set-local 'org-todo-key-trigger nil) - (org-set-local 'org-todo-keywords-1 nil) - (org-set-local 'org-done-keywords nil) - (org-set-local 'org-todo-heads nil) - (org-set-local 'org-todo-sets nil) - (org-set-local 'org-todo-log-states nil) + (setq-local org-todo-kwd-alist nil) + (setq-local org-todo-key-alist nil) + (setq-local org-todo-key-trigger nil) + (setq-local org-todo-keywords-1 nil) + (setq-local org-done-keywords nil) + (setq-local org-todo-heads nil) + (setq-local org-todo-sets nil) + (setq-local org-todo-log-states nil) (let ((todo-sequences (or (nreverse (cdr (assq 'todo alist))) (let ((d (default-value 'org-todo-keywords))) @@ -5057,9 +5038,9 @@ related expressions." ;; 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. - (if (not org-done-keywords) - (setq org-done-keywords - (and org-todo-keywords-1 (last org-todo-keywords-1)))) + (unless org-done-keywords + (setq org-done-keywords + (and org-todo-keywords-1 (last org-todo-keywords-1)))) (setq org-not-done-keywords (org-delete-all org-done-keywords (copy-sequence org-todo-keywords-1)) @@ -5074,7 +5055,7 @@ related expressions." "\\(?: +" org-todo-regexp "\\)?" "\\(?: +\\(\\[#.\\]\\)\\)?" "\\(?: +\\(.*?\\)\\)??" - (org-re "\\(?:[ \t]+\\(:[[:alnum:]_@#%:]+:\\)\\)?") + "\\(?:[ \t]+\\(:[[:alnum:]_@#%:]+:\\)\\)?" "[ \t]*$") org-complex-heading-regexp-format (concat "^\\(\\*+\\)" @@ -5086,13 +5067,13 @@ related expressions." "\\(%s\\)" "\\(?: *\\[[0-9%%/]+\\]\\)*" "\\)" - (org-re "\\(?:[ \t]+\\(:[[:alnum:]_@#%%:]+:\\)\\)?") + "\\(?:[ \t]+\\(:[[:alnum:]_@#%%:]+:\\)\\)?" "[ \t]*$") org-todo-line-tags-regexp (concat "^\\(\\*+\\)" "\\(?: +" org-todo-regexp "\\)?" "\\(?: +\\(.*?\\)\\)??" - (org-re "\\(?:[ \t]+\\(:[[:alnum:]:_@#%]+:\\)\\)?") + "\\(?:[ \t]+\\(:[[:alnum:]:_@#%]+:\\)\\)?" "[ \t]*$")) (org-compute-latex-and-related-regexp))))) @@ -5144,8 +5125,8 @@ Return value contains the following keys: `archive', `category', ((equal key "LINK") (when (string-match "\\`\\(\\S-+\\)[ \t]+\\(.+\\)" value) (let ((links (assq 'link alist)) - (pair (cons (org-match-string-no-properties 1 value) - (org-match-string-no-properties 2 value)))) + (pair (cons (match-string-no-properties 1 value) + (match-string-no-properties 2 value)))) (if links (push pair (cdr links)) (push (list 'link pair) alist))))) ((equal key "OPTIONS") @@ -5162,8 +5143,8 @@ Return value contains the following keys: `archive', `category', (when (string-match "\\(\\S-+\\)[ \t]+\\(.*\\)" value) (let* ((property (assq 'property alist)) (value (org--update-property-plist - (org-match-string-no-properties 1 value) - (org-match-string-no-properties 2 value) + (match-string-no-properties 1 value) + (match-string-no-properties 2 value) (cdr property)))) (if property (setcdr property value) (push (cons 'property value) alist))))) @@ -5176,11 +5157,8 @@ Return value contains the following keys: `archive', `category', ((equal key "TAGS") (let ((tag-cell (assq 'tags alist))) (if tag-cell - (setcdr tag-cell - (append (cdr tag-cell) - '("\\n") - (org-split-string value))) - (push (cons 'tags (org-split-string value)) alist)))) + (setcdr tag-cell (concat (cdr tag-cell) "\n" value)) + (push (cons 'tags value) alist)))) ((member key '("TODO" "SEQ_TODO" "TYP_TODO")) (let ((todo (assq 'todo alist)) (value (cons (if (equal key "TYP_TODO") 'type 'sequence) @@ -5191,9 +5169,10 @@ Return value contains the following keys: `archive', `category', (unless buffer-read-only ; Do not check in Gnus messages. (let ((f (and (org-string-nw-p value) (expand-file-name - (org-remove-double-quotes value))))) + (org-unbracket-string "\"" "\"" value))))) (when (and f (file-readable-p f) (not (member f files))) (with-temp-buffer + (setq default-directory (file-name-directory f)) (insert-file-contents f) (setq alist ;; Fake Org mode to benefit from cache @@ -5203,67 +5182,93 @@ Return value contains the following keys: `archive', `category', regexp (cons f files) alist))))))))))))))) alist) -(defun org--setup-process-tags (tags filetags) - "Precompute variables used for tags. -TAGS is a list of tags and tag group symbols, as strings. -FILETAGS is a list of tags, as strings." - ;; Process the file tags. - (org-set-local 'org-file-tags - (mapcar #'org-add-prop-inherited filetags)) - ;; Provide default tags if no local tags are found. - (when (and (not tags) org-tag-alist) - (setq tags - (mapcar (lambda (tag) - (case (car tag) - (:startgroup "{") - (:endgroup "}") - (:startgrouptag "[") - (:endgrouptag "]") - (:grouptags ":") - (:newline "\\n") - (otherwise (concat (car tag) - (and (characterp (cdr tag)) - (format "(%c)" (cdr tag))))))) - org-tag-alist))) - ;; Process the tags. - (org-set-local 'org-tag-groups-alist nil) - (org-set-local 'org-tag-alist nil) - (let (group-flag) - (while tags - (let ((e (car tags))) - (setq tags (cdr tags)) - (cond - ((equal e "{") - (push '(:startgroup) org-tag-alist) - (when (equal (nth 1 tags) ":") (setq group-flag t))) - ((equal e "}") - (push '(:endgroup) org-tag-alist) - (setq group-flag nil)) - ((equal e "[") - (push '(:startgrouptag) org-tag-alist) - (when (equal (nth 1 tags) ":") (setq group-flag t))) - ((equal e "]") - (push '(:endgrouptag) org-tag-alist) - (setq group-flag nil)) - ((equal e ":") - (push '(:grouptags) org-tag-alist) - (setq group-flag 'append)) - ((equal e "\\n") (push '(:newline) org-tag-alist)) - ((string-match - (org-re (concat "\\`\\([[:alnum:]_@#%]+" - "\\|{.+?}\\)" ; regular expression - "\\(?:(\\(.\\))\\)?\\'")) e) - (let ((tag (match-string 1 e)) - (key (and (match-beginning 2) - (string-to-char (match-string 2 e))))) - (cond ((eq group-flag 'append) - (setcar org-tag-groups-alist - (append (car org-tag-groups-alist) (list tag)))) - (group-flag (push (list tag) org-tag-groups-alist))) - ;; Push all tags in groups, no matter if they already exist. - (unless (and (not group-flag) (assoc tag org-tag-alist)) - (push (cons tag key) org-tag-alist)))))))) - (setq org-tag-alist (nreverse org-tag-alist))) +(defun org-tag-string-to-alist (s) + "Return tag alist associated to string S. +S is a value for TAGS keyword or produced with +`org-tag-alist-to-string'. Return value is an alist suitable for +`org-tag-alist' or `org-tag-persistent-alist'." + (let ((lines (mapcar #'split-string (split-string s "\n" t))) + (tag-re (concat "\\`\\([[:alnum:]_@#%]+" + "\\|{.+?}\\)" ; regular expression + "\\(?:(\\(.\\))\\)?\\'")) + alist group-flag) + (dolist (tokens lines (cdr (nreverse alist))) + (push '(:newline) alist) + (while tokens + (let ((token (pop tokens))) + (pcase token + ("{" + (push '(:startgroup) alist) + (when (equal (nth 1 tokens) ":") (setq group-flag t))) + ("}" + (push '(:endgroup) alist) + (setq group-flag nil)) + ("[" + (push '(:startgrouptag) alist) + (when (equal (nth 1 tokens) ":") (setq group-flag t))) + ("]" + (push '(:endgrouptag) alist) + (setq group-flag nil)) + (":" + (push '(:grouptags) alist)) + ((guard (string-match tag-re token)) + (let ((tag (match-string 1 token)) + (key (and (match-beginning 2) + (string-to-char (match-string 2 token))))) + ;; Push all tags in groups, no matter if they already + ;; appear somewhere else in the list. + (when (or group-flag (not (assoc tag alist))) + (push (cons tag key) alist)))))))))) + +(defun org-tag-alist-to-string (alist &optional skip-key) + "Return tag string associated to ALIST. + +ALIST is an alist, as defined in `org-tag-alist' or +`org-tag-persistent-alist', or produced with +`org-tag-string-to-alist'. + +Return value is a string suitable as a value for \"TAGS\" +keyword. + +When optional argument SKIP-KEY is non-nil, skip selection keys +next to tags." + (mapconcat (lambda (token) + (pcase token + (`(:startgroup) "{") + (`(:endgroup) "}") + (`(:startgrouptag) "[") + (`(:endgrouptag) "]") + (`(:grouptags) ":") + (`(:newline) "\\n") + ((and + (guard (not skip-key)) + `(,(and tag (pred stringp)) . ,(and key (pred characterp)))) + (format "%s(%c)" tag key)) + (`(,(and tag (pred stringp)) . ,_) tag) + (_ (user-error "Invalid tag token: %S" token)))) + alist + " ")) + +(defun org-tag-alist-to-groups (alist) + "Return group alist from tag ALIST. +ALIST is an alist, as defined in `org-tag-alist' or +`org-tag-persistent-alist', or produced with +`org-tag-string-to-alist'. Return value is an alist following +the pattern (GROUP-TAG TAGS) where GROUP-TAG is the tag, as +a string, summarizing TAGS, as a list of strings." + (let (groups group-status current-group) + (dolist (token alist (nreverse groups)) + (pcase token + (`(,(or :startgroup :startgrouptag)) (setq group-status t)) + (`(,(or :endgroup :endgrouptag)) + (when (eq group-status 'append) + (push (nreverse current-group) groups)) + (setq group-status nil)) + (`(:grouptags) (setq group-status 'append)) + ((and `(,tag . ,_) (guard group-status)) + (if (eq group-status 'append) (push tag current-group) + (setq current-group (list tag)))) + (_ nil))))) (defun org-file-contents (file &optional noerror) "Return the contents of FILE, as a string." @@ -5280,12 +5285,10 @@ FILETAGS is a list of tags, as strings." (defun org-extract-log-state-settings (x) "Extract the log state setting from a TODO keyword string. This will extract info from a string like \"WAIT(w@/!)\"." - (let (kw key log1 log2) - (when (string-match "^\\(.*?\\)\\(?:(\\([^!@/]\\)?\\([!@]\\)?\\(?:/\\([!@]\\)\\)?)\\)?$" x) - (setq kw (match-string 1 x) - key (and (match-end 2) (match-string 2 x)) - log1 (and (match-end 3) (match-string 3 x)) - log2 (and (match-end 4) (match-string 4 x))) + (when (string-match "^\\(.*?\\)\\(?:(\\([^!@/]\\)?\\([!@]\\)?\\(?:/\\([!@]\\)\\)?)\\)?$" x) + (let ((kw (match-string 1 x)) + (log1 (and (match-end 3) (match-string 3 x))) + (log2 (and (match-end 4) (match-string 4 x)))) (and (or log1 log2) (list kw (and log1 (if (equal log1 "!") 'time 'note)) @@ -5315,7 +5318,7 @@ Respect keys that are already there." (pop clist)) (unless clist (while (rassoc alt used) - (incf alt))) + (cl-incf alt))) (push (cons (car e) (or (car clist) alt)) new)))) (nreverse new))) @@ -5328,13 +5331,7 @@ Respect keys that are already there." (defvar org-finish-function nil "Function to be called when `C-c C-c' is used. This is for getting out of special buffers like capture.") - - -;; FIXME: Occasionally check by commenting these, to make sure -;; no other functions uses these, forgetting to let-bind them. -(org-no-warnings (defvar entry)) ;; unprefixed, from calendar.el (defvar org-last-state) -(org-no-warnings (defvar date)) ;; unprefixed, from calendar.el ;; Defined somewhere in this file, but used before definition. (defvar org-entities) ;; defined in org-entities.el @@ -5342,7 +5339,7 @@ This is for getting out of special buffers like capture.") (defvar org-org-menu) (defvar org-tbl-menu) -;;;; Define the Org-mode +;;;; Define the Org mode ;; We use a before-change function to check if a table might need ;; an update. @@ -5350,7 +5347,7 @@ This is for getting out of special buffers like capture.") "Indicates that a table might need an update. This variable is set by `org-before-change-function'. `org-table-align' sets it back to nil.") -(defun org-before-change-function (beg end) +(defun org-before-change-function (_beg _end) "Every change indicates that a table might need an update." (setq org-table-may-need-update t)) (defvar org-mode-map) @@ -5364,9 +5361,6 @@ This variable is set by `org-before-change-function'. (defvar buffer-face-mode-face) (require 'outline) -(if (and (not (keymapp outline-mode-map)) (featurep 'allout)) - (error "Conflict with outdated version of allout.el. Load org.el before allout.el, or upgrade to newer allout, for example by switching to Emacs 22")) -(require 'noutline "noutline" 'noerror) ;; stock XEmacs does not have it ;; Other stuff we need. (require 'time-date) @@ -5393,15 +5387,15 @@ This variable is set by `org-before-change-function'. "Outline-based notes management and organizer, alias \"Carsten's outline-mode for keeping track of everything.\" -Org-mode develops organizational tasks around a NOTES file which -contains information about projects as plain text. Org-mode is -implemented on top of outline-mode, which is ideal to keep the content +Org mode develops organizational tasks around a NOTES file which +contains information about projects as plain text. Org mode is +implemented on top of Outline mode, which is ideal to keep the content of large files well structured. It supports ToDo items, deadlines and time stamps, which magically appear in the diary listing of the Emacs calendar. Tables are easily created with a built-in table editor. Plain text URL-like links connect to websites, emails (VM), Usenet messages (Gnus), BBDB entries, and any files related to the project. -For printing and sharing of notes, an Org-mode file (or a part of it) +For printing and sharing of notes, an Org file (or a part of it) can be exported as a structured ASCII or HTML file. The following commands are available: @@ -5411,29 +5405,18 @@ The following commands are available: ;; Get rid of Outline menus, they are not needed ;; Need to do this here because define-derived-mode sets up ;; the keymap so late. Still, it is a waste to call this each time - ;; we switch another buffer into org-mode. - (if (featurep 'xemacs) - (when (boundp 'outline-mode-menu-heading) - ;; Assume this is Greg's port, it uses easymenu - (easy-menu-remove outline-mode-menu-heading) - (easy-menu-remove outline-mode-menu-show) - (easy-menu-remove outline-mode-menu-hide)) - (define-key org-mode-map [menu-bar headings] 'undefined) - (define-key org-mode-map [menu-bar hide] 'undefined) - (define-key org-mode-map [menu-bar show] 'undefined)) + ;; we switch another buffer into Org mode. + (define-key org-mode-map [menu-bar headings] 'undefined) + (define-key org-mode-map [menu-bar hide] 'undefined) + (define-key org-mode-map [menu-bar show] 'undefined) (org-load-modules-maybe) - (when (featurep 'xemacs) - (easy-menu-add org-org-menu) - (easy-menu-add org-tbl-menu)) (org-install-agenda-files-menu) - (if org-descriptive-links (add-to-invisibility-spec '(org-link))) + (when org-descriptive-links (add-to-invisibility-spec '(org-link))) (add-to-invisibility-spec '(org-cwidth)) (add-to-invisibility-spec '(org-hide-block . t)) - (when (featurep 'xemacs) - (org-set-local 'line-move-ignore-invisible t)) - (org-set-local 'outline-regexp org-outline-regexp) - (org-set-local 'outline-level 'org-outline-level) + (setq-local outline-regexp org-outline-regexp) + (setq-local outline-level 'org-outline-level) (setq bidi-paragraph-direction 'left-to-right) (when (and org-ellipsis (fboundp 'set-display-table-slot) (boundp 'buffer-display-table) @@ -5442,10 +5425,8 @@ The following commands are available: (setq org-display-table (make-display-table))) (set-display-table-slot org-display-table 4 - (vconcat (mapcar - (lambda (c) (make-glyph-code c (and (not (stringp org-ellipsis)) - org-ellipsis))) - (if (stringp org-ellipsis) org-ellipsis "...")))) + (vconcat (mapcar (lambda (c) (make-glyph-code c 'org-ellipsis)) + (if (stringp org-ellipsis) org-ellipsis "...")))) (setq buffer-display-table org-display-table)) (org-set-regexps-and-options) (org-set-font-lock-defaults) @@ -5453,29 +5434,25 @@ The following commands are available: ;; 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 "# ") + (setq-local calc-embedded-open-mode "# ") ;; Modify a few syntax entries (modify-syntax-entry ?@ "w") (modify-syntax-entry ?\" "\"") (modify-syntax-entry ?\\ "_") (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 - 'org-unfontify-region) + (setq-local font-lock-unfontify-region-function 'org-unfontify-region) ;; Activate before-change-function - (org-set-local 'org-table-may-need-update t) - (org-add-hook 'before-change-functions 'org-before-change-function nil - 'local) + (setq-local org-table-may-need-update t) + (add-hook 'before-change-functions 'org-before-change-function nil 'local) ;; Check for running clock before killing a buffer - (org-add-hook 'kill-buffer-hook 'org-check-running-clock nil 'local) + (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) + (setq-local indent-line-function 'org-indent-line) + (setq-local indent-region-function 'org-indent-region) ;; Filling and auto-filling. (org-setup-filling) ;; Comments. @@ -5483,15 +5460,15 @@ The following commands are available: ;; Initialize cache. (org-element-cache-reset) ;; Beginning/end of defun - (org-set-local 'beginning-of-defun-function 'org-backward-element) - (org-set-local 'end-of-defun-function - (lambda () - (if (not (org-at-heading-p)) - (org-forward-element) - (org-forward-element) - (forward-char -1)))) + (setq-local beginning-of-defun-function 'org-backward-element) + (setq-local end-of-defun-function + (lambda () + (if (not (org-at-heading-p)) + (org-forward-element) + (org-forward-element) + (forward-char -1)))) ;; Next error for sparse trees - (org-set-local 'next-error-function 'org-occur-next-match) + (setq-local next-error-function 'org-occur-next-match) ;; Make sure dependence stuff works reliably, even for users who set it ;; too late :-( (if org-enforce-todo-dependencies @@ -5506,72 +5483,60 @@ The following commands are available: 'org-block-todo-from-checkboxes)) ;; Align options lines - (org-set-local - 'align-mode-rules-list + (setq-local + align-mode-rules-list '((org-in-buffer-settings (regexp . "^[ \t]*#\\+[A-Z_]+:\\(\\s-*\\)\\S-+") (modes . '(org-mode))))) ;; Imenu - (org-set-local 'imenu-create-index-function - 'org-imenu-get-tree) + (setq-local imenu-create-index-function 'org-imenu-get-tree) ;; Make isearch reveal context - (if (or (featurep 'xemacs) - (not (boundp 'outline-isearch-open-invisible-function))) - ;; Emacs 21 and XEmacs make use of the hook - (org-add-hook 'isearch-mode-end-hook 'org-isearch-end 'append 'local) - ;; Emacs 22 deals with this through a special variable - (org-set-local 'outline-isearch-open-invisible-function - (lambda (&rest ignore) (org-show-context 'isearch)))) + (setq-local outline-isearch-open-invisible-function + (lambda (&rest _) (org-show-context 'isearch))) ;; Setup the pcomplete hooks - (set (make-local-variable 'pcomplete-command-completion-function) - 'org-pcomplete-initial) - (set (make-local-variable 'pcomplete-command-name-function) - 'org-command-at-point) - (set (make-local-variable 'pcomplete-default-completion-function) - 'ignore) - (set (make-local-variable 'pcomplete-parse-arguments-function) - 'org-parse-arguments) - (set (make-local-variable 'pcomplete-termination-string) "") - (when (>= emacs-major-version 23) - (set (make-local-variable 'buffer-face-mode-face) 'org-default)) - - ;; If empty file that did not turn on org-mode automatically, make it to. - (if (and org-insert-mode-line-in-empty-file - (org-called-interactively-p 'any) - (= (point-min) (point-max))) - (insert "# -*- mode: org -*-\n\n")) + (setq-local pcomplete-command-completion-function 'org-pcomplete-initial) + (setq-local pcomplete-command-name-function 'org-command-at-point) + (setq-local pcomplete-default-completion-function 'ignore) + (setq-local pcomplete-parse-arguments-function 'org-parse-arguments) + (setq-local pcomplete-termination-string "") + (setq-local buffer-face-mode-face 'org-default) + + ;; If empty file that did not turn on Org mode automatically, make + ;; it to. + (when (and org-insert-mode-line-in-empty-file + (called-interactively-p 'any) + (= (point-min) (point-max))) + (insert "# -*- mode: org -*-\n\n")) (unless org-inhibit-startup (org-unmodified - (and org-startup-with-beamer-mode (org-beamer-mode)) + (when 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-toggle-latex-fragment)) - (unless org-inhibit-startup-visibility-stuff - (org-set-startup-visibility)) + (org-table-map-tables #'org-table-align t)) + (when org-startup-with-inline-images (org-display-inline-images)) + (when org-startup-with-latex-preview (org-toggle-latex-fragment '(16))) + (unless org-inhibit-startup-visibility-stuff (org-set-startup-visibility)) + (when org-startup-truncated (setq truncate-lines t)) + (when org-startup-indented (require 'org-indent) (org-indent-mode 1)) (org-refresh-effort-properties))) - ;; Try to set org-hide correctly + ;; Try to set `org-hide' face correctly. (let ((foreground (org-find-invisible-foreground))) - (if foreground - (set-face-foreground 'org-hide foreground)))) + (when foreground + (set-face-foreground 'org-hide 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.2.6" . "24.4") ("8.3" . "25.1"))) + ("8.2.6" . "24.4") ("8.2.10" . "24.5") + ("9.0" . "26.1"))) (defvar org-mode-transpose-word-syntax-table (let ((st (make-syntax-table text-mode-syntax-table))) - (mapc (lambda(c) (modify-syntax-entry - (string-to-char (car c)) "w p" st)) - org-emphasis-alist) - st)) + (dolist (c org-emphasis-alist st) + (modify-syntax-entry (string-to-char (car c)) "w p" st)))) (when (fboundp 'abbrev-table-put) (abbrev-table-put org-mode-abbrev-table @@ -5586,7 +5551,7 @@ The following commands are available: (mapcar (lambda (alist) (when (boundp alist) - (cdr (assoc 'background-color (symbol-value alist))))) + (cdr (assq 'background-color (symbol-value alist))))) '(default-frame-alist initial-frame-alist window-system-default-frame-alist)) (list (face-foreground 'org-hide)))))) (car (remove nil candidates)))) @@ -5605,8 +5570,8 @@ the rounding returns a past time." (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))) + (if (and past (< (float-time (time-subtract (current-time) res)) 0)) + (seconds-to-time (- (float-time res) (* r 60))) res)))) (defun org-today () @@ -5629,9 +5594,6 @@ the rounding returns a past time." (require 'font-lock) (defconst org-non-link-chars "]\t\n\r<>") -(defvar org-link-types '("http" "https" "ftp" "mailto" "file" "file+emacs" - "file+sys" "news" "shell" "elisp" "doi" "message" - "help")) (defvar org-link-types-re nil "Matches a link that has a url-like prefix like \"http:\"") (defvar org-link-re-with-space nil @@ -5698,8 +5660,8 @@ stacked delimiters is N. Escaping delimiters is not possible." (defun org-make-link-regexps () "Update the link regular expressions. -This should be called after the variable `org-link-types' has changed." - (let ((types-re (regexp-opt org-link-types t))) +This should be called after the variable `org-link-parameters' has changed." + (let ((types-re (regexp-opt (org-link-types) t))) (setq org-link-types-re (concat "\\`" types-re ":") org-link-re-with-space @@ -5722,7 +5684,7 @@ This should be called after the variable `org-link-types' has changed." org-plain-link-re (concat "\\<" types-re ":" - (org-re "\\([^ \t\n()<>]+\\(?:([[:word:]0-9_]+)\\|\\([^[:punct:] \t\n]\\|/\\)\\)\\)")) + "\\([^ \t\n()<>]+\\(?:([[:word:]0-9_]+)\\|\\([^[:punct:] \t\n]\\|/\\)\\)\\)") ;; "\\([^]\t\n\r<>() ]+[^]\t\n\r<>,.;() ]\\)") org-bracket-link-regexp "\\[\\[\\([^][]+\\)\\]\\(\\[\\([^][]+\\)\\]\\)?\\]" @@ -5737,7 +5699,7 @@ This should be called after the variable `org-link-types' has changed." org-bracket-link-analytic-regexp++ (concat "\\[\\[" - "\\(" (regexp-opt (cons "coderef" org-link-types) t) ":\\)?" + "\\(" (regexp-opt (cons "coderef" (org-link-types)) t) ":\\)?" "\\([^]]+\\)" "\\]" "\\(\\[" "\\([^]]+\\)" "\\]\\)?" @@ -5753,34 +5715,36 @@ This should be called after the variable `org-link-types' has changed." (defun org-do-emphasis-faces (limit) "Run through the buffer and emphasize strings." - (let (rtn a) - (while (and (not rtn) (re-search-forward org-emph-re limit t)) - (let* ((border (char-after (match-beginning 3))) - (bre (regexp-quote (char-to-string border)))) - (if (and (not (= border (char-after (match-beginning 4)))) - (not (save-match-data - (string-match (concat bre ".*" bre) - (replace-regexp-in-string - "\n" " " - (substring (match-string 2) 1 -1)))))) - (progn - (setq rtn t) - (setq a (assoc (match-string 3) org-emphasis-alist)) - (font-lock-prepend-text-property (match-beginning 2) (match-end 2) - 'face - (nth 1 a)) - (and (nth 2 a) - (org-remove-flyspell-overlays-in - (match-beginning 0) (match-end 0))) + (let ((quick-re (format "\\([%s]\\|^\\)\\([~=*/_+]\\)" + (car org-emphasis-regexp-components)))) + (catch :exit + (while (re-search-forward quick-re limit t) + (let* ((marker (match-string 2)) + (verbatim? (member marker '("~" "=")))) + (when (save-excursion + (goto-char (match-beginning 0)) + ;; Do not match headline stars. Do not consider + ;; stars of a headline as closing marker for bold + ;; markup either. + (and (not (looking-at-p org-outline-regexp-bol)) + (looking-at (if verbatim? org-verbatim-re org-emph-re)) + (not (string-match-p + (concat org-outline-regexp-bol "\\'") + (match-string 0))))) + (pcase-let ((`(,_ ,face ,_) (assoc marker org-emphasis-alist))) + (font-lock-prepend-text-property + (match-beginning 2) (match-end 2) 'face face) + (when verbatim? + (org-remove-flyspell-overlays-in + (match-beginning 0) (match-end 0))) (add-text-properties (match-beginning 2) (match-end 2) '(font-lock-multiline t org-emphasis t)) (when org-hide-emphasis-markers (add-text-properties (match-end 4) (match-beginning 5) '(invisible org-link)) (add-text-properties (match-beginning 3) (match-end 3) - '(invisible org-link)))))) - (goto-char (1+ (match-beginning 0)))) - rtn)) + '(invisible org-link))) + (throw :exit t)))))))) (defun org-emphasize (&optional char) "Insert or change an emphasis, i.e. a font like bold or italic. @@ -5793,19 +5757,20 @@ If CHAR is not given (for example in an interactive call) it will be prompted for." (interactive) (let ((erc org-emphasis-regexp-components) - (prompt "") - (string "") beg end move c s) + (string "") beg end move s) (if (org-region-active-p) - (setq beg (region-beginning) end (region-end) + (setq beg (region-beginning) + end (region-end) string (buffer-substring beg end)) (setq move t)) (unless char (message "Emphasis marker or tag: [%s]" - (mapconcat (lambda(e) (car e)) org-emphasis-alist "")) + (mapconcat #'car org-emphasis-alist "")) (setq char (read-char-exclusive))) - (if (equal char ?\ ) - (setq s "" move nil) + (if (equal char ?\s) + (setq s "" + move nil) (unless (assoc (char-to-string char) org-emphasis-alist) (user-error "No such emphasis marker: \"%c\"" char)) (setq s (char-to-string char))) @@ -5814,7 +5779,7 @@ prompted for." (assoc (substring string 0 1) org-emphasis-alist)) (setq string (substring string 1 -1))) (setq string (concat s string s)) - (if beg (delete-region beg end)) + (when beg (delete-region beg end)) (unless (or (bolp) (string-match (concat "[" (nth 0 erc) "\n]") (char-to-string (char-before (point))))) @@ -5834,35 +5799,71 @@ prompted for." (defun org-activate-plain-links (limit) "Add link properties for plain links." - (let (f hl) - (when (and (re-search-forward (concat org-plain-link-re) limit t) - (not (member 'org-tag - (get-text-property (1- (match-beginning 0)) 'face))) - (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)) - (setq hl (org-match-string-no-properties 0)) - (if (or (eq f 'org-tag) - (and (listp f) (memq 'org-tag f))) - nil + (when (and (re-search-forward org-plain-link-re limit t) + (not (org-in-src-block-p))) + + (let* ((face (get-text-property (max (1- (match-beginning 0)) (point-min)) + 'face)) + (link (match-string-no-properties 0)) + (type (match-string-no-properties 1)) + (path (match-string-no-properties 2)) + (link-start (match-beginning 0)) + (link-end (match-end 0)) + (link-face (org-link-get-parameter type :face)) + (help-echo (org-link-get-parameter type :help-echo)) + (htmlize-link (org-link-get-parameter type :htmlize-link)) + (activate-func (org-link-get-parameter type :activate-func))) + (unless (if (consp face) (memq 'org-tag face) (eq 'org-tag face)) + (org-remove-flyspell-overlays-in (match-beginning 0) (match-end 0)) (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))) + (list + 'mouse-face (or (org-link-get-parameter type :mouse-face) + 'highlight) + 'face (cond + ;; A function that returns a face + ((functionp link-face) + (funcall link-face path)) + ;; a face + ((facep link-face) + link-face) + ;; An anonymous face + ((consp link-face) + link-face) + ;; default + (t + 'org-link)) + 'help-echo (cond + ((stringp help-echo) + help-echo) + ((functionp help-echo) + help-echo) + (t + (concat "LINK: " + (save-match-data + (org-link-unescape link))))) + 'htmlize-link (cond + ((functionp htmlize-link) + (funcall htmlize-link path)) + (t + `(:uri ,link))) + 'keymap (or (org-link-get-parameter type :keymap) + org-mouse-map) + 'org-link-start (match-beginning 0))) + (org-rear-nonsticky-at (match-end 0)) + (when activate-func + (funcall activate-func link-start link-end path nil)) + t)))) (defun org-activate-code (limit) - (if (re-search-forward "^[ \t]*\\(:\\(?: .*\\|$\\)\n?\\)" limit t) - (progn - (org-remove-flyspell-overlays-in (match-beginning 0) (match-end 0)) - (remove-text-properties (match-beginning 0) (match-end 0) - '(display t invisible t intangible t)) - t))) + (when (re-search-forward "^[ \t]*\\(:\\(?: .*\\|$\\)\n?\\)" limit t) + (org-remove-flyspell-overlays-in (match-beginning 0) (match-end 0)) + (remove-text-properties (match-beginning 0) (match-end 0) + '(display t invisible t intangible t)) + t)) (defcustom org-src-fontify-natively t - "When non-nil, fontify code in code blocks." + "When non-nil, fontify code in code blocks. +See also the `org-block' face." :type 'boolean :version "24.4" :package-version '(Org . "8.3") @@ -5880,95 +5881,108 @@ by a #." (defun org-fontify-meta-lines-and-blocks (limit) (condition-case nil (org-fontify-meta-lines-and-blocks-1 limit) - (error (message "org-mode fontification error")))) + (error (message "org-mode fontification error in %S at %d" + (current-buffer) + (line-number-at-pos))))) (defun org-fontify-meta-lines-and-blocks-1 (limit) "Fontify #+ lines and blocks." (let ((case-fold-search t)) - (if (re-search-forward - "^\\([ \t]*#\\(\\(\\+[a-zA-Z]+:?\\| \\|$\\)\\(_\\([a-zA-Z]+\\)\\)?\\)[ \t]*\\(\\([^ \t\n]*\\)[ \t]*\\(.*\\)\\)\\)" - limit t) - (let ((beg (match-beginning 0)) - (block-start (match-end 0)) - (block-end nil) - (lang (match-string 7)) - (beg1 (line-beginning-position 2)) - (dc1 (downcase (match-string 2))) - (dc3 (downcase (match-string 3))) - end end1 quoting block-type ovl) - (cond - ((and (match-end 4) (equal dc3 "+begin")) - ;; Truly a block - (setq block-type (downcase (match-string 5)) - quoting (member block-type org-protecting-blocks)) - (when (re-search-forward - (concat "^[ \t]*#\\+end" (match-string 4) "\\>.*") - nil t) ;; on purpose, we look further than LIMIT - (setq end (min (point-max) (match-end 0)) - end1 (min (point-max) (1- (match-beginning 0)))) - (setq block-end (match-beginning 0)) - (when quoting - (org-remove-flyspell-overlays-in beg1 end1) - (remove-text-properties beg end - '(display t invisible t intangible t))) - (add-text-properties - beg end '(font-lock-fontified t font-lock-multiline t)) - (add-text-properties beg beg1 '(face org-meta-line)) - (org-remove-flyspell-overlays-in beg beg1) - (add-text-properties ; For end_src - end1 (min (point-max) (1+ end)) '(face org-meta-line)) - (org-remove-flyspell-overlays-in end1 end) - (cond - ((and lang (not (string= lang "")) org-src-fontify-natively) - (org-src-font-lock-fontify-block lang block-start block-end) - (add-text-properties beg1 block-end '(src-block t))) - (quoting - (add-text-properties beg1 (min (point-max) (1+ end1)) - '(face org-block))) ; end of source block - ((not org-fontify-quote-and-verse-blocks)) - ((string= block-type "quote") - (add-text-properties beg1 (min (point-max) (1+ end1)) '(face org-quote))) - ((string= block-type "verse") - (add-text-properties beg1 (min (point-max) (1+ end1)) '(face org-verse)))) - (add-text-properties beg beg1 '(face org-block-begin-line)) - (add-text-properties (min (point-max) (1+ end)) (min (point-max) (1+ end1)) - '(face org-block-end-line)) - t)) - ((member dc1 '("+title:" "+author:" "+email:" "+date:")) - (org-remove-flyspell-overlays-in - (match-beginning 0) - (if (equal "+title:" dc1) (match-end 2) (match-end 0))) - (add-text-properties - beg (match-end 3) - (if (member (intern (substring dc1 1 -1)) org-hidden-keywords) - '(font-lock-fontified t invisible t) - '(font-lock-fontified t face org-document-info-keyword))) - (add-text-properties - (match-beginning 6) (min (point-max) (1+ (match-end 6))) - (if (string-equal dc1 "+title:") - '(font-lock-fontified t face org-document-title) - '(font-lock-fontified t face org-document-info)))) - ((equal dc1 "+caption:") - (org-remove-flyspell-overlays-in (match-end 2) (match-end 0)) - (remove-text-properties (match-beginning 0) (match-end 0) - '(display t invisible t intangible t)) - (add-text-properties (match-beginning 1) (match-end 3) - '(font-lock-fontified t face org-meta-line)) - (add-text-properties (match-beginning 6) (+ (match-end 6) 1) - '(font-lock-fontified t face org-block)) - t) - ((member dc3 '(" " "")) - (org-remove-flyspell-overlays-in beg (match-end 0)) + (when (re-search-forward + "^\\([ \t]*#\\(\\(\\+[a-zA-Z]+:?\\| \\|$\\)\\(_\\([a-zA-Z]+\\)\\)?\\)[ \t]*\\(\\([^ \t\n]*\\)[ \t]*\\(.*\\)\\)\\)" + limit t) + (let ((beg (match-beginning 0)) + (block-start (match-end 0)) + (block-end nil) + (lang (match-string 7)) + (beg1 (line-beginning-position 2)) + (dc1 (downcase (match-string 2))) + (dc3 (downcase (match-string 3))) + end end1 quoting block-type) + (cond + ((and (match-end 4) (equal dc3 "+begin")) + ;; Truly a block + (setq block-type (downcase (match-string 5)) + quoting (member block-type org-protecting-blocks)) + (when (re-search-forward + (concat "^[ \t]*#\\+end" (match-string 4) "\\>.*") + nil t) ;; on purpose, we look further than LIMIT + (setq end (min (point-max) (match-end 0)) + end1 (min (point-max) (1- (match-beginning 0)))) + (setq block-end (match-beginning 0)) + (when quoting + (org-remove-flyspell-overlays-in beg1 end1) + (remove-text-properties beg end + '(display t invisible t intangible t))) (add-text-properties - beg (match-end 0) - '(font-lock-fontified t face font-lock-comment-face))) - (t ;; just any other in-buffer setting, but not indented - (org-remove-flyspell-overlays-in (match-beginning 0) (match-end 0)) - (remove-text-properties (match-beginning 0) (match-end 0) - '(display t invisible t intangible t)) - (add-text-properties beg (match-end 0) - '(font-lock-fontified t face org-meta-line)) - t)))))) + beg end '(font-lock-fontified t font-lock-multiline t)) + (add-text-properties beg beg1 '(face org-meta-line)) + (org-remove-flyspell-overlays-in beg beg1) + (add-text-properties ; For end_src + end1 (min (point-max) (1+ end)) '(face org-meta-line)) + (org-remove-flyspell-overlays-in end1 end) + (cond + ((and lang (not (string= lang "")) org-src-fontify-natively) + (org-src-font-lock-fontify-block lang block-start block-end) + (add-text-properties beg1 block-end '(src-block t))) + (quoting + (add-text-properties beg1 (min (point-max) (1+ end1)) + (list 'face + (list :inherit + (let ((face-name + (intern (format "org-block-%s" lang)))) + (append (and (facep face-name) (list face-name)) + '(org-block))))))) ; end of source block + ((not org-fontify-quote-and-verse-blocks)) + ((string= block-type "quote") + (add-face-text-property + beg1 (min (point-max) (1+ end1)) 'org-quote t)) + ((string= block-type "verse") + (add-face-text-property + beg1 (min (point-max) (1+ end1)) 'org-verse t))) + (add-text-properties beg beg1 '(face org-block-begin-line)) + (add-text-properties (min (point-max) (1+ end)) (min (point-max) (1+ end1)) + '(face org-block-end-line)) + t)) + ((member dc1 '("+title:" "+author:" "+email:" "+date:")) + (org-remove-flyspell-overlays-in + (match-beginning 0) + (if (equal "+title:" dc1) (match-end 2) (match-end 0))) + (add-text-properties + beg (match-end 3) + (if (member (intern (substring dc1 1 -1)) org-hidden-keywords) + '(font-lock-fontified t invisible t) + '(font-lock-fontified t face org-document-info-keyword))) + (add-text-properties + (match-beginning 6) (min (point-max) (1+ (match-end 6))) + (if (string-equal dc1 "+title:") + '(font-lock-fontified t face org-document-title) + '(font-lock-fontified t face org-document-info)))) + ((string-prefix-p "+caption" dc1) + (org-remove-flyspell-overlays-in (match-end 2) (match-end 0)) + (remove-text-properties (match-beginning 0) (match-end 0) + '(display t invisible t intangible t)) + ;; Handle short captions. + (save-excursion + (beginning-of-line) + (looking-at "\\([ \t]*#\\+caption\\(?:\\[.*\\]\\)?:\\)[ \t]*")) + (add-text-properties (line-beginning-position) (match-end 1) + '(font-lock-fontified t face org-meta-line)) + (add-text-properties (match-end 0) (line-end-position) + '(font-lock-fontified t face org-block)) + t) + ((member dc3 '(" " "")) + (org-remove-flyspell-overlays-in beg (match-end 0)) + (add-text-properties + beg (match-end 0) + '(font-lock-fontified t face font-lock-comment-face))) + (t ;; just any other in-buffer setting, but not indented + (org-remove-flyspell-overlays-in (match-beginning 0) (match-end 0)) + (remove-text-properties (match-beginning 0) (match-end 0) + '(display t invisible t intangible t)) + (add-text-properties beg (match-end 0) + '(font-lock-fontified t face org-meta-line)) + t)))))) (defun org-fontify-drawers (limit) "Fontify drawers." @@ -5995,16 +6009,15 @@ by a #." (defun org-activate-angle-links (limit) "Add text properties for angle links." - (if (and (re-search-forward org-angle-link-re limit t) - (not (org-in-src-block-p))) - (progn - (org-remove-flyspell-overlays-in (match-beginning 0) (match-end 0)) - (add-text-properties (match-beginning 0) (match-end 0) - (list 'mouse-face 'highlight - 'keymap org-mouse-map - 'font-lock-multiline t)) - (org-rear-nonsticky-at (match-end 0)) - t))) + (when (and (re-search-forward org-angle-link-re limit t) + (not (org-in-src-block-p))) + (org-remove-flyspell-overlays-in (match-beginning 0) (match-end 0)) + (add-text-properties (match-beginning 0) (match-end 0) + (list 'mouse-face 'highlight + 'keymap org-mouse-map + 'font-lock-multiline t)) + (org-rear-nonsticky-at (match-end 0)) + t)) (defun org-activate-footnote-links (limit) "Add text properties for footnotes." @@ -6031,58 +6044,111 @@ by a #." (defun org-activate-bracket-links (limit) "Add text properties for bracketed links." - (if (and (re-search-forward org-bracket-link-regexp limit t) - (not (org-in-src-block-p))) - (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 - 'htmlize-link `(:uri ,hl)))) - (vp (list 'keymap org-mouse-map 'mouse-face 'highlight - '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)) - (remove-text-properties (match-beginning 0) (match-end 0) - '(invisible nil)) - (if (match-end 3) - (progn - (add-text-properties (match-beginning 0) (match-beginning 3) ip) - (org-rear-nonsticky-at (match-beginning 3)) - (add-text-properties (match-beginning 3) (match-end 3) vp) - (org-rear-nonsticky-at (match-end 3)) - (add-text-properties (match-end 3) (match-end 0) ip) - (org-rear-nonsticky-at (match-end 0))) - (add-text-properties (match-beginning 0) (match-beginning 1) ip) - (org-rear-nonsticky-at (match-beginning 1)) - (add-text-properties (match-beginning 1) (match-end 1) vp) - (org-rear-nonsticky-at (match-end 1)) - (add-text-properties (match-end 1) (match-end 0) ip) - (org-rear-nonsticky-at (match-end 0))) - t))) + (when (and (re-search-forward org-bracket-link-regexp limit t) + (not (org-in-src-block-p))) + (let* ((hl (save-match-data + (org-link-expand-abbrev (match-string-no-properties 1)))) + (type (save-match-data + (and (string-match org-plain-link-re hl) + (match-string-no-properties 1 hl)))) + (path (save-match-data + (and (string-match org-plain-link-re hl) + (match-string-no-properties 2 hl)))) + (link-start (match-beginning 0)) + (link-end (match-end 0)) + (bracketp t) + (help-echo (org-link-get-parameter type :help-echo)) + (help (cond + ((stringp help-echo) + help-echo) + ((functionp help-echo) + help-echo) + (t + (concat "LINK: " + (save-match-data + (org-link-unescape hl)))))) + (link-face (org-link-get-parameter type :face)) + (face (cond + ;; A function that returns a face + ((functionp link-face) + (funcall link-face path)) + ;; a face + ((facep link-face) + link-face) + ;; An anonymous face + ((consp link-face) + link-face) + ;; default + (t + 'org-link))) + (keymap (or (org-link-get-parameter type :keymap) + org-mouse-map)) + (mouse-face (or (org-link-get-parameter type :mouse-face) + 'highlight)) + (htmlize (org-link-get-parameter type :htmlize-link)) + (htmlize-link (cond + ((functionp htmlize) + (funcall htmlize)) + (t + `(:uri ,(format "%s:%s" type path))))) + (activate-func (org-link-get-parameter type :activate-func)) + ;; invisible part + (ip (list 'invisible (or + (org-link-get-parameter type :display) + 'org-link) + 'face face + 'keymap keymap + 'mouse-face mouse-face + 'font-lock-multiline t + 'help-echo help + 'htmlize-link htmlize-link)) + ;; visible part + (vp (list 'keymap keymap + 'face face + 'mouse-face mouse-face + 'font-lock-multiline t + 'help-echo help + 'htmlize-link htmlize-link))) + ;; 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)) + (remove-text-properties (match-beginning 0) (match-end 0) + '(invisible nil)) + (if (match-end 3) + (progn + (add-text-properties (match-beginning 0) (match-beginning 3) ip) + (org-rear-nonsticky-at (match-beginning 3)) + (add-text-properties (match-beginning 3) (match-end 3) vp) + (org-rear-nonsticky-at (match-end 3)) + (add-text-properties (match-end 3) (match-end 0) ip) + (org-rear-nonsticky-at (match-end 0))) + (add-text-properties (match-beginning 0) (match-beginning 1) ip) + (org-rear-nonsticky-at (match-beginning 1)) + (add-text-properties (match-beginning 1) (match-end 1) vp) + (org-rear-nonsticky-at (match-end 1)) + (add-text-properties (match-end 1) (match-end 0) ip) + (org-rear-nonsticky-at (match-end 0))) + (when activate-func + (funcall activate-func link-start link-end path bracketp)) + t))) (defun org-activate-dates (limit) "Add text properties for dates." - (if (and (re-search-forward org-tsr-regexp-both limit t) - (not (equal (char-before (match-beginning 0)) 91))) - (progn - (org-remove-flyspell-overlays-in (match-beginning 0) (match-end 0)) - (add-text-properties (match-beginning 0) (match-end 0) - (list 'mouse-face 'highlight - 'keymap org-mouse-map)) - (org-rear-nonsticky-at (match-end 0)) - (when org-display-custom-times - (if (match-end 3) - (org-display-custom-time (match-beginning 3) (match-end 3))) - (org-display-custom-time (match-beginning 1) (match-end 1))) - t))) + (when (and (re-search-forward org-tsr-regexp-both limit t) + (not (equal (char-before (match-beginning 0)) 91))) + (org-remove-flyspell-overlays-in (match-beginning 0) (match-end 0)) + (add-text-properties (match-beginning 0) (match-end 0) + (list 'mouse-face 'highlight + 'keymap org-mouse-map)) + (org-rear-nonsticky-at (match-end 0)) + (when org-display-custom-times + (if (match-end 3) + (org-display-custom-time (match-beginning 3) (match-end 3)) + (org-display-custom-time (match-beginning 1) (match-end 1)))) + t)) -(defvar org-target-link-regexp nil +(defvar-local org-target-link-regexp nil "Regular expression matching radio targets in plain text.") -(make-variable-buffer-local 'org-target-link-regexp) (defconst org-target-regexp (let ((border "[^<>\n\r \t]")) (format "<<\\(%s\\|%s[^<>\n\r]*%s\\)>>" @@ -6100,16 +6166,15 @@ by a #." "Add text properties for target matches." (when org-target-link-regexp (let ((case-fold-search t)) - (if (re-search-forward org-target-link-regexp limit t) - (progn - (org-remove-flyspell-overlays-in (match-beginning 1) (match-end 1)) - (add-text-properties (match-beginning 1) (match-end 1) - (list 'mouse-face 'highlight - 'keymap org-mouse-map - 'help-echo "Radio target link" - 'org-linked-text t)) - (org-rear-nonsticky-at (match-end 1)) - t))))) + (when (re-search-forward org-target-link-regexp limit t) + (org-remove-flyspell-overlays-in (match-beginning 1) (match-end 1)) + (add-text-properties (match-beginning 1) (match-end 1) + (list 'mouse-face 'highlight + 'keymap org-mouse-map + 'help-echo "Radio target link" + 'org-linked-text t)) + (org-rear-nonsticky-at (match-end 1)) + t)))) (defun org-update-radio-target-regexp () "Find all radio targets in this file and update the regular expression. @@ -6127,7 +6192,8 @@ Also refresh fontification if needed." (backward-char) (let ((obj (org-element-context))) (when (eq (org-element-type obj) 'radio-target) - (add-to-list 'rtn (org-element-property :value obj))))) + (cl-pushnew (org-element-property :value obj) rtn + :test #'equal)))) rtn)))) (setq org-target-link-regexp (and targets @@ -6166,7 +6232,7 @@ Also refresh fontification if needed." 'org-cwidth t)) (when s (setq e (next-single-property-change s 'org-cwidth)) - (add-text-properties s e (org-maybe-intangible '(invisible org-cwidth))) + (add-text-properties s e '(invisible org-cwidth)) (goto-char e) t))) @@ -6176,8 +6242,8 @@ Also refresh fontification if needed." (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 + (setq-local + org-latex-and-related-regexp (let* ((re-sub (cond ((not (memq 'script org-highlight-latex-and-related)) nil) ((eq org-use-sub-superscripts '{}) @@ -6203,9 +6269,13 @@ 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)) + (unless + (cl-some + (lambda (f) + (memq f '(org-code org-verbatim underline org-special-keyword))) + (save-excursion + (goto-char (1+ (match-beginning 0))) + (face-at-point nil t))) (let ((offset (if (memq (char-after (1+ (match-beginning 0))) '(?_ ?^)) 1 @@ -6225,14 +6295,14 @@ done, nil otherwise." (font-lock-mode 1))) (defun org-activate-tags (limit) - (if (re-search-forward (org-re "^\\*+.*[ \t]\\(:[[:alnum:]_@#%:]+:\\)[ \r\n]") limit t) - (progn - (org-remove-flyspell-overlays-in (match-beginning 1) (match-end 1)) - (add-text-properties (match-beginning 1) (match-end 1) - (list 'mouse-face 'highlight - 'keymap org-mouse-map)) - (org-rear-nonsticky-at (match-end 1)) - t))) + (when (re-search-forward + "^\\*+.*[ \t]\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$" limit t) + (org-remove-flyspell-overlays-in (match-beginning 1) (match-end 1)) + (add-text-properties (match-beginning 1) (match-end 1) + (list 'mouse-face 'highlight + 'keymap org-mouse-map)) + (org-rear-nonsticky-at (match-end 1)) + t)) (defun org-outline-level () "Compute the outline level of the heading at point. @@ -6287,6 +6357,8 @@ There are four matching groups: (defvar org-font-lock-hook nil "Functions to be called for special font lock stuff.") +(defvar org-font-lock-extra-keywords nil) ;Dynamically scoped. + (defvar org-font-lock-set-keywords-hook nil "Functions that can manipulate `org-font-lock-extra-keywords'. This is called after `org-font-lock-extra-keywords' is defined, but before @@ -6327,13 +6399,13 @@ needs to be inserted at a specific position in the font-lock sequence.") '(1 'org-special-keyword t) '(3 'org-property-value t)) ;; 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 (0 'org-link t))) - (if (memq 'bracket lk) '(org-activate-bracket-links (0 'org-link t))) - (if (memq 'radio lk) '(org-activate-target-links (1 'org-link t))) - (if (memq 'date lk) '(org-activate-dates (0 'org-date t))) - (if (memq 'footnote lk) '(org-activate-footnote-links)) + (when (memq 'tag lk) '(org-activate-tags (1 'org-tag prepend))) + (when (memq 'angle lk) '(org-activate-angle-links (0 'org-link t))) + (when (memq 'plain lk) '(org-activate-plain-links (0 'org-link))) + (when (memq 'bracket lk) '(org-activate-bracket-links (0 'org-link))) + (when (memq 'radio lk) '(org-activate-target-links (1 'org-link t))) + (when (memq 'date lk) '(org-activate-dates (0 'org-date t))) + (when (memq 'footnote lk) '(org-activate-footnote-links)) ;; Targets. (list org-any-target-regexp '(0 'org-target t)) ;; Diary sexps. @@ -6359,27 +6431,24 @@ needs to be inserted at a specific position in the font-lock sequence.") ;; 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))) + (when (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)) (list (concat "\\<" org-closed-string) '(0 'org-special-keyword t)) (list (concat "\\<" org-clock-string) '(0 'org-special-keyword t)) ;; Emphasis - (if em - (if (featurep 'xemacs) - '(org-do-emphasis-faces (0 nil append)) - '(org-do-emphasis-faces))) + (when em '(org-do-emphasis-faces)) ;; Checkboxes '("^[ \t]*\\(?:[-+*]\\|[0-9]+[.)]\\)[ \t]+\\(?:\\[@\\(?:start:\\)?[0-9]+\\][ \t]*\\)?\\(\\[[- X]\\]\\)" 1 'org-checkbox prepend) - (if (cdr (assq 'checkbox org-list-automatic-rules)) - '("\\[\\([0-9]*%\\)\\]\\|\\[\\([0-9]*\\)/\\([0-9]*\\)\\]" - (0 (org-get-checkbox-statistics-face) t))) + (when (cdr (assq 'checkbox org-list-automatic-rules)) + '("\\[\\([0-9]*%\\)\\]\\|\\[\\([0-9]*\\)/\\([0-9]*\\)\\]" + (0 (org-get-checkbox-statistics-face) t))) ;; Description list items '("^[ \t]*[-+*][ \t]+\\(.*?[ \t]+::\\)\\([ \t]+\\|$\\)" 1 'org-list-dt prepend) @@ -6405,26 +6474,26 @@ needs to be inserted at a specific position in the font-lock sequence.") (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 - (org-set-local 'org-font-lock-keywords org-font-lock-extra-keywords) - (org-set-local 'font-lock-defaults - '(org-font-lock-keywords t nil nil backward-paragraph)) - (kill-local-variable 'font-lock-keywords) nil)) + (setq-local org-font-lock-keywords org-font-lock-extra-keywords) + (setq-local font-lock-defaults + '(org-font-lock-keywords t nil nil backward-paragraph)) + (kill-local-variable 'font-lock-keywords) + nil)) (defun org-toggle-pretty-entities () "Toggle the composition display of entities as UTF8 characters." (interactive) - (org-set-local 'org-pretty-entities (not org-pretty-entities)) + (setq-local org-pretty-entities (not org-pretty-entities)) (org-restart-font-lock) (if org-pretty-entities (message "Entities are now displayed as UTF8 characters") (save-restriction (widen) - (org-decompose-region (point-min) (point-max)) + (decompose-region (point-min) (point-max)) (message "Entities are now displayed as plain text")))) -(defvar org-custom-properties-overlays nil +(defvar-local org-custom-properties-overlays nil "List of overlays used for custom properties.") -(make-variable-buffer-local 'org-custom-properties-overlays) (defun org-toggle-custom-properties-visibility () "Display or hide properties in `org-custom-properties'." @@ -6464,29 +6533,28 @@ needs to be inserted at a specific position in the font-lock sequence.") (while (re-search-forward "\\\\\\(there4\\|sup[123]\\|frac[13][24]\\|[a-zA-Z]+\\)\\($\\|{}\\|[^[:alpha:]\n]\\)" limit t) - (if (and (not (org-at-comment-p)) - (setq ee (org-entity-get (match-string 1))) - (= (length (nth 6 ee)) 1)) - (let* - ((end (if (equal (match-string 2) "{}") + (when (and (not (org-at-comment-p)) + (setq ee (org-entity-get (match-string 1))) + (= (length (nth 6 ee)) 1)) + (let* ((end (if (equal (match-string 2) "{}") (match-end 2) (match-end 1)))) - (add-text-properties - (match-beginning 0) end - (list 'font-lock-fontified t)) - (compose-region (match-beginning 0) end - (nth 6 ee) nil) - (backward-char 1) - (throw 'match t)))) + (add-text-properties + (match-beginning 0) end + (list 'font-lock-fontified t)) + (compose-region (match-beginning 0) end + (nth 6 ee) nil) + (backward-char 1) + (throw 'match t)))) nil)))) (defun org-fontify-like-in-org-mode (s &optional odd-levels) - "Fontify string S like in Org-mode." + "Fontify string S like in Org mode." (with-temp-buffer (insert s) (let ((org-odd-levels-only odd-levels)) (org-mode) - (font-lock-ensure) + (org-font-lock-ensure) (buffer-string)))) (defvar org-m nil) @@ -6495,14 +6563,14 @@ needs to be inserted at a specific position in the font-lock sequence.") (defun org-get-level-face (n) "Get the right face for match N in font-lock matching of headlines." (setq org-l (- (match-end 2) (match-beginning 1) 1)) - (if org-odd-levels-only (setq org-l (1+ (/ org-l 2)))) + (when org-odd-levels-only (setq org-l (1+ (/ org-l 2)))) (if org-cycle-level-faces (setq org-f (nth (% (1- org-l) org-n-level-faces) org-level-faces)) (setq org-f (nth (1- (min org-l org-n-level-faces)) org-level-faces))) (cond ((eq n 1) (if org-hide-leading-stars 'org-hide org-f)) ((eq n 2) org-f) - (t (if org-level-color-stars-only nil org-f)))) + (t (unless org-level-color-stars-only org-f)))) (defun org-face-from-face-or-color (context inherit face-or-color) "Create a face list that inherits INHERIT, but sets the foreground color. @@ -6516,7 +6584,7 @@ When FACE-OR-COLOR is not a string, just return it." (defun org-get-todo-face (kwd) "Get the right face for a TODO keyword KWD. If KWD is a number, get the corresponding match group." - (if (numberp kwd) (setq kwd (match-string kwd))) + (when (numberp kwd) (setq kwd (match-string kwd))) (or (org-face-from-face-or-color 'todo 'org-todo (cdr (assoc kwd org-todo-keyword-faces))) (and (member kwd org-done-keywords) 'org-done) @@ -6554,14 +6622,14 @@ If TAG is a number, get the corresponding match group." 'font-lock-fontified t)) (backward-char 1)))) -(defun org-unfontify-region (beg end &optional maybe_loudly) +(defun org-unfontify-region (beg end &optional _maybe_loudly) "Remove fontification and activation overlays from links." (font-lock-default-unfontify-region beg end) (let* ((buffer-undo-list t) (inhibit-read-only t) (inhibit-point-motion-hooks t) (inhibit-modification-hooks t) deactivate-mark buffer-file-name buffer-file-truename) - (org-decompose-region beg end) + (decompose-region beg end) (remove-text-properties beg end '(mouse-face t keymap t org-linked-text t invisible t intangible t @@ -6582,59 +6650,56 @@ and subscripts." (while (< beg end) (setq next (next-single-property-change beg 'display nil end) prop (get-text-property beg 'display)) - (if (member prop org-script-display) - (put-text-property beg next 'display nil)) + (when (member prop org-script-display) + (put-text-property beg next 'display nil)) (setq beg next)))) (defun org-raise-scripts (limit) "Add raise properties to sub/superscripts." - (when (and org-pretty-entities org-pretty-entities-include-sub-superscripts) - (if (re-search-forward - (if (eq org-use-sub-superscripts t) - org-match-substring-regexp - org-match-substring-with-braces-regexp) - limit t) - (let* ((pos (point)) table-p comment-p - (mpos (match-beginning 3)) - (emph-p (get-text-property mpos 'org-emphasis)) - (link-p (get-text-property mpos 'mouse-face)) - (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]*#[ +]")) - (goto-char 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) - 'display - (if (equal (char-after (match-beginning 2)) ?^) - (nth (if table-p 3 1) org-script-display) - (nth (if table-p 2 0) org-script-display))) - (add-text-properties (match-beginning 2) (match-end 2) - (list 'invisible t - 'org-dwidth t 'org-dwidth-n 1)) - (if (and (eq (char-after (match-beginning 3)) ?{) - (eq (char-before (match-end 3)) ?})) - (progn - (add-text-properties - (match-beginning 3) (1+ (match-beginning 3)) - (list 'invisible t 'org-dwidth t 'org-dwidth-n 1)) - (add-text-properties - (1- (match-end 3)) (match-end 3) - (list 'invisible t 'org-dwidth t 'org-dwidth-n 1)))) - t))))) + (when (and org-pretty-entities org-pretty-entities-include-sub-superscripts + (re-search-forward + (if (eq org-use-sub-superscripts t) + org-match-substring-regexp + org-match-substring-with-braces-regexp) + limit t)) + (let* ((pos (point)) table-p comment-p + (mpos (match-beginning 3)) + (emph-p (get-text-property mpos 'org-emphasis)) + (link-p (get-text-property mpos 'mouse-face)) + (keyw-p (eq 'org-special-keyword (get-text-property mpos 'face)))) + (goto-char (point-at-bol)) + (setq table-p (looking-at-p org-table-dataline-regexp) + comment-p (looking-at-p "^[ \t]*#[ +]")) + (goto-char pos) + ;; Handle a_b^c + (when (member (char-after) '(?_ ?^)) (goto-char (1- pos))) + (unless (or comment-p emph-p link-p keyw-p) + (put-text-property (match-beginning 3) (match-end 0) + 'display + (if (equal (char-after (match-beginning 2)) ?^) + (nth (if table-p 3 1) org-script-display) + (nth (if table-p 2 0) org-script-display))) + (add-text-properties (match-beginning 2) (match-end 2) + (list 'invisible t + 'org-dwidth t 'org-dwidth-n 1)) + (if (and (eq (char-after (match-beginning 3)) ?{) + (eq (char-before (match-end 3)) ?})) + (progn + (add-text-properties + (match-beginning 3) (1+ (match-beginning 3)) + (list 'invisible t 'org-dwidth t 'org-dwidth-n 1)) + (add-text-properties + (1- (match-end 3)) (match-end 3) + (list 'invisible t 'org-dwidth t 'org-dwidth-n 1))))) + t))) ;;;; Visibility cycling, including org-goto and indirect buffer ;;; Cycling -(defvar org-cycle-global-status nil) -(make-variable-buffer-local 'org-cycle-global-status) +(defvar-local org-cycle-global-status nil) (put 'org-cycle-global-status 'org-state t) -(defvar org-cycle-subtree-status nil) -(make-variable-buffer-local 'org-cycle-subtree-status) +(defvar-local org-cycle-subtree-status nil) (put 'org-cycle-subtree-status 'org-state t) (defvar org-inlinetask-min-level) @@ -6646,52 +6711,58 @@ and subscripts." ;;;###autoload (defun org-cycle (&optional arg) - "TAB-action and visibility cycling for Org-mode. + "TAB-action and visibility cycling for Org mode. -This is the command invoked in Org-mode by the TAB key. Its main purpose -is outline visibility cycling, but it also invokes other actions +This is the command invoked in Org mode by the `TAB' key. Its main +purpose is outline visibility cycling, but it also invokes other actions in special contexts. -- When this function is called with a prefix argument, rotate the entire - buffer through 3 states (global cycling) +When this function is called with a `\\[universal-argument]' prefix, rotate \ +the entire +buffer through 3 states (global cycling) 1. OVERVIEW: Show only top-level headlines. 2. CONTENTS: Show all headlines of all levels, but no body text. 3. SHOW ALL: Show everything. - When called with two `C-u C-u' prefixes, switch to the startup visibility, - determined by the variable `org-startup-folded', and by any VISIBILITY - properties in the buffer. - When called with three `C-u C-u C-u' prefixed, show the entire buffer, - including any drawers. -- When inside a table, re-align the table and move to the next field. +With a `\\[universal-argument] \\[universal-argument]' prefix argument, \ +switch to the startup visibility, +determined by the variable `org-startup-folded', and by any VISIBILITY +properties in the buffer. + +With a `\\[universal-argument] \\[universal-argument] \ +\\[universal-argument]' prefix argument, show the entire buffer, including +any drawers. + +When inside a table, re-align the table and move to the next field. -- When point is at the beginning of a headline, rotate the subtree started - by this line through 3 different states (local cycling) +When point is at the beginning of a headline, rotate the subtree started +by this line through 3 different states (local cycling) 1. FOLDED: Only the main headline is shown. 2. CHILDREN: The main headline and the direct children are shown. From this state, you can move to one of the children and zoom in further. 3. SUBTREE: Show the entire subtree, including body text. - If there is no subtree, switch directly from CHILDREN to FOLDED. - -- When point is at the beginning of an empty headline and the variable - `org-cycle-level-after-item/entry-creation' is set, cycle the level - of the headline by demoting and promoting it to likely levels. This - speeds up creation document structure by pressing TAB once or several - times right after creating a new headline. - -- When there is a numeric prefix, go up to a heading with level ARG, do - a `show-subtree' and return to the previous cursor position. If ARG - is negative, go up that many levels. - -- When point is not at the beginning of a headline, execute the global - binding for TAB, which is re-indenting the line. See the option - `org-cycle-emulate-tab' for details. - -- Special case: if point is at the beginning of the buffer and there is - no headline in line 1, this function will act as if called with prefix arg - (C-u TAB, same as S-TAB) also when called without prefix arg. - But only if also the variable `org-cycle-global-at-bob' is t." +If there is no subtree, switch directly from CHILDREN to FOLDED. + +When point is at the beginning of an empty headline and the variable +`org-cycle-level-after-item/entry-creation' is set, cycle the level +of the headline by demoting and promoting it to likely levels. This +speeds up creation document structure by pressing `TAB' once or several +times right after creating a new headline. + +When there is a numeric prefix, go up to a heading with level ARG, do +a `show-subtree' and return to the previous cursor position. If ARG +is negative, go up that many levels. + +When point is not at the beginning of a headline, execute the global +binding for `TAB', which is re-indenting the line. See the option +`org-cycle-emulate-tab' for details. + +As a special case, if point is at the beginning of the buffer and there is +no headline in line 1, this function will act as if called with prefix arg +\(`\\[universal-argument] TAB', same as `S-TAB') also when called without \ +prefix arg, but only +if the variable `org-cycle-global-at-bob' is t." (interactive "P") (org-load-modules-maybe) (unless (or (run-hook-with-args-until-success 'org-tab-first-hook) @@ -6720,10 +6791,6 @@ in special contexts. org-cycle-hook)) (pos (point))) - (if (or bob-special (equal arg '(4))) - ;; special case: use global cycling - (setq arg t)) - (cond ((equal arg '(16)) @@ -6732,25 +6799,30 @@ in special contexts. (org-unlogged-message "Startup visibility, plus VISIBILITY properties")) ((equal arg '(64)) - (show-all) + (outline-show-all) (org-unlogged-message "Entire buffer visible, including drawers")) + ((equal arg '(4)) (org-cycle-internal-global)) + + ;; Try hiding block at point. + ((org-hide-block-toggle-maybe)) + ;; Try cdlatex TAB completion ((org-try-cdlatex-tab)) ;; Table: enter it or move to the next field. ((org-at-table-p 'any) (if (org-at-table.el-p) - (message "Use C-c ' to edit table.el tables") + (message "%s" (substitute-command-keys "\\\ +Use `\\[org-edit-special]' to edit table.el tables")) (if arg (org-table-edit-field t) (org-table-justify-field-maybe) (call-interactively 'org-table-next-field)))) - ((run-hook-with-args-until-success - 'org-tab-after-check-for-table-hook)) + ((run-hook-with-args-until-success 'org-tab-after-check-for-table-hook)) ;; Global cycling: delegate to `org-cycle-internal-global'. - ((eq arg t) (org-cycle-internal-global)) + (bob-special (org-cycle-internal-global)) ;; Drawers: delegate to `org-flag-drawer'. ((save-excursion @@ -6830,7 +6902,7 @@ in special contexts. (eq org-cycle-global-status 'contents)) ;; We just showed the table of contents - now show everything (run-hook-with-args 'org-pre-cycle-hook 'all) - (show-all) + (outline-show-all) (unless ga (org-unlogged-message "SHOW ALL")) (setq org-cycle-global-status 'all) (run-hook-with-args 'org-cycle-hook 'all)) @@ -6873,15 +6945,10 @@ in special contexts. (org-list-search-forward (org-item-beginning-re) eos t))))) ;; Determine end invisible part of buffer (EOL) (beginning-of-line 2) - ;; XEmacs doesn't have `next-single-char-property-change' - (if (featurep 'xemacs) - (while (and (not (eobp)) ;; this is like `next-line' - (get-char-property (1- (point)) 'invisible)) - (beginning-of-line 2)) - (while (and (not (eobp)) ;; this is like `next-line' - (get-char-property (1- (point)) 'invisible)) - (goto-char (next-single-char-property-change (point) 'invisible)) - (and (eolp) (beginning-of-line 2)))) + (while (and (not (eobp)) ;This is like `next-line'. + (get-char-property (1- (point)) 'invisible)) + (goto-char (next-single-char-property-change (point) 'invisible)) + (and (eolp) (beginning-of-line 2))) (setq eol (point))) ;; Find out what to do next and set `this-command' (cond @@ -6894,7 +6961,7 @@ in special contexts. (save-excursion (goto-char eos) (outline-next-heading) - (if (outline-invisible-p) (org-flag-heading nil)))) + (when (outline-invisible-p) (org-flag-heading nil)))) ((and (or (>= eol eos) (not (string-match "\\S-" (buffer-substring eol eos)))) (or has-children @@ -6906,7 +6973,7 @@ in special contexts. (if (org-at-item-p) (org-list-set-item-visibility (point-at-bol) struct 'children) (org-show-entry) - (org-with-limited-levels (show-children)) + (org-with-limited-levels (org-show-children)) ;; FIXME: This slows down the func way too much. ;; How keep drawers hidden in subtree anyway? ;; (when (memq 'org-cycle-hide-drawers org-cycle-hook) @@ -6921,14 +6988,14 @@ in special contexts. (let* ((struct (org-list-struct)) (prevs (org-list-prevs-alist struct)) (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)) + (dolist (e (org-list-get-all-items (point) struct prevs)) + (org-list-set-item-visibility e struct 'folded)) (goto-char (if (< end eos) end eos))))))) (org-unlogged-message "CHILDREN") (save-excursion (goto-char eos) (outline-next-heading) - (if (outline-invisible-p) (org-flag-heading nil))) + (when (outline-invisible-p) (org-flag-heading nil))) (setq org-cycle-subtree-status 'children) (unless (org-before-first-heading-p) (run-hook-with-args 'org-cycle-hook 'children))) @@ -6957,15 +7024,15 @@ in special contexts. ;;;###autoload (defun org-global-cycle (&optional arg) "Cycle the global visibility. For details see `org-cycle'. -With \\[universal-argument] prefix arg, switch to startup visibility. +With `\\[universal-argument]' prefix ARG, switch to startup visibility. With a numeric prefix, show all headlines up to that level." (interactive "P") (let ((org-cycle-include-plain-lists (if (derived-mode-p 'org-mode) org-cycle-include-plain-lists nil))) (cond ((integerp arg) - (show-all) - (hide-sublevels arg) + (outline-show-all) + (outline-hide-sublevels arg) (setq org-cycle-global-status 'contents)) ((equal arg '(4)) (org-set-startup-visibility) @@ -6982,9 +7049,9 @@ With a numeric prefix, show all headlines up to that level." (org-content)) ((or (eq org-startup-folded 'showeverything) (eq org-startup-folded nil)) - (show-all))) + (outline-show-all))) (unless (eq org-startup-folded 'showeverything) - (if org-hide-block-startup (org-hide-block-all)) + (when org-hide-block-startup (org-hide-block-all)) (org-set-visibility-according-to-property 'no-cleanup) (org-cycle-hide-archived-subtrees 'all) (org-cycle-hide-drawers 'all) @@ -6993,33 +7060,32 @@ With a numeric prefix, show all headlines up to that level." (defun org-set-visibility-according-to-property (&optional no-cleanup) "Switch subtree visibilities according to :VISIBILITY: property." (interactive) - (let (org-show-entry-below) - (org-with-wide-buffer - (goto-char (point-min)) - (while (re-search-forward "^[ \t]*:VISIBILITY:" nil t) - (if (not (org-at-property-p)) (outline-next-heading) - (let ((state (match-string 3))) - (save-excursion - (org-back-to-heading t) - (hide-subtree) - (org-reveal) - (cond - ((equal state "folded") - (hide-subtree)) - ((equal state "children") - (org-show-hidden-entry) - (show-children)) - ((equal state "content") - (save-excursion - (save-restriction - (org-narrow-to-subtree) - (org-content)))) - ((member state '("all" "showall")) - (show-subtree))))))) - (unless no-cleanup - (org-cycle-hide-archived-subtrees 'all) - (org-cycle-hide-drawers 'all) - (org-cycle-show-empty-lines 'all))))) + (org-with-wide-buffer + (goto-char (point-min)) + (while (re-search-forward "^[ \t]*:VISIBILITY:" nil t) + (if (not (org-at-property-p)) (outline-next-heading) + (let ((state (match-string 3))) + (save-excursion + (org-back-to-heading t) + (outline-hide-subtree) + (org-reveal) + (cond + ((equal state "folded") + (outline-hide-subtree)) + ((equal state "children") + (org-show-hidden-entry) + (org-show-children)) + ((equal state "content") + (save-excursion + (save-restriction + (org-narrow-to-subtree) + (org-content)))) + ((member state '("all" "showall")) + (outline-show-subtree))))))) + (unless no-cleanup + (org-cycle-hide-archived-subtrees 'all) + (org-cycle-hide-drawers 'all) + (org-cycle-show-empty-lines 'all)))) ;; This function uses outline-regexp instead of the more fundamental ;; org-outline-regexp so that org-cycle-global works outside of Org @@ -7035,11 +7101,10 @@ results." (let ((level (save-excursion (goto-char (point-min)) - (if (re-search-forward (concat "^" outline-regexp) nil t) - (progn - (goto-char (match-beginning 0)) - (funcall outline-level)))))) - (and level (hide-sublevels level))))) + (when (re-search-forward (concat "^" outline-regexp) nil t) + (goto-char (match-beginning 0)) + (funcall outline-level))))) + (and level (outline-hide-sublevels level))))) (defun org-content (&optional arg) "Show all headlines in the buffer, like a table of contents. @@ -7057,9 +7122,9 @@ With numerical argument N, show content up to level N." t) (looking-at org-outline-regexp)) (if (integerp arg) - (show-children (1- arg)) - (show-branches)) - (if (bobp) (throw 'exit nil)))))) + (org-show-children (1- arg)) + (outline-show-branches)) + (when (bobp) (throw 'exit nil)))))) (defun org-optimize-window-after-visibility-change (state) "Adjust the window after a change in outline visibility. @@ -7074,13 +7139,11 @@ This function is the default value of the hook `org-cycle-hook'." (defun org-remove-empty-overlays-at (pos) "Remove outline overlays that do not contain non-white stuff." - (mapc - (lambda (o) - (and (eq 'outline (overlay-get o 'invisible)) - (not (string-match "\\S-" (buffer-substring (overlay-start o) - (overlay-end o)))) - (delete-overlay o))) - (overlays-at pos))) + (dolist (o (overlays-at pos)) + (and (eq 'outline (overlay-get o 'invisible)) + (not (string-match "\\S-" (buffer-substring (overlay-start o) + (overlay-end o)))) + (delete-overlay o)))) (defun org-clean-visibility-after-subtree-move () "Fix visibility issues after moving a subtree." @@ -7098,7 +7161,7 @@ This function is the default value of the hook `org-cycle-hook'." (point-at-eol) (point)))) (level (looking-at "\\*+")) - (re (if level (concat "^" (regexp-quote (match-string 0)) " ")))) + (re (when level (concat "^" (regexp-quote (match-string 0)) " ")))) (save-excursion (save-restriction (narrow-to-region beg end) @@ -7106,10 +7169,10 @@ This function is the default value of the hook `org-cycle-hook'." ;; Properly fold already folded siblings (goto-char (point-min)) (while (re-search-forward re nil t) - (if (and (not (outline-invisible-p)) - (save-excursion - (goto-char (point-at-eol)) (outline-invisible-p))) - (hide-entry)))) + (when (and (not (outline-invisible-p)) + (save-excursion + (goto-char (point-at-eol)) (outline-invisible-p))) + (outline-hide-entry)))) (org-cycle-show-empty-lines 'overview) (org-cycle-hide-drawers 'overview))))) @@ -7153,9 +7216,9 @@ are at least `org-cycle-separator-lines' empty lines before the headline." (goto-char (point-max)) (outline-previous-heading) (outline-end-of-heading) - (if (and (looking-at "[ \t\n]+") - (= (match-end 0) (point-max))) - (outline-flag-region (point) (match-end 0) nil)))) + (when (and (looking-at "[ \t\n]+") + (= (match-end 0) (point-max))) + (outline-flag-region (point) (match-end 0) nil)))) (defun org-show-empty-lines-in-parent () "Move to the parent and re-show empty lines before visible headlines." @@ -7164,21 +7227,19 @@ are at least `org-cycle-separator-lines' empty lines before the headline." (org-cycle-show-empty-lines context)))) (defun org-files-list () - "Return `org-agenda-files' list, plus all open org-mode files. + "Return `org-agenda-files' list, plus all open Org files. This is useful for operations that need to scan all of a user's open and agenda-wise Org files." (let ((files (mapcar 'expand-file-name (org-agenda-files)))) (dolist (buf (buffer-list)) (with-current-buffer buf - (if (and (derived-mode-p 'org-mode) (buffer-file-name)) - (let ((file (expand-file-name (buffer-file-name)))) - (unless (member file files) - (push file files)))))) + (when (and (derived-mode-p 'org-mode) (buffer-file-name)) + (cl-pushnew (expand-file-name (buffer-file-name)) files)))) files)) (defsubst org-entry-beginning-position () "Return the beginning position of the current entry." - (save-excursion (outline-back-to-heading t) (point))) + (save-excursion (org-back-to-heading t) (point))) (defsubst org-entry-end-position () "Return the end position of the current entry." @@ -7213,23 +7274,24 @@ specifying which drawers should not be hidden." Otherwise make it visible. When optional argument ELEMENT is a parsed drawer, as returned by `org-element-at-point', hide or show that drawer instead." - (when (save-excursion - (beginning-of-line) - (org-looking-at-p org-drawer-regexp)) - (let ((drawer (or element (org-element-at-point)))) - (when (memq (org-element-type drawer) '(drawer property-drawer)) - (let ((post (org-element-property :post-affiliated drawer))) - (save-excursion - (outline-flag-region - (progn (goto-char post) (line-end-position)) - (progn (goto-char (org-element-property :end drawer)) - (skip-chars-backward " \r\t\n") - (line-end-position)) - flag)) - ;; When the drawer is hidden away, make sure point lies in - ;; a visible part of the buffer. - (when (and flag (> (line-beginning-position) post)) - (goto-char post))))))) + (let ((drawer (or element + (and (save-excursion + (beginning-of-line) + (looking-at-p org-drawer-regexp)) + (org-element-at-point))))) + (when (memq (org-element-type drawer) '(drawer property-drawer)) + (let ((post (org-element-property :post-affiliated drawer))) + (save-excursion + (outline-flag-region + (progn (goto-char post) (line-end-position)) + (progn (goto-char (org-element-property :end drawer)) + (skip-chars-backward " \r\t\n") + (line-end-position)) + flag)) + ;; When the drawer is hidden away, make sure point lies in + ;; a visible part of the buffer. + (when (and flag (> (line-beginning-position) post)) + (goto-char post)))))) (defun org-subtree-end-visible-p () "Is the end of the current subtree visible?" @@ -7238,9 +7300,11 @@ show that drawer instead." (defun org-first-headline-recenter () "Move cursor to the first headline and recenter the headline." - (goto-char (point-min)) - (when (re-search-forward (concat "^\\(" org-outline-regexp "\\)") nil t) - (set-window-start (selected-window) (point-at-bol)))) + (let ((window (get-buffer-window))) + (when window + (goto-char (point-min)) + (when (re-search-forward (concat "^\\(" org-outline-regexp "\\)") nil t) + (set-window-start window (line-beginning-position)))))) ;;; Saving and restoring visibility @@ -7251,38 +7315,30 @@ The return value is a list of cons cells, with start and stop positions for each overlay. If USE-MARKERS is set, return the positions as markers." (let (beg end) - (save-excursion - (save-restriction - (widen) - (delq nil - (mapcar (lambda (o) - (when (eq (overlay-get o 'invisible) 'outline) - (setq beg (overlay-start o) - end (overlay-end o)) - (and beg end (> end beg) - (if use-markers - (cons (copy-marker beg) - (copy-marker end t)) - (cons beg end))))) - (overlays-in (point-min) (point-max)))))))) + (org-with-wide-buffer + (delq nil + (mapcar (lambda (o) + (when (eq (overlay-get o 'invisible) 'outline) + (setq beg (overlay-start o) + end (overlay-end o)) + (and beg end (> end beg) + (if use-markers + (cons (copy-marker beg) + (copy-marker end t)) + (cons beg end))))) + (overlays-in (point-min) (point-max))))))) (defun org-set-outline-overlay-data (data) "Create visibility overlays for all positions in DATA. DATA should have been made by `org-outline-overlay-data'." - (let (o) - (save-excursion - (save-restriction - (widen) - (show-all) - (mapc (lambda (c) - (outline-flag-region (car c) (cdr c) t)) - data))))) + (org-with-wide-buffer + (outline-show-all) + (dolist (c data) (outline-flag-region (car c) (cdr c) t)))) ;;; Folding of blocks -(defvar org-hide-block-overlays nil +(defvar-local org-hide-block-overlays nil "Overlays hiding blocks.") -(make-variable-buffer-local 'org-hide-block-overlays) (defun org-block-map (function &optional start end) "Call FUNCTION at the head of all source blocks in the current buffer. @@ -7310,7 +7366,7 @@ Optional arguments START and END can be used to limit the range." (defun org-show-block-all () "Unfold all blocks in the current buffer." (interactive) - (mapc 'delete-overlay org-hide-block-overlays) + (mapc #'delete-overlay org-hide-block-overlays) (setq org-hide-block-overlays nil)) (defun org-hide-block-toggle-maybe () @@ -7374,12 +7430,10 @@ a block. Return a non-nil value when toggling is successful." (when (eq (overlay-get ov 'invisible) 'org-hide-block) (delete-overlay ov)))))))) -;; org-tab-after-check-for-cycling-hook -(add-hook 'org-tab-first-hook 'org-hide-block-toggle-maybe) ;; Remove overlays when changing major mode (add-hook 'org-mode-hook - (lambda () (org-add-hook 'change-major-mode-hook - 'org-show-block-all 'append 'local))) + (lambda () (add-hook 'change-major-mode-hook + 'org-show-block-all 'append 'local))) ;;; Org-goto @@ -7446,8 +7500,8 @@ returns to the original buffer in which the visibility is still unchanged. After RET it will also jump to the location selected in the indirect buffer and expose the headline hierarchy above. -With a prefix argument, use the alternative interface: e.g. if -`org-goto-interface' is 'outline use 'outline-path-completion." +With a prefix argument, use the alternative interface: e.g., if +`org-goto-interface' is `outline' use `outline-path-completion'." (interactive "P") (org-goto-map) (let* ((org-refile-targets `((nil . (:maxlevel . ,org-goto-max-level)))) @@ -7463,23 +7517,23 @@ With a prefix argument, use the alternative interface: e.g. if (selected-point (if (eq interface 'outline) (car (org-get-location (current-buffer) org-goto-help)) - (let ((pa (org-refile-get-location "Goto" nil nil t))) + (let ((pa (org-refile-get-location "Goto"))) (org-refile-check-position pa) (nth 3 pa))))) (if selected-point (progn (org-mark-ring-push org-goto-start-pos) (goto-char selected-point) - (if (or (outline-invisible-p) (org-invisible-p2)) - (org-show-context 'org-goto))) + (when (or (outline-invisible-p) (org-invisible-p2)) + (org-show-context 'org-goto))) (message "Quit")))) (defvar org-goto-selected-point nil) ; dynamically scoped parameter (defvar org-goto-exit-command nil) ; dynamically scoped parameter (defvar org-goto-local-auto-isearch-map) ; defined below -(defun org-get-location (buf help) - "Let the user select a location in the Org-mode buffer BUF. +(defun org-get-location (_buf help) + "Let the user select a location in current buffer. This function uses a recursive edit. It returns the selected position or nil." (org-no-popups @@ -7492,7 +7546,7 @@ or nil." (save-window-excursion (delete-other-windows) (and (get-buffer "*org-goto*") (kill-buffer "*org-goto*")) - (org-pop-to-buffer-same-window + (pop-to-buffer-same-window (condition-case nil (make-indirect-buffer (current-buffer) "*org-goto*") (error (make-indirect-buffer (current-buffer) "*org-goto*")))) @@ -7555,11 +7609,11 @@ or nil." (isearch-mode t) (isearch-process-search-char (string-to-char keys))))) -(defun org-goto-ret (&optional arg) +(defun org-goto-ret (&optional _arg) "Finish `org-goto' by going to the new location." (interactive "P") - (setq org-goto-selected-point (point) - org-goto-exit-command 'return) + (setq org-goto-selected-point (point)) + (setq org-goto-exit-command 'return) (throw 'exit nil)) (defun org-goto-left () @@ -7598,17 +7652,18 @@ or nil." (defun org-tree-to-indirect-buffer (&optional arg) "Create indirect buffer and narrow it to current subtree. + With a numerical prefix ARG, go up to this level and then take that tree. If ARG is negative, go up that many levels. If `org-indirect-buffer-display' is not `new-frame', the command removes the indirect buffer previously made with this command, to avoid proliferation of indirect buffers. However, when you call the command with a \ -\\[universal-argument] prefix, or -when `org-indirect-buffer-display' is `new-frame', the last buffer -is kept so that you can work with several indirect buffers at the same time. -If `org-indirect-buffer-display' is `dedicated-frame', the \ -\\[universal-argument] prefix also +`\\[universal-argument]' prefix, or +when `org-indirect-buffer-display' is `new-frame', the last buffer is kept +so that you can work with several indirect buffers at the same time. If +`org-indirect-buffer-display' is `dedicated-frame', the \ +`\\[universal-argument]' prefix also requests that a new frame be made for the new buffer, so that the dedicated frame is not changed." (interactive "P") @@ -7620,18 +7675,18 @@ frame is not changed." (org-back-to-heading t) (when (numberp arg) (setq level (org-outline-level)) - (if (< arg 0) (setq arg (+ level arg))) + (when (< arg 0) (setq arg (+ level arg))) (while (> (setq level (org-outline-level)) arg) (org-up-heading-safe))) (setq beg (point) - heading (org-get-heading)) + heading (org-get-heading 'no-tags)) (org-end-of-subtree t t) - (if (org-at-heading-p) (backward-char 1)) + (when (org-at-heading-p) (backward-char 1)) (setq end (point))) - (if (and (buffer-live-p org-last-indirect-buffer) - (not (eq org-indirect-buffer-display 'new-frame)) - (not arg)) - (kill-buffer org-last-indirect-buffer)) + (when (and (buffer-live-p org-last-indirect-buffer) + (not (eq org-indirect-buffer-display 'new-frame)) + (not arg)) + (kill-buffer org-last-indirect-buffer)) (setq ibuf (org-get-indirect-buffer cbuf heading) org-last-indirect-buffer ibuf) (cond @@ -7639,7 +7694,7 @@ frame is not changed." (and arg (eq org-indirect-buffer-display 'dedicated-frame))) (select-frame (make-frame)) (delete-other-windows) - (org-pop-to-buffer-same-window ibuf) + (pop-to-buffer-same-window ibuf) (org-set-frame-title heading)) ((eq org-indirect-buffer-display 'dedicated-frame) (raise-frame @@ -7648,17 +7703,15 @@ frame is not changed." org-indirect-dedicated-frame) (setq org-indirect-dedicated-frame (make-frame))))) (delete-other-windows) - (org-pop-to-buffer-same-window ibuf) + (pop-to-buffer-same-window ibuf) (org-set-frame-title (concat "Indirect: " heading))) ((eq org-indirect-buffer-display 'current-window) - (org-pop-to-buffer-same-window ibuf)) + (pop-to-buffer-same-window ibuf)) ((eq org-indirect-buffer-display 'other-window) (pop-to-buffer ibuf)) (t (error "Invalid value"))) - (if (featurep 'xemacs) - (save-excursion (org-mode) (turn-on-font-lock))) (narrow-to-region beg end) - (show-all) + (outline-show-all) (goto-char pos) (run-hook-with-args 'org-cycle-hook 'all) (and (window-live-p cwin) (select-window cwin)))) @@ -7679,241 +7732,188 @@ frame is not changed." (defun org-set-frame-title (title) "Set the title of the current frame to the string TITLE." - ;; FIXME: how to name a single frame in XEmacs??? - (unless (featurep 'xemacs) - (modify-frame-parameters (selected-frame) (list (cons 'name title))))) + (modify-frame-parameters (selected-frame) (list (cons 'name title)))) ;;;; Structure editing ;;; Inserting headlines -(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." +(defun org--line-empty-p (n) + "Is the Nth next line empty? + +Counts the current line as N = 1 and the previous line as N = 0; +see `beginning-of-line'." (save-excursion (and (not (bobp)) - (or (beginning-of-line (if next 2 0)) t) + (or (beginning-of-line n) t) (save-match-data (looking-at "[ \t]*$"))))) -(defun org-insert-heading (&optional arg invisible-ok top-level) - "Insert a new heading or an item with the same depth at point. - -If point is at the beginning of a heading or a list item, insert -a new heading or a new item above the current one. If point is -at the beginning of a normal line, turn the line into a heading. +(defun org-previous-line-empty-p () + "Is the previous line a blank line? +When NEXT is non-nil, check the next line instead." + (org--line-empty-p 0)) -If point is in the middle of a headline or a list item, split the -headline or the item and create a new headline/item with the text -in the current line after point \(see `org-M-RET-may-split-line' -on how to modify this behavior). +(defun org-next-line-empty-p () + "Is the previous line a blank line? +When NEXT is non-nil, check the next line instead." + (org--line-empty-p 2)) + +(defun org--blank-before-heading-p (&optional parent) + "Non-nil when an empty line should precede a new heading here. +When optional argument PARENT is non-nil, consider parent +headline instead of current one." + (pcase (assq 'heading org-blank-before-new-entry) + (`(heading . auto) + (save-excursion + (org-with-limited-levels + (unless (and (org-before-first-heading-p) + (not (outline-next-heading))) + (org-back-to-heading t) + (when parent (org-up-heading-safe)) + (cond ((not (bobp)) + (org-previous-line-empty-p)) + ((outline-next-heading) + (org-previous-line-empty-p)) + ;; Ignore trailing spaces on last buffer line. + ((progn (skip-chars-backward " \t") (bolp)) + (org-previous-line-empty-p)) + (t nil)))))) + (`(heading . ,value) value) + (_ nil))) + +(defun org-insert-heading (&optional arg invisible-ok top) + "Insert a new heading or an item with the same depth at point. -With one universal prefix argument, set the user option -`org-insert-heading-respect-content' to t for the duration of -the command. This modifies the behavior described above in this -ways: on list items and at the beginning of normal lines, force -the insertion of a heading after the current subtree. +If point is at the beginning of a heading, insert a new heading +or a new headline above the current one. When at the beginning +of a regular line of text, turn it into a heading. -With two universal prefix arguments, insert the heading at the -end of the grandparent subtree. For example, if point is within -a 2nd-level heading, then it will insert a 2nd-level heading at -the end of the 1st-level parent heading. +If point is in the middle of a line, split it 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). As +a special case, on a headline, splitting can only happen on the +title itself. E.g., this excludes breaking stars or tags. -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). +With a `\\[universal-argument]' prefix, set \ +`org-insert-heading-respect-content' to +a non-nil value for the duration of the command. This forces the +insertion of a heading after the current subtree, independently +on the location of point. -If point is at the beginning of a normal line, turn this line -into a heading. +With a `\\[universal-argument] \\[universal-argument]' prefix, \ +insert the heading at the end of the tree +above the current heading. For example, if point is within a +2nd-level heading, then it will insert a 2nd-level heading at +the end of the 1st-level parent subtree. When INVISIBLE-OK is set, stop at invisible headlines when going back. This is important for non-interactive uses of the command. -When optional argument TOP-LEVEL is non-nil, insert a level 1 -heading, unconditionally." +When optional argument TOP is non-nil, insert a level 1 heading, +unconditionally." (interactive "P") - (if (org-called-interactively-p 'any) (org-reveal)) - (let ((itemp (and (not top-level) (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 '(4)))) - (initial-content "")) - + (let* ((blank? (org--blank-before-heading-p (equal arg '(16)))) + (level (org-current-level)) + (stars (make-string (if (and level (not top)) level 1) ?*))) (cond - - ((or (= (buffer-size) 0) - (and (not (save-excursion - (and (ignore-errors (org-back-to-heading invisible-ok)) - (org-at-heading-p)))) - (or arg (not itemp)))) - ;; At beginning of buffer or so high up that only a heading - ;; makes sense. - (cond ((and (bolp) (not respect-content)) (insert "* ")) - ((not respect-content) - (unless may-split (end-of-line)) - (insert "\n* ")) - ((re-search-forward org-outline-regexp-bol nil t) - (beginning-of-line) - (insert "* \n") - (backward-char)) - (t (goto-char (point-max)) - (insert "\n* "))) - (run-hooks 'org-insert-heading-hook)) - - ((and itemp (not (member arg '((4) (16)))) (org-insert-item))) - + ((or org-insert-heading-respect-content + (member arg '((4) (16))) + (and (not invisible-ok) + (invisible-p (max (1- (point)) (point-min))))) + ;; Position point at the location of insertion. + (if (not level) ;before first headline + (org-with-limited-levels (outline-next-heading)) + ;; Make sure we end up on a visible headline if INVISIBLE-OK + ;; is nil. + (org-with-limited-levels (org-back-to-heading invisible-ok)) + (cond ((equal arg '(16)) + (org-up-heading-safe) + (org-end-of-subtree t t)) + (t + (org-end-of-subtree t t)))) + (unless (bolp) (insert "\n")) ;ensure final newline + (unless (and blank? (org-previous-line-empty-p)) + (org-N-empty-lines-before-current (if blank? 1 0))) + (insert stars " \n") + (forward-char -1)) + ;; At a headline... + ((org-at-heading-p) + (cond ((bolp) + (when blank? (save-excursion (insert "\n"))) + (save-excursion (insert stars " \n")) + (unless (and blank? (org-previous-line-empty-p)) + (org-N-empty-lines-before-current (if blank? 1 0))) + (end-of-line)) + ((and (org-get-alist-option org-M-RET-may-split-line 'headline) + (org-match-line org-complex-heading-regexp) + (org-pos-in-match-range (point) 4)) + ;; Grab the text that should moved to the new headline. + ;; Preserve tags. + (let ((split (delete-and-extract-region (point) (match-end 4)))) + (if (looking-at "[ \t]*$") (replace-match "") + (org-set-tags nil t)) + (end-of-line) + (when blank? (insert "\n")) + (insert "\n" stars " ") + (when (org-string-nw-p split) (insert split)) + (when (eobp) (save-excursion (insert "\n"))))) + (t + (end-of-line) + (when blank? (insert "\n")) + (insert "\n" stars " ") + (when (eobp) (save-excursion (insert "\n")))))) + ;; On regular text, turn line into a headline or split, if + ;; appropriate. + ((bolp) + (insert stars " ") + (unless (and blank? (org-previous-line-empty-p)) + (org-N-empty-lines-before-current (if blank? 1 0)))) (t - ;; Maybe move at the end of the subtree - (when (equal arg '(16)) - (org-up-heading-safe) - (org-end-of-subtree 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 - (if (org-before-first-heading-p) "*" - (save-excursion - (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 - (if top-level "* " - (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 (and respect-content - (not (org-looking-at-p org-outline-regexp-bol))) - (if (not (org-before-first-heading-p)) - (org-end-of-subtree nil t) - (re-search-forward org-outline-regexp-bol) - (beginning-of-line 0)) - (skip-chars-backward " \r\t\n") - (and (not (looking-back "^\\*+" (line-beginning-position))) - (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: split intelligently (keeping - ;; tags). - (let ((pos (point))) - (beginning-of-line) - (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) ?\s))) - (setq initial-content (org-trim initial-content))) - (goto-char pos)) - ;; A normal line. - (setq initial-content - (org-trim - (delete-and-extract-region (point) (line-end-position)))))) - - ;; If we are at the beginning of the line, insert before it. - ;; Otherwise, after it. - (cond - ((and (bolp) (looking-at "[ \t]*$"))) - ((bolp) (save-excursion (insert "\n"))) - (t (end-of-line) - (insert "\n"))) - - ;; Insert the new heading - (insert stars) - (just-one-space) - (insert initial-content) - (unless (and blank (org-previous-line-empty-p)) - (org-N-empty-lines-before-current (if blank 1 0))) - ;; Adjust visibility, which may be messed up if we removed - ;; blank lines while previous entry was hidden. - (let ((bol (line-beginning-position))) - (dolist (o (overlays-at (1- bol))) - (when (and (eq (overlay-get o 'invisible) 'outline) - (eq (overlay-end o) bol)) - (move-overlay o (overlay-start o) (1- bol))))) - (run-hooks 'org-insert-heading-hook))))))) - -(defun org-N-empty-lines-before-current (N) + (unless (org-get-alist-option org-M-RET-may-split-line 'headline) + (end-of-line)) + (insert "\n" stars " ") + (unless (and blank? (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 (beginning-of-line) - (let ((p (point))) - (skip-chars-backward " \r\t\n") - (unless (bolp) (forward-line)) - (delete-region (point) p)) - (when (> N 0) (insert (make-string N ?\n))))) - -(defun org-get-heading (&optional no-tags no-todo) + (unless (bobp) + (let ((start (save-excursion + (skip-chars-backward " \r\t\n") + (line-end-position)))) + (delete-region start (line-end-position 0)))) + (insert (make-string n ?\n)))) + +(defun org-get-heading (&optional no-tags no-todo no-priority no-comment) "Return the heading of the current entry, without the stars. When NO-TAGS is non-nil, don't include tags. -When NO-TODO is non-nil, don't include TODO keywords." +When NO-TODO is non-nil, don't include TODO keywords. +When NO-PRIORITY is non-nil, don't include priority cookie. +When NO-COMMENT is non-nil, don't include COMMENT string." (save-excursion (org-back-to-heading t) - (cond - ((and no-tags no-todo) + (let ((case-fold-search nil)) (looking-at org-complex-heading-regexp) - (match-string 4)) - (no-tags - (looking-at (concat org-outline-regexp - "\\(.*?\\)" - "\\(?:[ \t]+:[[:alnum:]:_@#%]+:\\)?[ \t]*$")) - (match-string 1)) - (no-todo - (looking-at org-todo-line-regexp) - (match-string 3)) - (t (looking-at org-heading-regexp) - (match-string 2))))) + (let ((todo (and (not no-todo) (match-string 2))) + (priority (and (not no-priority) (match-string 3))) + (headline (pcase (match-string 4) + (`nil "") + ((and (guard no-comment) h) + (replace-regexp-in-string + (eval-when-compile + (format "\\`%s[ \t]+" org-comment-string)) + "" h)) + (h h))) + (tags (and (not no-tags) (match-string 5)))) + (mapconcat #'identity + (delq nil (list todo priority headline tags)) + " "))))) (defvar orgstruct-mode) ; defined below @@ -7928,24 +7928,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 - (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)))))) + (when (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))) + (match-string-no-properties 2) + (and (match-end 3) (aref (match-string 3) 2)) + (match-string-no-properties 4) + (match-string-no-properties 5)))))) (defun org-get-entry () "Get the entry text, after heading, entire subtree." @@ -7953,6 +7953,24 @@ This is a list with the following elements: (org-back-to-heading t) (buffer-substring (point-at-bol 2) (org-end-of-subtree t)))) +(defun org-edit-headline (&optional heading) + "Edit the current headline. +Set it to HEADING when provided." + (interactive) + (org-with-wide-buffer + (org-back-to-heading t) + (let ((case-fold-search nil)) + (when (looking-at org-complex-heading-regexp) + (let* ((old (match-string-no-properties 4)) + (new (save-match-data + (org-trim (or heading (read-string "Edit: " old)))))) + (unless (equal old new) + (if old (replace-match new t t nil 4) + (goto-char (or (match-end 3) (match-end 2) (match-end 1))) + (insert " " new)) + (org-set-tags nil t) + (when (looking-at "[ \t]*$") (replace-match "")))))))) + (defun org-insert-heading-after-current () "Insert a new heading with same level as current, after current subtree." (interactive) @@ -7973,9 +7991,14 @@ This is a list with the following elements: (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 one prefix arg, force first state. With -two prefix args, force inserting at the end of the parent subtree." + +If the heading has no TODO state, or if the state is DONE, use +the first state (TODO by default). Also with one prefix arg, +force first state. With two prefix args, force inserting at the +end of the parent subtree. + +When called at a plain list item, insert a new item with an +unchecked check box." (interactive "P") (when (or force-heading (not (org-insert-item 'checkbox))) (org-insert-heading (or (and (equal arg '(16)) '(16)) @@ -7983,19 +8006,18 @@ two prefix args, force inserting at the end of the parent subtree." (save-excursion (org-back-to-heading) (outline-previous-heading) - (looking-at org-todo-line-regexp)) - (let* - ((new-mark-x - (if (or (equal arg '(4)) - (not (match-beginning 2)) - (member (match-string 2) org-done-keywords)) - (car org-todo-keywords-1) - (match-string 2))) - (new-mark - (or - (run-hook-with-args-until-success - 'org-todo-get-default-hook new-mark-x nil) - new-mark-x))) + (let ((case-fold-search nil)) (looking-at org-todo-line-regexp))) + (let* ((new-mark-x + (if (or (equal arg '(4)) + (not (match-beginning 2)) + (member (match-string 2) org-done-keywords)) + (car org-todo-keywords-1) + (match-string 2))) + (new-mark + (or + (run-hook-with-args-until-success + 'org-todo-get-default-hook new-mark-x nil) + new-mark-x))) (beginning-of-line 1) (and (looking-at org-outline-regexp) (goto-char (match-end 0)) (if org-treat-insert-todo-heading-as-state-change @@ -8043,18 +8065,17 @@ See also `org-promote'." (org-fix-position-after-promote)) (defun org-demote-subtree () - "Demote the entire subtree. See `org-demote'. -See also `org-promote'." + "Demote the entire subtree. +See `org-demote' and `org-promote'." (interactive) (save-excursion (org-with-limited-levels (org-map-tree 'org-demote))) (org-fix-position-after-promote)) - (defun org-do-promote () "Promote the current heading higher up the tree. -If the region is active in `transient-mark-mode', promote all headings -in the region." +If the region is active in `transient-mark-mode', promote all +headings in the region." (interactive) (save-excursion (if (org-region-active-p) @@ -8064,8 +8085,8 @@ in the region." (defun org-do-demote () "Demote the current heading lower down the tree. -If the region is active in `transient-mark-mode', demote all headings -in the region." +If the region is active in `transient-mark-mode', demote all +headings in the region." (interactive) (save-excursion (if (org-region-active-p) @@ -8074,15 +8095,15 @@ in the region." (org-fix-position-after-promote)) (defun org-fix-position-after-promote () - "Make sure that after pro/demotion cursor position is right." + "Fix cursor position and indentation after demoting/promoting." (let ((pos (point))) (when (save-excursion - (beginning-of-line 1) - (looking-at org-todo-line-regexp) - (or (equal pos (match-end 1)) (equal pos (match-end 2)))) + (beginning-of-line) + (let ((case-fold-search nil)) (looking-at org-todo-line-regexp)) + (or (eq pos (match-end 1)) (eq pos (match-end 2)))) (cond ((eobp) (insert " ")) ((eolp) (insert " ")) - ((equal (char-after) ?\ ) (forward-char 1)))))) + ((equal (char-after) ?\s) (forward-char 1)))))) (defun org-current-level () "Return the level of the current entry, or nil if before the first headline. @@ -8117,23 +8138,17 @@ time to headlines when structure editing, based on the value of (if org-odd-levels-only 2 1)) (defun org-get-valid-level (level &optional change) - "Rectify a level change under the influence of `org-odd-levels-only' -LEVEL is a current level, CHANGE is by how much the level should be -modified. Even if CHANGE is nil, LEVEL may be returned modified because -even level numbers will become the next higher odd number." + "Rectify a level change under the influence of `org-odd-levels-only'. +LEVEL is a current level, CHANGE is by how much the level should +be modified. Even if CHANGE is nil, LEVEL may be returned +modified because even level numbers will become the next higher +odd number. Returns values greater than 0." (if org-odd-levels-only (cond ((or (not change) (= 0 change)) (1+ (* 2 (/ level 2)))) - ((> change 0) (1+ (* 2 (/ (+ level (* 2 change)) 2)))) + ((> change 0) (1+ (* 2 (/ (+ (1- level) (* 2 change)) 2)))) ((< change 0) (max 1 (1+ (* 2 (/ (+ level (* 2 change)) 2)))))) (max 1 (+ level (or change 0))))) -(if (boundp 'define-obsolete-function-alias) - (if (or (featurep 'xemacs) (< emacs-major-version 23)) - (define-obsolete-function-alias 'org-get-legal-level - 'org-get-valid-level) - (define-obsolete-function-alias 'org-get-legal-level - 'org-get-valid-level "23.1"))) - (defun org-promote () "Promote the current heading higher up the tree." (org-with-wide-buffer @@ -8181,32 +8196,32 @@ After top level, it switches back to sibling level." (cond ;; If first headline in file, promote to top-level. ((= prev-level 0) - (loop repeat (/ (- cur-level 1) (org-level-increment)) - do (org-do-promote))) + (cl-loop repeat (/ (- cur-level 1) (org-level-increment)) + do (org-do-promote))) ;; If same level as prev, demote one. ((= prev-level cur-level) (org-do-demote)) ;; If parent is top-level, promote to top level if not already. ((= prev-level 1) - (loop repeat (/ (- cur-level 1) (org-level-increment)) - do (org-do-promote))) + (cl-loop repeat (/ (- cur-level 1) (org-level-increment)) + do (org-do-promote))) ;; If top-level, return to prev-level. ((= cur-level 1) - (loop repeat (/ (- prev-level 1) (org-level-increment)) - do (org-do-demote))) + (cl-loop repeat (/ (- prev-level 1) (org-level-increment)) + do (org-do-demote))) ;; If less than prev-level, promote one. ((< cur-level prev-level) (org-do-promote)) ;; If deeper than prev-level, promote until higher than ;; prev-level. ((> cur-level prev-level) - (loop repeat (+ 1 (/ (- cur-level prev-level) (org-level-increment))) - do (org-do-promote)))) + (cl-loop repeat (+ 1 (/ (- cur-level prev-level) (org-level-increment))) + do (org-do-promote)))) t)))) (defun org-map-tree (fun) "Call FUN for every heading underneath the current one." - (org-back-to-heading) + (org-back-to-heading t) (let ((level (funcall outline-level))) (save-excursion (funcall fun) @@ -8222,9 +8237,9 @@ After top level, it switches back to sibling level." (save-excursion (setq end (copy-marker end)) (goto-char beg) - (if (and (re-search-forward org-outline-regexp-bol nil t) - (< (point) end)) - (funcall fun)) + (when (and (re-search-forward org-outline-regexp-bol nil t) + (< (point) end)) + (funcall fun)) (while (and (progn (outline-next-heading) (< (point) end)) @@ -8260,7 +8275,7 @@ Assume point is at a heading or an inlinetask beginning." (point))) (forward-line) ;; Indent properly planning info and property drawer. - (when (org-looking-at-p org-planning-line-re) + (when (looking-at-p org-planning-line-re) (org-indent-line) (forward-line)) (when (looking-at org-property-drawer-re) @@ -8281,12 +8296,12 @@ Assume point is at a heading or an inlinetask beginning." (save-excursion (while (not (eobp)) (cond - ((org-looking-at-p "[ \t]*$") (forward-line)) - ((and (org-looking-at-p org-footnote-definition-re) + ((looking-at-p "[ \t]*$") (forward-line)) + ((and (looking-at-p org-footnote-definition-re) (let ((e (org-element-at-point))) (and (eq (org-element-type e) 'footnote-definition) (goto-char (org-element-property :end e)))))) - ((org-looking-at-p org-outline-regexp) (forward-line)) + ((looking-at-p org-outline-regexp) (forward-line)) ;; Give up if shifting would move before column 0 or ;; if it would introduce a headline or a footnote ;; definition. @@ -8294,13 +8309,13 @@ Assume point is at a heading or an inlinetask beginning." (skip-chars-forward " \t") (let ((ind (current-column))) (when (or (< ind diff) - (and (= ind diff) (org-looking-at-p forbidden-re))) + (and (= ind diff) (looking-at-p forbidden-re))) (throw 'no-shift nil))) ;; Ignore contents of example blocks and source ;; blocks if their indentation is meant to be ;; preserved. Jump to block's closing line. (beginning-of-line) - (or (and (org-looking-at-p "[ \t]*#\\+BEGIN_\\(EXAMPLE\\|SRC\\)") + (or (and (looking-at-p "[ \t]*#\\+BEGIN_\\(EXAMPLE\\|SRC\\)") (let ((e (org-element-at-point))) (and (memq (org-element-type e) '(example-block src-block)) @@ -8316,16 +8331,16 @@ Assume point is at a heading or an inlinetask beginning." ;; when indentation is meant to be preserved. (while (not (eobp)) (cond - ((and (org-looking-at-p org-footnote-definition-re) + ((and (looking-at-p org-footnote-definition-re) (let ((e (org-element-at-point))) (and (eq (org-element-type e) 'footnote-definition) (goto-char (org-element-property :end e)))))) - ((org-looking-at-p org-outline-regexp) (forward-line)) - ((org-looking-at-p "[ \t]*$") (forward-line)) + ((looking-at-p org-outline-regexp) (forward-line)) + ((looking-at-p "[ \t]*$") (forward-line)) (t - (org-indent-line-to (+ (org-get-indentation) diff)) + (indent-line-to (+ (org-get-indentation) diff)) (beginning-of-line) - (or (and (org-looking-at-p "[ \t]*#\\+BEGIN_\\(EXAMPLE\\|SRC\\)") + (or (and (looking-at-p "[ \t]*#\\+BEGIN_\\(EXAMPLE\\|SRC\\)") (let ((e (org-element-at-point))) (and (memq (org-element-type e) '(example-block src-block)) @@ -8338,7 +8353,7 @@ Assume point is at a heading or an inlinetask beginning." (forward-line))))))))) (defun org-convert-to-odd-levels () - "Convert an org-mode file with all levels allowed to one with odd levels. + "Convert an Org file with all levels allowed to one with odd levels. This will leave level 1 alone, convert level 2 to level 3, level 3 to level 5 etc." (interactive) @@ -8354,7 +8369,7 @@ level 5 etc." (end-of-line 1)))))) (defun org-convert-to-oddeven-levels () - "Convert an org-mode file with only odd levels to one with odd/even levels. + "Convert an Org file with only odd levels to one with odd/even levels. This promotes level 3 to level 2, level 5 to level 3 etc. If the file contains a section with an even level, conversion would destroy the structure of the file. An error is signaled in this @@ -8425,12 +8440,12 @@ case." (progn (goto-char beg0) (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 - (progn (org-end-of-subtree t t) - (save-excursion - (org-back-over-empty-lines) - (or (bolp) (newline))))) + (when (> arg 0) + ;; Moving forward - still need to move over subtree + (org-end-of-subtree t t) + (save-excursion + (org-back-over-empty-lines) + (or (bolp) (newline)))) (setq ne-ins (org-back-over-empty-lines)) (move-marker ins-point (point)) (setq txt (buffer-substring beg end)) @@ -8459,9 +8474,9 @@ case." (insert (make-string (- ne-ins ne-beg) ?\n))) (move-marker ins-point nil) (if folded - (hide-subtree) + (outline-hide-subtree) (org-show-entry) - (show-children) + (org-show-children) (org-cycle-hide-drawers 'children)) (org-clean-visibility-after-subtree-move) ;; move back to the initial column we were at @@ -8493,7 +8508,7 @@ of some markers in the region, even if CUT is non-nil. This is useful if the caller implements cut-and-paste as copy-then-paste-then-cut." (interactive "p") (let (beg end folded (beg0 (point))) - (if (org-called-interactively-p 'any) + (if (called-interactively-p 'any) (org-back-to-heading nil) ; take what looks like a subtree (org-back-to-heading t)) ; take what is really there (setq beg (point)) @@ -8598,22 +8613,22 @@ When REMOVE is non-nil, remove the subtree from the clipboard." (org-odd-levels-only nil) beg end newend) ;; Remove the forced level indicator - (if force-level - (delete-region (point-at-bol) (point))) + (when force-level + (delete-region (point-at-bol) (point))) ;; Paste (beginning-of-line (if (bolp) 1 2)) (setq beg (point)) (and (fboundp 'org-id-paste-tracker) (org-id-paste-tracker txt)) (insert-before-markers txt) - (unless (string-match "\n\\'" txt) (insert "\n")) + (unless (string-suffix-p "\n" txt) (insert "\n")) (setq newend (point)) (org-reinstall-markers-in-region beg) (setq end (point)) (goto-char beg) (skip-chars-forward " \t\n\r") (setq beg (point)) - (if (and (outline-invisible-p) visp) - (save-excursion (outline-show-heading))) + (when (and (outline-invisible-p) visp) + (save-excursion (outline-show-heading))) ;; Shift if necessary (unless (= shift 0) (save-restriction @@ -8623,14 +8638,14 @@ When REMOVE is non-nil, remove the subtree from the clipboard." (setq shift (+ delta shift))) (goto-char (point-min)) (setq newend (point-max)))) - (when (or (org-called-interactively-p 'interactive) for-yank) + (when (or (called-interactively-p 'interactive) for-yank) (message "Clipboard pasted as level %d subtree" new-level)) - (if (and (not for-yank) ; in this case, org-yank will decide about folding - kill-ring - (eq org-subtree-clip (current-kill 0)) - org-subtree-clip-folded) - ;; The tree was folded before it was killed/copied - (hide-subtree)) + (when (and (not for-yank) ; in this case, org-yank will decide about folding + kill-ring + (eq org-subtree-clip (current-kill 0)) + org-subtree-clip-folded) + ;; The tree was folded before it was killed/copied + (outline-hide-subtree)) (and for-yank (goto-char newend)) (and remove (setq kill-ring (cdr kill-ring)))))) @@ -8682,15 +8697,14 @@ called immediately, to move the markers with the entries." "Check if MARKER is between BEG and END. If yes, remember the marker and the distance to BEG." (when (and (marker-buffer marker) - (equal (marker-buffer marker) (current-buffer))) - (if (and (>= marker beg) (< marker end)) - (push (cons marker (- marker beg)) org-markers-to-move)))) + (equal (marker-buffer marker) (current-buffer)) + (>= marker beg) (< marker end)) + (push (cons marker (- marker beg)) org-markers-to-move))) (defun org-reinstall-markers-in-region (beg) "Move all remembered markers to their position relative to BEG." - (mapc (lambda (x) - (move-marker (car x) (+ beg (cdr x)))) - org-markers-to-move) + (dolist (x org-markers-to-move) + (move-marker (car x) (+ beg (cdr x)))) (setq org-markers-to-move nil)) (defun org-narrow-to-subtree () @@ -8702,7 +8716,7 @@ If yes, remember the marker and the distance to BEG." (narrow-to-region (progn (org-back-to-heading t) (point)) (progn (org-end-of-subtree t t) - (if (and (org-at-heading-p) (not (eobp))) (backward-char 1)) + (when (and (org-at-heading-p) (not (eobp))) (backward-char 1)) (point))))))) (defun org-narrow-to-block () @@ -8731,6 +8745,9 @@ stamps in the subtree shifted for each clone produced. If SHIFT is nil or the empty string, time stamps will be left alone. The ID property of the original subtree is removed. +In each clone, all the CLOCK entries will be removed. This +prevents Org from considering that the clocked times overlap. + If the original subtree did contain time stamps with a repeater, the following will happen: - the repeater will be removed in each clone @@ -8748,77 +8765,79 @@ subtree has a repeater. Setting N to 0, then, can be used to remove the repeater from a subtree and create a shifted clone with the original repeater." (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) - (org-clock-re (format "^[ \t]*%s.*$" org-clock-string)) - beg end template task idprop - shift-n shift-what doshift nmin nmax) - (unless (wholenump n) - (user-error "Invalid number of replications %s" n)) - (if (and (setq doshift (and (stringp shift) (string-match "\\S-" shift))) - (not (string-match "\\`[ \t]*\\+?\\([0-9]+\\)\\([hdwmy]\\)[ \t]*\\'" - shift))) - (user-error "Invalid shift specification %s" shift)) - (when doshift - (setq shift-n (string-to-number (match-string 1 shift)) - shift-what (cdr (assoc (match-string 2 shift) - '(("d" . day) ("w" . week) - ("m" . month) ("y" . year)))))) - (if (eq shift-what 'week) (setq shift-n (* 7 shift-n) shift-what 'day)) - (setq nmin 1 nmax n) - (org-back-to-heading t) - (setq beg (point)) - (setq idprop (org-entry-get nil "ID")) - (org-end-of-subtree t t) - (or (bolp) (insert "\n")) - (setq end (point)) - (setq template (buffer-substring beg end)) - (when (and doshift - (string-match "<[^<>\n]+ [.+]?\\+[0-9]+[hdwmy][^<>\n]*>" template)) - (delete-region beg end) - (setq end beg) - (setq nmin 0 nmax (1+ nmax) n-no-remove nmax)) - (goto-char end) - (loop for n from nmin to nmax do - ;; prepare clone - (with-temp-buffer - (insert template) - (org-mode) - (goto-char (point-min)) - (org-show-subtree) - (and idprop (if org-clone-delete-id - (org-entry-delete nil "ID") - (org-id-get-create t))) - (unless (= n 0) - (while (re-search-forward org-clock-re nil t) - (kill-whole-line)) - (goto-char (point-min)) - (while (re-search-forward drawer-re nil t) - (org-remove-empty-drawer-at (point)))) - (goto-char (point-min)) - (when doshift - (while (re-search-forward org-ts-regexp-both nil t) - (org-timestamp-change (* n shift-n) shift-what)) - (unless (= n n-no-remove) - (goto-char (point-min)) - (while (re-search-forward org-ts-regexp nil t) - (save-excursion - (goto-char (match-beginning 0)) - (if (looking-at "<[^<>\n]+\\( +[.+]?\\+[0-9]+[hdwmy]\\)") - (delete-region (match-beginning 1) (match-end 1))))))) - (setq task (buffer-string))) - (insert task)) + (unless (wholenump n) (user-error "Invalid number of replications %s" n)) + (when (org-before-first-heading-p) (user-error "No subtree to clone")) + (let* ((beg (save-excursion (org-back-to-heading t) (point))) + (end-of-tree (save-excursion (org-end-of-subtree t t) (point))) + (shift + (or shift + (if (and (not (equal current-prefix-arg '(4))) + (save-excursion + (goto-char beg) + (re-search-forward org-ts-regexp-both end-of-tree t))) + (read-from-minibuffer + "Date shift per clone (e.g. +1w, empty to copy unchanged): ") + ""))) ;No time shift + (doshift + (and (org-string-nw-p shift) + (or (string-match "\\`[ \t]*\\+?\\([0-9]+\\)\\([dwmy]\\)[ \t]*\\'" + shift) + (user-error "Invalid shift specification %s" shift))))) + (goto-char end-of-tree) + (unless (bolp) (insert "\n")) + (let* ((end (point)) + (template (buffer-substring beg end)) + (shift-n (and doshift (string-to-number (match-string 1 shift)))) + (shift-what (pcase (and doshift (match-string 2 shift)) + (`nil nil) + ("d" 'day) + ("w" (setq shift-n (* 7 shift-n)) 'day) + ("m" 'month) + ("y" 'year) + (_ (error "Unsupported time unit")))) + (nmin 1) + (nmax n) + (n-no-remove -1) + (idprop (org-entry-get nil "ID"))) + (when (and doshift + (string-match-p "<[^<>\n]+ [.+]?\\+[0-9]+[hdwmy][^<>\n]*>" + template)) + (delete-region beg end) + (setq end beg) + (setq nmin 0) + (setq nmax (1+ nmax)) + (setq n-no-remove nmax)) + (goto-char end) + (cl-loop for n from nmin to nmax do + (insert + ;; Prepare clone. + (with-temp-buffer + (insert template) + (org-mode) + (goto-char (point-min)) + (org-show-subtree) + (and idprop (if org-clone-delete-id + (org-entry-delete nil "ID") + (org-id-get-create t))) + (unless (= n 0) + (while (re-search-forward org-clock-line-re nil t) + (delete-region (line-beginning-position) + (line-beginning-position 2))) + (goto-char (point-min)) + (while (re-search-forward org-drawer-regexp nil t) + (org-remove-empty-drawer-at (point)))) + (goto-char (point-min)) + (when doshift + (while (re-search-forward org-ts-regexp-both nil t) + (org-timestamp-change (* n shift-n) shift-what)) + (unless (= n n-no-remove) + (goto-char (point-min)) + (while (re-search-forward org-ts-regexp nil t) + (save-excursion + (goto-char (match-beginning 0)) + (when (looking-at "<[^<>\n]+\\( +[.+]?\\+[0-9]+[hdwmy]\\)") + (delete-region (match-beginning 1) (match-end 1))))))) + (buffer-string))))) (goto-char beg))) ;;; Outline Sorting @@ -8834,18 +8853,14 @@ 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 invisible part of links and emphasis markers 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) + (replace-regexp-in-string + org-verbatim-re (lambda (m) (format "%s " (match-string 4 m))) + (replace-regexp-in-string + org-emph-re (lambda (m) (format " %s " (match-string 4 m))) + (org-link-display-format s) + t t) t t)) (defvar org-priority-regexp) ; defined later in the file @@ -8915,7 +8930,7 @@ When sorting is done, call `org-after-sorting-entries-or-items-hook'." (setq end (region-end) what "region") (goto-char (region-beginning)) - (if (not (org-at-heading-p)) (outline-next-heading)) + (unless (org-at-heading-p) (outline-next-heading)) (setq start (point))) ((or (org-at-heading-p) (ignore-errors (progn (org-back-to-heading) t))) @@ -8929,7 +8944,7 @@ When sorting is done, call `org-after-sorting-entries-or-items-hook'." (point)) what "children") (goto-char start) - (show-subtree) + (outline-show-subtree) (outline-next-heading)) (t ;; we will sort the top-level entries in this file @@ -8945,7 +8960,7 @@ When sorting is done, call `org-after-sorting-entries-or-items-hook'." (setq end (point-max)) (setq what "top-level") (goto-char start) - (show-all))) + (outline-show-all))) (setq beg (point)) (when (>= beg end) (goto-char start) (user-error "Nothing to sort")) @@ -8955,9 +8970,9 @@ When sorting is done, call `org-after-sorting-entries-or-items-hook'." re (concat "^" (regexp-quote stars) " +") re2 (concat "^" (regexp-quote (substring stars 0 -1)) "[ \t\n]") 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)) - (user-error "Region to sort contains a level above the first entry")) + (unless (equal (substring txt -1) "\n") (setq txt (concat txt "\n"))) + (when (and (not (equal stars "*")) (string-match re2 txt)) + (user-error "Region to sort contains a level above the first entry")) (unless sorting-type (message @@ -8970,16 +8985,16 @@ When sorting is done, call `org-after-sorting-entries-or-items-hook'." (unless getkey-func (and (= (downcase sorting-type) ?f) (setq getkey-func - (org-icompleting-read "Sort using function: " - obarray 'fboundp t nil nil)) + (completing-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)) - nil t)))) + (completing-read "Property: " + (mapcar #'list (org-buffer-property-keys t)) + nil t)))) (when (member sorting-type '(?k ?K)) (org-clock-sum)) (message "Sorting entries...") @@ -9023,24 +9038,24 @@ When sorting is done, call `org-after-sorting-entries-or-items-hook'." (if (or (re-search-forward org-ts-regexp end t) (re-search-forward org-ts-regexp-both end t)) (org-time-string-to-seconds (match-string 0)) - (org-float-time now)))) + (float-time now)))) ((= dcst ?c) (let ((end (save-excursion (outline-next-heading) (point)))) (if (re-search-forward (concat "^[ \t]*\\[" org-ts-regexp1 "\\]") end t) (org-time-string-to-seconds (match-string 0)) - (org-float-time now)))) + (float-time now)))) ((= dcst ?s) (let ((end (save-excursion (outline-next-heading) (point)))) (if (re-search-forward org-scheduled-time-regexp end t) (org-time-string-to-seconds (match-string 1)) - (org-float-time now)))) + (float-time now)))) ((= dcst ?d) (let ((end (save-excursion (outline-next-heading) (point)))) (if (re-search-forward org-deadline-time-regexp end t) (org-time-string-to-seconds (match-string 1)) - (org-float-time now)))) + (float-time now)))) ((= dcst ?p) (if (re-search-forward org-priority-regexp (point-at-eol) t) (string-to-char (match-string 2)) @@ -9048,15 +9063,15 @@ When sorting is done, call `org-after-sorting-entries-or-items-hook'." ((= dcst ?r) (or (org-entry-get nil property) "")) ((= dcst ?o) - (if (looking-at org-complex-heading-regexp) - (let* ((m (match-string 2)) - (s (if (member m org-done-keywords) '- '+))) - (- 99 (funcall s (length (member m org-todo-keywords-1))))))) + (when (looking-at org-complex-heading-regexp) + (let* ((m (match-string 2)) + (s (if (member m org-done-keywords) '- '+))) + (- 99 (funcall s (length (member m org-todo-keywords-1))))))) ((= dcst ?f) (if getkey-func (progn (setq tmp (funcall getkey-func)) - (if (stringp tmp) (setq tmp (funcall case-func tmp))) + (when (stringp tmp) (setq tmp (funcall case-func tmp))) tmp) (error "Invalid key function `%s'" getkey-func))) (t (error "Invalid sorting type `%c'" sorting-type)))) @@ -9077,15 +9092,15 @@ When sorting is done, call `org-after-sorting-entries-or-items-hook'." ;;; The orgstruct minor mode ;; Define a minor mode which can be used in other modes in order to -;; integrate the org-mode structure editing commands. +;; integrate the Org mode structure editing commands. -;; This is really a hack, because the org-mode structure commands use +;; This is really a hack, because the Org mode structure commands use ;; keys which normally belong to the major mode. Here is how it ;; works: The minor mode defines all the keys necessary to operate the ;; structure commands, but wraps the commands into a function which ;; tests if the cursor is currently at a headline or a plain list ;; item. If that is the case, the structure command is used, -;; temporarily setting many Org-mode variables like regular +;; temporarily setting many Org mode variables like regular ;; expressions for filling etc. However, when any of those keys is ;; used at a different location, function uses `key-binding' to look ;; up if the key has an associated command in another currently active @@ -9117,10 +9132,10 @@ orgstruct(++)-mode." ;;;###autoload (define-minor-mode orgstruct-mode "Toggle the minor mode `orgstruct-mode'. -This mode is for using Org-mode structure commands in other -modes. The following keys behave as if Org-mode were active, if +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)." +defined by Org mode)." nil " OrgStruct" (make-sparse-keymap) (funcall (if orgstruct-mode 'add-to-invisibility-spec @@ -9137,40 +9152,38 @@ defined by Org-mode)." "Unconditionally turn on `orgstruct-mode'." (orgstruct-mode 1)) -(defvar org-fb-vars nil) -(make-variable-buffer-local 'org-fb-vars) +(defvar-local orgstruct-is-++ nil + "Is `orgstruct-mode' in ++ version in the current-buffer?") +(defvar-local org-fb-vars nil) (defun orgstruct++-mode (&optional arg) "Toggle `orgstruct-mode', the enhanced version of it. In addition to setting orgstruct-mode, this also exports all -indentation and autofilling variables from org-mode into the +indentation and autofilling variables from Org mode into the buffer. It will also recognize item context in multiline items." (interactive "P") (setq arg (prefix-numeric-value (or arg (if orgstruct-mode -1 1)))) (if (< arg 1) (progn (orgstruct-mode -1) - (mapc (lambda(v) - (org-set-local (car v) - (if (eq (car-safe (cadr v)) 'quote) (cadadr v) (cadr v)))) - org-fb-vars)) + (dolist (v org-fb-vars) + (set (make-local-variable (car v)) + (if (eq (car-safe (cadr v)) 'quote) + (cl-cadadr v) + (nth 1 v))))) (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) - (when (string-match - "^\\(paragraph-\\|auto-fill\\|normal-auto-fill\\|fill-paragraph\\|fill-prefix\\|indent-\\)" - (symbol-name (car x))) - (setq var (car x) val (nth 1 x)) - (push (list var `(quote ,(eval var))) org-fb-vars) - (org-set-local var (if (eq (car-safe val) 'quote) (nth 1 val) val)))) - org-local-vars) - (org-set-local 'orgstruct-is-++ t)))) - -(defvar orgstruct-is-++ nil - "Is `orgstruct-mode' in ++ version in the current-buffer?") -(make-variable-buffer-local 'orgstruct-is-++) + (dolist (x org-local-vars) + (when (string-match + "^\\(paragraph-\\|auto-fill\\|normal-auto-fill\\|fill-paragraph\ +\\|fill-prefix\\|indent-\\)" + (symbol-name (car x))) + (setq var (car x) val (nth 1 x)) + (push (list var `(quote ,(eval var))) org-fb-vars) + (set (make-local-variable var) + (if (eq (car-safe val) 'quote) (nth 1 val) val)))) + (setq-local orgstruct-is-++ t)))) ;;;###autoload (defun turn-on-orgstruct++ () @@ -9199,6 +9212,7 @@ buffer. It will also recognize item context in multiline items." org-ctrl-c-minus org-ctrl-c-star org-cycle + org-force-cycle-archived org-forward-heading-same-level org-insert-heading org-insert-heading-respect-content @@ -9218,6 +9232,7 @@ buffer. It will also recognize item context in multiline items." org-shifttab org-shifttab org-shiftup + org-show-children org-show-subtree org-sort org-up-element @@ -9225,8 +9240,7 @@ buffer. It will also recognize item context in multiline items." outline-next-visible-heading outline-previous-visible-heading outline-promote - outline-up-heading - show-children)) + outline-up-heading)) (let ((f (or (car-safe cell) cell)) (disable-when-heading-prefix (cdr-safe cell))) (when (fboundp f) @@ -9245,7 +9259,7 @@ buffer. It will also recognize item context in multiline items." (regexp-quote (cdr rep)) (car rep) (key-description binding))))) - (pushnew binding new-bindings :test 'equal))) + (cl-pushnew binding new-bindings :test 'equal))) (dolist (binding new-bindings) (let ((key (lookup-key orgstruct-mode-map binding))) (when (or (not key) (numberp key)) @@ -9352,9 +9366,9 @@ definitions." ;; normalize contexts (mapcar (lambda(c) (cond ((listp (cadr c)) - (list (car c) (car c) (cadr c))) + (list (car c) (car c) (nth 1 c))) ((string= "" (cadr c)) - (list (car c) (car c) (caddr c))) + (list (car c) (car c) (nth 2 c))) (t c))) contexts)) (a alist) r s) @@ -9368,7 +9382,7 @@ definitions." (setq vrules (org-contextualize-validate-key (car c) contexts))) (mapc (lambda (vr) - (when (not (equal (car vr) (cadr vr))) + (unless (equal (car vr) (cadr vr)) (setq repl vr))) vrules) (if (not repl) (push c r) @@ -9385,39 +9399,37 @@ definitions." (delete-dups (mapcar (lambda (x) (let ((tpl (car x))) - (when (not (delq - nil - (mapcar (lambda (y) - (equal y tpl)) - s))) + (unless (delq + nil + (mapcar (lambda (y) + (equal y tpl)) + s)) x))) (reverse r)))))) (defun org-contextualize-validate-key (key contexts) "Check CONTEXTS for agenda or capture KEY." - (let (rr res) + (let (res) (dolist (r contexts) - (mapc - (lambda (rr) - (when - (and (equal key (car r)) - (if (functionp rr) (funcall rr) - (or (and (eq (car rr) 'in-file) - (buffer-file-name) - (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)))) - (when (eq (car rr) 'not-in-buffer) - (not (string-match (cdr rr) (buffer-name))))))) - (push r res))) - (car (last r)))) + (dolist (rr (car (last r))) + (when + (and (equal key (car r)) + (if (functionp rr) (funcall rr) + (or (and (eq (car rr) 'in-file) + (buffer-file-name) + (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)))) + (when (eq (car rr) 'not-in-buffer) + (not (string-match (cdr rr) (buffer-name))))))) + (push r res)))) (delete-dups (delq nil res)))) (defun org-context-p (&rest contexts) @@ -9435,45 +9447,47 @@ Possible values in the list of contexts are `table', `headline', and `item'." (org-in-item-p))) (goto-char pos)))) +(defconst org-unique-local-variables + '(org-element--cache + org-element--cache-objects + org-element--cache-sync-keys + org-element--cache-sync-requests + org-element--cache-sync-timer) + "List of local variables that cannot be transferred to another buffer.") + (defun org-get-local-variables () "Return a list of all local variables in an Org mode buffer." - (let (varlist) - (with-current-buffer (get-buffer-create "*Org tmp*") - (erase-buffer) - (org-mode) - (setq varlist (buffer-local-variables))) - (kill-buffer "*Org tmp*") - (delq nil - (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)))) + (delq nil + (mapcar + (lambda (x) + (let* ((binding (if (symbolp x) (list x) (list (car x) (cdr x)))) + (name (car binding))) + (and (not (get name 'org-state)) + (not (memq name org-unique-local-variables)) + (string-match-p + "\\`\\(org-\\|orgtbl-\\|outline-\\|comment-\\|paragraph-\\|\ +auto-fill\\|normal-auto-fill\\|fill-paragraph\\|indent-\\)" + (symbol-name name)) + binding))) + (with-temp-buffer + (org-mode) + (buffer-local-variables))))) (defun org-clone-local-variables (from-buffer &optional regexp) "Clone local variables from FROM-BUFFER. Optional argument REGEXP selects variables to clone." - (mapc - (lambda (pair) - (and (symbolp (car pair)) - (or (null regexp) - (string-match regexp (symbol-name (car pair)))) - (set (make-local-variable (car pair)) - (cdr pair)))) - (buffer-local-variables from-buffer))) + (dolist (pair (buffer-local-variables from-buffer)) + (let ((name (car pair))) + (when (and (symbolp name) + (not (memq name org-unique-local-variables)) + (or (null regexp) (string-match regexp (symbol-name name)))) + (set (make-local-variable name) (cdr pair)))))) ;;;###autoload (defun org-run-like-in-org-mode (cmd) - "Run a command, pretending that the current buffer is in Org-mode. + "Run a command, pretending that the current buffer is in Org mode. This will temporarily bind local variables that are typically bound in -Org-mode to the values they have in Org-mode, and then interactively +Org mode to the values they have in Org mode, and then interactively call CMD." (org-load-modules-maybe) (unless org-local-vars @@ -9490,7 +9504,7 @@ call CMD." (defun org-get-category (&optional pos force-refresh) "Get the category applying to position POS." (save-match-data - (if force-refresh (org-refresh-category-properties)) + (when force-refresh (org-refresh-category-properties)) (let ((pos (or pos (point)))) (or (get-text-property pos 'org-category) (progn (org-refresh-category-properties) @@ -9504,33 +9518,39 @@ DPROP is the drawer property and TPROP is either the corresponding text property to set, or an alist with each element being a text property (as a symbol) and a function to apply to the value of the drawer property." - (let ((case-fold-search t) - (inhibit-read-only t)) + (let* ((case-fold-search t) + (inhibit-read-only t) + (inherit? (org-property-inherit-p dprop)) + (property-re (org-re-property (concat (regexp-quote dprop) "\\+?") t)) + (global (and inherit? (org--property-global-value dprop nil)))) (org-with-silent-modifications - (save-excursion - (save-restriction - (widen) - (goto-char (point-min)) - (while (re-search-forward (concat "^[ \t]*:" dprop ": +\\(.*\\)[ \t]*$") nil t) - (org-refresh-property tprop (org-match-string-no-properties 1)))))))) - -(defun org-refresh-property (tprop p) + (org-with-point-at 1 + ;; Set global values (e.g., values defined through + ;; "#+PROPERTY:" keywords) to the whole buffer. + (when global (put-text-property (point-min) (point-max) tprop global)) + ;; Set local values. + (while (re-search-forward property-re nil t) + (when (org-at-property-p) + (org-refresh-property tprop (org-entry-get (point) dprop) inherit?)) + (outline-next-heading)))))) + +(defun org-refresh-property (tprop p &optional inherit) "Refresh the buffer text property TPROP from the drawer property P. -The refresh happens only for the current tree (not subtree)." +The refresh happens only for the current headline, or the whole +sub-tree if optional argument INHERIT is non-nil." (unless (org-before-first-heading-p) (save-excursion (org-back-to-heading t) - (if (symbolp tprop) - ;; TPROP is a text property symbol - (put-text-property - (point) (or (outline-next-heading) (point-max)) tprop p) - ;; TPROP is an alist with (properties . function) elements - (dolist (al tprop) - (save-excursion - (put-text-property - (line-beginning-position) (or (outline-next-heading) (point-max)) - (car al) - (funcall (cdr al) p)))))))) + (let ((start (point)) + (end (save-excursion + (if inherit (org-end-of-subtree t t) + (or (outline-next-heading) (point-max)))))) + (if (symbolp tprop) + ;; TPROP is a text property symbol. + (put-text-property start end tprop p) + ;; TPROP is an alist with (property . function) elements. + (pcase-dolist (`(,prop . ,f) tprop) + (put-text-property start end prop (funcall f p)))))))) (defun org-refresh-category-properties () "Refresh category text properties in the buffer." @@ -9564,7 +9584,7 @@ The refresh happens only for the current tree (not subtree)." (goto-char (point-min)) (let ((regexp (org-re-property "CATEGORY"))) (while (re-search-forward regexp nil t) - (let ((value (org-match-string-no-properties 3))) + (let ((value (match-string-no-properties 3))) (when (org-at-property-p) (put-text-property (save-excursion (org-back-to-heading t) (point)) @@ -9576,29 +9596,27 @@ The refresh happens only for the current tree (not subtree)." "Refresh stats text properties in the buffer." (let (stats) (org-with-silent-modifications - (save-excursion - (save-restriction - (widen) - (goto-char (point-min)) - (while (re-search-forward - (concat org-outline-regexp-bol ".*" - "\\(?:\\[\\([0-9]+\\)%\\|\\([0-9]+\\)/\\([0-9]+\\)\\]\\)") - nil t) - (setq stats (cond ((equal (match-string 3) "0") 0) - ((match-string 2) - (/ (* (string-to-number (match-string 2)) 100) - (string-to-number (match-string 3)))) - (t (string-to-number (match-string 1))))) - (org-back-to-heading t) - (put-text-property (point) (progn (org-end-of-subtree t t) (point)) - 'org-stats stats))))))) + (org-with-wide-buffer + (goto-char (point-min)) + (while (re-search-forward + (concat org-outline-regexp-bol ".*" + "\\(?:\\[\\([0-9]+\\)%\\|\\([0-9]+\\)/\\([0-9]+\\)\\]\\)") + nil t) + (setq stats (cond ((equal (match-string 3) "0") 0) + ((match-string 2) + (/ (* (string-to-number (match-string 2)) 100) + (string-to-number (match-string 3)))) + (t (string-to-number (match-string 1))))) + (org-back-to-heading t) + (put-text-property (point) (progn (org-end-of-subtree t t) (point)) + 'org-stats stats)))))) (defun org-refresh-effort-properties () "Refresh effort properties" (org-refresh-properties org-effort-property '((effort . identity) - (effort-minutes . org-duration-string-to-minutes)))) + (effort-minutes . org-duration-to-minutes)))) ;;;; Link Stuff @@ -9638,78 +9656,53 @@ The refresh happens only for the current tree (not subtree)." (defvar org-store-link-plist nil "Plist with info about the most recently link created with `org-store-link'.") -(defvar org-link-protocols nil - "Link protocols added to Org-mode using `org-add-link-type'.") +(defun org-store-link-functions () + "Return a list of functions that are called to create and store a link. +The functions defined in the :store property of +`org-link-parameters'. -(defvar org-store-link-functions nil - "List of functions that are called to create and store a link. Each function will be called in turn until one returns a non-nil -value. Each function should check if it is responsible for creating -this link (for example by looking at the major mode). -If not, it must exit and return nil. -If yes, it should return a non-nil value after a calling -`org-store-link-props' with a list of properties and values. -Special properties are: +value. Each function should check if it is responsible for +creating this link (for example by looking at the major mode). +If not, it must exit and return nil. If yes, it should return +a non-nil value after calling `org-store-link-props' with a list +of properties and values. Special properties are: :type The link prefix, like \"http\". This must be given. :link The link, like \"http://www.astro.uva.nl/~dominik\". This is obligatory as well. :description Optional default description for the second pair - of brackets in an Org-mode link. The user can still change - this when inserting this link into an Org-mode buffer. + of brackets in an Org mode link. The user can still change + this when inserting this link into an Org mode buffer. In addition to these, any additional properties can be specified -and then used in capture templates.") - -(defun org-add-link-type (type &optional follow export) - "Add TYPE to the list of `org-link-types'. -Re-compute all regular expressions depending on `org-link-types' - -FOLLOW and EXPORT are two functions. - -FOLLOW should take the link path as the single argument and do whatever -is necessary to follow the link, for example find a file or display -a mail message. - -EXPORT should format the link path for export to one of the export formats. -It should be a function accepting three arguments: - - path the path of the link, the text after the prefix (like \"http:\") - desc the description of the link, if any - format the export format, a symbol like `html' or `latex' or `ascii'. - -The function may use the FORMAT information to return different values -depending on the format. The return value will be put literally into -the exported file. If the return value is nil, this means Org should -do what it normally does with links which do not have EXPORT defined. - -Org mode has a built-in default for exporting links. If you are happy with -this default, there is no need to define an export function for the link -type. For a simple example of an export function, see `org-bbdb.el'." - (add-to-list 'org-link-types type t) - (org-make-link-regexps) - (org-element-update-syntax) - (if (assoc type org-link-protocols) - (setcdr (assoc type org-link-protocols) (list follow export)) - (push (list type follow export) org-link-protocols))) +and then used in capture templates." + (cl-loop for link in org-link-parameters + with store-func + do (setq store-func (org-link-get-parameter (car link) :store)) + if store-func + collect store-func)) (defvar org-agenda-buffer-name) ; Defined in org-agenda.el (defvar org-id-link-to-org-use-id) ; Defined in org-id.el ;;;###autoload (defun org-store-link (arg) - "\\Store an org-link to the current location. + "Store an org-link to the current location. +\\ This link is added to `org-stored-links' and can later be inserted -into an Org buffer with \\[org-insert-link]. +into an Org buffer with `org-insert-link' (`\\[org-insert-link]'). -For some link types, a prefix ARG is interpreted. +For some link types, a `\\[universal-argument]' 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'. -A double prefix ARG force skipping storing functions that are not -part of Org's core. +A `\\[universal-argument] \\[universal-argument]' prefix ARG forces \ +skipping storing functions that are not +part of Org core. -A triple prefix ARG force storing a link for each line in the +A `\\[universal-argument] \\[universal-argument] \\[universal-argument]' \ +prefix ARG forces storing a link for each line in the active region." (interactive "P") (org-load-modules-maybe) @@ -9724,118 +9717,111 @@ active region." (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 + (setq org-store-link-plist nil) + (let (link cpltxt desc description search + txt custom-id agenda-link sfuns sfunsn) + (cond - ;; 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 nil 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) - (cond - ((save-excursion - (beginning-of-line) - (looking-at (concat (format org-coderef-label-format "\\(.*?\\)") - "[ \t]*$"))) - (setq link (format "(%s)" (org-match-string-no-properties 1)))) - ((org-called-interactively-p 'any) - (let (label) - (while (or (not label) - (org-with-wide-buffer - (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) - (setq link (format org-coderef-label-format label)) - (let ((gc (- 79 (length link)))) - (if (< (current-column) gc) (org-move-to-column gc t) - (insert " "))) - (insert link) - (setq link (concat "(" label ")") desc nil))) - (t (setq link 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 - ((derived-mode-p '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)) + ;; 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 nil 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 ((coderef-format (org-src-coderef-format))) + (cond ((save-excursion + (beginning-of-line) + (looking-at (org-src-coderef-regexp coderef-format))) + (setq link (format "(%s)" (match-string-no-properties 3)))) + ((called-interactively-p 'any) + (let ((label (read-string "Code line label: "))) + (end-of-line) + (setq link (format coderef-format label)) + (let ((gc (- 79 (length link)))) + (if (< (current-column) gc) + (org-move-to-column gc t) + (insert " "))) + (insert link) + (setq link (concat "(" label ")")) + (setq desc nil))) + (t (setq link nil))))) + + ;; We are in the agenda, link to referenced location + ((equal (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 (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 + ((derived-mode-p '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)) + (org-with-limited-levels (setq custom-id (org-entry-get nil "CUSTOM_ID")) (cond ;; Store a link using the target at point @@ -9848,7 +9834,7 @@ active region." link cpltxt)) ((and (featurep 'org-id) (or (eq org-id-link-to-org-use-id t) - (and (org-called-interactively-p 'any) + (and (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) @@ -9872,14 +9858,11 @@ active region." (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)))) + (let* ((element (org-element-at-point)) + (name (org-element-property :name element))) (setq txt (cond ((org-at-heading-p) nil) - ((and (eq et 'keyword) eok) ev) + (name) ((org-region-active-p) (buffer-substring (region-beginning) (region-end))))) (when (or (null txt) (string-match "\\S-" txt)) @@ -9888,74 +9871,79 @@ active region." (condition-case nil (org-make-org-heading-search-string txt) (error ""))) - desc (or (and (eq et 'keyword) eok ev) + desc (or name (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) - (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)) - ((and desc (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)) - (car org-stored-links)))))) + (when (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)) + + ((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 + (when (consp link) (setq cpltxt (car link) link (cdr link))) + (setq link (or link cpltxt) + desc (or desc cpltxt)) + (cond ((not desc)) + ((equal desc "NONE") (setq desc nil)) + (t (setq desc + (replace-regexp-in-string + org-bracket-link-analytic-regexp + (lambda (m) (or (match-string 5 m) (match-string 3 m))) + desc)))) + ;; Return the link + (if (not (and (or (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)) + (car org-stored-links))))) (defun org-store-link-props (&rest plist) - "Store link properties, extract names and addresses." - (let (x adr) - (when (setq x (plist-get plist :from)) - (setq adr (mail-extract-address-components x)) - (setq plist (plist-put plist :fromname (car adr))) - (setq plist (plist-put plist :fromaddress (nth 1 adr)))) - (when (setq x (plist-get plist :to)) - (setq adr (mail-extract-address-components x)) - (setq plist (plist-put plist :toname (car adr))) - (setq plist (plist-put plist :toaddress (nth 1 adr))))) + "Store link properties, extract names, addresses and dates." + (let ((x (plist-get plist :from))) + (when x + (let ((adr (mail-extract-address-components x))) + (setq plist (plist-put plist :fromname (car adr))) + (setq plist (plist-put plist :fromaddress (nth 1 adr)))))) + (let ((x (plist-get plist :to))) + (when x + (let ((adr (mail-extract-address-components x))) + (setq plist (plist-put plist :toname (car adr))) + (setq plist (plist-put plist :toaddress (nth 1 adr)))))) + (let ((x (ignore-errors (date-to-time (plist-get plist :date))))) + (when x + (setq plist (plist-put plist :date-timestamp + (format-time-string + (org-time-stamp-format t) x))) + (setq plist (plist-put plist :date-timestamp-inactive + (format-time-string + (org-time-stamp-format t t) x))))) (let ((from (plist-get plist :from)) (to (plist-get plist :to))) (when (and from to org-from-is-user-regexp) @@ -10030,7 +10018,7 @@ according to FMT (default from `org-email-link-description-format')." ;; square brackets). File links however, are ;; encoded since, e.g., spaces are significant. ((or (file-name-absolute-p link) - (org-string-match-p "\\`\\.\\.?/\\|[][]" link)) + (string-match-p "\\`\\.\\.?/\\|[][]" link)) (org-link-escape link)) (t link))) (description @@ -10049,15 +10037,6 @@ according to FMT (default from `org-email-link-description-format')." "List of characters that should be escaped in a link when stored to Org. This is the list that is used for internal purposes.") -(defconst org-link-escape-chars-browser - ;;%20 %22 - '(?\s ?\") - "List of characters to be escaped before handing over to the browser. -If you consider using this constant then you probably want to use -the function `org-link-escape-browser' instead. See there why -this constant is a candidate to be removed once Org drops support -for Emacs 24.1 and 24.2.") - (defun org-link-escape (text &optional table merge) "Return percent escaped representation of TEXT. TEXT is a string with the text to escape. @@ -10080,29 +10059,6 @@ If optional argument MERGE is set, merge TABLE into (char-to-string c))) text ""))) -(defun org-link-escape-browser (text) - "Escape some characters before handing over to the browser. -This function is a candidate to be removed together with the -constant `org-link-escape-chars-browser' once Org drops support -for Emacs 24.1 and 24.2. All calls to this function will have to -be replaced with `url-encode-url' which is available since Emacs -24.3.1." - ;; Example with the Org link - ;; [[http://lists.gnu.org/archive/cgi-bin/namazu.cgi?idxname=emacs-orgmode&query=%252Bsubject:"Release+8.2"]] - ;; to open the browser with +subject:"Release 8.2" filled into the - ;; query field: In this case the variable TEXT contains the - ;; unescaped [...]=%2Bsubject:"Release+8.2". Then `url-encode-url' - ;; converts correctly to [...]=%2Bsubject:%22Release+8.2%22 or - ;; `org-link-escape' with `org-link-escape-chars-browser' converts - ;; wrongly to [...]=%252Bsubject:%22Release+8.2%22. - (if (fboundp 'url-encode-url) - (url-encode-url text) - (if (org-string-match-p - (concat "[[:nonascii:]" org-link-escape-chars-browser "]") - text) - (org-link-escape text org-link-escape-chars-browser) - text))) - (defun org-link-unescape (str) "Unhex hexified Unicode parts in string STR. E.g. `%C3%B6' becomes the german o-Umlaut. This is the @@ -10133,13 +10089,13 @@ Note: this function also decodes single byte encodings like ((>= val 192) (cons 2 192)) (t (cons 0 0))) (cons 6 128)))) - (if (>= val 192) (setq eat (car shift-xor))) + (when (>= val 192) (setq eat (car shift-xor))) (setq val (logxor val (cdr shift-xor))) (setq sum (+ (lsh sum (car shift-xor)) val)) - (if (> eat 0) (setq eat (- eat 1))) + (when (> eat 0) (setq eat (- eat 1))) (cond ((= 0 eat) ;multi byte - (setq ret (concat ret (org-char-to-string sum))) + (setq ret (concat ret (char-to-string sum))) (setq sum 0)) ((not bytes) ; single byte(s) (setq ret (org-link-unescape-single-byte-sequence hex)))))) @@ -10181,8 +10137,8 @@ The cdr of LINK must be either a link description or nil." ;;;###autoload (defun org-insert-link-global () - "Insert a link like Org-mode does. -This command can be called in any mode to insert a link in Org-mode syntax." + "Insert a link like Org mode does. +This command can be called in any mode to insert a link in Org syntax." (interactive) (org-load-modules-maybe) (org-run-like-in-org-mode 'org-insert-link)) @@ -10195,7 +10151,7 @@ When `ARG' is a number, insert the last N link(s). prepend or to append." (interactive "P") (let ((org-keep-stored-link-after-insertion (equal arg '(4))) - (links (copy-seq org-stored-links)) + (links (copy-sequence org-stored-links)) (pr (or pre "- ")) (po (or post "\n")) (cnt 1) l) @@ -10237,73 +10193,73 @@ prepend or to append." (put-text-property 0 (length l) 'face 'font-lock-comment-face l)) (delq nil (append a b))))) -(defvar org-link-links-in-this-file nil) +(defvar org--links-history nil) (defun org-insert-link (&optional complete-file link-location default-description) "Insert a link. At the prompt, enter the link. -Completion can be used to insert any of the link protocol prefixes like -http or ftp in use. +Completion can be used to insert any of the link protocol prefixes in use. The history can be used to select a link previously stored with `org-store-link'. When the empty string is entered (i.e. if you just -press RET at the prompt), the link defaults to the most recently -stored link. As SPC triggers completion in the minibuffer, you need to -use M-SPC or C-q SPC to force the insertion of a space character. +press `RET' at the prompt), the link defaults to the most recently +stored link. As `SPC' triggers completion in the minibuffer, you need to +use `M-SPC' or `C-q SPC' to force the insertion of a space character. You will also be prompted for a description, and if one is given, it will be displayed in the buffer instead of the link. -If there is already a link at point, this command will allow you to edit link -and description parts. +If there is already a link at point, this command will allow you to edit +link and description parts. -With a \\[universal-argument] prefix, prompts for a file to link to. The file name can -be selected using completion. The path to the file will be relative to the +With a `\\[universal-argument]' prefix, prompts for a file to link to. The \ +file name can be +selected using completion. The path to the file will be relative to the current directory if the file is in the current directory or a subdirectory. Otherwise, the link will be the absolute path as completed in the minibuffer \(i.e. normally ~/path/to/file). You can configure this behavior using the option `org-link-file-path-type'. -With two \\[universal-argument] prefixes, enforce an absolute path even if the file is in +With a `\\[universal-argument] \\[universal-argument]' prefix, enforce an \ +absolute path even if the file is in the current directory or below. -With three \\[universal-argument] prefixes, negate the meaning of -`org-keep-stored-link-after-insertion'. +A `\\[universal-argument] \\[universal-argument] \\[universal-argument]' \ +prefix negates `org-keep-stored-link-after-insertion'. If `org-make-link-description-function' is non-nil, this function will be called with the link target, and the result will be the default link description. -If the LINK-LOCATION parameter is non-nil, this value will be -used as the link location instead of reading one interactively. +If the LINK-LOCATION parameter is non-nil, this value will be used as +the link location instead of reading one interactively. -If the DEFAULT-DESCRIPTION parameter is non-nil, this value will -be used as the default description." +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)))) + (region (when (org-region-active-p) + (buffer-substring (region-beginning) (region-end)))) (remove (and region (list (region-beginning) (region-end)))) (desc region) - tmphist ; byte-compile incorrectly complains about this (link link-location) (abbrevs org-link-abbrev-alist-local) - entry file all-prefixes auto-desc) + entry all-prefixes auto-desc) (cond - (link-location) ; specified by arg, just use it. + (link-location) ; specified by arg, just use it. ((org-in-regexp org-bracket-link-regexp 1) ;; We do have a link at point, and we are going to edit it. (setq remove (list (match-beginning 0) (match-end 0))) - (setq desc (if (match-end 3) (org-match-string-no-properties 3))) + (setq desc (when (match-end 3) (match-string-no-properties 3))) (setq link (read-string "Link: " (org-link-unescape - (org-match-string-no-properties 1))))) + (match-string-no-properties 1))))) ((or (org-in-regexp org-angle-link-re) (org-in-regexp org-plain-link-re)) ;; Convert to bracket link (setq remove (list (match-beginning 0) (match-end 0)) link (read-string "Link: " - (org-remove-angle-brackets (match-string 0))))) + (org-unbracket-string "<" ">" (match-string 0))))) ((member complete-file '((4) (16))) ;; Completing read for file names. (setq link (org-file-complete-link complete-file))) @@ -10326,92 +10282,91 @@ Use TAB to complete link prefixes, then RET for type-specific completion support (unless (pos-visible-in-window-p (point-max)) (org-fit-window-to-buffer)) (and (window-live-p cw) (select-window cw))) - ;; Fake a link history, containing the stored links. - (setq tmphist (append (mapcar 'car org-stored-links) - org-insert-link-history)) (setq all-prefixes (append (mapcar 'car abbrevs) (mapcar 'car org-link-abbrev-alist) - org-link-types)) + (org-link-types))) (unwind-protect - (progn + ;; Fake a link history, containing the stored links. + (let ((org--links-history + (append (mapcar #'car org-stored-links) + org-insert-link-history))) (setq link (org-completing-read "Link: " (append - (mapcar (lambda (x) (concat x ":")) - all-prefixes) - (mapcar 'car org-stored-links)) + (mapcar (lambda (x) (concat x ":")) all-prefixes) + (mapcar #'car org-stored-links)) nil nil nil - 'tmphist + 'org--links-history (caar org-stored-links))) - (if (not (string-match "\\S-" link)) - (user-error "No link selected")) - (mapc (lambda(l) - (when (equal link (cadr l)) (setq link (car l) auto-desc t))) - org-stored-links) - (if (or (member link all-prefixes) - (and (equal ":" (substring link -1)) - (member (substring link 0 -1) all-prefixes) - (setq link (substring link 0 -1)))) - (setq link (with-current-buffer origbuf - (org-link-try-special-completion link))))) + (unless (org-string-nw-p link) (user-error "No link selected")) + (dolist (l org-stored-links) + (when (equal link (cadr l)) + (setq link (car l)) + (setq auto-desc t))) + (when (or (member link all-prefixes) + (and (equal ":" (substring link -1)) + (member (substring link 0 -1) all-prefixes) + (setq link (substring link 0 -1)))) + (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)) (or entry (push link org-insert-link-history)) (setq desc (or desc (nth 1 entry))))) - (if (funcall (if (equal complete-file '(64)) 'not 'identity) - (not org-keep-stored-link-after-insertion)) - (setq org-stored-links (delq (assoc link org-stored-links) - org-stored-links))) + (when (funcall (if (equal complete-file '(64)) 'not 'identity) + (not org-keep-stored-link-after-insertion)) + (setq org-stored-links (delq (assoc link org-stored-links) + org-stored-links))) - (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))) + (when (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-unbracket-string "<" ">" link))) ;; Check if we are linking to the current file with a search ;; option If yes, simplify the link by using only the search ;; option. (when (and buffer-file-name - (string-match "^file:\\(.+?\\)::\\(.+\\)" link)) - (let* ((path (match-string 1 link)) - (case-fold-search nil) - (search (match-string 2 link))) + (let ((case-fold-search nil)) + (string-match "\\`file:\\(.+?\\)::" link))) + (let ((path (match-string-no-properties 1 link)) + (search (substring-no-properties link (match-end 0)))) (save-match-data - (if (equal (file-truename buffer-file-name) (file-truename path)) - ;; We are linking to this same file, with a search option - (setq link search))))) + (when (equal (file-truename buffer-file-name) (file-truename path)) + ;; We are linking to this same file, with a search option + (setq link search))))) ;; Check if we can/should use a relative path. If yes, simplify the link - (when (string-match "^\\(file:\\|docview:\\)\\(.*\\)" link) - (let* ((type (match-string 1 link)) - (path (match-string 2 link)) - (origpath path) - (case-fold-search nil)) - (cond - ((or (eq org-link-file-path-type 'absolute) - (equal complete-file '(16))) - (setq path (abbreviate-file-name (expand-file-name path)))) - ((eq org-link-file-path-type 'noabbrev) - (setq path (expand-file-name path))) - ((eq org-link-file-path-type 'relative) - (setq path (file-relative-name path))) - (t - (save-match-data - (if (string-match (concat "^" (regexp-quote - (expand-file-name - (file-name-as-directory - default-directory)))) - (expand-file-name path)) - ;; We are linking a file with relative path name. - (setq path (substring (expand-file-name path) - (match-end 0))) - (setq path (abbreviate-file-name (expand-file-name path))))))) - (setq link (concat type path)) - (if (equal desc origpath) - (setq desc path)))) + (let ((case-fold-search nil)) + (when (string-match "\\`\\(file:\\|docview\\):" link) + (let ((type (match-string-no-properties 0 link)) + (path (substring-no-properties link (match-end 0))) + (origpath path)) + (cond + ((or (eq org-link-file-path-type 'absolute) + (equal complete-file '(16))) + (setq path (abbreviate-file-name (expand-file-name path)))) + ((eq org-link-file-path-type 'noabbrev) + (setq path (expand-file-name path))) + ((eq org-link-file-path-type 'relative) + (setq path (file-relative-name path))) + (t + (save-match-data + (if (string-match (concat "^" (regexp-quote + (expand-file-name + (file-name-as-directory + default-directory)))) + (expand-file-name path)) + ;; We are linking a file with relative path name. + (setq path (substring (expand-file-name path) + (match-end 0))) + (setq path (abbreviate-file-name (expand-file-name path))))))) + (setq link (concat type path)) + (when (equal desc origpath) + (setq desc path))))) (if org-make-link-description-function (setq desc @@ -10426,19 +10381,21 @@ Use TAB to complete link prefixes, then RET for type-specific completion support (read-string "Description: " desc))))) (unless (string-match "\\S-" desc) (setq desc nil)) - (if remove (apply 'delete-region remove)) - (insert (org-make-link-string link desc)))) + (when remove (apply 'delete-region remove)) + (insert (org-make-link-string link desc)) + ;; Redisplay so as the new link has proper invisible characters. + (sit-for 0))) (defun org-link-try-special-completion (type) "If there is completion support for link type TYPE, offer it." - (let ((fun (intern (concat "org-" type "-complete-link")))) + (let ((fun (org-link-get-parameter type :complete))) (if (functionp fun) (funcall fun) (read-string "Link (no completion support): " (concat type ":"))))) (defun org-file-complete-link (&optional arg) "Create a file link using completion." - (let ((file (org-iread-file-name "File: ")) + (let ((file (read-file-name "File: ")) (pwd (file-name-as-directory (expand-file-name "."))) (pwd1 (file-name-as-directory (abbreviate-file-name (expand-file-name "."))))) @@ -10455,19 +10412,6 @@ Use TAB to complete link prefixes, then RET for type-specific completion support (match-string 1 (expand-file-name file)))) (t (concat "file:" file))))) -(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) - (org-bound-and-true-p ido-mode) - (listp (nth 1 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) @@ -10475,42 +10419,9 @@ See `read-file-name' for a description of parameters." (copy-keymap minibuffer-local-completion-map))) (org-defkey minibuffer-local-completion-map " " 'self-insert-command) (org-defkey minibuffer-local-completion-map "?" 'self-insert-command) - (org-defkey minibuffer-local-completion-map (kbd "C-c !") 'org-time-stamp-inactive) - (apply 'org-icompleting-read args))) - -(defun org-completing-read-no-i (&rest args) - (let (org-completion-use-ido org-completion-use-iswitchb) - (apply 'org-completing-read args))) - -(defun org-iswitchb-completing-read (prompt choices &rest args) - "Use iswitch as a completing-read replacement to choose from choices. -PROMPT is a string to prompt with. CHOICES is a list of strings to choose -from." - (let* ((iswitchb-use-virtual-buffers nil) - (iswitchb-make-buflist-hook - (lambda () - (setq iswitchb-temp-buflist choices)))) - (iswitchb-read-buffer prompt))) - -(defun org-icompleting-read (&rest args) - "Completing-read using `ido-mode' or `iswitchb' speedups if available. -Should be called like `completing-read'." - (org-without-partial-completion - (if (not (listp (nth 1 args))) - ;; Ido only supports lists as the COLLECTION argument. Use - ;; default completion function when second argument is not - ;; a list. - (apply #'completing-read args) - (let ((ido-enter-matching-directory nil)) - (apply (cond ((and org-completion-use-ido - (fboundp 'ido-completing-read) - (org-bound-and-true-p ido-mode)) - #'ido-completing-read) - ((and org-completion-use-iswitchb - (org-bound-and-true-p iswitchb-mode)) - #'org-iswitchb-completing-read) - (t #'completing-read)) - args))))) + (org-defkey minibuffer-local-completion-map (kbd "C-c !") + 'org-time-stamp-inactive) + (apply #'completing-read args))) ;;; Opening/following a link @@ -10530,8 +10441,8 @@ handle this as a special case. When the function does handle the link, it must return a non-nil value. 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.") +nil to indicate that that Org can continue with other options like +exact and fuzzy text search.") (defun org-next-link (&optional search-backward) "Move forward to the next link. @@ -10543,7 +10454,7 @@ If the link is in hidden text, expose it." (setq org-link-search-failed nil) (let* ((pos (point)) (ct (org-context)) - (a (assoc :link ct)) + (a (assq :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) @@ -10552,7 +10463,7 @@ If the link is in hidden text, expose it." (if (funcall srch-fun org-any-link-re nil t) (progn (goto-char (match-beginning 0)) - (if (outline-invisible-p) (org-show-context))) + (when (outline-invisible-p) (org-show-context))) (goto-char pos) (setq org-link-search-failed t) (message "No further link found")))) @@ -10587,7 +10498,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-unbracket-string "<" ">" (match-string 2 path)))))) (cons type path)) (defun org-find-file-at-mouse (ev) @@ -10601,8 +10512,8 @@ This is still an experimental function, your mileage may vary." See the docstring of `org-open-file' for details." (interactive "e") (mouse-set-point ev) - (if (eq major-mode 'org-agenda-mode) - (org-agenda-copy-local-variable 'org-link-abbrev-alist-local)) + (when (eq major-mode 'org-agenda-mode) + (org-agenda-copy-local-variable 'org-link-abbrev-alist-local)) (org-open-at-point)) (defvar org-window-config-before-follow-link nil @@ -10611,15 +10522,22 @@ This is saved in case the need arises to restore it.") ;;;###autoload (defun org-open-at-point-global () - "Follow a link like Org-mode does. -This command can be called in any mode to follow a link that has -Org-mode syntax." + "Follow a link or time-stamp like Org mode does. +This command can be called in any mode to follow an external link +or a time-stamp that has Org mode syntax. Its behavior is +undefined when called on internal links (e.g., fuzzy links). +Raise an error when there is nothing to follow. " (interactive) - (org-run-like-in-org-mode 'org-open-at-point)) + (cond ((org-in-regexp org-any-link-re) + (org-open-link-from-string (match-string-no-properties 0))) + ((or (org-in-regexp org-ts-regexp-both nil t) + (org-in-regexp org-tsr-regexp-both nil t)) + (org-follow-timestamp-link)) + (t (user-error "No link found")))) ;;;###autoload (defun org-open-link-from-string (s &optional arg reference-buffer) - "Open a link in the string S, as if it was in Org-mode." + "Open a link in the string S, as if it was in Org mode." (interactive "sLink: \nP") (let ((reference-buffer (or reference-buffer (current-buffer)))) (with-temp-buffer @@ -10640,8 +10558,61 @@ 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 +(defvar org-link-search-inhibit-query nil) +(defvar clean-buffer-list-kill-buffer-names) ;Defined in midnight.el +(defun org--open-doi-link (path) + "Open a \"doi\" type link. +PATH is a the path to search for, as a string." + (browse-url (url-encode-url (concat org-doi-server-url path)))) + +(defun org--open-elisp-link (path) + "Open a \"elisp\" type link. +PATH is the sexp to evaluate, as a string." + (let ((cmd path)) + (if (or (and (org-string-nw-p + org-confirm-elisp-link-not-regexp) + (string-match-p org-confirm-elisp-link-not-regexp cmd)) + (not org-confirm-elisp-link-function) + (funcall org-confirm-elisp-link-function + (format "Execute \"%s\" as elisp? " + (org-add-props cmd nil 'face 'org-warning)))) + (message "%s => %s" cmd + (if (eq (string-to-char cmd) ?\() + (eval (read cmd)) + (call-interactively (read cmd)))) + (user-error "Abort")))) + +(defun org--open-help-link (path) + "Open a \"help\" type link. +PATH is a symbol name, as a string." + (pcase (intern path) + ((and (pred fboundp) variable) (describe-function variable)) + ((and (pred boundp) function) (describe-variable function)) + (name (user-error "Unknown function or variable: %s" name)))) + +(defun org--open-shell-link (path) + "Open a \"shell\" type link. +PATH is the command to execute, as a string." + (let ((buf (generate-new-buffer "*Org Shell Output*")) + (cmd path)) + (if (or (and (org-string-nw-p + org-confirm-shell-link-not-regexp) + (string-match + org-confirm-shell-link-not-regexp cmd)) + (not org-confirm-shell-link-function) + (funcall org-confirm-shell-link-function + (format "Execute \"%s\" in shell? " + (org-add-props cmd nil + 'face 'org-warning)))) + (progn + (message "Executing %s" cmd) + (shell-command cmd buf) + (when (featurep 'midnight) + (setq clean-buffer-list-kill-buffer-names + (cons (buffer-name buf) + clean-buffer-list-kill-buffer-names)))) + (user-error "Abort")))) + (defun org-open-at-point (&optional arg reference-buffer) "Open link, timestamp, footnote or tags at point. @@ -10692,19 +10663,17 @@ link in a property drawer line." ;; Exception: open timestamps and links in properties ;; drawers, keywords and comments. ((memq type '(comment comment-block keyword node-property)) - (cond ((org-in-regexp org-any-link-re) - (org-open-link-from-string (match-string-no-properties 0))) - ((or (org-at-timestamp-p t) (org-at-date-range-p t)) - (org-follow-timestamp-link)) - (t (user-error "No link found")))) + (call-interactively #'org-open-at-point-global)) ;; On a headline or an inlinetask, but not on a timestamp, ;; a link, a footnote reference or on tags. ((and (memq type '(headline inlinetask)) ;; Not on tags. - (progn (save-excursion (beginning-of-line) - (looking-at org-complex-heading-regexp)) - (or (not (match-beginning 5)) - (< (point) (match-beginning 5))))) + (let ((case-fold-search nil)) + (save-excursion + (beginning-of-line) + (looking-at org-complex-heading-regexp)) + (or (not (match-beginning 5)) + (< (point) (match-beginning 5))))) (let* ((data (org-offer-links-in-entry (current-buffer) (point) arg)) (links (car data)) (links-end (cdr data))) @@ -10722,30 +10691,25 @@ link in a property drawer line." (>= (point) (org-element-property :begin value)) (<= (point) (org-element-property :end value))) (org-follow-timestamp-link)) - ;; Do nothing on white spaces after an object, unless point - ;; is right after it. - ((> (point) - (save-excursion - (goto-char (org-element-property :end context)) - (skip-chars-backward " \t") - (point))) + ;; Do nothing on white spaces after an object. + ((>= (point) + (save-excursion + (goto-char (org-element-property :end context)) + (skip-chars-backward " \t") + (point))) (user-error "No link found")) ((eq type 'timestamp) (org-follow-timestamp-link)) ;; On tags within a headline or an inlinetask. ((and (memq type '(headline inlinetask)) - (progn (save-excursion (beginning-of-line) - (looking-at org-complex-heading-regexp)) - (and (match-beginning 5) - (>= (point) (match-beginning 5))))) + (let ((case-fold-search nil)) + (save-excursion (beginning-of-line) + (looking-at org-complex-heading-regexp)) + (and (match-beginning 5) + (>= (point) (match-beginning 5))))) (org-tags-view arg (substring (match-string 5) 0 -1))) ((eq type 'link) - ;; When link is located within the description of another - ;; link (e.g., an inline image), always open the parent - ;; link. - (let*((link (let ((up (org-element-property :parent context))) - (if (eq (org-element-type up) 'link) up context))) - (type (org-element-property :type link)) - (path (org-link-unescape (org-element-property :path link)))) + (let ((type (org-element-property :type context)) + (path (org-link-unescape (org-element-property :path context)))) ;; Switch back to REFERENCE-BUFFER needed when called in ;; a temporary buffer through `org-open-link-from-string'. (with-current-buffer (or reference-buffer (current-buffer)) @@ -10753,21 +10717,19 @@ link in a property drawer line." ((equal type "file") (if (string-match "[*?{]" (file-name-nondirectory path)) (dired path) - ;; Look into `org-link-protocols' in order to find + ;; Look into `org-link-parameters' in order to find ;; a DEDICATED-FUNCTION to open file. The function ;; will be applied on raw link instead of parsed ;; link due to the limitation in `org-add-link-type' ;; ("open" function called with a single argument). ;; If no such function is found, fallback to ;; `org-open-file'. - ;; - ;; Note : "file+emacs" and "file+sys" types are - ;; hard-coded in order to escape the previous - ;; limitation. - (let* ((option (org-element-property :search-option link)) - (app (org-element-property :application link)) + (let* ((option (org-element-property :search-option context)) + (app (org-element-property :application context)) (dedicated-function - (nth 1 (assoc app org-link-protocols)))) + (org-link-get-parameter + (if app (concat type "+" app) type) + :follow))) (if dedicated-function (funcall dedicated-function (concat path @@ -10778,62 +10740,12 @@ link in a property drawer line." ((equal app "emacs") 'emacs) ((equal app "sys") 'system)) (cond ((not option) nil) - ((org-string-match-p "\\`[0-9]+\\'" option) + ((string-match-p "\\`[0-9]+\\'" option) (list (string-to-number option))) (t (list nil (org-link-unescape option))))))))) - ((assoc type org-link-protocols) - (funcall (nth 1 (assoc type org-link-protocols)) path)) - ((equal type "help") - (let ((f-or-v (intern path))) - (cond ((fboundp f-or-v) (describe-function f-or-v)) - ((boundp f-or-v) (describe-variable f-or-v)) - (t (error "Not a known function or variable"))))) - ((member type '("http" "https" "ftp" "mailto" "news")) - (browse-url (org-link-escape-browser (concat type ":" path)))) - ((equal type "doi") - (browse-url - (org-link-escape-browser (concat org-doi-server-url path)))) - ((equal type "message") (browse-url (concat type ":" path))) - ((equal type "shell") - (let ((buf (generate-new-buffer "*Org Shell Output*")) - (cmd path)) - (if (or (and (org-string-nw-p - org-confirm-shell-link-not-regexp) - (string-match - org-confirm-shell-link-not-regexp cmd)) - (not org-confirm-shell-link-function) - (funcall org-confirm-shell-link-function - (format "Execute \"%s\" in shell? " - (org-add-props cmd nil - 'face 'org-warning)))) - (progn - (message "Executing %s" cmd) - (shell-command cmd buf) - (when (featurep 'midnight) - (setq clean-buffer-list-kill-buffer-names - (cons (buffer-name buf) - clean-buffer-list-kill-buffer-names)))) - (user-error "Abort")))) - ((equal type "elisp") - (let ((cmd path)) - (if (or (and (org-string-nw-p - org-confirm-elisp-link-not-regexp) - (org-string-match-p - org-confirm-elisp-link-not-regexp cmd)) - (not org-confirm-elisp-link-function) - (funcall org-confirm-elisp-link-function - (format "Execute \"%s\" as elisp? " - (org-add-props cmd nil - 'face 'org-warning)))) - (message "%s => %s" cmd - (if (eq (string-to-char cmd) ?\() - (eval (read cmd)) - (call-interactively (read cmd)))) - (user-error "Abort")))) - ((equal type "id") - (require 'org-id) - (funcall (nth 1 (assoc "id" org-link-protocols)) path)) + ((functionp (org-link-get-parameter type :follow)) + (funcall (org-link-get-parameter type :follow) path)) ((member type '("coderef" "custom-id" "fuzzy" "radio")) (unless (run-hook-with-args-until-success 'org-open-link-functions path) @@ -10844,15 +10756,15 @@ link in a property drawer line." (org-with-wide-buffer (if (equal type "radio") (org-search-radio-target - (org-element-property :path link)) + (org-element-property :path context)) (org-link-search (if (member type '("custom-id" "coderef")) - (org-element-property :raw-link link) + (org-element-property :raw-link context) path) ;; Prevent fuzzy links from matching ;; themselves. (and (equal type "fuzzy") - (+ 2 (org-element-property :begin link))))) + (+ 2 (org-element-property :begin context))))) (point)))) (unless (and (<= (point-min) destination) (>= (point-max) destination)) @@ -10883,57 +10795,54 @@ If NTH is an integer, return the NTH link found. If ZERO is a string, check also this string for a link, and if there is one, return it." (with-current-buffer buffer - (save-excursion - (save-restriction - (widen) - (goto-char marker) - (let ((cnt ?0) - (in-emacs (if (integerp nth) nil nth)) - have-zero end links link c) - (when (and (stringp zero) (string-match org-bracket-link-regexp zero)) - (push (match-string 0 zero) links) - (setq cnt (1- cnt) have-zero t)) - (save-excursion - (org-back-to-heading t) - (setq end (save-excursion (outline-next-heading) (point))) - (while (re-search-forward org-any-link-re end t) - (push (match-string 0) links)) - (setq links (org-uniquify (reverse links)))) - (cond - ((null links) - (message "No links")) - ((equal (length links) 1) - (setq link (car links))) - ((and (integerp nth) (>= (length links) (if have-zero (1+ nth) nth))) - (setq link (nth (if have-zero nth (1- nth)) links))) - (t ; we have to select a link - (save-excursion - (save-window-excursion - (delete-other-windows) - (with-output-to-temp-buffer "*Select Link*" - (mapc (lambda (l) - (if (not (string-match org-bracket-link-regexp l)) - (princ (format "[%c] %s\n" (incf cnt) - (org-remove-angle-brackets l))) - (if (match-end 3) - (princ (format "[%c] %s (%s)\n" (incf cnt) - (match-string 3 l) (match-string 1 l))) - (princ (format "[%c] %s\n" (incf cnt) - (match-string 1 l)))))) - links)) - (org-fit-window-to-buffer (get-buffer-window "*Select Link*")) - (message "Select link to open, RET to open all:") - (setq c (read-char-exclusive)) - (and (get-buffer "*Select Link*") (kill-buffer "*Select Link*")))) - (when (equal c ?q) (user-error "Abort")) - (if (equal c ?\C-m) - (setq link links) - (setq nth (- c ?0)) - (if have-zero (setq nth (1+ nth))) - (unless (and (integerp nth) (>= (length links) nth)) - (user-error "Invalid link selection")) - (setq link (nth (1- nth) links))))) - (cons link end)))))) + (org-with-wide-buffer + (goto-char marker) + (let ((cnt ?0) + have-zero end links link c) + (when (and (stringp zero) (string-match org-bracket-link-regexp zero)) + (push (match-string 0 zero) links) + (setq cnt (1- cnt) have-zero t)) + (save-excursion + (org-back-to-heading t) + (setq end (save-excursion (outline-next-heading) (point))) + (while (re-search-forward org-any-link-re end t) + (push (match-string 0) links)) + (setq links (org-uniquify (reverse links)))) + (cond + ((null links) + (message "No links")) + ((equal (length links) 1) + (setq link (car links))) + ((and (integerp nth) (>= (length links) (if have-zero (1+ nth) nth))) + (setq link (nth (if have-zero nth (1- nth)) links))) + (t ; we have to select a link + (save-excursion + (save-window-excursion + (delete-other-windows) + (with-output-to-temp-buffer "*Select Link*" + (dolist (l links) + (cond + ((not (string-match org-bracket-link-regexp l)) + (princ (format "[%c] %s\n" (cl-incf cnt) + (org-unbracket-string "<" ">" l)))) + ((match-end 3) + (princ (format "[%c] %s (%s)\n" (cl-incf cnt) + (match-string 3 l) (match-string 1 l)))) + (t (princ (format "[%c] %s\n" (cl-incf cnt) + (match-string 1 l))))))) + (org-fit-window-to-buffer (get-buffer-window "*Select Link*")) + (message "Select link to open, RET to open all:") + (setq c (read-char-exclusive)) + (and (get-buffer "*Select Link*") (kill-buffer "*Select Link*")))) + (when (equal c ?q) (user-error "Abort")) + (if (equal c ?\C-m) + (setq link links) + (setq nth (- c ?0)) + (when have-zero (setq nth (1+ nth))) + (unless (and (integerp nth) (>= (length links) nth)) + (user-error "Invalid link selection")) + (setq link (nth (1- nth) links))))) + (cons link end))))) ;; TODO: These functions are deprecated since `org-open-at-point' ;; hard-codes behaviour for "file+emacs" and "file+sys" types. @@ -10966,8 +10875,8 @@ which see. A function in this hook may also use `setq' to set the variable `description' to provide a suggestion for the descriptive text to -be used for this link when it gets inserted into an Org-mode -buffer with \\[org-insert-link].") +be used for this link when it gets inserted into an Org buffer +with \\[org-insert-link].") (defvar org-execute-file-search-functions nil "List of functions to execute a file search triggered by a link. @@ -11032,13 +10941,14 @@ visibility around point, thus ignoring `org-show-context-detail' variable. Search is case-insensitive and ignores white spaces. Return type -of matched result, with is either `dedicated' or `fuzzy'." +of matched result, which is either `dedicated' or `fuzzy'." (unless (org-string-nw-p s) (error "Invalid search string \"%s\"" s)) (let* ((case-fold-search t) (origin (point)) (normalized (replace-regexp-in-string "\n[ \t]*" " " s)) - (words (org-split-string s "[ \t\n]+")) - (s-multi-re (mapconcat #'regexp-quote words "[ \t]+\\(?:\n[ \t]*\\)?")) + (starred (eq (string-to-char normalized) ?*)) + (words (split-string (if starred (substring s 1) s))) + (s-multi-re (mapconcat #'regexp-quote words "\\(?:[ \t\n]+\\)")) (s-single-re (mapconcat #'regexp-quote words "[ \t]+")) type) (cond @@ -11079,112 +10989,102 @@ of matched result, with is either `dedicated' or `fuzzy'." ;; Look for a regular expression. (funcall (if (derived-mode-p 'org-mode) #'org-occur #'org-do-occur) (match-string 1 s))) - ;; Fuzzy links. - (t - (let* ((starred (eq (string-to-char normalized) ?*)) - (headline-search (and (derived-mode-p 'org-mode) - (or org-link-search-must-match-exact-headline - starred)))) - (cond - ;; Look for targets, only if not in a headline search. - ((and (not starred) - (let ((target (format "<<%s>>" s-multi-re))) - (catch :target-match - (goto-char (point-min)) - (while (re-search-forward target nil t) - (backward-char) - (let ((context (org-element-context))) - (when (eq (org-element-type context) 'target) - (setq type 'dedicated) - (goto-char (org-element-property :begin context)) - (throw :target-match t)))) - nil)))) - ;; Look for elements named after S, only if not in a headline - ;; search. - ((and (not starred) - (let ((name (format "^[ \t]*#\\+NAME: +%s[ \t]*$" s-single-re))) - (catch :name-match - (goto-char (point-min)) - (while (re-search-forward name nil t) - (let ((element (org-element-at-point))) - (when (equal (org-split-string - (org-element-property :name element) - "[ \t]+") - words) - (setq type 'dedicated) - (beginning-of-line) - (throw :name-match t)))) - nil)))) - ;; Regular text search. Prefer headlines in Org mode - ;; buffers. - ((and (derived-mode-p 'org-mode) - (let* ((wspace "[ \t]") - (wspaceopt (concat wspace "*")) - (cookie (concat "\\(?:" - wspaceopt - "\\[[0-9]*\\(?:%\\|/[0-9]*\\)\\]" - wspaceopt - "\\)")) - (sep (concat "\\(?:\\(?:" wspace "\\|" cookie "\\)+\\)")) - (re (concat - org-outline-regexp-bol - "\\(?:" org-todo-regexp "[ \t]+\\)?" - "\\(?:\\[#.\\][ \t]+\\)?" - "\\(?:" org-comment-string "[ \t]+\\)?" - sep "?" - (let ((title (mapconcat #'regexp-quote - words - sep))) - (if starred (substring title 1) title)) - sep "?" - (org-re "\\(?:[ \t]+:[[:alnum:]_@#%%:]+:\\)?") - "[ \t]*$"))) - (goto-char (point-min)) - (re-search-forward re nil t))) - (goto-char (match-beginning 0)) - (setq type 'dedicated)) - ;; Offer to create non-existent headline depending on - ;; `org-link-search-must-match-exact-headline'. - ((and (derived-mode-p 'org-mode) - (not org-link-search-inhibit-query) - (eq org-link-search-must-match-exact-headline 'query-to-create) - (yes-or-no-p "No match - create this as a new heading? ")) - (goto-char (point-max)) - (unless (bolp) (newline)) - (org-insert-heading nil t t) - (insert s "\n") - (beginning-of-line 0)) - ;; Only headlines are looked after. No need to process - ;; further: throw an error. - ((and (derived-mode-p 'org-mode) - (or starred org-link-search-must-match-exact-headline)) - (goto-char origin) - (error "No match for fuzzy expression: %s" normalized)) - ;; Regular text search. - ((catch :fuzzy-match - (goto-char (point-min)) - (while (re-search-forward s-multi-re nil t) - ;; Skip match if it contains AVOID-POS or it is included - ;; in a link with a description but outside the - ;; description. - (unless (or (and avoid-pos - (<= (match-beginning 0) avoid-pos) - (> (match-end 0) avoid-pos)) - (and (save-match-data - (org-in-regexp org-bracket-link-regexp)) - (match-beginning 3) - (or (> (match-beginning 3) (point)) - (<= (match-end 3) (point))) - (org-element-lineage - (save-match-data (org-element-context)) - '(link) t))) - (goto-char (match-beginning 0)) - (setq type 'fuzzy) - (throw :fuzzy-match t))) - nil)) - ;; All failed. Throw an error. - (t (goto-char origin) - (error "No match for fuzzy expression: %s" normalized)))))) + ;; From here, we handle fuzzy links. + ;; + ;; Look for targets, only if not in a headline search. + ((and (not starred) + (let ((target (format "<<%s>>" s-multi-re))) + (catch :target-match + (goto-char (point-min)) + (while (re-search-forward target nil t) + (backward-char) + (let ((context (org-element-context))) + (when (eq (org-element-type context) 'target) + (setq type 'dedicated) + (goto-char (org-element-property :begin context)) + (throw :target-match t)))) + nil)))) + ;; Look for elements named after S, only if not in a headline + ;; search. + ((and (not starred) + (let ((name (format "^[ \t]*#\\+NAME: +%s[ \t]*$" s-single-re))) + (catch :name-match + (goto-char (point-min)) + (while (re-search-forward name nil t) + (let ((element (org-element-at-point))) + (when (equal words + (split-string + (org-element-property :name element))) + (setq type 'dedicated) + (beginning-of-line) + (throw :name-match t)))) + nil)))) + ;; Regular text search. Prefer headlines in Org mode buffers. + ;; Ignore COMMENT keyword, TODO keywords, priority cookies, + ;; statistics cookies and tags. + ((and (derived-mode-p 'org-mode) + (let ((title-re + (format "%s.*\\(?:%s[ \t]\\)?.*%s" + org-outline-regexp-bol + org-comment-string + (mapconcat #'regexp-quote words ".+"))) + (cookie-re "\\[[0-9]*\\(?:%\\|/[0-9]*\\)\\]") + (comment-re (eval-when-compile + (format "\\`%s[ \t]+" org-comment-string)))) + (goto-char (point-min)) + (catch :found + (while (re-search-forward title-re nil t) + (when (equal words + (split-string + (replace-regexp-in-string + cookie-re "" + (replace-regexp-in-string + comment-re "" (org-get-heading t t t))))) + (throw :found t))) + nil))) + (beginning-of-line) + (setq type 'dedicated)) + ;; Offer to create non-existent headline depending on + ;; `org-link-search-must-match-exact-headline'. + ((and (derived-mode-p 'org-mode) + (not org-link-search-inhibit-query) + (eq org-link-search-must-match-exact-headline 'query-to-create) + (yes-or-no-p "No match - create this as a new heading? ")) + (goto-char (point-max)) + (unless (bolp) (newline)) + (org-insert-heading nil t t) + (insert s "\n") + (beginning-of-line 0)) + ;; Only headlines are looked after. No need to process + ;; further: throw an error. + ((and (derived-mode-p 'org-mode) + (or starred org-link-search-must-match-exact-headline)) + (goto-char origin) + (error "No match for fuzzy expression: %s" normalized)) + ;; Regular text search. + ((catch :fuzzy-match + (goto-char (point-min)) + (while (re-search-forward s-multi-re nil t) + ;; Skip match if it contains AVOID-POS or it is included in + ;; a link with a description but outside the description. + (unless (or (and avoid-pos + (<= (match-beginning 0) avoid-pos) + (> (match-end 0) avoid-pos)) + (and (save-match-data + (org-in-regexp org-bracket-link-regexp)) + (match-beginning 3) + (or (> (match-beginning 3) (point)) + (<= (match-end 3) (point))) + (org-element-lineage + (save-match-data (org-element-context)) + '(link) t))) + (goto-char (match-beginning 0)) + (setq type 'fuzzy) + (throw :fuzzy-match t))) + nil)) + ;; All failed. Throw an error. + (t (goto-char origin) + (error "No match for fuzzy expression: %s" normalized))) ;; Disclose surroundings of match, if appropriate. (when (and (derived-mode-p 'org-mode) (not stealth)) (org-show-context 'link-search)) @@ -11195,7 +11095,7 @@ of matched result, with is either `dedicated' or `fuzzy'." (cond ((not org-display-internal-link-with-indirect-buffer) buffer) - ((string-match "(Clone)$" (buffer-name buffer)) + ((string-suffix-p "(Clone)" (buffer-name buffer)) (message "Buffer is already a clone, not making another one") ;; we also do not modify visibility in this case buffer) @@ -11219,8 +11119,8 @@ to read." (goto-char (point-min)) (when (re-search-forward "match[a-z]+" nil t) (setq beg (match-end 0)) - (if (re-search-forward "^[ \t]*[0-9]+" nil t) - (setq end (1- (match-beginning 0))))) + (when (re-search-forward "^[ \t]*[0-9]+" nil t) + (setq end (1- (match-beginning 0))))) (and beg end (let ((inhibit-read-only t)) (delete-region beg end))) (goto-char (point-min)) (select-window cwin)))) @@ -11228,13 +11128,13 @@ to read." ;;; The mark ring for links jumps (defvar org-mark-ring nil - "Mark ring for positions before jumps in Org-mode.") + "Mark ring for positions before jumps in Org mode.") (defvar org-mark-ring-last-goto nil "Last position in the mark ring used to go back.") ;; Fill and close the ring (setq org-mark-ring nil org-mark-ring-last-goto nil) ;; in case file is reloaded -(loop for i from 1 to org-mark-ring-length do - (push (make-marker) org-mark-ring)) +(dotimes (_ org-mark-ring-length) + (push (make-marker) org-mark-ring)) (setcdr (nthcdr (1- org-mark-ring-length) org-mark-ring) org-mark-ring) @@ -11248,15 +11148,15 @@ to read." (or buffer (current-buffer))) (message "%s" (substitute-command-keys - "Position saved to mark ring, go back with \\[org-mark-ring-goto]."))) + "Position saved to mark ring, go back with \ +`\\[org-mark-ring-goto]'."))) (defun org-mark-ring-goto (&optional n) "Jump to the previous position in the mark ring. With prefix arg N, jump back that many stored positions. When called several times in succession, walk through the entire ring. -Org-mode commands jumping to a different position in the current file, -or to another Org-mode file, automatically push the old position -onto the ring." +Org mode commands jumping to a different position in the current file, +or to another Org file, automatically push the old position onto the ring." (interactive "p") (let (p m) (if (eq last-command this-command) @@ -11264,25 +11164,19 @@ onto the ring." (setq p org-mark-ring)) (setq org-mark-ring-last-goto p) (setq m (car p)) - (org-pop-to-buffer-same-window (marker-buffer m)) + (pop-to-buffer-same-window (marker-buffer m)) (goto-char m) - (if (or (outline-invisible-p) (org-invisible-p2)) (org-show-context 'mark-goto)))) + (when (or (outline-invisible-p) (org-invisible-p2)) (org-show-context 'mark-goto)))) -(defun org-remove-angle-brackets (s) - (if (equal (substring s 0 1) "<") (setq s (substring s 1))) - (if (equal (substring s -1) ">") (setq s (substring s 0 -1))) - s) (defun org-add-angle-brackets (s) - (if (equal (substring s 0 1) "<") nil (setq s (concat "<" s))) - (if (equal (substring s -1) ">") nil (setq s (concat s ">"))) - s) -(defun org-remove-double-quotes (s) - (if (equal (substring s 0 1) "\"") (setq s (substring s 1))) - (if (equal (substring s -1) "\"") (setq s (substring s 0 -1))) + (unless (equal (substring s 0 1) "<") (setq s (concat "<" s))) + (unless (equal (substring s -1) ">") (setq s (concat s ">"))) s) ;;; Following specific links +(defvar org-agenda-buffer-tmp-name) +(defvar org-agenda-start-on-weekday) (defun org-follow-timestamp-link () "Open an agenda view for the time-stamp date/range at point." (cond @@ -11337,43 +11231,47 @@ If the file does not exist, an error is thrown." buffer-file-name (substitute-in-file-name (expand-file-name path)))) (file-apps (append org-file-apps (org-default-apps))) - (apps (org-remove-if + (apps (cl-remove-if 'org-file-apps-entry-match-against-dlink-p file-apps)) - (apps-dlink (org-remove-if-not + (apps-dlink (cl-remove-if-not 'org-file-apps-entry-match-against-dlink-p file-apps)) (remp (and (assq 'remote apps) (org-file-remote-p file))) - (dirp (if remp nil (file-directory-p file))) + (dirp (unless remp (file-directory-p file))) (file (if (and dirp org-open-directory-means-index-dot-org) (concat (file-name-as-directory file) "index.org") file)) (a-m-a-p (assq 'auto-mode apps)) (dfile (downcase file)) - ;; reconstruct the original file: link from the PATH, LINE and SEARCH args - (link (cond ((and (eq line nil) - (eq search nil)) - file) - (line - (concat file "::" (number-to-string line))) - (search - (concat file "::" search)))) + ;; Reconstruct the original link from the PATH, LINE and + ;; SEARCH args. + (link (cond (line (concat file "::" (number-to-string line))) + (search (concat file "::" search)) + (t file))) (dlink (downcase link)) - (old-buffer (current-buffer)) - (old-pos (point)) - (old-mode major-mode) - ext cmd link-match-data) - (if (string-match "^.*\\.\\([a-zA-Z0-9]+\\.gz\\)$" dfile) - (setq ext (match-string 1 dfile)) - (if (string-match "^.*\\.\\([a-zA-Z0-9]+\\)$" dfile) - (setq ext (match-string 1 dfile)))) + (ext + (and (string-match "\\`.*?\\.\\([a-zA-Z0-9]+\\(\\.gz\\)?\\)\\'" dfile) + (match-string 1 dfile))) + (save-position-maybe + (let ((old-buffer (current-buffer)) + (old-pos (point)) + (old-mode major-mode)) + (lambda () + (and (derived-mode-p 'org-mode) + (eq old-mode 'org-mode) + (or (not (eq old-buffer (current-buffer))) + (not (eq old-pos (point)))) + (org-mark-ring-push old-pos old-buffer))))) + cmd link-match-data) (cond ((member in-emacs '((16) system)) - (setq cmd (cdr (assoc 'system apps)))) + (setq cmd (cdr (assq 'system apps)))) (in-emacs (setq cmd 'emacs)) (t - (setq cmd (or (and remp (cdr (assoc 'remote apps))) - (and dirp (cdr (assoc 'directory apps))) - ; first, try matching against apps-dlink - ; if we get a match here, store the match data for later + (setq cmd (or (and remp (cdr (assq 'remote apps))) + (and dirp (cdr (assq 'directory apps))) + ;; First, try matching against apps-dlink if we + ;; get a match here, store the match data for + ;; later. (let ((match (assoc-default dlink apps-dlink 'string-match))) (if match @@ -11386,9 +11284,9 @@ If the file does not exist, an error is thrown." (assoc-default dfile (org-apps-regexp-alist apps a-m-a-p) 'string-match) (cdr (assoc ext apps)) - (cdr (assoc t apps)))))) + (cdr (assq t apps)))))) (when (eq cmd 'system) - (setq cmd (cdr (assoc 'system apps)))) + (setq cmd (cdr (assq 'system apps)))) (when (eq cmd 'default) (setq cmd (cdr (assoc t apps)))) (when (eq cmd 'mailcap) @@ -11399,21 +11297,20 @@ If the file does not exist, an error is thrown." (if (stringp command) (setq cmd command) (setq cmd 'emacs)))) - (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)) - (user-error "No such file: %s" file)) + (when (and (not (eq cmd 'emacs)) ; Emacs has no problems with non-ex files + (not (file-exists-p file)) + (not org-open-non-existing-files)) + (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. (while (string-match "['\"]%s['\"]" cmd) (setq cmd (replace-match "%s" t t cmd))) - (while (string-match "%s" cmd) - (setq cmd (replace-match - (save-match-data - (shell-quote-argument - (convert-standard-filename file))) - t t cmd))) + (setq cmd (replace-regexp-in-string + "%s" + (shell-quote-argument (convert-standard-filename file)) + cmd + nil t)) ;; Replace "%1", "%2" etc. in command with group matches from regex (save-match-data @@ -11435,20 +11332,34 @@ If the file does not exist, an error is thrown." (eq cmd 'emacs)) (funcall (cdr (assq 'file org-link-frame-setup)) file) (widen) - (if line (progn (org-goto-line line) - (if (derived-mode-p 'org-mode) - (org-reveal))) - (if search (org-link-search search)))) + (cond (line (org-goto-line line) + (when (derived-mode-p 'org-mode) (org-reveal))) + (search (condition-case err + (org-link-search search) + ;; Save position before error-ing out so user + ;; can easily move back to the original buffer. + (error (funcall save-position-maybe) + (error (nth 1 err))))))) + ((functionp cmd) + (save-match-data + (set-match-data link-match-data) + (condition-case nil + (funcall cmd file link) + ;; FIXME: Remove this check when most default installations + ;; of Emacs have at least Org 9.0. + ((debug wrong-number-of-arguments wrong-type-argument + invalid-function) + (user-error "Please see Org News for version 9.0 about \ +`org-file-apps'--Lisp error: %S" cmd))))) ((consp cmd) - (let ((file (convert-standard-filename file))) - (save-match-data - (set-match-data link-match-data) - (eval cmd)))) + ;; FIXME: Remove this check when most default installations of + ;; Emacs have at least Org 9.0. Heads-up instead of silently + ;; fall back to `org-link-frame-setup' for an old usage of + ;; `org-file-apps' with sexp instead of a function for `cmd'. + (user-error "Please see Org News for version 9.0 about \ +`org-file-apps'--Error: Deprecated usage of %S" cmd)) (t (funcall (cdr (assq 'file org-link-frame-setup)) file))) - (and (derived-mode-p 'org-mode) (eq old-mode 'org-mode) - (or (not (equal old-buffer (current-buffer))) - (not (equal old-pos (point)))) - (org-mark-ring-push old-pos old-buffer)))) + (funcall save-position-maybe))) (defun org-file-apps-entry-match-against-dlink-p (entry) "This function returns non-nil if `entry' uses a regular @@ -11458,7 +11369,7 @@ org-open-file. It assumes that is the case when the entry uses a regular expression which has at least one grouping construct and the action is either a lisp form or a command string containing -'%1', i.e. using at least one subexpression match as a +`%1', i.e. using at least one subexpression match as a parameter." (let ((selector (car entry)) (action (cdr entry))) @@ -11488,16 +11399,15 @@ be opened in Emacs." (append (delq nil (mapcar (lambda (x) - (if (not (stringp (car x))) - nil + (unless (not (stringp (car x))) (if (string-match "\\W" (car x)) x (cons (concat "\\." (car x) "\\'") (cdr x))))) list)) - (if add-auto-mode - (mapcar (lambda (x) (cons (car x) 'emacs)) auto-mode-alist)))) + (when add-auto-mode + (mapcar (lambda (x) (cons (car x) 'emacs)) auto-mode-alist)))) -(defvar ange-ftp-name-format) ; to silence the XEmacs compiler. +(defvar ange-ftp-name-format) (defun org-file-remote-p (file) "Test whether FILE specifies a location on a remote system. Return non-nil if the location is indeed remote. @@ -11530,8 +11440,8 @@ on the system \"/user@host:\"." ((not (listp org-reverse-note-order)) nil) (t (catch 'exit (dolist (entry org-reverse-note-order) - (if (string-match (car entry) buffer-file-name) - (throw 'exit (cdr entry)))))))) + (when (string-match (car entry) buffer-file-name) + (throw 'exit (cdr entry)))))))) (defvar org-refile-target-table nil "The list of refile targets, created by `org-refile'.") @@ -11556,7 +11466,7 @@ on the system \"/user@host:\"." (defun org-refile-cache-clear () "Clear the refile cache and disable all the markers." - (mapc (lambda (m) (move-marker m nil)) org-refile-markers) + (dolist (m org-refile-markers) (move-marker m nil)) (setq org-refile-markers nil) (setq org-refile-cache nil) (message "Refile cache has been cleared")) @@ -11591,17 +11501,23 @@ on the system \"/user@host:\"." org-refile-cache)))) (and set (org-refile-cache-check-set set) set))))) -(defun org-refile-get-targets (&optional default-buffer excluded-entries) +(defvar org-outline-path-cache nil + "Alist between buffer positions and outline paths. +It value is an alist (POSITION . PATH) where POSITION is the +buffer position at the beginning of an entry and PATH is a list +of strings describing the outline path for that entry, in reverse +order.") + +(defun org-refile-get-targets (&optional default-buffer) "Produce a table with refile targets." (let ((case-fold-search nil) ;; otherwise org confuses "TODO" as a kw and "Todo" as a word (entries (or org-refile-targets '((nil . (:level . 1))))) - targets tgs txt re files desc descre fast-path-p level pos0) + targets tgs files desc descre) (message "Getting targets...") (with-current-buffer (or default-buffer (current-buffer)) (dolist (entry entries) (setq files (car entry) desc (cdr entry)) - (setq fast-path-p nil) (cond ((null files) (setq files (list (current-buffer)))) ((eq files 'org-agenda-files) @@ -11610,7 +11526,7 @@ on the system \"/user@host:\"." (setq files (funcall files))) ((and (symbolp files) (boundp files)) (setq files (symbol-value files)))) - (if (stringp files) (setq files (list files))) + (when (stringp files) (setq files (list files))) (cond ((eq (car desc) :tag) (setq descre (concat "^\\*+[ \t]+.*?:" (regexp-quote (cdr desc)) ":"))) @@ -11625,7 +11541,6 @@ on the system \"/user@host:\"." (cdr desc))) "\\}[ \t]"))) ((eq (car desc) :maxlevel) - (setq fast-path-p t) (setq descre (concat "^\\*\\{1," (number-to-string (if org-odd-levels-only (1- (* 2 (cdr desc))) @@ -11633,58 +11548,51 @@ on the system \"/user@host:\"." "\\}[ \t]"))) (t (error "Bad refiling target description %s" desc))) (dolist (f files) - (with-current-buffer - (if (bufferp f) f (org-get-agenda-file-buffer f)) + (with-current-buffer (if (bufferp f) f (org-get-agenda-file-buffer f)) (or (setq tgs (org-refile-cache-get (buffer-file-name) descre)) (progn - (if (bufferp f) (setq f (buffer-file-name - (buffer-base-buffer f)))) + (when (bufferp f) + (setq f (buffer-file-name (buffer-base-buffer f)))) (setq f (and f (expand-file-name f))) - (if (eq org-refile-use-outline-path 'file) - (push (list (file-name-nondirectory f) f nil nil) tgs)) - (save-excursion - (save-restriction - (widen) - (goto-char (point-min)) - (while (re-search-forward descre nil t) - (goto-char (setq pos0 (point-at-bol))) - (catch 'next - (when org-refile-target-verify-function - (save-match-data - (or (funcall org-refile-target-verify-function) - (throw 'next t)))) - (when (and (looking-at org-complex-heading-regexp) - (not (member (match-string 4) excluded-entries)) - (match-string 4)) - (setq level (org-reduced-level - (- (match-end 1) (match-beginning 1))) - txt (org-link-display-format (match-string 4)) - txt (replace-regexp-in-string "\\( *\[[0-9]+/?[0-9]*%?\]\\)+$" "" txt) - re (format org-complex-heading-regexp-format - (regexp-quote (match-string 4)))) - (when org-refile-use-outline-path - (setq txt (mapconcat - 'org-protect-slash - (append - (if (eq org-refile-use-outline-path - 'file) - (list (file-name-nondirectory - (buffer-file-name - (buffer-base-buffer)))) - (if (eq org-refile-use-outline-path - 'full-file-path) - (list (buffer-file-name - (buffer-base-buffer))))) - (org-get-outline-path fast-path-p - level txt) - (list txt)) - "/"))) - (push (list txt f re (org-refile-marker (point))) - tgs))) - (when (= (point) pos0) - ;; verification function has not moved point - (goto-char (point-at-eol)))))))) + (when (eq org-refile-use-outline-path 'file) + (push (list (file-name-nondirectory f) f nil nil) tgs)) + (org-with-wide-buffer + (goto-char (point-min)) + (setq org-outline-path-cache nil) + (while (re-search-forward descre nil t) + (beginning-of-line) + (let ((case-fold-search nil)) + (looking-at org-complex-heading-regexp)) + (let ((begin (point)) + (heading (match-string-no-properties 4))) + (unless (or (and + org-refile-target-verify-function + (not + (funcall org-refile-target-verify-function))) + (not heading)) + (let ((re (format org-complex-heading-regexp-format + (regexp-quote heading))) + (target + (if (not org-refile-use-outline-path) heading + (mapconcat + #'org-protect-slash + (append + (pcase org-refile-use-outline-path + (`file (list (file-name-nondirectory + (buffer-file-name + (buffer-base-buffer))))) + (`full-file-path + (list (buffer-file-name + (buffer-base-buffer)))) + (_ nil)) + (org-get-outline-path t t)) + "/")))) + (push (list target f re (org-refile-marker (point))) + tgs))) + (when (= (point) begin) + ;; Verification function has not moved point. + (end-of-line))))))) (when org-refile-use-cache (org-refile-cache-put tgs (buffer-file-name) descre)) (setq targets (append tgs targets)))))) @@ -11692,40 +11600,61 @@ on the system \"/user@host:\"." (nreverse targets))) (defun org-protect-slash (s) - (while (string-match "/" s) - (setq s (replace-match "\\" t t s))) - s) - -(defvar org-olpa (make-vector 20 nil)) - -(defun org-get-outline-path (&optional fastp level heading) - "Return the outline path to the current entry, as a list. - -The parameters FASTP, LEVEL, and HEADING are for use by a scanner -routine which makes outline path derivations for an entire file, -avoiding backtracing. Refile target collection makes use of that." - (if fastp - (progn - (if (> level 19) - (error "Outline path failure, more than 19 levels")) - (loop for i from level upto 19 do - (aset org-olpa i nil)) - (prog1 - (delq nil (append org-olpa nil)) - (aset org-olpa level heading))) - (let (rtn case-fold-search) - (save-excursion - (save-restriction - (widen) - (while (org-up-heading-safe) - (when (looking-at org-complex-heading-regexp) - (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))))) + (replace-regexp-in-string "/" "\\/" s nil t)) + +(defun org--get-outline-path-1 (&optional use-cache) + "Return outline path to current headline. + +Outline path is a list of strings, in reverse order. When +optional argument USE-CACHE is non-nil, make use of a cache. See +`org-get-outline-path' for details. + +Assume buffer is widened and point is on a headline." + (or (and use-cache (cdr (assq (point) org-outline-path-cache))) + (let ((p (point)) + (heading (let ((case-fold-search nil)) + (looking-at org-complex-heading-regexp) + (if (not (match-end 4)) "" + ;; Remove statistics cookies. + (org-trim + (org-link-display-format + (replace-regexp-in-string + "\\[[0-9]+%\\]\\|\\[[0-9]+/[0-9]+\\]" "" + (match-string-no-properties 4)))))))) + (if (org-up-heading-safe) + (let ((path (cons heading (org--get-outline-path-1 use-cache)))) + (when use-cache + (push (cons p path) org-outline-path-cache)) + path) + ;; This is a new root node. Since we assume we are moving + ;; forward, we can drop previous cache so as to limit number + ;; of associations there. + (let ((path (list heading))) + (when use-cache (setq org-outline-path-cache (list (cons p path)))) + path))))) + +(defun org-get-outline-path (&optional with-self use-cache) + "Return the outline path to the current entry. + +An outline path is a list of ancestors for current headline, as +a list of strings. Statistics cookies are removed and links are +replaced with their description, if any, or their path otherwise. + +When optional argument WITH-SELF is non-nil, the path also +includes the current headline. + +When optional argument USE-CACHE is non-nil, cache outline paths +between calls to this function so as to avoid backtracking. This +argument is useful when planning to find more than one outline +path in the same document. In that case, there are two +conditions to satisfy: + - `org-outline-path-cache' is set to nil before starting the + process; + - outline paths are computed by increasing buffer positions." + (org-with-wide-buffer + (and (or (and with-self (org-back-to-heading t)) + (org-up-heading-safe)) + (reverse (org--get-outline-path-1 use-cache))))) (defun org-format-outline-path (path &optional width prefix separator) "Format the outline path PATH for display. @@ -11735,38 +11664,28 @@ 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) - (or prefix "") - (let* ((nsteps (length path)) - (total-width (+ nsteps (apply '+ (mapcar 'length path)))) - (maxwidth (if (<= total-width width) - 10000 ;; everything fits - ;; we need to shorten the level headings - (/ (- width nsteps) nsteps))) - (org-odd-levels-only nil) - (n 0) - (total (1+ (length prefix)))) - (setq maxwidth (max maxwidth 10)) - (concat prefix - (if prefix (or separator "/")) - (mapconcat - (lambda (h) - (setq n (1+ n)) - (if (and (= n nsteps) (< maxwidth 10000)) - (setq maxwidth (- total-width total))) - (if (< (length h) maxwidth) - (progn (setq total (+ total (length h) 1)) h) - (setq h (substring h 0 (- maxwidth 2)) - total (+ total maxwidth 1)) - (if (string-match "[ \t]+\\'" h) - (setq h (substring h 0 (match-beginning 0)))) - (setq h (concat h ".."))) - (org-add-props h nil 'face - (nth (% (1- n) org-n-level-faces) - org-level-faces)) - h) - path (or separator "/")))))) + (setq path (delq nil path)) + (unless (> width 0) + (user-error "Argument `width' must be positive")) + (setq separator (or separator "/")) + (let* ((org-odd-levels-only nil) + (fpath (concat + prefix (and prefix path separator) + (mapconcat + (lambda (s) (replace-regexp-in-string "[ \t]+\\'" "" s)) + (cl-loop for head in path + for n from 0 + collect (org-add-props + head nil 'face + (nth (% n org-n-level-faces) org-level-faces))) + separator)))) + (when (> (length fpath) width) + (if (< width 7) + ;; It's unlikely that `width' will be this small, but don't + ;; waste characters by adding ".." if it is. + (setq fpath (substring fpath 0 width)) + (setf (substring fpath (- width 2)) ".."))) + fpath)) (defun org-display-outline-path (&optional file current separator just-return-string) "Display the current outline path in the echo area. @@ -11781,10 +11700,10 @@ If JUST-RETURN-STRING is non-nil, return a string, don't display a message." (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) + (when current (setq path (append path + (save-excursion + (org-back-to-heading t) + (when (looking-at org-complex-heading-regexp) (list (match-string 4))))))) (setq res (org-format-outline-path @@ -11816,6 +11735,7 @@ the *old* location.") (defun org-refile (&optional arg 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. @@ -11827,10 +11747,12 @@ If there is an active region, all entries in that region will be refiled. However, the region must fulfill the requirement that the first heading sets the top-level of the moved text. -With prefix arg ARG, the command will only visit the target -location and not actually move anything. +With a `\\[universal-argument]' ARG, the command will only visit the target \ +location +and not actually move anything. -With a double prefix arg \\[universal-argument] \\[universal-argument], go to the location where the last +With a prefix `\\[universal-argument] \\[universal-argument]', go to the \ +location where the last refiling operation has put the subtree. With a numeric prefix argument of `2', refile to the running clock. @@ -11845,11 +11767,11 @@ 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'. +See also `org-refile-use-outline-path'. If you are using target caching (see `org-refile-use-cache'), you have to clear the target cache in order to find new targets. -This can be done with a 0 prefix (`C-0 C-c C-w') or a triple +This can be done with a `0' prefix (`C-0 C-c C-w') or a triple prefix argument (`C-u C-u C-u C-c C-w')." (interactive "P") (if (member arg '(0 (64))) @@ -11857,13 +11779,11 @@ prefix argument (`C-u C-u C-u C-c C-w')." (let* ((actionmsg (cond (msg msg) ((equal arg 3) "Refile (and keep)") (t "Refile"))) - (cbuf (current-buffer)) (regionp (org-region-active-p)) (region-start (and regionp (region-beginning))) (region-end (and regionp (region-end))) - (filename (buffer-file-name (buffer-base-buffer cbuf))) (org-refile-keep (if (equal arg 3) t org-refile-keep)) - pos it nbuf file re level reversed) + pos it nbuf file level reversed) (setq last-command nil) (when regionp (goto-char region-start) @@ -11888,43 +11808,43 @@ prefix argument (`C-u C-u C-u C-c C-w')." "" (marker-position org-clock-hd-marker))) (setq arg nil))) - (setq it (or rfloc - (let (heading-text) - (save-excursion - (unless (and arg (listp arg)) - (org-back-to-heading t) - (setq heading-text - (replace-regexp-in-string - org-bracket-link-regexp - "\\3" - (nth 4 (org-heading-components))))) - (org-refile-get-location - (cond ((and arg (listp arg)) "Goto") - (regionp (concat actionmsg " region to")) - (t (concat actionmsg " subtree \"" - heading-text "\" to"))) - default-buffer - (and (not (equal '(4) arg)) - org-refile-allow-creating-parent-nodes) - arg)))))) + (setq it + (or rfloc + (let (heading-text) + (save-excursion + (unless (and arg (listp arg)) + (org-back-to-heading t) + (setq heading-text + (replace-regexp-in-string + org-bracket-link-regexp + "\\3" + (or (nth 4 (org-heading-components)) + "")))) + (org-refile-get-location + (cond ((and arg (listp arg)) "Goto") + (regionp (concat actionmsg " region to")) + (t (concat actionmsg " subtree \"" + heading-text "\" to"))) + default-buffer + (and (not (equal '(4) arg)) + org-refile-allow-creating-parent-nodes))))))) (setq file (nth 1 it) - re (nth 2 it) pos (nth 3 it)) - (if (and (not arg) - pos - (equal (buffer-file-name) file) - (if regionp - (and (>= pos region-start) - (<= pos region-end)) - (and (>= pos (point)) - (< pos (save-excursion - (org-end-of-subtree t t)))))) - (error "Cannot refile to position inside the tree or region")) + (when (and (not arg) + pos + (equal (buffer-file-name) file) + (if regionp + (and (>= pos region-start) + (<= pos region-end)) + (and (>= pos (point)) + (< pos (save-excursion + (org-end-of-subtree t t)))))) + (error "Cannot refile to position inside the tree or region")) (setq nbuf (or (find-buffer-visiting file) (find-file-noselect file))) (if (and arg (not (equal arg 3))) (progn - (org-pop-to-buffer-same-window nbuf) + (pop-to-buffer-same-window nbuf) (goto-char pos) (org-show-context 'org-goto)) (if regionp @@ -11935,50 +11855,47 @@ prefix argument (`C-u C-u C-u C-c C-w')." (with-current-buffer (setq nbuf (or (find-buffer-visiting file) (find-file-noselect file))) (setq reversed (org-notes-order-reversed-p)) - (save-excursion - (save-restriction - (widen) - (if pos - (progn - (goto-char pos) - (looking-at org-outline-regexp) - (setq level (org-get-valid-level (funcall outline-level) 1)) - (goto-char - (if reversed - (or (outline-next-heading) (point-max)) - (or (save-excursion (org-get-next-sibling)) - (org-end-of-subtree t t) - (point-max))))) - (setq level 1) - (if (not reversed) - (goto-char (point-max)) - (goto-char (point-min)) - (or (outline-next-heading) (goto-char (point-max))))) - (if (not (bolp)) (newline)) - (org-paste-subtree level nil nil t) - (when 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))) - (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) - (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)))) + (org-with-wide-buffer + (if pos + (progn + (goto-char pos) + (setq level (org-get-valid-level (funcall outline-level) 1)) + (goto-char + (if reversed + (or (outline-next-heading) (point-max)) + (or (save-excursion (org-get-next-sibling)) + (org-end-of-subtree t t) + (point-max))))) + (setq level 1) + (if (not reversed) + (goto-char (point-max)) + (goto-char (point-min)) + (or (outline-next-heading) (goto-char (point-max))))) + (unless (bolp) (newline)) + (org-paste-subtree level nil nil t) + (when org-log-refile + (org-add-log-setup 'refile nil nil 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))) + (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 (bound-and-true-p org-capture-is-refiling) + (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))) + (when (fboundp 'deactivate-mark) (deactivate-mark)) + (run-hooks 'org-after-refile-insert-hook))) (unless org-refile-keep (if regionp (delete-region (point) (+ (point) (- region-end region-start))) @@ -12007,35 +11924,22 @@ Also check `org-refile-target-table'." (list (replace-regexp-in-string "/$" "" refloc) (replace-regexp-in-string "\\([^/]\\)$" "\\1/" refloc)))))) -(defun org-refile-get-location (&optional prompt default-buffer new-nodes - no-exclude) +(defun org-refile-get-location (&optional prompt default-buffer new-nodes) "Prompt the user for a refile location, using PROMPT. PROMPT should not be suffixed with a colon and a space, because this function appends the default value from -`org-refile-history' automatically, if that is not empty. -When NO-EXCLUDE is set, do not exclude headlines in the current subtree, -this is used for the GOTO interface." +`org-refile-history' automatically, if that is not empty." (let ((org-refile-targets org-refile-targets) - (org-refile-use-outline-path org-refile-use-outline-path) - excluded-entries) - (when (and (derived-mode-p 'org-mode) - (not org-refile-use-cache) - (not no-exclude)) - (org-map-tree - (lambda() - (setq excluded-entries - (append excluded-entries (list (org-get-heading t t))))))) - (setq org-refile-target-table - (org-refile-get-targets default-buffer excluded-entries))) + (org-refile-use-outline-path org-refile-use-outline-path)) + (setq org-refile-target-table (org-refile-get-targets default-buffer))) (unless org-refile-target-table (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 org-outline-path-complete-in-steps) - 'org-olpath-completing-read - 'org-icompleting-read)) + #'org-olpath-completing-read + #'completing-read)) (extra (if org-refile-use-outline-path "/" "")) (cbnex (concat (buffer-name) extra)) (filename (and cfn (expand-file-name cfn))) @@ -12070,8 +11974,8 @@ this is used for the GOTO interface." (cons (car pa) (if (assoc (car org-refile-history) tbl) org-refile-history (cdr org-refile-history)))) - (if (equal (car org-refile-history) (nth 1 org-refile-history)) - (pop org-refile-history))) + (when (equal (car org-refile-history) (nth 1 org-refile-history)) + (pop org-refile-history))) pa) (if (string-match "\\`\\(.*\\)/\\([^/]+\\)\\'" answ) (progn @@ -12101,13 +12005,11 @@ this is used for the GOTO interface." (or (find-buffer-visiting file) (find-file-noselect file)))) (with-current-buffer buffer - (save-excursion - (save-restriction - (widen) - (goto-char pos) - (beginning-of-line 1) - (unless (org-looking-at-p re) - (user-error "Invalid refile position, please clear the cache with `C-0 C-c C-w' before refiling"))))))))) + (org-with-wide-buffer + (goto-char pos) + (beginning-of-line 1) + (unless (looking-at-p re) + (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." @@ -12118,29 +12020,25 @@ this is used for the GOTO interface." level) (with-current-buffer (or (find-buffer-visiting file) (find-file-noselect file)) - (save-excursion - (save-restriction - (widen) - (if pos - (goto-char pos) - (goto-char (point-max)) - (if (not (bolp)) (newline))) - (when (looking-at org-outline-regexp) - (setq level (funcall outline-level)) - (org-end-of-subtree t t)) - (org-back-over-empty-lines) - (insert "\n" (make-string - (if pos (org-get-valid-level level 1) 1) ?*) - " " child "\n") - (beginning-of-line 0) - (list (concat (car parent-target) "/" child) file "" (point))))))) + (org-with-wide-buffer + (if pos + (goto-char pos) + (goto-char (point-max)) + (unless (bolp) (newline))) + (when (looking-at org-outline-regexp) + (setq level (funcall outline-level)) + (org-end-of-subtree t t)) + (org-back-over-empty-lines) + (insert "\n" (make-string + (if pos (org-get-valid-level level 1) 1) ?*) + " " child "\n") + (beginning-of-line 0) + (list (concat (car parent-target) "/" child) file "" (point)))))) (defun org-olpath-completing-read (prompt collection &rest args) "Read an outline path like a file name." - (let ((thetable collection) - (org-completion-use-ido nil) ; does not work with ido. - (org-completion-use-iswitchb nil)) ; or iswitchb - (apply #'org-icompleting-read + (let ((thetable collection)) + (apply #'completing-read prompt (lambda (string predicate &optional flag) (cond @@ -12171,7 +12069,7 @@ If not found, stay at current position and return nil." (setq pos (and (re-search-forward (concat "^[ \t]*#\\+\\(?:BEGIN\\|begin\\):[ \t]+" name "\\>") nil t) (match-beginning 0)))) - (if pos (goto-char pos)) + (when pos (goto-char pos)) pos)) (defun org-create-dblock (plist) @@ -12296,15 +12194,14 @@ This function can be used in a hook." ;;;; Completion -(declare-function org-export-backend-name "org-export" (cl-x)) -(declare-function org-export-backend-options "org-export" (cl-x)) +(declare-function org-export-backend-options "ox" (cl-x) t) (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) + (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) @@ -12326,11 +12223,11 @@ keywords relative to each registered export back-end." ("v" "#+BEGIN_VERSE\n?\n#+END_VERSE") ("V" "#+BEGIN_VERBATIM\n?\n#+END_VERBATIM") ("c" "#+BEGIN_CENTER\n?\n#+END_CENTER") - ("l" "#+BEGIN_LaTeX\n?\n#+END_LaTeX") + ("l" "#+BEGIN_EXPORT latex\n?\n#+END_EXPORT") ("L" "#+LaTeX: ") - ("h" "#+BEGIN_HTML\n?\n#+END_HTML") + ("h" "#+BEGIN_EXPORT html\n?\n#+END_EXPORT") ("H" "#+HTML: ") - ("a" "#+BEGIN_ASCII\n?\n#+END_ASCII") + ("a" "#+BEGIN_EXPORT ascii\n?\n#+END_EXPORT") ("A" "#+ASCII: ") ("i" "#+INDEX: ?") ("I" "#+INCLUDE: %file ?")) @@ -12349,7 +12246,7 @@ variable `org-mtags-prefer-muse-templates'." (list (string :tag "Key") (string :tag "Template"))) - :version "25.1" + :version "26.1" :package-version '(Org . "8.3")) (defun org-try-structure-completion () @@ -12377,18 +12274,18 @@ expands them." (setq ind (buffer-substring (point-at-bol) (point)))) (t (newline)))) (setq start (point)) - (if (string-match "%file" rpl) - (setq rpl (replace-match - (concat - "\"" - (save-match-data - (abbreviate-file-name (read-file-name "Include file: "))) - "\"") - t t rpl))) + (when (string-match "%file" rpl) + (setq rpl (replace-match + (concat + "\"" + (save-match-data + (abbreviate-file-name (read-file-name "Include file: "))) + "\"") + t t rpl))) (setq rpl (mapconcat 'identity (split-string rpl "\n") (concat "\n" ind))) (insert rpl) - (if (re-search-backward "\\?" start t) (delete-char 1)))) + (when (re-search-backward "\\?" start t) (delete-char 1)))) ;;;; TODO, DEADLINE, Comments @@ -12397,7 +12294,8 @@ expands them." (interactive) (save-excursion (org-back-to-heading) - (looking-at org-complex-heading-regexp) + (let ((case-fold-search nil)) + (looking-at org-complex-heading-regexp)) (goto-char (or (match-end 3) (match-end 2) (match-end 1))) (skip-chars-forward " \t") (unless (memq (char-before) '(?\s ?\t)) (insert " ")) @@ -12447,8 +12345,7 @@ nil or a string to be used for the todo mark." ) (if (eq major-mode 'org-agenda-mode) (apply 'org-agenda-todo-yesterday arg) (let* ((org-use-effective-time t) - (hour (third (decode-time - (org-current-time)))) + (hour (nth 2 (decode-time (org-current-time)))) (org-extend-today-until (1+ hour))) (org-todo arg)))) @@ -12462,44 +12359,49 @@ nil or a string to be used for the todo mark." ) (org-back-to-heading t) (let ((bound1 (point)) (bound0 (save-excursion (outline-next-heading) (point)))) - (when (re-search-forward - (concat "\\(" org-scheduled-time-regexp "\\)\\|\\(" - org-deadline-time-regexp "\\)\\|\\(" - org-ts-regexp "\\)") - bound0 t) - (if (re-search-backward "[ \t]+\\(?:[.+]\\)?\\+\\([0-9]+\\)[hdwmy]" bound1 t) - (replace-match "0" t nil nil 1)))))) - + (when (and (re-search-forward + (concat "\\(" org-scheduled-time-regexp "\\)\\|\\(" + org-deadline-time-regexp "\\)\\|\\(" + org-ts-regexp "\\)") + bound0 t) + (re-search-backward "[ \t]+\\(?:[.+]\\)?\\+\\([0-9]+\\)[hdwmy]" + bound1 t)) + (replace-match "0" t nil nil 1))))) + +(defvar org-state) ;; dynamically scoped into this function (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, like *** TODO Write paper *** DONE Call mom The different keywords are specified in the variable `org-todo-keywords'. -By default the available states are \"TODO\" and \"DONE\". -So for this example: when the item starts with TODO, it is changed to DONE. +By default the available states are \"TODO\" and \"DONE\". So, for this +example: when the item starts with TODO, it is changed to DONE. When it starts with DONE, the DONE is removed. And when neither TODO nor DONE are present, add TODO at the beginning of the heading. -With \\[universal-argument] prefix arg, use completion to determine the new \ +With `\\[universal-argument]' prefix ARG, use completion to determine the new \ state. -With numeric prefix arg, switch to that state. -With a double \\[universal-argument] prefix, switch to the next set of TODO \ +With numeric prefix ARG, switch to that state. +With a `\\[universal-argument] \\[universal-argument]' prefix, switch to the \ +next set of TODO \ keywords (nextset). -With a triple \\[universal-argument] prefix, circumvent any state blocking. +With a `\\[universal-argument] \\[universal-argument] \\[universal-argument]' \ +prefix, circumvent any state blocking. With a numeric prefix arg of 0, inhibit note taking for the change. With a numeric prefix arg of -1, cancel repeater to allow marking as DONE. When called through ELisp, arg is also interpreted in the following way: -'none -> empty state -\"\"(empty string) -> switch to empty state -'done -> switch to DONE -'nextset -> switch to the next set of keywords -'previousset -> switch to the previous set of keywords -\"WAITING\" -> switch to the specified keyword, but only if it - really is a member of `org-todo-keywords'." +`none' -> empty state +\"\" -> switch to empty state +`done' -> switch to DONE +`nextset' -> switch to the next set of keywords +`previousset' -> switch to the previous set of keywords +\"WAITING\" -> switch to the specified keyword, but only if it + really is a member of `org-todo-keywords'." (interactive "P") (if (and (org-region-active-p) org-loop-over-headlines-in-active-region) (let ((cl (if (eq org-loop-over-headlines-in-active-region 'start-level) @@ -12508,8 +12410,8 @@ When called through ELisp, arg is also interpreted in the following way: (org-map-entries `(org-todo ,arg) org-loop-over-headlines-in-active-region - cl (if (outline-invisible-p) (org-end-of-subtree nil t)))) - (if (equal arg '(16)) (setq arg 'nextset)) + cl (when (outline-invisible-p) (org-end-of-subtree nil t)))) + (when (equal arg '(16)) (setq arg 'nextset)) (when (equal arg -1) (org-cancel-repeater) (setq arg nil)) (let ((org-blocker-hook org-blocker-hook) commentp @@ -12526,7 +12428,7 @@ When called through ELisp, arg is also interpreted in the following way: (when (org-in-commented-heading-p t) (org-toggle-comment) (setq commentp t)) - (if (looking-at org-outline-regexp) (goto-char (1- (match-end 0)))) + (when (looking-at org-outline-regexp) (goto-char (1- (match-end 0)))) (or (looking-at (concat " +" org-todo-regexp "\\( +\\|[ \t]*$\\)")) (looking-at "\\(?: *\\|[ \t]*$\\)")) (let* ((match-data (match-data)) @@ -12562,16 +12464,15 @@ When called through ELisp, arg is also interpreted in the following way: (or (not org-use-fast-todo-selection) (not org-todo-key-trigger))) ;; Read a state with completion - (org-icompleting-read - "State: " (mapcar 'list org-todo-keywords-1) + (completing-read + "State: " (mapcar #'list org-todo-keywords-1) nil t)) ((eq arg 'right) (if this (if tail (car tail) nil) (car org-todo-keywords-1))) ((eq arg 'left) - (if (equal member org-todo-keywords-1) - nil + (unless (equal member org-todo-keywords-1) (if this (nth (- (length org-todo-keywords-1) (length tail) 2) @@ -12624,7 +12525,7 @@ When called through ELisp, arg is also interpreted in the following way: (org-with-wide-buffer (run-hook-with-args-until-failure 'org-blocker-hook change-plist)))) - (if (org-called-interactively-p 'interactive) + (if (called-interactively-p 'interactive) (user-error "TODO state change from %s to %s blocked (by \"%s\")" this org-state org-block-entry-blocking) ;; fail silently @@ -12660,8 +12561,8 @@ When called through ELisp, arg is also interpreted in the following way: ;; we need to look at recording a time and note (setq dolog (or (nth 1 (assoc org-state org-todo-log-states)) (nth 2 (assoc this org-todo-log-states)))) - (if (and (eq dolog 'note) (eq org-inhibit-logging 'note)) - (setq dolog 'time)) + (when (and (eq dolog 'note) (eq org-inhibit-logging 'note)) + (setq dolog 'time)) (when (or (and (not org-state) (not org-closed-keep-when-no-todo)) (and org-state (member org-state org-not-done-keywords) @@ -12672,19 +12573,19 @@ When called through ELisp, arg is also interpreted in the following way: (when (and now-done-p org-log-done) ;; It is now done, and it was not done before (org-add-planning-info 'closed (org-current-effective-time)) - (if (and (not dolog) (eq 'note org-log-done)) - (org-add-log-setup 'done org-state this 'findpos 'note))) + (when (and (not dolog) (eq 'note org-log-done)) + (org-add-log-setup 'done org-state this 'note))) (when (and org-state dolog) ;; This is a non-nil state, and we need to log it - (org-add-log-setup 'state org-state this 'findpos dolog))) + (org-add-log-setup 'state org-state this dolog))) ;; Fixup tag positioning (org-todo-trigger-tag-changes org-state) (and org-auto-align-tags (not org-setting-tags) (org-set-tags nil t)) (when org-provide-todo-statistics (org-update-parent-todo-statistics)) (run-hooks 'org-after-todo-state-change-hook) - (if (and arg (not (member org-state org-done-keywords))) - (setq head (org-get-todo-sequence-head org-state))) + (when (and arg (not (member org-state org-done-keywords))) + (setq head (org-get-todo-sequence-head org-state))) (put-text-property (point-at-bol) (point-at-eol) 'org-todo-head head) ;; Do we need to trigger a repeat? (when now-done-p @@ -12695,14 +12596,13 @@ When called through ELisp, arg is also interpreted in the following way: (org-get-heading)))) (org-auto-repeat-maybe org-state)) ;; Fixup cursor location if close to the keyword - (if (and (outline-on-heading-p) - (not (bolp)) - (save-excursion (beginning-of-line 1) - (looking-at org-todo-line-regexp)) - (< (point) (+ 2 (or (match-end 2) (match-end 1))))) - (progn - (goto-char (or (match-end 2) (match-end 1))) - (and (looking-at " ") (just-one-space)))) + (when (and (outline-on-heading-p) + (not (bolp)) + (save-excursion (beginning-of-line 1) + (looking-at org-todo-line-regexp)) + (< (point) (+ 2 (or (match-end 2) (match-end 1))))) + (goto-char (or (match-end 2) (match-end 1))) + (and (looking-at " ") (just-one-space))) (when org-trigger-hook (save-excursion (run-hook-with-args 'org-trigger-hook change-plist))) @@ -12744,10 +12644,10 @@ changes. Such blocking occurs when: (> child-level this-level)) ;; this todo has children, check whether they are all ;; completed - (if (and (not (org-entry-is-done-p)) - (org-entry-is-todo-p)) - (progn (setq org-block-entry-blocking (org-get-heading)) - (throw 'dont-block nil))) + (when (and (not (org-entry-is-done-p)) + (org-entry-is-todo-p)) + (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 @@ -12755,8 +12655,9 @@ changes. Such blocking occurs when: (save-excursion (org-back-to-heading t) (let* ((pos (point)) - (parent-pos (and (org-up-heading-safe) (point)))) - (if (not parent-pos) (throw 'dont-block t)) ; no parent + (parent-pos (and (org-up-heading-safe) (point))) + (case-fold-search nil)) + (unless 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)) @@ -12765,11 +12666,11 @@ changes. Such blocking occurs when: ;; Search further up the hierarchy, to see if an ancestor is blocked (while t (goto-char parent-pos) - (if (not (looking-at org-not-done-heading-regexp)) - (throw 'dont-block t)) ; do not block, parent is not a TODO + (unless (looking-at org-not-done-heading-regexp) + (throw 'dont-block t)) ; do not block, parent is not a TODO (setq pos (point)) (setq parent-pos (and (org-up-heading-safe) (point))) - (if (not parent-pos) (throw 'dont-block t)) ; no parent + (unless 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) @@ -12837,15 +12738,14 @@ changes because there are unchecked boxes in this entry." (outline-next-heading) (setq end (point)) (goto-char beg) - (if (org-list-search-forward - (concat (org-item-beginning-re) - "\\(?:\\[@\\(?:start:\\)?\\([0-9]+\\|[A-Za-z]\\)\\][ \t]*\\)?" - "\\[[- ]\\]") - end t) - (progn - (if (boundp 'org-blocked-by-checkboxes) - (setq org-blocked-by-checkboxes t)) - (throw 'dont-block nil))))) + (when (org-list-search-forward + (concat (org-item-beginning-re) + "\\(?:\\[@\\(?:start:\\)?\\([0-9]+\\|[A-Za-z]\\)\\][ \t]*\\)?" + "\\[[- ]\\]") + end t) + (when (boundp 'org-blocked-by-checkboxes) + (setq org-blocked-by-checkboxes t)) + (throw 'dont-block nil)))) t))) ; do not block (defun org-entry-blocked-p () @@ -12861,7 +12761,9 @@ changes because there are unchecked boxes in this entry." (defun org-update-statistics-cookies (all) "Update the statistics cookie, either from TODO or from checkboxes. -This should be called with the cursor in a line with a statistics cookie." +This should be called with the cursor in a line with a statistics +cookie. When called with a \\[universal-argument] prefix, update +all statistics cookies in the buffer." (interactive "P") (if all (progn @@ -12877,7 +12779,7 @@ This should be called with the cursor in a line with a statistics cookie." (setq l1 (org-outline-level)) (setq end (save-excursion (outline-next-heading) - (if (org-at-heading-p) (setq l2 (org-outline-level))) + (when (org-at-heading-p) (setq l2 (org-outline-level))) (point))) (if (and (save-excursion (re-search-forward @@ -12914,7 +12816,7 @@ statistics everywhere." (box-re "\\(\\(\\[[0-9]*%\\]\\)\\|\\(\\[[0-9]*/[0-9]*\\]\\)\\)") level ltoggle l1 new ndel (cnt-all 0) (cnt-done 0) is-percent kwd - checkbox-beg ov ovs ove cookie-present) + checkbox-beg cookie-present) (catch 'exit (save-excursion (beginning-of-line 1) @@ -12954,16 +12856,17 @@ statistics everywhere." (and (listp org-provide-todo-statistics) (stringp (car org-provide-todo-statistics)) (or (member kwd org-provide-todo-statistics) - (member kwd org-done-keywords))) + (member kwd org-done-keywords))) (and (listp org-provide-todo-statistics) (listp (car org-provide-todo-statistics)) (or (member kwd (car org-provide-todo-statistics)) (and (member kwd org-done-keywords) (member kwd (cadr org-provide-todo-statistics)))))) (setq cnt-all (1+ cnt-all)) - (if (eq org-provide-todo-statistics t) - (and kwd (setq cnt-all (1+ cnt-all))))) - (when (or (and (member org-provide-todo-statistics '(t all-headlines)) + (and (eq org-provide-todo-statistics t) + kwd + (setq cnt-all (1+ cnt-all)))) + (when (or (and (member org-provide-todo-statistics '(t all-headlines)) (member kwd org-done-keywords)) (and (listp org-provide-todo-statistics) (listp (car org-provide-todo-statistics)) @@ -12980,15 +12883,10 @@ statistics everywhere." (max 1 cnt-all))) (format "[%d/%d]" cnt-done cnt-all)) ndel (- (match-end 0) checkbox-beg)) - ;; handle overlays when updating cookie from column view - (when (setq ov (car (overlays-at checkbox-beg))) - (setq ovs (overlay-start ov) ove (overlay-end ov)) - (delete-overlay ov)) (goto-char checkbox-beg) (insert new) (delete-region (point) (+ (point) ndel)) - (when org-auto-align-tags (org-fix-tags-on-the-fly)) - (when ov (move-overlay ov ovs ove))) + (when org-auto-align-tags (org-fix-tags-on-the-fly))) (when cookie-present (run-hook-with-args 'org-after-todo-statistics-hook cnt-done (- cnt-all cnt-done)))))) @@ -13024,9 +12922,9 @@ This hook runs even if there is no statistics cookie present, in which case (when (and (stringp state) (> (length state) 0)) (setq changes (append changes (cdr (assoc state l))))) (when (member state org-not-done-keywords) - (setq changes (append changes (cdr (assoc 'todo l))))) + (setq changes (append changes (cdr (assq 'todo l))))) (when (member state org-done-keywords) - (setq changes (append changes (cdr (assoc 'done l))))) + (setq changes (append changes (cdr (assq 'done l))))) (dolist (c changes) (org-toggle-tag (car c) (if (cdr c) 'on 'off))))) @@ -13082,13 +12980,13 @@ Returns the new TODO keyword, or nil if no state change should occur." (set-buffer (get-buffer-create " *Org todo*")) (org-switch-to-buffer-other-window (get-buffer-create " *Org todo*"))) (erase-buffer) - (org-set-local 'org-done-keywords done-keywords) + (setq-local org-done-keywords done-keywords) (setq tbl fulltable cnt 0) (while (setq e (pop tbl)) (cond ((equal e '(:startgroup)) (push '() groups) (setq ingroup t) - (when (not (= cnt 0)) + (unless (= cnt 0) (setq cnt 0) (insert "\n")) (insert "{ ")) @@ -13096,7 +12994,7 @@ Returns the new TODO keyword, or nil if no state change should occur." (setq ingroup nil cnt 0) (insert "}\n")) ((equal e '(:newline)) - (when (not (= cnt 0)) + (unless (= cnt 0) (setq cnt 0) (insert "\n") (setq e (car tbl)) @@ -13105,19 +13003,19 @@ Returns the new TODO keyword, or nil if no state change should occur." (setq tbl (cdr tbl))))) (t (setq tg (car e) c (cdr e)) - (if ingroup (push tg (car groups))) + (when ingroup (push tg (car groups))) (setq tg (org-add-props tg nil 'face (org-get-todo-face tg))) - (if (and (= cnt 0) (not ingroup)) (insert " ")) + (when (and (= cnt 0) (not ingroup)) (insert " ")) (insert "[" c "] " tg (make-string (- fwidth 4 (length tg)) ?\ )) (when (= (setq cnt (1+ cnt)) ncol) (insert "\n") - (if ingroup (insert " ")) + (when ingroup (insert " ")) (setq cnt 0))))) (insert "\n") (goto-char (point-min)) - (if (not expert) (org-fit-window-to-buffer)) + (unless expert (org-fit-window-to-buffer)) (message "[a-z..]:Set [SPC]:clear") (setq c (let ((inhibit-quit t)) (read-char-exclusive))) (cond @@ -13139,7 +13037,7 @@ Returns the new TODO keyword, or nil if no state change should occur." "Return the TODO keyword of the current subtree." (save-excursion (org-back-to-heading t) - (and (looking-at org-todo-line-regexp) + (and (let ((case-fold-search nil)) (looking-at org-todo-line-regexp)) (match-end 2) (match-string 2)))) @@ -13168,16 +13066,27 @@ on INACTIVE-OK." (throw 'exit t))) nil))) -(defun org-get-repeat (&optional tagline) - "Check if there is a deadline/schedule with repeater in this entry." +(defun org-get-repeat (&optional timestamp) + "Check if there is a time-stamp with repeater in this entry. + +Return the repeater, as a string, or nil. Also return nil when +this function is called before first heading. + +When optional argument TIMESTAMP is a string, extract the +repeater from there instead." (save-match-data - (save-excursion - (org-back-to-heading t) - (and (re-search-forward (if tagline - (concat tagline "\\s-*" org-repeat-re) - org-repeat-re) - (org-entry-end-position) t) - (match-string-no-properties 1))))) + (cond (timestamp + (and (string-match org-repeat-re timestamp) + (match-string-no-properties 1 timestamp))) + ((org-before-first-heading-p) nil) + (t + (save-excursion + (org-back-to-heading t) + (let ((end (org-entry-end-position))) + (catch :repeat + (while (re-search-forward org-repeat-re end t) + (when (save-match-data (org-at-timestamp-p)) + (throw :repeat (match-string-no-properties 1))))))))))) (defvar org-last-changed-timestamp) (defvar org-last-inserted-timestamp) @@ -13186,11 +13095,12 @@ on INACTIVE-OK." (defvar org-log-note-how nil) (defvar org-log-note-extra) (defun org-auto-repeat-maybe (done-word) - "Check if the current headline contains a repeated deadline/schedule. + "Check if the current headline contains a repeated time-stamp. + If yes, set TODO state back to what it was and change the base date of repeating deadline/scheduled time stamps to new date. + This function is run automatically after each state change to a DONE state." - ;; last-state is dynamically scoped into this function (let* ((repeat (org-get-repeat)) (aa (assoc org-last-state org-todo-kwd-alist)) (interpret (nth 1 aa)) @@ -13199,80 +13109,121 @@ This function is run automatically after each state change to a DONE state." (msg "Entry repeats: ") (org-log-done nil) (org-todo-log-states nil) - re type n what ts time to-state) - (when (and repeat (not (zerop (string-to-number (substring repeat 1))))) - (if (eq org-log-repeat t) (setq org-log-repeat 'state)) - (setq to-state (or (org-entry-get nil "REPEAT_TO_STATE") - org-todo-repeat-to-state)) - (unless (and to-state (member to-state org-todo-keywords-1)) - (setq to-state (if (eq interpret 'type) org-last-state head))) - (org-todo to-state) - (when (or org-log-repeat (org-entry-get nil "CLOCK")) - (org-entry-put nil "LAST_REPEAT" (format-time-string - (org-time-stamp-format t t)))) - (when org-log-repeat - (if (or (memq 'org-add-log-note (default-value 'post-command-hook)) - (memq 'org-add-log-note post-command-hook)) - ;; OK, we are already setup for some record - (if (eq org-log-repeat 'note) - ;; make sure we take a note, not only a time stamp - (setq org-log-note-how 'note)) - ;; Set up for taking a record - (org-add-log-setup 'state (or done-word (car org-done-keywords)) - org-last-state - 'findpos org-log-repeat))) - (org-back-to-heading t) - (org-add-planning-info nil nil 'closed) - (setq re (concat "\\(" org-scheduled-time-regexp "\\)\\|\\(" - org-deadline-time-regexp "\\)\\|\\(" - org-ts-regexp "\\)")) - (while (re-search-forward - re (save-excursion (outline-next-heading) (point)) t) - (setq type (if (match-end 1) org-scheduled-string - (if (match-end 3) org-deadline-string "Plain:")) - ts (match-string (if (match-end 2) 2 (if (match-end 4) 4 0)))) - (when (string-match "\\([.+]\\)?\\(\\+[0-9]+\\)\\([hdwmy]\\)" ts) - (setq n (string-to-number (match-string 2 ts)) - 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))) - (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))) - (cond - ((equal (match-string 1 ts) ".") - ;; Shift starting date to today - (org-timestamp-change - (- (org-today) (time-to-days time)) - 'day)) - ((equal (match-string 1 ts) "+") - (let ((nshiftmax 10) (nshift 0)) - (while (or (= nshift 0) - (<= (time-to-days time) - (time-to-days (current-time)))) - (when (= (incf nshift) nshiftmax) - (or (y-or-n-p (message "%d repeater intervals were not enough to shift date past today. Continue? " nshift)) - (user-error "Abort"))) - (org-timestamp-change n (cdr (assoc what whata))) - (org-at-timestamp-p t) - (setq ts (match-string 1)) - (setq time (save-match-data (org-time-string-to-time ts))))) - (org-timestamp-change (- n) (cdr (assoc what whata))) - ;; rematch, so that we have everything in place for the real shift - (org-at-timestamp-p t) - (setq ts (match-string 1)) - (string-match "\\([.+]\\)?\\(\\+[0-9]+\\)\\([hdwmy]\\)" ts)))) - (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)))) + (end (copy-marker (org-entry-end-position)))) + (unwind-protect + (when (and repeat (not (zerop (string-to-number (substring repeat 1))))) + (when (eq org-log-repeat t) (setq org-log-repeat 'state)) + (let ((to-state (or (org-entry-get nil "REPEAT_TO_STATE" 'selective) + org-todo-repeat-to-state))) + (org-todo (cond + ((and to-state (member to-state org-todo-keywords-1)) + to-state) + ((eq interpret 'type) org-last-state) + (head) + (t 'none)))) + (org-back-to-heading t) + (org-add-planning-info nil nil 'closed) + ;; When `org-log-repeat' is non-nil or entry contains + ;; a clock, set LAST_REPEAT property. + (when (or org-log-repeat + (catch :clock + (while (re-search-forward org-clock-line-re end t) + (when (org-at-clock-log-p) (throw :clock t))))) + (org-entry-put nil "LAST_REPEAT" (format-time-string + (org-time-stamp-format t t) + (current-time)))) + (when org-log-repeat + (if (or (memq 'org-add-log-note (default-value 'post-command-hook)) + (memq 'org-add-log-note post-command-hook)) + ;; We are already setup for some record. + (when (eq org-log-repeat 'note) + ;; Make sure we take a note, not only a time stamp. + (setq org-log-note-how 'note)) + ;; Set up for taking a record. + (org-add-log-setup 'state + (or done-word (car org-done-keywords)) + org-last-state + org-log-repeat))) + (let ((planning-re (regexp-opt + (list org-scheduled-string org-deadline-string)))) + (while (re-search-forward org-ts-regexp end t) + (let* ((ts (match-string 0)) + (planning? (org-at-planning-p)) + (type (if (not planning?) "Plain:" + (save-excursion + (re-search-backward + planning-re (line-beginning-position) t) + (match-string 0))))) + (cond + ;; Ignore fake time-stamps (e.g., within comments). + ((not (org-at-timestamp-p t))) + ;; Time-stamps without a repeater are usually + ;; skipped. However, a SCHEDULED time-stamp without + ;; one is removed, as they are no longer relevant. + ((not (string-match "\\([.+]\\)?\\(\\+[0-9]+\\)\\([hdwmy]\\)" + ts)) + (when (equal type org-scheduled-string) + (org-remove-timestamp-with-keyword type))) + (t + (let ((n (string-to-number (match-string 2 ts))) + (what (match-string 3 ts))) + (when (equal what "w") (setq n (* n 7) what "d")) + (when (and (equal what "h") + (not (string-match-p "[0-9]\\{1,2\\}:[0-9]\\{2\\}" + ts))) + (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) + (let ((time (save-match-data + (org-time-string-to-time ts)))) + (cond + ((equal (match-string 1 ts) ".") + ;; Shift starting date to today + (org-timestamp-change + (- (org-today) (time-to-days time)) + 'day)) + ((equal (match-string 1 ts) "+") + (let ((nshiftmax 10) + (nshift 0)) + (while (or (= nshift 0) + (not (time-less-p (current-time) time))) + (when (= (cl-incf nshift) nshiftmax) + (or (y-or-n-p + (format "%d repeater intervals were not \ +enough to shift date past today. Continue? " + nshift)) + (user-error "Abort"))) + (org-timestamp-change n (cdr (assoc what whata))) + (org-in-regexp org-ts-regexp3) + (setq ts (match-string 1)) + (setq time + (save-match-data + (org-time-string-to-time ts))))) + (org-timestamp-change (- n) (cdr (assoc what whata))) + ;; Rematch, so that we have everything in place + ;; for the real shift. + (org-in-regexp org-ts-regexp3) + (setq ts (match-string 1)) + (string-match "\\([.+]\\)?\\(\\+[0-9]+\\)\\([hdwmy]\\)" + ts))))) + (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)) + (set-marker end nil)))) (defun org-show-todo-tree (arg) "Make a compact tree which shows all headlines marked with TODO. The tree will show the lines where the regexp matches, and all higher headlines above the match. -With a \\[universal-argument] prefix, prompt for a regexp to match. +With a `\\[universal-argument]' prefix, prompt for a regexp to match. With a numeric prefix N, construct a sparse tree for the Nth element of `org-todo-keywords-1'." (interactive "P") @@ -13280,8 +13231,9 @@ of `org-todo-keywords-1'." (kwd-re (cond ((null arg) org-not-done-regexp) ((equal arg '(4)) - (let ((kwd (org-icompleting-read "Keyword (or KWD1|KWD2|...): " - (mapcar 'list org-todo-keywords-1)))) + (let ((kwd + (completing-read "Keyword (or KWD1|KWD2|...): " + (mapcar #'list org-todo-keywords-1)))) (concat "\\(" (mapconcat 'identity (org-split-string kwd "|") "\\|") "\\)\\>"))) @@ -13292,6 +13244,83 @@ of `org-todo-keywords-1'." (message "%d TODO entries found" (org-occur (concat "^" org-outline-regexp " *" kwd-re ))))) +(defun org--deadline-or-schedule (arg type time) + "Insert DEADLINE or SCHEDULE information in current entry. +TYPE is either `deadline' or `scheduled'. See `org-deadline' or +`org-schedule' for information about ARG and TIME arguments." + (let* ((deadline? (eq type 'deadline)) + (keyword (if deadline? org-deadline-string org-scheduled-string)) + (log (if deadline? org-log-redeadline org-log-reschedule)) + (old-date (org-entry-get nil (if deadline? "DEADLINE" "SCHEDULED"))) + (old-date-time (and old-date (org-time-string-to-time old-date))) + ;; Save repeater cookie from either TIME or current scheduled + ;; time stamp. We are going to insert it back at the end of + ;; the process. + (repeater (or (and (org-string-nw-p time) + ;; We use `org-repeat-re' because we need + ;; to tell the difference between a real + ;; repeater and a time delta, e.g. "+2d". + (string-match org-repeat-re time) + (match-string 1 time)) + (and (org-string-nw-p old-date) + (string-match "\\([.+-]+[0-9]+[hdwmy]\ +\\(?:[/ ][-+]?[0-9]+[hdwmy]\\)?\\)" + old-date) + (match-string 1 old-date))))) + (pcase arg + (`(4) + (when (and old-date log) + (org-add-log-setup (if deadline? 'deldeadline 'delschedule) + nil old-date log)) + (org-remove-timestamp-with-keyword keyword) + (message (if deadline? "Item no longer has a deadline." + "Item is no longer scheduled."))) + (`(16) + (save-excursion + (org-back-to-heading t) + (let ((regexp (if deadline? org-deadline-time-regexp + org-scheduled-time-regexp))) + (if (not (re-search-forward regexp (line-end-position 2) t)) + (user-error (if deadline? "No deadline information to update" + "No scheduled information to update")) + (let* ((rpl0 (match-string 1)) + (rpl (replace-regexp-in-string " -[0-9]+[hdwmy]" "" rpl0)) + (msg (if deadline? "Warn starting from" "Delay until"))) + (replace-match + (concat keyword + " <" rpl + (format " -%dd" + (abs (- (time-to-days + (save-match-data + (org-read-date + nil t nil msg old-date-time))) + (time-to-days old-date-time)))) + ">") t t)))))) + (_ + (org-add-planning-info type time 'closed) + (when (and old-date + log + (not (equal old-date org-last-inserted-timestamp))) + (org-add-log-setup (if deadline? 'redeadline 'reschedule) + org-last-inserted-timestamp + old-date + log)) + (when repeater + (save-excursion + (org-back-to-heading t) + (when (re-search-forward + (concat keyword " " org-last-inserted-timestamp) + (line-end-position 2) + t) + (goto-char (1- (match-end 0))) + (insert " " repeater) + (setq org-last-inserted-timestamp + (concat (substring org-last-inserted-timestamp 0 -1) + " " repeater + (substring org-last-inserted-timestamp -1)))))) + (message (if deadline? "Deadline on %s" "Scheduled to %s") + org-last-inserted-timestamp))))) + (defun org-deadline (arg &optional time) "Insert the \"DEADLINE:\" string with a timestamp to make a deadline. With one universal prefix argument, remove any deadline from the item. @@ -13300,68 +13329,14 @@ 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") (if (and (org-region-active-p) org-loop-over-headlines-in-active-region) - (let ((cl (if (eq org-loop-over-headlines-in-active-region 'start-level) - 'region-start-level 'region)) - org-loop-over-headlines-in-active-region) - (org-map-entries - `(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)))) - (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 org-last-inserted-timestamp))) - (org-add-log-setup - 'redeadline org-last-inserted-timestamp old-date 'findpos - org-log-redeadline)) - (when repeater - (save-excursion - (org-back-to-heading t) - (when (re-search-forward (concat org-deadline-string " " - org-last-inserted-timestamp) - (save-excursion - (outline-next-heading) (point)) t) - (goto-char (1- (match-end 0))) - (insert " " repeater) - (setq org-last-inserted-timestamp - (concat (substring org-last-inserted-timestamp 0 -1) - " " repeater - (substring org-last-inserted-timestamp -1)))))) - (message "Deadline on %s" org-last-inserted-timestamp)))))) + (org-map-entries + (lambda () (org--deadline-or-schedule arg 'deadline time)) + nil + (if (eq org-loop-over-headlines-in-active-region 'start-level) + 'region-start-level + 'region) + (lambda () (when (outline-invisible-p) (org-end-of-subtree nil t)))) + (org--deadline-or-schedule arg 'deadline time))) (defun org-schedule (arg &optional time) "Insert the SCHEDULED: string with a timestamp to schedule a TODO item. @@ -13371,69 +13346,14 @@ 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") (if (and (org-region-active-p) org-loop-over-headlines-in-active-region) - (let ((cl (if (eq org-loop-over-headlines-in-active-region 'start-level) - 'region-start-level 'region)) - org-loop-over-headlines-in-active-region) - (org-map-entries - `(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)))) - (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 org-last-inserted-timestamp))) - (org-add-log-setup - 'reschedule org-last-inserted-timestamp old-date 'findpos - org-log-reschedule)) - (when repeater - (save-excursion - (org-back-to-heading t) - (when (re-search-forward (concat org-scheduled-string " " - org-last-inserted-timestamp) - (save-excursion - (outline-next-heading) (point)) t) - (goto-char (1- (match-end 0))) - (insert " " repeater) - (setq org-last-inserted-timestamp - (concat (substring org-last-inserted-timestamp 0 -1) - " " repeater - (substring org-last-inserted-timestamp -1)))))) - (message "Scheduled to %s" org-last-inserted-timestamp)))))) + (org-map-entries + (lambda () (org--deadline-or-schedule arg 'scheduled time)) + nil + (if (eq org-loop-over-headlines-in-active-region 'start-level) + 'region-start-level + 'region) + (lambda () (when (outline-invisible-p) (org-end-of-subtree nil t)))) + (org--deadline-or-schedule arg 'scheduled time))) (defun org-get-scheduled-time (pom &optional inherit) "Get the scheduled time as a time tuple, of a format suitable @@ -13464,10 +13384,10 @@ nil." (if (and (string-match "\\S-" (buffer-substring (point-at-bol) (point))) (equal (char-before) ?\ )) (backward-delete-char 1) - (if (string-match "^[ \t]*$" (buffer-substring - (point-at-bol) (point-at-eol))) - (delete-region (point-at-bol) - (min (point-max) (1+ (point-at-eol)))))))))) + (when (string-match "^[ \t]*$" (buffer-substring + (point-at-bol) (point-at-eol))) + (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 @@ -13478,7 +13398,7 @@ nil." ;; planning info location is fixed in the section. (org-with-wide-buffer (beginning-of-line) - (and (org-looking-at-p org-planning-line-re) + (and (looking-at-p org-planning-line-re) (eq (point) (ignore-errors (if (and (featurep 'org-inlinetask) (org-inlinetask-in-task-p)) @@ -13526,40 +13446,48 @@ WHAT entry will also be removed." (org-back-to-heading t) (forward-line) (unless (bolp) (insert "\n")) - (cond ((org-looking-at-p org-planning-line-re) + (cond ((looking-at-p org-planning-line-re) ;; Move to current indentation. (skip-chars-forward " \t") ;; Check if we have to remove something. (dolist (type (if what (cons what remove) remove)) (save-excursion (when (re-search-forward - (concat - " *" - (case type - (closed org-closed-time-regexp) - (deadline org-deadline-time-regexp) - (scheduled org-scheduled-time-regexp) - (otherwise - (error "Invalid planning type: %s" type)))) + (cl-case type + (closed org-closed-time-regexp) + (deadline org-deadline-time-regexp) + (scheduled org-scheduled-time-regexp) + (otherwise + (error "Invalid planning type: %s" type))) (line-end-position) t) - (replace-match "") - (when (looking-at "--+<[^>]+>") (replace-match "")) - (when (and (not what) (eq type 'closed)) - (save-excursion - (beginning-of-line) - (when (looking-at "[ \t]*$") - (delete-region (point) - (line-beginning-position 2))))))) - ;; Remove leading white spaces. - (when (looking-at "[ \t]+") (replace-match "")))) + ;; Delete until next keyword or end of line. + (delete-region + (match-beginning 0) + (if (re-search-forward org-keyword-time-not-clock-regexp + (line-end-position) + t) + (match-beginning 0) + (line-end-position)))))) + ;; If there is nothing more to add and no more keyword + ;; is left, remove the line completely. + (if (and (looking-at-p "[ \t]*$") (not what)) + (delete-region (line-beginning-position) + (line-beginning-position 2)) + ;; If we removed last keyword, do not leave trailing + ;; white space at the end of line. + (let ((p (point))) + (save-excursion + (end-of-line) + (unless (= (skip-chars-backward " \t" p) 0) + (delete-region (point) (line-end-position))))))) ((not what) (throw 'exit nil)) ; Nothing to do. (t (insert-before-markers "\n") (backward-char 1) (when org-adapt-indentation - (org-indent-to-column (1+ (org-outline-level)))))) + (indent-to-column (1+ (org-outline-level)))))) (when what ;; Insert planning keyword. - (insert (case what + (insert (cl-case what (closed org-closed-string) (deadline org-deadline-string) (scheduled org-scheduled-string) @@ -13575,7 +13503,8 @@ WHAT entry will also be removed." (unless (eolp) (insert " ")) ts)))))) -(defvar org-log-note-marker (make-marker)) +(defvar org-log-note-marker (make-marker) + "Marker pointing at the entry where the note is to be inserted.") (defvar org-log-note-purpose nil) (defvar org-log-note-state nil) (defvar org-log-note-previous-state nil) @@ -13584,8 +13513,7 @@ WHAT entry will also be removed." (defvar org-log-note-return-to (make-marker)) (defvar org-log-note-effective-time nil "Remembered current time so that dynamically scoped -`org-extend-today-until' affects tha timestamps in state change -log") +`org-extend-today-until' affects timestamps in state change log") (defvar org-log-post-message nil "Message to be displayed after a log note has been stored. @@ -13595,7 +13523,7 @@ The auto-repeater uses this.") "Add a note to the current entry. This is done in the same way as adding a state change note." (interactive) - (org-add-log-setup 'note nil nil 'findpos nil)) + (org-add-log-setup 'note)) (defun org-log-beginning (&optional create) "Return expected start of log notes in current entry. @@ -13603,13 +13531,13 @@ When optional argument CREATE is non-nil, the function creates a drawer to store notes, if necessary. Returned position ignores narrowing." (org-with-wide-buffer - (org-end-of-meta-data) - (let ((end (if (org-at-heading-p) (point) - (save-excursion (outline-next-heading) (point)))) - (drawer (org-log-into-drawer))) + (let ((drawer (org-log-into-drawer))) (cond (drawer + (org-end-of-meta-data) (let ((regexp (concat "^[ \t]*:" (regexp-quote drawer) ":[ \t]*$")) + (end (if (org-at-heading-p) (point) + (save-excursion (outline-next-heading) (point)))) (case-fold-search t)) (catch 'exit ;; Try to find existing drawer. @@ -13627,38 +13555,29 @@ narrowing." (insert ":" drawer ":\n:END:\n") (org-indent-region beg (point))) (end-of-line -1))))) - (org-log-state-notes-insert-after-drawers - (while (and (looking-at org-drawer-regexp) - (progn (goto-char (match-end 0)) - (re-search-forward org-property-end-re end t))) + (t + (org-end-of-meta-data org-log-state-notes-insert-after-drawers) + (skip-chars-forward " \t\n") + (beginning-of-line) + (unless org-log-states-order-reversed + (org-skip-over-state-notes) + (skip-chars-backward " \t\n") (forward-line))))) (if (bolp) (point) (line-beginning-position 2)))) -(defun org-add-log-setup (&optional purpose state prev-state findpos how extra) +(defun org-add-log-setup (&optional purpose state prev-state how extra) "Set up the post command hook to take a note. If this is about to TODO state change, the new state is expected in STATE. -When FINDPOS is non-nil, find the correct position for the note in -the current entry. If not, assume that it can be inserted at point. HOW is an indicator what kind of note should be created. EXTRA is additional text that will be inserted into the notes buffer." - (org-with-wide-buffer - (when findpos - (goto-char (org-log-beginning t)) - (unless org-log-states-order-reversed - (org-skip-over-state-notes) - (skip-chars-backward " \t\n\r") - (forward-line))) - (move-marker org-log-note-marker (point)) - ;; Preserve position even if a property drawer is inserted in the - ;; process. - (set-marker-insertion-type org-log-note-marker t) - (setq org-log-note-purpose purpose - org-log-note-state state - org-log-note-previous-state prev-state - org-log-note-how how - org-log-note-extra extra - org-log-note-effective-time (org-current-effective-time)) - (add-hook 'post-command-hook 'org-add-log-note 'append))) + (move-marker org-log-note-marker (point)) + (setq org-log-note-purpose purpose + org-log-note-state state + org-log-note-previous-state prev-state + org-log-note-how how + org-log-note-extra extra + org-log-note-effective-time (org-current-effective-time)) + (add-hook 'post-command-hook 'org-add-log-note 'append)) (defun org-skip-over-state-notes () "Skip past the list of State notes in an entry." @@ -13679,17 +13598,17 @@ EXTRA is additional text that will be inserted into the notes buffer." ("%T" . ,org-ts-regexp) ("%u" . ".*?") ("%U" . ".*?"))))))) - (while (org-looking-at-p regexp) + (while (looking-at-p regexp) (goto-char (or (org-list-get-next-item (point) struct prevs) (org-list-get-item-end (point) struct))))))) -(defun org-add-log-note (&optional purpose) - "Pop up a window for taking a note, and add this note later at point." +(defun org-add-log-note (&optional _purpose) + "Pop up a window for taking a note, and add this note later." (remove-hook 'post-command-hook 'org-add-log-note) (setq org-log-note-window-configuration (current-window-configuration)) (delete-other-windows) (move-marker org-log-note-return-to (point)) - (org-pop-to-buffer-same-window (marker-buffer org-log-note-marker)) + (pop-to-buffer-same-window (marker-buffer org-log-note-marker)) (goto-char org-log-note-marker) (org-switch-to-buffer-other-window "*Org Note*") (erase-buffer) @@ -13718,100 +13637,102 @@ EXTRA is additional text that will be inserted into the notes buffer." ((eq org-log-note-purpose 'note) "this entry") (t (error "This should not happen"))))) - (if org-log-note-extra (insert org-log-note-extra)) - (org-set-local 'org-finish-function 'org-store-log-note) + (when org-log-note-extra (insert org-log-note-extra)) + (setq-local org-finish-function 'org-store-log-note) (run-hooks 'org-log-buffer-setup-hook))) (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))) - (kill-buffer (current-buffer)) - (let ((note (cdr (assq org-log-note-purpose org-log-note-headings))) lines) - (while (string-match "\\`# .*\n[ \t\n]*" txt) - (setq txt (replace-match "" t t txt))) - (if (string-match "\\s-+\\'" txt) - (setq txt (replace-match "" t t txt))) - (setq lines (org-split-string txt "\n")) - (when (and note (string-match "\\S-" note)) - (setq note - (org-replace-escapes - note - (list (cons "%u" (user-login-name)) - (cons "%U" user-full-name) - (cons "%t" (format-time-string - (org-time-stamp-format 'long 'inactive) - org-log-note-effective-time)) - (cons "%T" (format-time-string - (org-time-stamp-format 'long nil) - org-log-note-effective-time)) - (cons "%d" (format-time-string - (org-time-stamp-format nil 'inactive) - org-log-note-effective-time)) - (cons "%D" (format-time-string - (org-time-stamp-format nil nil) - org-log-note-effective-time)) - (cons "%s" (cond - ((not org-log-note-state) "") - ((org-string-match-p org-ts-regexp - org-log-note-state) - (format "\"[%s]\"" - (substring org-log-note-state 1 -1))) - (t (format "\"%s\"" org-log-note-state)))) - (cons "%S" - (cond - ((not org-log-note-previous-state) "") - ((org-string-match-p org-ts-regexp - org-log-note-previous-state) - (format "\"[%s]\"" - (substring - org-log-note-previous-state 1 -1))) - (t (format "\"%s\"" - org-log-note-previous-state))))))) - (when lines (setq note (concat note " \\\\"))) - (push note lines)) - (when (or current-prefix-arg org-note-abort) - (when (org-log-into-drawer) - (org-remove-empty-drawer-at org-log-note-marker)) - (setq lines nil)) - (when lines - (with-current-buffer (marker-buffer org-log-note-marker) - (org-with-wide-buffer - (goto-char org-log-note-marker) - (move-marker org-log-note-marker nil) - ;; Make sure point is at the beginning of an empty line. - (cond ((not (bolp)) (let ((inhibit-read-only t)) (insert "\n"))) - ((looking-at "[ \t]*\\S-") (save-excursion (insert "\n")))) - ;; In an existing list, add a new item at the top level. - ;; Otherwise, indent line like a regular one. - (let ((itemp (org-in-item-p))) - (if itemp - (org-indent-line-to - (let ((struct (save-excursion - (goto-char itemp) (org-list-struct)))) - (org-list-get-ind (org-list-get-top-point struct) struct))) - (org-indent-line))) - (insert (org-list-bullet-string "-") (pop lines)) - (let ((ind (org-list-item-body-column (line-beginning-position)))) - (dolist (line lines) - (insert "\n") - (org-indent-line-to ind) - (insert line))) - (message "Note stored") - (org-back-to-heading t) - (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 ((txt (prog1 (buffer-string) + (kill-buffer))) + (note (cdr (assq org-log-note-purpose org-log-note-headings))) + lines) + (while (string-match "\\`# .*\n[ \t\n]*" txt) + (setq txt (replace-match "" t t txt))) + (when (string-match "\\s-+\\'" txt) + (setq txt (replace-match "" t t txt))) + (setq lines (org-split-string txt "\n")) + (when (org-string-nw-p note) + (setq note + (org-replace-escapes + note + (list (cons "%u" (user-login-name)) + (cons "%U" user-full-name) + (cons "%t" (format-time-string + (org-time-stamp-format 'long 'inactive) + org-log-note-effective-time)) + (cons "%T" (format-time-string + (org-time-stamp-format 'long nil) + org-log-note-effective-time)) + (cons "%d" (format-time-string + (org-time-stamp-format nil 'inactive) + org-log-note-effective-time)) + (cons "%D" (format-time-string + (org-time-stamp-format nil nil) + org-log-note-effective-time)) + (cons "%s" (cond + ((not org-log-note-state) "") + ((string-match-p org-ts-regexp + org-log-note-state) + (format "\"[%s]\"" + (substring org-log-note-state 1 -1))) + (t (format "\"%s\"" org-log-note-state)))) + (cons "%S" + (cond + ((not org-log-note-previous-state) "") + ((string-match-p org-ts-regexp + org-log-note-previous-state) + (format "\"[%s]\"" + (substring + org-log-note-previous-state 1 -1))) + (t (format "\"%s\"" + org-log-note-previous-state))))))) + (when lines (setq note (concat note " \\\\"))) + (push note lines)) + (when (and lines (not (or current-prefix-arg org-note-abort))) + (with-current-buffer (marker-buffer org-log-note-marker) + (org-with-wide-buffer + ;; Find location for the new note. + (goto-char org-log-note-marker) + (set-marker org-log-note-marker nil) + ;; Note associated to a clock is to be located right after + ;; the clock. Do not move point. + (unless (eq org-log-note-purpose 'clock-out) + (goto-char (org-log-beginning t))) + ;; Make sure point is at the beginning of an empty line. + (cond ((not (bolp)) (let ((inhibit-read-only t)) (insert "\n"))) + ((looking-at "[ \t]*\\S-") (save-excursion (insert "\n")))) + ;; In an existing list, add a new item at the top level. + ;; Otherwise, indent line like a regular one. + (let ((itemp (org-in-item-p))) + (if itemp + (indent-line-to + (let ((struct (save-excursion + (goto-char itemp) (org-list-struct)))) + (org-list-get-ind (org-list-get-top-point struct) struct))) + (org-indent-line))) + (insert (org-list-bullet-string "-") (pop lines)) + (let ((ind (org-list-item-body-column (line-beginning-position)))) + (dolist (line lines) + (insert "\n") + (indent-line-to ind) + (insert line))) + (message "Note stored") + (org-back-to-heading t) + (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)))) + (when org-log-post-message (message "%s" org-log-post-message)))) (defun org-remove-empty-drawer-at (pos) "Remove an empty drawer at position POS. @@ -13847,10 +13768,10 @@ D Show deadlines and scheduled items between a date range." (interactive "P") (setq type (or type org-sparse-tree-default-date-type)) (setq org-ts-type type) - (message "Sparse tree: [/]regexp [t]odo [T]odo-kwd [m]atch [p]roperty - [d]eadlines [b]efore-date [a]fter-date [D]ates range - [c]ycle through date types: %s" - (case type + (message "Sparse tree: [r]egexp [t]odo [T]odo-kwd [m]atch [p]roperty + \[d]eadlines [b]efore-date [a]fter-date [D]ates range + \[c]ycle through date types: %s" + (cl-case type (all "all timestamps") (scheduled "only scheduled") (deadline "only deadline") @@ -13859,7 +13780,7 @@ D Show deadlines and scheduled items between a date range." (closed "with a closed time-stamp") (otherwise "scheduled/deadline"))) (let ((answer (read-char-exclusive))) - (case answer + (cl-case answer (?c (org-sparse-tree arg @@ -13873,20 +13794,19 @@ D Show deadlines and scheduled items between a date range." (?T (org-show-todo-tree '(4))) (?m (call-interactively 'org-match-sparse-tree)) ((?p ?P) - (let* ((kwd (org-icompleting-read - "Property: " (mapcar 'list (org-buffer-property-keys)))) - (value (org-icompleting-read - "Value: " (mapcar 'list (org-property-values kwd))))) + (let* ((kwd (completing-read + "Property: " (mapcar #'list (org-buffer-property-keys)))) + (value (completing-read + "Value: " (mapcar #'list (org-property-values kwd))))) (unless (string-match "\\`{.*}\\'" value) (setq value (concat "\"" value "\""))) (org-match-sparse-tree arg (concat kwd "=" value)))) ((?r ?R ?/) (call-interactively 'org-occur)) (otherwise (user-error "No such sparse tree command \"%c\"" answer))))) -(defvar org-occur-highlights nil +(defvar-local org-occur-highlights nil "List of overlays used for occur matches.") -(make-variable-buffer-local 'org-occur-highlights) -(defvar org-occur-parameters nil +(defvar-local org-occur-parameters nil "Parameters of the active org-occur calls. This is a list, each call to org-occur pushes as cons cell, containing the regular expression and the callback, onto the list. @@ -13896,18 +13816,21 @@ will only contain one set of parameters. When the highlights are removed (for example with `C-c C-c', or with the next edit (depending on `org-remove-highlights-with-change'), this variable is emptied as well.") -(make-variable-buffer-local 'org-occur-parameters) (defun org-occur (regexp &optional keep-previous callback) "Make a compact tree which shows all matches of REGEXP. -The tree will show the lines where the regexp matches, and all higher -headlines above the match. It will also show the heading after the match, -to make sure editing the matching entry is easy. -If KEEP-PREVIOUS is non-nil, highlighting and exposing done by a previous -call to `org-occur' will be kept, to allow stacking of calls to this -command. -If CALLBACK is non-nil, it is a function which is called to confirm -that the match should indeed be shown." + +The tree will show the lines where the regexp matches, and any other context +defined in `org-show-context-detail', which see. + +When optional argument KEEP-PREVIOUS is non-nil, highlighting and exposing +done by a previous call to `org-occur' will be kept, to allow stacking of +calls to this command. + +Optional argument CALLBACK can be a function of no argument. In this case, +it is called with point at the end of the match, match data being set +accordingly. Current match is shown only if the return value is non-nil. +The function must neither move point nor alter narrowing." (interactive "sRegexp: \nP") (when (equal regexp "") (user-error "Regexp cannot be empty")) @@ -13917,33 +13840,35 @@ that the match should indeed be shown." (let ((cnt 0)) (save-excursion (goto-char (point-min)) - (if (or (not keep-previous) ; do not want to keep - (not org-occur-highlights)) ; no previous matches - ;; hide everything - (org-overview)) - (while (re-search-forward regexp nil t) - (backward-char) ;; FIXME: Match timestamps at the end of a headline - (when (or (not callback) - (save-match-data (funcall callback))) - (setq cnt (1+ cnt)) - (when org-highlight-sparse-tree-matches - (org-highlight-new-match (match-beginning 0) (match-end 0))) - (org-show-context 'occur-tree)))) + (when (or (not keep-previous) ; do not want to keep + (not org-occur-highlights)) ; no previous matches + ;; hide everything + (org-overview)) + (let ((case-fold-search (if (eq org-occur-case-fold-search 'smart) + (isearch-no-upper-case-p regexp t) + org-occur-case-fold-search))) + (while (re-search-forward regexp nil t) + (when (or (not callback) + (save-match-data (funcall callback))) + (setq cnt (1+ cnt)) + (when org-highlight-sparse-tree-matches + (org-highlight-new-match (match-beginning 0) (match-end 0))) + (org-show-context 'occur-tree))))) (when org-remove-highlights-with-change - (org-add-hook 'before-change-functions 'org-remove-occur-highlights - nil 'local)) + (add-hook 'before-change-functions 'org-remove-occur-highlights + nil 'local)) (unless org-sparse-tree-open-archived-trees (org-hide-archived-subtrees (point-min) (point-max))) (run-hooks 'org-occur-hook) - (if (org-called-interactively-p 'interactive) - (message "%d match(es) for regexp %s" cnt regexp)) + (when (called-interactively-p 'interactive) + (message "%d match(es) for regexp %s" cnt regexp)) cnt)) -(defun org-occur-next-match (&optional n reset) +(defun org-occur-next-match (&optional n _reset) "Function for `next-error-function' to find sparse tree matches. N is the number of matches to move, when negative move backwards. -RESET is entirely ignored - this function always goes back to the -starting point when no match is found." +This function always goes back to the starting point when no +match is found." (let* ((limit (if (< n 0) (point-min) (point-max))) (search-func (if (< n 0) 'previous-single-char-property-change @@ -13980,28 +13905,33 @@ be shown." DETAIL is either nil, `minimal', `local', `ancestors', `lineage', `tree', `canonical' or t. See `org-show-context-detail' for more information." - (unless (org-before-first-heading-p) - ;; Show current heading and possibly its entry, following headline - ;; or all children. - (if (and (org-at-heading-p) (not (eq detail 'local))) - (org-flag-heading nil) - (org-show-entry) + ;; Show current heading and possibly its entry, following headline + ;; or all children. + (if (and (org-at-heading-p) (not (eq detail 'local))) + (org-flag-heading nil) + (org-show-entry) + ;; If point is hidden within a drawer or a block, make sure to + ;; expose it. + (dolist (o (overlays-at (point))) + (when (memq (overlay-get o 'invisible) '(org-hide-block outline)) + (delete-overlay o))) + (unless (org-before-first-heading-p) (org-with-limited-levels - (case detail - ((tree canonical t) (show-children)) + (cl-case detail + ((tree canonical t) (org-show-children)) ((nil minimal ancestors)) (t (save-excursion (outline-next-heading) - (org-flag-heading nil)))))) - ;; Show all siblings. - (when (eq detail 'lineage) (org-show-siblings)) - ;; Show ancestors, possibly with their children. - (when (memq detail '(ancestors lineage tree canonical t)) - (save-excursion - (while (org-up-heading-safe) - (org-flag-heading nil) - (when (memq detail '(canonical t)) (org-show-entry)) - (when (memq detail '(tree canonical t)) (show-children))))))) + (org-flag-heading nil))))))) + ;; Show all siblings. + (when (eq detail 'lineage) (org-show-siblings)) + ;; Show ancestors, possibly with their children. + (when (memq detail '(ancestors lineage tree canonical t)) + (save-excursion + (while (org-up-heading-safe) + (org-flag-heading nil) + (when (memq detail '(canonical t)) (org-show-entry)) + (when (memq detail '(tree canonical t)) (org-show-children)))))) (defvar org-reveal-start-hook nil "Hook run before revealing a location.") @@ -14016,9 +13946,8 @@ With optional argument SIBLINGS, on each level of the hierarchy all siblings are shown. This repairs the tree structure to what it would look like when opened with hierarchical calls to `org-cycle'. -With double optional argument \\[universal-argument] \\[universal-argument], \ -go to the parent and show the -entire tree." +With a \\[universal-argument] \\[universal-argument] prefix, \ +go to the parent and show the entire tree." (interactive "P") (run-hooks 'org-reveal-start-hook) (cond ((equal siblings '(4)) (org-show-set-visibility 'canonical)) @@ -14036,13 +13965,13 @@ entire tree." (overlay-put ov 'org-type 'org-occur) (push ov org-occur-highlights))) -(defun org-remove-occur-highlights (&optional beg end noremove) +(defun org-remove-occur-highlights (&optional _beg _end noremove) "Remove the occur highlights from the buffer. BEG and END are ignored. If NOREMOVE is nil, remove this function from the `before-change-functions' in the current buffer." (interactive) (unless org-inhibit-highlight-removal - (mapc 'delete-overlay org-occur-highlights) + (mapc #'delete-overlay org-occur-highlights) (setq org-occur-highlights nil) (setq org-occur-parameters nil) (unless noremove @@ -14066,7 +13995,7 @@ from the `before-change-functions' in the current buffer." (interactive) (org-priority 'down)) -(defun org-priority (&optional action show) +(defun org-priority (&optional action _show) "Change the priority of an item. ACTION can be `set', `up', `down', or a character." (interactive "P") @@ -14078,23 +14007,23 @@ ACTION can be `set', `up', `down', or a character." (let (current new news have remove) (save-excursion (org-back-to-heading t) - (if (looking-at org-priority-regexp) - (setq current (string-to-char (match-string 2)) - have t)) + (when (looking-at org-priority-regexp) + (setq current (string-to-char (match-string 2)) + have t)) (cond ((eq action 'remove) (setq remove t new ?\ )) ((or (eq action 'set) - (if (featurep 'xemacs) (characterp action) (integerp action))) + (integerp action)) (if (not (eq action 'set)) (setq new action) (message "Priority %c-%c, SPC to remove: " org-highest-priority org-lowest-priority) (save-match-data (setq new (read-char-exclusive)))) - (if (and (= (upcase org-highest-priority) org-highest-priority) - (= (upcase org-lowest-priority) org-lowest-priority)) - (setq new (upcase new))) + (when (and (= (upcase org-highest-priority) org-highest-priority) + (= (upcase org-lowest-priority) org-lowest-priority)) + (setq new (upcase new))) (cond ((equal new ?\ ) (setq remove t)) ((or (< (upcase new) org-highest-priority) (> (upcase new) org-lowest-priority)) (user-error "Priority must be between `%c' and `%c'" @@ -14120,16 +14049,16 @@ ACTION can be `set', `up', `down', or a character." org-default-priority (1+ org-default-priority)))))) (t (user-error "Invalid action"))) - (if (or (< (upcase new) org-highest-priority) - (> (upcase new) org-lowest-priority)) - (if (and (memq action '(up down)) - (not have) (not (eq last-command this-command))) - ;; `new' is from default priority - (error - "The default can not be set, see `org-default-priority' why") - ;; normal cycling: `new' is beyond highest/lowest priority - ;; and is wrapped around to the empty priority - (setq remove t))) + (when (or (< (upcase new) org-highest-priority) + (> (upcase new) org-lowest-priority)) + (if (and (memq action '(up down)) + (not have) (not (eq last-command this-command))) + ;; `new' is from default priority + (error + "The default can not be set, see `org-default-priority' why") + ;; normal cycling: `new' is beyond highest/lowest priority + ;; and is wrapped around to the empty priority + (setq remove t))) (setq news (format "%c" new)) (if have (if remove @@ -14137,8 +14066,7 @@ ACTION can be `set', `up', `down', or a character." (replace-match news t t nil 2)) (if remove (user-error "No priority cookie found in line") - (let ((case-fold-search nil)) - (looking-at org-todo-line-regexp)) + (let ((case-fold-search nil)) (looking-at org-todo-line-regexp)) (if (match-end 2) (progn (goto-char (match-end 2)) @@ -14183,6 +14111,7 @@ Can be set by the action argument to `org-scan-tags' and `org-map-entries'.") (defvar org-scanner-tags nil "The current tag list while the tags scanner is running.") + (defvar org-trust-scanner-tags nil "Should `org-get-tags-at' use the tags for the scanner. This is for internal dynamical scoping only. @@ -14194,6 +14123,8 @@ obtain a list of properties. Building the tags list for each entry in such a file becomes an N^2 operation - but with this variable set, it scales as N.") +(defvar org--matcher-tags-todo-only nil) + (defun org-scan-tags (action matcher todo-only &optional start-level) "Scan headline tags with inheritance and produce output ACTION. @@ -14202,11 +14133,14 @@ or `agenda' to produce an entry list for an agenda view. It can also be a Lisp form or a function that should be called at each matched headline, in this case the return value is a list of all return values from these calls. -MATCHER is a Lisp form to be evaluated, testing if a given set of tags -qualifies a headline for inclusion. When TODO-ONLY is non-nil, -only lines with a not-done TODO keyword are included in the output. -This should be the same variable that was scoped into -and set by `org-make-tags-matcher' when it constructed MATCHER. +MATCHER is a function accepting three arguments, returning +a non-nil value whenever a given set of tags qualifies a headline +for inclusion. See `org-make-tags-matcher' for more information. +As a special case, it can also be set to t (respectively nil) in +order to match all (respectively none) headline. + +When TODO-ONLY is non-nil, only lines with a not-done TODO +keyword are included in the output. START-LEVEL can be a string with asterisks, reducing the scope to headlines matching this string." @@ -14217,8 +14151,8 @@ headlines matching this string." (concat "\\*\\{" (number-to-string start-level) "\\} ") org-outline-regexp) " *\\(\\<\\(" - (mapconcat 'regexp-quote org-todo-keywords-1 "\\|") - (org-re "\\)\\>\\)? *\\(.*?\\)\\(:[[:alnum:]_@#%:]+:\\)?[ \t]*$"))) + (mapconcat #'regexp-quote org-todo-keywords-1 "\\|") + "\\)\\>\\)? *\\(.*?\\)\\(:[[:alnum:]_@#%:]+:\\)?[ \t]*$")) (props (list 'face 'default 'done-face 'org-agenda-done 'undone-face 'default @@ -14237,7 +14171,7 @@ headlines matching this string." (llast 0) rtn rtn1 level category i txt todo marker entry priority ts-date ts-date-type ts-date-pair) - (when (not (or (member action '(agenda sparse-tree)) (functionp action))) + (unless (or (member action '(agenda sparse-tree)) (functionp action)) (setq action (list 'lambda nil action))) (save-excursion (goto-char (point-min)) @@ -14248,8 +14182,10 @@ headlines matching this string." (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))) + (setq todo + ;; TODO: is the 1-2 difference a bug? + (when (match-end 1) (match-string-no-properties 2)) + tags (when (match-end 4) (match-string-no-properties 4))) (goto-char (setq lspos (match-beginning 0))) (setq level (org-reduced-level (org-outline-level)) category (org-get-category)) @@ -14283,18 +14219,20 @@ headlines matching this string." (when (and tags org-use-tag-inheritance (or (not (eq t org-use-tag-inheritance)) org-tags-exclude-from-inheritance)) - ;; selective inheritance, remove uninherited ones + ;; Selective inheritance, remove uninherited ones. (setcdr (car tags-alist) (org-remove-uninherited-tags (cdar tags-alist)))) (when (and ;; eval matcher only when the todo condition is OK (and (or (not todo-only) (member todo org-not-done-keywords)) - (let ((case-fold-search t) (org-trust-scanner-tags t)) - (eval matcher))) + (if (functionp matcher) + (let ((case-fold-search t) (org-trust-scanner-tags t)) + (funcall matcher todo tags-list level)) + matcher)) - ;; Call the skipper, but return t if it does not skip, - ;; so that the `and' form continues evaluating + ;; Call the skipper, but return t if it does not + ;; skip, so that the `and' form continues evaluating. (progn (unless (eq action 'sparse-tree) (org-agenda-skip)) t) @@ -14376,13 +14314,19 @@ headlines matching this string." (defun org-match-sparse-tree (&optional todo-only match) "Create a sparse tree according to tags string MATCH. -MATCH can contain positive and negative selection of tags, like -\"+WORK+URGENT-WITHBOSS\". -If optional argument TODO-ONLY is non-nil, only select lines that are -also TODO lines." + +MATCH is a string with match syntax. It can contain a selection +of tags (\"+work+urgent-boss\"), properties (\"LEVEL>3\"), and +TODO keywords (\"TODO=\\\"WAITING\\\"\") or a combination of +those. See the manual for details. + +If optional argument TODO-ONLY is non-nil, only select lines that +are also TODO tasks." (interactive "P") (org-agenda-prepare-buffers (list (current-buffer))) - (org-scan-tags 'sparse-tree (cdr (org-make-tags-matcher match)) todo-only)) + (let ((org--matcher-tags-todo-only todo-only)) + (org-scan-tags 'sparse-tree (cdr (org-make-tags-matcher match)) + org--matcher-tags-todo-only))) (defalias 'org-tags-sparse-tree 'org-match-sparse-tree) @@ -14391,7 +14335,7 @@ also TODO lines." (if (or (eq t org-use-property-inheritance) (and (stringp org-use-property-inheritance) (let ((case-fold-search t)) - (org-string-match-p org-use-property-inheritance property))) + (string-match-p org-use-property-inheritance property))) (and (listp org-use-property-inheritance) (member-ignore-case property org-use-property-inheritance))) ;; Caching is not possible, check it directly. @@ -14409,175 +14353,162 @@ instead of the agenda files." (save-excursion (org-uniquify (delq nil - (apply 'append + (apply #'append (mapcar (lambda (file) (set-buffer (find-file-noselect file)) - (append (org-get-buffer-tags) - (mapcar (lambda (x) (if (stringp (car-safe x)) - (list (car-safe x)) nil)) - org-tag-alist))) - (if (and files (car files)) - files + (mapcar (lambda (x) + (and (stringp (car-safe x)) + (list (car-safe x)))) + (or org-current-tag-alist (org-get-buffer-tags)))) + (if (car-safe files) files (org-agenda-files)))))))) (defun org-make-tags-matcher (match) "Create the TAGS/TODO matcher form for the selection string MATCH. -The variable `todo-only' is scoped dynamically into this function. -It will be set to t if the matcher restricts matching to TODO entries, -otherwise will not be touched. - -Returns a cons of the selection string MATCH and the constructed -lisp form implementing the matcher. The matcher is to be evaluated -at an Org entry, with point on the headline, and returns t if the -entry matches the selection string MATCH. The returned lisp form -references two variables with information about the entry, which -must be bound around the form's evaluation: todo, the TODO keyword -at the entry (or nil of none); and tags-list, the list of all tags -at the entry including inherited ones. Additionally, the category -of the entry (if any) must be specified as the text property -'org-category on the headline. - -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")) +Returns a cons of the selection string MATCH and a function +implementing the matcher. + +The matcher is to be called at an Org entry, with point on the +headline, and returns non-nil if the entry matches the selection +string MATCH. It must be called with three arguments: the TODO +keyword at the entry (or nil if none), the list of all tags at +the entry including inherited ones and the reduced level of the +headline. Additionally, the category of the entry, if any, must +be specified as the text property `org-category' on the headline. + +This function sets the variable `org--matcher-tags-todo-only' to +a non-nil value if the matcher restricts matching to TODO +entries, otherwise it is not touched. + +See also `org-scan-tags'." (unless match ;; Get a new match request, with completion against the global - ;; tags table and the local tags in current buffer + ;; tags table and the local tags in current buffer. (let ((org-last-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)))) + (setq match + (completing-read + "Match: " + 'org-tags-completion-function nil nil nil 'org-tags-history)))) - ;; Parse the string and create a lisp form (let ((match0 match) - (re (org-re "^&?\\([-+:]\\)?\\({[^}]+}\\|LEVEL\\([<=>]\\{1,2\\}\\)\\([0-9]+\\)\\|\\(\\(?:[[:alnum:]_]+\\(?:\\\\-\\)*\\)+\\)\\([<>=]\\{1,2\\}\\)\\({[^}]+}\\|\"[^\"]*\"\\|-?[.0-9]+\\(?:[eE][-+]?[0-9]+\\)?\\)\\|[[:alnum:]_@#%]+\\)")) - 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 (start 0) (ss 0)) - ;; Expand group tags + (re "^&?\\([-+:]\\)?\\({[^}]+}\\|LEVEL\\([<=>]\\{1,2\\}\\)\\([0-9]+\\)\\|\\(\\(?:[[:alnum:]_]+\\(?:\\\\-\\)*\\)+\\)\\([<>=]\\{1,2\\}\\)\\({[^}]+}\\|\"[^\"]*\"\\|-?[.0-9]+\\(?:[eE][-+]?[0-9]+\\)?\\)\\|[[:alnum:]_@#%]+\\)") + (start 0) + tagsmatch todomatch tagsmatcher todomatcher) + + ;; 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))) + ;; 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. + (let ((s 0)) + (while (string-match "/+" match s) + (setq start (match-beginning 0)) + (setq s (match-end 0)))) (if (and (string-match "/+" match start) - (not (save-match-data (string-match "\"" match start)))) - ;; match contains also a todo-matching request + (not (string-match-p "\"" match start))) + ;; Match contains also a TODO-matching request. (progn - (setq tagsmatch (substring match 0 (match-beginning 0)) - todomatch (substring match (match-end 0))) - (if (string-match "^!" todomatch) - (setq todo-only t todomatch (substring todomatch 1))) - (if (string-match "^\\s-*$" todomatch) - (setq todomatch nil))) - ;; only matching tags - (setq tagsmatch match todomatch nil)) - - ;; Make the tags matcher - (if (or (not tagsmatch) (not (string-match "\\S-" tagsmatch))) - (setq tagsmatcher t) - (setq orterms (org-split-string tagsmatch "|") orlist nil) - (while (setq term (pop orterms)) - (while (and (equal (substring term -1) "\\") orterms) - (setq term (concat term "|" (pop orterms)))) ; repair bad split - (while (string-match re term) - (setq rest (substring term (match-end 0)) - minus (and (match-end 1) - (equal (match-string 1 term) "-")) - tag (save-match-data (replace-regexp-in-string - "\\\\-" "-" - (match-string 2 term))) - re-p (equal (string-to-char tag) ?{) - level-p (match-end 4) - prop-p (match-end 5) - mm (cond - (re-p `(org-match-any-p ,(substring tag 1 -1) tags-list)) - (level-p - (setq level-op (org-op-to-function (match-string 3 term))) - `(,level-op level ,(string-to-number - (match-string 4 term)))) - (prop-p - (setq pn (match-string 5 term) - po (match-string 6 term) - pv (match-string 7 term) - re-p (equal (string-to-char pv) ?{) - str-p (equal (string-to-char pv) ?\") - time-p (save-match-data - (string-match "^\"[[<].*[]>]\"$" pv)) - pv (if (or re-p str-p) (substring pv 1 -1) pv)) - (if time-p (setq pv (org-matcher-time pv))) - (setq po (org-op-to-function po (if time-p 'time str-p))) - (cond - ((equal pn "CATEGORY") - (setq gv '(get-text-property (point) 'org-category))) - ((equal pn "TODO") - (setq gv 'todo)) - (t - (setq gv `(org-cached-entry-get nil ,pn)))) - (if re-p - (if (eq po 'org<>) - `(not (string-match ,pv (or ,gv ""))) - `(string-match ,pv (or ,gv ""))) - (if str-p - `(,po (or ,gv "") ,pv) - `(,po (string-to-number (or ,gv "")) - ,(string-to-number pv) )))) - (t `(member ,tag tags-list))) - mm (if minus (list 'not mm) mm) - term rest) - (push mm tagsmatcher)) - (push (if (> (length tagsmatcher) 1) - (cons 'and tagsmatcher) - (car tagsmatcher)) - orlist) - (setq tagsmatcher nil)) - (setq tagsmatcher (if (> (length orlist) 1) (cons 'or orlist) (car orlist))) - (setq tagsmatcher - (list 'progn '(setq org-cached-props nil) tagsmatcher))) - ;; Make the todo matcher - (if (or (not todomatch) (not (string-match "\\S-" todomatch))) - (setq todomatcher t) - (setq orterms (org-split-string todomatch "|") orlist nil) - (dolist (term orterms) - (while (string-match re term) - (setq minus (and (match-end 1) - (equal (match-string 1 term) "-")) - kwd (match-string 2 term) - re-p (equal (string-to-char kwd) ?{) - term (substring term (match-end 0)) - mm (if re-p - `(string-match ,(substring kwd 1 -1) todo) - (list 'equal 'todo kwd)) - mm (if minus (list 'not mm) mm)) - (push mm todomatcher)) - (push (if (> (length todomatcher) 1) - (cons 'and todomatcher) - (car todomatcher)) - orlist) - (setq todomatcher nil)) - (setq todomatcher (if (> (length orlist) 1) - (cons 'or orlist) (car orlist)))) - - ;; Return the string and lisp forms of the matcher - (setq matcher (if todomatcher - (list 'and tagsmatcher todomatcher) - tagsmatcher)) - (when todo-only - (setq matcher (list 'and '(member todo org-not-done-keywords) - matcher))) - (cons match0 matcher))) + (setq tagsmatch (substring match 0 (match-beginning 0))) + (setq todomatch (substring match (match-end 0))) + (when (string-prefix-p "!" todomatch) + (setq org--matcher-tags-todo-only t) + (setq todomatch (substring todomatch 1))) + (when (string-match "\\`\\s-*\\'" todomatch) + (setq todomatch nil))) + ;; Only matching tags. + (setq tagsmatch match) + (setq todomatch nil)) + + ;; Make the tags matcher. + (when (org-string-nw-p tagsmatch) + (let ((orlist nil) + (orterms (org-split-string tagsmatch "|")) + term) + (while (setq term (pop orterms)) + (while (and (equal (substring term -1) "\\") orterms) + (setq term (concat term "|" (pop orterms)))) ;repair bad split. + (while (string-match re term) + (let* ((rest (substring term (match-end 0))) + (minus (and (match-end 1) + (equal (match-string 1 term) "-"))) + (tag (save-match-data + (replace-regexp-in-string + "\\\\-" "-" (match-string 2 term)))) + (regexp (eq (string-to-char tag) ?{)) + (levelp (match-end 4)) + (propp (match-end 5)) + (mm + (cond + (regexp `(org-match-any-p ,(substring tag 1 -1) tags-list)) + (levelp + `(,(org-op-to-function (match-string 3 term)) + level + ,(string-to-number (match-string 4 term)))) + (propp + (let* ((gv (pcase (upcase (match-string 5 term)) + ("CATEGORY" + '(get-text-property (point) 'org-category)) + ("TODO" 'todo) + (p `(org-cached-entry-get nil ,p)))) + (pv (match-string 7 term)) + (regexp (eq (string-to-char pv) ?{)) + (strp (eq (string-to-char pv) ?\")) + (timep (string-match-p "^\"[[<].*[]>]\"$" pv)) + (po (org-op-to-function (match-string 6 term) + (if timep 'time strp)))) + (setq pv (if (or regexp strp) (substring pv 1 -1) pv)) + (when timep (setq pv (org-matcher-time pv))) + (cond ((and regexp (eq po 'org<>)) + `(not (string-match ,pv (or ,gv "")))) + (regexp `(string-match ,pv (or ,gv ""))) + (strp `(,po (or ,gv "") ,pv)) + (t + `(,po + (string-to-number (or ,gv "")) + ,(string-to-number pv)))))) + (t `(member ,tag tags-list))))) + (push (if minus `(not ,mm) mm) tagsmatcher) + (setq term rest))) + (push `(and ,@tagsmatcher) orlist) + (setq tagsmatcher nil)) + (setq tagsmatcher `(progn (setq org-cached-props nil) (or ,@orlist))))) + + ;; Make the TODO matcher. + (when (org-string-nw-p todomatch) + (let ((orlist nil)) + (dolist (term (org-split-string todomatch "|")) + (while (string-match re term) + (let* ((minus (and (match-end 1) + (equal (match-string 1 term) "-"))) + (kwd (match-string 2 term)) + (regexp (eq (string-to-char kwd) ?{)) + (mm (if regexp `(string-match ,(substring kwd 1 -1) todo) + `(equal todo ,kwd)))) + (push (if minus `(not ,mm) mm) todomatcher)) + (setq term (substring term (match-end 0)))) + (push (if (> (length todomatcher) 1) + (cons 'and todomatcher) + (car todomatcher)) + orlist) + (setq todomatcher nil)) + (setq todomatcher (cons 'or orlist)))) + + ;; Return the string and function of the matcher. If no + ;; tags-specific or todo-specific matcher exists, match + ;; everything. + (let ((matcher (if (and tagsmatcher todomatcher) + `(and ,tagsmatcher ,todomatcher) + (or tagsmatcher todomatcher t)))) + (when org--matcher-tags-todo-only + (setq matcher `(and (member todo org-not-done-keywords) ,matcher))) + (cons match0 `(lambda (todo tags-list level) ,matcher))))) (defun org-tags-expand (match &optional single-as-list downcased tags-already-expanded) "Expand group tags in MATCH. @@ -14627,7 +14558,7 @@ When DOWNCASE is non-nil, expand downcased TAGS." (modify-syntax-entry ?_ "w" stable) ;; Temporarily replace regexp-expressions in the match-expression. (while (string-match "{.+?}" return-match) - (incf count) + (cl-incf count) (push (match-string 0 return-match) regexps-in-match) (setq return-match (replace-match (format "<%d>" count) t nil return-match))) (while (and taggroups-keys @@ -14713,7 +14644,7 @@ When DOWNCASE is non-nil, expand downcased TAGS." (setq return-match (replace-regexp-in-string (format "<%d>" count) (pop regexps-in-match) return-match t t)) - (decf count)) + (cl-decf count)) (if single-as-list (if tags-in-group tags-in-group (list return-match)) return-match)) @@ -14786,7 +14717,7 @@ epoch to the beginning of today (00:00)." (defvar org-add-colon-after-tag-completion nil) ;; dynamically scoped param (defvar org-tags-overlay (make-overlay 1 1)) -(org-detach-overlay org-tags-overlay) +(delete-overlay org-tags-overlay) (defun org-get-local-tags-at (&optional pos) "Get a list of tags defined in the current headline." @@ -14820,10 +14751,9 @@ ignore inherited ones." (org-back-to-heading t) (while (not (equal lastpos (point))) (setq lastpos (point)) - (when (looking-at - (org-re "[^\r\n]+?:\\([[:alnum:]_@#%:]+\\):[ \t]*$")) + (when (looking-at ".+?:\\([[:alnum:]_@#%:]+\\):[ \t]*$") (setq ltags (org-split-string - (org-match-string-no-properties 1) ":")) + (match-string-no-properties 1) ":")) (when parent (setq ltags (mapcar 'org-add-prop-inherited ltags))) (setq tags (append @@ -14832,7 +14762,7 @@ ignore inherited ones." ltags) tags))) (or org-use-tag-inheritance (throw 'done t)) - (if local (throw 'done t)) + (when local (throw 'done t)) (or (org-up-heading-safe) (error nil)) (setq parent t))) (error nil))))) @@ -14854,7 +14784,7 @@ If ONOFF is `on' or `off', don't toggle but set to this state." (let (res current) (save-excursion (org-back-to-heading t) - (if (re-search-forward (org-re "[ \t]:\\([[:alnum:]_@#%:]+\\):[ \t]*$") + (if (re-search-forward "[ \t]:\\([[:alnum:]_@#%:]+\\):[ \t]*$" (point-at-eol) t) (progn (setq current (match-string 1)) @@ -14880,29 +14810,24 @@ If ONOFF is `on' or `off', don't toggle but set to this state." (run-hooks 'org-after-tags-change-hook)) res)) -(defun org-align-tags-here (to-col) - ;; Assumes that this is a headline - "Align tags on the current headline to TO-COL." - (let ((pos (point)) (col (current-column)) ncol tags-l p) - (beginning-of-line 1) - (if (and (looking-at (org-re ".*?\\([ \t]+\\)\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$")) - (< pos (match-beginning 2))) - (progn - (setq tags-l (- (match-end 2) (match-beginning 2))) - (goto-char (match-beginning 1)) - (insert " ") - (delete-region (point) (1+ (match-beginning 2))) - (setq ncol (max (current-column) - (1+ col) - (if (> to-col 0) - to-col - (- (abs to-col) tags-l)))) - (setq p (point)) - (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))) - (goto-char pos)))) +(defun org--align-tags-here (to-col) + "Align tags on the current headline to TO-COL. +Assume point is on a headline." + (let ((pos (point))) + (beginning-of-line) + (if (or (not (looking-at ".*?\\([ \t]+\\)\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$")) + (>= pos (match-beginning 2))) + ;; No tags or point within tags: do not align. + (goto-char pos) + (goto-char (match-beginning 1)) + (let ((shift (max (- (if (>= to-col 0) to-col + (- (abs to-col) (string-width (match-string 2)))) + (current-column)) + 1))) + (replace-match (make-string shift ?\s) nil nil nil 1) + ;; Preserve initial position, if possible. In any case, stop + ;; before tags. + (when (< pos (point)) (goto-char pos)))))) (defun org-set-tags-command (&optional arg just-align) "Call the set-tags command for the current entry." @@ -14932,7 +14857,8 @@ If DATA is nil or the empty string, any tags will be removed." (when data (save-excursion (org-back-to-heading t) - (when (looking-at org-complex-heading-regexp) + (when (let ((case-fold-search nil)) + (looking-at org-complex-heading-regexp)) (if (match-end 5) (progn (goto-char (match-beginning 5)) @@ -14943,11 +14869,11 @@ If DATA is nil or the empty string, any tags will be removed." (insert " " data) (org-set-tags nil 'align))) (beginning-of-line 1) - (if (looking-at ".*?\\([ \t]+\\)$") - (delete-region (match-beginning 1) (match-end 1)))))) + (when (looking-at ".*?\\([ \t]+\\)$") + (delete-region (match-beginning 1) (match-end 1)))))) (defun org-align-all-tags () - "Align the tags i all headings." + "Align the tags in all headings." (interactive) (save-excursion (or (ignore-errors (org-back-to-heading t)) @@ -14978,27 +14904,36 @@ When JUST-ALIGN is non-nil, only align tags." (if arg (save-excursion (goto-char (point-min)) - (let ((buffer-invisibility-spec (org-inhibit-invisibility))) - (while (re-search-forward org-outline-regexp-bol nil t) - (org-set-tags nil t) - (end-of-line))) + (while (re-search-forward org-outline-regexp-bol nil t) + (org-set-tags nil t) + (end-of-line)) (message "All tags realigned to column %d" org-tags-column)) (let* ((current (org-get-tags-string)) - (col (current-column)) (tags (if just-align current ;; Get a new set of tags from the user. (save-excursion - (let* ((table + (let* ((seen) + (table (setq org-last-tags-completion-table - (append - org-tag-persistent-alist - (or org-tag-alist (org-get-buffer-tags)) - (and - org-complete-tags-always-offer-all-agenda-tags - (org-global-tags-completion-table - (org-agenda-files)))))) + ;; Uniquify tags in alists, yet preserve + ;; structure (i.e., keywords). + (delq nil + (mapcar + (lambda (pair) + (let ((head (car pair))) + (cond ((symbolp head) pair) + ((member head seen) nil) + (t (push head seen) + pair)))) + (append + (or org-current-tag-alist + (org-get-buffer-tags)) + (and + org-complete-tags-always-offer-all-agenda-tags + (org-global-tags-completion-table + (org-agenda-files)))))))) (current-tags (org-split-string current ":")) (inherited-tags (nreverse (nthcdr (length current-tags) @@ -15025,51 +14960,54 @@ When JUST-ALIGN is non-nil, only align tags." (setq tags (mapconcat #'identity - (sort (org-split-string tags (org-re "[^[:alnum:]_@#%]+")) + (sort (org-split-string tags "[^[:alnum:]_@#%]+") org-tags-sort-function) ":"))) + (if (or (string= ":" tags) + (string= "::" tags)) + (setq tags "")) (if (not (org-string-nw-p tags)) (setq tags "") - (unless (string-match ":\\'" tags) (setq tags (concat tags ":"))) - (unless (string-match "\\`:" tags) (setq tags (concat ":" tags)))) + (unless (string-suffix-p ":" tags) (setq tags (concat tags ":"))) + (unless (string-prefix-p ":" tags) (setq tags (concat ":" tags)))) - ;; Insert new tags at the correct column - (beginning-of-line) - (let ((level (if (looking-at org-outline-regexp) - (- (match-end 0) (point) 1) - 1))) - (cond - ((and (equal current "") (equal tags ""))) - ((re-search-forward - (concat "\\([ \t]*" (regexp-quote current) "\\)[ \t]*$") - (line-end-position) - t) - (if (equal tags "") (replace-match "" t t) - (goto-char (match-beginning 0)) - (let* ((c0 (current-column)) - ;; Compute offset for the case of org-indent-mode - ;; active. - (di (if (org-bound-and-true-p org-indent-mode) + ;; Insert new tags at the correct column. + (unless (equal current tags) + (save-excursion + (beginning-of-line) + (let ((case-fold-search nil)) + (looking-at org-complex-heading-regexp)) + ;; Remove current tags, if any. + (when (match-end 5) (replace-match "" nil nil nil 5)) + ;; Insert new tags, if any. Otherwise, remove trailing + ;; white spaces. + (end-of-line) + (if (not (equal tags "")) + ;; When text is being inserted on an invisible + ;; region boundary, it can be inadvertently sucked + ;; into invisibility. + (outline-flag-region (point) (progn (insert " " tags) (point)) nil) + (skip-chars-backward " \t") + (delete-region (point) (line-end-position))))) + ;; Align tags, if any. Fix tags column if `org-indent-mode' + ;; is on. + (unless (equal tags "") + (let* ((level (save-excursion + (beginning-of-line) + (skip-chars-forward "\\*"))) + (offset (if (bound-and-true-p org-indent-mode) (* (1- org-indent-indentation-per-level) (1- level)) 0)) - (p0 (if (eq (char-before) ?*) (1+ (point)) (point))) - (tc (+ org-tags-column - (if (> org-tags-column 0) (- di) di))) - (c1 (max (1+ c0) - (if (> tc 0) tc - (- (- tc) (string-width tags))))) - (rpl (concat (make-string (max 0 (- c1 c0)) ?\s) tags))) - (replace-match rpl t t) - (when (and (not (featurep 'xemacs)) indent-tabs-mode) - (tabify p0 (point)))))) - (t (error "Tags alignment failed")))) - (org-move-to-column col)) + (tags-column + (+ org-tags-column + (if (> org-tags-column 0) (- offset) offset)))) + (org--align-tags-here tags-column)))) (unless just-align (run-hooks 'org-after-tags-change-hook)))))) (defun org-change-tag-in-region (beg end tag off) "Add or remove TAG for each entry in the region. -This works in the agenda, and also in an org-mode buffer." +This works in the agenda, and also in an Org buffer." (interactive (list (region-beginning) (region-end) (let ((org-last-tags-completion-table @@ -15078,37 +15016,37 @@ This works in the agenda, and also in an org-mode buffer." (delq nil (append (org-get-buffer-tags) (org-global-tags-completion-table)))) (org-global-tags-completion-table)))) - (org-icompleting-read + (completing-read "Tag: " 'org-tags-completion-function nil nil nil 'org-tags-history)) (progn (message "[s]et or [r]emove? ") (equal (read-char-exclusive) ?r)))) - (if (fboundp 'deactivate-mark) (deactivate-mark)) + (when (fboundp 'deactivate-mark) (deactivate-mark)) (let ((agendap (equal major-mode 'org-agenda-mode)) l1 l2 m buf pos newhead (cnt 0)) (goto-char end) (setq l2 (1- (org-current-line))) (goto-char beg) (setq l1 (org-current-line)) - (loop for l from l1 to l2 do - (org-goto-line l) - (setq m (get-text-property (point) 'org-hd-marker)) - (when (or (and (derived-mode-p 'org-mode) (org-at-heading-p)) - (and agendap m)) - (setq buf (if agendap (marker-buffer m) (current-buffer)) - pos (if agendap m (point))) - (with-current-buffer buf - (save-excursion - (save-restriction - (goto-char pos) - (setq cnt (1+ cnt)) - (org-toggle-tag tag (if off 'off 'on)) - (setq newhead (org-get-heading))))) - (and agendap (org-agenda-change-all-lines newhead m)))) + (cl-loop for l from l1 to l2 do + (org-goto-line l) + (setq m (get-text-property (point) 'org-hd-marker)) + (when (or (and (derived-mode-p 'org-mode) (org-at-heading-p)) + (and agendap m)) + (setq buf (if agendap (marker-buffer m) (current-buffer)) + pos (if agendap m (point))) + (with-current-buffer buf + (save-excursion + (save-restriction + (goto-char pos) + (setq cnt (1+ cnt)) + (org-toggle-tag tag (if off 'off 'on)) + (setq newhead (org-get-heading))))) + (and agendap (org-agenda-change-all-lines newhead m)))) (message "Tag :%s: %s in %d headings" tag (if off "removed" "set") cnt))) -(defun org-tags-completion-function (string predicate &optional flag) +(defun org-tags-completion-function (string _predicate &optional flag) (let (s1 s2 rtn (ctable org-last-tags-completion-table) (confirm (lambda (x) (stringp (car x))))) (if (string-match "^\\(.*[-+:&,|]\\)\\([^-+:&,|]*\\)$" string) @@ -15119,12 +15057,12 @@ This works in the agenda, and also in an org-mode buffer." ((eq flag nil) ;; try completion (setq rtn (try-completion s2 ctable confirm)) - (if (stringp rtn) - (setq rtn - (concat s1 s2 (substring rtn (length s2)) - (if (and org-add-colon-after-tag-completion - (assoc rtn ctable)) - ":" "")))) + (when (stringp rtn) + (setq rtn + (concat s1 s2 (substring rtn (length s2)) + (if (and org-add-colon-after-tag-completion + (assoc rtn ctable)) + ":" "")))) rtn) ((eq flag t) ;; all-completions @@ -15143,8 +15081,8 @@ Also insert END." (defun org-fast-tag-show-exit (flag) (save-excursion (org-goto-line 3) - (if (re-search-forward "[ \t]+Next change exits" (point-at-eol) t) - (replace-match "")) + (when (re-search-forward "[ \t]+Next change exits" (point-at-eol) t) + (replace-match "")) (when flag (end-of-line 1) (org-move-to-column (- (window-width) 19) t) @@ -15153,11 +15091,8 @@ Also insert END." (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) - 'secondary-selection) - (put-text-property 0 (length s) 'face '(secondary-selection org-tag) s) - (org-overlay-display org-tags-overlay (concat prefix s))))) + (put-text-property 0 (length s) 'face '(secondary-selection org-tag) s) + (org-overlay-display org-tags-overlay (concat prefix s)))) (defvar org-last-tag-selection-key nil) (defun org-fast-tag-selection (current inherited table &optional todo-table) @@ -15187,8 +15122,7 @@ Returns the new tags string, or nil to not change the current settings." groups ingroup intaggroup) (save-excursion (beginning-of-line 1) - (if (looking-at - (org-re ".*[ \t]\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$")) + (if (looking-at ".*[ \t]\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$") (setq ov-start (match-beginning 1) ov-end (match-end 1) ov-prefix "") @@ -15209,7 +15143,7 @@ Returns the new tags string, or nil to not change the current settings." (set-window-buffer (split-window-vertically) (get-buffer-create " *Org tags*")) (org-switch-to-buffer-other-window " *Org tags*")) (erase-buffer) - (org-set-local 'org-done-keywords done-keywords) + (setq-local org-done-keywords done-keywords) (org-fast-tag-insert "Inherited" inherited i-face "\n") (org-fast-tag-insert "Current" current c-face "\n\n") (org-fast-tag-show-exit exit-after-next) @@ -15270,7 +15204,7 @@ Returns the new tags string, or nil to not change the current settings." (insert "[" c "] " tg (make-string (- fwidth 4 (length tg)) ?\ )) (push (cons tg c) ntable) - (when (= (incf cnt) ncol) + (when (= (cl-incf cnt) ncol) (insert "\n") (when (or ingroup intaggroup) (insert " ")) (setq cnt 0))))) @@ -15303,14 +15237,14 @@ Returns the new tags string, or nil to not change the current settings." (org-fit-window-to-buffer))) ((or (= c ?\C-g) (and (= c ?q) (not (rassoc c ntable)))) - (org-detach-overlay org-tags-overlay) + (delete-overlay org-tags-overlay) (setq quit-flag t)) ((= c ?\ ) (setq current nil) (when exit-after-next (setq exit-after-next 'now))) ((= c ?\t) (condition-case nil - (setq tg (org-icompleting-read + (setq tg (completing-read "Tag: " (or buffer-tags (with-current-buffer buf @@ -15318,7 +15252,7 @@ Returns the new tags string, or nil to not change the current settings." (org-get-buffer-tags)))))) (quit (setq tg ""))) (when (string-match "\\S-" tg) - (add-to-list 'buffer-tags (list tg)) + (cl-pushnew (list tg) buffer-tags :test #'equal) (if (member tg current) (setq current (delete tg current)) (push tg current))) @@ -15330,9 +15264,9 @@ Returns the new tags string, or nil to not change the current settings." ((setq e (rassoc c ntable) tg (car e)) (if (member tg current) (setq current (delete tg current)) - (loop for g in groups do - (when (member tg g) - (dolist (x g) (setq current (delete x current))))) + (cl-loop for g in groups do + (when (member tg g) + (dolist (x g) (setq current (delete x current))))) (push tg current)) (when exit-after-next (setq exit-after-next 'now)))) @@ -15347,8 +15281,7 @@ Returns the new tags string, or nil to not change the current settings." (delete-region (point) (point-at-eol)) (org-fast-tag-insert "Current" current c-face) (org-set-current-tags-overlay current ov-prefix) - (while (re-search-forward - (org-re "\\[.\\] \\([[:alnum:]_@#%]+\\)") nil t) + (while (re-search-forward "\\[.\\] \\([[:alnum:]_@#%]+\\)" nil t) (setq tg (match-string 1)) (add-text-properties (match-beginning 1) (match-end 1) @@ -15358,7 +15291,7 @@ Returns the new tags string, or nil to not change the current settings." ((member tg inherited) i-face) (t (get-text-property (match-beginning 1) 'face)))))) (goto-char (point-min))))) - (org-detach-overlay org-tags-overlay) + (delete-overlay org-tags-overlay) (if rtn (mapconcat 'identity current ":") nil)))) @@ -15369,8 +15302,8 @@ Returns the new tags string, or nil to not change the current settings." (user-error "Not on a heading")) (save-excursion (beginning-of-line 1) - (if (looking-at (org-re ".*[ \t]\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$")) - (org-match-string-no-properties 1) + (if (looking-at ".*[ \t]\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$") + (match-string-no-properties 1) ""))) (defun org-get-tags () @@ -15382,16 +15315,17 @@ Returns the new tags string, or nil to not change the current settings." (org-with-wide-buffer (goto-char (point-min)) (let ((tag-re (concat org-outline-regexp-bol - "\\(?:.*?[ \t]\\)?" - (org-re ":\\([[:alnum:]_@#%:]+\\):[ \t]*$"))) + "\\(?:.*?[ \t]\\)?:\\([[:alnum:]_@#%:]+\\):[ \t]*$")) tags) (while (re-search-forward tag-re nil t) - (dolist (tag (org-split-string (org-match-string-no-properties 1) ":")) + (dolist (tag (org-split-string (match-string-no-properties 1) ":")) (push tag tags))) (mapcar #'list (append org-file-tags (org-uniquify tags)))))) ;;;; The mapping API +(defvar org-agenda-skip-comment-trees) +(defvar org-agenda-skip-function) (defun org-map-entries (func &optional match scope &rest skip) "Call FUNC at each headline selected by MATCH in SCOPE. @@ -15461,12 +15395,12 @@ a *different* entry, you cannot use these techniques." (car (org-delete-all '(comment archive) skip))) (org-tags-match-list-sublevels t) (start-level (eq scope 'region-start-level)) - matcher file res + matcher res org-todo-keywords-for-agenda org-done-keywords-for-agenda org-todo-keyword-alist-for-agenda org-tag-alist-for-agenda - todo-only) + org--matcher-tags-todo-only) (cond ((eq match t) (setq matcher t)) @@ -15499,7 +15433,9 @@ a *different* entry, you cannot use these techniques." (progn (org-agenda-prepare-buffers (and buffer-file-name (list buffer-file-name))) - (setq res (org-scan-tags func matcher todo-only start-level))) + (setq res + (org-scan-tags + func matcher org--matcher-tags-todo-only start-level))) ;; Get the right scope (cond ((and scope (listp scope) (symbolp (car scope))) @@ -15516,11 +15452,13 @@ a *different* entry, you cannot use these techniques." (org-agenda-prepare-buffers scope) (dolist (file scope) (with-current-buffer (org-find-base-buffer-visiting file) - (save-excursion - (save-restriction - (widen) - (goto-char (point-min)) - (setq res (append res (org-scan-tags func matcher todo-only)))))))))) + (org-with-wide-buffer + (goto-char (point-min)) + (setq res + (append + res + (org-scan-tags + func matcher org--matcher-tags-todo-only))))))))) res))) ;;; Properties API @@ -15543,6 +15481,12 @@ but in some other way.") "Some properties that are used by Org mode for various purposes. Being in this list makes sure that they are offered for completion.") +(defun org--valid-property-p (property) + "Non nil when string PROPERTY is a valid property name." + (not + (or (equal property "") + (string-match-p "\\s-" property)))) + (defun org--update-property-plist (key val props) "Associate KEY to VAL in alist PROPS. Modifications are made by side-effect. Return new alist." @@ -15568,7 +15512,7 @@ return nil." (org-back-to-heading t)) (t (org-with-limited-levels (org-back-to-heading t)))))) (forward-line) - (when (org-looking-at-p org-planning-line-re) (forward-line)) + (when (looking-at-p org-planning-line-re) (forward-line)) (cond ((looking-at org-property-drawer-re) (forward-line) (cons (point) (progn (goto-char (match-end 0)) @@ -15594,10 +15538,9 @@ See `org-property-re' for match data, if applicable." (defun org-property-action () "Do an action on properties." (interactive) - (unless (org-at-property-p) (user-error "Not at a property")) (message "Property Action: [s]et [d]elete [D]elete globally [c]ompute") (let ((c (read-char-exclusive))) - (case c + (cl-case c (?s (call-interactively #'org-set-property)) (?d (call-interactively #'org-delete-property)) (?D (call-interactively #'org-delete-property-globally)) @@ -15618,7 +15561,7 @@ With numerical prefix arg, use the nth allowed value, 0 stands for the When INCREMENT is non-nil, set the property to the next allowed value." (interactive "P") - (if (equal value 0) (setq value 10)) + (when (equal value 0) (setq value 10)) (let* ((completion-ignore-case t) (prop org-effort-property) (cur (org-entry-get nil prop)) @@ -15632,7 +15575,7 @@ When INCREMENT is non-nil, set the property to the next allowed value." (or (car (nth (1- value) allowed)) (car (org-last allowed)))) ((and allowed increment) - (or (caadr (member (list cur) allowed)) + (or (cl-caadr (member (list cur) allowed)) (user-error "Allowed effort values are not set"))) (allowed (message "Select 1-9,0, [RET%s]: %s" @@ -15642,24 +15585,23 @@ When INCREMENT is non-nil, set the property to the next allowed value." (if (equal rpl ?\r) cur (setq rpl (- rpl ?0)) - (if (equal rpl 0) (setq rpl 10)) + (when (equal rpl 0) (setq rpl 10)) (if (and (> rpl 0) (<= rpl (length allowed))) (car (nth (1- rpl) allowed)) (org-completing-read "Effort: " allowed nil)))) (t - (let (org-completion-use-ido org-completion-use-iswitchb) - (org-completing-read - (concat "Effort " (if (and cur (string-match "\\S-" cur)) - (concat "[" cur "]") "") - ": ") - existing nil nil "" nil cur)))))) + (org-completing-read + (concat "Effort" (and cur (string-match "\\S-" cur) + (concat " [" cur "]")) + ": ") + existing nil nil "" nil cur))))) (unless (equal (org-entry-get nil prop) val) (org-entry-put nil prop val)) (org-refresh-property '((effort . identity) - (effort-minutes . org-duration-string-to-minutes)) + (effort-minutes . org-duration-to-minutes)) val) - (when (string= heading org-clock-current-task) + (when (equal heading (bound-and-true-p org-clock-current-task)) (setq org-clock-effort (get-text-property (point-at-bol) 'effort)) (org-clock-update-mode-line)) (message "%s is now %s" prop val))) @@ -15695,9 +15637,7 @@ strings." (when (or (not specific) (string= specific "CLOCKSUM")) (let ((clocksum (get-text-property (point) :org-clock-minutes))) (when clocksum - (push (cons "CLOCKSUM" - (org-columns-number-to-string - (/ (float clocksum) 60.) 'add_times)) + (push (cons "CLOCKSUM" (org-duration-from-minutes clocksum)) props))) (when specific (throw 'exit props))) (when (or (not specific) (string= specific "CLOCKSUM_T")) @@ -15705,29 +15645,28 @@ strings." :org-clock-minutes-today))) (when clocksumt (push (cons "CLOCKSUM_T" - (org-columns-number-to-string - (/ (float clocksumt) 60.) 'add_times)) + (org-duration-from-minutes clocksumt)) props))) (when specific (throw 'exit props))) (when (or (not specific) (string= specific "ITEM")) - (when (looking-at org-complex-heading-regexp) - (push (cons "ITEM" - (concat - (org-match-string-no-properties 1) - (let ((title (org-match-string-no-properties 4))) - (when (org-string-nw-p title) - (concat " " (org-remove-tabs title)))))) - props)) + (let ((case-fold-search nil)) + (when (looking-at org-complex-heading-regexp) + (push (cons "ITEM" + (let ((title (match-string-no-properties 4))) + (if (org-string-nw-p title) + (org-remove-tabs title) + ""))) + props))) (when specific (throw 'exit props))) (when (or (not specific) (string= specific "TODO")) (let ((case-fold-search nil)) (when (and (looking-at org-todo-line-regexp) (match-end 2)) - (push (cons "TODO" (org-match-string-no-properties 2)) props))) + (push (cons "TODO" (match-string-no-properties 2)) props))) (when specific (throw 'exit props))) (when (or (not specific) (string= specific "PRIORITY")) (push (cons "PRIORITY" (if (looking-at org-priority-regexp) - (org-match-string-no-properties 2) + (match-string-no-properties 2) (char-to-string org-default-priority))) props) (when specific (throw 'exit props))) @@ -15752,7 +15691,7 @@ strings." (when (or (not specific) (member specific '("CLOSED" "DEADLINE" "SCHEDULED"))) (forward-line) - (when (org-looking-at-p org-planning-line-re) + (when (looking-at-p org-planning-line-re) (end-of-line) (let ((bol (line-beginning-position)) ;; Backward compatibility: time keywords used to @@ -15769,14 +15708,17 @@ strings." (skip-chars-forward " \t") (and (looking-at org-ts-regexp-both) (push (cons (car pair) - (org-match-string-no-properties 0)) + (match-string-no-properties 0)) props))))))) (when specific (throw 'exit props))) (when (or (not specific) (member specific '("TIMESTAMP" "TIMESTAMP_IA"))) (let ((find-ts (lambda (end ts) - (let ((regexp (cond + ;; Fix next time-stamp before END. TS is the + ;; list of time-stamps found so far. + (let ((ts ts) + (regexp (cond ((string= specific "TIMESTAMP") org-ts-regexp) ((string= specific "TIMESTAMP_IA") @@ -15821,12 +15763,11 @@ strings." ;; First look for timestamps within headline. (let ((ts (funcall find-ts (line-end-position) nil))) (if (= (length ts) 2) (setq props (nconc ts props)) - (forward-line) ;; Then find timestamps in the section, skipping ;; planning line. - (when (org-looking-at-p org-planning-line-re) - (forward-line)) (let ((end (save-excursion (outline-next-heading)))) + (forward-line) + (when (looking-at-p org-planning-line-re) (forward-line)) (setq props (nconc (funcall find-ts end ts) props)))))))) ;; Get the standard properties, like :PROP:. (when (memq which '(nil all standard)) @@ -15846,10 +15787,10 @@ strings." ;; after its extension. We also forbid standard ;; properties to be named as special properties. (while (re-search-forward org-property-re end t) - (let* ((key (upcase (org-match-string-no-properties 2))) - (extendp (org-string-match-p "\\+\\'" key)) + (let* ((key (upcase (match-string-no-properties 2))) + (extendp (string-match-p "\\+\\'" key)) (key-base (if extendp (substring key 0 -1) key)) - (value (org-match-string-no-properties 3))) + (value (match-string-no-properties 3))) (cond ((member-ignore-case key-base org-special-properties)) (extendp @@ -15866,9 +15807,9 @@ strings." ;; Return value. props))))) -(defun org-property--local-values (property literal-nil) +(defun org--property-local-values (property literal-nil) "Return value for PROPERTY in current entry. -Value is a list whose care is the base value for PROPERTY and cdr +Value is a list whose car is the base value for PROPERTY and cdr a list of accumulated values. Return nil if neither is found in the entry. Also return nil when PROPERTY is set to \"nil\", unless LITERAL-NIL is non-nil." @@ -15882,15 +15823,26 @@ unless LITERAL-NIL is non-nil." (save-excursion (let ((v (and (re-search-forward (org-re-property property nil t) end t) - (org-match-string-no-properties 3)))) + (match-string-no-properties 3)))) (list (if literal-nil v (org-not-nil v))))))) ;; Find additional values. (let* ((property+ (org-re-property (concat property "+") nil t))) (while (re-search-forward property+ end t) - (push (org-match-string-no-properties 3) value))) + (push (match-string-no-properties 3) value))) ;; Return final values. (and (not (equal value '(nil))) (nreverse value)))))) +(defun org--property-global-value (property literal-nil) + "Return value for PROPERTY in current buffer. +Return value is a string. Return nil if property is not set +globally. Also return nil when PROPERTY is set to \"nil\", +unless LITERAL-NIL is non-nil." + (let ((global + (cdr (or (assoc-string property org-file-properties t) + (assoc-string property org-global-properties t) + (assoc-string property org-global-properties-fixed t))))) + (if literal-nil global (org-not-nil global)))) + (defun org-entry-get (pom property &optional inherit literal-nil) "Get value of PROPERTY for entry or content at point-or-marker POM. @@ -15918,7 +15870,7 @@ value higher up the hierarchy." (or (not (eq inherit 'selective)) (org-property-inherit-p property))) (org-entry-get-with-inheritance property literal-nil)) (t - (let* ((local (org-property--local-values property literal-nil)) + (let* ((local (org--property-local-values property literal-nil)) (value (and local (mapconcat #'identity (delq nil local) " ")))) (if literal-nil value (org-not-nil value))))))) @@ -15934,24 +15886,22 @@ If yes, return this value. If not, return the current value of the variable." "Delete PROPERTY from entry at point-or-marker POM. Accumulated properties, i.e. PROPERTY+, are also removed. Return non-nil when a property was removed." - (unless (member property org-special-properties) - (org-with-point-at pom - (let ((range (org-get-property-block))) - (when range - (let* ((begin (car range)) - (origin (cdr range)) - (end (copy-marker origin)) - (re (org-re-property - (concat (regexp-quote property) "\\+?") t t))) - (goto-char begin) - (while (re-search-forward re end t) - (delete-region (match-beginning 0) (line-beginning-position 2))) - ;; If drawer is empty, remove it altogether. - (when (= begin end) - (delete-region (line-beginning-position 0) - (line-beginning-position 2))) - ;; Return non-nil if some property was removed. - (prog1 (/= end origin) (set-marker end nil)))))))) + (org-with-point-at pom + (pcase (org-get-property-block) + (`(,begin . ,origin) + (let* ((end (copy-marker origin)) + (re (org-re-property + (concat (regexp-quote property) "\\+?") t t))) + (goto-char begin) + (while (re-search-forward re end t) + (delete-region (match-beginning 0) (line-beginning-position 2))) + ;; If drawer is empty, remove it altogether. + (when (= begin end) + (delete-region (line-beginning-position 0) + (line-beginning-position 2))) + ;; Return non-nil if some property was removed. + (prog1 (/= end origin) (set-marker end nil)))) + (_ nil)))) ;; Multi-values properties are properties that contain multiple values ;; These values are assumed to be single words, separated by whitespace. @@ -16032,7 +15982,7 @@ However, if LITERAL-NIL is set, return the string value \"nil\" instead." (let (value) (catch 'exit (while t - (let ((v (org-property--local-values property literal-nil))) + (let ((v (org--property-local-values property literal-nil))) (when v (setq value (concat (mapconcat #'identity (delq nil v) " ") @@ -16045,10 +15995,7 @@ However, if LITERAL-NIL is set, return the string value \"nil\" instead." (throw 'exit nil)) ((org-up-heading-safe)) (t - (let ((global - (cdr (or (assoc-string property org-file-properties t) - (assoc-string property org-global-properties t) - (assoc-string property org-global-properties-fixed t))))) + (let ((global (org--property-global-value property literal-nil))) (cond ((not global)) (value (setq value (concat global " " value))) (t (setq value global)))) @@ -16063,8 +16010,9 @@ and the new value.") (defun org-entry-put (pom property value) "Set PROPERTY to VALUE for entry at point-or-marker POM. -If the value is nil, it is converted to the empty string. If -it is not a string, an error is raised. +If the value is nil, it is converted to the empty string. If it +is not a string, an error is raised. Also raise an error on +invalid property names. PROPERTY can be any regular property (see `org-special-properties'). It can also be \"TODO\", @@ -16074,7 +16022,9 @@ For the last two properties, VALUE may have any of the special values \"earlier\" and \"later\". The function then increases or decreases scheduled or deadline date by one day." (cond ((null value) (setq value "")) - ((not (stringp value)) (error "Properties values should be strings"))) + ((not (stringp value)) (error "Properties values should be strings")) + ((not (org--valid-property-p property)) + (user-error "Invalid property name: \"%s\"" property))) (org-with-point-at pom (if (or (not (featurep 'org-inlinetask)) (org-inlinetask-in-task-p)) (org-back-to-heading t) @@ -16092,7 +16042,7 @@ decreases scheduled or deadline date by one day." (org-set-tags nil 'align)) ((equal property "SCHEDULED") (forward-line) - (if (and (org-looking-at-p org-planning-line-re) + (if (and (looking-at-p org-planning-line-re) (re-search-forward org-scheduled-time-regexp (line-end-position) t)) (cond ((string= value "earlier") (org-timestamp-change -1 'day)) @@ -16104,7 +16054,7 @@ decreases scheduled or deadline date by one day." (org-schedule nil value)))) ((equal property "DEADLINE") (forward-line) - (if (and (org-looking-at-p org-planning-line-re) + (if (and (looking-at-p org-planning-line-re) (re-search-forward org-deadline-time-regexp (line-end-position) t)) (cond ((string= value "earlier") (org-timestamp-change -1 'day)) @@ -16132,7 +16082,8 @@ decreases scheduled or deadline date by one day." (org-indent-line))))) (run-hook-with-args 'org-property-changed-functions property value))) -(defun org-buffer-property-keys (&optional specials defaults columns) +(defun org-buffer-property-keys + (&optional specials defaults columns ignore-malformed) "Get all property keys in the current buffer. When SPECIALS is non-nil, also list the special properties that @@ -16143,7 +16094,10 @@ special meaning internally: ARCHIVE, CATEGORY, SUMMARY, DESCRIPTION, LOCATION, and LOGGING and others. When COLUMNS in non-nil, also include property names given in -COLUMN formats in the current buffer." +COLUMN formats in the current buffer. + +When IGNORE-MALFORMED is non-nil, malformed drawer repair will not be +automatically performed, such drawers will be silently ignored." (let ((case-fold-search t) (props (append (and specials org-special-properties) @@ -16155,7 +16109,8 @@ COLUMN formats in the current buffer." (let ((range (org-get-property-block))) (catch 'skip (unless range - (when (and (not (org-before-first-heading-p)) + (when (and (not ignore-malformed) + (not (org-before-first-heading-p)) (y-or-n-p (format "Malformed drawer at %d, repair?" (line-beginning-position)))) (org-get-property-block nil t)) @@ -16180,11 +16135,11 @@ COLUMN formats in the current buffer." (if (< begin (point)) (throw 'skip nil) (goto-char begin)) (while (< (point) end) (let ((p (progn (looking-at org-property-re) - (org-match-string-no-properties 2)))) + (match-string-no-properties 2)))) ;; Only add true property name, not extension symbol. - (add-to-list 'props - (if (not (org-string-match-p "\\+\\'" p)) p - (substring p 0 -1)))) + (push (if (not (string-match-p "\\+\\'" p)) p + (substring p 0 -1)) + props)) (forward-line)))) (outline-next-heading))) (when columns @@ -16196,10 +16151,10 @@ COLUMN formats in the current buffer." (start 0)) (while (string-match "%[0-9]*\\(\\S-+\\)" value start) (setq start (match-end 0)) - (let ((p (org-match-string-no-properties 1 value))) + (let ((p (match-string-no-properties 1 value))) (unless (member-ignore-case p org-special-properties) - (add-to-list 'props p)))))))))) - (sort props (lambda (a b) (string< (upcase a) (upcase b)))))) + (push p props)))))))))) + (sort (delete-dups props) (lambda (a b) (string< (upcase a) (upcase b)))))) (defun org-property-values (key) "List all non-nil values of property KEY in current buffer." @@ -16209,8 +16164,8 @@ COLUMN formats in the current buffer." (re (org-re-property key)) values) (while (re-search-forward re nil t) - (add-to-list 'values (org-entry-get (point) key))) - values))) + (push (org-entry-get (point) key) values)) + (delete-dups values)))) (defun org-insert-property-drawer () "Insert a property drawer into the current entry." @@ -16219,8 +16174,8 @@ COLUMN formats in the current buffer." (org-back-to-heading t) (org-with-limited-levels (org-back-to-heading t))) (forward-line) - (when (org-looking-at-p org-planning-line-re) (forward-line)) - (unless (org-looking-at-p org-property-drawer-re) + (when (looking-at-p org-planning-line-re) (forward-line)) + (unless (looking-at-p org-property-drawer-re) ;; Make sure we start editing a line from current entry, not from ;; next one. It prevents extending text properties or overlays ;; belonging to the latter. @@ -16250,7 +16205,7 @@ Point is left between drawer's boundaries." ;; With C-u, fall back on `org-insert-property-drawer' (arg (org-insert-property-drawer)) ;; Check validity of suggested drawer's name. - ((not (org-string-match-p org-drawer-regexp (format ":%s:" drawer))) + ((not (string-match-p org-drawer-regexp (format ":%s:" drawer))) (user-error "Invalid drawer name")) ;; With an active region, insert a drawer at point. ((not (org-region-active-p)) @@ -16317,10 +16272,9 @@ This is computed according to `org-property-set-functions-alist'." (funcall set-function prompt allowed nil (not (get-text-property 0 'org-unrestricted (caar allowed)))) - (let (org-completion-use-ido org-completion-use-iswitchb) - (funcall set-function prompt - (mapcar 'list (org-property-values property)) - nil nil "" nil cur))))) + (funcall set-function prompt + (mapcar 'list (org-property-values property)) + nil nil "" nil cur)))) (org-trim val))) (defvar org-last-set-property nil) @@ -16329,7 +16283,7 @@ This is computed according to `org-property-set-functions-alist'." "Read a property name." (let ((completion-ignore-case t) (default-prop (or (and (org-at-property-p) - (org-match-string-no-properties 2)) + (match-string-no-properties 2)) org-last-set-property))) (org-completing-read (concat "Property" @@ -16357,21 +16311,29 @@ When use-default, don't even ask, just use the last (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 completion on existing and default properties. And then it will prompt for a value, offering completion either on allowed values (via an inherited xxx_ALL property) or on existing values in other instances of this property -in the current file." +in the current file. + +Throw an error when trying to set a property with an invalid name." (interactive (list nil nil)) - (let* ((property (or property (org-read-property-name))) - (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)))) + (let ((property (or property (org-read-property-name)))) + ;; `org-entry-put' also makes the following check, but this one + ;; avoids polluting `org-last-set-property' and + ;; `org-last-set-property-value' needlessly. + (unless (org--valid-property-p property) + (user-error "Invalid property name: \"%s\"" property)) + (let ((value (or value (org-read-property-value property))) + (fn (cdr (assoc-string property org-properties-postprocess-alist t)))) + (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-find-property (property &optional value) "Find first entry in buffer that sets PROPERTY. @@ -16402,7 +16364,7 @@ part of the buffer." (props (if cat props0 (delete `("CATEGORY" . ,(org-get-category)) props0))) (prop (if (< 1 (length props)) - (org-icompleting-read "Property: " props nil t) + (completing-read "Property: " props nil t) (caar props)))) (list prop))) (if (not property) @@ -16415,7 +16377,7 @@ part of the buffer." This function ignores narrowing, if any." (interactive (let* ((completion-ignore-case t) - (prop (org-icompleting-read + (prop (completing-read "Globally remove property: " (mapcar #'list (org-buffer-property-keys))))) (list prop))) @@ -16424,7 +16386,7 @@ This function ignores narrowing, if any." (let ((count 0) (re (org-re-property (concat (regexp-quote property) "\\+?") t t))) (while (re-search-forward re nil t) - (when (org-entry-delete (point) property) (incf count))) + (when (org-entry-delete (point) property) (cl-incf count))) (message "Property \"%s\" removed from %d entries" property count)))) (defvar org-columns-current-fmt-compiled) ; defined in org-colview.el @@ -16436,9 +16398,9 @@ then applies it to the property in the column format's scope." (interactive) (unless (org-at-property-p) (user-error "Not at a property")) - (let ((prop (org-match-string-no-properties 2))) + (let ((prop (match-string-no-properties 2))) (org-columns-get-format-and-top-level) - (unless (nth 3 (assoc prop org-columns-current-fmt-compiled)) + (unless (nth 3 (assoc-string prop org-columns-current-fmt-compiled t)) (user-error "No operator defined for property %s" prop)) (org-columns-compute prop))) @@ -16484,7 +16446,7 @@ completion." (org-add-props (car vals) '(org-unrestricted t))) (if table (mapcar 'list vals) vals))) -(defun org-property-previous-allowed-value (&optional previous) +(defun org-property-previous-allowed-value (&optional _previous) "Switch to the next allowed value for this property." (interactive) (org-property-next-allowed-value t)) @@ -16504,12 +16466,12 @@ completion." nval) (unless allowed (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))))) + (when previous (setq allowed (reverse allowed))) + (when (member value allowed) + (setq nval (car (cdr (member value allowed))))) (setq nval (or nval (car allowed))) - (if (equal nval value) - (user-error "Only one allowed value for this property")) + (when (equal nval value) + (user-error "Only one allowed value for this property")) (org-at-property-p) (replace-match (concat " :" key ": " nval) t t) (org-indent-line) @@ -16518,7 +16480,7 @@ completion." (when (equal prop org-effort-property) (org-refresh-property '((effort . identity) - (effort-minutes . org-duration-string-to-minutes)) + (effort-minutes . org-duration-to-minutes)) nval) (when (string= org-clock-current-task heading) (setq org-clock-effort nval) @@ -16544,31 +16506,30 @@ only headings." (level 1) (lmin 1) (lmax 1) - limit re end found pos heading cnt flevel) + end found flevel) (unless buffer (error "File not found :%s" file)) (with-current-buffer buffer - (save-excursion - (save-restriction - (widen) - (setq limit (point-max)) - (goto-char (point-min)) - (dolist (heading path) - (setq re (format org-complex-heading-regexp-format - (regexp-quote heading))) - (setq cnt 0 pos (point)) - (while (re-search-forward re end t) - (setq level (- (match-end 1) (match-beginning 1))) - (if (and (>= level lmin) (<= level lmax)) - (setq found (match-beginning 0) flevel level cnt (1+ cnt)))) - (when (= cnt 0) (error "Heading not found on level %d: %s" - lmax heading)) - (when (> cnt 1) (error "Heading not unique on level %d: %s" - lmax heading)) - (goto-char found) - (setq lmin (1+ flevel) lmax (+ lmin (if org-odd-levels-only 1 0))) - (setq end (save-excursion (org-end-of-subtree t t)))) - (when (org-at-heading-p) - (point-marker))))))) + (unless (derived-mode-p 'org-mode) + (error "Buffer %s needs to be in Org mode" buffer)) + (org-with-wide-buffer + (goto-char (point-min)) + (dolist (heading path) + (let ((re (format org-complex-heading-regexp-format + (regexp-quote heading))) + (cnt 0)) + (while (re-search-forward re end t) + (setq level (- (match-end 1) (match-beginning 1))) + (when (and (>= level lmin) (<= level lmax)) + (setq found (match-beginning 0) flevel level cnt (1+ cnt)))) + (when (= cnt 0) + (error "Heading not found on level %d: %s" lmax heading)) + (when (> cnt 1) + (error "Heading not unique on level %d: %s" lmax heading)) + (goto-char found) + (setq lmin (1+ flevel) lmax (+ lmin (if org-odd-levels-only 1 0))) + (setq end (save-excursion (org-end-of-subtree t t))))) + (when (org-at-heading-p) + (point-marker)))))) (defun org-find-exact-headline-in-buffer (heading &optional buffer pos-only) "Find node HEADING in BUFFER. @@ -16578,17 +16539,15 @@ If POS-ONLY is set, return just the position instead of a marker. The heading text must match exact, but it may have a TODO keyword, a priority cookie and tags in the standard locations." (with-current-buffer (or buffer (current-buffer)) - (save-excursion - (save-restriction - (widen) - (goto-char (point-min)) - (let (case-fold-search) - (if (re-search-forward - (format org-complex-heading-regexp-format - (regexp-quote heading)) nil t) - (if pos-only - (match-beginning 0) - (move-marker (make-marker) (match-beginning 0))))))))) + (org-with-wide-buffer + (goto-char (point-min)) + (let (case-fold-search) + (when (re-search-forward + (format org-complex-heading-regexp-format + (regexp-quote heading)) nil t) + (if pos-only + (match-beginning 0) + (move-marker (make-marker) (match-beginning 0)))))))) (defun org-find-exact-heading-in-directory (heading &optional dir) "Find Org node headline HEADING in all .org files in directory DIR. @@ -16624,7 +16583,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-ts-what) ; dynamically scoped parameter (defun org-time-stamp (arg &optional inactive) "Prompt for a date/time and insert a time stamp. @@ -16709,7 +16667,7 @@ non-nil." (if (not t2) t1 (setq dh (- h2 h1) dm (- m2 m1)) - (if (< dm 0) (setq dm (+ dm 60) dh (1- dh))) + (when (< dm 0) (setq dm (+ dm 60) dh (1- dh))) (concat t1 "+" (number-to-string dh) (and (/= 0 dm) (format ":%02d" dm))))))) @@ -16724,7 +16682,7 @@ So these are more for recording a certain time/date." (defvar org-date-ovl (make-overlay 1 1)) (overlay-put org-date-ovl 'face 'org-date-selected) -(org-detach-overlay org-date-ovl) +(delete-overlay org-date-ovl) (defvar org-ans1) ; dynamically scoped parameter (defvar org-ans2) ; dynamically scoped parameter @@ -16746,7 +16704,9 @@ So these are more for recording a certain time/date." (org-defkey map (kbd ".") (lambda () (interactive) ;; Are we at the beginning of the prompt? - (if (looking-back "^[^:]+: ") + (if (looking-back "^[^:]+: " + (let ((inhibit-field-text-motion t)) + (line-beginning-position))) (org-eval-in-calendar '(calendar-goto-today)) (insert ".")))) (org-defkey map (kbd "C-.") @@ -16813,7 +16773,8 @@ So these are more for recording a certain time/date." (defvar org-defdecode) (defvar org-with-time) -(defun org-read-date (&optional org-with-time to-time from-string prompt +(defvar calendar-setup) ; Dynamically scoped. +(defun org-read-date (&optional 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. The prompt will suggest to enter an ISO date, but you can also enter anything @@ -16853,12 +16814,12 @@ While prompting, a calendar is popped up - you can also select the date with the mouse (button 1). The calendar shows a period of three months. To scroll it to other months, use the keys `>' and `<'. If you don't like the calendar, turn it off with - \(setq org-read-date-popup-calendar nil) + (setq org-read-date-popup-calendar nil) With optional argument TO-TIME, the date will immediately be converted to an internal time. -With an optional argument ORG-WITH-TIME, the prompt will suggest to -also insert a time. Note that when ORG-WITH-TIME is not set, you can +With an optional argument WITH-TIME, the prompt will suggest to +also insert a time. Note that when WITH-TIME is not set, you can still enter a time, and this function will inform the calling routine about this change. The calling routine may then choose to change the format used to insert the time stamp into the buffer to include the time. @@ -16867,83 +16828,90 @@ the user. PROMPT can overwrite the default prompt. DEFAULT-TIME is the time/date that is used for everything that is not specified by the user." (require 'parse-time) - (let* ((org-time-stamp-rounding-minutes - (if (equal org-with-time '(16)) '(0 0) org-time-stamp-rounding-minutes)) + (let* ((org-with-time with-time) + (org-time-stamp-rounding-minutes + (if (equal org-with-time '(16)) + '(0 0) + org-time-stamp-rounding-minutes)) (org-dcst org-display-custom-times) (ct (org-current-time)) (org-def (or org-overriding-default-time default-time ct)) (org-defdecode (decode-time org-def)) - (dummy (progn - (when (< (nth 2 org-defdecode) org-extend-today-until) - (setcar (nthcdr 2 org-defdecode) -1) - (setcar (nthcdr 1 org-defdecode) 59) - (setq org-def (apply 'encode-time org-defdecode) - org-defdecode (decode-time org-def))))) (cur-frame (selected-frame)) - (mouse-autoselect-window nil) ; Don't let the mouse jump - (calendar-frame-setup nil) - (calendar-setup (when (eq calendar-setup 'calendar-only) 'calendar-only)) + (mouse-autoselect-window nil) ; Don't let the mouse jump + (calendar-setup + (and (eq calendar-setup 'calendar-only) 'calendar-only)) (calendar-move-hook nil) (calendar-view-diary-initially-flag nil) (calendar-view-holidays-initially-flag nil) - (timestr (format-time-string - (if org-with-time "%Y-%m-%d %H:%M" "%Y-%m-%d") org-def)) - (prompt (concat (if prompt (concat prompt " ") "") - (format "Date+time [%s]: " timestr))) ans (org-ans0 "") org-ans1 org-ans2 final cal-frame) - - (cond - (from-string (setq ans from-string)) - (org-read-date-popup-calendar - (save-excursion - (save-window-excursion - (calendar) - (when (eq calendar-setup 'calendar-only) - (setq cal-frame - (window-frame (get-buffer-window "*Calendar*" 'visible))) - (select-frame cal-frame)) - (org-eval-in-calendar '(setq cursor-type nil) t) - (unwind-protect - (progn - (calendar-forward-day (- (time-to-days org-def) - (calendar-absolute-from-gregorian - (calendar-current-date)))) - (org-eval-in-calendar nil t) - (let* ((old-map (current-local-map)) - (map (copy-keymap calendar-mode-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) - (unwind-protect - (progn - (use-local-map map) - (setq org-read-date-inactive inactive) - (add-hook 'post-command-hook 'org-read-date-display) - (setq org-ans0 (read-string prompt default-input - 'org-read-date-history nil)) - ;; org-ans0: from prompt - ;; org-ans1: from mouse click - ;; org-ans2: from calendar motion - (setq ans (concat org-ans0 " " (or org-ans1 org-ans2)))) - (remove-hook 'post-command-hook 'org-read-date-display) - (use-local-map old-map) - (when org-read-date-overlay - (delete-overlay org-read-date-overlay) - (setq org-read-date-overlay nil))))) - (bury-buffer "*Calendar*") - (when cal-frame - (delete-frame cal-frame) - (select-frame-set-input-focus cur-frame)))))) - - (t ; Naked prompt only - (unwind-protect - (setq ans (read-string prompt default-input - 'org-read-date-history timestr)) - (when org-read-date-overlay - (delete-overlay org-read-date-overlay) - (setq org-read-date-overlay nil))))) + ;; Rationalize `org-def' and `org-defdecode', if required. + (when (< (nth 2 org-defdecode) org-extend-today-until) + (setf (nth 2 org-defdecode) -1) + (setf (nth 1 org-defdecode) 59) + (setq org-def (apply #'encode-time org-defdecode)) + (setq org-defdecode (decode-time org-def))) + (let* ((timestr (format-time-string + (if org-with-time "%Y-%m-%d %H:%M" "%Y-%m-%d") + org-def)) + (prompt (concat (if prompt (concat prompt " ") "") + (format "Date+time [%s]: " timestr)))) + (cond + (from-string (setq ans from-string)) + (org-read-date-popup-calendar + (save-excursion + (save-window-excursion + (calendar) + (when (eq calendar-setup 'calendar-only) + (setq cal-frame + (window-frame (get-buffer-window "*Calendar*" 'visible))) + (select-frame cal-frame)) + (org-eval-in-calendar '(setq cursor-type nil) t) + (unwind-protect + (progn + (calendar-forward-day (- (time-to-days org-def) + (calendar-absolute-from-gregorian + (calendar-current-date)))) + (org-eval-in-calendar nil t) + (let* ((old-map (current-local-map)) + (map (copy-keymap calendar-mode-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) + (unwind-protect + (progn + (use-local-map map) + (setq org-read-date-inactive inactive) + (add-hook 'post-command-hook 'org-read-date-display) + (setq org-ans0 + (read-string prompt + default-input + 'org-read-date-history + nil)) + ;; org-ans0: from prompt + ;; org-ans1: from mouse click + ;; org-ans2: from calendar motion + (setq ans + (concat org-ans0 " " (or org-ans1 org-ans2)))) + (remove-hook 'post-command-hook 'org-read-date-display) + (use-local-map old-map) + (when org-read-date-overlay + (delete-overlay org-read-date-overlay) + (setq org-read-date-overlay nil))))) + (bury-buffer "*Calendar*") + (when cal-frame + (delete-frame cal-frame) + (select-frame-set-input-focus cur-frame)))))) + + (t ; Naked prompt only + (unwind-protect + (setq ans (read-string prompt default-input + 'org-read-date-history timestr)) + (when org-read-date-overlay + (delete-overlay org-read-date-overlay) + (setq org-read-date-overlay nil)))))) (setq final (org-read-date-analyze ans org-def org-defdecode)) @@ -17004,16 +16972,18 @@ user." (make-overlay (1- (point-at-eol)) (point-at-eol))) (org-overlay-display org-read-date-overlay txt 'secondary-selection))))) -(defun org-read-date-analyze (ans org-def org-defdecode) +(defun org-read-date-analyze (ans def defdecode) "Analyze the combined answer of the date prompt." ;; FIXME: cleanup and comment ;; Pass `current-time' result to `decode-time' (instead of calling ;; without arguments) so that only `current-time' has to be ;; overriden in tests. - (let ((nowdecode (decode-time (current-time))) + (let ((org-def def) + (org-defdecode defdecode) + (nowdecode (decode-time (current-time))) delta deltan deltaw deltadef year month day hour minute second wday pm h2 m2 tl wday1 - iso-year iso-weekday iso-week iso-year iso-date futurep kill-year) + iso-year iso-weekday iso-week iso-date futurep kill-year) (setq org-read-date-analyze-futurep nil org-read-date-analyze-forced-year nil) (when (string-match "\\`[ \t]*\\.[ \t]*\\'" ans) @@ -17029,11 +16999,11 @@ user." ;; info and postpone interpreting it until the rest of the parsing ;; is done. (when (string-match "\\<\\(?:\\([0-9]+\\)-\\)?[wW]\\([0-9]\\{1,2\\}\\)\\(?:-\\([0-6]\\)\\)?\\([ \t]\\|$\\)" ans) - (setq iso-year (if (match-end 1) - (org-small-year-to-year - (string-to-number (match-string 1 ans)))) - iso-weekday (if (match-end 3) - (string-to-number (match-string 3 ans))) + (setq iso-year (when (match-end 1) + (org-small-year-to-year + (string-to-number (match-string 1 ans)))) + iso-weekday (when (match-end 3) + (string-to-number (match-string 3 ans))) iso-week (string-to-number (match-string 2 ans))) (setq ans (replace-match "" t t ans))) @@ -17046,7 +17016,7 @@ user." (string-to-number (format-time-string "%Y")))) month (string-to-number (match-string 3 ans)) day (string-to-number (match-string 4 ans))) - (if (< year 100) (setq year (+ 2000 year))) + (setq year (org-small-year-to-year year)) (setq ans (replace-match (format "%04d-%02d-%02d\\5" year month day) t nil ans))) @@ -17070,26 +17040,26 @@ user." (string-to-number (format-time-string "%Y")))) month (string-to-number (match-string 1 ans)) day (string-to-number (match-string 2 ans))) - (if (< year 100) (setq year (+ 2000 year))) + (setq year (org-small-year-to-year year)) (setq ans (replace-match (format "%04d-%02d-%02d\\5" year month day) t nil ans))) ;; Help matching am/pm times, because `parse-time-string' does not do that. ;; If there is a time with am/pm, and *no* time without it, we convert ;; so that matching will be successful. - (loop for i from 1 to 2 do ; twice, for end time as well - (when (and (not (string-match "\\(\\`\\|[^+]\\)[012]?[0-9]:[0-9][0-9]\\([ \t\n]\\|$\\)" ans)) - (string-match "\\([012]?[0-9]\\)\\(:\\([0-5][0-9]\\)\\)?\\(am\\|AM\\|pm\\|PM\\)\\>" ans)) - (setq hour (string-to-number (match-string 1 ans)) - minute (if (match-end 3) - (string-to-number (match-string 3 ans)) - 0) - pm (equal ?p - (string-to-char (downcase (match-string 4 ans))))) - (if (and (= hour 12) (not pm)) - (setq hour 0) - (if (and pm (< hour 12)) (setq hour (+ 12 hour)))) - (setq ans (replace-match (format "%02d:%02d" hour minute) - t t ans)))) + (cl-loop for i from 1 to 2 do ; twice, for end time as well + (when (and (not (string-match "\\(\\`\\|[^+]\\)[012]?[0-9]:[0-9][0-9]\\([ \t\n]\\|$\\)" ans)) + (string-match "\\([012]?[0-9]\\)\\(:\\([0-5][0-9]\\)\\)?\\(am\\|AM\\|pm\\|PM\\)\\>" ans)) + (setq hour (string-to-number (match-string 1 ans)) + minute (if (match-end 3) + (string-to-number (match-string 3 ans)) + 0) + pm (equal ?p + (string-to-char (downcase (match-string 4 ans))))) + (if (and (= hour 12) (not pm)) + (setq hour 0) + (when (and pm (< hour 12)) (setq hour (+ 12 hour)))) + (setq ans (replace-match (format "%02d:%02d" hour minute) + t t ans)))) ;; Check if a time range is given as a duration (when (string-match "\\([012]?[0-9]\\):\\([0-6][0-9]\\)\\+\\([012]?[0-9]\\)\\(:\\([0-5][0-9]\\)\\)?" ans) @@ -17098,7 +17068,7 @@ user." minute (string-to-number (match-string 2 ans)) m2 (+ minute (if (match-end 5) (string-to-number (match-string 5 ans))0))) - (if (>= m2 60) (setq h2 (1+ h2) m2 (- m2 60))) + (when (>= m2 60) (setq h2 (1+ h2) m2 (- m2 60))) (setq ans (replace-match (format "%02d:%02d-%02d:%02d" hour minute h2 m2) t t ans))) @@ -17202,17 +17172,17 @@ user." (setq wday1 (nth 6 (decode-time (encode-time 0 0 0 day month year)))) (unless (equal wday wday1) (setq day (+ day (% (- wday wday1 -7) 7)))))) - (if (and (boundp 'org-time-was-given) - (nth 2 tl)) - (setq org-time-was-given t)) - (if (< year 100) (setq year (+ 2000 year))) + (when (and (boundp 'org-time-was-given) + (nth 2 tl)) + (setq org-time-was-given t)) + (when (< year 100) (setq year (+ 2000 year))) ;; Check of the date is representable (if org-read-date-force-compatible-dates (progn - (if (< year 1970) - (setq year 1970 org-read-date-analyze-forced-year t)) - (if (> year 2037) - (setq year 2037 org-read-date-analyze-forced-year t))) + (when (< year 1970) + (setq year 1970 org-read-date-analyze-forced-year t)) + (when (> year 2037) + (setq year 2037 org-read-date-analyze-forced-year t))) (condition-case nil (ignore (encode-time second minute hour day month year)) (error @@ -17252,12 +17222,11 @@ DEF-FLAG is t when a double ++ or -- indicates shift relative to (if wday1 (progn (setq delta (mod (+ 7 (- wday1 wday)) 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))))) + (when (= delta 0) (setq delta 7)) + (when (= dir ?-) + (setq delta (- delta 7)) + (when (= delta 0) (setq delta -7))) + (when (> n 1) (setq delta (+ delta (* (1- n) (if (= dir ?-) -7 7))))) (list delta "d" rel)) (list (* n (if (= dir ?-) -1 1)) what rel))))) @@ -17266,23 +17235,14 @@ DEF-FLAG is t when a double ++ or -- indicates shift relative to The internal representation needed by the calendar is (month day year). This is a wrapper to handle the brain-dead convention in calendar that user function argument order change dependent on argument order." - (if (boundp 'calendar-date-style) - (cond - ((eq calendar-date-style 'american) - (list arg1 arg2 arg3)) - ((eq calendar-date-style 'european) - (list arg2 arg1 arg3)) - ((eq calendar-date-style 'iso) - (list arg2 arg3 arg1))) - (org-no-warnings ;; european-calendar-style is obsolete as of version 23.1 - (if (org-bound-and-true-p european-calendar-style) - (list arg2 arg1 arg3) - (list arg1 arg2 arg3))))) + (pcase calendar-date-style + (`american (list arg1 arg2 arg3)) + (`european (list arg2 arg1 arg3)) + (`iso (list arg2 arg3 arg1)))) (defun org-eval-in-calendar (form &optional keepdate) "Eval FORM in the calendar window and return to current window. -When KEEPDATE is non-nil, update `org-ans2' from the cursor date, -otherwise stick to the current value of `org-ans2'." +Unless KEEPDATE is non-nil, update `org-ans2' to the cursor date." (let ((sf (selected-frame)) (sw (selected-window))) (select-window (get-buffer-window "*Calendar*" t)) @@ -17293,7 +17253,7 @@ otherwise stick to the current value of `org-ans2'." (setq org-ans2 (format-time-string "%Y-%m-%d" time)))) (move-overlay org-date-ovl (1- (point)) (1+ (point)) (current-buffer)) (select-window sw) - (org-select-frame-set-input-focus sf))) + (select-frame-set-input-focus sf))) (defun org-calendar-select () "Return to `org-read-date' with the date currently selected. @@ -17303,7 +17263,7 @@ This is used by `org-read-date' in a temporary keymap for the calendar buffer." (let* ((date (calendar-cursor-to-date)) (time (encode-time 0 0 0 (nth 1 date) (nth 0 date) (nth 2 date)))) (setq org-ans1 (format-time-string "%Y-%m-%d" time))) - (if (active-minibuffer-window) (exit-minibuffer)))) + (when (active-minibuffer-window) (exit-minibuffer)))) (defun org-insert-time-stamp (time &optional with-hm inactive pre post extra) "Insert a date stamp for the date given by the internal TIME. @@ -17316,7 +17276,7 @@ stamp. The command returns the inserted time stamp." (let ((fmt (funcall (if with-hm 'cdr 'car) org-time-stamp-formats)) stamp) - (if inactive (setq fmt (concat "[" (substring fmt 1 -1) "]"))) + (when inactive (setq fmt (concat "[" (substring fmt 1 -1) "]"))) (insert-before-markers (or pre "")) (when (listp extra) (setq extra (car extra)) @@ -17339,14 +17299,12 @@ The command returns the inserted time stamp." (unless org-display-custom-times (let ((p (point-min)) (bmp (buffer-modified-p))) (while (setq p (next-single-property-change p 'display)) - (if (and (get-text-property p 'display) - (eq (get-text-property p 'face) 'org-date)) - (remove-text-properties - p (setq p (next-single-property-change p 'display)) - '(display t)))) + (when (and (get-text-property p 'display) + (eq (get-text-property p 'face) 'org-date)) + (remove-text-properties + p (setq p (next-single-property-change p 'display)) + '(display t)))) (set-buffer-modified-p bmp))) - (if (featurep 'xemacs) - (remove-text-properties (point-min) (point-max) '(end-glyph t))) (org-restart-font-lock) (setq org-table-may-need-update t) (if org-display-custom-times @@ -17359,8 +17317,8 @@ The command returns the inserted time stamp." t1 w1 with-hm tf time str w2 (off 0)) (save-match-data (setq t1 (org-parse-time-string ts t)) - (if (string-match "\\(-[0-9]+:[0-9]+\\)?\\( [.+]?\\+[0-9]+[hdwmy]\\(/[0-9]+[hdwmy]\\)?\\)?\\'" ts) - (setq off (- (match-end 0) (match-beginning 0))))) + (when (string-match "\\(-[0-9]+:[0-9]+\\)?\\( [.+]?\\+[0-9]+[hdwmy]\\(/[0-9]+[hdwmy]\\)?\\)?\\'" ts) + (setq off (- (match-end 0) (match-beginning 0))))) (setq end (- end off)) (setq w1 (- end beg) with-hm (and (nth 1 t1) (nth 2 t1)) @@ -17371,14 +17329,10 @@ The command returns the inserted time stamp." (substring tf 1 -1) (apply 'encode-time time)) nil 'mouse-face 'highlight) w2 (length str)) - (if (not (= w2 w1)) - (add-text-properties (1+ beg) (+ 2 beg) - (list 'org-dwidth t 'org-dwidth-n (- w1 w2)))) - (if (featurep 'xemacs) - (progn - (put-text-property beg end 'invisible t) - (put-text-property beg end 'end-glyph (make-glyph str))) - (put-text-property beg end 'display str)))) + (unless (= w2 w1) + (add-text-properties (1+ beg) (+ 2 beg) + (list 'org-dwidth t 'org-dwidth-n (- w1 w2)))) + (put-text-property beg end 'display str))) (defun org-fix-decoded-time (time) "Set 0 instead of nil for the first 6 elements of time. @@ -17386,19 +17340,17 @@ Don't touch the rest." (let ((n 0)) (mapcar (lambda (x) (if (< (setq n (1+ n)) 7) (or x 0) x)) 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))) + (let ((fdiff (if seconds #'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) +(defun org-deadline-close-p (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-time-stamp-to-now timestamp-string) ndays) + (and (<= (org-time-stamp-to-now timestamp-string) ndays) (not (org-entry-is-done-p)))) (defun org-get-wdays (ts &optional delay zero-delay) @@ -17434,14 +17386,15 @@ This is used by `org-read-date' in a temporary keymap for the calendar buffer." (let* ((date (calendar-cursor-to-date)) (time (encode-time 0 0 0 (nth 1 date) (nth 0 date) (nth 2 date)))) (setq org-ans1 (format-time-string "%Y-%m-%d" time))) - (if (active-minibuffer-window) (exit-minibuffer)))) + (when (active-minibuffer-window) (exit-minibuffer)))) (defun org-check-deadlines (ndays) "Check if there are any deadlines due or past due. A deadline is considered due if it happens within `org-deadline-warning-days' days from today's date. If the deadline appears in an entry marked DONE, -it is not shown. The prefix arg NDAYS can be used to test that many -days. If the prefix is a raw \\[universal-argument] prefix, all deadlines are shown." +it is not shown. A numeric prefix argument NDAYS can be used to test that +many days. If the prefix is a raw `\\[universal-argument]', all deadlines \ +are shown." (interactive "P") (let* ((org-warn-days (cond @@ -17451,7 +17404,7 @@ days. If the prefix is a raw \\[universal-argument] prefix, all deadlines are s (case-fold-search nil) (regexp (concat "\\<" org-deadline-string " *<\\([^>]+\\)>")) (callback - (lambda () (org-deadline-close (match-string 1) org-warn-days)))) + (lambda () (org-deadline-close-p (match-string 1) org-warn-days)))) (message "%d deadlines past-due or due within %d days" (org-occur regexp nil callback) org-warn-days))) @@ -17469,7 +17422,7 @@ Allowed values for TYPE are: When TYPE is nil, fall back on returning a regexp that matches both scheduled and deadline timestamps." - (case type + (cl-case type (all org-ts-regexp-both) (active org-ts-regexp) (inactive org-ts-regexp-inactive) @@ -17481,39 +17434,49 @@ both scheduled and deadline timestamps." (regexp-opt (list org-deadline-string org-scheduled-string)) " *<\\([^>]+\\)>")))) -(defun org-check-before-date (date) - "Check if there are deadlines or scheduled entries before DATE." +(defun org-check-before-date (d) + "Check if there are deadlines or scheduled entries before date D." (interactive (list (org-read-date))) - (let ((case-fold-search nil) - (regexp (org-re-timestamp org-ts-type)) - (callback - `(lambda () + (let* ((case-fold-search nil) + (regexp (org-re-timestamp org-ts-type)) + (ts-type org-ts-type) + (callback + (lambda () (let ((match (match-string 1))) - (and ,(if (memq org-ts-type '(active inactive all)) - '(eq (org-element-type (org-element-context)) 'timestamp) - '(org-at-planning-p)) + (and (if (memq ts-type '(active inactive all)) + (eq (org-element-type (save-excursion + (backward-char) + (org-element-context))) + 'timestamp) + (org-at-planning-p)) (time-less-p (org-time-string-to-time match) - (org-time-string-to-time date))))))) + (org-time-string-to-time d))))))) (message "%d entries before %s" - (org-occur regexp nil callback) date))) + (org-occur regexp nil callback) + d))) -(defun org-check-after-date (date) - "Check if there are deadlines or scheduled entries after DATE." +(defun org-check-after-date (d) + "Check if there are deadlines or scheduled entries after date D." (interactive (list (org-read-date))) - (let ((case-fold-search nil) - (regexp (org-re-timestamp org-ts-type)) - (callback - `(lambda () + (let* ((case-fold-search nil) + (regexp (org-re-timestamp org-ts-type)) + (ts-type org-ts-type) + (callback + (lambda () (let ((match (match-string 1))) - (and ,(if (memq org-ts-type '(active inactive all)) - '(eq (org-element-type (org-element-context)) 'timestamp) - '(org-at-planning-p)) + (and (if (memq ts-type '(active inactive all)) + (eq (org-element-type (save-excursion + (backward-char) + (org-element-context))) + 'timestamp) + (org-at-planning-p)) (not (time-less-p (org-time-string-to-time match) - (org-time-string-to-time date)))))))) + (org-time-string-to-time d)))))))) (message "%d entries after %s" - (org-occur regexp nil callback) date))) + (org-occur regexp nil callback) + d))) (defun org-check-dates-range (start-date end-date) "Check for deadlines/scheduled entries between START-DATE and END-DATE." @@ -17522,18 +17485,22 @@ both scheduled and deadline timestamps." (let ((case-fold-search nil) (regexp (org-re-timestamp org-ts-type)) (callback - `(lambda () - (let ((match (match-string 1))) - (and - ,(if (memq org-ts-type '(active inactive all)) - '(eq (org-element-type (org-element-context)) 'timestamp) - '(org-at-planning-p)) - (not (time-less-p - (org-time-string-to-time match) - (org-time-string-to-time start-date))) - (time-less-p - (org-time-string-to-time match) - (org-time-string-to-time end-date))))))) + (let ((type org-ts-type)) + (lambda () + (let ((match (match-string 1))) + (and + (if (memq type '(active inactive all)) + (eq (org-element-type (save-excursion + (backward-char) + (org-element-context))) + 'timestamp) + (org-at-planning-p)) + (not (time-less-p + (org-time-string-to-time match) + (org-time-string-to-time start-date))) + (time-less-p + (org-time-string-to-time match) + (org-time-string-to-time end-date)))))))) (message "%d entries between %s and %s" (org-occur regexp nil callback) start-date end-date))) @@ -17552,16 +17519,16 @@ days in order to avoid rounding problems." (unless (org-at-date-range-p t) (goto-char (point-at-bol)) (re-search-forward org-tr-regexp-both (point-at-eol) t)) - (if (not (org-at-date-range-p t)) - (user-error "Not at a time-stamp range, and none found in current line"))) + (unless (org-at-date-range-p t) + (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))) (match-end (match-end 0)) (time1 (org-time-string-to-time ts1)) (time2 (org-time-string-to-time ts2)) - (t1 (org-float-time time1)) - (t2 (org-float-time time2)) + (t1 (float-time time1)) + (t2 (float-time time2)) (diff (abs (- t2 t1))) (negative (< (- t2 t1) 0)) ;; (ys (floor (* 365 24 60 60))) @@ -17591,27 +17558,31 @@ days in order to avoid rounding problems." (setq align t) (and (looking-at " *|") (goto-char (match-end 0)))) (goto-char match-end)) - (if (looking-at - "\\( *-? *[0-9]+y\\)?\\( *[0-9]+d\\)? *[0-9][0-9]:[0-9][0-9]") - (replace-match "")) - (if negative (insert " -")) + (when (looking-at + "\\( *-? *[0-9]+y\\)?\\( *[0-9]+d\\)? *[0-9][0-9]:[0-9][0-9]") + (replace-match "")) + (when negative (insert " -")) (if (> y 0) (insert " " (format (if havetime fy fy1) y d h m)) (if (> d 0) (insert " " (format (if havetime fd fd1) d h m)) (insert " " (format fh h m)))) - (if align (org-table-align)) + (when align (org-table-align)) (message "Time difference inserted"))))) (defun org-make-tdiff-string (y d h m) (let ((fmt "") (l nil)) - (if (> y 0) (setq fmt (concat fmt "%d year" (if (> y 1) "s" "") " ") - l (push y l))) - (if (> d 0) (setq fmt (concat fmt "%d day" (if (> d 1) "s" "") " ") - l (push d l))) - (if (> h 0) (setq fmt (concat fmt "%d hour" (if (> h 1) "s" "") " ") - l (push h l))) - (if (> m 0) (setq fmt (concat fmt "%d minute" (if (> m 1) "s" "") " ") - l (push m l))) + (when (> y 0) + (setq fmt (concat fmt "%d year" (if (> y 1) "s" "") " ")) + (push y l)) + (when (> d 0) + (setq fmt (concat fmt "%d day" (if (> d 1) "s" "") " ")) + (push d l)) + (when (> h 0) + (setq fmt (concat fmt "%d hour" (if (> h 1) "s" "") " ")) + (push h l)) + (when (> m 0) + (setq fmt (concat fmt "%d minute" (if (> m 1) "s" "") " ")) + (push m l)) (apply 'format fmt (nreverse l)))) (defun org-time-string-to-time (s &optional buffer pos) @@ -17621,36 +17592,47 @@ days in order to avoid rounding problems." (error (error "Bad timestamp `%s'%s\nError was: %s" s (if (not (and buffer pos)) "" - (format " at %d in buffer `%s'" pos buffer)) + (format-message " at %d in buffer `%s'" pos buffer)) (cdr errdata))))) (defun org-time-string-to-seconds (s) "Convert a timestamp string to a number of seconds." - (org-float-time (org-time-string-to-time s))) - -(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. -PREFER and SHOW-ALL are passed through to `org-closest-date'. -The variable `date' is bound by the calendar when this is called." + (float-time (org-time-string-to-time s))) + +(org-define-error 'org-diary-sexp-no-match "Unable to match diary sexp") + +(defun org-time-string-to-absolute (s &optional daynr prefer buffer pos) + "Convert time stamp S to an absolute day number. + +If DAYNR in non-nil, and there is a specifier for a cyclic time +stamp, get the closest date to DAYNR. If PREFER is +`past' (respectively `future') return a date past (respectively +after) or equal to DAYNR. + +POS is the location of time stamp S, as a buffer position in +BUFFER. + +Diary sexp timestamps are matched against DAYNR, when non-nil. +If matching fails or DAYNR is nil, `org-diary-sexp-no-match' is +signalled." (cond - ((and daynr (string-match "\\`%%\\((.*)\\)" s)) - (if (org-diary-sexp-entry (match-string 1 s) "" date) + ((string-match "\\`%%\\((.*)\\)" s) + ;; Sexp timestamp: try to match DAYNR, if available, since we're + ;; only able to match individual dates. If it fails, raise an + ;; error. + (if (and daynr + (org-diary-sexp-entry + (match-string 1 s) "" (calendar-gregorian-from-absolute daynr))) daynr - (+ daynr 1000))) - ((and daynr (string-match "\\+\\([0-9]+\\)[hdwmy]" s) - (> (string-to-number (match-string 1 s)) 0)) - (org-closest-date s (if (and (boundp 'daynr) (integerp daynr)) daynr - (time-to-days (current-time))) (match-string 0 s) - prefer show-all)) + (signal 'org-diary-sexp-no-match (list s)))) + (daynr (org-closest-date s daynr prefer)) (t (time-to-days (condition-case errdata - (apply 'encode-time (org-parse-time-string s)) + (apply #'encode-time (org-parse-time-string s)) (error (error "Bad timestamp `%s'%s\nError was: %s" - s (if (not (and buffer pos)) - "" - (format " at %d in buffer `%s'" pos buffer)) + s + (if (not (and buffer pos)) "" + (format-message " at %d in buffer `%s'" pos buffer)) (cdr errdata)))))))) (defun org-days-to-iso-week (days) @@ -17673,31 +17655,33 @@ into a past one. Any year larger than 99 is returned unchanged." (defun org-time-from-absolute (d) "Return the time corresponding to date D. D may be an absolute day number, or a calendar-type list (month day year)." - (if (numberp d) (setq d (calendar-gregorian-from-absolute d))) + (when (numberp d) (setq d (calendar-gregorian-from-absolute d))) (encode-time 0 0 0 (nth 1 d) (car d) (nth 2 d))) +(defvar org-agenda-current-date) (defun org-calendar-holiday () - "List of holidays, for Diary display in Org-mode." + "List of holidays, for Diary display in Org mode." (require 'holidays) - (let ((hl (funcall - (if (fboundp 'calendar-check-holidays) - 'calendar-check-holidays 'check-calendar-holidays) date))) - (if hl (mapconcat 'identity hl "; ")))) + (let ((hl (calendar-check-holidays org-agenda-current-date))) + (and hl (mapconcat #'identity hl "; ")))) -(defun org-diary-sexp-entry (sexp entry date) - "Process a SEXP diary ENTRY for DATE." +(defun org-diary-sexp-entry (sexp entry d) + "Process a SEXP diary ENTRY for date D." (require 'diary-lib) - (let ((result (if calendar-debug-sexp - (let ((stack-trace-on-error t)) - (eval (car (read-from-string sexp)))) - (condition-case nil - (eval (car (read-from-string sexp))) - (error - (beep) - (message "Bad sexp at line %d in %s: %s" - (org-current-line) - (buffer-file-name) sexp) - (sleep-for 2)))))) + ;; `org-anniversary' and alike expect ENTRY and DATE to be bound + ;; dynamically. + (let* ((sexp `(let ((entry ,entry) + (date ',d)) + ,(car (read-from-string sexp)))) + (result (if calendar-debug-sexp (eval sexp) + (condition-case nil + (eval sexp) + (error + (beep) + (message "Bad sexp at line %d in %s: %s" + (org-current-line) + (buffer-file-name) sexp) + (sleep-for 2)))))) (cond ((stringp result) (split-string result "; ")) ((and (consp result) (not (consp (cdr result))) @@ -17709,9 +17693,7 @@ D may be an absolute day number, or a calendar-type list (month day year)." (defun org-diary-to-ical-string (frombuf) "Get iCalendar entries from diary entries in buffer FROMBUF. This uses the icalendar.el library." - (let* ((tmpdir (if (featurep 'xemacs) - (temp-directory) - temporary-file-directory)) + (let* ((tmpdir temporary-file-directory) (tmpfile (make-temp-name (expand-file-name "orgics" tmpdir))) buf rtn b e) @@ -17720,126 +17702,136 @@ This uses the icalendar.el library." (setq buf (find-buffer-visiting tmpfile)) (set-buffer buf) (goto-char (point-min)) - (if (re-search-forward "^BEGIN:VEVENT" nil t) - (setq b (match-beginning 0))) + (when (re-search-forward "^BEGIN:VEVENT" nil t) + (setq b (match-beginning 0))) (goto-char (point-max)) - (if (re-search-backward "^END:VEVENT" nil t) - (setq e (match-end 0))) + (when (re-search-backward "^END:VEVENT" nil t) + (setq e (match-end 0))) (setq rtn (if (and b e) (concat (buffer-substring b e) "\n") ""))) (kill-buffer buf) (delete-file tmpfile) rtn)) -(defun org-closest-date (start current change prefer show-all) - "Find the date closest to CURRENT that is consistent with START and CHANGE. -When PREFER is `past', return a date that is either CURRENT or past. -When PREFER is `future', return a date that is either CURRENT or future. -When SHOW-ALL is nil, only return the current occurrence of a time stamp." - ;; Make the proper lists from the dates - (catch 'exit - (let ((a1 '(("h" . hour) - ("d" . day) - ("w" . week) - ("m" . month) - ("y" . year))) - (shour (nth 2 (org-parse-time-string start))) - dn dw sday cday n1 n2 n0 - d m y y1 y2 date1 date2 nmonths nm ny m2) - - (setq start (org-date-to-gregorian start) - current (org-date-to-gregorian - (if show-all - current - (time-to-days (current-time)))) - sday (calendar-absolute-from-gregorian start) - cday (calendar-absolute-from-gregorian current)) - - (if (<= cday sday) (throw 'exit sday)) - - (when (string-match "\\(\\+[0-9]+\\)\\([hdwmy]\\)" change) - (setq dn (string-to-number (match-string 1 change)) - dw (cdr (assoc (match-string 2 change) a1)))) - (unless (and dn (> dn 0)) - (user-error "Invalid change specifier: %s" change)) - (if (eq dw 'week) (setq dw 'day dn (* 7 dn))) - (cond - ((eq dw 'hour) - (let ((missing-hours - (mod (+ (- (* 24 (- cday sday)) shour) org-extend-today-until) - dn))) - (setq n1 (if (zerop missing-hours) cday - (- cday (1+ (floor (/ missing-hours 24))))) - n2 (+ cday (floor (/ (- dn missing-hours) 24)))))) - ((eq dw 'day) - (setq n1 (+ sday (* dn (floor (/ (- cday sday) dn)))) - n2 (+ n1 dn))) - ((eq dw 'year) - (setq d (nth 1 start) m (car start) y1 (nth 2 start) y2 (nth 2 current)) - (setq y1 (+ (* (floor (/ (- y2 y1) dn)) dn) y1)) - (setq date1 (list m d y1) - n1 (calendar-absolute-from-gregorian date1) - date2 (list m d (+ y1 (* (if (< n1 cday) 1 -1) dn))) - n2 (calendar-absolute-from-gregorian date2))) - ((eq dw 'month) - ;; approx number of month between the two dates - (setq nmonths (floor (/ (- cday sday) 30.436875))) - ;; How often does dn fit in there? - (setq d (nth 1 start) m (car start) y (nth 2 start) - nm (* dn (max 0 (1- (floor (/ nmonths dn))))) - m (+ m nm) - ny (floor (/ m 12)) - y (+ y ny) - m (- m (* ny 12))) - (while (> m 12) (setq m (- m 12) y (1+ y))) - (setq n1 (calendar-absolute-from-gregorian (list m d y))) - (setq m2 (+ m dn) y2 y) - (if (> m2 12) (setq y2 (1+ y2) m2 (- m2 12))) - (setq n2 (calendar-absolute-from-gregorian (list m2 d y2))) - (while (<= n2 cday) - (setq n1 n2 m m2 y y2) - (setq m2 (+ m dn) y2 y) - (if (> m2 12) (setq y2 (1+ y2) m2 (- m2 12))) - (setq n2 (calendar-absolute-from-gregorian (list m2 d y2)))))) - ;; Make sure n1 is the earlier date - (setq n0 n1 n1 (min n1 n2) n2 (max n0 n2)) - (if show-all - (cond - ((eq prefer 'past) (if (= cday n2) n2 n1)) - ((eq prefer 'future) (if (= cday n1) n1 n2)) - (t (if (> (abs (- cday n1)) (abs (- cday n2))) n2 n1))) - (cond - ((eq prefer 'past) (if (= cday n2) n2 n1)) - ((eq prefer 'future) (if (= cday n1) n1 n2)) - (t (if (= cday n1) n1 n2))))))) - -(defun org-date-to-gregorian (date) - "Turn any specification of DATE into a Gregorian date for the calendar." - (cond ((integerp date) (calendar-gregorian-from-absolute date)) - ((and (listp date) (= (length date) 3)) date) - ((stringp date) - (setq date (org-parse-time-string date)) - (list (nth 4 date) (nth 3 date) (nth 5 date))) - ((listp date) - (list (nth 4 date) (nth 3 date) (nth 5 date))))) +(defun org-closest-date (start current prefer) + "Return closest date to CURRENT starting from START. + +CURRENT and START are both time stamps. + +When PREFER is `past', return a date that is either CURRENT or +past. When PREFER is `future', return a date that is either +CURRENT or future. + +Only time stamps with a repeater are modified. Any other time +stamp stay unchanged. In any case, return value is an absolute +day number." + (if (not (string-match "\\+\\([0-9]+\\)\\([hdwmy]\\)" start)) + ;; No repeater. Do not shift time stamp. + (time-to-days (apply #'encode-time (org-parse-time-string start))) + (let ((value (string-to-number (match-string 1 start))) + (type (match-string 2 start))) + (if (= 0 value) + ;; Repeater with a 0-value is considered as void. + (time-to-days (apply #'encode-time (org-parse-time-string start))) + (let* ((base (org-date-to-gregorian start)) + (target (org-date-to-gregorian current)) + (sday (calendar-absolute-from-gregorian base)) + (cday (calendar-absolute-from-gregorian target)) + n1 n2) + ;; If START is already past CURRENT, just return START. + (if (<= cday sday) sday + ;; Compute closest date before (N1) and closest date past + ;; (N2) CURRENT. + (pcase type + ("h" + (let ((missing-hours + (mod (+ (- (* 24 (- cday sday)) + (nth 2 (org-parse-time-string start))) + org-extend-today-until) + value))) + (setf n1 (if (= missing-hours 0) cday + (- cday (1+ (/ missing-hours 24))))) + (setf n2 (+ cday (/ (- value missing-hours) 24))))) + ((or "d" "w") + (let ((value (if (equal type "w") (* 7 value) value))) + (setf n1 (+ sday (* value (/ (- cday sday) value)))) + (setf n2 (+ n1 value)))) + ("m" + (let* ((add-months + (lambda (d n) + ;; Add N months to gregorian date D, i.e., + ;; a list (MONTH DAY YEAR). Return a valid + ;; gregorian date. + (let ((m (+ (nth 0 d) n))) + (list (mod m 12) + (nth 1 d) + (+ (/ m 12) (nth 2 d)))))) + (months ; Complete months to TARGET. + (* (/ (+ (* 12 (- (nth 2 target) (nth 2 base))) + (- (nth 0 target) (nth 0 base)) + ;; If START's day is greater than + ;; TARGET's, remove incomplete month. + (if (> (nth 1 target) (nth 1 base)) 0 -1)) + value) + value)) + (before (funcall add-months base months))) + (setf n1 (calendar-absolute-from-gregorian before)) + (setf n2 + (calendar-absolute-from-gregorian + (funcall add-months before value))))) + (_ + (let* ((d (nth 1 base)) + (m (nth 0 base)) + (y (nth 2 base)) + (years ; Complete years to TARGET. + (* (/ (- (nth 2 target) + y + ;; If START's month and day are + ;; greater than TARGET's, remove + ;; incomplete year. + (if (or (> (nth 0 target) m) + (and (= (nth 0 target) m) + (> (nth 1 target) d))) + 0 + 1)) + value) + value)) + (before (list m d (+ y years)))) + (setf n1 (calendar-absolute-from-gregorian before)) + (setf n2 (calendar-absolute-from-gregorian + (list m d (+ (nth 2 before) value))))))) + ;; Handle PREFER parameter, if any. + (cond + ((eq prefer 'past) (if (= cday n2) n2 n1)) + ((eq prefer 'future) (if (= cday n1) n1 n2)) + (t (if (> (abs (- cday n1)) (abs (- cday n2))) n2 n1))))))))) + +(defun org-date-to-gregorian (d) + "Turn any specification of date D into a Gregorian date for the calendar." + (cond ((integerp d) (calendar-gregorian-from-absolute d)) + ((and (listp d) (= (length d) 3)) d) + ((stringp d) + (let ((d (org-parse-time-string d))) + (list (nth 4 d) (nth 3 d) (nth 5 d)))) + ((listp d) (list (nth 4 d) (nth 3 d) (nth 5 d))))) (defun org-parse-time-string (s &optional nodefault) - "Parse the standard Org-mode time string. + "Parse the standard Org time string. 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." (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"))) + (when (or (match-beginning 8) (not nodefault)) + (string-to-number (or (match-string 8 s) "0"))) + (when (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)))) + (t (error "Not a standard Org time string: %s" s)))) (defun org-timestamp-up (&optional arg) "Increase the date item at the cursor by one. @@ -17883,36 +17875,54 @@ inactive timestamps. When this function returns a non-nil value, match data is set according to `org-ts-regexp3' or `org-ts-regexp2', depending on -INACTIVE-OK." +INACTIVE-OK. + +Return the position of the point as a symbol among `bracket', +`after', `year', `month', `hour', `minute', `day' or a number of +character from the last know part of the time stamp. + +This function checks context and only return non-nil for valid +time stamps. If you need to match anything looking like a time +stamp, or if you are sure about the context, consider using +`org-in-regexp', e.g., + + (org-in-regexp org-ts-regexp) + +Unlike to `org-element-context', the function recognizes time +stamps in properties drawers, planning lines and clocks." (interactive) (let* ((tsr (if inactive-ok org-ts-regexp3 org-ts-regexp2)) (pos (point)) - (ans (or (looking-at tsr) - (save-excursion - (skip-chars-backward "^[<\n\r\t") - (if (> (point) (point-min)) (backward-char 1)) - (and (looking-at tsr) - (> (- (match-end 0) pos) -1)))))) - (and ans - (boundp 'org-ts-what) - (setq org-ts-what - (cond - ((= pos (match-beginning 0)) 'bracket) - ;; Point is considered to be "on the bracket" whether - ;; it's really on it or right after it. - ((= pos (1- (match-end 0))) 'bracket) - ((= pos (match-end 0)) 'after) - ((org-pos-in-match-range pos 2) 'year) - ((org-pos-in-match-range pos 3) 'month) - ((org-pos-in-match-range pos 7) 'hour) - ((org-pos-in-match-range pos 8) 'minute) - ((or (org-pos-in-match-range pos 4) - (org-pos-in-match-range pos 5)) 'day) - ((and (> pos (or (match-end 8) (match-end 5))) - (< pos (match-end 0))) - (- pos (or (match-end 8) (match-end 5)))) - (t 'day)))) - ans)) + (match + (let ((boundaries (org-in-regexp tsr))) + (save-match-data + (cond ((null boundaries) nil) + ((org-at-planning-p)) + ((org-at-property-p)) + ;; CLOCK lines only contain inactive time-stamps. + ((and inactive-ok (org-at-clock-log-p))) + (t + (eq 'timestamp + (save-excursion + (when (= pos (cdr boundaries)) (forward-char -1)) + (org-element-type (org-element-context)))))))))) + (cond + ((not match) nil) + ((= pos (match-beginning 0)) 'bracket) + ;; Distinguish location right before the closing bracket from + ;; right after it. + ((= pos (1- (match-end 0))) 'bracket) + ((= pos (match-end 0)) 'after) + ((org-pos-in-match-range pos 2) 'year) + ((org-pos-in-match-range pos 3) 'month) + ((org-pos-in-match-range pos 7) 'hour) + ((org-pos-in-match-range pos 8) 'minute) + ((or (org-pos-in-match-range pos 4) + (org-pos-in-match-range pos 5)) 'day) + ((and (> pos (or (match-end 8) (match-end 5))) + (< pos (match-end 0))) + (- pos (or (match-end 8) (match-end 5)))) + (t 'day)))) (defun org-toggle-timestamp-type () "Toggle the type ( or [inactive]) of a time stamp." @@ -17928,11 +17938,10 @@ INACTIVE-OK." (message "Timestamp is now %sactive" (if (equal (char-after beg) ?<) "" "in"))))) -(defun org-at-clock-log-p nil - "Is the cursor on the clock log line?" - (save-excursion - (move-beginning-of-line 1) - (looking-at org-clock-line-re))) +(defun org-at-clock-log-p () + "Non-nil if point is on a clock log line." + (and (org-match-line org-clock-line-re) + (eq (org-element-type (save-match-data (org-element-at-point))) 'clock))) (defvar org-clock-history) ; defined in org-clock.el (defvar org-clock-adjust-closest nil) ; defined in org-clock.el @@ -17942,26 +17951,26 @@ 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. When SUPPRESS-TMP-DELAY is non-nil, suppress delays like \"--2d\"." - (let ((origin (point)) origin-cat + (let ((origin (point)) + (timestamp? (org-at-timestamp-p t)) + origin-cat with-hm inactive (dm (max (nth 1 org-time-stamp-rounding-minutes) 1)) - org-ts-what extra rem ts time time0 fixnext clrgx) - (if (not (org-at-timestamp-p t)) - (user-error "Not at a timestamp")) - (if (and (not what) (eq org-ts-what 'bracket)) + (unless timestamp? (user-error "Not at a timestamp")) + (if (and (not what) (eq timestamp? 'bracket)) (org-toggle-timestamp-type) ;; Point isn't on brackets. Remember the part of the time-stamp ;; the point was in. Indeed, size of time-stamps may change, ;; but point must be kept in the same category nonetheless. - (setq origin-cat org-ts-what) - (if (and (not what) (not (eq org-ts-what 'day)) - org-display-custom-times - (get-text-property (point) 'display) - (not (get-text-property (1- (point)) 'display))) - (setq org-ts-what 'day)) - (setq org-ts-what (or what org-ts-what) + (setq origin-cat timestamp?) + (when (and (not what) (not (eq timestamp? 'day)) + org-display-custom-times + (get-text-property (point) 'display) + (not (get-text-property (1- (point)) 'display))) + (setq timestamp? 'day)) + (setq timestamp? (or what timestamp?) inactive (= (char-after (match-beginning 0)) ?\[) ts (match-string 0)) (replace-match "") @@ -17969,45 +17978,46 @@ When SUPPRESS-TMP-DELAY is non-nil, suppress delays like \"--2d\"." "\\(\\(-[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)) + (when suppress-tmp-delay + (setq extra (replace-regexp-in-string " --[0-9]+[hdwmy]" "" extra)))) + (when (string-match "^.\\{10\\}.*?[0-9]+:[0-9][0-9]" ts) + (setq with-hm t)) (setq time0 (org-parse-time-string ts)) (when (and updown - (eq org-ts-what 'minute) + (eq timestamp? 'minute) (not current-prefix-arg)) ;; This looks like s-up and s-down. Change by one rounding step. (setq n (* dm (cond ((> n 0) 1) ((< n 0) -1) (t 0)))) - (when (not (= 0 (setq rem (% (nth 1 time0) dm)))) + (unless (= 0 (setq rem (% (nth 1 time0) dm))) (setcar (cdr time0) (+ (nth 1 time0) (if (> n 0) (- rem) (- dm rem)))))) (setq time - (encode-time (or (car time0) 0) - (+ (if (eq org-ts-what 'minute) n 0) (nth 1 time0)) - (+ (if (eq org-ts-what 'hour) n 0) (nth 2 time0)) - (+ (if (eq org-ts-what 'day) n 0) (nth 3 time0)) - (+ (if (eq org-ts-what 'month) n 0) (nth 4 time0)) - (+ (if (eq org-ts-what 'year) n 0) (nth 5 time0)) - (nthcdr 6 time0))) - (when (and (member org-ts-what '(hour minute)) + (apply #'encode-time + (or (car time0) 0) + (+ (if (eq timestamp? 'minute) n 0) (nth 1 time0)) + (+ (if (eq timestamp? 'hour) n 0) (nth 2 time0)) + (+ (if (eq timestamp? 'day) n 0) (nth 3 time0)) + (+ (if (eq timestamp? 'month) n 0) (nth 4 time0)) + (+ (if (eq timestamp? 'year) n 0) (nth 5 time0)) + (nthcdr 6 time0))) + (when (and (memq timestamp? '(hour minute)) extra (string-match "-\\([012][0-9]\\):\\([0-5][0-9]\\)" extra)) (setq extra (org-modify-ts-extra extra - (if (eq org-ts-what 'hour) 2 5) + (if (eq timestamp? 'hour) 2 5) n dm))) - (when (integerp org-ts-what) - (setq extra (org-modify-ts-extra extra org-ts-what n dm))) - (if (eq what 'calendar) - (let ((cal-date (org-get-date-from-calendar))) - (setcar (nthcdr 4 time0) (nth 0 cal-date)) ; month - (setcar (nthcdr 3 time0) (nth 1 cal-date)) ; day - (setcar (nthcdr 5 time0) (nth 2 cal-date)) ; year - (setcar time0 (or (car time0) 0)) - (setcar (nthcdr 1 time0) (or (nth 1 time0) 0)) - (setcar (nthcdr 2 time0) (or (nth 2 time0) 0)) - (setq time (apply 'encode-time time0)))) + (when (integerp timestamp?) + (setq extra (org-modify-ts-extra extra timestamp? n dm))) + (when (eq what 'calendar) + (let ((cal-date (org-get-date-from-calendar))) + (setcar (nthcdr 4 time0) (nth 0 cal-date)) ; month + (setcar (nthcdr 3 time0) (nth 1 cal-date)) ; day + (setcar (nthcdr 5 time0) (nth 2 cal-date)) ; year + (setcar time0 (or (car time0) 0)) + (setcar (nthcdr 1 time0) (or (nth 1 time0) 0)) + (setcar (nthcdr 2 time0) (or (nth 2 time0) 0)) + (setq time (apply 'encode-time time0)))) ;; Insert the new time-stamp, and ensure point stays in the same ;; category as before (i.e. not after the last position in that ;; category). @@ -18018,17 +18028,21 @@ When SUPPRESS-TMP-DELAY is non-nil, suppress delays like \"--2d\"." (goto-char pos)) (save-match-data (looking-at org-ts-regexp3) - (goto-char (cond - ;; `day' category ends before `hour' if any, or at - ;; the end of the day name. - ((eq origin-cat 'day) - (min (or (match-beginning 7) (1- (match-end 5))) origin)) - ((eq origin-cat 'hour) (min (match-end 7) origin)) - ((eq origin-cat 'minute) (min (1- (match-end 8)) origin)) - ((integerp origin-cat) (min (1- (match-end 0)) origin)) - ;; `year' and `month' have both fixed size: point - ;; couldn't have moved into another part. - (t origin)))) + (goto-char + (pcase origin-cat + ;; `day' category ends before `hour' if any, or at the end + ;; of the day name. + (`day (min (or (match-beginning 7) (1- (match-end 5))) origin)) + (`hour (min (match-end 7) origin)) + (`minute (min (1- (match-end 8)) origin)) + ((pred integerp) (min (1- (match-end 0)) origin)) + ;; Point was right after the time-stamp. However, the + ;; time-stamp length might have changed, so refer to + ;; (match-end 0) instead. + (`after (match-end 0)) + ;; `year' and `month' have both fixed size: point couldn't + ;; have moved into another part. + (_ origin)))) ;; Update clock if on a CLOCK line. (org-clock-update-time-maybe) ;; Maybe adjust the closest clock in `org-clock-history' @@ -18037,11 +18051,12 @@ When SUPPRESS-TMP-DELAY is non-nil, suppress delays like \"--2d\"." (< 1 (length (delq nil (mapcar 'marker-position org-clock-history)))))) (message "No clock to adjust") - (cond ((save-excursion ; fix previous clock? + (cond ((save-excursion ; fix previous clock? (re-search-backward org-ts-regexp0 nil t) - (org-looking-back (concat org-clock-string " \\["))) + (looking-back (concat org-clock-string " \\[") + (line-beginning-position))) (setq fixnext 1 clrgx (concat org-ts-regexp0 "\\] =>.*$"))) - ((save-excursion ; fix next clock? + ((save-excursion ; fix next clock? (re-search-backward org-ts-regexp0 nil t) (looking-at (concat org-ts-regexp0 "\\] =>"))) (setq fixnext -1 clrgx (concat org-clock-string " \\[" org-ts-regexp0)))) @@ -18051,7 +18066,7 @@ When SUPPRESS-TMP-DELAY is non-nil, suppress delays like \"--2d\"." (cl (mapcar (lambda(c) (abs (- (marker-position c) p))) org-clock-history)) (clfixnth (+ fixnext (- (length cl) (or (length (member (apply 'min cl) cl)) 100)))) - (clfixpos (if (> 0 clfixnth) nil (nth clfixnth org-clock-history)))) + (clfixpos (unless (> 0 clfixnth) (nth clfixnth org-clock-history)))) (if (not clfixpos) (message "No clock to adjust") (save-excursion @@ -18060,15 +18075,15 @@ When SUPPRESS-TMP-DELAY is non-nil, suppress delays like \"--2d\"." (when (re-search-forward clrgx nil t) (goto-char (match-beginning 1)) (let (org-clock-adjust-closest) - (org-timestamp-change n org-ts-what updown)) + (org-timestamp-change n timestamp? updown)) (message "Clock adjusted in %s for heading: %s" (file-name-nondirectory (buffer-file-name)) (org-get-heading t t))))))))) ;; Try to recenter the calendar window, if any. - (if (and org-calendar-follow-timestamp-change - (get-buffer-window "*Calendar*" t) - (memq org-ts-what '(day month year))) - (org-recenter-calendar (time-to-days time)))))) + (when (and org-calendar-follow-timestamp-change + (get-buffer-window "*Calendar*" t) + (memq timestamp? '(day month year))) + (org-recenter-calendar (time-to-days time)))))) (defun org-modify-ts-extra (s pos n dm) "Change the different parts of the lead-time and repeat fields in timestamp." @@ -18082,13 +18097,13 @@ When SUPPRESS-TMP-DELAY is non-nil, suppress delays like \"--2d\"." h (string-to-number (match-string 2 s))) (if (org-pos-in-match-range pos 2) (setq h (+ h n)) - (setq n (* dm (org-no-warnings (signum n)))) - (when (not (= 0 (setq rem (% m dm)))) + (setq n (* dm (with-no-warnings (signum n)))) + (unless (= 0 (setq rem (% m dm))) (setq m (+ m (if (> n 0) (- rem) (- dm rem))))) (setq m (+ m n))) - (if (< m 0) (setq m (+ m 60) h (1- h))) - (if (> m 59) (setq m (- m 60) h (1+ h))) - (setq h (min 24 (max 0 h))) + (when (< m 0) (setq m (+ m 60) h (1- h))) + (when (> m 59) (setq m (- m 60) h (1+ h))) + (setq h (mod h 24)) (setq ng 1 new (format "-%02d:%02d" h m))) ((org-pos-in-match-range pos 6) (setq ng 6 new (car (rassoc (+ n (cdr (assoc (match-string 6 s) idx))) idx)))) @@ -18107,14 +18122,14 @@ When SUPPRESS-TMP-DELAY is non-nil, suppress delays like \"--2d\"." (substring s (match-end ng)))))) s)) -(defun org-recenter-calendar (date) - "If the calendar is visible, recenter it to DATE." +(defun org-recenter-calendar (d) + "If the calendar is visible, recenter it to date D." (let ((cwin (get-buffer-window "*Calendar*" t))) (when cwin (let ((calendar-move-hook nil)) (with-selected-window cwin - (calendar-goto-date (if (listp date) date - (calendar-gregorian-from-absolute date)))))))) + (calendar-goto-date + (if (listp d) d (calendar-gregorian-from-absolute d)))))))) (defun org-goto-calendar (&optional arg) "Go to the Emacs calendar at the current date. @@ -18125,17 +18140,17 @@ A prefix ARG can be used to force the current date." (calendar-move-hook nil) (calendar-view-holidays-initially-flag nil) (calendar-view-diary-initially-flag nil)) - (if (or (org-at-timestamp-p) - (save-excursion - (beginning-of-line 1) - (looking-at (concat ".*" tsr)))) - (let ((d1 (time-to-days (current-time))) - (d2 (time-to-days - (org-time-string-to-time (match-string 1))))) - (setq diff (- d2 d1)))) + (when (or (org-at-timestamp-p) + (save-excursion + (beginning-of-line 1) + (looking-at (concat ".*" tsr)))) + (let ((d1 (time-to-days (current-time))) + (d2 (time-to-days + (org-time-string-to-time (match-string 1))))) + (setq diff (- d2 d1)))) (calendar) (calendar-goto-today) - (if (and diff (not arg)) (calendar-forward-day diff)))) + (when (and diff (not arg)) (calendar-forward-day diff)))) (defun org-get-date-from-calendar () "Return a list (month day year) of date at point in calendar." @@ -18171,122 +18186,11 @@ minutes. For example, if the value of this variable is ((\"hours\" . 60)), then an effort string \"2hours\" is equivalent to 120 minutes." :group 'org-agenda - :version "25.1" + :version "26.1" :package-version '(Org . "8.3") :type '(alist :key-type (string :tag "Modifier") :value-type (number :tag "Minutes"))) -(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? @@ -18324,10 +18228,6 @@ tables are not re-aligned, etc." :version "24.3" :group 'org-agenda) -(define-obsolete-variable-alias - 'org-agenda-ignore-drawer-properties - 'org-agenda-ignore-properties "25.1") - (defcustom org-agenda-ignore-properties nil "Avoid updating text properties when building the agenda. Properties are used to prepare buffers for effort estimates, @@ -18341,42 +18241,22 @@ The value is a list, with zero or more of the symbols `effort', `appt', (const appt) (const stats) (const category)) - :version "25.1" + :version "26.1" :package-version '(Org . "8.3") :group 'org-agenda) -(defun org-duration-string-to-minutes (s &optional output-to-string) - "Convert a duration string S to minutes. - -A bare number is interpreted as minutes, modifiers can be set by -customizing `org-effort-durations' (which see). - -Entries containing a colon are interpreted as H:MM by -`org-hh:mm-string-to-minutes'." - (let ((result 0) - (re (concat "\\([0-9.]+\\) *\\(" - (regexp-opt (mapcar 'car org-effort-durations)) - "\\)"))) - (while (string-match re s) - (incf result (* (cdr (assoc (match-string 2 s) org-effort-durations)) - (string-to-number (match-string 1 s)))) - (setq s (replace-match "" nil t s))) - (setq result (floor result)) - (incf result (org-hh:mm-string-to-minutes s)) - (if output-to-string (number-to-string result) result))) - ;;;; Files (defun org-save-all-org-buffers () - "Save all Org-mode buffers without user confirmation." + "Save all Org buffers without user confirmation." (interactive) - (message "Saving all Org-mode buffers...") + (message "Saving all Org buffers...") (save-some-buffers t (lambda () (derived-mode-p 'org-mode))) (when (featurep 'org-id) (org-id-locations-save)) - (message "Saving all Org-mode buffers... done")) + (message "Saving all Org buffers... done")) (defun org-revert-all-org-buffers () - "Revert all Org-mode buffers. + "Revert all Org buffers. Prompt for confirmation when there are unsaved changes. Be sure you know what you are doing before letting this function overwrite your changes. @@ -18393,13 +18273,11 @@ changes from another. I believe the procedure must be like this: (user-error "Abort")) (save-excursion (save-window-excursion - (mapc - (lambda (b) - (when (and (with-current-buffer b (derived-mode-p 'org-mode)) - (with-current-buffer b buffer-file-name)) - (org-pop-to-buffer-same-window b) - (revert-buffer t 'no-confirm))) - (buffer-list)) + (dolist (b (buffer-list)) + (when (and (with-current-buffer b (derived-mode-p 'org-mode)) + (with-current-buffer b buffer-file-name)) + (pop-to-buffer-same-window b) + (revert-buffer t 'no-confirm))) (when (and (featurep 'org-id) org-id-track-globally) (org-id-locations-load))))) @@ -18408,29 +18286,19 @@ changes from another. I believe the procedure must be like this: ;;;###autoload (defun org-switchb (&optional arg) "Switch between Org buffers. -With one prefix argument, restrict available buffers to files. -With two prefix arguments, restrict available buffers to agenda files. -Defaults to `iswitchb' for buffer name completion. -Set `org-completion-use-ido' to make it use ido instead." +With `\\[universal-argument]' prefix, restrict available buffers to files. + +With `\\[universal-argument] \\[universal-argument]' \ +prefix, restrict available buffers to agenda files." (interactive "P") - (let ((blist (cond ((equal arg '(4)) (org-buffer-list 'files)) - ((equal arg '(16)) (org-buffer-list 'agenda)) - (t (org-buffer-list)))) - (org-completion-use-iswitchb org-completion-use-iswitchb) - (org-completion-use-ido org-completion-use-ido)) - (unless (or org-completion-use-ido org-completion-use-iswitchb) - (setq org-completion-use-iswitchb t)) - (org-pop-to-buffer-same-window - (org-icompleting-read "Org buffer: " - (mapcar 'list (mapcar 'buffer-name blist)) - nil t)))) - -;;; Define some older names previously used for this functionality -;;;###autoload -(defalias 'org-ido-switchb 'org-switchb) -;;;###autoload -(defalias 'org-iswitchb 'org-switchb) + (let ((blist (org-buffer-list + (cond ((equal arg '(4)) 'files) + ((equal arg '(16)) 'agenda))))) + (pop-to-buffer-same-window + (completing-read "Org buffer: " + (mapcar #'list (mapcar #'buffer-name blist)) + nil t)))) (defun org-buffer-list (&optional predicate exclude-tmp) "Return a list of Org buffers. @@ -18449,7 +18317,7 @@ If EXCLUDE-TMP is non-nil, ignore temporary buffers." ((eq predicate 'files) (lambda (b) (with-current-buffer b (derived-mode-p 'org-mode)))) ((eq predicate 'export) - (lambda (b) (string-match "\*Org .*Export" (buffer-name b)))) + (lambda (b) (string-match "\\*Org .*Export" (buffer-name b)))) ((eq predicate 'agenda) (lambda (b) (with-current-buffer b @@ -18458,7 +18326,7 @@ If EXCLUDE-TMP is non-nil, ignore temporary buffers." (member (file-truename bfn) agenda-files))))) (t (lambda (b) (with-current-buffer b (or (derived-mode-p 'org-mode) - (string-match "\*Org .*Export" + (string-match "\\*Org .*Export" (buffer-name b))))))))) (delq nil (mapcar @@ -18520,15 +18388,15 @@ the buffer and restores the previous window configuration." (if (stringp org-agenda-files) (let ((cw (current-window-configuration))) (find-file org-agenda-files) - (org-set-local 'org-window-configuration cw) - (org-add-hook 'after-save-hook - (lambda () - (set-window-configuration - (prog1 org-window-configuration - (kill-buffer (current-buffer)))) - (org-install-agenda-files-menu) - (message "New agenda file list installed")) - nil 'local) + (setq-local org-window-configuration cw) + (add-hook 'after-save-hook + (lambda () + (set-window-configuration + (prog1 org-window-configuration + (kill-buffer (current-buffer)))) + (org-install-agenda-files-menu) + (message "New agenda file list installed")) + nil 'local) (message "%s" (substitute-command-keys "Edit list and finish with \\[save-buffer]"))) (customize-variable 'org-agenda-files))) @@ -18587,7 +18455,7 @@ If the current buffer does not, find the first agenda file." (while (and (setq file (pop files)) (not (equal (file-truename file) tcf))))) (find-file (car (or files fs))) - (if (buffer-base-buffer) (org-pop-to-buffer-same-window (buffer-base-buffer))))) + (when (buffer-base-buffer) (pop-to-buffer-same-window (buffer-base-buffer))))) (defun org-agenda-file-to-front (&optional to-end) "Move/add the current file to the top of the agenda file list. @@ -18605,7 +18473,7 @@ end of the list." x had) (setq x (assoc ctf file-alist) had x) - (if (not x) (setq x (cons ctf (abbreviate-file-name buffer-file-name)))) + (unless x (setq x (cons ctf (abbreviate-file-name buffer-file-name)))) (if to-end (setq file-alist (append (delq x file-alist) (list x))) (setq file-alist (cons x (delq x file-alist)))) @@ -18626,9 +18494,9 @@ Optional argument FILE means use this file instead of the current." (afile (abbreviate-file-name file)) (files (delq nil (mapcar (lambda (x) - (if (equal true-file - (file-truename x)) - nil x)) + (unless (equal true-file + (file-truename x)) + x)) (org-agenda-files t))))) (if (not (= (length files) (length (org-agenda-files t)))) (progn @@ -18642,7 +18510,7 @@ Optional argument FILE means use this file instead of the current." (defun org-check-agenda-file (file) "Make sure FILE exists. If not, ask user what to do." - (when (not (file-exists-p file)) + (unless (file-exists-p file) (message "Non-existent agenda file %s. [R]emove from list or [A]bort?" (abbreviate-file-name file)) (let ((r (downcase (read-char-exclusive)))) @@ -18661,7 +18529,7 @@ which might be released later." buf ; just return it ;; Make a new buffer and remember it (setq buf (find-file-noselect file)) - (if buf (push buf org-agenda-new-buffers)) + (when buf (push buf org-agenda-new-buffers)) buf))) (defun org-release-buffers (blist) @@ -18686,7 +18554,7 @@ 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 ":")) - file re pos) + re pos) (setq org-tag-alist-for-agenda nil org-tag-groups-alist-for-agenda nil) (save-excursion @@ -18717,20 +18585,23 @@ When a buffer is unmodified, it is just killed. When modified, it is saved (setq org-tag-alist-for-agenda (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-current-tag-alist))) + ;; Merge current file's tag groups into global + ;; `org-tag-groups-alist-for-agenda'. + (when org-group-tags + (dolist (alist org-tag-groups-alist) + (let ((old (assoc (car alist) org-tag-groups-alist-for-agenda))) + (if old + (setcdr old (org-uniquify (append (cdr old) (cdr alist)))) + (push alist org-tag-groups-alist-for-agenda))))) (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)))) + (when (org-at-heading-p t) + (add-text-properties (point-at-bol) (org-end-of-subtree t) pa)))) (goto-char (point-min)) (setq re (format "^\\*+ .*\\<%s\\>" org-comment-string)) (while (re-search-forward re nil t) @@ -18761,7 +18632,7 @@ When a buffer is unmodified, it is just killed. When modified, it is saved (define-minor-mode org-cdlatex-mode "Toggle the minor `org-cdlatex-mode'. This mode supports entering LaTeX environment and math in LaTeX fragments -in Org-mode. +in Org mode. \\{org-cdlatex-mode-map}" nil " OCDL" nil (when org-cdlatex-mode @@ -18771,11 +18642,11 @@ in Org-mode. (unless org-cdlatex-texmathp-advice-is-done (setq org-cdlatex-texmathp-advice-is-done t) (defadvice texmathp (around org-math-always-on activate) - "Always return t in org-mode buffers. + "Always return t in Org buffers. This is because we want to insert math symbols without dollars even outside -the LaTeX math segments. If Orgmode thinks that point is actually inside -an embedded LaTeX fragment, let texmathp do its job. -\\[org-cdlatex-mode-map]" +the LaTeX math segments. If Org mode thinks that point is actually inside +an embedded LaTeX fragment, let `texmathp' do its job. +`\\[org-cdlatex-mode-map]'" (interactive) (let (p) (cond @@ -18787,8 +18658,8 @@ an embedded LaTeX fragment, let texmathp do its job. (let ((p (org-inside-LaTeX-fragment-p))) (if (and p (member (car p) (plist-get org-format-latex-options :matchers))) (setq ad-return-value t - texmathp-why '("Org-mode embedded math" . 0)) - (if p ad-do-it))))))))) + texmathp-why '("Org mode embedded math" . 0)) + (when p ad-do-it))))))))) (defun turn-on-org-cdlatex () "Unconditionally turn on `org-cdlatex-mode'." @@ -18813,7 +18684,7 @@ It makes sense to do so if `org-cdlatex-mode' is active and if the cursor is (cdlatex-tab) t) ((org-inside-LaTeX-fragment-p) (cdlatex-tab) t)))) -(defun org-cdlatex-underscore-caret (&optional arg) +(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") @@ -18822,7 +18693,7 @@ Revert to the normal definition outside of these fragments." (let (org-cdlatex-mode) (call-interactively (key-binding (vector last-input-event)))))) -(defun org-cdlatex-math-modify (&optional arg) +(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") @@ -18851,10 +18722,10 @@ environment remains unintended." ;; environment has been inserted. (lines (when inserted (save-excursion - (- (loop while (< beg (point)) + (- (cl-loop while (< beg (point)) with x = 0 do (forward-line -1) - (incf x) + (cl-incf x) finally return x) (if (progn (goto-char beg) (and (progn (skip-chars-forward " \t") (eolp)) @@ -18880,11 +18751,11 @@ environment remains unintended." (save-excursion (goto-char beg) (while (< (point) end) - (unless (eolp) (org-indent-line-to ind)) + (unless (eolp) (indent-line-to ind)) (forward-line)))) (goto-char beg) (forward-line lines) - (org-indent-line-to ind))) + (indent-line-to ind))) (set-marker beg nil) (set-marker end nil))) @@ -18933,7 +18804,7 @@ looks only before point, not after." (while (re-search-backward "\\$\\$" lim t) (setq dd-on (not dd-on))) (goto-char pos) - (if dd-on (cons "$$" m)))))) + (when dd-on (cons "$$" m)))))) (defun org-inside-latex-macro-p () "Is point inside a LaTeX macro or its arguments?" @@ -18941,30 +18812,38 @@ looks only before point, not after." (org-in-regexp "\\\\[a-zA-Z]+\\*?\\(\\(\\[[^][\n{}]*\\]\\)\\|\\({[^{}\n]*}\\)\\)*"))) -(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) +(defun org--format-latex-make-overlay (beg end image &optional imagetype) + "Build an overlay between BEG and END using IMAGE file. +Argument IMAGETYPE is the extension of the displayed image, +as a string. It defaults to \"png\"." + (let ((ov (make-overlay beg end)) + (imagetype (or (intern imagetype) 'png))) + (overlay-put ov 'org-overlay-type 'org-latex-overlay) + (overlay-put ov 'evaporate t) + (overlay-put ov + 'modification-hooks + (list (lambda (o _flag _beg _end &optional _l) + (delete-overlay o)))) + (overlay-put ov + 'display + (list 'image :type imagetype :file image :ascent 'center)))) + +(defun org--list-latex-overlays (&optional beg end) + "List all Org LaTeX overlays in current buffer. +Limit to overlays between BEG and END when those are provided." + (cl-remove-if-not + (lambda (o) (eq (overlay-get o 'org-overlay-type) 'org-latex-overlay)) + (overlays-in (or beg (point-min)) (or end (point-max))))) (defun org-remove-latex-fragment-image-overlays (&optional beg end) "Remove all overlays with LaTeX fragment images in current buffer. When optional arguments BEG and END are non-nil, remove all -overlays between them instead. Return t when some overlays were -removed, nil otherwise." - (let (removedp) - (setq org-latex-fragment-image-overlays - (let ((beg (or beg (point-min))) - (end (or end (point-max)))) - (org-remove-if - (lambda (o) - (and (>= (overlay-start o) beg) - (<= (overlay-end o) end) - (progn (delete-overlay o) - (or removedp (setq removedp t))))) - org-latex-fragment-image-overlays))) - removedp)) - -(define-obsolete-function-alias - 'org-preview-latex-fragment 'org-toggle-latex-fragment "24.4") +overlays between them instead. Return a non-nil value when some +overlays were removed, nil otherwise." + (let ((overlays (org--list-latex-overlays beg end))) + (mapc #'delete-overlay overlays) + overlays)) + (defun org-toggle-latex-fragment (&optional arg) "Preview the LaTeX fragment at point, or all locally or globally. @@ -18975,75 +18854,71 @@ current section. With prefix ARG, preview or clear image for all fragments in the current subtree or in the whole buffer when used before the first -headline. With a double prefix ARG \\[universal-argument] \ -\\[universal-argument] preview or clear images +headline. With a prefix ARG `\\[universal-argument] \ +\\[universal-argument]' preview or clear images for all fragments in the buffer." (interactive "P") - (unless (buffer-file-name (buffer-base-buffer)) - (user-error "Can't preview LaTeX fragment in a non-file buffer")) (when (display-graphic-p) (catch 'exit (save-excursion - (let ((window-start (window-start)) msg) - (save-restriction - (cond - ((or (equal arg '(16)) - (and (equal arg '(4)) - (org-with-limited-levels (org-before-first-heading-p)))) - (if (org-remove-latex-fragment-image-overlays) - (progn (message "LaTeX fragments images removed from buffer") - (throw 'exit nil)) - (setq msg "Creating images for buffer..."))) - ((equal arg '(4)) - (org-with-limited-levels (org-back-to-heading t)) - (let ((beg (point)) - (end (progn (org-end-of-subtree t) (point)))) - (if (org-remove-latex-fragment-image-overlays beg end) - (progn - (message "LaTeX fragment images removed from subtree") - (throw 'exit nil)) - (setq msg "Creating images for subtree...") - (narrow-to-region beg end)))) - ((let ((datum (org-element-context))) - (when (memq (org-element-type datum) - '(latex-environment latex-fragment)) - (let* ((beg (org-element-property :begin datum)) - (end (org-element-property :end datum))) - (if (org-remove-latex-fragment-image-overlays beg end) - (progn (message "LaTeX fragment image removed") - (throw 'exit nil)) - (narrow-to-region beg end) - (setq msg "Creating image...")))))) - (t - (org-with-limited-levels - (let ((beg (if (org-at-heading-p) (line-beginning-position) - (outline-previous-heading) - (point))) - (end (progn (outline-next-heading) (point)))) - (if (org-remove-latex-fragment-image-overlays beg end) - (progn - (message "LaTeX fragment images removed from section") + (let (beg end msg) + (cond + ((or (equal arg '(16)) + (and (equal arg '(4)) + (org-with-limited-levels (org-before-first-heading-p)))) + (if (org-remove-latex-fragment-image-overlays) + (progn (message "LaTeX fragments images removed from buffer") (throw 'exit nil)) - (setq msg "Creating images for section...") - (narrow-to-region beg end)))))) - (let ((file (buffer-file-name (buffer-base-buffer)))) - (org-format-latex - (concat org-latex-preview-ltxpng-directory - (file-name-sans-extension (file-name-nondirectory file))) - ;; Emacs cannot overlay images from remote hosts. - ;; Create it in `temporary-file-directory' instead. - (if (file-remote-p file) temporary-file-directory - default-directory) - 'overlays msg 'forbuffer - org-latex-create-formula-image-program))) - ;; Work around a bug that doesn't restore window's start - ;; when widening back the buffer. - (set-window-start nil window-start) + (setq msg "Creating images for buffer..."))) + ((equal arg '(4)) + (org-with-limited-levels (org-back-to-heading t)) + (setq beg (point)) + (setq end (progn (org-end-of-subtree t) (point))) + (if (org-remove-latex-fragment-image-overlays beg end) + (progn + (message "LaTeX fragment images removed from subtree") + (throw 'exit nil)) + (setq msg "Creating images for subtree..."))) + ((let ((datum (org-element-context))) + (when (memq (org-element-type datum) + '(latex-environment latex-fragment)) + (setq beg (org-element-property :begin datum)) + (setq end (org-element-property :end datum)) + (if (org-remove-latex-fragment-image-overlays beg end) + (progn (message "LaTeX fragment image removed") + (throw 'exit nil)) + (setq msg "Creating image..."))))) + (t + (org-with-limited-levels + (setq beg (if (org-at-heading-p) (line-beginning-position) + (outline-previous-heading) + (point))) + (setq end (progn (outline-next-heading) (point))) + (if (org-remove-latex-fragment-image-overlays beg end) + (progn + (message "LaTeX fragment images removed from section") + (throw 'exit nil)) + (setq msg "Creating images for section..."))))) + (let ((file (buffer-file-name (buffer-base-buffer)))) + (org-format-latex + (concat org-preview-latex-image-directory "org-ltximg") + beg end + ;; Emacs cannot overlay images from remote hosts. Create + ;; it in `temporary-file-directory' instead. + (if (or (not file) (file-remote-p file)) + temporary-file-directory + default-directory) + 'overlays msg 'forbuffer org-preview-latex-default-process)) (message (concat msg "done"))))))) (defun org-format-latex - (prefix &optional dir overlays msg forbuffer processing-type) - "Replace LaTeX fragments with links to an image, and produce images. + (prefix &optional beg end dir overlays msg forbuffer processing-type) + "Replace LaTeX fragments with links to an image. + +The function takes care of creating the replacement image. + +Only consider fragments between BEG and END when those are +provided. When optional argument OVERLAYS is non-nil, display the image on top of the fragment instead of replacing it. @@ -19057,11 +18932,11 @@ Some of the options can be changed using the variable (let* ((math-regexp "\\$\\|\\\\[([]\\|^[ \t]*\\\\begin{[A-Za-z0-9*]+}") (cnt 0) checkdir-flag) - (goto-char (point-min)) + (goto-char (or beg (point-min))) ;; Optimize overlay creation: (info "(elisp) Managing Overlays"). (when (and overlays (memq processing-type '(dvipng imagemagick))) - (overlay-recenter (point-max))) - (while (re-search-forward math-regexp nil t) + (overlay-recenter (or end (point-max)))) + (while (re-search-forward math-regexp end t) (unless (and overlays (eq (get-char-property (point) 'org-overlay-type) 'org-latex-overlay)) @@ -19075,102 +18950,88 @@ Some of the options can be changed using the variable (goto-char (org-element-property :end context)) (skip-chars-backward " \r\t\n") (point)))) - (case processing-type - (mathjax - ;; Prepare for MathJax processing. - (if (eq (char-after beg) ?$) - (save-excursion - (delete-region beg end) - (insert "\\(" (substring value 1 -1) "\\)")) - (goto-char end))) - ((dvipng imagemagick) - ;; Process to an image. - (incf cnt) - (goto-char beg) - (let* ((face (face-at-point)) - ;; Get the colors from the face at point. - (fg - (let ((color (plist-get org-format-latex-options - :foreground))) - (if (and forbuffer (eq color 'auto)) - (face-attribute face :foreground nil 'default) - color))) - (bg - (let ((color (plist-get org-format-latex-options - :background))) - (if (and forbuffer (eq color 'auto)) - (face-attribute face :background nil 'default) - color))) - (hash (sha1 (prin1-to-string - (list org-format-latex-header - org-latex-default-packages-alist - org-latex-packages-alist - org-format-latex-options - forbuffer value fg bg)))) - (absprefix (expand-file-name prefix dir)) - (linkfile (format "%s_%s.png" prefix hash)) - (movefile (format "%s_%s.png" absprefix hash)) - (sep (and block-type "\n\n")) - (link (concat sep "[[file:" linkfile "]]" sep)) - (options - (org-combine-plists - org-format-latex-options - `(:foreground ,fg :background ,bg)))) - (when msg (message msg cnt)) - (unless checkdir-flag ; Ensure the directory exists. - (setq checkdir-flag t) - (let ((todir (file-name-directory absprefix))) - (unless (file-directory-p todir) - (make-directory todir t)))) - (unless (file-exists-p movefile) - (org-create-formula-image - value movefile options forbuffer processing-type)) - (if overlays - (progn - (dolist (o (overlays-in beg end)) - (when (eq (overlay-get o 'org-overlay-type) - 'org-latex-overlay) - (delete-overlay o))) - (let ((ov (make-overlay beg end))) - (overlay-put ov - 'org-overlay-type - 'org-latex-overlay) - (overlay-put ov 'evaporate t) - (if (featurep 'xemacs) - (progn - (overlay-put ov 'invisible t) - (overlay-put - ov 'end-glyph - (make-glyph - (vector 'png :file movefile)))) - (overlay-put - ov 'display - (list 'image - :type 'png - :file movefile - :ascent 'center))) - (push ov org-latex-fragment-image-overlays)) - (goto-char end)) - (delete-region beg end) - (insert - (org-add-props link - (list 'org-latex-src - (replace-regexp-in-string "\"" "" value) - 'org-latex-src-embed-type - (if block-type 'paragraph 'character))))))) - (mathml - ;; Process to MathML. - (unless (org-format-latex-mathml-available-p) - (user-error "LaTeX to MathML converter not configured")) - (incf cnt) - (when msg (message msg cnt)) - (goto-char beg) - (delete-region beg end) - (insert (org-format-latex-as-mathml - value block-type prefix dir))) - (otherwise - (error "Unknown conversion type %s for LaTeX fragments" - processing-type))))))))))) + (cond + ((eq processing-type 'mathjax) + ;; Prepare for MathJax processing. + (if (not (string-match "\\`\\$\\$?" value)) + (goto-char end) + (delete-region beg end) + (if (string= (match-string 0 value) "$$") + (insert "\\[" (substring value 2 -2) "\\]") + (insert "\\(" (substring value 1 -1) "\\)")))) + ((assq processing-type org-preview-latex-process-alist) + ;; Process to an image. + (cl-incf cnt) + (goto-char beg) + (let* ((processing-info + (cdr (assq processing-type org-preview-latex-process-alist))) + (face (face-at-point)) + ;; Get the colors from the face at point. + (fg + (let ((color (plist-get org-format-latex-options + :foreground))) + (if (and forbuffer (eq color 'auto)) + (face-attribute face :foreground nil 'default) + color))) + (bg + (let ((color (plist-get org-format-latex-options + :background))) + (if (and forbuffer (eq color 'auto)) + (face-attribute face :background nil 'default) + color))) + (hash (sha1 (prin1-to-string + (list org-format-latex-header + org-latex-default-packages-alist + org-latex-packages-alist + org-format-latex-options + forbuffer value fg bg)))) + (imagetype (or (plist-get processing-info :image-output-type) "png")) + (absprefix (expand-file-name prefix dir)) + (linkfile (format "%s_%s.%s" prefix hash imagetype)) + (movefile (format "%s_%s.%s" absprefix hash imagetype)) + (sep (and block-type "\n\n")) + (link (concat sep "[[file:" linkfile "]]" sep)) + (options + (org-combine-plists + org-format-latex-options + `(:foreground ,fg :background ,bg)))) + (when msg (message msg cnt)) + (unless checkdir-flag ; Ensure the directory exists. + (setq checkdir-flag t) + (let ((todir (file-name-directory absprefix))) + (unless (file-directory-p todir) + (make-directory todir t)))) + (unless (file-exists-p movefile) + (org-create-formula-image + value movefile options forbuffer processing-type)) + (if overlays + (progn + (dolist (o (overlays-in beg end)) + (when (eq (overlay-get o 'org-overlay-type) + 'org-latex-overlay) + (delete-overlay o))) + (org--format-latex-make-overlay beg end movefile imagetype) + (goto-char end)) + (delete-region beg end) + (insert + (org-add-props link + (list 'org-latex-src + (replace-regexp-in-string "\"" "" value) + 'org-latex-src-embed-type + (if block-type 'paragraph 'character))))))) + ((eq processing-type 'mathml) + ;; Process to MathML. + (unless (org-format-latex-mathml-available-p) + (user-error "LaTeX to MathML converter not configured")) + (cl-incf cnt) + (when msg (message msg cnt)) + (goto-char beg) + (delete-region beg end) + (insert (org-format-latex-as-mathml + value block-type prefix dir))) + (t + (error "Unknown conversion process %s for LaTeX fragments" + processing-type))))))))))) (defun org-create-math-formula (latex-frag &optional mathml-file) "Convert LATEX-FRAG to MathML and store it in MATHML-FILE. @@ -19186,22 +19047,24 @@ inspection." (region-beginning) (region-end))))) (read-string "LaTeX Fragment: " frag nil frag)))) (unless latex-frag (user-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)) + (let* ((tmp-in-file + (let ((file (file-relative-name + (make-temp-name (expand-file-name "ltxmathml-in"))))) + (write-region latex-frag nil file) + file)) (tmp-out-file (file-relative-name (make-temp-name (expand-file-name "ltxmathml-out")))) (cmd (format-spec org-latex-to-mathml-convert-command `((?j . ,(and org-latex-to-mathml-jar-file - (shell-quote-argument - (expand-file-name - org-latex-to-mathml-jar-file)))) + (shell-quote-argument + (expand-file-name + org-latex-to-mathml-jar-file)))) (?I . ,(shell-quote-argument tmp-in-file)) (?i . ,latex-frag) (?o . ,(shell-quote-argument tmp-out-file))))) mathml shell-command-output) - (when (org-called-interactively-p 'any) + (when (called-interactively-p 'any) (unless (org-format-latex-mathml-available-p) (user-error "LaTeX to MathML converter not configured"))) (message "Running %s" cmd) @@ -19211,12 +19074,9 @@ inspection." (with-current-buffer (find-file-noselect tmp-out-file t) (goto-char (point-min)) (when (re-search-forward - (concat - (regexp-quote - "]*?>" - "\\(.\\|\n\\)*" - "") + (format "]*?%s[^>]*?>\\(.\\|\n\\)*" + (regexp-quote + "xmlns=\"http://www.w3.org/1998/Math/MathML\"")) nil t) (prog1 (match-string 0) (kill-buffer)))))) (cond @@ -19225,7 +19085,7 @@ inspection." (concat "\n" mathml)) (when mathml-file (write-region mathml nil mathml-file)) - (when (org-called-interactively-p 'any) + (when (called-interactively-p 'any) (message mathml))) ((message "LaTeX to MathML conversion failed") (message shell-command-output))) @@ -19264,188 +19124,117 @@ inspection." ;; Failed conversion. Return the LaTeX fragment verbatim 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))) - (defun org--get-display-dpi () "Get the DPI of the display. - -Assumes that the display has the same pixel width in the -horizontal and vertical directions." +The function assumes that the display has the same pixel width in +the horizontal and vertical directions." (if (display-graphic-p) (round (/ (display-pixel-height) (/ (display-mm-height) 25.4))) (error "Attempt to calculate the dpi of a non-graphic display"))) -;; This function borrows from Ganesh Swami's latex2png.el -(defun org-create-formula-image-with-dvipng (string tofile options buffer) - "This calls dvipng." - (require 'ox-latex) - (let* ((tmpdir (if (featurep 'xemacs) - (temp-directory) - temporary-file-directory)) +(defun org-create-formula-image + (string tofile options buffer &optional processing-type) + "Create an image from LaTeX source using external processes. + +The LaTeX STRING is saved to a temporary LaTeX file, then +converted to an image file by process PROCESSING-TYPE defined in +`org-preview-latex-process-alist'. A nil value defaults to +`org-preview-latex-default-process'. + +The generated image file is eventually moved to TOFILE. + +The OPTIONS argument controls the size, foreground color and +background color of the generated image. + +When BUFFER non-nil, this function is used for LaTeX previewing. +Otherwise, it is used to deal with LaTeX snippets showed in +a HTML file." + (let* ((processing-type (or processing-type + org-preview-latex-default-process)) + (processing-info + (cdr (assq processing-type org-preview-latex-process-alist))) + (programs (plist-get processing-info :programs)) + (error-message (or (plist-get processing-info :message) "")) + (use-xcolor (plist-get processing-info :use-xcolor)) + (image-input-type (plist-get processing-info :image-input-type)) + (image-output-type (plist-get processing-info :image-output-type)) + (post-clean (or (plist-get processing-info :post-clean) + '(".dvi" ".xdv" ".pdf" ".tex" ".aux" ".log" + ".svg" ".png" ".jpg" ".jpeg" ".out"))) + (latex-header + (or (plist-get processing-info :latex-header) + (org-latex-make-preamble + (org-export-get-environment (org-export-get-backend 'latex)) + org-format-latex-header + 'snippet))) + (latex-compiler (plist-get processing-info :latex-compiler)) + (image-converter (plist-get processing-info :image-converter)) + (tmpdir temporary-file-directory) (texfilebase (make-temp-name (expand-file-name "orgtex" tmpdir))) (texfile (concat texfilebase ".tex")) - (dvifile (concat texfilebase ".dvi")) - (pngfile (concat texfilebase ".png")) - (scale (or (plist-get options (if buffer :scale :html-scale)) 1.0)) - ;; This assumes that the display has the same pixel width in - ;; the horizontal and vertical directions - (dpi (number-to-string (* scale (if buffer (org--get-display-dpi) 120)))) + (image-size-adjust (or (plist-get processing-info :image-size-adjust) + '(1.0 . 1.0))) + (scale (* (if buffer (car image-size-adjust) (cdr image-size-adjust)) + (or (plist-get options (if buffer :scale :html-scale)) 1.0))) + (dpi (* scale (if buffer (org--get-display-dpi) 140.0))) (fg (or (plist-get options (if buffer :foreground :html-foreground)) "Black")) (bg (or (plist-get options (if buffer :background :html-background)) - "Transparent"))) - (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))) + "Transparent")) + (log-buf (get-buffer-create "*Org Preview LaTeX Output*")) + (resize-mini-windows nil)) ;Fix Emacs flicker when creating image. + (dolist (program programs) + (org-check-external-command program error-message)) + (if use-xcolor + (progn (if (eq fg 'default) + (setq fg (org-latex-color :foreground)) + (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") "white" bg)))) + (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"))) + (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)))) (with-temp-file texfile (insert latex-header) (insert "\n\\begin{document}\n" string "\n\\end{document}\n"))) - (let ((dir default-directory)) - (ignore-errors - (cd tmpdir) - (call-process "latex" nil nil nil texfile)) - (cd dir)) - (if (not (file-exists-p dvifile)) - (progn (message "Failed to create dvi file from %s" texfile) nil) - (ignore-errors - (if (featurep 'xemacs) - (call-process "dvipng" nil nil nil - "-fg" fg "-bg" bg - "-T" "tight" - "-o" pngfile - dvifile) - (call-process "dvipng" nil nil nil - "-fg" fg "-bg" bg - "-D" dpi - ;;"-x" scale "-y" scale - "-T" "tight" - "-o" pngfile - dvifile))) - (if (not (file-exists-p pngfile)) - (if org-format-latex-signal-error - (error "Failed to create png file from %s" texfile) - (message "Failed to create png file from %s" texfile) - nil) - ;; Use the requested file name and clean up - (copy-file pngfile tofile 'replace) - (loop for e in '(".dvi" ".tex" ".aux" ".log" ".png" ".out") do - (if (file-exists-p (concat texfilebase e)) - (delete-file (concat texfilebase e)))) - pngfile)))) - -(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 'ox-latex) - (let* ((tmpdir (if (featurep 'xemacs) - (temp-directory) - temporary-file-directory)) - (texfilebase (make-temp-name - (expand-file-name "orgtex" tmpdir))) - (texfile (concat texfilebase ".tex")) - (pdffile (concat texfilebase ".pdf")) - (pngfile (concat texfilebase ".png")) - (scale (or (plist-get options (if buffer :scale :html-scale)) 1.0)) - (dpi (number-to-string (* scale (if buffer (org--get-display-dpi) 120)))) - (fg (or (plist-get options (if buffer :foreground :html-foreground)) - "black")) - (bg (or (plist-get options (if buffer :background :html-background)) - "white"))) - (if (eq fg 'default) (setq fg (org-latex-color :foreground)) - (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") "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) - (ignore-errors - (if (featurep 'xemacs) - (call-process "convert" nil nil nil - "-density" "96" - "-trim" - "-antialias" - pdffile - "-quality" "100" - ;; "-sharpen" "0x1.0" - pngfile) - (call-process "convert" nil nil nil - "-density" dpi - "-trim" - "-antialias" - pdffile - "-quality" "100" - ;; "-sharpen" "0x1.0" - pngfile))) - (if (not (file-exists-p pngfile)) - (if org-format-latex-signal-error - (error "Failed to create png file from %s" texfile) - (message "Failed to create png file from %s" texfile) - nil) - ;; Use the requested file name and clean up - (copy-file pngfile tofile 'replace) - (loop for e in '(".pdf" ".tex" ".aux" ".log" ".png") do - (if (file-exists-p (concat texfilebase e)) - (delete-file (concat texfilebase e)))) - pngfile)))) + + (let* ((err-msg (format "Please adjust '%s' part of \ +`org-preview-latex-process-alist'." + processing-type)) + (image-input-file + (org-compile-file + texfile latex-compiler image-input-type err-msg log-buf)) + (image-output-file + (org-compile-file + image-input-file image-converter image-output-type err-msg log-buf + `((?F . ,(shell-quote-argument fg)) + (?B . ,(shell-quote-argument bg)) + (?D . ,(shell-quote-argument (format "%s" dpi))) + (?S . ,(shell-quote-argument (format "%s" (/ dpi 140.0)))))))) + (copy-file image-output-file tofile 'replace) + (dolist (e post-clean) + (when (file-exists-p (concat texfilebase e)) + (delete-file (concat texfilebase e)))) + image-output-file))) (defun org-splice-latex-header (tpl def-pkg pkg snippets-p &optional extra) "Fill a LaTeX header template TPL. @@ -19469,22 +19258,22 @@ SNIPPETS-P indicates if this is run to create snippet images for HTML." (setq rpl (if (or (match-end 1) (not def-pkg)) "" (org-latex-packages-to-string def-pkg snippets-p t)) tpl (replace-match rpl t t tpl)) - (if def-pkg (setq end (org-latex-packages-to-string def-pkg snippets-p)))) + (when def-pkg (setq end (org-latex-packages-to-string def-pkg snippets-p)))) (if (string-match "\\[\\(NO-\\)?PACKAGES\\][ \t]*\n?" tpl) (setq rpl (if (or (match-end 1) (not pkg)) "" (org-latex-packages-to-string pkg snippets-p t)) tpl (replace-match rpl t t tpl)) - (if pkg (setq end - (concat end "\n" - (org-latex-packages-to-string pkg snippets-p))))) + (when pkg (setq end + (concat end "\n" + (org-latex-packages-to-string pkg snippets-p))))) (if (string-match "\\[\\(NO-\\)?EXTRA\\][ \t]*\n?" tpl) (setq rpl (if (or (match-end 1) (not extra)) "" (concat extra "\n")) tpl (replace-match rpl t t tpl)) - (if (and extra (string-match "\\S-" extra)) - (setq end (concat end "\n" extra)))) + (when (and extra (string-match "\\S-" extra)) + (setq end (concat end "\n" extra)))) (if (string-match "\\S-" end) (concat tpl "\n" end) @@ -19508,35 +19297,21 @@ SNIPPETS-P indicates if this is run to create snippet images for HTML." (defun org-dvipng-color (attr) "Return a RGB color specification for dvipng." - (apply 'format "rgb %s %s %s" - (mapcar 'org-normalize-color - (if (featurep 'xemacs) - (color-rgb-components - (face-property 'default - (cond ((eq attr :foreground) 'foreground) - ((eq attr :background) 'background)))) - (color-values (face-attribute 'default attr nil)))))) + (org-dvipng-color-format (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" + (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" - (mapcar 'org-normalize-color - (if (featurep 'xemacs) - (color-rgb-components - (face-property 'default - (cond ((eq attr :foreground) 'foreground) - ((eq attr :background) 'background)))) - (color-values (face-attribute 'default attr nil)))))) + (org-latex-color-format (face-attribute 'default attr nil))) (defun org-latex-color-format (color-name) "Convert COLOR-NAME to a RGB color value." - (apply 'format "%s,%s,%s" + (apply #'format "%s,%s,%s" (mapcar 'org-normalize-color (color-values color-name)))) @@ -19548,8 +19323,7 @@ SNIPPETS-P indicates if this is run to create snippet images for HTML." ;; Image display -(defvar org-inline-image-overlays nil) -(make-variable-buffer-local 'org-inline-image-overlays) +(defvar-local org-inline-image-overlays nil) (defun org-toggle-inline-images (&optional include-linked) "Toggle the display of inline images. @@ -19558,10 +19332,10 @@ INCLUDE-LINKED is passed to `org-display-inline-images'." (if org-inline-image-overlays (progn (org-remove-inline-images) - (when (org-called-interactively-p 'interactive) + (when (called-interactively-p 'interactive) (message "Inline image display turned off"))) (org-display-inline-images include-linked) - (when (org-called-interactively-p 'interactive) + (when (called-interactively-p 'interactive) (message (if org-inline-image-overlays (format "%d images displayed inline" (length org-inline-image-overlays)) @@ -19604,7 +19378,7 @@ boundaries." (org-with-wide-buffer (goto-char (or beg (point-min))) (let ((case-fold-search t) - (file-extension-re (org-image-file-name-regexp))) + (file-extension-re (image-file-name-regexp))) (while (re-search-forward "[][]\\[\\(?:file\\|[./~]\\)" end t) (let ((link (save-match-data (org-element-context)))) ;; Check if we're at an inline image. @@ -19614,8 +19388,8 @@ boundaries." (let ((parent (org-element-property :parent link))) (or (not (eq (org-element-type parent) 'link)) (not (cdr (org-element-contents parent))))) - (org-string-match-p file-extension-re - (org-element-property :path link))) + (string-match-p file-extension-re + (org-element-property :path link))) (let ((file (expand-file-name (org-link-unescape (org-element-property :path link))))) @@ -19686,10 +19460,7 @@ boundaries." (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") - -(defun org-display-inline-remove-overlay (ov after beg end &optional len) +(defun org-display-inline-remove-overlay (ov after _beg _end &optional _len) "Remove inline-display overlay if a corresponding region is modified." (let ((inhibit-modification-hooks t)) (when (and ov after) @@ -19699,7 +19470,7 @@ boundaries." (defun org-remove-inline-images () "Remove inline display of images." (interactive) - (mapc 'delete-overlay org-inline-image-overlays) + (mapc #'delete-overlay org-inline-image-overlays) (setq org-inline-image-overlays nil)) ;;;; Key bindings @@ -19707,12 +19478,12 @@ boundaries." ;; Outline functions from `outline-mode-prefix-map' ;; that can be remapped in Org: (define-key org-mode-map [remap outline-mark-subtree] 'org-mark-subtree) -(define-key org-mode-map [remap show-subtree] 'org-show-subtree) +(define-key org-mode-map [remap outline-show-subtree] 'org-show-subtree) (define-key org-mode-map [remap outline-forward-same-level] 'org-forward-heading-same-level) (define-key org-mode-map [remap outline-backward-same-level] 'org-backward-heading-same-level) -(define-key org-mode-map [remap show-branches] +(define-key org-mode-map [remap outline-show-branches] 'org-kill-note-or-show-branches) (define-key org-mode-map [remap outline-promote] 'org-promote-subtree) (define-key org-mode-map [remap outline-demote] 'org-demote-subtree) @@ -19721,6 +19492,7 @@ boundaries." 'org-next-visible-heading) (define-key org-mode-map [remap outline-previous-visible-heading] 'org-previous-visible-heading) +(define-key org-mode-map [remap show-children] 'org-show-children) ;; Outline functions from `outline-mode-prefix-map' that can not ;; be remapped in Org: @@ -19733,13 +19505,10 @@ boundaries." ;; | Outline function | key binding | Org replacement | ;; |------------------------------------+-------------+--------------------------| -;; | `outline-next-visible-heading' | `C-c C-n' | better: skip inlinetasks | -;; | `outline-previous-visible-heading' | `C-c C-p' | better: skip inlinetasks | ;; | `outline-up-heading' | `C-c C-u' | still same function | ;; | `outline-move-subtree-up' | overridden | better: org-shiftup | ;; | `outline-move-subtree-down' | overridden | better: org-shiftdown | ;; | `show-entry' | overridden | no replacement | -;; | `show-children' | `C-c C-i' | visibility cycling | ;; | `show-branches' | `C-c C-k' | still same function | ;; | `show-subtree' | overridden | visibility cycling | ;; | `show-all' | overridden | no replacement | @@ -19759,8 +19528,7 @@ boundaries." (org-defkey org-mode-map [(control tab)] 'org-force-cycle-archived) (org-defkey org-mode-map "\M-\t" #'pcomplete) ;; The following line is necessary under Suse GNU/Linux -(unless (featurep 'xemacs) - (org-defkey org-mode-map [S-iso-lefttab] 'org-shifttab)) +(org-defkey org-mode-map [S-iso-lefttab] 'org-shifttab) (org-defkey org-mode-map [(shift tab)] 'org-shifttab) (define-key org-mode-map [backtab] 'org-shifttab) @@ -19793,17 +19561,14 @@ boundaries." ;; Babel keys (define-key org-mode-map org-babel-key-prefix org-babel-map) -(mapc (lambda (pair) - (define-key org-babel-map (car pair) (cdr pair))) - org-babel-key-bindings) +(dolist (pair org-babel-key-bindings) + (define-key org-babel-map (car pair) (cdr pair))) ;;; Extra keys for tty access. ;; We only set them when really needed because otherwise the ;; menus don't show the simple keys -(when (or org-use-extra-keys - (featurep 'xemacs) ;; because XEmacs supports multi-device stuff - (not window-system)) +(when (or org-use-extra-keys (not window-system)) (org-defkey org-mode-map "\C-c\C-xc" 'org-table-copy-down) (org-defkey org-mode-map "\C-c\C-xM" 'org-insert-todo-heading) (org-defkey org-mode-map "\C-c\C-xm" 'org-meta-return) @@ -19835,7 +19600,7 @@ boundaries." ;; All the other keys -(org-defkey org-mode-map "\C-c\C-a" 'show-all) ; in case allout messed up. +(org-defkey org-mode-map "\C-c\C-a" 'outline-show-all) ; in case allout messed up. (org-defkey org-mode-map "\C-c\C-r" 'org-reveal) (if (boundp 'narrow-map) (org-defkey narrow-map "s" 'org-narrow-to-subtree) @@ -19874,7 +19639,6 @@ boundaries." (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) -(org-defkey org-mode-map "\M-\C-m" 'org-insert-heading) (org-defkey org-mode-map "\C-c\C-xc" 'org-clone-subtree-with-time-shift) (org-defkey org-mode-map "\C-c\C-xv" 'org-copy-visible) (org-defkey org-mode-map [(control return)] 'org-insert-heading-respect-content) @@ -19962,7 +19726,7 @@ boundaries." (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) -(org-defkey org-mode-map "\C-c\C-xi" 'org-insert-columns-dblock) +(org-defkey org-mode-map "\C-c\C-xi" 'org-columns-insert-dblock) (org-defkey org-mode-map [(control ?c) (control ?x) ?\;] 'org-timer-set-timer) (org-defkey org-mode-map "\C-c\C-x." 'org-timer) @@ -19981,10 +19745,6 @@ boundaries." (define-key org-mode-map "\C-c\C-x[" 'org-reftex-citation) -(when (featurep 'xemacs) - (org-defkey org-mode-map 'button3 'popup-mode-menu)) - - (defconst org-speed-commands-default '( ("Outline Navigation") @@ -20065,10 +19825,10 @@ boundaries." (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) + (mapc #'org-print-speed-command org-speed-commands-user) (princ "\n") (princ "Built-in Speed commands\n=======================\n") - (mapc 'org-print-speed-command org-speed-commands-default)) + (mapc #'org-print-speed-command org-speed-commands-default)) (with-current-buffer "*Help*" (setq truncate-lines t)))) @@ -20087,9 +19847,6 @@ If not, return to the original position and throw an error." (defvar org-table-auto-blank-field) ; defined in org-table.el (defvar org-speed-command nil) -(define-obsolete-function-alias - 'org-speed-command-default-hook 'org-speed-command-activate "24.3") - (defun org-speed-command-activate (keys) "Hook for activating single-letter speed commands. `org-speed-commands-default' specifies a minimal command set. @@ -20100,16 +19857,13 @@ Use `org-speed-commands-user' for further customization." (cdr (assoc keys (append org-speed-commands-user org-speed-commands-default))))) -(define-obsolete-function-alias - 'org-babel-speed-command-hook 'org-babel-speed-command-activate "24.3") - (defun org-babel-speed-command-activate (keys) "Hook for activating single-letter code block commands." (when (and (bolp) (looking-at org-babel-src-block-regexp)) (cdr (assoc keys org-babel-key-bindings)))) (defcustom org-speed-command-hook - '(org-speed-command-default-hook org-babel-speed-command-hook) + '(org-speed-command-activate org-babel-speed-command-activate) "Hook for activating speed commands at strategic locations. Hook functions are called in sequence until a valid handler is found. @@ -20151,94 +19905,98 @@ overwritten, and the table is not marked as requiring realignment." (t (let (org-use-speed-commands) (call-interactively 'org-self-insert-command))))) ((and - (org-table-p) + (org-at-table-p) (progn - ;; check if we blank the field, and if that triggers align + ;; Check if we blank the field, and if that triggers align. (and (featurep 'org-table) org-table-auto-blank-field (memq last-command '(org-cycle org-return org-shifttab org-ctrl-c-ctrl-c)) - (if (or (equal (char-after) ?\ ) (looking-at "[^|\n]* |")) - ;; got extra space, this field does not determine column width + (if (or (eq (char-after) ?\s) (looking-at "[^|\n]* |")) + ;; Got extra space, this field does not determine + ;; column width. (let (org-table-may-need-update) (org-table-blank-field)) - ;; no extra space, this field may determine column width + ;; No extra space, this field may determine column + ;; width. (org-table-blank-field))) t) (eq N 1) - (looking-at "[^|\n]* |")) - (let (org-table-may-need-update) - (goto-char (1- (match-end 0))) - (backward-delete-char 1) - (goto-char (match-beginning 0)) - (self-insert-command N))) + (looking-at "[^|\n]* \\( \\)|")) + ;; There is room for insertion without re-aligning the table. + (delete-region (match-beginning 1) (match-end 1)) + (self-insert-command N)) (t (setq org-table-may-need-update t) (self-insert-command N) (org-fix-tags-on-the-fly) - (if org-self-insert-cluster-for-undo - (if (not (eq last-command 'org-self-insert-command)) + (when org-self-insert-cluster-for-undo + (if (not (eq last-command 'org-self-insert-command)) + (setq org-self-insert-command-undo-counter 1) + (if (>= org-self-insert-command-undo-counter 20) (setq org-self-insert-command-undo-counter 1) - (if (>= org-self-insert-command-undo-counter 20) - (setq org-self-insert-command-undo-counter 1) - (and (> org-self-insert-command-undo-counter 0) - buffer-undo-list (listp buffer-undo-list) - (not (cadr buffer-undo-list)) ; remove nil entry - (setcdr buffer-undo-list (cddr buffer-undo-list))) - (setq org-self-insert-command-undo-counter - (1+ org-self-insert-command-undo-counter)))))))) + (and (> org-self-insert-command-undo-counter 0) + buffer-undo-list (listp buffer-undo-list) + (not (cadr buffer-undo-list)) ; remove nil entry + (setcdr buffer-undo-list (cddr buffer-undo-list))) + (setq org-self-insert-command-undo-counter + (1+ org-self-insert-command-undo-counter)))))))) (defun org-check-before-invisible-edit (kind) "Check is editing if kind KIND would be dangerous with invisible text around. The detailed reaction depends on the user option `org-catch-invisible-edits'." ;; First, try to get out of here as quickly as possible, to reduce overhead - (if (and org-catch-invisible-edits - (or (not (boundp 'visible-mode)) (not visible-mode)) - (or (get-char-property (point) 'invisible) - (get-char-property (max (point-min) (1- (point))) 'invisible))) - ;; OK, we need to take a closer look - (let* ((invisible-at-point (get-char-property (point) 'invisible)) - (invisible-before-point (if (bobp) nil (get-char-property - (1- (point)) 'invisible))) - (border-and-ok-direction - (or - ;; Check if we are acting predictably before invisible text - (and invisible-at-point (not invisible-before-point) - (memq kind '(insert delete-backward))) - ;; Check if we are acting predictably after invisible text - ;; This works not well, and I have turned it off. It seems - ;; better to always show and stop after invisible text. - ;; (and (not invisible-at-point) invisible-before-point - ;; (memq kind '(insert delete))) - ))) - (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) - (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) - ;; Make the area visible - (save-excursion - (if invisible-before-point - (goto-char (previous-single-char-property-change - (point) 'invisible))) - (show-subtree)) - (cond - ((eq org-catch-invisible-edits 'show) - ;; That's it, we do the edit after showing - (message - "Unfolding invisible region around point before editing") - (sit-for 1)) - ((and (eq org-catch-invisible-edits 'smart) - border-and-ok-direction) - (message "Unfolding invisible region around point before editing")) - (t - ;; Don't do the edit, make the user repeat it in full visibility - (user-error "Edit in invisible region aborted, repeat to confirm with text visible")))))))) + (when (and org-catch-invisible-edits + (or (not (boundp 'visible-mode)) (not visible-mode)) + (or (get-char-property (point) 'invisible) + (get-char-property (max (point-min) (1- (point))) 'invisible))) + ;; OK, we need to take a closer look + (let* ((invisible-at-point (get-char-property (point) 'invisible)) + (invisible-before-point (unless (bobp) (get-char-property + (1- (point)) 'invisible))) + (border-and-ok-direction + (or + ;; Check if we are acting predictably before invisible text + (and invisible-at-point (not invisible-before-point) + (memq kind '(insert delete-backward))) + ;; Check if we are acting predictably after invisible text + ;; This works not well, and I have turned it off. It seems + ;; better to always show and stop after invisible text. + ;; (and (not invisible-at-point) invisible-before-point + ;; (memq kind '(insert delete))) + ))) + (when (or (memq invisible-at-point '(outline org-hide-block t)) + (memq invisible-before-point '(outline org-hide-block t))) + (when (eq org-catch-invisible-edits 'error) + (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) + ;; Make the area visible + (save-excursion + (when invisible-before-point + (goto-char (previous-single-char-property-change + (point) 'invisible))) + (outline-show-subtree)) + (cond + ((eq org-catch-invisible-edits 'show) + ;; That's it, we do the edit after showing + (message + "Unfolding invisible region around point before editing") + (sit-for 1)) + ((and (eq org-catch-invisible-edits 'smart) + border-and-ok-direction) + (message "Unfolding invisible region around point before editing")) + (t + ;; Don't do the edit, make the user repeat it in full visibility + (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)) ?*) + "Align tags in headline at point. +Unlike to `org-set-tags', it ignores region and sorting." + (when (and (eq (char-after (line-beginning-position)) ?*) ;short-circuit (org-at-heading-p)) - (org-align-tags-here org-tags-column))) + (let ((org-ignore-region t) + (org-tags-sort-function nil)) + (org-set-tags nil t)))) (defun org-delete-backward-char (N) "Like `delete-backward-char', insert whitespace at field end in tables. @@ -20249,7 +20007,7 @@ because, in this case the deletion might narrow the column." (interactive "p") (save-match-data (org-check-before-invisible-edit 'delete-backward) - (if (and (org-table-p) + (if (and (org-at-table-p) (eq N 1) (string-match "|" (buffer-substring (point-at-bol) (point))) (looking-at ".*?|")) @@ -20257,14 +20015,13 @@ because, in this case the deletion might narrow the column." (noalign (looking-at "[^|\n\r]* |")) (c org-table-may-need-update)) (backward-delete-char N) - (if (not overwrite-mode) - (progn - (skip-chars-forward "^|") - (insert " ") - (goto-char (1- pos)))) + (unless overwrite-mode + (skip-chars-forward "^|") + (insert " ") + (goto-char (1- pos))) ;; noalign: if there were two spaces at the end, this field ;; does not determine the width of the column. - (if noalign (setq org-table-may-need-update c))) + (when noalign (setq org-table-may-need-update c))) (backward-delete-char N) (org-fix-tags-on-the-fly)))) @@ -20277,7 +20034,7 @@ because, in this case the deletion might narrow the column." (interactive "p") (save-match-data (org-check-before-invisible-edit 'delete) - (if (and (org-table-p) + (if (and (org-at-table-p) (not (bolp)) (not (= (char-after) ?|)) (eq N 1)) @@ -20290,12 +20047,12 @@ because, in this case the deletion might narrow the column." (goto-char pos) ;; noalign: if there were two spaces at the end, this field ;; does not determine the width of the column. - (if noalign (setq org-table-may-need-update c))) + (when noalign (setq org-table-may-need-update c))) (delete-char N)) (delete-char N) (org-fix-tags-on-the-fly)))) -;; Make `delete-selection-mode' work with org-mode and orgtbl-mode +;; Make `delete-selection-mode' work with Org mode and Orgtbl mode (put 'org-self-insert-command 'delete-selection (lambda () (not (run-hook-with-args-until-success @@ -20314,7 +20071,7 @@ because, in this case the deletion might narrow the column." (put 'org-delete-char 'flyspell-delayed t) (put 'org-delete-backward-char 'flyspell-delayed t) -;; Make pabbrev-mode expand after org-mode commands +;; Make pabbrev-mode expand after Org mode commands (put 'org-self-insert-command 'pabbrev-expand-after-command t) (put 'orgtbl-self-insert-command 'pabbrev-expand-after-command t) @@ -20324,9 +20081,7 @@ COMMANDS is a list of alternating OLDDEF NEWDEF command names." (let (new old) (while commands (setq old (pop commands) new (pop commands)) - (if (fboundp 'command-remapping) - (org-defkey map (vector 'remap old) new) - (substitute-key-definition old new map global-map))))) + (org-defkey map (vector 'remap old) new)))) (defun org-transpose-words () "Transpose words for Org. @@ -20468,7 +20223,7 @@ See `org-ctrl-c-ctrl-c-hook' for more information.") (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) - (user-error "To use shift-selection with Org-mode, customize `org-support-shift-select'") + (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) @@ -20523,7 +20278,7 @@ individual commands for more information." (call-interactively 'org-indent-item-tree)) (t (org-modifier-cursor-error)))) -(defun org-shiftmetaup (&optional arg) +(defun org-shiftmetaup (&optional _arg) "Drag the line at point up. In a table, kill the current row. On a clock timestamp, update the value of the timestamp like `S-' @@ -20537,7 +20292,7 @@ Everywhere else, drag the line at point up." (call-interactively 'org-timestamp-up))) (t (call-interactively 'org-drag-line-backward)))) -(defun org-shiftmetadown (&optional arg) +(defun org-shiftmetadown (&optional _arg) "Drag the line at point down. In a table, insert an empty row at the current line. On a clock timestamp, update the value of the timestamp like `S-' @@ -20555,7 +20310,7 @@ Everywhere else, drag the line at point down." (user-error "Hidden subtree, open with TAB or use subtree command M-S-/")) -(defun org-metaleft (&optional arg) +(defun org-metaleft (&optional _arg) "Promote heading, list item at point or move table column left. Calls `org-do-promote', `org-outdent-item' or `org-table-move-column', @@ -20589,13 +20344,13 @@ and returns at first non-nil value." (call-interactively 'org-outdent-item)) (t (call-interactively 'backward-word)))) -(defun org-metaright (&optional arg) +(defun org-metaright (&optional _arg) "Demote heading, list item at point or move table column right. In front of a drawer or a block keyword, indent it correctly. Calls `org-do-demote', `org-indent-item', `org-table-move-column', -`org-indnet-drawer' or `org-indent-block' depending on context. +`org-indent-drawer' or `org-indent-block' depending on context. With no specific context, calls the Emacs default `forward-word'. See the individual commands for more information. @@ -20650,11 +20405,11 @@ this function returns t, nil otherwise." (goto-char (point-at-eol)) (setq end (max end (point))) (while (re-search-forward re end t) - (if (get-char-property (match-beginning 0) 'invisible) - (throw 'exit t)))) + (when (get-char-property (match-beginning 0) 'invisible) + (throw 'exit t)))) nil)))) -(defun org-metaup (&optional arg) +(defun org-metaup (&optional _arg) "Move subtree up or move table row up. Calls `org-move-subtree-up' or `org-table-move-row' or `org-move-item-up', depending on context. See the individual commands @@ -20676,7 +20431,7 @@ for more information." ((org-at-item-p) (call-interactively 'org-move-item-up)) (t (org-drag-element-backward)))) -(defun org-metadown (&optional arg) +(defun org-metadown (&optional _arg) "Move subtree down or move table row down. Calls `org-move-subtree-down' or `org-table-move-row' or `org-move-item-down', depending on context. See the individual @@ -20848,7 +20603,7 @@ Depending on context, this does one of the following: "Change timestamps synchronously up in CLOCK log lines. Optional argument N tells to change by that many units." (interactive "P") - (if (and (org-at-clock-log-p) (org-at-timestamp-p t)) + (if (and (org-at-clock-log-p) (org-in-regexp org-ts-regexp-inactive)) (let (org-support-shift-select) (org-clock-timestamps-up n)) (user-error "Not at a clock log"))) @@ -20857,7 +20612,7 @@ Optional argument N tells to change by that many units." "Change timestamps synchronously down in CLOCK log lines. Optional argument N tells to change by that many units." (interactive "P") - (if (and (org-at-clock-log-p) (org-at-timestamp-p t)) + (if (and (org-at-clock-log-p) (org-in-regexp org-ts-regexp-inactive)) (let (org-support-shift-select) (org-clock-timestamps-down n)) (user-error "Not at a clock log"))) @@ -20922,19 +20677,19 @@ this numeric value." (defun org-copy-special () "Copy region in table or copy current subtree. -Calls `org-table-copy' or `org-copy-subtree', depending on context. -See the individual commands for more information." +Calls `org-table-copy-region' or `org-copy-subtree', depending on +context. See the individual commands for more information." (interactive) (call-interactively - (if (org-at-table-p) 'org-table-copy-region 'org-copy-subtree))) + (if (org-at-table-p) #'org-table-copy-region #'org-copy-subtree))) (defun org-cut-special () "Cut region in table or cut current subtree. -Calls `org-table-copy' or `org-cut-subtree', depending on context. -See the individual commands for more information." +Calls `org-table-cut-region' or `org-cut-subtree', depending on +context. See the individual commands for more information." (interactive) (call-interactively - (if (org-at-table-p) 'org-table-cut-region 'org-cut-subtree))) + (if (org-at-table-p) #'org-table-cut-region #'org-cut-subtree))) (defun org-paste-special (arg) "Paste rectangular region into table, or past subtree relative to level. @@ -20945,40 +20700,35 @@ See the individual commands for more information." (org-table-paste-rectangle) (org-paste-subtree arg))) -(defsubst org-in-fixed-width-region-p () - "Is point in a fixed-width region?" - (save-match-data - (eq 'fixed-width (org-element-type (org-element-at-point))))) - (defun org-edit-special (&optional arg) "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 export block, call `org-edit-export-block'. +When in a LaTeX environment, call `org-edit-latex-environment'. When at an #+INCLUDE keyword, visit the included file. When at a footnote reference, call `org-edit-footnote-reference' On a link, call `ffap' to visit the link at point. Otherwise, return a user error." (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 + (barf-if-buffer-read-only) + (pcase (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 + (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 + (`keyword (if (member (org-element-property :key element) '("INCLUDE" "SETUPFILE")) (org-open-link-from-string (format "[[%s]]" @@ -20992,23 +20742,25 @@ Otherwise, return a user error." (match-string 0 value)) (t (user-error "No valid file specified"))))))) (user-error "No special environment to edit here"))) - (table + (`table (if (eq (org-element-property :type element) 'table.el) (org-edit-table.el) (call-interactively 'org-table-edit-formulas))) ;; Only Org tables contain `table-row' type elements. - (table-row (call-interactively 'org-table-edit-formulas)) - (example-block (org-edit-src-code)) - (export-block (org-edit-export-block)) - (fixed-width (org-edit-fixed-width-region)) - (otherwise + (`table-row (call-interactively 'org-table-edit-formulas)) + (`example-block (org-edit-src-code)) + (`export-block (org-edit-export-block)) + (`fixed-width (org-edit-fixed-width-region)) + (`latex-environment (org-edit-latex-environment)) + (_ ;; No notable element at point. Though, we may be at a link or ;; a footnote reference, which are objects. Thus, scan deeper. (let ((context (org-element-context element))) - (case (org-element-type context) - (link (call-interactively #'ffap)) - (footnote-reference (org-edit-footnote-reference)) - (t (user-error "No special environment to edit here")))))))) + (pcase (org-element-type context) + (`footnote-reference (org-edit-footnote-reference)) + (`inline-src-block (org-edit-inline-src-code)) + (`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) @@ -21057,204 +20809,225 @@ This command does many different things, depending on context: inhibited by setting `org-babel-no-eval-on-ctrl-c-ctrl-c'." (interactive "P") (cond - ((or (and (boundp 'org-clock-overlays) org-clock-overlays) - org-occur-highlights) - (and (boundp 'org-clock-overlays) (org-clock-remove-overlays)) + ((or (bound-and-true-p org-clock-overlays) org-occur-highlights) + (when (boundp 'org-clock-overlays) (org-clock-remove-overlays)) (org-remove-occur-highlights) (message "Temporary highlights/overlays removed from current buffer")) - ((and (local-variable-p 'org-finish-function (current-buffer)) + ((and (local-variable-p 'org-finish-function) (fboundp org-finish-function)) (funcall org-finish-function)) + ((org-babel-hash-at-point)) ((run-hook-with-args-until-success 'org-ctrl-c-ctrl-c-hook)) (t - (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")) - (let* ((context (org-element-context)) - (type (org-element-type context))) - (case type - ;; When at a link, act according to the parent instead. - (link (setq context (org-element-property :parent context)) - (setq type (org-element-type context))) - ;; Unsupported object types: refer to the first supported - ;; element or object containing it. - ((bold code entity export-snippet inline-babel-call inline-src-block - italic latex-fragment line-break macro strike-through subscript - superscript underline verbatim) - (setq context - (org-element-lineage - context '(radio-target paragraph verse-block table-cell))))) - ;; 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) - (= (line-beginning-position) - (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 + (let* ((context + (org-element-lineage + (org-element-context) + ;; Limit to supported contexts. + '(babel-call clock dynamic-block footnote-definition + footnote-reference inline-babel-call inline-src-block + inlinetask item keyword node-property paragraph + plain-list property-drawer radio-target src-block + statistics-cookie table table-cell table-row + timestamp) + t)) + (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) + (= (line-beginning-position) + (org-element-property :begin parent))) + (setq context parent) + (setq type 'item)))) + ;; Act according to type of element or object at point. + ;; + ;; Do nothing on a blank line, except if it is contained in + ;; a src block. Hence, we first check if point is in such + ;; a block and then if it is at a blank line. + (pcase type + ((or `inline-src-block `src-block) + (unless org-babel-no-eval-on-ctrl-c-ctrl-c + (org-babel-eval-wipe-error-buffer) + (org-babel-execute-src-block + current-prefix-arg (org-babel-get-src-block-info nil context)))) + ((guard (org-match-line "[ \t]*$")) + (or (run-hook-with-args-until-success 'org-ctrl-c-ctrl-c-final-hook) + (user-error + (substitute-command-keys + "`\\[org-ctrl-c-ctrl-c]' can do nothing useful here")))) + ((or `babel-call `inline-babel-call) + (let ((info (org-babel-lob-get-info context))) + (when info (org-babel-execute-src-block nil info)))) + (`clock (org-clock-update-time-maybe)) + (`dynamic-block + (save-excursion (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 a 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"))))))))) + (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)) + ((or `headline `inlinetask) + (save-excursion (goto-char (org-element-property :begin context)) + (call-interactively #'org-set-tags))) + (`item + ;; At an item: `C-u C-u' sets checkbox to "[-]" + ;; unconditionally, whereas `C-u' will toggle its presence. + ;; Without a 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 + (dolist (pos + (org-list-get-all-items + begin struct (org-list-prevs-alist struct))) + (org-list-set-checkbox pos struct new-box))) + ((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)))) + ((or `property-drawer `node-property) + (call-interactively #'org-property-action)) + (`radio-target + (call-interactively #'org-update-radio-target-regexp)) + (`statistics-cookie + (call-interactively #'org-update-statistics-cookies)) + ((or `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 "%s" (substitute-command-keys "\\\ +Use `\\[org-edit-special]' 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)) + ((and `nil (guard (org-at-heading-p))) + ;; When point is on an unsupported object type, we can miss + ;; the fact that it also is at a heading. Handle it here. + (call-interactively #'org-set-tags)) + ((guard + (run-hook-with-args-until-success 'org-ctrl-c-ctrl-c-final-hook))) + (_ + (user-error + (substitute-command-keys + "`\\[org-ctrl-c-ctrl-c]' can do nothing useful here")))))))) (defun org-mode-restart () (interactive) - (let ((indent-status (org-bound-and-true-p org-indent-mode))) + (let ((indent-status (bound-and-true-p org-indent-mode))) (funcall major-mode) (hack-local-variables) - (when (and indent-status (not (org-bound-and-true-p org-indent-mode))) + (when (and indent-status (not (bound-and-true-p org-indent-mode))) (org-indent-mode -1))) (message "%s restarted" major-mode)) (defun org-kill-note-or-show-branches () - "If this is a Note buffer, abort storing the note. Else call `show-branches'." + "Abort storing current note, or call `outline-show-branches'." (interactive) (if (not org-finish-function) (progn - (hide-subtree) - (call-interactively 'show-branches)) + (outline-hide-subtree) + (call-interactively 'outline-show-branches)) (let ((org-note-abort t)) (funcall org-finish-function)))) -(defun org-delete-indentation (&optional ARG) +(defun org-delete-indentation (&optional arg) "Join current line to previous and fix whitespace at join. If previous line is a headline add to headline title. Otherwise the function calls `delete-indentation'. -With argument, join this line to following line." +With a non-nil optional argument, join it to the following one." (interactive "*P") (if (save-excursion - (if ARG (beginning-of-line) - (forward-line -1)) - (looking-at org-complex-heading-regexp)) + (beginning-of-line (if arg 1 0)) + (let ((case-fold-search nil)) + (looking-at org-complex-heading-regexp))) ;; At headline. (let ((tags-column (when (match-beginning 5) (save-excursion (goto-char (match-beginning 5)) (current-column)))) - (string (concat " " (progn (when ARG (forward-line 1)) + (string (concat " " (progn (when arg (forward-line 1)) (org-trim (delete-and-extract-region (line-beginning-position) (line-end-position))))))) @@ -21265,23 +21038,21 @@ With argument, join this line to following line." (skip-chars-backward " \t") (save-excursion (insert string)) ;; Adjust alignment of tags. - (when tags-column - (org-align-tags-here (if org-auto-align-tags - org-tags-column - tags-column)))) - (delete-indentation ARG))) + (cond + ((not tags-column)) ;no tags + (org-auto-align-tags (org-set-tags nil t)) + (t (org--align-tags-here tags-column)))) ;preserve tags column + (delete-indentation arg))) (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." +If `org-special-ctrl-o' is nil, just call `open-line' everywhere. +As a special case, when a document starts with a table, allow to +call `open-line' on the very first character." (interactive "*p") - (cond - ((not org-special-ctrl-o) - (open-line n)) - ((org-at-table-p) - (org-table-insert-row)) - (t - (open-line n)))) + (if (and org-special-ctrl-o (/= (point) 1) (org-at-table-p)) + (org-table-insert-row) + (open-line n))) (defun org-return (&optional indent) "Goto next table row or insert a newline. @@ -21297,30 +21068,29 @@ will not happen if point is in a table or on a \"dead\" object (e.g., within a comment). In these case, you need to use `org-open-at-point' directly." (interactive) - (let* ((context (if org-return-follows-link (org-element-context) - (org-element-at-point))) - (type (org-element-type context))) + (let ((context (if org-return-follows-link (org-element-context) + (org-element-at-point)))) (cond ;; In a table, call `org-table-next-row'. - ((or (and (eq type 'table) + ((or (and (eq (org-element-type context) 'table) (>= (point) (org-element-property :contents-begin context)) (< (point) (org-element-property :contents-end context))) (org-element-lineage context '(table-row table-cell) t)) (org-table-justify-field-maybe) (call-interactively #'org-table-next-row)) - ;; On a link or a timestamp but not on white spaces after it, - ;; call `org-open-line' if `org-return-follows-link' allows it. + ;; On a link or a timestamp, call `org-open-at-point' if + ;; `org-return-follows-link' allows it. Tolerate fuzzy + ;; locations, e.g., in a comment, as `org-open-at-point'. ((and org-return-follows-link - (memq type '(link timestamp)) - (< (point) - (save-excursion (goto-char (org-element-property :end context)) - (skip-chars-backward " \t") - (point)))) + (or (org-in-regexp org-ts-regexp-both nil t) + (org-in-regexp org-tsr-regexp-both nil t) + (org-in-regexp org-any-link-re nil t))) (call-interactively #'org-open-at-point)) ;; Insert newline in heading, but preserve tags. ((and (not (bolp)) (save-excursion (beginning-of-line) - (looking-at org-complex-heading-regexp))) + (let ((case-fold-search nil)) + (looking-at org-complex-heading-regexp)))) ;; At headline. Split line. However, if point is on keyword, ;; priority cookie or tags, do not break any of them: add ;; a newline after the headline instead. @@ -21328,14 +21098,13 @@ object (e.g., within a comment). In these case, you need to use (save-excursion (goto-char (match-beginning 5)) (current-column)))) (string - (when (and (match-end 4) - (>= (point) - (or (match-end 3) (match-end 2) (1+ (match-end 1)))) - (<= (point) (match-end 4))) + (when (and (match-end 4) (org-point-in-group (point) 4)) (delete-and-extract-region (point) (match-end 4))))) - (when (and tags-column string) ; Adjust tag alignment. - (org-align-tags-here - (if org-auto-align-tags org-tags-column tags-column))) + ;; Adjust tag alignment. + (cond + ((not (and tags-column string))) + (org-auto-align-tags (org-set-tags nil t)) + (t (org--align-tags-here tags-column))) ;preserve tags column (end-of-line) (org-show-entry) (if indent (newline-and-indent) (newline)) @@ -21385,153 +21154,11 @@ Calls `org-table-insert-hline', `org-toggle-item', or (t (call-interactively 'org-toggle-item)))) -(defun org-toggle-item (arg) - "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 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 a list of items. -With a prefix argument ARG, change the region in a single item." - (interactive "P") - (let ((shift-text - (function - ;; Shift text in current section to IND, from point to END. - ;; The function leaves point to END line. - (lambda (ind end) - (let ((min-i 1000) (end (copy-marker end))) - ;; First determine the minimum indentation (MIN-I) of - ;; the text. - (save-excursion - (catch 'exit - (while (< (point) end) - (let ((i (org-get-indentation))) - (cond - ;; Skip blank lines and inline tasks. - ((looking-at "^[ \t]*$")) - ((looking-at org-outline-regexp-bol)) - ;; We can't find less than 0 indentation. - ((zerop i) (throw 'exit (setq min-i 0))) - ((< i min-i) (setq min-i i)))) - (forward-line)))) - ;; Then indent each line so that a line indented to - ;; MIN-I becomes indented to IND. Ignore blank lines - ;; and inline tasks in the process. - (let ((delta (- ind min-i))) - (while (< (point) end) - (unless (or (looking-at "^[ \t]*$") - (looking-at org-outline-regexp-bol)) - (org-indent-line-to (+ (org-get-indentation) delta))) - (forward-line))))))) - (skip-blanks - (function - ;; Return beginning of first non-blank line, starting from - ;; line at POS. - (lambda (pos) - (save-excursion - (goto-char pos) - (skip-chars-forward " \r\t\n") - (point-at-bol))))) - beg end) - ;; Determine boundaries of changes. - (if (org-region-active-p) - (setq beg (funcall skip-blanks (region-beginning)) - end (copy-marker (region-end))) - (setq beg (funcall skip-blanks (point-at-bol)) - end (copy-marker (point-at-eol)))) - ;; Depending on the starting line, choose an action on the text - ;; between BEG and END. - (org-with-limited-levels - (save-excursion - (goto-char beg) - (cond - ;; Case 1. Start at an item: de-itemize. Note that it only - ;; happens when a region is active: `org-ctrl-c-minus' - ;; would call `org-cycle-list-bullet' otherwise. - ((org-at-item-p) - (while (< (point) end) - (when (org-at-item-p) - (skip-chars-forward " \t") - (delete-region (point) (match-end 0))) - (forward-line))) - ;; Case 2. Start at an heading: convert to items. - ((org-at-heading-p) - (let* ((bul (org-list-bullet-string "-")) - (bul-len (length bul)) - (done (org-entry-is-done-p)) - (todo (org-entry-is-todo-p)) - ;; Indentation of the first heading. It should be - ;; relative to the indentation of its parent, if any. - (start-ind (save-excursion - (cond - ((not org-adapt-indentation) 0) - ((not (outline-previous-heading)) 0) - (t (length (match-string 0)))))) - ;; Level of first heading. Further headings will be - ;; compared to it to determine hierarchy in the list. - (ref-level (org-reduced-level (org-outline-level)))) - (when (or done todo) (org-todo "")) - (while (< (point) end) - (let* ((level (org-reduced-level (org-outline-level))) - (delta (max 0 (- level ref-level)))) - ;; If current headline is less indented than the first - ;; one, set it as reference, in order to preserve - ;; subtrees. - (when (< level ref-level) (setq ref-level level)) - (replace-match bul t t) - (org-indent-line-to (+ start-ind (* delta bul-len))) - (when (or done todo) - (let* ((struct (org-list-struct)) - (old (copy-tree struct))) - (org-list-set-checkbox (line-beginning-position) - struct - (if done "[X]" "[ ]")) - (org-list-write-struct struct - (org-list-parents-alist struct) - old))) - ;; Ensure all text down to END (or SECTION-END) belongs - ;; to the newly created item. - (let ((section-end (save-excursion - (or (outline-next-heading) (point))))) - (forward-line) - (funcall shift-text - (+ start-ind (* (1+ delta) bul-len)) - (min end section-end))))))) - ;; 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") - (insert bul) - (forward-line) - (while (< (point) end) - ;; Ensure that lines less indented than first one - ;; still get included in item body. - (funcall shift-text - (+ ref-ind bul-len) - (min end (save-excursion (or (outline-next-heading) - (point))))) - (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 convert the current line. -With a \\[universal-argument] prefix, convert the whole list at +With a `\\[universal-argument]' prefix, convert the whole list at point into heading. In a region: @@ -21567,7 +21194,7 @@ number of stars to add." ;; do not consider the last line to be in the region. (when (and current-prefix-arg (org-at-item-p)) - (if (listp current-prefix-arg) (setq current-prefix-arg 1)) + (when (listp current-prefix-arg) (setq current-prefix-arg 1)) (org-mark-element)) (if (org-region-active-p) @@ -21596,10 +21223,11 @@ number of stars to add." (when (org-at-item-p) ;; Pay attention to cases when region ends before list. (let* ((struct (org-list-struct)) - (list-end (min (org-list-get-bottom-point struct) (1+ end)))) + (list-end + (min (org-list-get-bottom-point struct) (1+ end)))) (save-restriction (narrow-to-region (point) list-end) - (insert (org-list-to-subtree (org-list-parse-list t))))) + (insert (org-list-to-subtree (org-list-to-lisp t)) "\n"))) (setq toggled t)) (forward-line))) ;; Case 3. Started at normal text: make every line an heading, @@ -21613,7 +21241,7 @@ number of stars to add." (org-odd-levels-only "**") ; inside heading, odd (t "*"))) ; inside heading, oddeven (rpl (concat stars add-stars " ")) - (lend (if (listp nstars) (save-excursion (end-of-line) (point))))) + (lend (when (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-\\)")) @@ -21621,15 +21249,18 @@ number of stars to add." (forward-line))))))) (unless toggled (message "Cannot toggle heading from here")))) -(defun org-meta-return (&optional _arg) +(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." - (interactive) +Calls `org-insert-heading', `org-insert-item' or +`org-table-wrap-region', depending on context. When called with +an argument, unconditionally call `org-insert-heading'." + (interactive "P") (org-check-before-invisible-edit 'insert) (or (run-hook-with-args-until-success 'org-metareturn-hook) - (call-interactively (if (org-at-table-p) #'org-table-wrap-region - #'org-insert-heading)))) + (call-interactively (cond (arg #'org-insert-heading) + ((org-at-table-p) #'org-table-wrap-region) + ((org-in-item-p) #'org-insert-item) + (t #'org-insert-heading))))) ;;; Menu entries @@ -21638,7 +21269,7 @@ on context. See the individual commands for more information." (and (not (org-before-first-heading-p)) (not (org-at-table-p)))) -;; Define the Org-mode menus +;; Define the Org mode menus (easy-menu-define org-tbl-menu org-mode-map "Tbl menu" '("Tbl" ["Align" org-ctrl-c-ctrl-c :active (org-at-table-p)] @@ -21685,11 +21316,11 @@ on context. See the individual commands for more information." ["Which Column?" org-table-current-column (org-at-table-p)]) ["Debug Formulas" org-table-toggle-formula-debugger - :style toggle :selected (org-bound-and-true-p org-table-formula-debug)] + :style toggle :selected (bound-and-true-p org-table-formula-debug)] ["Show Col/Row Numbers" org-table-toggle-coordinate-overlays :style toggle - :selected (org-bound-and-true-p org-table-overlay-coordinates)] + :selected (bound-and-true-p org-table-overlay-coordinates)] "--" ["Create" org-table-create (and (not (org-at-table-p)) org-enable-table-editor)] @@ -21710,7 +21341,7 @@ on context. See the individual commands for more information." ["Cycle Global Visibility" org-shifttab :active (not (org-at-table-p))] ["Sparse Tree..." org-sparse-tree t] ["Reveal Context" org-reveal t] - ["Show All" show-all t] + ["Show All" outline-show-all t] "--" ["Subtree to indirect buffer" org-tree-to-indirect-buffer t]) "--" @@ -21813,7 +21444,7 @@ on context. See the individual commands for more information." "--" ["Set property" org-set-property (not (org-before-first-heading-p))] ["Column view of properties" org-columns t] - ["Insert Column View DBlock" org-insert-columns-dblock t]) + ["Insert Column View DBlock" org-columns-insert-dblock t]) ("Dates and Scheduling" ["Timestamp" org-time-stamp (not (org-before-first-heading-p))] ["Timestamp (inactive)" org-time-stamp-inactive (not (org-before-first-heading-p))] @@ -21863,7 +21494,6 @@ on context. See the individual commands for more information." ("Special views current file" ["TODO Tree" org-show-todo-tree t] ["Check Deadlines" org-check-deadlines t] - ["Timeline" org-timeline t] ["Tags/Property tree" org-match-sparse-tree t]) "--" ["Export/Publish..." org-export-dispatch t] @@ -21874,9 +21504,7 @@ on context. See the individual commands for more information." ["Insert math symbol" cdlatex-math-symbol (fboundp 'cdlatex-math-symbol)] ["Modify math symbol" org-cdlatex-math-modify (org-inside-LaTeX-fragment-p)] - ["Insert citation" org-reftex-citation t] - "--" - ["Template for BEAMER" (org-beamer-insert-options-template) t]) + ["Insert citation" org-reftex-citation t]) "--" ("MobileOrg" ["Push Files and Views" org-mobile-push t] @@ -21902,20 +21530,20 @@ on context. See the individual commands for more information." )) (defun org-info (&optional node) - "Read documentation for Org-mode in the info system. + "Read documentation for Org in the info system. With optional NODE, go directly to that node." (interactive) (info (format "(org)%s" (or node "")))) ;;;###autoload (defun org-submit-bug-report () - "Submit a bug report on Org-mode via mail. + "Submit a bug report on Org via mail. Don't hesitate to report any problems or inaccurate documentation. If you don't have setup sending mail from (X)Emacs, please copy the output buffer into your mail program, as it gives us important -information about your Org-mode version and configuration." +information about your Org version and configuration." (interactive) (require 'reporter) (defvar reporter-prompt-for-summary-p) @@ -21927,12 +21555,12 @@ information about your Org-mode version and configuration." (org-version nil 'full) (let (list) (save-window-excursion - (org-pop-to-buffer-same-window (get-buffer-create "*Warn about privacy*")) + (pop-to-buffer-same-window (get-buffer-create "*Warn about privacy*")) (delete-other-windows) (erase-buffer) - (insert "You are about to submit a bug report to the Org-mode mailing list. + (insert "You are about to submit a bug report to the Org mailing list. -We would like to add your full Org-mode and Outline configuration to the +We would like to add your full Org and Outline configuration to the bug report. This greatly simplifies the work of the maintainer and other experts on the mailing list. @@ -21942,7 +21570,7 @@ appear in the form of file names, tags, todo states, or search strings. If you answer yes to the prompt, you might want to check and remove such private information before sending the email.") (add-text-properties (point-min) (point-max) '(face org-warning)) - (when (yes-or-no-p "Include your Org-mode configuration ") + (when (yes-or-no-p "Include your Org configuration ") (mapatoms (lambda (v) (and (boundp v) @@ -21961,11 +21589,11 @@ what in fact did happen. You don't know how to make a good report? See http://orgmode.org/manual/Feedback.html#Feedback -Your bug report will be posted to the Org-mode mailing list. +Your bug report will be posted to the Org mailing list. ------------------------------------------------------------------------") (save-excursion - (if (re-search-backward "^\\(Subject: \\)Org-mode version \\(.*?\\);[ \t]*\\(.*\\)" nil t) - (replace-match "\\1Bug: \\3 [\\2]"))))) + (when (re-search-backward "^\\(Subject: \\)Org mode version \\(.*?\\);[ \t]*\\(.*\\)" nil t) + (replace-match "\\1Bug: \\3 [\\2]"))))) (defun org-install-agenda-files-menu () @@ -21973,7 +21601,7 @@ Your bug report will be posted to the Org-mode mailing list. (save-excursion (while bl (set-buffer (pop bl)) - (if (derived-mode-p 'org-mode) (setq bl nil))) + (when (derived-mode-p 'org-mode) (setq bl nil))) (when (derived-mode-p 'org-mode) (easy-menu-change '("Org") "File List for Agenda" @@ -21991,7 +21619,7 @@ Your bug report will be posted to the Org-mode mailing list. (defun org-require-autoloaded-modules () (interactive) - (mapc 'require + (mapc #'require '(org-agenda org-archive org-attach org-clock org-colview org-id org-table org-timer))) @@ -22004,13 +21632,8 @@ With prefix arg UNCOMPILED, load the uncompiled versions." (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")) - "\\|")) + (remove-re (format "\\`%s\\'" + (regexp-opt '("org" "org-loaddefs" "org-version")))) (feats (delete-dups (mapcar 'file-name-sans-extension (mapcar 'file-name-nondirectory @@ -22042,9 +21665,9 @@ With prefix arg UNCOMPILED, load the uncompiled versions." '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)) + (when 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)) @@ -22059,7 +21682,7 @@ With prefix arg UNCOMPILED, load the uncompiled versions." (customize-browse 'org)) (defun org-create-customize-menu () - "Create a full customization menu for Org-mode, insert it into the menu." + "Create a full customization menu for Org mode, insert it into the menu." (interactive) (org-load-modules-maybe) (org-require-autoloaded-modules) @@ -22082,7 +21705,7 @@ With prefix arg UNCOMPILED, load the uncompiled versions." ;;; Generally useful functions -(defsubst org-get-at-eol (property n) +(defun org-get-at-eol (property n) "Get text property PROPERTY at the end of line less N characters." (get-text-property (- (point-at-eol) n) property)) @@ -22092,19 +21715,9 @@ With prefix arg UNCOMPILED, load the uncompiled versions." (get-text-property (or (next-single-property-change 0 prop s) 0) prop s))) -(defun org-display-warning (message) ;; Copied from Emacs-Muse +(defun org-display-warning (message) "Display the given MESSAGE as a warning." - (if (fboundp 'display-warning) - (display-warning 'org message - (if (featurep 'xemacs) 'warning :warning)) - (let ((buf (get-buffer-create "*Org warnings*"))) - (with-current-buffer buf - (goto-char (point-max)) - (insert "Warning (Org): " message) - (unless (bolp) - (newline))) - (display-buffer buf) - (sit-for 0)))) + (display-warning 'org message :warning)) (defun org-eval (form) "Eval FORM and return result." @@ -22125,19 +21738,39 @@ With prefix arg UNCOMPILED, load the uncompiled versions." (defun org-in-verbatim-emphasis () (save-match-data - (and (org-in-regexp org-emph-re 2) + (and (org-in-regexp org-verbatim-re 2) (>= (point) (match-beginning 3)) - (<= (point) (match-end 4)) - (member (match-string 3) '("=" "~"))))) + (<= (point) (match-end 4))))) + +(defun org-overlay-display (ovl text &optional face evap) + "Make overlay OVL display TEXT with face FACE." + (overlay-put ovl 'display text) + (if face (overlay-put ovl 'face face)) + (if evap (overlay-put ovl 'evaporate t))) + +(defun org-overlay-before-string (ovl text &optional face evap) + "Make overlay OVL display TEXT with face FACE." + (if face (org-add-props text nil 'face face)) + (overlay-put ovl 'before-string text) + (if evap (overlay-put ovl 'evaporate t))) + +(defun org-find-overlays (prop &optional pos delete) + "Find all overlays specifying PROP at POS or point. +If DELETE is non-nil, delete all those overlays." + (let (found) + (dolist (ov (overlays-at (or pos (point))) found) + (cond ((not (overlay-get ov prop))) + (delete (delete-overlay ov)) + (t (push ov found)))))) (defun org-goto-marker-or-bmk (marker &optional bookmark) "Go to MARKER, widen if necessary. When marker is not live, try BOOKMARK." (if (and marker (marker-buffer marker) (buffer-live-p (marker-buffer marker))) (progn - (org-pop-to-buffer-same-window (marker-buffer marker)) - (if (or (> marker (point-max)) (< marker (point-min))) - (widen)) + (pop-to-buffer-same-window (marker-buffer marker)) + (when (or (> marker (point-max)) (< marker (point-min))) + (widen)) (goto-char marker) (org-show-context 'org-goto)) (if bookmark @@ -22180,7 +21813,7 @@ upon the next fontification round." l)) (defun org-shorten-string (s maxlength) - "Shorten string S so tht it is no longer than MAXLENGTH characters. + "Shorten string S so that it is no longer than MAXLENGTH characters. If the string is shorter or has length MAXLENGTH, just return the original string. If it is longer, the functions finds a space in the string, breaks this string off at that locations and adds three dots @@ -22200,8 +21833,8 @@ if necessary." "Get the indentation of the current line, interpreting tabs. When LINE is given, assume it represents a line and compute its indentation." (if line - (if (string-match "^ *" (org-remove-tabs line)) - (match-end 0)) + (when (string-match "^ *" (org-remove-tabs line)) + (match-end 0)) (save-excursion (beginning-of-line 1) (skip-chars-forward " \t") @@ -22238,35 +21871,45 @@ leave it alone. If it is larger than ind, set it to the target." (let* ((l (org-remove-tabs line)) (i (org-get-indentation l)) (i1 (car ind)) (i2 (cdr ind))) - (if (>= i i2) (setq l (substring line i2))) + (when (>= i i2) (setq l (substring line i2))) (if (> i1 0) (concat (make-string i1 ?\ ) l) l))) (defun org-remove-indentation (code &optional n) - "Remove the maximum common indentation from the lines in CODE. -N may optionally be the number of spaces to remove." + "Remove maximum common indentation in string CODE and return it. +N may optionally be the number of columns to remove. Return CODE +as-is if removal failed." (with-temp-buffer (insert code) - (org-do-remove-indentation n) - (buffer-string))) + (if (org-do-remove-indentation n) (buffer-string) code))) (defun org-do-remove-indentation (&optional n) - "Remove the maximum common indentation from the buffer." - (untabify (point-min) (point-max)) - (let ((min 10000) re) - (if n - (setq min n) - (goto-char (point-min)) - (while (re-search-forward "^ *[^ \n]" nil t) - (setq min (min min (1- (- (match-end 0) (match-beginning 0))))))) - (unless (or (= min 0) (= min 10000)) - (setq re (format "^ \\{%d\\}" min)) - (goto-char (point-min)) - (while (re-search-forward re nil t) - (replace-match "") - (end-of-line 1)) - min))) + "Remove the maximum common indentation from the buffer. +When optional argument N is a positive integer, remove exactly +that much characters from indentation, if possible. Return nil +if it fails." + (catch :exit + (goto-char (point-min)) + ;; Find maximum common indentation, if not specified. + (let ((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 nil) + (setq min-ind (min min-ind ind)))))) + min-ind)))) + (if (zerop n) (throw :exit nil) + ;; 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 nil)) + (t (indent-line-to (- ind n)))) + (forward-line))) + ;; Signal success. + t)))) (defun org-fill-template (template alist) "Find each %key of ALIST in TEMPLATE and replace it." @@ -22358,7 +22001,7 @@ and end of string." "Whether point is in a code source block. When INSIDE is non-nil, don't consider we are within a src block when point is at #+BEGIN_SRC or #+END_SRC." - (let ((case-fold-search t) ov) + (let ((case-fold-search t)) (or (and (eq (get-char-property (point) 'src-block) t)) (and (not inside) (save-match-data @@ -22381,7 +22024,7 @@ contexts are: :item on the first line of a plain list item :item-bullet on the bullet/number of a plain list item :checkbox on the checkbox in a plain list item -:table in an org-mode table +:table in an Org table :table-special on a special filed in a table :table-table in a table.el table :clocktable in a clocktable @@ -22412,8 +22055,8 @@ and :keyword." (push (org-point-in-group p 4 :tags) clist)) (goto-char p) (skip-chars-backward "^[\n\r \t") (or (bobp) (backward-char 1)) - (if (looking-at "\\[#[A-Z0-9]\\]") - (push (org-point-in-group p 0 :priority) clist))) + (when (looking-at "\\[#[A-Z0-9]\\]") + (push (org-point-in-group p 0 :priority) clist))) ((org-at-item-p) (push (org-point-in-group p 2 :item-bullet) clist) @@ -22425,10 +22068,10 @@ and :keyword." ((org-at-table-p) (push (list :table (org-table-begin) (org-table-end)) clist) - (if (memq 'org-formula faces) - (push (list :table-special - (previous-single-property-change p 'face) - (next-single-property-change p 'face)) clist))) + (when (memq 'org-formula faces) + (push (list :table-special + (previous-single-property-change p 'face) + (next-single-property-change p 'face)) clist))) ((org-at-table-p 'any) (push (list :table-table) clist))) (goto-char p) @@ -22466,14 +22109,14 @@ and :keyword." ((org-at-target-p) (push (org-point-in-group p 0 :target) clist) (goto-char (1- (match-beginning 0))) - (if (looking-at org-radio-target-regexp) - (push (org-point-in-group p 0 :radio-target) clist)) + (when (looking-at org-radio-target-regexp) + (push (org-point-in-group p 0 :radio-target) clist)) (goto-char p)) - ((setq o (car (delq nil - (mapcar - (lambda (x) - (if (memq x org-latex-fragment-image-overlays) x)) - (overlays-at (point)))))) + ((setq o (cl-some + (lambda (o) + (and (eq (overlay-get o 'org-overlay-type) 'org-latex-overlay) + o)) + (overlays-at (point)))) (push (list :latex-fragment (overlay-start o) (overlay-end o)) clist) (push (list :latex-preview @@ -22485,25 +22128,27 @@ and :keyword." (setq clist (nreverse (delq nil clist))) clist)) -(defun org-in-regexp (re &optional nlines visually) - "Check if point is inside a match of RE. +(defun org-in-regexp (regexp &optional nlines visually) + "Check if point is inside a match of REGEXP. Normally only the current line is checked, but you can include -NLINES extra lines after point into the search. If VISUALLY is +NLINES extra lines around point into the search. If VISUALLY is set, require that the cursor is not after the match but really -on, so that the block visually is on the match." - (catch 'exit +on, so that the block visually is on the match. + +Return nil or a cons cell (BEG . END) where BEG and END are, +respectively, the positions at the beginning and the end of the +match." + (catch :exit (let ((pos (point)) - (eol (point-at-eol (+ 1 (or nlines 0)))) - (inc (if visually 1 0))) + (eol (line-end-position (if nlines (1+ nlines) 1)))) (save-excursion (beginning-of-line (- 1 (or nlines 0))) - (while (re-search-forward re eol t) - (if (and (<= (match-beginning 0) pos) - (>= (+ inc (match-end 0)) pos)) - (throw 'exit (cons (match-beginning 0) (match-end 0))))))))) -(define-obsolete-function-alias 'org-at-regexp-p 'org-in-regexp - "Org mode 8.3") + (while (and (re-search-forward regexp eol t) + (<= (match-beginning 0) pos)) + (let ((end (match-end 0))) + (when (or (> end pos) (and (= end pos) (not visually))) + (throw :exit (cons (match-beginning 0) (match-end 0)))))))))) (defun org-between-regexps-p (start-re end-re &optional lim-up lim-down) "Non-nil when point is between matches of START-RE and END-RE. @@ -22550,14 +22195,13 @@ block from point." (let ((case-fold-search t) (lim-up (save-excursion (outline-previous-heading))) (lim-down (save-excursion (outline-next-heading)))) - (mapc (lambda (name) - (let ((n (regexp-quote name))) - (when (org-between-regexps-p - (concat "^[ \t]*#\\+begin_" n) - (concat "^[ \t]*#\\+end_" n) - lim-up lim-down) - (throw 'exit n)))) - names)) + (dolist (name names) + (let ((n (regexp-quote name))) + (when (org-between-regexps-p + (concat "^[ \t]*#\\+begin_" n) + (concat "^[ \t]*#\\+end_" n) + lim-up lim-down) + (throw 'exit n))))) nil))) (defun org-occur-in-agenda-files (regexp &optional _nlines) @@ -22584,27 +22228,8 @@ block from point." files) regexp))) -(if (boundp 'occur-mode-find-occurrence-hook) - ;; Emacs 23 - (add-hook 'occur-mode-find-occurrence-hook - (lambda () - (when (derived-mode-p 'org-mode) - (org-reveal)))) - ;; Emacs 22 - (defadvice occur-mode-goto-occurrence - (after org-occur-reveal activate) - (and (derived-mode-p 'org-mode) (org-reveal))) - (defadvice occur-mode-goto-occurrence-other-window - (after org-occur-reveal activate) - (and (derived-mode-p 'org-mode) (org-reveal))) - (defadvice occur-mode-display-occurrence - (after org-occur-reveal activate) - (when (derived-mode-p 'org-mode) - (let ((pos (occur-mode-find-occurrence))) - (with-current-buffer (marker-buffer pos) - (save-excursion - (goto-char pos) - (org-reveal))))))) +(add-hook 'occur-mode-find-occurrence-hook + (lambda () (when (derived-mode-p 'org-mode) (org-reveal)))) (defun org-occur-link-in-agenda-files () "Create a link and search for it in the agendas. @@ -22627,88 +22252,34 @@ for the search purpose." For example, in this alist: -\(org-uniquify-alist '((a 1) (b 2) (a 3))) - => '((a 1 3) (b 2)) +\(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)) + (dolist (e alist rtn) + (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)))))) (defun org-delete-all (elts list) - "Remove all elements in ELTS from LIST." + "Remove all elements in ELTS from LIST. +Comparison is done with `equal'. It is a destructive operation +that may remove elements by altering the list structure." (while elts (setq list (delete (pop elts) list))) list) -(defun org-count (cl-item cl-seq) - "Count the number of occurrences of ITEM in SEQ. -Taken from `count' in cl-seq.el with all keyword arguments removed." - (let ((cl-end (length cl-seq)) (cl-start 0) (cl-count 0) cl-x) - (when (consp cl-seq) (setq cl-seq (nthcdr cl-start cl-seq))) - (while (< cl-start cl-end) - (setq cl-x (if (consp cl-seq) (pop cl-seq) (aref cl-seq cl-start))) - (if (equal cl-item cl-x) (setq cl-count (1+ cl-count))) - (setq cl-start (1+ cl-start))) - cl-count)) - -(defun org-remove-if (predicate seq) - "Remove everything from SEQ that fulfills PREDICATE." - (let (res e) - (while seq - (setq e (pop seq)) - (if (not (funcall predicate e)) (push e res))) - (nreverse res))) - -(defun org-remove-if-not (predicate seq) - "Remove everything from SEQ that does not fulfill PREDICATE." - (let (res e) - (while seq - (setq e (pop seq)) - (if (funcall predicate e) (push e res))) - (nreverse res))) - -(defun org-reduce (cl-func cl-seq &rest cl-keys) - "Reduce two-argument FUNCTION across SEQ. -Taken from `reduce' in cl-seq.el with all keyword arguments but -\":initial-value\" removed." - (let ((cl-accum (cond ((memq :initial-value cl-keys) - (cadr (memq :initial-value cl-keys))) - (cl-seq (pop cl-seq)) - (t (funcall cl-func))))) - (while cl-seq - (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." (let ((pos (point))) - (if (cdr (assoc 'heading org-blank-before-new-entry)) + (if (cdr (assq 'heading org-blank-before-new-entry)) (skip-chars-backward " \t\n\r") (unless (eobp) (forward-line -1))) @@ -22761,7 +22332,7 @@ so values can contain further %-escapes if they are define later in TABLE." (let ((tbl (copy-alist table)) (case-fold-search nil) (pchg 0) - e re rpl) + re rpl) (dolist (e tbl) (setq re (concat "%-?[0-9.]*" (substring (car e) 1))) (when (and (cdr e) (string-match re (cdr e))) @@ -22779,16 +22350,6 @@ so values can contain further %-escapes if they are define later in TABLE." (setq string (replace-match sref t t string))))) string)) -(defun org-sublist (list start end) - "Return a section of LIST, from START to END. -Counting starts at 1." - (let (rtn (c start)) - (setq list (nthcdr (1- start) list)) - (while (and list (<= c end)) - (push (pop list) rtn) - (setq c (1+ c))) - (nreverse rtn))) - (defun org-find-base-buffer-visiting (file) "Like `find-buffer-visiting' but always return the base buffer and not an indirect buffer." @@ -22798,26 +22359,12 @@ not an indirect buffer." (or (buffer-base-buffer buf) buf) nil))) -(defun org-image-file-name-regexp (&optional extensions) - "Return regexp matching the file names of images. -If EXTENSIONS is given, only match these." - (if (and (not extensions) (fboundp 'image-file-name-regexp)) - (image-file-name-regexp) - (let ((image-file-name-extensions - (or extensions - '("png" "jpeg" "jpg" "gif" "tiff" "tif" - "xbm" "xpm" "pbm" "pgm" "ppm")))) - (concat "\\." - (regexp-opt (nconc (mapcar 'upcase - image-file-name-extensions) - image-file-name-extensions) - t) - "\\'")))) - -(defun org-file-image-p (file &optional extensions) +;;; TODO: Only called once, from ox-odt which should probably use +;;; org-export-inline-image-p or something. +(defun org-file-image-p (file) "Return non-nil if FILE is an image." (save-match-data - (string-match (org-image-file-name-regexp extensions) file))) + (string-match (image-file-name-regexp) file))) (defun org-get-cursor-date (&optional with-time) "Return the date at cursor in as a time. @@ -22841,10 +22388,10 @@ the agenda) or the current time of the day." (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 (or mod 0) (or hod 0) - (nth 1 date) (nth 0 date) (nth 2 date)))))) + (when day + (setq date (calendar-gregorian-from-absolute day) + 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) @@ -22857,11 +22404,77 @@ hierarchy of headlines by UP levels before marking the subtree." (cond ((org-at-heading-p) (beginning-of-line)) ((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) + (when up (while (and (> up 0) (org-up-heading-safe)) (cl-decf up))) + (if (called-interactively-p 'any) (call-interactively 'org-mark-element) (org-mark-element))) +(defun org-file-newer-than-p (file time) + "Non-nil if FILE is newer than TIME. +FILE is a filename, as a string, TIME is a list of integers, as +returned by, e.g., `current-time'." + (and (file-exists-p file) + ;; Only compare times up to whole seconds as some file-systems + ;; (e.g. HFS+) do not retain any finer granularity. As + ;; a consequence, make sure we return non-nil when the two + ;; times are equal. + (not (time-less-p (cl-subseq (nth 5 (file-attributes file)) 0 2) + (cl-subseq time 0 2))))) + +(defun org-compile-file (source process ext &optional err-msg log-buf spec) + "Compile a SOURCE file using PROCESS. + +PROCESS is either a function or a list of shell commands, as +strings. EXT is a file extension, without the leading dot, as +a string. It is used to check if the process actually succeeded. + +PROCESS must create a file with the same base name and directory +as SOURCE, but ending with EXT. The function then returns its +filename. Otherwise, it raises an error. The error message can +then be refined by providing string ERR-MSG, which is appended to +the standard message. + +If PROCESS is a function, it is called with a single argument: +the SOURCE file. + +If it is a list of commands, each of them is called using +`shell-command'. By default, in each command, %b, %f, %F, %o and +%O are replaced with, respectively, SOURCE base name, name, full +name, directory and absolute output file name. It is possible, +however, to use more place-holders by specifying them in optional +argument SPEC, as an alist following the pattern + + (CHARACTER . REPLACEMENT-STRING). + +When PROCESS is a list of commands, optional argument LOG-BUF can +be set to a buffer or a buffer name. `shell-command' then uses +it for output." + (let* ((base-name (file-name-base source)) + (full-name (file-truename source)) + (out-dir (or (file-name-directory source) "./")) + (output (expand-file-name (concat base-name "." ext) out-dir)) + (time (current-time)) + (err-msg (if (stringp err-msg) (concat ". " err-msg) ""))) + (save-window-excursion + (pcase process + ((pred functionp) (funcall process (shell-quote-argument source))) + ((pred consp) + (let ((log-buf (and log-buf (get-buffer-create log-buf))) + (spec (append spec + `((?b . ,(shell-quote-argument base-name)) + (?f . ,(shell-quote-argument source)) + (?F . ,(shell-quote-argument full-name)) + (?o . ,(shell-quote-argument out-dir)) + (?O . ,(shell-quote-argument output)))))) + (dolist (command process) + (shell-command (format-spec command spec) log-buf)) + (when log-buf (with-current-buffer log-buf (compilation-mode))))) + (_ (error "No valid command to process %S%s" source err-msg)))) + ;; Check for process failure. Output file is expected to be + ;; located in the same directory as SOURCE. + (unless (org-file-newer-than-p output time) + (error (format "File %S wasn't produced%s" output err-msg))) + output)) ;;; Indentation @@ -22876,7 +22489,7 @@ ELEMENT." (org-with-wide-buffer (cond (contentsp - (case type + (cl-case type ((diary-sexp footnote-definition) 0) ((headline inlinetask nil) (if (not org-adapt-indentation) 0 @@ -22887,7 +22500,7 @@ ELEMENT." (goto-char start) (org-get-indentation)))) ((memq type '(headline inlinetask nil)) - (if (save-excursion (beginning-of-line) (looking-at "[ \t]*$")) + (if (org-match-line "[ \t]*$") (org--get-expected-indentation element t) 0)) ((memq type '(diary-sexp footnote-definition)) 0) @@ -22954,16 +22567,15 @@ ELEMENT." ;; ;; As a special case, if point is at the end of a footnote ;; definition or an item, indent like the very last element - ;; within. + ;; within. If that last element is an item, indent like its + ;; contents. ((and (not (eq type 'paragraph)) (let ((cend (org-element-property :contents-end element))) (and cend (<= cend pos)))) (if (memq type '(footnote-definition item plain-list)) (let ((last (org-element-at-point))) (org--get-expected-indentation - last - (memq (org-element-type last) - '(footnote-definition item plain-list)))) + last (eq (org-element-type last) 'item))) (goto-char start) (org-get-indentation))) ;; In any other case, indent like the current line. @@ -23022,15 +22634,15 @@ Indentation is done according to the following rules: - Otherwise, indent like the first non-blank line above. The function doesn't indent an item as it could break the whole -list structure. Instead, use \\\\[org-shiftmetaleft] or \ -\\[org-shiftmetaright]. +list structure. Instead, use \\`\\[org-shiftmetaleft]' or \ +`\\[org-shiftmetaright]'. Also align node properties according to `org-property-format'." (interactive) (cond (orgstruct-is-++ (let ((indent-line-function - (cadadr (assq 'indent-line-function org-fb-vars)))) + (cl-cadadr (assq 'indent-line-function org-fb-vars)))) (indent-according-to-mode))) ((org-at-heading-p) 'noindent) (t @@ -23040,6 +22652,13 @@ Also align node properties according to `org-property-format'." (= (line-beginning-position) (org-element-property :post-affiliated element))) 'noindent) + ((and (eq type 'latex-environment) + (>= (point) (org-element-property :post-affiliated element)) + (< (point) (org-with-wide-buffer + (goto-char (org-element-property :end element)) + (skip-chars-backward " \r\t\n") + (line-beginning-position 2)))) + 'noindent) ((and (eq type 'src-block) org-src-tab-acts-natively (> (line-beginning-position) @@ -23054,8 +22673,8 @@ Also align node properties according to `org-property-format'." (let ((column (org--get-expected-indentation element nil))) ;; Preserve current column. (if (<= (current-column) (current-indentation)) - (org-indent-line-to column) - (save-excursion (org-indent-line-to column)))) + (indent-line-to column) + (save-excursion (indent-line-to column)))) ;; Align node property. Also preserve current column. (when (eq type 'node-property) (let ((column (current-column))) @@ -23076,37 +22695,53 @@ assumed to be significant there." (let ((indent-to (lambda (ind pos) ;; Set IND as indentation for all lines between point and - ;; POS or END, whichever comes first. Blank lines are - ;; ignored. Leave point after POS once done. - (let ((limit (copy-marker (min end pos)))) + ;; POS. Blank lines are ignored. Leave point after POS + ;; once done. + (let ((limit (copy-marker pos))) (while (< (point) limit) - (unless (org-looking-at-p "[ \t]*$") (org-indent-line-to ind)) + (unless (looking-at-p "[ \t]*$") (indent-line-to ind)) (forward-line)) (set-marker limit nil)))) (end (copy-marker end))) (while (< (point) end) - (if (or (org-looking-at-p " \r\t\n") (org-at-heading-p)) (forward-line) + (if (or (looking-at-p " \r\t\n") (org-at-heading-p)) (forward-line) (let* ((element (org-element-at-point)) (type (org-element-type element)) (element-end (copy-marker (org-element-property :end element))) (ind (org--get-expected-indentation element nil))) (cond + ;; Element indented as a single block. Example blocks + ;; preserving indentation are a special case since the + ;; "contents" must not be indented whereas the block + ;; boundaries can. + ((or (memq type '(export-block latex-environment)) + (and (eq type 'example-block) + (not + (or org-src-preserve-indentation + (org-element-property :preserve-indent element))))) + (let ((offset (- ind (org-get-indentation)))) + (unless (zerop offset) + (indent-rigidly (org-element-property :begin element) + (org-element-property :end element) + offset))) + (goto-char element-end)) + ;; Elements indented line wise. Be sure to exclude + ;; example blocks (preserving indentation) and source + ;; blocks from this category as they are treated + ;; specially later. ((or (memq type '(paragraph table table-row)) (not (or (org-element-property :contents-begin element) - (memq type - '(example-block export-block src-block))))) - ;; Elements here are indented as a single block. Also - ;; align node properties. + (memq type '(example-block src-block))))) (when (eq type 'node-property) (org--align-node-property) (beginning-of-line)) - (funcall indent-to ind element-end)) + (funcall indent-to ind (min element-end end))) + ;; Elements consisting of three parts: before the + ;; contents, the contents, and after the contents. The + ;; contents are treated specially, according to the + ;; element type, or not indented at all. Other parts are + ;; indented as a single block. (t - ;; Elements in this category consist of three parts: - ;; before the contents, the contents, and after the - ;; contents. The contents are treated specially, - ;; according to the element type, or not indented at - ;; all. Other parts are indented as a single block. (let* ((post (copy-marker (org-element-property :post-affiliated element))) (cbeg @@ -23116,8 +22751,7 @@ assumed to be significant there." ;; Fake contents for source blocks. (org-with-wide-buffer (goto-char post) - (forward-line) - (point))) + (line-beginning-position 2))) ((memq type '(footnote-definition item plain-list)) ;; Contents in these elements could start on ;; the same line as the beginning of the @@ -23148,10 +22782,10 @@ assumed to be significant there." offset)) (goto-char cbeg))) ((eq type 'item) (goto-char cbeg)) - (t (funcall indent-to ind cbeg))) + (t (funcall indent-to ind (min cbeg end)))) (when (< (point) end) - (case type - ((example-block export-block verse-block)) + (cl-case type + ((example-block verse-block)) (src-block ;; In a source block, indent source code ;; according to language major mode, but only if @@ -23162,7 +22796,8 @@ assumed to be significant there." (indent-region (point-min) (point-max)))))) (t (org-indent-region (point) (min cend end)))) (goto-char (min cend end)) - (when (< (point) end) (funcall indent-to ind element-end))) + (when (< (point) end) + (funcall indent-to ind (min element-end end)))) (set-marker post nil) (set-marker cbeg nil) (set-marker cend nil)))) @@ -23174,7 +22809,7 @@ assumed to be significant there." (interactive) (unless (save-excursion (beginning-of-line) - (org-looking-at-p org-drawer-regexp)) + (looking-at-p org-drawer-regexp)) (user-error "Not at a drawer")) (let ((element (org-element-at-point))) (unless (memq (org-element-type element) '(drawer property-drawer)) @@ -23190,7 +22825,7 @@ assumed to be significant there." (unless (save-excursion (beginning-of-line) (let ((case-fold-search t)) - (org-looking-at-p "[ \t]*#\\+\\(begin\\|end\\)_"))) + (looking-at-p "[ \t]*#\\+\\(begin\\|end\\)_"))) (user-error "Not at a block")) (let ((element (org-element-at-point))) (unless (memq (org-element-type element) @@ -23225,20 +22860,20 @@ assumed to be significant there." (require 'org-element) ;; Prevent auto-fill from inserting unwanted new items. (when (boundp 'fill-nobreak-predicate) - (org-set-local - 'fill-nobreak-predicate + (setq-local + fill-nobreak-predicate (org-uniquify (append fill-nobreak-predicate '(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)) + (setq-local paragraph-start paragraph-ending) + (setq-local paragraph-separate paragraph-ending)) + (setq-local fill-paragraph-function 'org-fill-paragraph) + (setq-local auto-fill-inhibit-regexp nil) + (setq-local adaptive-fill-function 'org-adaptive-fill-function) + (setq-local normal-auto-fill-function 'org-auto-fill-function) + (setq-local comment-line-break-function 'org-comment-line-break-function)) (defun org-fill-line-break-nobreak-p () "Non-nil when a new line at point would create an Org line break." @@ -23264,7 +22899,7 @@ matches in paragraphs or comments, use it." (save-excursion (beginning-of-line) (cond ((not (message-in-body-p)) (throw 'exit nil)) - ((org-looking-at-p org-table-line-regexp) (throw 'exit nil)) + ((looking-at-p org-table-line-regexp) (throw 'exit nil)) ((looking-at message-cite-prefix-regexp) (throw 'exit (match-string-no-properties 0))) ((looking-at org-outline-regexp) @@ -23278,7 +22913,7 @@ matches in paragraphs or comments, use it." (type (org-element-type element)) (post-affiliated (org-element-property :post-affiliated element))) (unless (< p post-affiliated) - (case type + (cl-case type (comment (save-excursion (beginning-of-line) @@ -23346,11 +22981,11 @@ a footnote definition, try to fill the first paragraph within." (looking-at message-cite-prefix-regexp)))) ;; First ensure filling is correct in message-mode. (let ((fill-paragraph-function - (cadadr (assoc 'fill-paragraph-function org-fb-vars))) - (fill-prefix (cadadr (assoc 'fill-prefix org-fb-vars))) - (paragraph-start (cadadr (assoc 'paragraph-start org-fb-vars))) + (cl-cadadr (assq 'fill-paragraph-function org-fb-vars))) + (fill-prefix (cl-cadadr (assq 'fill-prefix org-fb-vars))) + (paragraph-start (cl-cadadr (assq 'paragraph-start org-fb-vars))) (paragraph-separate - (cadadr (assoc 'paragraph-separate org-fb-vars)))) + (cl-cadadr (assq 'paragraph-separate org-fb-vars)))) (fill-paragraph nil)) (with-syntax-table org-mode-transpose-word-syntax-table ;; Move to end of line in order to get the first paragraph @@ -23362,7 +22997,7 @@ a footnote definition, try to fill the first paragraph within." (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. - (case (org-element-type element) + (cl-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. @@ -23522,7 +23157,7 @@ region only contains such lines." (<= (org-element-property :post-affiliated element) (point))) (skip-chars-forward " \t") (insert ": ")) - ((and (org-looking-at-p "[ \t]*$") + ((and (looking-at-p "[ \t]*$") (or (eq type 'inlinetask) (save-excursion (skip-chars-forward " \r\t\n") @@ -23571,7 +23206,7 @@ region only contains such lines." (setq min-ind 0) (catch 'zerop (while (< (point) end) - (unless (org-looking-at-p "[ \t]*$") + (unless (looking-at-p "[ \t]*$") (let ((ind (org-get-indentation))) (setq min-ind (min min-ind ind)) (when (zerop ind) (throw 'zerop t)))) @@ -23585,10 +23220,10 @@ region only contains such lines." ((org-at-heading-p) (insert ": ") (forward-line) - (while (and (< (point) end) (org-looking-at-p "[ \t]*$")) + (while (and (< (point) end) (looking-at-p "[ \t]*$")) (insert ":") (forward-line))) - ((org-looking-at-p "[ \t]*:\\( \\|$\\)") + ((looking-at-p "[ \t]*:\\( \\|$\\)") (let* ((element (org-element-at-point)) (element-end (org-element-property :end element))) (if (eq (org-element-type element) 'fixed-width) @@ -23627,12 +23262,12 @@ region only contains such lines." (defun org-setup-comments-handling () (interactive) - (org-set-local 'comment-use-syntax nil) - (org-set-local 'comment-start "# ") - (org-set-local 'comment-start-skip "^\\s-*#\\(?: \\|$\\)") - (org-set-local 'comment-insert-comment-function 'org-insert-comment) - (org-set-local 'comment-region-function 'org-comment-or-uncomment-region) - (org-set-local 'uncomment-region-function 'org-comment-or-uncomment-region)) + (setq-local comment-use-syntax nil) + (setq-local comment-start "# ") + (setq-local comment-start-skip "^\\s-*#\\(?: \\|$\\)") + (setq-local comment-insert-comment-function 'org-insert-comment) + (setq-local comment-region-function 'org-comment-or-uncomment-region) + (setq-local uncomment-region-function 'org-comment-or-uncomment-region)) (defun org-insert-comment () "Insert an empty comment above current line. @@ -23674,7 +23309,13 @@ strictly within a source block, use appropriate comment syntax." (skip-chars-backward " \r\t\n") (line-beginning-position)) end))) - (org-babel-do-in-edit-buffer (call-interactively 'comment-dwim)) + ;; Translate region boundaries for the Org buffer to the source + ;; buffer. + (let ((offset (- end beg))) + (save-excursion + (goto-char beg) + (org-babel-do-in-edit-buffer + (comment-or-uncomment-region (point) (+ offset (point)))))) (save-restriction ;; Restrict region (narrow-to-region (save-excursion (goto-char beg) @@ -23724,7 +23365,7 @@ strictly within a source block, use appropriate comment syntax." (insert comment-start)) (forward-line))))))))) -(defun org-comment-dwim (arg) +(defun org-comment-dwim (_arg) "Call `comment-dwim' within a source edit buffer if needed." (interactive "*P") (if (org-in-src-block-p) @@ -23764,7 +23405,8 @@ time-range, if possible. When optional argument UTC is non-nil, time will be expressed as Universal Time." (format-time-string - format (org-timestamp--to-internal-time timestamp end) utc)) + format (org-timestamp--to-internal-time timestamp end) + (and utc t))) (defun org-timestamp-split-range (timestamp &optional end) "Extract a TIMESTAMP object from a date or time range. @@ -23826,7 +23468,6 @@ it has a `diary' type." ;;; Other stuff. (defvar reftex-docstruct-symbol) -(defvar reftex-cite-format) (defvar org--rds) (defun org-reftex-citation () @@ -23844,131 +23485,137 @@ Export of such citations to both LaTeX and HTML is handled by the contributed package ox-bibtex by Taru Karttunen." (interactive) (let ((reftex-docstruct-symbol 'org--rds) - (reftex-cite-format "\\cite{%l}") org--rds bib) - (save-excursion - (save-restriction - (widen) - (let ((case-fold-search t) - (re "^[ \t]*#\\+BIBLIOGRAPHY:[ \t]+\\([^ \t\n]+\\)")) - (if (not (save-excursion - (or (re-search-forward re nil t) - (re-search-backward re nil t)))) - (user-error "No bibliography defined in file") - (setq bib (concat (match-string 1) ".bib") - org--rds (list (list 'bib bib))))))) + (org-with-wide-buffer + (let ((case-fold-search t) + (re "^[ \t]*#\\+BIBLIOGRAPHY:[ \t]+\\([^ \t\n]+\\)")) + (if (not (save-excursion + (or (re-search-forward re nil t) + (re-search-backward re nil t)))) + (user-error "No bibliography defined in file") + (setq bib (concat (match-string 1) ".bib") + org--rds (list (list 'bib bib)))))) (call-interactively 'reftex-citation))) ;;;; Functions extending outline functionality -(defun org-beginning-of-line (&optional arg) - "Go to the beginning of the current line. If that is invisible, continue -to a visible line beginning. This makes the function of C-a more intuitive. -If this is a headline, and `org-special-ctrl-a/e' is set, ignore tags on the -first attempt, and only move to after the tags when the cursor is already -beyond the end of the headline." - (interactive "P") - (let ((pos (point)) - (special (if (consp org-special-ctrl-a/e) - (car org-special-ctrl-a/e) - org-special-ctrl-a/e)) - deactivate-mark refpos) - (if (org-bound-and-true-p visual-line-mode) - (beginning-of-visual-line 1) - (beginning-of-line 1)) - (if (and arg (fboundp 'move-beginning-of-line)) - (call-interactively 'move-beginning-of-line) - (if (bobp) - nil - (backward-char 1) - (if (org-truely-invisible-p) - (while (and (not (bobp)) (org-truely-invisible-p)) - (backward-char 1) - (beginning-of-line 1)) - (forward-char 1)))) - (when special - (cond - ((and (looking-at org-complex-heading-regexp) - (eq (char-after (match-end 1)) ?\s)) - (setq refpos (min (1+ (or (match-end 3) (match-end 2) (match-end 1))) - (point-at-eol))) - (goto-char - (if (eq special t) - (cond ((> pos refpos) refpos) - ((= pos (point)) refpos) - (t (point))) - (cond ((> pos (point)) (point)) - ((not (eq last-command this-command)) (point)) - (t refpos))))) - ((org-at-item-p) - ;; Being at an item and not looking at an the item means point - ;; was previously moved to beginning of a visual line, which - ;; doesn't contain the item. Therefore, do nothing special, - ;; just stay here. - (when (looking-at org-list-full-item-re) - ;; Set special position at first white space character after - ;; bullet, and check-box, if any. - (let ((after-bullet - (let ((box (match-end 3))) - (if (not box) (match-end 1) - (let ((after (char-after box))) - (if (and after (= after ? )) (1+ box) box)))))) - ;; Special case: Move point to special position when - ;; currently after it or at beginning of line. - (if (eq special t) - (when (or (> pos after-bullet) (= (point) pos)) - (goto-char after-bullet)) - ;; Reversed case: Move point to special position when - ;; point was already at beginning of line and command is - ;; repeated. - (when (and (= (point) pos) (eq last-command this-command)) - (goto-char after-bullet)))))))) - (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)))))))) - -(defun org-end-of-line (&optional arg) - "Go to the end of the line. +(defun org-beginning-of-line (&optional n) + "Go to the beginning of the current visible line. + If this is a headline, and `org-special-ctrl-a/e' is set, ignore tags on the first attempt, and only move to after the tags when -the cursor is already beyond the end of the headline." - (interactive "P") - (let ((special (if (consp org-special-ctrl-a/e) (cdr org-special-ctrl-a/e) - org-special-ctrl-a/e)) - (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))) +the cursor is already beyond the end of the headline. + +With argument N not nil or 1, move forward N - 1 lines first." + (interactive "^p") + (let ((origin (point)) + (special (pcase org-special-ctrl-a/e + (`(,C-a . ,_) C-a) (_ org-special-ctrl-a/e))) deactivate-mark) - (if (or (not special) arg) (call-interactively move-fun) - (let* ((element (save-excursion (beginning-of-line) - (org-element-at-point))) - (type (org-element-type element))) - (cond - ((memq type '(headline inlinetask)) - (let ((pos (point))) - (beginning-of-line 1) - (if (looking-at (org-re ".*?\\(?:\\([ \t]*\\)\\(:[[:alnum:]_@#%:]+:\\)?[ \t]*\\)?$")) - (if (eq special t) - (if (or (< pos (match-beginning 1)) (= pos (match-end 0))) - (goto-char (match-beginning 1)) - (goto-char (match-end 0))) - (if (or (< pos (match-end 0)) - (not (eq this-command last-command))) - (goto-char (match-end 0)) - (goto-char (match-beginning 1)))) - (call-interactively move-fun)))) - ((outline-invisible-p (line-end-position)) - ;; If element is hidden, `move-end-of-line' would put point - ;; 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)))) - (setq disable-point-adjustment - (or (not (invisible-p (point))) - (not (invisible-p (max (point-min) (1- (point)))))))) + ;; First move to a visible line. + (if (bound-and-true-p visual-line-mode) + (beginning-of-visual-line n) + (move-beginning-of-line n) + ;; `move-beginning-of-line' may leave point after invisible + ;; characters if line starts with such of these (e.g., with + ;; a link at column 0). Really move to the beginning of the + ;; current visible line. + (beginning-of-line)) + (cond + ;; No special behavior. Point is already at the beginning of + ;; a line, logical or visual. + ((not special)) + ;; `beginning-of-visual-line' left point before logical beginning + ;; of line: point is at the beginning of a visual line. Bail + ;; out. + ((and (bound-and-true-p visual-line-mode) (not (bolp)))) + ((let ((case-fold-search nil)) (looking-at org-complex-heading-regexp)) + ;; At a headline, special position is before the title, but + ;; after any TODO keyword or priority cookie. + (let ((refpos (min (1+ (or (match-end 3) (match-end 2) (match-end 1))) + (line-end-position))) + (bol (point))) + (if (eq special 'reversed) + (when (and (= origin bol) (eq last-command this-command)) + (goto-char refpos)) + (when (or (> origin refpos) (= origin bol)) + (goto-char refpos))))) + ((and (looking-at org-list-full-item-re) + (memq (org-element-type (save-match-data (org-element-at-point))) + '(item plain-list))) + ;; Set special position at first white space character after + ;; bullet, and check-box, if any. + (let ((after-bullet + (let ((box (match-end 3))) + (cond ((not box) (match-end 1)) + ((eq (char-after box) ?\s) (1+ box)) + (t box))))) + (if (eq special 'reversed) + (when (and (= (point) origin) (eq last-command this-command)) + (goto-char after-bullet)) + (when (or (> origin after-bullet) (= (point) origin)) + (goto-char after-bullet))))) + ;; No special context. Point is already at beginning of line. + (t nil)))) + +(defun org-end-of-line (&optional n) + "Go to the end of the line, but before ellipsis, if any. + +If this is a headline, and `org-special-ctrl-a/e' is set, ignore +tags on the first attempt, and only move to after the tags when +the cursor is already beyond the end of the headline. + +With argument N not nil or 1, move forward N - 1 lines first." + (interactive "^p") + (let ((origin (point)) + (special (pcase org-special-ctrl-a/e + (`(,_ . ,C-e) C-e) (_ org-special-ctrl-a/e))) + deactivate-mark) + ;; First move to a visible line. + (if (bound-and-true-p visual-line-mode) + (beginning-of-visual-line n) + (move-beginning-of-line n)) + (cond + ;; At a headline, with tags. + ((and special + (save-excursion + (beginning-of-line) + (let ((case-fold-search nil)) + (looking-at org-complex-heading-regexp))) + (match-end 5)) + (let ((tags (save-excursion + (goto-char (match-beginning 5)) + (skip-chars-backward " \t") + (point))) + (visual-end (and (bound-and-true-p visual-line-mode) + (save-excursion + (end-of-visual-line) + (point))))) + ;; If `end-of-visual-line' brings us before end of line or + ;; even tags, i.e., the headline spans over multiple visual + ;; lines, move there. + (cond ((and visual-end + (< visual-end tags) + (<= origin visual-end)) + (goto-char visual-end)) + ((eq special 'reversed) + (if (and (= origin (line-end-position)) + (eq this-command last-command)) + (goto-char tags) + (end-of-line))) + (t + (if (or (< origin tags) (= origin (line-end-position))) + (goto-char tags) + (end-of-line)))))) + ((bound-and-true-p visual-line-mode) + (let ((bol (line-beginning-position))) + (end-of-visual-line) + ;; If `end-of-visual-line' gets us past the ellipsis at the + ;; end of a line, backtrack and use `end-of-line' instead. + (when (/= bol (line-beginning-position)) + (goto-char bol) + (end-of-line)))) + (t (end-of-line))))) (define-key org-mode-map "\C-a" 'org-beginning-of-line) (define-key org-mode-map "\C-e" 'org-end-of-line) @@ -24026,14 +23673,14 @@ depending on context." ((or (not org-special-ctrl-k) (bolp) (not (org-at-heading-p))) - (if (and (get-char-property (min (point-max) (point-at-eol)) 'invisible) - 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? "))) - (user-error "C-k aborted as it would kill a hidden subtree"))) + (when (and (get-char-property (min (point-max) (point-at-eol)) 'invisible) + org-ctrl-k-protect-subtree + (or (eq org-ctrl-k-protect-subtree 'error) + (not (y-or-n-p "Kill hidden subtree along with headline? ")))) + (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]*$")) + (if (bound-and-true-p visual-line-mode) 'kill-visual-line 'kill-line))) + ((looking-at ".*?\\S-\\([ \t]+\\(:[[:alnum:]_@#%:]+:\\)\\)[ \t]*$") (kill-region (point) (match-beginning 1)) (org-set-tags nil t)) (t (kill-region (point) (point-at-eol))))) @@ -24046,20 +23693,21 @@ This command will look at the current kill and check if is a single subtree, or a series of subtrees[1]. If it passes the test, and if the cursor is at the beginning of a line or after the stars of a currently empty headline, then the yank is handled specially. How exactly depends -on the value of the following variables, both set by default. +on the value of the following variables. `org-yank-folded-subtrees' - When set, the subtree(s) will be folded after insertion, but only - if doing so would now swallow text after the yanked text. + By default, this variable is non-nil, which results in + subtree(s) being folded after insertion, except if doing so + would swallow text after the yanked text. `org-yank-adjusted-subtrees' - When set, the subtree will be promoted or demoted in order to - fit into the local outline tree structure, which means that the - level will be adjusted so that it becomes the smaller one of the - two *visible* surrounding headings. + When non-nil (the default value is nil), the subtree will be + promoted or demoted in order to fit into the local outline tree + structure, which means that the level will be adjusted so that it + becomes the smaller one of the two *visible* surrounding headings. Any prefix to this command will cause `yank' to be called directly with -no special treatment. In particular, a simple \\[universal-argument] prefix \ +no special treatment. In particular, a simple `\\[universal-argument]' prefix \ will just plainly yank the text as it is. @@ -24106,7 +23754,7 @@ interactive command with similar behavior." (or (looking-at org-outline-regexp) (re-search-forward org-outline-regexp-bol end t)) (while (and (< (point) end) (looking-at org-outline-regexp)) - (hide-subtree) + (outline-hide-subtree) (org-cycle-show-empty-lines 'folded) (condition-case nil (outline-forward-same-level 1) @@ -24137,11 +23785,9 @@ interactive command with similar behavior." (setq level (org-outline-level))) (goto-char end) (skip-chars-forward " \t\r\n\v\f") - (if (or (eobp) - (and (bolp) (looking-at org-outline-regexp) - (<= (org-outline-level) level))) - nil ; Nothing would be swallowed - t))))) ; something would swallow + (not (or (eobp) + (and (bolp) (looking-at-p org-outline-regexp) + (<= (org-outline-level) level)))))))) (define-key org-mode-map "\C-y" 'org-yank) @@ -24150,14 +23796,13 @@ interactive command with similar behavior." This version does not only check the character property, but also `visible-mode'." ;; Early versions of noutline don't have `outline-invisible-p'. - (if (org-bound-and-true-p visible-mode) - nil + (unless (bound-and-true-p visible-mode) (outline-invisible-p))) (defun org-invisible-p2 () "Check if point is at a character currently not visible." (save-excursion - (if (and (eolp) (not (bobp))) (backward-char 1)) + (when (and (eolp) (not (bobp))) (backward-char 1)) ;; Early versions of noutline don't have `outline-invisible-p'. (outline-invisible-p))) @@ -24176,8 +23821,6 @@ This version does not only check the character property, but also (defun org-at-heading-p (&optional ignored) (outline-on-heading-p t)) -;; Compatibility alias with Org versions < 7.8.03 -(defalias 'org-on-heading-p 'org-at-heading-p) (defun org-in-commented-heading-p (&optional no-inheritance) "Non-nil if point is under a commented heading. @@ -24188,8 +23831,8 @@ unless optional argument NO-INHERITANCE is non-nil." ((let ((headline (nth 4 (org-heading-components)))) (and headline (let ((case-fold-search nil)) - (org-string-match-p (concat "^" org-comment-string "\\(?: \\|$\\)") - headline))))) + (string-match-p (concat "^" org-comment-string "\\(?: \\|$\\)") + headline))))) (no-inheritance nil) (t (save-excursion (and (org-up-heading-safe) (org-in-commented-heading-p)))))) @@ -24217,13 +23860,13 @@ unless optional argument NO-INHERITANCE is non-nil." "If point is at the end of an empty headline, return t, else nil. If the heading only contains a TODO keyword, it is still still considered empty." - (and (looking-at "[ \t]*$") - (when org-todo-line-regexp + (let ((case-fold-search nil)) + (and (looking-at "[ \t]*$") + org-todo-line-regexp (save-excursion - (beginning-of-line 1) - (let ((case-fold-search nil)) - (looking-at org-todo-line-regexp) - (string= (match-string 3) "")))))) + (beginning-of-line) + (looking-at org-todo-line-regexp) + (string= (match-string 3) ""))))) (defun org-at-heading-or-item-p () (or (org-at-heading-p) (org-at-item-p))) @@ -24238,9 +23881,7 @@ empty." "Move to the heading line of which the present line is a subheading. This function considers both visible and invisible heading lines. With argument, move up ARG levels." - (if (fboundp 'outline-up-heading-all) - (outline-up-heading-all arg) ; emacs 21 version of outline.el - (outline-up-heading arg t))) ; emacs 22 version of outline.el + (outline-up-heading arg t)) (defun org-up-heading-safe () "Move to the heading line of which the present line is a subheading. @@ -24339,8 +23980,7 @@ This is like outline-next-sibling, but invisible headings are ok." (outline-next-heading) (while (and (not (eobp)) (> (funcall outline-level) level)) (outline-next-heading)) - (if (or (eobp) (< (funcall outline-level) level)) - nil + (unless (or (eobp) (< (funcall outline-level) level)) (point)))) (defun org-get-last-sibling () @@ -24353,8 +23993,7 @@ If there is no such heading, return nil." (while (and (> (funcall outline-level) level) (not (bobp))) (outline-previous-heading)) - (if (< (funcall outline-level) level) - nil + (unless (< (funcall outline-level) level) (point))))) (defun org-end-of-subtree (&optional invisible-ok to-heading) @@ -24370,7 +24009,7 @@ If there is no such heading, return nil." (let ((first t) (level (funcall outline-level))) (if (and (derived-mode-p 'org-mode) (< level 1000)) - ;; A true heading (not a plain list item), in Org-mode + ;; A true heading (not a plain list item), in Org ;; This means we can easily find the end by looking ;; only for the right number of stars. Using a regexp to do ;; this is so much faster than using a Lisp loop. @@ -24383,13 +24022,12 @@ If there is no such heading, return nil." (setq first nil) (outline-next-heading))) (unless to-heading - (if (memq (preceding-char) '(?\n ?\^M)) - (progn - ;; Go to end of line before heading - (forward-char -1) - (if (memq (preceding-char) '(?\n ?\^M)) - ;; leave blank line before heading - (forward-char -1)))))) + (when (memq (preceding-char) '(?\n ?\^M)) + ;; Go to end of line before heading + (forward-char -1) + (when (memq (preceding-char) '(?\n ?\^M)) + ;; leave blank line before heading + (forward-char -1))))) (point)) (defun org-end-of-meta-data (&optional full) @@ -24399,7 +24037,7 @@ clocking lines and regular drawers at the beginning of the entry." (org-back-to-heading t) (forward-line) - (when (org-looking-at-p org-planning-line-re) (forward-line)) + (when (looking-at-p org-planning-line-re) (forward-line)) (when (looking-at org-property-drawer-re) (goto-char (match-end 0)) (forward-line)) @@ -24408,11 +24046,11 @@ entry." (let ((end (save-excursion (outline-next-heading) (point))) (re (concat "[ \t]*$" "\\|" org-clock-line-re))) (while (not (eobp)) - (cond ((org-looking-at-p org-drawer-regexp) + (cond ((looking-at-p org-drawer-regexp) (if (re-search-forward "^[ \t]*:END:[ \t]*$" end t) (forward-line) (throw 'exit t))) - ((org-looking-at-p re) (forward-line)) + ((looking-at-p re) (forward-line)) (t (throw 'exit t)))))))) (defun org-forward-heading-same-level (arg &optional invisible-ok) @@ -24465,7 +24103,7 @@ respect customization of `org-odd-levels-only'." (outline-next-visible-heading arg))) (defun org-previous-visible-heading (arg) - "Move to the next visible heading. + "Move to the previous visible heading. This function wraps `outline-previous-visible-heading' with `org-with-limited-levels' in order to skip over inline tasks and @@ -24506,7 +24144,7 @@ Throw an error if no block is found." (<= (match-beginning 0) (org-element-property :post-affiliated element))) (setq last-element element) - (decf count)))) + (cl-decf count)))) (if (= count 0) (prog1 (goto-char (org-element-property :post-affiliated last-element)) (save-match-data (org-show-context))) @@ -24578,7 +24216,7 @@ item, etc. It also provides some special moves for convenience: ((not contents-begin) (goto-char end)) ;; If contents are invisible, skip the element altogether. ((outline-invisible-p (line-end-position)) - (case type + (cl-case type (headline (org-with-limited-levels (outline-next-visible-heading 1))) ;; At a plain list, make sure we move to the next item @@ -24589,7 +24227,7 @@ item, etc. It also provides some special moves for convenience: ((>= (point) contents-end) (goto-char end)) ((>= (point) contents-begin) ;; This can only happen on paragraphs and plain lists. - (case type + (cl-case type (paragraph (goto-char end)) ;; At a plain list, try to move to second element in ;; first item, if possible. @@ -24750,34 +24388,41 @@ Move to the previous element at the same level, when possible." (defun org-drag-element-backward () "Move backward element at point." (interactive) - (if (org-with-limited-levels (org-at-heading-p)) (org-move-subtree-up) - (let* ((elem (org-element-at-point)) - (prev-elem - (save-excursion - (goto-char (org-element-property :begin elem)) - (skip-chars-backward " \r\t\n") - (unless (bobp) - (let* ((beg (org-element-property :begin elem)) - (prev (org-element-at-point)) - (up prev)) - (while (and (setq up (org-element-property :parent up)) - (<= (org-element-property :end up) beg)) - (setq prev up)) - prev))))) - ;; 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)) - (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) - (- pos (org-element-property :begin elem))))))))) + (let ((elem (or (org-element-at-point) + (user-error "No element at point")))) + (if (eq (org-element-type elem) 'headline) + ;; Preserve point when moving a whole tree, even if point was + ;; on blank lines below the headline. + (let ((offset (skip-chars-backward " \t\n"))) + (unwind-protect (org-move-subtree-up) + (forward-char (- offset)))) + (let ((prev-elem + (save-excursion + (goto-char (org-element-property :begin elem)) + (skip-chars-backward " \r\t\n") + (unless (bobp) + (let* ((beg (org-element-property :begin elem)) + (prev (org-element-at-point)) + (up prev)) + (while (and (setq up (org-element-property :parent up)) + (<= (org-element-property :end up) beg)) + (setq prev up)) + prev))))) + ;; 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)) + (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) + (- pos (org-element-property :begin elem)))))))))) (defun org-drag-element-forward () "Move forward element at point." (interactive) (let* ((pos (point)) - (elem (org-element-at-point))) + (elem (or (org-element-at-point) + (user-error "No element at point")))) (when (= (point-max) (org-element-property :end elem)) (user-error "Cannot drag element forward")) (goto-char (org-element-property :end elem)) @@ -24810,7 +24455,7 @@ Move to the previous element at the same level, when possible." (defun org-drag-line-forward (arg) "Drag the line at point ARG lines forward." (interactive "p") - (dotimes (n (abs arg)) + (dotimes (_ (abs arg)) (let ((c (current-column))) (if (< 0 arg) (progn @@ -24834,7 +24479,7 @@ mode) if the mark is active, it marks the next element after the ones already marked." (interactive) (let (deactivate-mark) - (if (and (org-called-interactively-p 'any) + (if (and (called-interactively-p 'any) (or (and (eq last-command this-command) (mark t)) (and transient-mark-mode mark-active))) (set-mark @@ -24880,13 +24525,10 @@ modified." (interactive) (unless (eq major-mode '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 - (function - (lambda (contents) - (mapc - (lambda (element) + (letrec ((parse-tree (org-element-parse-buffer 'greater-element)) + (unindent-tree + (lambda (contents) + (dolist (element (reverse contents)) (if (memq (org-element-type element) '(headline section)) (funcall unindent-tree (org-element-contents element)) (save-excursion @@ -24894,10 +24536,49 @@ modified." (narrow-to-region (org-element-property :begin element) (org-element-property :end element)) - (org-do-remove-indentation))))) - (reverse contents)))))) + (org-do-remove-indentation)))))))) (funcall unindent-tree (org-element-contents parse-tree)))) +(defun org-show-children (&optional level) + "Show all direct subheadings of this heading. +Prefix arg LEVEL is how many levels below the current level +should be shown. Default is enough to cause the following +heading to appear." + (interactive "p") + ;; If `orgstruct-mode' is active, use the slower version. + (if orgstruct-mode (call-interactively #'outline-show-children) + (save-excursion + (org-back-to-heading t) + (let* ((current-level (funcall outline-level)) + (max-level (org-get-valid-level + current-level + (if level (prefix-numeric-value level) 1))) + (end (save-excursion (org-end-of-subtree t t))) + (regexp-fmt "^\\*\\{%d,%s\\}\\(?: \\|$\\)") + (past-first-child nil) + ;; Make sure to skip inlinetasks. + (re (format regexp-fmt + current-level + (cond + ((not (featurep 'org-inlinetask)) "") + (org-odd-levels-only (- (* 2 org-inlinetask-min-level) + 3)) + (t (1- org-inlinetask-min-level)))))) + ;; Display parent heading. + (outline-flag-region (line-end-position 0) (line-end-position) nil) + (forward-line) + ;; Display children. First child may be deeper than expected + ;; MAX-LEVEL. Since we want to display it anyway, adjust + ;; MAX-LEVEL accordingly. + (while (re-search-forward re end t) + (unless past-first-child + (setq re (format regexp-fmt + current-level + (max (funcall outline-level) max-level))) + (setq past-first-child t)) + (outline-flag-region + (line-end-position 0) (line-end-position) nil)))))) + (defun org-show-subtree () "Show everything after this heading at deeper levels." (interactive) @@ -24933,36 +24614,12 @@ when non-nil, is a regexp matching keywords names." (and extra (concat (and kwds "\\|") extra)) "\\):[ \t]*\\(.*\\)")) -;; Make isearch reveal the necessary context -(defun org-isearch-end () - "Reveal context after isearch exits." - (when isearch-success ; only if search was successful - (if (featurep 'xemacs) - ;; Under XEmacs, the hook is run in the correct place, - ;; we directly show the context. - (org-show-context 'isearch) - ;; In Emacs the hook runs *before* restoring the overlays. - ;; So we have to use a one-time post-command-hook to do this. - ;; (Emacs 22 has a special variable, see function `org-mode') - (unless (and (boundp 'isearch-mode-end-hook-quit) - isearch-mode-end-hook-quit) - ;; Only when the isearch was not quitted. - (org-add-hook 'post-command-hook 'org-isearch-post-command - 'append 'local))))) - -(defun org-isearch-post-command () - "Remove self from hook, and show context." - (remove-hook 'post-command-hook 'org-isearch-post-command 'local) - (org-show-context 'isearch)) - - ;;;; Integration with and fixes for other packages ;;; Imenu support -(defvar org-imenu-markers nil +(defvar-local org-imenu-markers nil "All markers currently used by Imenu.") -(make-variable-buffer-local 'org-imenu-markers) (defun org-imenu-new-marker (&optional pos) "Return a new marker for use by Imenu, and remember the marker." @@ -24973,50 +24630,48 @@ when non-nil, is a regexp matching keywords names." (defun org-imenu-get-tree () "Produce the index for Imenu." - (mapc (lambda (x) (move-marker x nil)) org-imenu-markers) + (dolist (x org-imenu-markers) (move-marker x nil)) (setq org-imenu-markers nil) - (let* ((n org-imenu-depth) + (let* ((case-fold-search nil) + (n org-imenu-depth) (re (concat "^" (org-get-limited-outline-regexp))) (subs (make-vector (1+ n) nil)) (last-level 0) m level head0 head) - (save-excursion - (save-restriction - (widen) - (goto-char (point-max)) - (while (re-search-backward re nil t) - (setq level (org-reduced-level (funcall outline-level))) - (when (and (<= level n) - (looking-at org-complex-heading-regexp) - (setq head0 (org-match-string-no-properties 4))) - (setq head (org-link-display-format head0) - m (org-imenu-new-marker)) - (org-add-props head nil 'org-imenu-marker m 'org-imenu t) - (if (>= level last-level) - (push (cons head m) (aref subs level)) - (push (cons head (aref subs (1+ level))) (aref subs level)) - (loop for i from (1+ level) to n do (aset subs i nil))) - (setq last-level level))))) + (org-with-wide-buffer + (goto-char (point-max)) + (while (re-search-backward re nil t) + (setq level (org-reduced-level (funcall outline-level))) + (when (and (<= level n) + (looking-at org-complex-heading-regexp) + (setq head0 (match-string-no-properties 4))) + (setq head (org-link-display-format head0) + m (org-imenu-new-marker)) + (org-add-props head nil 'org-imenu-marker m 'org-imenu t) + (if (>= level last-level) + (push (cons head m) (aref subs level)) + (push (cons head (aref subs (1+ level))) (aref subs level)) + (cl-loop for i from (1+ level) to n do (aset subs i nil))) + (setq last-level level)))) (aref subs 1))) (eval-after-load "imenu" '(progn (add-hook 'imenu-after-jump-hook (lambda () - (if (derived-mode-p 'org-mode) - (org-show-context 'org-goto)))))) + (when (derived-mode-p 'org-mode) + (org-show-context 'org-goto)))))) -(defun org-link-display-format (link) - "Replace a link with its the description. +(defun org-link-display-format (s) + "Replace links in string S with their 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) - (match-string 5 link) - (concat (match-string 1 link) - (match-string 3 link))) - nil t link) - link))) + (replace-regexp-in-string + org-bracket-link-analytic-regexp + (lambda (m) + (if (match-end 5) (match-string 5 m) + (concat (match-string 1 m) (match-string 3 m)))) + s nil t))) (defun org-toggle-link-display () "Toggle the literal or descriptive display of links." @@ -25037,11 +24692,11 @@ If there is no description, use the link target." 'face 'org-agenda-restriction-lock) (overlay-put org-speedbar-restriction-lock-overlay 'help-echo "Agendas are currently limited to this item.") -(org-detach-overlay org-speedbar-restriction-lock-overlay) +(delete-overlay org-speedbar-restriction-lock-overlay) (defun org-speedbar-set-agenda-restriction () "Restrict future agenda commands to the location at point in speedbar. -To get rid of the restriction, use \\[org-agenda-remove-restriction-lock]." +To get rid of the restriction, use `\\[org-agenda-remove-restriction-lock]'." (interactive) (require 'org-agenda) (let (p m tp np dir txt) @@ -25065,9 +24720,9 @@ 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) - (user-error "Cannot restrict to non-Org-mode file")) + (user-error "Cannot restrict to non-Org mode file")) (org-agenda-set-restriction-lock 'file))) - (t (user-error "Don't know how to restrict Org-mode's agenda"))) + (t (user-error "Don't know how to restrict Org mode agenda"))) (move-overlay org-speedbar-restriction-lock-overlay (point-at-bol) (point-at-eol)) (setq current-prefix-arg nil) @@ -25091,9 +24746,9 @@ To get rid of the restriction, use \\[org-agenda-remove-restriction-lock]." "Non-nil when Flyspell can check object at point. ELEMENT is the element at point." (let ((object (save-excursion - (when (org-looking-at-p "\\>") (backward-char)) + (when (looking-at-p "\\>") (backward-char)) (org-element-context element)))) - (case (org-element-type object) + (cl-case (org-element-type object) ;; Prevent checks in links due to keybinding conflict with ;; Flyspell. ((code entity export-snippet inline-babel-call @@ -25116,8 +24771,9 @@ ELEMENT is the element at point." ;; faster than relying on `org-element-at-point'. (and (save-excursion (beginning-of-line) (and (let ((case-fold-search t)) - (not (looking-at "\\*+ END[ \t]*$"))) - (looking-at org-complex-heading-regexp))) + (not (looking-at-p "\\*+ END[ \t]*$"))) + (let ((case-fold-search nil)) + (looking-at org-complex-heading-regexp)))) (match-beginning 4) (>= (point) (match-beginning 4)) (or (not (match-beginning 5)) @@ -25143,7 +24799,7 @@ ELEMENT is the element at point." t))))) nil) (t - (case (org-element-type element) + (cl-case (org-element-type element) ((comment quote-section) t) (comment-block ;; Allow checks between block markers, not on them. @@ -25171,7 +24827,7 @@ ELEMENT is the element at point." (defun org-remove-flyspell-overlays-in (beg end) "Remove flyspell overlays in region." - (and (org-bound-and-true-p flyspell-mode) + (and (bound-and-true-p flyspell-mode) (fboundp 'flyspell-delete-region-overlays) (flyspell-delete-region-overlays beg end))) @@ -25199,8 +24855,8 @@ ELEMENT is the element at point." (eval-after-load "ecb" '(defadvice ecb-method-clicked (after esf/org-show-context activate) "Make hierarchy visible when jumping into location from ECB tree buffer." - (if (derived-mode-p 'org-mode) - (org-show-context)))) + (when (derived-mode-p 'org-mode) + (org-show-context)))) (defun org-bookmark-jump-unhide () "Unhide the current position, to show the bookmark location." diff --git a/elpa/org-plus-contrib-20170407/orgcard.pdf b/elpa/org-plus-contrib-20170407/orgcard.pdf new file mode 100644 index 0000000000000000000000000000000000000000..61a694a3848ba0d128af5102638c7fb0bf8e5444 GIT binary patch literal 81692 zcmeFYWmKHavM7wZI|=Tt0}R1Ja0u@1?k>SKxVyW%CP>iW65KTq9D)Q0b_d9NcJ_C^ zbJt$?{=Hc%HT6_iS9M8u7xm0g$_a}yvN8b>C?}@-<`LLQSV(LQEJ%2H5t!c_+n73; zkpMV=EF{nW5ST^Ht(=S@mB zTK7xq+Sber`+218xYf8_duOV4rAdc11L21qSU>&Su0y(1FCHJ&DqP#}`k;dm%=ZsL z$9H@>8yG)W1^C2_A;ebic!ry;rbr(T>rbj53_9#hrN}ijINNwHB04Wk5SKWTVuy85 zP%FaXc#l4uFR{<1ZPiJJ6EIz$57Z!4d*SOfMh;xj&Wh~feJ@(*{uwcWvT)nc>zuh` z8GKMDY8)BwMS%m3{z|Y@P%AU&TbrIx5*{UzbbHrf&H%1@+Ic+Gas7^ceIIvcrTpkd z9Q6<^e^Ne@$!!OETrLCW{8HcjLbvOYyWnoxPPu`d%_eC|1~KD8{-b#L#hcN|-w_pk zkong)LK$6w{X1$nP_)@X%Lzu8V;N>T^@z%j+Q})89$rl(U)EoFf61r!zj07H4YM!{ zlj?`-gR0i)SQM+*Yi4-YgPi9jOdzd+fHdlwbhLS9j;77jz`9Y!L<2XMc`{_sFUqtx zff^2Vj_5u)8NI9yp3lMK;;>W|$Kiw5$)hSgpn`q~rZp`LA;Q(3oVNx3P&SV9%oyEmFx)Cxu4@`j^FUFM+u z&hnCIT=4UDKC&pMHJ7D<8J49Xl=Bx6H?o8pvpEiSLWST7NR_9Nm;H3nlDNOG-pO9| zI_EH5O_e>?gt5!U#g~#@zN$RGC;7k=Wq7SK_ey8h7;{c~@aW=zqSDz)BuzEvY?s2p zb530~ek^DVA#=fzU(iOrBtyn+;)aVHB%VXJ- zc{k6q?Er~BlK{h%2jqG!Xo59Ij*2b>Tij%7d6CZ8UrL>%Knp&<@xZ;i{=>`|(lnwP7?NUXG3(5$n9Lj;dQpm(FQ&vXPT5gc! zCe4c-uaOL0m>k^m75@xYx~x~7R2WS9JA9wR*)G*=hQ)hNt9@$4G{rUbmTI0&B}dc} zwacW?Z(CS;&1s!BlML+Ogl-SfRQ)%bW1g)oQ(B?0B=AGFSel|xk?&WCX8k)%=W|`H zE@06eyM01*@cg@1r|iY#)tl@^x!BGN;|`%>s8EF!;Nk#geS$lOy2h)KqP>${++wY> z?dmljulY>uqaD6weqjhDZTRu}-B+vuxAHC6zO$oBaq*?KGCCF~0FM9g**f%XGZR!K zo6?M=fzfhIuVGfs{e34Hf{) zD~O9}NZGFXzP(~jI8Wmcn`Dd&U)0~NDxuAdm)f(#E{N=4bFZQXY`SWOo1G(3%?KBYn?%f9)KnHX z6Kb0_*UKN9s6;en9f2Wzi$_@A1pmB+hPkUy4F$mzV5*tGb!P=RXa_7?cy0CZh%N_H z>wRB~d! zV26i6%W?7LyxDt~TSd49NfdO_$o0w5JwmE}j^V({DT4XgUW0OBpnMvXN9$XvSq0Y<#0fiBKJd`+iiMp+ zGX5l`q!aEq`-NfQ(B^vHvoh~9PrSfiUT7p~$mk>b46oodJMBEEK4m%%>pC50ZexdO zFA$bb{(ehl#GLP$!CzddTzV|X$%9!zq-^f`DkX}dkEq^+60%dGf3T5u=)$yPiRMl& zvw=x!HM2wT8+bs%y>FE0Le0h4x=NT^0L+BF1X zE()_Ctst(T{CEr7eg=QV z0G{JpwB+Dzsp53Xc5!jc_?$1BW1@;1`s(CFtrwq>w;;*KPrf`rqH2>!PHs@M%o@^Z zU!x&Z|EvgR_Ggi|h}#Lx`az!jOVyWVPK~=uY&uPVGvb zk{%I=f*Hb<9r)ipg996z(?F2s_#zX(GrP%8jx_+Iuy^x7dm${F*61 z4=KXRJ$Pl2NAi`B5|@*xOLFj$cnl9s{!eiuL|T6iB8q%#U~Kt2W#ojqqnhZUfX*d+ zm_n3I7*RCn%-diqI(N1d}%S9>7~U8Z(5t#Y@%$u=!djHu1H>?{_R&8t7q;uE0`8lbGVICCSQ*H^|FM| zTgXyvm@%<6qKtAJM?zSoA*IGr35-wdTi$oFyd|ygU~7g3iwo^h1FEQdkrQy4+uz=< zxkMCFUfpD&w)JsU3~;|9T#5-#JOS49W1^whU8Z~ujhGciEmUk>VCX;tRkPgH$TaR9 zpF@MngMa1o)Tkc4L6+~MI*phbeC(8%6 zjqxnp)X`DRRUL<~y_Y@V(MRL_E)8|9^31Kn7tBbX=-s=1lx2RT=__%gl*{PWGAzLS z?V$AKw%5-0f_f`&iC6CI>uehHX&FP4LF9((Lq4m{HB8G$wBcEEW*llVP7~q6AkR$d z!!k5%P^(zFkf2Tf<-_SsxaOJ3M6|A!7T#Cf@5s2gxH;1>`u6>rxp<35b+D0vDBDtX z!GX+Tw7t7$1_`{3LaHstP>#K5wbo7V1@l@iFek*@&)(T)ipH?$L(>ex%cZTZ_8}g9 zw{3kdPN8Hr*a~)|C{$RsUzGRjfG4|#?D*R*kZpl4XHV-Qv_!Q9_Co_3gn}m`spoqM zttqX?J!vpS^I{j*90scQ(@lj|^6upR9d%~2yutS$H|`mEZn39a0TQQ&moxR*S$^)d zCcj1yA;=DYSxICJ=;7FAd)>BkNDavPq^bwM4yxzz*m8k!raqP9Z1w!rY+9YuT2k*S zEZ5ou3pzooTxUp;Sih)DDD328rjh#cWS4*bag!yF)tZtQE0LW1SfZ*)XTg>eSoA(# zMqkOlI{ot1f$i~K|J_w5m5vdaMSCR}rp9!@8yo+0jjucg>+Gw2C&W z0{qexY3MGCb7{0{GZD?<0~KX?4CT~odeN}6e%TWfyk$T`+Mc;lI<((1L~m1o`G0(PQ$ z>cpdT`BrRm&?6ED=02&?Nf|ZHRik=pJFlM4(=%x(hofrWJGK6>L#Z7QTJ z__C(gxVAaEXY%6_Q|QDtuh;t3FJouUcMU8-x9_Xx&s)~j8!1K$SMxt>X<8Fkia8?p zZz|o;joP9Zl_!6lY@9)$%XJmbCes{FuM(P;J*M-1ZL2$jkoo<69pt4_lMHQ{m)$w^ z;-Cu@TBX zv#8BGUxX@#VxypGTO#3uOo_l;{oa1cibJJh|BCeTaD?%jZ1qsym7`v2$b!WK`ZTfq zR#|GEY4a*i5&!EndYu$#4l8m+0Z`JBz5`HF2%3FdDIB?4R31cntk;pn|Q&HI}w4CbTD!s1`A~W%X zSgfK6p1<*vK_q2L<2ip)23gJ~T^mEV148r)k@-&^4eNkKepP)YxlcB?=O3bGuyD&z zkNZR0(XYM5x<8P*kPQ`uuc6C-8OF>wTvwo{KR09Q;F~OO5!-OVIOWElXN-lBFF;KD z{n$TFa2uqfDgKQkYh8dkWTCb2+=$nbF&O9{Li=$KGMO6vU9jEj2SGBQFYqqRpFbGH zaZty;@5V$KNEvwlHBlfcuPpxT`}~Dxa$w7-F~bzXF0OiqF#FOVV}tEE4hB%q5>~8@ zHXu{!x;U7!avf>edYe`=73>hG32QL(?R)Ln^h3pQbYN;$ErA`+cNGlg6P~u^b_l5$ z=5MZ*VGG|6o1uL8tR=kBFBXaKcLS;~v~*P3IF558W&)&-)7y^#kCDdrGJ)zGt=dUZ zb2EhfEt5`}vkdx{&>6@Beh5h!$Ms;J#Je=4z@&hB{TQlP>^Jf-f`_6%OEKxu3T@xn z3B_i%G0884E9#KSgL^53^$0>`=O8wq zYG}U%YbW{ZVriom^Ie&q(LGf3nXA`ciFElPgvx)3;E5HfCQ2UlVY{%(GgY@n8^^Pe zYs9~!390@O&FjCqYbI`qAB#CiHEOeN2Q2rFWnPrkxK1jBAw*;jo5lj%jd&z)z~U4O zoZ5^8KB646-<5fDmQc$z3|?`|b(>^o^*&NiOYOQv3`3;xCU;y*ViI_pwyuKyP`19d zma2D%|NO%SSk<;Y=Q(1~ZvuO=nk{U4y1u@iweg$n{_)$}EfF&}!D-?&$}9a5W@dL~ z4XjswQ^q{oh{~|Ru6hQ7OB!taKgWt3;_AHRb7ywNj^{7T8B&z5Z33hiUTF<#C9N>H zxE{#yKBmA)9+SPh?0W=T{tcuD zKvEn)(@9ugxcT`>{^)yp{-;GH3eo}URe>5(9IPaOC$S)uorL2bjE#iz56VHp^#^0) zBmw?2&P~Go2W90TVSQSL0tu*}#VqGwYp7`KM4|~YMp%@DS;^SVi9{RJ>iVxmJSqEU z75_BK09>s9X`^gL>%eh|6XS99OE*`0sw6u)ZAYnAHGAk`fqDG=kCOIu2_8o*c&Q3n zh3%fChg--RFgSiA|GL|a4sk4Ki10pxt7g>Gqy5+SnTA?;O(qLf?zNv=?T|*hkM4cJ zmwF~%>y1(5$xpVHRmQp_NK)rGI8HJ|EyE6X4TiErMYEp%XJlgv4n3(14WCTrGSM}V ztv7%Pv#GWgE#LY^8aT#Hd#kFLtNlt)DHpNdD#wUMOfVu8yAfSkzR8TxB9{9`=^Ryh z!P-c4k!ETvM@CY&To<0#k-P%lzWJqQh}CDnNwNjq&|;pY2oSZAniegVpU+^r;k2U$ z(?QcpF`9EUGRH6%0*jE46N4O+Cscakc!6fBOo}2wNG)F_pLPCbA}0%RvB9&9-RY+x8men6I|m~79?8wxOw)lJ-xin zU2a-2UOP4n!zB~Z^vlTO8#sUTF}`B8bVxSk`8DTc^1h4!@#1{&!J%Hsz>26BdJ>lmt}M-ONo3za%=D<6CG#iq7CIvzN*f9aI(6#fv|E#l@RA65a{_$wzCS`EY%(*e6GV!~RN-E?C z^1OjB6=i`ux;!(qlb)HlP_# zH_MoHIZ14@PCD7Se8b=ShZ`t?VVK0sXED?lEEd|GtNN2B6xIbaJGB`i(GQPL7=0k5 zW&Ny29&8_Dr`Wc%G1$;s7Y?0jEH3}kVJN~nmIx{$$ghk!tVOPO<+Z8bW9dXqru2k% z>5rc#SFk~9Lhv6A9#7=LKq9|Uw;I?De7WE+30@*js^Y3 zhu7~Xn3^fkPPVdERzD_3qmmW=aUOend7ROA3jrE<{IF|40*}g)0y9}V-UDNxwDcvP zW3fZ9A?$bjtfbH~(^~*zgq}q;ww!KG@4mL3EUe*xa9mnH@ZF~@828oAMacYziPOXm zRgJ_dT(T+B`BEqX0oroRuf8NgGTo_39K?;h z%JMpCpYaPlNq=~}-iug0^|Za$#o$>*6iz0W3_ti6QFMPEf9(kJT% zE85#U9B+R1{Gf+&_~XBbuocq}sy6IV0&+zc2RZBaUL(ljCCaXAzU^$jzj99jiQ=Vr9V6~hq* zKi2X5BwxuDtU6))C~oB}V?azjKRK&t=Fq2Mrcx=J&@yQpxM$Jv*qzH73NMJ4muChm z6cE^w$la5s=&L4cN|c8w;j6Q7Cn&*Y3_XP*vGD^Tx|Ne|84;~su22%0ZIA%+>I01l zTNp?87Ex?M>5qq&NKC3>Uj{h<;0$HU9>9K4t1sy&Sfr7Fj}uLJXVjFgBW7PK3$cUM zlTD#E`arQLQ*7xG)jzQAwoFit48tAQXFS6?j={!-ZC=b zc@|LDjMTCl)R4~Ii*lm*a8f@BGnrt}D8gLdP6T8A5d(TrhfIVdHf0Z%5?r5N*K(AN z-W{*7WOiAhp3e(~GS)!6_F!e8K_Y5ZO|lyuOyUG8cUW&UzcZRujMj@jl^ln7d^~LN z2V^eKnqG!S&kP>oSf-1nmQ;(4NA$@&009N+(~X5GSqLT9Mk-m6q;m1iZBDuKi`_ND z_~JEql#D^gSRa{JDfz5`qP2ilJV45{)-6q z2_#``!3vsOQiKGrrI6LQ2GHf_2!ckYPZg5;fstx?dcJ|t7PKo7TX{^V9~TncIW5q=IDu3%gGPhdy$XZ1=s3bQ(uhSh3uI2Z9%)6t;4-WH!vZCz}TKMz`}xI>p)d#{~> z6r-iOoW&$`uGrE)_^|NN@C$6-LUp#7s%z*gc2UAN3CIrFdm}m= zAKUo?ax3AWxQHd1Hbit25;Lv_^pwZpUHufuap-`JE)K?!1d>~=19V%-d+W}!Gyi4MEArh zHpeqj67!B8`q@DBrqYsG7N^Hn{hi0hv^nVw-AEo7(jm%hI`u$l33r!k>W_CS#=2z6 z$AF)LO-rhU;z~aw_#)~2!l`3t4c1zOzm^B@F5l^9In}@ zv1=$Fi+)QYr)jQoO{@$**;jWy6fX0gi)m~~0^8%_T_du3SXxm$XScT?M!uG;f8Cl0 z{+q>FTG`Y7>TQ;vb>Kz#MT#?6m2bLg2VLc}=eq9?g(aw3Ss??izH_VZxO7aMZb~kw zw#Oe;l%vWN@nxPjZH5G=wb-1GZ;wq&%yPP_%etzYWewTK^)9@_!cVdAFe6Dk$wUxtytm&_ z#NT6r_t(~avQ1QU{+@@kgB#xBQ32*ei(m$KY9*2*E31OiI4qN*WiwsnXrFMPg>`Uf zIptZ_AyS4CXYTkBg6!LZDaPdMgC*Ml2yAK;Tekl2&X5g_Rra!@aJo@=iq5r5ecHr0 zKW5Vrr*ukIcF}-%WQ)K|d^{5s%lH(|FAJg*u((GoAHyK%>P0=iJe2&O~VVP}7r;2Z613=Sb93iKjv z_xlo^3q6{*`;kPzIdQ)g@2(IU%M3#q-f`Y7iJFho@gnvp6hZG2&FN>~m&2f>6$xp# z;|sV4l;fTxU&B1y|MP&GqIvcBTUx=oR0PGq@Xo7-mdAUWDcYfay2qhEZ-00Ty!(q&_ErUtlwyF?$ zG(>G!WRY9ASfZAGi!D|Uf5X8O!0H}bBzn?A3u39WTNq%*jx9?DOTA0;Jm3JqxXXr7}e8m6b=qCeCWR2LBxG|aN0 zNGA(=ndka{OUb#f(;Q2uWt^WKgw z9Sw$_3LQIb5nqP1d=yF5)!rt(b|F%?yw`V%%Z;V-+PUsCI||IK_L_7Lh-`av+TW4T zbOe{yLCDMw80eD{Al~{|?(An*+JQc%-m~I+#Xu8(<8fi3FQheuUL;D`7~zeWOJoR_ zf387Y^lno=Nao$oxsY$LxdgNfqyZZuOgdY|)~|}QG%?dqCGvP*UN zKsLLIzxr+D?L4rld--Gkd!p|XxfG`bFoFstUKm6DyC2GB>IXiwVcw!D4|~(f$Q#B# zBn_xRm|?71D|STN@#4BYcNv)vl&Ad$(L7TyKNaK>Kx)uJ?#`74&RxtHA{gmF3_ zDX%l;8~lro)3n7RT{*8gxM0Rg1DwD8->9J!ymLQySjcHGpM8D z0OUYO*xjW~m;$w`XeVK!j!4cRLBD3rmFoBMvKhyiC27S5n z@T^4n;`{?m@)r2s;CPW6Y?RiP&qfN5w|&}ChuOgp?JgQ_y!N(G@BJ)3YgA8pwcEhN zfNQDPHUsFf?X|55PW;T-_{p8M{Ixy~k2V5MTC*K@(9ZH{4Fmq__Z6oN@JTVdEh!gO z490Wuft)wWfZ-az=|20C9X0VJnhNm=(P(Ey%BQqeJuzRR-SYc&b2P`hK)0zJ5y#8# zIM%-q7Uk>2L*{W=SWc5~KPVf#W_$%m>P$!Srn!bJxnpRi6jw<2EtcAqhs3Pg2^kXjKAVNq@EJZK@41 zOj%X+By`{vp{4S3x`!jD^l*LGoR2-Qtx{RLLmk((kNfYvE7rfi@AUuMykdRsD*apc z>Z#!c>Sz6*wy*x~m;Imgum07kVix@$dRbf~Ag2Gkm-W;md+OwAva+$UF|lbs`RVDI z^{Hj{JOE_lWCD=}=djY$O~2AQR{R6?~ENHw1!w2OCgG|I&ZWMU-&vT!qT zk#Mnbfqcuw0&0P>vyi-S0a%}%2y!J5WI9`6HR*$wUA<5ab?q4$h~raDkqmwQ{ktgMtO%1~38t70Rd1 z?QMj{-DqSKmp-oe_AaN2mpnM z8?-ji%Ae=5f;3>%D#|uwue9^_h1$^46&+vuvVn2|R8$|zOIminjoaM>>r=$W|3`$Bi zkc6i+25>yt`?S-!K@npo;bMRC7Aq@={KCKuiUTOm**QSQzTn)f93aM*U;#mHWhLPT zg`5L4`XrW>?fLY0d3b?bFZuZ5i)Y`y*z;ol-?lxyI^g&t`cDj>bAsb}+x%PnpXvWZ z?I|}o0Z*Irh4N4AUJ~jhVP5cOCJvS-Qvtx|lza~3pVWIEeR121xM%oZ3Cs5Mdg0~l z;Q+nrAOWy)f}F+vjB~O+?d<;>_#)?T2>Nc+Q!<0X%k>AoP=KKG0JIr7SU>>;f(`{x zWI!?DA_1~K#eoa>l)l`cmoXs9GbaG>v@to^08ezbCuv+9>>$X>!p-tuOn*c_i}-_s z90c+!7sr38`J?z*DCnkn()>4x3l!pi_s8G9`P;HTetH(o0rL7kYF==5(3S;JUOf8D z^Jnf09kgvhfqwQnD+}n*eOck(?3~Xm03a)f5dZ`Q>KXgP_dNFEwimu<_^%-Uc{_!m z`S&gK|M36kf&ah*|H`62H6ns0Co4DTsNewYG*C7541vI>!}JBRflfSD(7pY1>i+NL zbAdQPnG7l;Ku5y!iOt3NRCc^nQ7;s3P(ARptwCqnQ`PZwLA@w=fiFxiivPy{<^;T4 z)X(q_&tG!bL6-*GADJ(s|2OdOwY}hfjA3~?yEvZV3+2UluIJn4kJ-%daRZ*aK=%9Rif=`#*pR9WxeKCmR8GnJ#+W(cYfBujHW$beW_X3|X>Zvw( zu4X`z0nZ070CXKa)gAx-|EcN#jXVd2gPRMaA5;#590~+geJ?XuS)OktR@P_E7drbN zsi1TGxkh=>^(6ZR`z=OIr&N2k3zROPWa8ie*~rEAoL($X+k+c)Cjp-89FFIi+@M4TB_Q`xQa>dT z=;Mh62+By%^yl091qVKtPA`rJK5;ykt}lvNS%FV=^`BKd`;Y6{UoY!_@!h|y|Jy2# z=Nj*6_DgJD6mWq4@Bp1WplkFcHZRma^PZ`kpfU+m$v=DMB^G~Xf;|6%y>I}yo@@tz zN(vBsj?mwuFTQ%=e1`wZxc~kQ3{cq(;N08lWC_=^dB}iKCJX<%g12 zaQoYjsG5&_EfwXJl^7Gp*&C0I3XjyN4fS^=)z?(?=lCbu|Ebp#?0udm#Bw-LEE1_6Bs~TL6-U$KnZuJ3Jv(> zDllC%stb2%evA7qa`9epSGxaZPHqBn%=}RdNy8HLVfb1=h47&uw;kmzHQGFm(eWAe z(7nJnAL2uS_6c|3eURMLm`_?xR;IPzSdtI++pBF^9%7~8zLke+Kts38eFpw7Tj^O(jK(mUXrWUS#BFB54~7=-lv5*y4SRLhQje~ZFtIE9~Wa=Q*7 zAGV16CFBl6w8PZRlz3~)_G5t4c7}DK9<2YmVc~~1*VYQsxCz_QFp|hX6y&J(1iFf4 z&&VY!amCrizPNdujK1!y`=fjoLi|NPUqSXX%Zi7M^GbHW4RnJsyA?!gj6G?Om`gt2(V2g4Zpvs<8m!C^uN>h|-umkjzivXura z9`#tIMwGvvN?EP@yz+zCXo^&Lc^)546Pq3{%Vi(*UNpg?X3eJVw3K&L3NAT9(4(p& zn3TT$;?AVG?S4@nKJJF3IVQQ^sSmv`@a^0VvwdwjfT?OVJ;1{%abvL;t|vC0z)bZ6 zeIF+7W;7(`FeW}as(7wTIt%j-8h=3ZEdYa=mfMBFfq^4{smFXJ8WnHnL{h%}_^#6q`X4nJFl9Ow$O z55BSckvA0{8R=_TBrhQ}G);4=JXxwYxMRCMI(YJ1%gd4RQf1GoQ;s3>0B&Jot|Or9 zuDnVPa7&3vHY_|=Q&faTCm7T0`McKl+W)*4A67fzf+fq!Kq4nWZvHX z9dprzVm~1-CyIUg=cH9i@~hQM^1!R~{NpPwn7f#->!kJzE3D|#&?BXq(!my#S)r76 z(m8_F7Xk1Ha@F*mH$iy0_gAN|8LyGjQ*(;ta&PY?-tei*%N;|%?paS(G_g``PB_6` zo!(HFndam-}eG*qxXp0zI=cGO-LZteLOfKpJoHw;b@$)-FJbLaR@7kN>kVK^AdTjm=)>jg5mn>$`*rCE+s z6Qr)oEAZk-F1LAw7VBi}-8-4r`{aXBOh4`rwc8f@XzbM}2iR~K~LKk6{FiF>ew z5AR7*Zdy0KvfqwGBHk{316xcRsA7P_#*BR<7JUw#I-Fg3Wz5|5qy2+Y;m_&HeVjPY z`(O27<3mgB90IPO7a4=5AP@!b93l;SfbPr@iImK}_#LsUH2B2_J*uy#V`xP8&%7S--s*GD z3xaERnrPH<^(AX{0S?z(6*oQ9mTFMz{heafCVE`Sq#JZX*S@?3wu-*kDIOOl ztYx1e1Er777}yuJB*GEcPhv=Vwyt5z)BnEWO(w*0-AVh!y2B2a3*<;X9g0PmkrW0^ zf_z*>(;3akV50LbrstR)9l3j{YQ43GG#T~qeRO$)?z^vk?17DaTkR%HpXLrd;JZ6X zUd2o4;Dt5CBgv+`R;K$#l&6>WZi$ThhI#E?>BB}K6$YlHoPqbAuT*=XJXtWhY_!s@ zWgSl>^tejaA>m}*`$AUspIqnbwRDtT2X@X)I;-C;8|XWmJ-x18;n^K#UMUREs$|LC zTUuQ~ZS~h@exvoypRoO{(pForT!noSA2dFgWvlmJ5Pd4y*ilUxF_aAZR#=J8<1>1>MBfZvOqgD} zP6%hqkhECzs~n4HJVG6}zwq^*MYKW7*T&VR&BpH?tvq4@sB~1~P@a?7NA5ZYP{E0-q~siC{t) z5XkS9m#4St8(VDm1|+Bu3LW@lCYB@{Ro#>!avLHfs!^s6$Ww|jPuC2J{4nS;Y889T z`0UgPRB*3bhcC4q{j<3@+kcVs#>c!fu{|_aZCA;<3G};cv=#*DwxDC4^1PA7y=&d~ zYMsPA{Rr#@v}no{t)Zj3#w-jqe&ahT(18vC-jW%q2fA!*c9Cq@#&T?AF41ATyVjmQ z?(zZA5Nr3*pp_|mNq3l+PeU{^~}s>Am%g}gZMipzw}92=S& zbHpSZcmnQf2O7%xP4uV<(Z|m{7Mh}8{g*Ep0%vg1DT6Z#!&-#!>A%!EnQesueyVWF z&cQJZShPXc8`A`LO4V|I>1M~zc(nW==g}iwYA`hgY#Y8At6XEc4*xz>qA(_3Oz1+K8wpUU zL#F*~m*Sx7b#QeX{d*gMvJlu!jG*=%pWIA>col9nb)KF?HeDvFM>|=1^fjJAPh{6v z5V?%RUDDg)tCQks+pU6_zOGx((QJ7wH{Y=IPIw#qC9Dq~9Fe=DoL@Y}$aH2Rs7a^d zYv_mcU(2eTe8U0DGl`ga{JPaFYa=Obs7F|KlmFv_Oq`E&i9@o(hBW=Kh-3mS6|9OX z7+>6(u|hIyo*qnq*|F1l>=;GKd~;8!qT-%*UtH>&2yG&olqCjBnm++Ebwr(z7UyN@ zbv=tX%aPzH==)RIGmUC`fe{_kERAfe(6`qs9hwah%=VEAKe*p}Prolj`K>O;vUWUr z*5uqZ=Nhzyu1W0{+6|*=&EH6C|D7A|>Vh`!^U>wQS0S=pno|)8#cX$DFX5t?`h10x z8QTjj+!kl`tAPIfMUNhd7O9ED_jCPhm{)wSyNt$^{9-fv*c-QZukR1P0QHv-mxKm? zXZaShDBW?#= z!&HfOc?Y*|ohW&y3gRjBw>TZL8h|BFkJ^ZRw`voKCR+aKt!6e9tp28C#CN6(YfL=s z;ZRZ6eJ*g&P5`Zuz2deVeamUjQRIuyQMt9@V~MXO>{}6nKCdIj4J8nKP4cEvePvC8SC~Y-bCXLM1J`7V?LTAeP>_;DbN*9s{#9WX+D6}}iha?kCv*fw>zcCu@7B9y=R_c?i9-WdKM2q=THnKDl!X4n)} zT!QUv{i(DHbow8VTC0(ase_#E!aAiP)Jv+zH-iY9gw_!&Y0H7%5vHhq-8wsF#4Mmp z&r0%7k&`FywdWC;io~jeT@i4~S5qlY8~pkmPwz&xHor7#BnC8E!dcmuWLGBbIHb1+fn z%n9MI^o{#$Omy_x4#I0|1&@(MBi`Io@H$rcb1 z1fFa#PFmo`uK3a%av1m$0gd%%3 zpI?M~x;3h%RgT!iB>7>O;l(WTEcUYZGtg&F4Fp~d>!PbS3g(1m15KdUZ4Gl#C>d3w<%>;8 zn#%;Trve+tKw>ineHgfQyIO3HvpWi8x-FV8Td@ExdZr%3@kGw@E%&TM?le6 zQe}?}6xsV95?98gF}A-Q0q zLtK-BnzS_vu5t46sq-17W~g%s{Eh4tTdglnlPJeEqcCMgS{lX!rx}5HMyodH1=*v#N(59Q*Vt* zy`cZ9+;MTkSL`|)Bx`OIDm8g^f&}F#U)*;~3v+_@Jb|PaOzCMC=$xZ{x`tnvX?DJM zq< zk#kM1WQtbpDqQew==ZE#{6m6Pvl%MBzbdFDP$ zhI9VMZ+qwb&algl?H};Vg@2u0*)z+sq(~AdeKZ$Zsh${<{~|Z5ChH!CL(#a0v`2{Q zaFTJ%;lZ76qXuK;wLqEuvkY#+Yl`Nh6L7j~gi9{V5aKou;X}(<9B+94l@&XyKf=})|zynrb5;2*{X-zs5*=`6ULmRO`?hHfK@+|pE zGIA@oj<%Mu;&qwZh`3`~EMi)tJ{_?XLI~Yu(56T#DQnb}O(3`%cBRbf_>UuO&D}`> zN>i1Rl+)XYkN)p1tDqF$7bhfV{wfyrzl;^XrMckON7Khy>EPXd)LP>5+)Aa{(EYvE_;GXs6#V53#z+6S<}wpvUkHFO-0m`_P@S$R-&nM)LkZ0HMJm63@W zX;L~AEHJr7g{Dx|rv0uQD$Caz>SjoW+4d=mC2xKG(^|N>tOJ>$c+A`?Go^C1$AT}4pH+C%;)lSH1rOZ@({=r7 zWj1^DR{JA?m-RN#Ji3YI)oZAt-H864CK31c?14(BX9%#F5J;JAaltAOZp3BIG!#>|c)3>1^Fv$M)QBr)Q}z?B zobO) z2Q~o#`H&UykHpk)?U)5VED2wcotpyYS=lC5v|GQ{kBeee^urylc%E0jPVmfg2x(V} z(xJ@JWEOpMQ?|KqWb!Hx*uh60>KzAdH)qZ`nP>i*gKT)j=!#lGBF2`%9=3AO>8Px;b3rC}bnkb5Ys8qi1b*y)&9g5?uc4c`}P zR^;STjP3;matfsi&UI`C?jIbbHa|5Cc$9uiMD@xw_$}!mT^BPFuU|_N9%W5VDjz-4 zG}E98SLN;R!4fYrf7_&Uh<@#|JcnhRE5E%7xHNUin9~Uc_ylM&Qp&tDV`oh%vc}9F3JRu|OyhO>XK%>l~J6~)O32@#ivd1NZF4e}tK5_eq$r0uzn zUgef!j!@0?U`tFzO%2h^tmgfWz-Q=p44AEG@Z$|o@GaKo)!UIR+EJ$qw<}@@w>nca z8?q>&zHhu&UF{`0cY1=7OlOShDQcC`o0IuOxw*YwyBqoz#}2Lw1V^#i|1fH>rjV*h zpGc&L!t2W?>gV8UJSG&*YbAqY6LbggHIoq%n=&l#{ZiiXm|5pLP$1D84?acLhpFZ; z-s5Lf;#$YkkY~RgO0*UuE08up_p4 z2l02RfJ_UuaDAx`X*q4(|03-iqa*p-bsbFXWMbRt*tTukoY=N)+qN}vGO=yjI`egw)V{h_O_`@SBtAIJgC)>}d4X2Olq9NTIp1^vrB&%hA=y0%}K zS{!GW$51BKNs5tetbBy1C_0?19?K2;rQ2ffXBu1siJ|Xx?bD=AFArm+^S{b1 zzz#&H(L*NU*A}VzqVP$fFU)=i9A=WCg^j1fUmTcmNG_QW8deu94E8Z&LAA<2SjnQ_ zgQs)F%z1a}6M`rPp$Yut290<*N&<58yZfz026V3WN*SDYoMclx&LA9kFT*XCd z+^udzO{+S8JEj)q0IuLdt2yQW76FDdI~bFxRxlzAhm(x&vCcfupx-mB!!OTOz?ez( z`*AZD^h`upSs%RzL0=wypkaEoM{X}S3TnNz$jO;$eYa;&@3K=wJO+_3Xl$6H7tDBl zs;p6eD0@c$t2LNWWolUZyb|K?J(tJ0`YFlNHtQGN6OOfzNUh$B1uI7Ew^ci8;hdrq zxYPnNEq!IHQ6|g*H4BMG=uuaM-eyRqMRhi7K+Fj8#_hUydUsmRRBM(wgZF|K`Tgt; zslE%LB41SSIwTlF9r?=LISiH3XWgQ7B&$eWjBa-7VW{}S?=1}SKXP(iSBn~50%M7n zB6+OP8zq=O<@x_!gwv*1y@W$KEsLT$58o(Mz!4>T$uO6eJHV-5V$WnOwLTAgIcpv1 zRz;G;ekOP@PtH9P8UHpL_Q?7mqpgZXrS5^!HEJZ09YIzgmyz^nFm@3PQw(hq#bnib z$}*L(Gh6^;r_>y}i3bHGuc>qnrRr~zie@&(D#?>u;nC`SC7{K$`sgOBaS$wiFD9je-0OXbd0Wsjxz-~*$3XaZdB|ayq_MH0toisKbP>xtqGdhu z5S`~|u4JA-E^32%AKss1^8tP?62^C09goV|u6t zxp=-73;3TxlmfhJ(=21r;1V=`y*v!jovYid*pT#cc(lp!n;LYbUyP(|Ou<)b>5QXs zL#1~lYq1ZUg2aza;ORv9bl;cB<@BXi*-2XlPN}%pW@bKFynu|C9IFkp3m;$)h$a0c z{2LfP`ahtt`)j7uvQVI`oj5~*2X75(w!A3~toF+bEf`16#)gQTtNR0+Sh40l=dS2` zU3YJ{>A;|)ty1?fN`}-N)ip^MU4~ZrUnmU2*{XJx;O$jQ>hLiXy*;;;-pg1?GGc18 zHt<7gOy~J3>eW7{d(0FXy`WAtn#@{DX9iV)9_lKCpW#%_AM+F=w9d z5^{ODGNiF$<`kKFRm|*mX$xfscR(mfDX?WON~_y;D)(X@hHV{WEiG`5eRhOicwB|T zjb4|js4JdGRVdHloT?MrMuBO6*uVe&^zOaFZCRmHAo?v>qFR@KP+ZLK%74BGQiX~u zVy&Yuo?SIqFGsMzrx*EakSDqYbnTtm{o+H|$XWigt{pLK>Gc3zE@FCIxUJ&OO?u&I z5?r7YHywX85{IeMY+C|)U6MKgl*T=*N3gskNl9(>m0`)kj<#a*bU*hRH|pI?=nd+2 z_CJpvw(#KPqhBIE zuh@r0C%PNcquQ{0&kcYME6#l4QYYQ$4YvEYqz&5Y^==3`>HULrmE=7>6G?^lCcuRT6ljA@yeo;xg+e(5e>YLJI5fSh7zZk z2b?g4sb-EQz4XeyORb9%T>V)2k=nOd4e&X%7@wQ!RcMwz7Kba7Sea5;*~>S~d~Qj< zD-swk#tp+?TqODN;&hD9;u5XLEu}A7D%Rd5(;yYrevr0vaq__(u}zM2a}_i`g{nv6 zM8d9|zKHp3fY8fD)GmfL26RYX9i8wrBStqneclk&AkxI1CYm;pQhx%ebO*exEFdQ( z_=>7*WyP^pS%Y%>$(UbNC?zK{jw)LXg!d}kuSc})HHCcN7*_!yi zEskiQ4^4;fDFZy9JQNqE&K(PR#@}Q5>e}pUTcvI{4`P@g;AVoH37i-lpzl$-P=4ND zU#@*9o487PpBZ!R^QzEt}&mKd+d)QtdJfI?p z!P#6p33~LE+LTIqf8Loz6pAvWMUsSe#j-nQv*A9zCHvLxPt{mnjkr)wk}V_AW3~e7#UmjTz{cV|@`{z%9Z7B4>k8 zRmEpMVz2@~3c0*}g983meSvtwHX%Wx#3anD<|ZI3s_j+mw-tFOTfcrJI)}{|(D8uV zB4RksKo6RSMI4IuLY^l4@aQd6Cm!mAXOXJvYE&CO$Bk6S3uvU$>i(nM zEw%Ek1$f}5n{~8Aa`~Kg=a1k=)6SYfzd|2IO!ykT`@zAIhns1-4xBDnnZqPX=({k8 z?(M_a5pGxZ33&J#ZDpg-h>Q*yj~(#!4;mHsQJvsi@#!quAz^9zu9oe*d)9*uc-skS z%_?jg-?STMXNM}NZoA8D{JVav6fCypsr|dYF&ipB5bcSZ~5HwvSAQFnV%nx@w5Y*0#siC_u!^=@Z zZ}SbFRy028>A##|eay@o+6_`v-uoc(S^V5-{kvuNleh;~@(!2^o?Z%gNwwjB&)q#s zAj2lHtr%nA*zI1H5|A4TNG#~0F3e(z4UbqkIt2#>DJob28@O; zApfC0qNMfLLu!GQ;Ol`{B9f7>dT!jJPms1~RmD>#tSgs2^kS5@foj1W$plgwW~HEg zQ0Tw3MuhXN%_H~Lb43nSm=fqfLWB{@>xe*uEExgb3j93_I~^akvhO~m3m(c~McDWz&lycr=)HjwpPyQMxblJg-{NUfFHDQ26mrO?%+_HZkRO@6M9+?NDp zZ;J|P*H6HSH=E=Q#z z@&e#zNp!cXR>Ml-N$9zFr1YMKN#gTiulhbtd6`#wzb|r9a5d(MWwab;kV$Nhd*nVn zW>G_()bFpRGecYT5=q2O9Muo$7pKPr=lx(#wg#P0l~~1^i|}{<9l_GP1!vYiPvwNB ze+x8Z=yca^wvL_KY)<)LK^$0)s}LEM9_mwZj3guXrfK@eP^z=BxL(bPZL({Z-mPXg zAoVCV-fVsbOIgcBqt1XM2s8|GA(@(^IS%-a{R)PGqS1&X7v{L#Z_5dU$IOy+7;Qb+ z6Ct;T)-6*me&6DPeCJ_zmZBoGBf@2F_NqL}2uZ0d+j@)~ThtAY zzF3d>w(>-_adLD(Wwp_L$%LkB&CB+ca3?9`Rc0#@Ut=8}U4syFnkPb^iV&0PJnjk- zan_yIc1%*RsFqkt>=$})&F`SCvsd7^VI0$G9zBPZ-SzM#YC&BOv9O0j+gN{ng1e5e zKbMZ=qI(W)xFs57>QZ`wTW4|2TW{xtp7VUZb@8LH6rx!*9&ODN-15RKkF;vODCH+J zmcqpYBR)pr659AC!&K)eKVIvAKo#>v&%e@O(>MY)$ z_p3ISRC3lBEn$bvd(-sF9UO`gETkv3s!9eCHR#H$YNrL+=~*ihZz#TSYWz*dESc-3 zCeJ@*!U}x9_mzriC`H`^jCWYnOw4L=1Ed{w5L8me_E5V>U=q@y<9X z%~ZHkQS2wXZW)MoyjCpGD*o2p7&m_=(6w_ruy<{yZnC-yYA_wleqs}4?NX~La(jsS ze?{Sol#m+mkEIq&&zm2AN->=WZdNMVoC%a#NmG6JIWesfpYP|#$<3^rJ1aEcpZED^jh5k` zMF}SZYYQU*TQh5uf5MtdP9`?0e-HF`Mg2cs#LWE9G0Y8q{p04M00;mC0YU&_fCxYo zAO?^CNCRX5vH&@NJU|hk1W*R30@MKN00V#_zzARrFaekXOf3Lr0CRx3yS=%IEx-a` z1+WI#0Biwv06SX~fIYzeALp30iK)}SAN~60qXK>b9088j29D+cCxDZy9l#mj0&oSm z0o*D7{oVgc@l6Q+mh}ERZNm>8+R2Kk}nkpj#?yu zh&X-GJ=6N=wY}{)mHVt~#WT}U`&i?8qG#T1oC?mN>4%DwUvsg6vq1!;;fyIn2*d_~ zj>gkn#e{JJ?GQ8$tkX{fWNTnx>(`XY;ui|jM@uk3O)x+jCV~*>9OTX+RAr+LEZs2a ziwXr&gxfcbC`Iry58kO6n2X@5?#CLaE~lnoUyUvfkcFqG-?SdNHV~&idR-$I#*qK; z6daHMjSeuHz7^!p$a?^xNm(*6|4lCaDBM$S64%Nq7$KOxpg1EaVg!L$SvNY+kCuVG z1$*HK5Mt>sU-8f9LulKlCoKNZ-kNVK@$W=%PX3GTFFXH2(8(#(3s`yAAO6|--#V5+ zUn4TVXTN+qC^|td2~+0etvu=d&T|omM1c38z%2x{X>EX1`90BZwjJnyK5RpWm4DLq zQC61})fA4u&8&ZLm4XHF>o|Aoe{a31-EL2QW+F8@gt&o3wX?UiwIKzEZTsd(e^;h* zFU%qR@F!aG*8>7_asl@+AbbK5_yEGU1^NLE;tA5118E=&Usg!H2MNT0#OIe>$h4#f zP~u1IqkLC8!AAzSAODsL2+Ml26Fgx4CMC25Dt)rs1GYc=Akzgpp4c9O*jf0L0RfWz z^o6QN$m-iB`LWaVA`|A5@{P<#WOiyEyVCkC+}7R(l$FPaXz=4J8nU6`EgDjQdK7;c zQskTuao7AFaCb{Q3S$cT)rd*-bnG6~wuv8B*Z2*JbO!HRMj-sxq6T0Y;X}*^e+NaP zn)W3qsGYzM!^l0y5Bp>P_bIF^Ujo6w{a7RdX6|qPppfP5m);3#;{B7;!D#@j{_(Du zH3|ZNk3TMV;`*Di$;r_LTuA5pON-wN+ZUA zd{!gQq$(4Ih4*37#W0kHlyDtAwt}<1Y7u)&*%)d6GXGk^b3>s`*!9IyjsgdQgVc0# z`?|e%YvRtfn4Wt=@p&zHRy!DHrg>>GHfSV0#*&~wf$4J*UeJGH8U+aF(W zBsrU2{l`Q6iNH9gs7TxnCuHP5&V<%;=lfqkX2J6 zX)~+hBm(xWEvX7GzCV5?jqh<$JLHUQfVg^j{=G<)&*ni+nIbX=_7YrHyrEb2Ty{C^ zejv%zQ=&8s&YDg9RaiH54GW*AXBx$$%(xKNs&#yp6Axum*kx*od;vdY=Cc5=XYYW= zk>XfzQu#haj+Q#8epDgGci_=Zu%W$~3D1}HE9;u4WFh5oC(Ud`G62m~)Dq1l55 z8{13Sx5hX5=hv&)wfviPF1f%Y)47GsOzfv#!UqXkRvhjy_7DTj*>e%jttdTJR4zr2xgnEe8c_=Trch zDr1cJ3RrCF!uYQQHGJiwcg&OZw(1WHpw-vsW5Bugpk~-eT%z=&D6p3Ytm-`%mBlL? zcHYF~St46ukz6f(9y!aSpXa#JS%$kZEeg|lk}E;0-4Wc9)^W5Rc(t&;^BX4Ee2CT_ zkxl_(x(8{FB*Pw)&_bJYANE_Uuq4Jcp-MBOVV2Tz)1vmF>0eAJI!Kl$=anOA2|`#r@@2v9xYkxM-Frt!B?3j^L&b@?#8M_>QPoI82s~`{0UM z7?P+kYstKZeGIe9(y6T&jrNK!Tk)!fH7d6~!?a6^D8xl{3@e-F+u{5|G&33w%NU#R zm!AhgN0nt(uJ1_mMs~L38SiltABk7QRo5X+{P$7#`}kn25N@;EPQ;X^7bqV$?rO=E zM?PO6ATE}Diw+zV0VGf5T{4rYaSv2oLRF`g$8jegdm8Se?y6!FU-6VvD?X|?RW&Q2 zZVeme{6w=6C4QWpv=uc3e0S=eDL+eE3JWz0lL0P)ALC9j&$4(n;>m@0b%Umr!aptA28utEP zQA>3V?KsAvd8*_xdOo>GHFNpG)jCR7iXB@{GG>n~G#&XcCO}n&=xu1pw*pXy4ayY4BTOoQ^pIUB}IrFQ~@+XB1Mrf0p zM3_l)*p^H&vCsre56|8HXCD@#95o!H=i2;J4Q!#)a_T9Br<33)p2s6cnOl-yn2!Rm zXKBNmI};iSk#fRSjw*@8$3qCaq@B0)Hk~VngJ4)F943mrr%7DI9lQs<=Bi{B1WAhN zSlyPUI*6vuELJyffpsnwi+g)T<2t42>5J2qyzLn%jv6i5rkCHEHdiC*B|%a4eNe+@ zy}ot`992d62!(5joGj8}s0?@c>*bq}pO4=g*`o$pyZKas(^jp<{v|10)knntJHS|hM{wM_YB z)znJ?ToKPLjoO#toMDk{yO56XUP>qan z5rb=D6Wyrr&@{!zuJ;VYZ33;i{?5Qb%_Ya5g!f zc{!Keww$+wZA;`6{@W6%_@y{O?~F5D0N#w}-dMBa&nFbc{0GYvEpTS09TT>Tv=+N8 zvP}-T*ADinM{Y$PBBi3MuQMEiC$6nWm7%_jIakEzY5BPLB5i|3oPUtLlTjkyT4XHH z`TSQI6qMh*!O+)@Q5)ogaqy|zW4vD8AIPiLSGbaUHkQ=w+Gtp~mZ;^pC77G5XFwdN zr%4ch`SWYUO7?Wq~PtML+BJGXvRbiJ9C6#X0FuMSMflr-C=qN<6c80e|6(Wtd`N~d zbq;xr0Zt@~){w_T%zA)bbkXh6Zq60De`3xHiPXo?G$95Y6263NpQ6)Lc)R`Fe$ena zVA>fZeQEdHPE7?ul#G|70)S~cU*vW~1LN!UQlNHMsU+gE)do%8CGQseJJrp@p@lBS zH~7;l^gJIZ9n*(KPfz3~J%&0^wd0aJVK1GqaeaJmsz$^IH%5;HIs+&4NZ#B}^T7dU z?zOrk4CKs7V|GGL*wcJ7-V+@rCh<0sUiQ=InAke{iq{~tbMMvEnN)%N^4uWLiu8zTKA4U-sX5rC9 zeC@1zd98wRE3sRGEEZH&8i(SyE`Jhoe=PSWaU<3S7|1;u_(Zj-K_g#BG<4TMsI+k@XRZScJ#U8S%RCHs|R6z`7^ao2{7oO$sUeM&v zmq2X~Au^xRVuLo}`0|=xdJ_L}m5IN(bJ_)l(LhSzH*tOP>D2I~0Uhbr4(M zB#<5@8WqvGlIN}NSsz7jN_2!dahYy>StA`hs-1I-$OAAAWm6MO@l<_TeIx&77Zyo^eX+mw8^Zi75vzmOca2Jf;$;-}XWv8oRIuSo!^0s0zwmMZC8-cui9V zCAv%2Qv+f_*O{`piMYXF-*#`J4r` z(W=%yWU<9qkAPK9A%i;OZwYHE*A=71+#>S^K83cBS_x0_1+pEFnN7;;+QfrVdSh`B zkRB->%lrrr1%K%Ar{C+>YjJrbz^0aNp;#1O;$>d8xeO^aMz-8P%6kgO9DDeQbu-SQ zP%+5Ry-y>xS&JDjpK!$<|8k#TOKHZ;dy{hNY}UdfsOC-cB^5N~3gcYzZj;)#;^*hK zR&5n{)D_MaZ8l>lxP=N0u*iSktuQ}trD6Kq$iQ!Ymwc0!=zI8$pu~ykpv3{RR(%4b zZyMnsPyMqz#VV~jD}CX%z^W54ZlW?91C+4M@69uwh}eWVM~11P^RwDFOF$glVm2O@ zYZF63V+~o5_wz`2HZ!ndwmvEf2~|Dk#tjQ=s`L$3(~o>3&sPlf7Pk)yERr%J;5I{i4OB1NK`Sd*TaV?gxaz8Rf5JvBJfGuD_;T zp5x~n^mfPJ;%$eI%oaf|wNw?J7r7>!my}ko&8w>ien)HwHh216n`ytg(VcSHm49_n z&7a+rm9nF@vz;c_Bwmp8*=LjPNWhxHEGKneT4c1>--wn5G^yt#uC+Bp4RlF}IJGh= z=j;b~8vGiKFE4($f0o5;o&nd;5-u=lH1~vq3XoNbD*A{u{iSH!--KdMQb-oKaaS zQ$%Z_T%^c_H)T~77umbCBXZxzG*193iF0MtU>ucU$D|Av)tz6oA8sBmizK+H7XeDQ zH1HAT$MX>aEAvuAV0;=1WY(L?dTe-(IAT}Om$~MaB`JbAp~@oH)1Q=q2z4~>xN6#G z12|KFu=gSd;wj-#*B%RcegYG(IGM+$K_~XH1>Vi{hL3N&@nRI+pmA5imB#CZT;GNM z*bj0uip{XAlR&n5=X4y6_q$HAAYNlJ^1kY#AzGWh0to`u;FQDv{@t=`UzE%t>UWA1dP(y;732I$MAstV zv;Jb~j`{#A^;xKoozE(3tE%P4K@s9g^f;R*hn5ggkt^StL5zSxwuvz+M^t3 zKO2=)rLs~lTbgkPNs$L`Fsy!-orn-bn?~+x zDJgDKwBYr{#rR!kQThP2Y;q@f4es5MPQrIeClh+iZHLP{l$TIhbOwroA3F!#g*lPZ z$gazCR2(zdgZQLU7imL_36rMgjQDEH9KCFWh(eE2efJ=^LSEyoqD(*2ExLA79XGUM zREes9h!%`vj|?kVryf;L zLtpBwv~E1w&oHEkhS)qnBEdVsdTGot^LL4?QW2xyLcdZ>#VVoNuBJ5hdgbem@|KFi z#ycu6?SNNw8wYH3_(^EcG$(iJvCo*MV`85qY^!j*9Uo(|Fy+9zE;%K(1Uf>UZDRXl zTiD{?u%5~K2A_;z>y`q%_5BeqwSt_p-x%%1lE&!)G*|F;qYzGWPntH9)W!irxa5i` zX`F$DOm=aGHL4T^wyqIMYZO+^QC&h|^UuU@#=7s6ZlyCZb;vXEHn@6{6&B1ijBBg3 z2z>5vq2!LvDGqx~=949wpinTf2D26j1&Jri++^8;ickS3J}5!ZhQ-`){v7atVv8#dyQ3Y;Eu%6VbKcFS8;4VW=etqye z1U1>Xr6Uy9>NAx+ulCUMbs7--CIAlm06&jdtPLJ`^a(L&t}mqjsV~=?w12mjFF?oY zjJix)D)x%auCC7|e)keXK<`;%KyS3(HrI&HMpT}pXcH#F9oK($$s7D}#o9e@D4n|b zVu4A!T?bDFCt>6Hol3K;{*fMof{{qI+8+!Hd_f#4ASpqx4ZT!&MaiRRLT+qd2^mqX z3EyxL8L;<2Sr&||(+A5NIJVcro*af`01{O*-MLz&e3A&`sZ)!)GGl-{4=$n3ht|S= zPpW;b{d7`i7)>H0D4S;P>5T_dV)jyC<1?RPo)E+K%eY9-H*+5>1bs&nyuI9}%C0pi z_<~fCt|4YRr_w7+&nHkuHygNZ9(`DS<5$a0GegMuQvdw1Tv~>M8NkomH4*HGO1Fy3 zw$z`Uw~e-jm6hQNsi0>JWiyRDLoaHfj4dF$aBtq}@fQ;0CGk~m?<{?{&gp)m!Lgw3 z%U0EC`lZp+;j!4`*k%+a3eCHLKM~R5(iN2_bsk~3+SFaT$-(irZ3fpaG+YHU2vNR09g4ZB`=hsjYA}x{`%dk63a9tU7G)7QZ z)bITG#hPo^hFMlzW(fQ+VK=Pz_11$AuYD3>vAI$O1o3ieOn;ie2S9EeZ`IIOK-Kb=G=KIaHTb~z*4RWpDLbbA(TJN6pulack$3I>=56Yl z=dgE-u^;~89)Tk#8(vPd`qBv;$b6@d=9^I&jNkUN8tLnoPoPM50`j^6H;jKrVLz+1 zo{}~3Ay+0mvdfPB9cv|;F=xZXo47`Y)qwcw4GjZJ?+U1E;7p0)8O46@+>m#MMUG|o zIxU)d85nG7rhygiU??F;u(lr;9xX}{&^RVER1C>kh`L}^<*sK%WQCUOM>(SBU@c5V zdI@$u?M^GX3&jHV%tZ`6j1+uE`DXzupLnV4$o6sJhU)(4TB+T$%DR`EqL@X}YWw#v zP^J4zAo}aV)MkW98Dz3RoukCcFSZfmbVPqf;@sZKsrl*ybUw`}^W3R36X9Pjq8*4@ z$6^&DFa@L;a`@=1FO^_A)uQwIV6Z3gTL`L?jOQgX;9Q6&+DeTdcjs>xP8t$vW3~LZ zh&PJX2lH72X}j#)Y`PxK8dnb{pWOwJb^baar{!CwG>sII0PE==4R%wCF|DN77e*+~ zFSEg1orO%#Jfi&dewbVtmc*A7*A*xo;sKIAIjJbDUr)c6(y+wh+{vQ>FumBl6J`|) zXfaCTqS12jA;b|uNd6lwg`#dL0u8PE_p7C)*~LBRP=u57a`<|(iv_Y8%%xqOnK|XF z?2)m|0j4ntlHK9a{dkt+S%9T!R6GBW=ElqdHE%1mazU7On+^>^P7FNoQ}Yt-wwl#p zsdaLC@fj^|;*qOOICRHe-otMU!-w?v7cr;FfTU5zB=Q$(%x10qa8WOF@DnMBR8&vk zirKd_RpxB;cm?>AyXqqQ;6A+S4bf^-tp!?#*s?NuCj#+&-drv{gx{ebi*pKqMkJ%n zf`@9_1t>QG7}caevifiCAL#snR4IE`LN-cJ9PQ zewTEz)~m+h3>5GERI)H7mg3t&iDgl!goUnM0ja$by-fcNgb_uE*E1L9kiHOmEQWt4 z4eRS|^>R{T&ai@5@YK`g1#w1cme&D5>e2?LuBJZ1M?ylx7uJGdo>WXID*vc(dzMz< zjl9c95KO*cVb~8#Wr60bNYPq%s~5{sA=EE7I(~(_9Ybz?kJ!{D4K9Xr-0Uj4am`t$ z$D1DsMzKwXpuoPt4y3uDEftI;=eY;+-?ntuo#`7j4YALJqsI+H%{9L*W$t=uo! zJ6{2U-y?vdF_LFXBcnV_H~Ed~sScT&L6zHqqxPvpS8fpQ14|?J8+Nx3>{aL5NkZeV z9c6`3i#H-y3(LM0O+B2+03MJLM2bq&Z=*;3oKc4(a=Mq>%ByY&SwVtNb!o2E+v7qs zjb*Pfw9T9+jyE%!*tI?KIaW8TWJvOOXd+#`!-b+&j!+xV;K|`a&dvDVVPBya+&8UUrVZV!{8ef+)pAJ!_(&#Q_c&q~F9I z@-O4PnxMW|@ScfSNeX%n>IzBWGfvBdu4^qcipC_*n&J`%FQ{4}bTv9{83q%b7Q1dTLA@}_T z(LdZXIzBWq5c)f2FA$d}tD3f28@OrD$rsfDRQOV0dWl~N!mpsb5_J@>0GPQMv@Fnn zi9ij3%&#mPm;bUBl@5p{4rcU~XEX~cI2l#n7S0JQ&7YV$78G>uY9cWSjjbc(#UmSoqH1>_4^i4~5Xlhn!Z26taZ5;b0 zx3sXeHogCS*#8t`TSH*xN3?=-aB;I;yq4!%MHw(zy?OD?MSX5*X$JSxxvmKmSp5r1 zqf=a?GjLL+O2=On2u6tu{m-^TT;Qv3rl0ltHd@-EGbyP_^2zsChHt5|bTzIv3pdU; z>SyJXovF9M=oY(HC+LGln!36=VQ^gU_lMbwUNs4>pT46N#Hhp00Z1ArSEffE|1?+- zJFspQkQIbu92d|5{O!c#0gy{D4KRPpU;hxWi|FgQ(Ju#(G?8!Ue;h-mx4z+-V0|=? zf>l7Kr|5%T|rs}O7H0H0q(f8O~*4T8_-U{9({k-8nL0;Xh=A?5*-uao!``q-tWz06;m@I$Htu$*i692(@ zg4o?{@$?LkH9tJXFEknJ5CP>V4GevyYC^{H45K!d=Xtxv_Gk!bZ*wkUyks5}JS$rr zTcDrI9v|QsQ03DnAs?ug{qedMMA-ZXkn7L2v9*CpbV$mB`LUIYHajwwv(M=C!rH3O zVrOS&f`v*eG$VkegORzo_GGV?JVnDjwk3?4dqq#3mTf#vx+)mY&ekBXvl+KP@w1H) zn=#{B=*G*6MwDas-DW+n(*2~8%^eRZG~(SU>dy(>hTC-_^dc_S$4Z}s>v#0^3DVM; zCe8@!hFxjD3Ymk8VQQ`huB@ldZo8=j-T=ABVC6=5skK&)HgpUWIa{(yor>LvuT7q|9YroCMQ^(s#oa3}-Htory(;QjC`csaE2I!GUS2-9 zk%|*J(1ArGmlEQJB^TdLk>iSHRw~PToxq3n-Pf2`S(6-d>yU~jqBxxwIj5#g0&SXU zX48^iTKitL(;0~8L|~JqOR}|MQ#jc*E`gR?N{JMMs;tYD>jEYDtlj;#0+s#jLyqjV{#$nemWcxe12+0F4oH` zW=GH|K2kMQ*EkmLYnD@I3X>W+B*>a+x-CqxI4saSrrmK&?q6SP{AOz09Whobt1BB1 zk{kvn?&-u06n#)7RW-IQFFWlBcDlyfSH_IK29p$gFC;f?lPaVD zne`}Rb@C2)J*{o`MC<~8%;xcVfFl&-3gq_}v{^sSv~rvHOnjP4v;s*ks^WW-Bhr+B znR~8{{fxnyqn?_)tpj3{?66!E@yf&`Unls`-BnmXDZ-G5O#qr?{pBg5qw9jf;pwey z#Y?>GFxXK_0rT-89WQ&oxJJ+IpPj1?AARO^tOj%KG~HkxW0LV&jQg-EQ7aE3^w_!Pp_iVI2<-Jakx>Uyp^k z(L!o3F0>D>(TOuPh(hHb|F~2O2`XGK=y~%wcdJeX1U(;hclYL zwPG{a$vdsJ`ptZV-ki#saKJgouMVl2FI{7GUO~W=@1ppUUL#8pxF`5LmTR9iaFB_l*ui*j%>R_Alb{p*&W75Q(KUuJQL+U)(7Y3ui@~92k!-Z z?)?2F;|prtMiRL20^R(>R`J%X zEq0H{E%>U7&!`*PK3op7%QEtPn-h08XDMO9+w$ZgJ9|`Wk26q{p~|&uPMV0rYOrx?El+NLBH5 zvymh?Wki9fb_SJ}j(Q`S{n$DwbOAbIa_o(o&xc9=oP#ELvYe+4I8vN4e%f!9^UCxm zQ&7#4PI2#Y!Na%k6~E3B>)}h)dlv)?9$7+QSmS?}$%&Dm*fbskBERsEV&*APxI}zrIsIKAx}a@XP(a7+>GzMqmOiiteb8R2BvEr1Nv# z>*y94n)wMtNbpLFlN_#)U*JnmxSDZnN+Yyw+!?vGXYA6?Lm8vK(J;QdCx>D`F>C!t zf}TTRQP`PsnP9C$v|H|8)iX4pC7^@3_Rn6jj4LOUw~`O$r{t)?JQhd+3eUDgxyq(Z z0Xb2?=JVS|XE%`lmFf4ys|U)kP znEx0Pr0Y-twO8q0@_o5KlCOy)D1#+!!6ZNC&|zGWw7~^I8MY<_`yh;E>fXtj=X8*S)*u8j*c{hak30Laamdp+{Nd>>6;>A6$1sVG5!&%=hD{HDBHzpz}HSi zsA0!c^kw5#_oN%&%PD{iYir$YGX5r$0UVcxgx>E{JDHpU$bU!4Q0~xK7s?$rk80NJ zZQ3Y*oTdr@!Rer%u?E9r^^NO4@cf?PI&3rF@RN%tk=feXiapUvjC`hW+ zuAWr`P4eM*+))1Bq1Xo;PB5Tnc42AiCDy5Y6>KKTtj%pQQJXB zTZnA<8#a|Fka z-*h~tPxr-~F~VK954F=U`x}tM+WLlJ+nEArT_n;}9IIohSe7TaM#b%@2^q_5{iwzD zGn;vkM2m^S_PDSZ!^OXEmoj?q!r^3QWjqcSbd8&!Le#h?78qU=90XC<^mz1CWb`$I zIYYgPbO+u#nabE6dH*ccYf`EZ)#Nnna$iF~BDX}S2+b&MQIorwO;Hj7IoxRFuLSWsT7%yJXYC9P3F>KN+7llvM|o0 zYqI13gVtozK|+{J3fg;~*{fbk5&txHvSd&>E@#$hEBC{h`5=MyQuM>adHIJxYI03S zUb&R3&yH*MOhY(Kl+xSLg(JN?K``>e9(vJfgb40B8Ayj6>mzFfN{bye)3H)R^A*&# zM+~#><~h~ceau(LBXb)!q-dw(iiTy#(jjOjrsVpV>4N&uBVJ@p^Cgv!YJ4+wHRzp{?FKwM$8p8%n=DpTZi*j+|RoAj|eOE7jg# zE6uSa3+zZ2KdgdHeVc^-j=#dN_?jR#=*|k}9Sw9)V-WPeClOFyRq_PmH;(rL z>AIzTaH$9{JySZBAuoXo={-6Ww@)6k+EC0m)gABi1RduM>fYVQQ<-qCywotPHidP= zV=&wej{Oa)026%>6SXPfSF&+KUE>;EaHE7}F!;WU2LZ#-=?~8FBOX6g7|Y65q)8{F z!Vm;jIy3KfIjw7JCw!~aS$5?BNNv9EZz$C!&I`fZ@0LCdJUJ$}w*gF{PogKumC@}H0xbGq`NwXS)*qj<`UlW~}aQh57j2-o-L6>5Mo3~;` z2d}EFx6fuL)F;Ef%Kau&xpt&&IWGUl&5{visn9t(O~n6dL-YYb^EfgP(2R|CN4 z{dF;~Xxv5W(!-949KrfYV?<6n(+lAd^*rR{wWI;(gsZh1Yg&;~%5T8FwgB3P4)w?y zWqI`Bvjzn{6)!Nwxmu3vowBxo-kt z=V$k9iVBK>y0Z=36@G|6uH$VnvDC1>0rYwr$(CZQHij zUbb!9w(Y%a+q(Pj)7|M#PHws$Dzhr}RP|Cb8Q&N#40ADZZ3Y=&eh=gEJAP{?QitH~ zPMywOyYMBnY-Qg~4E%BA{N@+dXuD%+5fYmeo~RLb<2Sv7^o%$NHfkfv)n0N>Fa^wV z$PJ!!@$Sruh2}(X!#T|r5edBx|0eextBV7=-f1Z@piO?XK)Mfodr0y-WW!z~R}=kV zlRj}48tGjNU-MT7#zmSrG9?=N&0tDIKd2n|AiOf)ABZ0ABP-52)7IVk#w7?@+-ZV! zFx8*Ch-Y3p^!pyjl8O!!#b0amF%w-N-zrXND*y&Rvzyk&8xo8`vQrJpo+IIMFWuFB zIdBJ}v2686RdGcZz}oz2_SG(@Mb>fB&TCjFTlvJo3+N)%4F01MJI5E6T;EVWq-K>L?p}E6lJkYXi?%pJ%oga(B9UXXtc4bpEeE{>JHIF2C%}1mP z06g!S5FtYKy>zJ=j9R`PaM-OUi=%2Cw<=q{Q7V&RLb-5PPI!%_Kwg|SH-)u8X@*jc zcXioWXNzLMqj!Jx1@oc3Es)_v;rj**&X#E4(m7z?ZNs*cbN$r;hT35Rs)4y~cC2ye z;C}RDLa1GhBDZF%#AaI)GzIt9AY?$s}seX%4q%~+*iwsj4=eO9n_7CJ7T*4b_R|&$!=eLx< z@kOy4Pn7=A1Ic7yXtj;DZB@7)n&VS%Ozn5i06N@BN7@JT>*&|F0xrk#Qu3s7GuFO= zBbQMeG+^GeHRh|W^Nw4$Wf&g-IomKXvGZFzd&_CjEQ7w_y<=vtY%xULr<=8rNTuA| zI!{$;eH!1%u(9Ba3Q;cr${Eq?=WfKBwjmwvuqQgkcscLWx^v{!AIeE^;u=|c{bSKc zS5rv5Gd6{YuXMK>Ti5>dnKD0O&$r@;V?Cou(u+<|C?Z3L3yZm5*>e*deldpH$^?tB zh#4h%69T5@O~R>}w~>OeSykq{unp`o0)kgDgI4XSy)rwbSh$ko_tJt=Ho?MD=$}Qr z;rES}%h*o-d)_e^UU4>!XQysZr;C7}_ZDP%3T=G1=6XK@DVlDwSC_QwM^kY5xD>z_ zg^Yj?xKz1F0Y4qS5x_TU(l6YT?e2J@@R~08$3W=m+uqi2YnGv+w$1n|DQAlROQ=-9 zS~robyt!**p04ZdNj5@Rx(W4hx-e_y5qoC|R~G;7K!!nPWGim~(vlYV3OZ2KP@{q^ zl+pn`DYZo10pAj%_6d7epbR}CD40fAi-{s_rq!%?fA?fWUh~6}vvrsDd$>h&C{j9W z1)go1=f!&s(nHVbyqFnPVsV(7=4hY=0*il%j(Ssl0>u1wDq`@w2Si; zY%&mp^e6%r;QlFGJrbuw3LirYwMUM|5fvU$O-{1%^LS5K{3#ITn>zRf9byg?Jh+Sp zvZ&g7G|J8;m+zv7Y1_LCW$apdXoE1X22l9D>U3enIq@eIH6wNtnYE*4y$d64>ZDGs z#QQEVZ^2d0dRHGRE*!;wKHHJF_Oeh@&rG>**po(~G8A@wmXJSmBU$}-#tEK_*HtP# z@?(~jYFAM*mLMcoJxO5G=M1=yS#@b0_ORHPnBh4-htQ3?q<|H%u~qqf0D+`aZWX$y z5&786!Bm@W523)}L++r7M^^pX8EgQOh$TxTdniFijn)33ml$94F=SB9I8Z+IAl;Wz zesr^vF3r3_Dzd7Ya<+cU)N6+Ig*y0QQe^1GGJk`Qh~|$bR~7=~Y=Yd2p#|Oh7bJg| z_Bcd~dUy-L0a`v|Ja^{n7+*<|wAu@oW2wAq^oor13&nt4dLp8Z3yaf6`r8v&)-HEI z^}S^qFyMX!awI=yZsB*)(&5%=A>`P_6tA%bg{%$TXySmlKH_c4q(`8kO8Y)zOv6!9Yv8xs&)dM?iC*7V+0rM;vq?aAh7oNLA>`?nL*;X(2s^HPRQ23+_F zCqjO;$A8A=?F}&R@ zHi&YUaAL|>y$v&5?AaBW{Ok{x+1&@=-<C(dM?iP+!Ct1ta1pF~WUBep=qb=H78^?jg?A-ZHMuab*rCu_-~mNd7=X|*4Gnk-8Je;)xCo{4b(Tp zsj#Xn^b=3KmTx69j%R>P6F35_}@s{|{; zmoBAM`_v3yVZ|8joNIdLx^e&BkzY7DW`Nmo6H!)Ze5Z?+CTT15+nSwp)+rciV8*GR zKR=y#rV`r6zq=uV8T&xHz#*%^4^6(x^V9-X$nymLNB36NRc4}u{vdlI>}0!padz4D z*?Dl=X|=x9XT3WO31OacGK4m2%?cw~ido#l8PmP#pgDb3Ws;tB)3W%vD&R0f;K@Pb z@{z6l_o$||XBGP;AXm`O3ZL&zF#^z2+WjwFoBST`oHSgbUCC1PM_DmK4} zS*-(tZS2M2CIJPAsoMx80o1?oZcSn6y4iA}*I|Q(-=_^6jS31G9>f9a@nXC+QbS*V z3LVq-8>_zQI(uxaQzEL@?x zKFKS|C-DMh6GO3X9TCxq6dG19vH0*cXGaeRkHdixx^A1u{l2h$6BrrKA8L%ajGtA- zL;{uRv~Sg-xP`K9aCwMYg@6AwBz$|S?X)c z3iznWykq*G+Q_!}-JoD-ReSuGRVG8hU{5Comd4v{F>NS_)gwqDKd6jH%aor#1l@&f zEYfOYCNP)J@j}TE*JTD)km-LKs3a|1MdS*l7MgYV`66eik3Es>kL++Z6LYl&hfqt7eOu`Q1H-79* z&CPrBD1Ev5=VMT$_ni>PdJr)+Pj5hTGBWZ#6lw<6{oycM5>Fx6Zec#-wDF>_hNrVg z{&87c1y@f$4tQX}VA0bWp!PeB5A^7vH@Y@Nk}S{fcSPb693f~Qw7OqGX3G;#WEdlB zuOGnLDZSFAO4U2dF^e-``UXM^SykE$c5Yu^Q!2y$%W;;wJI;S4l21HCjSZ53Pmmqs2_cfP46I@W6AtTq&tRZ442 z$P8O$sXyx0IkTJ;Q*r&${O`>KVvToqpMas9>ZYM>9*@PjZWvtWQn!C;a-y`>r0s|T z1~|@}=tm`jVif9SdSn4u8kinzTGViUh`R);Tsj(w?^UD8wT386FLYM5s1G zIM6wW?JlAo*S|!2@q-;@By4v$VDrgPr|H9H3uR1*eQ&~j^0Jn&03|%S&t?gdhX4)i zlSJ@Nb%Hy8MXlnm$iL0?D6Oi}`T;Tk|KM0Aja2)M$bss)9dcd+gY2n{Z#6fdKq zUR+f|-SmdXB6{5TnokWux0{e@CTM};yoYQI^xx&VzhqYV@M}B$Y*>=uzk+1l1ieJG zv?GXU9|)kjI!$9nvj9;d%fMo1IastETv^ixw!579?x^1$$qQBBWmbxVUg2yZ^s{S|Z(*LXi|39%y%9^60l5+pp zC8d9i&VQ$~_?K+`pEe85e{tLYUv!E2|H)>-@$a$!O)fDr{@*eS;r~`+q53}r7Di5n z#@41T|3gjjKiB^yr!c1fFSN+=7kpcwz9qW{Zu@$dax+PIiH5&Y*nxR{EV8r%P?oAL2MIlDNS8rnkr8xQ(Vh)t)l z6?%ZQ9mM|c_P-<8`|t*VrJWljNZY|3>EA8L8-$}L?xxrHjemxV`|vKc31!tPbXd-Y zM5>c2cT1mpqbJ;7y3DWN6M0aD2y_~dc{^)(quDUk`d0z2a)i_>VyL&Fdd3N7pn zOwRWv01&`|04e@N*??4Lvu1L3W~DH9)6)RT)X3-o4H=;+xIBmaUd7kb*MQl-Y+0RL zU$+Ta8A;3%C;?C;iC6%M7FPD)Pax@;8AHre>%mqTfyrOLgcrYLX%3)3sDEsJCE+s{ zex0pMtU;f?@|?Z3!PU{3$pgB3Dl(F`e_dBtKHFG4nU$&4w|>2;u8lyNnGjo>05Sp7 ze{36_QtKZWm{l8{7#l#+u>o^teoWb$n7{jo1dKn^K*VHSVMR3|H~noN^~I&c)ZFN- za^Zd@KjLot(%*9gn;aV-0M3{g85kLZaRm8)KeK**DM{_jjqI&V!8_ruZ~%zO$%*AX z=6e7Tx%;y)4NT3gP5>Dm0nSZL>YLmFLjeSc??KbIxCeflWZ>KYithMJ{gJ@~6pwN^ z0RI%;4ucw?c$3=!6utRJBtiC5+{;Y^h)uW~0WwJSAX5h@e&h(OnC?QV=-&KW9RFvr z|8If%E3A`$A$1EO|Ibj><*;5=0UE&Tl0%>w!?(=9lkDr`X^iP zb#ij!WE&L4;7cwa5rZ2uV?DhCU}jo(=eqj0;rG+|J`Y$yoa`24(bDMHUKKzDX>Bq6Tt;H98Y#Jmp?A$*dbvdPi7s2A_DGgjAd*hSrmrz`NKKzcK zksu+T8knW=n;LAn>76^sX!>{1AFgJ{^e6bG)?XdOwD}EMu#$Gy8=z)jacN+2`i34p ze&&K6#MST{J!sYN5j|)W=nGn~=u4WD*#hr2V?(gOP0j80x+#ciqhk~6_c2rRt7I<^ z?Ru9r$Z7Kz^0NBY#pP!^7z;n9J3%?Ux!L`Cmv5PB#Ofz-b%XO`V{Cj;zWStkg_>xekhNd&lhufhubn0WPfOOF~1*H~SVfk13bn5D9 z*(8nFfaI!JR69$T=1;WEj+GbM+zE;3VVsh#0q+1OpDgn#F{j~X{7 z0UC=^cRkjEdb~fT&z!lLKr)3-APar?{=r-A=Qm;r)X&>NIctd*KxBj*7G3`zj`_B6Z>Q8z9^CF|bWh7xP-YDj$ zP@N2UL7cf`r^~G3%MHMw$M9$**VkoSoHIW`sJ&4l<3Bs-N)sDRTuo;jw1i1{&!QOb z`!t;V=qW_*ZlY1k7zRp$S~Fz|?&1-9%Hpodu}Y$5C6NwkZR;BTBjW7Ye`YXA0TnQ> zW6hn!^^_H>wJ)uTDS9RSos}aQ3_k@NEg?%2kz*&Q{=zK{Onj zF^cjSh=juQ3;(%LHvd-1dUg|~wBKtKY!pF?w!CuEo$$thyj5|V+kYY>Bt~;C`TEST zYIr+gVXN+hLn)FeBr1in~O0C|ND1KI*-g2`fEF7`W`2g79A4@{>`a!sfaf9RrZ~bj;^Q3flO^_KCnlgdc1* z(hCDLV^hnbS(i1LN^4|{Pp3AJTP4O!1X!ij{|9c<@*TWNt@Tb}bjHtp)9Yf#FK2E} z{UnCxQe;`l*^$&YT|Z78;8=5()2u4hE_61e2&&KPP;C>Si0rV-P@L7fgBMv)d<&#} zm{PqA{AG9B7gJ!h9`A9@K-^hYw823 zv0M#5a#(pmT@vtbqtBx}NY)O*C8VnX;ryi+KHNbC0AR!I1X?Jc=Cm+wxgiX1j&`yR zrvfoqcS_vRBkgTlC$ED-Gp9^Fj&q%NZb2L$z7|T~(_~tk_QK1f-Gc_&JH4RjFkzv7 zm2iYmm?$>BL7qi1VU`eJmEGL|NbhkBORo?SOX+(-9RuU?Vy?PKFEa-WNWB3k>}o(j zB5OD{3xMZoLIC=%9Hj9N<7L?=Mp*AQ96b#QIj3Zvo|B>a9(MB(6-W`3czcx$j&ez& zZN56OFFWL`i=x74a03QQurgLK@EqjhRG?;Z2I0h?Mf`+ z#n9y66D|NLBSPLJuBMKVk_Dh4m-*sC-lHEw}x zFW-zd7$LDn!IHz5XS(5Ql`_>(4F(lcn5Vu%bERb24>kU zWy8`-d`&3twgx$3a8#8zKSvGoYRPGkqKQX?5 zFsLg=EYH(Izpr!oi13;CgK&{((4CVHa^6`KuTkyjnP%mip?k@NWe*`jos<9{m67bE>i3JlgV2n zjr#d9_$Okq?sRZhpmDiJ!kk`7&Q~@~tb?}I4z}td9r>1$w3lm1A#!s|`M4iCA>o%l zwbX`2V~|&XNSF1U#akLHqlCl8*|2dP#3x73jx!pzWN_T-UgGgx0{|h#v(faopFDV9 zqQ6PN#>kyW*^2HD-AElj6Gc4WnmC#hn&+E7yIh$wJQPS?-f)}0KW;lEglg;I}O%qvStITEJ5gCWnNWs>Bkxl2o7sHYlU=Z9rx}js-4*CoSNmRb{70y|{hnH&M9t^ksD3sp^@}YWMY!~XY ztXXTA15+z7i6#@TJAm#h@yq(#TswW!N5KHVo3FAH@huzoK5PCIWXc)W2~;~cS)&!Z z$aDJ)1P2WFN5%T4WIjV?sP8nD@t%Fe$@EPq!f)G%sk#NOtq;L&_Sv=id1_jd9fgcl zU>xVEo5Nwi#DEBd8`~74?kc`&m_jV+ts&bDqMAzXB6NCYgQ@5xEy))t-gR0CnZrg@ z0~>|I81Gxf<#?Z>CiV_RXn{r)Op@TMM^p9-khThYC#FSF)tGa zSYH0Gur+(Nb>{MbKh-?7h9ZgAk#`6{|JsdENl;jeFcuiVKF0D-w7Dk%9qv2kG-tyy zjY3;STDsBaKTC3u%~0^WP~ZmfW*+h2g^f+@uJ>M3iu&rQ;1mjS9HB zydTp5+A7SkQA##R;K5ay2laiU@h|LA(8yia3(yO6Pm*n?^0g45yc!{plG>GozjZ2J zWy%o?;$QB7!hgwz%~>_R&h!b|sxka0pdcE_2>e^}NvIBg2}(MI_9p=SIZ*SNDn5eS z-#hUcv7^UBBgz-F4$Um%yq0)p2s4F2kXFfT_qFt?nmFE=xQH3%Pt#R zJcbkoneZ{`;w&t)(z~nrD<0?ZOt)64Pb=`spNJbDkz)8=Zer}4zt_3f|2Amhlp`Xb zoM0bbUUblmBKpZqstd{KqDzkncT?}3oK8R$#ObKe+;~PAh>43Yh4Ygzl%t!JX{FP& z%90@`>~l5C%n_Vx7`VM(JI8)Ii2}o?EmGWg4l7xbsLYkOcSal)AG5a1<=vu{8W?5w zLMbdm)>=)$9G@PJdhhyh7Na}{6f7RP0DLn;6(KxKZ!EAL+|8i4F&F?!57?Ud=m+{Y zIC5QACy~bG{8AT`Vs~khTJ65;Tu_{O7$%13<2Bo z;VP-4;QCd4aWBV`cMrym8oeD7^8wY0pYNE&gi*GTkyEX+(o5{C%~0zvGS4FQ1Dg6S z*%Kh=+r#r{hHi~OYmEanQ(Yes~M~8OMM~Ca7-F<>O6fhSCFr#FWx!) z0s@WFYQoRkgcFW~DzB*Y-5Y8%ZJ*h}){G8T7N$SDT?`PSwnR}1Tdt{VPsuB2dPQ5WXl&63dV{za!5h9{i> z*$>KfMOXhU_Yr5WC2cBt1Az5kN>!B;)MFot6_f0y9GB5Njn-@~dd_Gi2qU}p8kFd{ zJ2Rqgkm01%`Z%~Yl6@sIi1{61HdPz$5-|qa&WiR8X_u{`N3QKM6|xVP?6vD z?~Zml1$G2;LtAxBBZk*6mau?UdtL#q=CpGgWlMhyqucUm#Q|~Z1mcA9B^Zc5YSW{- zXHpJbiqhInJXki14D&VmO`n+rjdLsPl@z zvp?KDYaY~=d#QFEDgXln3`cOeo~5;|TWH(E+e?`JAp6o%{O1ub8`jMF%p@=1aC}Vg z@L|L03)~Y{Q~QL`FGAr;o8wEN=MBA*Wg5+VucJqHxY5AI^k})zw5DdPS@(&spi*k3 zxthW`m`$0n>J{mDB2LXc#mKRjlZ<-Xkj&oB49qhyQVCtOi*OipF^)bs9&l-=-2Ihi z`N0ru5)#Un4$g!;mEYq9ld++e9-<3V2J=4ayFW=o_ei}Zh)YLv|AzHR4mG2Kj|!m$ zYlR503!+Ul=}TR>Vcj+OHn9S* zHBU0BeFS8cN2QvJ&z!|;&Wzr-l3!)Jso2)yy4rgyA>MfuY}?S`d=px0yJ}HEWuHoi z+FmiGNa|FXKOA=?a#4LG$TF2@ANW_B70HBzpU6ftVm9)5301sVF8ElCdujiVXSL;R z3!Ybbis&U9xOlFdtObd^>V(2CCM?yNk!+F>)9ORPEcIx|!WEJUv%FhM8@R8XMd;ZF zH6BS{T>YXt&8nhwLp$448PIpBB$^r!yU`#|{CTAfYP&Cypn-FqeYNaWqY#D`t2>b2 z*dJUQAFZwfR4++TnDlZ4=VXa;4iW(Dx_}m*0#}@ZkmiM$>c_AVX`AUWV74rrj<_W2 zQ&4HJkZFa_19%HAj z8p$SaF#?9ck#?&*GfQSV``dsQySi_nLb_>fYi-_j<{G5+(U+CvpztGIU>3OCvL`s0(1I6in#-Hh1}&<@N9w#f13>FJ}?JD z-9cTeVhbj(t)v+j*Z%S0=jj!}rq%8654hp-;g7R|CME1$3=XPvC7rQhDZ7rrfaF8l zKV-4KQJfG<0n=ky&M*!O(3>(aUKpFi^P*0va~l$4Z8`PIp}0T(wq$X~H^aIvY-cc4+o268cFA~!;x^SMyUNNR=w<#w$Zn{mN$ zm&Jq4MLvC{SOX>=vHNX7r%+xE&09N$3r{Pm0zbysMz2zeZYuqt%p`~E$zUyG-xh3G z$P+C2;f3xXD+)?E|G*qhzpAx+@~p($tCqsqw0om7i?L+*m1t=iK#mh-OIjBYqj%cW zSWdAEU<=LYk~D%VqXO{#H>ssC_+MjdUPn4*5s*lV8cWSfFGvnNH2s*kkc!!VogHK2 zsawx3x9&y*pedvT$sfM} zZQE(o+Mc}}UD~d%8+M*}N8C1Ki}dr)r;9?)hzcYIs-Bog0fbs3BdUK6I#-@SRdtjk z1mGPpzJp3&3zzkwsA>4N(n6z*dBPTnwfxUWf8#!<-K)7=Ew^qZ`ghuFa}wsJDAn!l zPRN43BZbk6j+W(J{wUG>&heb!ytqvz>d-itSlXQ^6o_131oGc2pqS?c{z}>37rwq1 z(8{owWzQHKG$UTA-R|I985cv0M$Pw4qEmsG9^s>n3^5kNCL5q_2J7Gz>XhF8nd^n1 z)=ThpHE1l9^QAicFY>sd*7q}yyCIoY$0J-5=5(oH(URGUmpS>ffyB(F- z{O>~$cX5Ww193ROCQl>6Q#uoTPb3v`{LeX!CXJrITX%|n1_P?a16`w>9dV)%TnvCp zq=3y}*HTtj<9P@D1)a87=Jo3ZJ5)-5qFqy2tjmhJkJxKZk>^nH-%`7t@rt9bnC9E;YRD`Fo!=+t#BC`~A76 zOYH~&tK@D}XD_V7eL~qzQr}9(hj>id6HsNT{kLo7!&s%2K3y^qpDTSnot1K309ONf z#EY9Fa+`Y{US5^ib?HVn=$-9&ql2~!qM|L`?-b_K76`i9fbnx!JHBd zjCWM3SUAgzLdjR&st~VwVR&hWr~G0cHO?o|z%+ZG?xCa8cE9C^ABg_N$$-|XdT|v^ zj}m4iY#N08;;waLFp z!eD6KkC5aHeKhDtR&0CF1!*WGb_7&dxTfJ&;K25YDfHF0rf)k)+>MpL&dZKzmR<_-OuPh)VLjqaqKiVs|wfGEcSn$Tf_7w^)B<*XsO0 z1DFRcvlgh>du`1gJp|PaYJy|MW)UX`YrNGb%j!=gd8%^M6XOzMbxNG$b;(vlx$vOT zURZOG-WnI`o|xE03$`2)G=UL`9$#!zYC2#L^LwvpQ|+3Rr^e|-8o0~^x$M**WUC{NG{ifaUKE+H4P(dp z4o2obNhjgK9f`15CLZ}|PQQ61)g(qL_N%2}|C-ya9{c9)pMz9^i9405%-nXm0LtJt zU0}rwaO2k=LVOU|ZSm$LhhXhu(R>q_E2ZW}!`x5wMa!Lmqv5M}PBWRfrnIIp^ibsO z647ee)}N%-vORM~U_c+J>bH20&;iP%`_Cmk2piSg&;F{s`C;Ztel8Y=La%IGM8Yu- zT0h)AWnmxiTXd)18Xr2>AG#kddTHz$_mbHv%VuQ4ce3b6w5L;5qiLsIeY`Rz&TN~zZN zbslG>;RlU1OH$<|eLO>oLZuHRTSKz#d#a#`p}o%2*gfx6hZmfM3u=oHBIvxu`Tw4MR{BzlL`j4tfK|Z{-0Gs(xE)Zd=Z$FKUQRDVmbM zL_VP3D1K8Kbn^0{q9WoupvlXxg{?FHJ;zDJqcCre=tyOZSS)}`z>5Abl>H@{S(Ns~ znQekPlDa@1Fr_r1S;>Tb_B0jVGs?m?<7$vaE&ox-3XIb^M8aWl_PF#}ZN2^XgIj@$ z+D`X@3+q0hgR*~N2I<%2iRNbuf0Hhk^@_e125?``9K7FJcK87!Q)XGvjC%#lza~8x{N>3}DE-VK;2sP)sfYUE7DqgZ5C zBO!EtS4mmLFff)Ivx$WEy#NET9KBo`w~8a)nfmi}5%y?LWMGq-@L-Nfu7V9L|Da5_ z{pMF--jHe>5nsaYaX16~ob^xk|8i8Cxlt{bK{6Ol-kwM&)91U@2AGww>r_%=tWroe zP3q;|vMNWeajj$Z(XgiM25&^U@IA6wMTqM|wEg}$W-Q67zv>Yi~WY6$#9#qeC09m4T1)>w<$~V!PX-Xa}>JlsD>5>5( zad7h*Z_?Y11+%ycf>K1IXB8GfAuGf`mBi{@iFkwvl-LqR3U&ZZsK0(WMtf-RZ0l}e zxr1LzaLR@uie*+VIm_=X{UTWI9b@CYj-;)I&bBj&_epxp7E&_A>%ZO~$7$}_< z0$-|*q1BWZ4Kmk~C3dU0Y$6OgIr0`X({GSA@}Zzc+&|?S8lqIo5?`O3uWRTZB_KoV z>7$eZ2x_T)r zV_hbEsJbY_ZyTZ#$`}jWD*JP}MwZr^9%fl9(W48Eg=iIulipeSE0K#eaXkN-O6O)O zP@!X?DPdBFLmA-~lZv`gos2(A<#6zALnQalZAa;#;VSm)pofJ};KlkJm(g}E;Xu87 z6_s-&H|h8l+HOA1kdm*z8_F6EpP%weMA+I1D-p@qPMnrtqN5R!c*vN|WT7U{w}dg5 z>VJe^D224{GlwSR@)8G}TI!s-RKvI_i5d&2718okUBZ^KKecXK13Ync)oDMEai5Ok z(Y;Ta1a9Q9Z1NtG@eD?u)F@4czaZheEjL0CuW3O3oHi!pqj#DctGx=Ao66=JF;SUm@MOUP;m@kp_3ND$^%_(9D@QA-gyVfJ z7|5=wDNqX-ild`PvK$~X$AxIT`~|K`ekon&7#TOwA-NvZR!N^&hzO&bR|hs_`B0&u z#?!!4$6I?X@n8cG(ZoE2qjNqq^Mw|Fr0(XE>I-^5mXw`~Y{>9A#*a&uThrlbY@D-Y z)dBlRCam3U;0&^gdctnpk{q%Q{NA$!v$D!0Mv-eN!rFvFzXcJ>(_Po}cOPfd+afc{ z+BL~gUzM0Hcp2!@L-e{WzR>y&hf;b6KsIHTgKm{4p!ai`ub=htxoQZUHf6swdkzA6 zcaly0q{?2=OpD4NF&WXy(xtEbF=I|!%26wrIxl-D-bZnOZ?2S1u$kydRbBV_?HQ0% zH||B2i$4+$Hb=FuxVB}ZWZiBUK{fJmiA=PBiLv<)es^dPh?zZ$>xe}h-C^Pb9{r~a z+T9S~*Uq$t4`Zj5uT6h9<7iF5pM3B2H#rPc79<#Cf#Yf^tvaDt=0P6)jyWeM<|!$# z^y@=ZBSu+BLS_oGvMcBNR`%HkZM-a;6}W2ZDoGj~e#~tC;6RIFon9Z9RjSOyS<7_2 zyAf$QDsyKc)jlCII{T$A$E5PKU4G=wiETx`Qs$8BVXZfyPz5asm#Blb!V-~D3=A^7 z*<3iO`ODc}YhN$^IPhI-DS5KLuLEW-~-WH<5(C&RQC|}14KEloVztb z+}6|Z#rAvsxG-Ma42CJLD+g8;PL00u{~|4uemAJW-i6qv#fSWKn%gxmPse|p=tFy(yvjC++$IHwy5t#+i;C@qE*I@x$t4qB70LP;O9i73 zO^pw~wChnI)c+Zp8jERabkIuI%_ZyqEv!}+S7DcI>^BD@Ce@I9^RY5ei(q2Xp0yOg z=3yvWHVw#>xyLFD+Ut)PlabFeXf;b`y^jo)#=DAhAPv9EI;<}D8dh>IJcUku0+?Ed zU%fx#j}bZaZNArZ)D^oX)%L0i#CX87*XlE%@P8M6+uA&Gf*iRW&aGeLPoqF zB+%3{HhD-oGZH@Gb?mHiM;swvOlxm^;{GzDyuqgWaPng9%y0n%rQ)q39w%&yn;vCw z%@`=eYbaiMVQ1GEaHVXCHadGjf><%TNy6S6G(JrMpN*t^P(Mw?>ilvt)ah@?)3;8; z1Tw{eO>voc^Aj3SZ_*RjlY;sNtEy`()Pv0kDgM_KoK@%@TOr9R8jDh2hCkJ=lA8vm zo=?hb+df-U?xkl_Qxs}4fHS$L%gylCc0hL@L*<>FhTmr3>yLW-sh9m2D_oS_X4P$+ zSBhe>t}--sun2kIsLe?4mbdmHEfz~+H}?g~veu9>&+95H)8Pb`XTJjSQBh2g;h_9r zIPC_z!6IcoI9r#tstoVeijwhNMB1ajLRumv4`X@p<`4t=+GCzO^qfl1b%Qzz>FtcY zORCs0}r32J*;WRje-D72NPo?< zI>|#}rh=_>Cb|!oVnj-;oC%VLp>iteK;DZg)&m7};vi_buPE-o(o{2)R=giS)#4EM zri1c@C~2xrwK{1-;6(nNk8byud5O6+e0+=tvRUTs1v*XngXB9{t|s21JeMNFHUrlG z6NOWkZPiEin*e607X{}h9r0T#+FB~8?ZS|$!coxXz$i>{2@PFdQ>-j-pA-dkX{S1* zQqT=2=;VM0=QgAM3tUW!NgZ~yA2Dc5y`27Vu}2aLXiROqKYJafItKO6ZLQBHX#7DI z$YUoZxz~O@M{|O!QG7?>!xoUrzLibOQ5kGuwTU*@h8Y|FafbH1Ltq6JxY&ScxfaV~ zTa*0T<&qYeA-c#r!p&)}#i~f#PwXC*xz}a{UyYqL8Lz!zK|iZm^TgI$49a!bc?2Yl z_hff!YqHNk5k6BpuNytTaZUkSJbWXIO{8wNdn1e(W6<-Yoj2ncGCJbL%!qoiP%;m! zNZ9IcymOjuJ5qV?L@l#Kc}#;Cys#u+TC=MXN0$9drRsUPQk#Q46ko34HAoV4ZgUkn zxnWqU)=t;1&b_o$k;`$7A4KkFU}8YRKnqmW2^~U0LhMr1ry}BOhx>4m^}R5L(5##9 zLik11C=51s;DyIl{b9Yp7_qMK_Lo{wn#_kAuathyEx7th5Lzk9qjbsYU(Zo?(^D1k zzi^w}>?l&^eRjE8I(r{5zsuO!RYp7rgB2$SUEq1MyQxFQCi0(OTDz;Y&>HyriBk1j zqU4G~G#n)#p!i<@GCIvDobFFegBt;B^gH$k&rUHsI4!UXAj}POHZl1aq-uUa!?8|g zO5)mhy-{d_P9xBE@a%gXH#QSI2f4TgGCmE3Ewn`d7nX7`}}c8Fsbyc%Rj zk42bSVll;NqF6(%mb7M-TuJCjlKY%7P`3nyy#w84=y%-3P!(5d&pOm+(PZk6l^Mry znMe#xXM2ZY`gJB3gR;bq4DKGUWU*cWH!-No#(&6;NicfM6ur!>D_c{RR|c|GORR^r zWBjR0sXZr$d-hq|;dR}SW%7JW1&IqDJ=^PwvjzTG-!g0{mMlMw0;l(o&+Eu9{eP^z zV~}hCmbP2APT4$V+qP}n_9<7LvTfV8ZQJ%K+qb&s>zVGE?mK?r_FIJNu;!s{0v#vR8{qx6Q1 z&*!~5cV|Lr%qKl4T_ZL&`phvb+MHihl1430s-*pn%KfEiDgK;gCkYn|st507?S0?T z&K=*@c$h0XY}nIx%$JAdDaGfMiH#!x>3ri)hAhk|`k$eJvzSXv9Iy~_GSV56ZE;jk7j*$tT zYPViiUrO=0h07mhsnxXy5KEKx@2)0$*8|tD(+(a{<0bvZb3-G*p*!OhJ&$ zJGXcp^N`J98^z00HF)(x1}e*B7(q7X2rnzHYTME8XO)muNW2#lm3d6d1ER>17%*sn z9|iSqUVe0vwfYyeI&r`g+S}BXWLg=#1?Js*=y&cg=z8p!=i}&MMuT;z6y~DGS;|Nv zox3S=+7w!SGXcytIIXQkTBR(H;zAG_-!Ax41f5H~r#~yLI(-@96R<;kNi=ek9Si6V zNxYQolM%xkhbwmp_kcZ)J9a*XDc4n)lL@A5F~v+-vOR32)ho@L+EC@H)Pq{j-aWVn zh_F}_S_mHk@6=rV`JOzVTdYVT=4GViSwT(J|-9 z1cxX7RBwtBj|nETu1yqDN{VHhH(XUb7n3sb@BGDnHS^R~XKF7$r&(1Io6>V|EU+of z^R(Lu33@2M8mSQ=y?y=0>lxgV^ziL?F+zffN9SFK6f{oQHpy^2cVL(Fx$4&murn3b zM94^6`249V*_oj-s@MSXAl4hTXYh}xf0d#|E^5vR5zQ?275kghrgJR1 z6>O#uq~>XjlNKQQ3_?y8h7F{}lTMztSxLWvbc;thN8})BTnvX8vr0`2hX2WX0bB)M zwA7YRP~@aT1tN#j#teOkbReEPE+}(^&(zuXIH>!j%Y+B~Ns;HD-6v~le(1+iHb2PX zG@7A3XsxIuDszwAP>Iey%=VZ)d>S%znt>1;zSEQb67L4yFYEuNLz`b^;ba3Ys#QHz!g~QN2{ot&yPGT z7uHnX*Sy1$WqI_MeZV_|*^U$o?hR_4k%yv2RbY6c z%pEPimBs&W#Fx2)p|iD#m9g7@gTIVyt*rDNzD>u*_RjiNw8n0RR{GX|(H{Rb^V;Np zU||;jDM0=!7-r*aZD8!+Xm0wy2$Ajn101ubwRg64GBz@>`YV?9w}b!S(*An%PyEUM z4KVw*DAWG>ACTE!nX-R?%ozUe*Z*76HY@XY4*1^~GZyCmOx^wm!i=7k;or^KR#b+8 zSaOycm6dQFpQfB;USMocuzQ4!Vp61AVBAqqcBYY#rW&1?b`+-)Z&aXbXkb#Zqmovo zV^XH0Yi3|*U|`u*P_~<*Euk8dnkJKs#ac1LRwbpa3Q=yjH!-Bmp{7@ zTVVqLiE@&L5{y%VKiEuc8WbOC(ZTVd5=B8lk^Sl0A@GF+XxnehC;`@uN+!}_T6#1i zF0vT90whO9M~YmiTSsUKNriA^&pSnh@Y|WhpkjfIqx7^m^|WxBbM?5C_|!is$yxDb zIhJO5rg~OTu_IJ2;}v4kkRw#$Q*vUG6XY_W;l)RVIh>&Azx0An-oQX!*xfAz4N$1i zVp3975f#*9%Jh8YV2-c|pL^&i#wz4OSY{aM=s+ky1kfo_Cux>D4&D6d3~t z^6~~GXn=F%MT&}`7K5Nt-N{Q)ph{8rz|YSQ50e2J$p8e4R0ycML!gmMgNC49M^lAI z*-J-r*eC%<9rRy^M#;PLG?s<ZuR>2Alu*#p*vunciM>^Et2LbLiee zXEl_uBs!<^7LGf8rnJ=hBHa23GTo7YCLcEuPRpuFPg zeihY-t#{XPn)$eZtX-7spH9)adw=9mZfn)*F+z(zywEA8N#fxs8H%uW(%9c+3JgfNqKHNim!>_;tHx+zvF}5X&C9QReu3zl^rS|lb z-w)zJ>}a&y$CbJ@<=cpu;=I#Up+5rlaE2BZxHip-)y$(yh_Gy{bzN^i-0jYijYp^S zG_jodr`o}JPaimX?QPF-s{=BOP2t!Yd4spm5?J$Qx;%>%nw5$Cw{?@$4)3$usUl=D zqjn)@AMX%KV(E=GGWRQM0`IeynPaGPPf+%H^gCVq)23tBT}6jieYc3tuVD>08l%nF zfpLQH2L|5hPCGtNTZ`4!<*?gh4U*7{Y3cg5qgI=_ z%2Jjtel1S4(=yvh`X6!KOE-7=AN#BE$B$X$sf0Qj$ z%J!*a-?$FIO;N4o*Nf@Z_kNpIbA$`OR5nw8dCMN|USQJmEYi;_kWN53QgLc|a9GJ~ zYo3neZ`ylQUScxbW_5E2Uq}1*5ru;;PEsU2HGx)tx#`p`w2VwYT#Sia-j7C8WKM(s zaudeuj(58^_Syx$vL1tfoB#xf>|zD~pL{dpcX7kFHL&=%_-1K21sMVH?>4BY{x1M$ zCVXmkCN})PaJcxaY%Kq!X84Akzu{zkJ27K(Q!^)gmcM|@LdK4U#x_p))b#A%aId(N zzLmKlzm2Jt@%NeU6N*m8)++ey|C(?%{BB!T-(atuyMxo;BgKq=DenJJ?V0}WBLB16 zvwq{!f2;Ov|K(WthicD6$MWx1`$`3KIV4kbT%!*E%v{_Yza)4%lwNEsh-Ca^69BBL z5Py7^QJPVMIxJSmK0O3c;ofklkQ{#~H5$-TY(hd&a-~`R!|yX8$`o?gpabR53-)0? zoZH!6*~jkNPpijo=tDdLMbHAj^E`o683<5~;5R_}_%s1(*_gokBZc&dMRv~hi7nvq zIXNL(N(KP-0HY$glP%%p33o(B^2Ma6y-PFbN8jVc|J7iCVBiK@Rq{tF5sRjW`) z93LMcVZcl!jH*poT)yv}FqgKVt_1}VVmJstHfk`iyug{~ z=NgOUGMJVSJ~|DURu;3bIATrUW#GKd!eHLia1SRO4IQalN{{m_4 zvO;D(MeTtqIRWz2ydrt11W9EmjG%Jl`JLsj<1+~%5k_iuUvtq)e|$~cn%Y{$FHtgu z*q>pP#kvTIbH^Mo`EkOtVoE~u4M=&7Z~cnnd$$HGMvVv4#=}eI9anf9Ct$fKBVh-xwo7mj~Y+2ii9yn9G5HA7x$yroKe%?GU-@z*UcP` zpUh5AMIYW*AGdnkcDo|*ySL7d+F_e;!o}Ip3OG-evN%D|KvSEF{HAW|L3jP`A}Tq! zEu9+SbUF-?--<*Xw+pT%G7sUqb9VFerW1o)Tbg;L)EtkM4>WnRx}BD>;GfrdzC_?R z*@de|irpBu6Dx7n`bYWhV%IO$@G{Y`P{ibPjZ0qDk z&#t!8wkktW47GvelXyMrx0qAzmCwq(Z5n$$oU%l;z61_&VHf z_se$R&-pJ`Rh#m3u1Ce|TFcFTb$IYb>g_5P;c&|a&iR7#4j?ywBP#lh3d(HuHXDAu z7cmzRrxBrW{SBAuU)rNOoka``bY7CpF50Xio3XWjeu-DL3AG!VUm5#sXMp?nV->2l z`A{`kBaNtA4n|AtMNi-~9e_b(qM~9jh+?9j1@WGU?Fki(tcS;5s$= z;0p8=X|Qv*BmksNtc*6SntIgPGqh$w#Os&?@sTOJdL$lS(3-cJjCaL`3!!tThI@O> zo$7G)XOhkcGeXy)Fbq3t-TEHxmG*-tL*c&C21On%b;1@?pDg`t=sLpnM^78{$FTLM zzxl8#gX3^8^qMC0*+L{kGQbJSNFb+ehKlMPuz2%@=@&MN{5C>1)h?SMvY2+dC0;erb8xzxK6%b$|CA+`-Pw zj89L`_U#;EW&gj>*x1v*SPXx4*Qrf9P+25efaR ziT|y?v9q)OSASz-WdFXh|9I=~8yqto(|_b;;Qt$e8S$=Mi{W3x^`eg|durhr z^z_6)retAqA_M>v@4Clyu1F-dlB9=t=J_+n3zWao{y4shpLKR-^e3rjg6MQ7E z_u_=!zHI|UvW&YP z4Cc4H141sunQ7hfl|Y@b&&-@>Z>LW`+(HCBz9lK%f8sPPNn zs0ZLDX4Ew(zUPgp8b58!*uEnfk8p2qihA=MEt@DdV$zPQhV zeebha5w<}ez&Dc}pM0KRm+%8V2~WIaQMN~KSYIB26cp&&0P>I!d`j5<+2m@dATdF{ z{-3h=6IkKGIriOOKi&!6CuPLmFYpn%AkYsF*uY5ecGH#+)PKo#>eWODjf4~Bv+W6v zf1qL98l*ek!sM?E0V;wV<9>MkQZ-`NK1-4zMz{odnb^v~Ucu1=>i7!nN>39fqn-b4 z1>R(CD7tcYpv_t7Av3Y|bGc45e`E^zs<%THdem_fw#JF)O@+$-bl`dQle>B6b2>hG zez$|NG@(g0%}EjA===`St5}zr4m4#n4_7690(j_7{PA&BzZv5UW))oaK4eI;OWl%7 zcJ&9@+cjif%L|V3cw3o)+FZ9tEHrw)V%_cnT#PsJjp9%0%<;HoR!6d>&s=`F2SewC76*8aQkS{S7 z!(zd9=|nEwsqyOS1&7s+C%sBAOm1({wCSO)CGx{*%aswYq8IwqP;0UwnN+U5XB8Q7 zolvQZ)rKg*|9r?{2C|DKOy$XX;pt*`oOU|Y_#2V|+1O$s&PV`%dTWi7FtvqElogY5SVS?f>(^DNR5R%Q z^Y;`QH5r2J`6bCm3HUJZ_rV*CnM=EP6-+J97JTh5HoT|5<1Hby&p8`JTkM)KEO%-eiPHyMm zyflrIdI-({)PSDgH|r^SqgUoMS(lL*oiRm-FeGt_^UN(Y{>%zoNy8A4Q7*~020spj zNo(-p?!2o*HJoGnH?K+=!;kHQDsJEx3%f99g=Ju>4xiQWXIIZER`9t(AX3m=Bu;h_ zH!fG(^OtVYHKqB{ugy-cE_bkMqvbxte@4J`0k}Uzqp$Nzuiga$DwF{oG+F$K!4BGc zH1qPV^`b9%?Afe{OU8xsKP%JU0-f_jTC znc^d4YJBj;qQ`QHwkZCS3e;K_uZL2`*y<$D-gd#voqRNaN^&+tMCJDZYUh>mXMgEk zyvRD-7zwsaR$eAKe&7{KeQ&4q8a6got$Ht#)y|7!?X+|q7YEiQ3rzBCE8F&rB=H8C za!G6QirYQeE1u58oTZeP;(Ly7s;Yw@u}8X7KuTb8WZvaZ-jJM?+c{r+!`|Ok6A-ec zJ;mKt-Bg8{nMwVz7KimSNI^v*fuFV;`{m{A%Cf{EksMYM%N_5W*^1GX>sYP{xU7MI% zkQMg0x(<3ZWh$-n*wi00VJpN%ZGMsE?Y(XqWvDo62Uv+TK&MIvcU-&^;m7(ToF|6} z#|nPY(gp0>i$rdI7;dR$!r`W&xy`4u@XaIUU1RVo7)Nkf<(y=P$SCGhb*WHx+6h76 z=@|kA;MA#&LJN@j_AoCDKt&DAym3m8;&dAptZJ$^!wLpe(TWl92*lx}C8ItKQ3|+& zk~S%S@iMU#%@UFj{jR5RDceL|$u*_Co)tZv-vmX^63^g=gv@j3xiyk&jl%}st%k&d zjGL(ztSH5iKR50zh2+H%=uOrqP-40qlR2WLSEA#MGFi_BQQb92#=xeZEAw!k>*y17 zmyhl<#V9MA!8y!N$C6};K^|NknudOP5ZcHtib3dhcUOz+aM&!UDm;Bh%1`iiG5am! zYeYGzXqn=qc2xF0ZM_;xbZ+Pnpon+6QL+|Ypp1EShkBEo+`8bXY1_U8DO5kq?g2qE zzN`3zZN(qEn+drE70P@23|57j67Mx|0&gHkueYk1Q_&E96q z9+8@+S$Slis}8F<;#BMq?<8$g!bMp9K9yI|Pnd%>z4j1Zn)}lr`RX0ng-Rgb@k4x?wR_1j2P0>z)vku$6v%Y3n_NAd}}< z@S(Vr77r*OLfgS15xkMoafr6oK0sibt)hrk@?oqIpqRT!?J5=o&r0m-BSpVRA9dZD zDGNLkaTWej6IoYJL{2KHh2ubZ&) z{Z11Fx<=@4`za?rTd}9@ zY%!8@{(ScQ&rzXRtRL@-DQ=AX+MFk_lC5lR034Zbf2!8UOO|i@w^$hpJ@T{oNCmp8 z5uH|tqG%Vm5*_c;@}h5y={b;3jhbA650F|1s%#?mB+#_>p{l{Gyfhirtc5qs-`E=! z?nEj-k!(GI_7##a9nRVkt(Sptx^I6lPkYFRhp*6(Yhr6t8@#@kqKDF!-USK?o|#Vp zL37~?_a=sL9p_V-_ItXHlLNP(Y0{R`O`LbNSJNv%K?R5ubb|O7pv>zOHBuh_6pVoH ze&%h+Zfd%Z(1`I|$|g-ImwvOiwvseV>v}b)#$;|QkFtaofe?QkS!NTkVq?xU99}Ws zs3(H!!EAA0o}PowHkRLPsb zW8lRe!O`EGx**C(U?}ngeSse|E8JvlE~DDqSXDCaz+x$z)?&D)62UE*??1AtWopiC zuj*%>-cwlp8C-YWbPAk4aS65`SvU7wIazmh3@e)6aC}dyEN5-GefZWK_(ZL#H8EMB zemmw0n}2yRN7}WsTZ?&4Es?COG}k#v?!;WznHiw;S`)T3IjeqP5DmzaC&(w7IANhy zJ&8HGu#;?Rq?J9JsBYEYu7Ae&DU-+XVnem-y7!`0q*mNJ;9u^l#;PJ}-n<33Vpdgd zr9_abeo#@rqw8khtX9tRc9^4vbkyeDX{p?`O-*&R{F$T+rXzOOOoDO7|5h@%skeJB z)QZq?Ui5D6iVGYcwL@EZut6%>6Y+T3x|~Z*d64NKQ3-ySeCI!x!P*$2nim!9Vk5P= zVHE2$8Zl)qphD7BPLGz=OZh-W*Hn5gt_3fwu|5(9%Y~bGIq52Js_*b(YQv3_;;c`B!pz;tO zt7l+NM{0;syGC(-K&yLnu^LS4F(TH=IYlU z3ats|6zhtsL4RKKL*q}^qY_z}N&lE|PouD0IYZNX8O#X9OsFL8r9TeNFc-vOwx|ta zUvHK?18m;xm`;dcL*5%7&Nuae{Q_R29M>}H#PNzJrUA88uLXp0iltkorqLk!VnB*D zS6Y&__q#x%aCDtQe=Lv4Z&iu-p?aBys5?^`>CQ^RVJmVbLxC!!DdG+8nbykQ#hrHP zw&FZI9@{Pf@irLG!D+60OvbMMwT>8G(lmUpkRQ^c!~L`h&wJqE_$2f~|%fnFpz=~o?Q`!1RwOsXw_ZrxF z*xb{Z5(Vdi!40*if-{rjhfaCDxWxLtuT9DML`gW^JdVp^7jYrqg5tFJW6Q(Deh+Hh zM@&s;MoP=|WCwEO@7+kGM4qU@Yv%**@!f(NcdFnotR>E>>99OXsh*3m>K9f;FC6yUJq{VoEe|0z`EPTbB8i)zp70jKIW+ycs>onGOUSB?Ojs7eQ1SB0qz0nWHcF3;Zrd=Iyo&6m>cMc_D5JY;$&IJZYM!uy zR8np=xA*wnxmvEbqzLqU=kQUv<0i#e<25RNI8L6sjotvD!giZ$Uxb23IMPe)Vj>{2 z&uaO)DwL^|FB1uwd5ouwz^p4<>g@x^`)j1mU$ei`REp;ou~ur^1Ql4R;ZN&3kvhku zf9}Kwz6ux-DtPkOdj67dK4e(5k9|ycstr^-<9KnL+hG1)Wyu7fSO7sdXHE>HkrMpsHK@JQw+)LLa?ObF`eA?$Uncb zzwaD-FVOB#^gDUI=B*vdWL#w&T;&1cT1CB z+Ew%C&tyE#kCX9oi|3uQQ6ym-bD>@2SA}rCW=;;XA1#A&)D`ojpL8G#v+Wbs$a6F! zcM;2qTv|7=MP@4&611*GS=BOadqG&-tzu`%pMv%2v%O!yoT%di|70%u|HZ{FA}%ke zs_{J+RTBSKb5Z913^e}#wfFLO5BymF^#ecQ??B_f=+}+DH&V=K&1tP@t!e+VTJnGP zM;vG!zaxj8Y2E%|So+^3>x}yIuXJTZc|936xE#H=P=_Tf{ z?<`?VS97YCc97+rnU?nN7g#a~Bq9|Xh^$@n&ZP`nW~zI((b1a+&1a3u#hQn8DTPhR zXyRgu@Fcbrp90)t)dU|ZJ|3TzymlryfRVmnUJ&ji;H(6f)>89L z_AWpjoDBjYG&X{kd~WRm$$_@|W^D4CP>J#3_e_i}py&bB)zpa^d{B!mZEXNvKW;aq zrtg1Iw+3Wr_v8UM>BZgy)Ce(xduY=7VvJyiK4b#3p+Zy~e8J0qookIvE7AOLL^*(wbD{%gU;nBuMLpSGL*_S8v2poor#QE;vNWc!u+@hK zs`*H-bBL|G1xY2>Y)#Vu(#qWA`^w{gH2EqA)N1k}*Go)7NmfuYes|^kYApKR8oDaG zJbaFx-yZtv`%X^N!ZxLp?eSniWnsZzL3qFO=|27XrkXtz!5Jw%uDR^&fg>_ABRgYy z0suv{0Pyg8#I9vRi0lpU?fKxcxh(0b!SkZiy?^z#g2VnJ3-U7CO z)CRxsaRJH)@CKmu65qi)je%<k_W)|fKKU~MR9bl+^UTA?b>O<>m$wyF)E??0mAMjqc z!SC^^dwk|u@Rz^pjt`%Mzp`O>_R>ECT6z$rajbfu`glX_KTZDp`9y{p0lS>ZmazAQ zHaOC=d}}tjE~)=4g?+L;H~{M+{agiB0mik^-0y}O2dfHx(M7N_xETg@o85cjhI-|M zQd`R&v-gKKI6X9jtos@Vno$1$?NzA!^50>vd4cwK{343Q$|#^789c0Zwk!Ocg9gER zha3cbG`2PVA~lDzGxK2OjNe|a7}SmHVPz`s$D7s5hV!`q0_qLr_*4fQwqtSuTm4d{ zW%v8i|7wrN)`Q%kX8~RPG9LS&of_Mf?Plu@bZ&5dqol`Av44$!wmkrIc=<5;NJYHd zE(kdHfhPdJ@>%&p1p@KMx>L>e-BEal90uJw0II8h&87zq|H_UB02zMYPk_#7C@*9@ zk*#d$8MJ?}d$t5#30~Jl*pPkd#%HS<);$LASihtF_VhiVfi(BNMYGkA+Q!^<3x0IV z2BxG06vH#3`KD$D;PilI3EJrBbbm20Iy-_jk3ZT9@_Fcxgb0M_~ zxjvUgNM?ev6PrwZt~s-=O+MNX&vi|x+^^Xev_P{9SlVW_@*MdqrDGY;yqZ zLhs)O3I<~x8PW^rkI@Q_K;#IHoK07j`rfSjK^8U~DZ+J36(kukuxu$;=??y=kDm+x zr_ANfQr){Rod#rnY$MGR))XBabA!|tjVp~qrx8MFXz`Zpe8{vTn+sbL{F&=6jg~;gd)~ z4HqY<;)9Xz*u5D*DZor~rl8k#s6w=n{tuxPRGga(K968UPOV=gnl~v3l&6pf#ET80lB3e38>4|_LUo+kUA({mJ zz&&Q4G@mewa|l^8yO#{1xds2NYlq76&frX*4+y&n?1}aXoSjL@9nxl^o{cSy>BHZL zg2;dnH<58V*rteEEa!!Oh^CK2lrDGiYBGg6$>}jGmQl;v+iJdvC7lMf>vd9`6Bp+^ zt3ZBt(ro2t!(aG&MKh+!!U$K&{iCZsuS@sAxAOK(!pS#W=$K9*>>)IADLUH%T3fz~ z!@oOstE$28E8&$=5kdRwXL+34J*V;kXnlDnoh+C^^GgN3czW zqt;NX#3EXHT--^fJB!6^#=8eYwjLI6oEBAxgzOn?XwuWJOUTJ!!_f~dHv2`$F(rMe zBgJFv@FSL&^Jm+9H*viSCZ4qX9pvCE8F?5>`YJMS%35BR{sdc&?P;-;01~MUmuQ?$ zV>-3xAOt#7@EzZuF)WEUfBsZ~@zcDl7uwGD4VpqW39@B(y-1o?1F@h~M-+x}O^JXd}y|Bf(SnnXgUqXOr>vEEIMV zNUM(iRU)*gO==yS`E|ei#13R=&Ys+S{s!;4%6N5Zf^L()GUPW3=CI69o%bmivD>1> zp4lH2Q@HNA_OyHY`-juOyrH+-bJC5dr4t330-pLO$2F0t5ncw;qBN$YJOcDfBDv{*(AF%|{q?oQPGygf`=0MTkAud`drW)6h6n|X!2~(TP zm5k!181lTh{j0)un>`;Ej`@q)zrAZem+gL_Y4sF;N9rvvr)Lbj9s^<~TO->h6^VU+sQ)?6WN)ea4(*yMpMa(nynYF;!1CqFLIZ+ z&oZaJb;fisz>Xyr7&iF1cRWBt&Hx(*I3daMbVtkKN)i}_+ik90xu@`sPS)6_@= zh*F-}3;7njF3bpM4zJ`Jh_I55MZyI36JtVNMXNUG+++{Z#(FcaP$(80LBBZ*>(8FzI zn41GNaY$^+`k)gtEk{UTMY^nQg}n+5e6xaA_?-m`Mud=jHZBLNu^4pnrkQBL( zEU&v}otuT6#2rY(RDJ01Sx52= z)|#}c;9dEYt>DkeqkLoQ-_)ix$<& zysX2!%ey1Cb$8r)77NA97eRB;OL+af#5eE}-etRbQ&=tg%kx4}jnzsALM5=ag~?Tl zv89tiT)U9CO-5KNHBL!Fj`f9x)f58>cX1GxKOzIYi_|G`Jr4NsQ&tQi_mmPPk(USD zUWMg8p@KbAx!!Tync#fpRQpsB%>z^p!OcSt^)m+sPmbBMss@W>7{7XD(x&~2On}}= z|3rt;t=hFiM^j}Tpx%;(M{!M|v}CAt?7NmI!>fzzXW3O}&G}IqG%DS^;nDLOD?!!W z9Y0A)1d3jHVq>HVMMhpw2IwY}bxmZ;!@$EtKF|o7GF=6werF`Up6==jcv4aFN=>LR zRJ-t1k3%p10nK)PA8qkP=dv%y7tcc^yPuX_%g718I#0%8{xu+5dOu}M2Du!hy=wqq zmc%GeBJg65U^MkTy-Vi-C0LlL33l-%M?;HICTiQ{>fncV$z3E-Ny61lIzEG)7xTH0 zXT#RNBN)-{tU-LXW$e!mVoCYF3GgIH$Y9wq!yjBJO3eUkQU|yXJpJoBHa}XL!wN0>?d_Ce z7Z9_h`{D9p8mlKQuh7Y-Gl)m=Hs2K9lfHL>9u`&dq6`;QLH@DCf{!?j&X}|Oz$u7N ztZ|mKt{(={ViPU)6wKaHyi)9fzYP7SWZT56#Dfem{JUnYg2X6wYH7gwkPYgGKe_Wy z4X+C#xjMsmq>jQq3XrTPVJO?T3}hnlNtBk>J#zu_&>)_GtB1H{muS`0_BGUTn^TDj z7qp2XPt0m*xGYhp=Rpi;hO;?@&~}oV%O}o}A7o{+)M<~4#Y-Y88kh)~e}fPk+_!aL zkEhidGF#iHW)NkEa`4i^^_%d(3py)ia28H{ z>-@rZxuU6}6#jv`-22`R*U;U+dxvu$nroungbf;b;I8e z0$H?L&R$1aD$QW+dB+ObYfj3sH4dEo6OdR7LR7a40$W$L!;jx_$G7f& zL;c*(;)(xfOT<@3?zI?Ly8nJdlvkcLV^sc^IqdD(&4Bc*lEho0>IVh}{3S_}_D5&^ zjw#>D*h7S|W?Bpx>xHYYnU65QCeOXp)jh@pd833tW1>wb!tT#AEUT0BNx?)CotU?< zTgmbjYp)T|*XZ#qN@4ni&m5S}%U$yf$fAjxtmqq^ZaYY+?9EYQOzNv04KoOa63`3% zLITn<$b&w-pql4K#>FjPzEzN^TeDAenXm-Ffi_<8+FI}~5j))$gbX}$7=CX;lRST1 zO`+2ePriHF;WTkbu5;LVJVJe+{=-nnY3K`zDh!D9Kuo(u6vu1eCT^5GyM%b(D?w=j z7}z|_i31hNO9*B(Xc;vb{$U4ZD6r^lIZ1DS+7la?smbx!FPG~)`zy6{KZNibV@OZNng%oC(C2~qDJcjpo{CE zez!z-0v(y1aA;dKYj-gVb$|9h(mtouTOqQ<<2&1`g4dt}Ahpl#Q&t*ex{;hELYioA2YF)aA6w-oWjf%s|Aa;|)UhtzgKIv4NtiVLS!9Laj97fJ;%zJ7osu=PxXI_$b>dutR%rDGHX)Rt6t zk1?UzYOCM-i84g>kGCWvq79bsuY!fmDkT5 zq+JK&vwE4Re$x!NpNegzi}3JaDu{rH5EAcNBzyS(QQ_mVTn&^_toAiYXd zX=zSZHN=WMKp0nVMls~OkKnvyMZU1V;DRWQ9wq>jah{=r-x%tMmX3BwqvT!Is7Fus z4#PfIS0B4iLUt2D;5_aCjC|;u7tw9)I#~z|j1qqWCbCNZ6aIoJxv4?&Ana zTE@O1OoiO?6Q$J|^algshame#IF-ZkiOyo#AQ)xSnvHnHv#LAjY-JG;hOsGpT{H2% zuc=~qHaJ4lZOVJsQdfYtlx*L0KSBBBeMGVoAZ=xJ2AvIDsjhx$(WGX3_z3paA0wz1YJpe)=3|s4kic=ED5pd zF=;xUjDvQYYo+gNCqG93ykBDI?ywEcotkfbv5kSe1jifNl@VDB@3O#FgYH|BY;6=% z5f`+`OK}~yhO8a1uwIqpUpr>))M)UA3(MnY6233v^GVg8~YNb#5jKz?Vo{X_E&+FWqL`rHdjmu4g%`R zEP%w;I+iT>puE(bRqcs|xik%pPdrMo_{_>J$-`Y^4D!Re>h4I&$_c;UA`L|WJaq^< z$aH8;x4Zk!`w!)W2C2-I$5{ z2W^B+FJ*G1TZAT_;CcH+D(YeC}SM6ab#_Kzt(V><*z-c8&V|9Sn@Evlre@W*W# zk6d+VaRTy1HcN_BvRTes6L=uXZx2sJl1Nd=W#HrSZ47TVC!J$$tyb~em^#zK9kLrN zqdKo7-)&KXqbKZC3rz%w(X@z$V#q<4T7rG(%O+hVK+rTI6;OYRlP;UBJ(5a4FW{Zw6^0b+HAt}NyMhXj^);uhoi2RY;b#qKc-dzjY^b3tSfiq?zzLgPs$1SV$NpH`#x>1xC^K)6(a0xA`#u&Z2OvFHf<}SLZube z0ShV^SaJ4V78uoO7mHRAr?hH(@glDqN$#O}Kyq6MUe4XN%_gagaymlG{#z2OzdPcy zK|Qpp6Nh^QqHHitO(DrTY<k6_wRxd9y`$zr=M zZ>WonuX$Ul->Q*B$b7?>&*A#V3b}_|O`Ao>elzX6g%K_`R#$tH4*KB03F=0g@qWm- zUQq?w?bdDc1fjyfFS`N*K?)Ick~PmWh+Z+t&{-_a(@OhTlvETYKkgDAu)`r#6JOXK z+sX*FhlR5YN|WI6+u*^5)|*T}1M?M^&6Jl3*bZ$@AT~(%-aF=%=Q{&?o-UJiX_SAo z9$MZja#KYzwP*$!)Tax5qdorUZfUp#T{-`qz3relY9z5>;CElP7@pL7!+$= z$}i>0aAA`MrY7hgA|B)yoDH+Ro%HqdAh#R}4HCo|h&LZUc z5(A8nDUUzZ3$(D_FwHfht_FAev{;}SUF}lC5(UyZ!fLqxiqLwPhS+c?P8w^&I@Vm6 zi2B@3KSm_knkLvWwW?B=zyk&9^pwqIZAUt?o{RUl+~e-q7;XMliNQIzZlnANdI6=z&Wl<|Sdlm@E2-&l2h#9RO#yw7af!me$^kf$NJ7wqM9) znRya8MS<6$l#XYWg}?1LUrD}@tlV|wmZxJbnAGJ6^uGV$K!Ld_plW4d)%`&%^zgZK zA{(WuTwTi=PRLok)55*SPXV9a}QVR6HHiyzKg4f>}ygX@S(`!k}X6wT56=lNbf}QIN#dfzbG3DIyExL?;1?j z+YiFi*UrXrXx#x^8S zh3E0H5Hqr{X?i$Pi9OHWA;GAR# z&E2nUM^Q1{+4f-XI2ZHD}8gSUQ+;0noS3 zCTWwRZjq>0#Y~<@;7BQx_s;6c(~{g$)tP9o#BJT+3iO62Dy-9D6ou~`d(nD9p8Ae1Oq=`w z@!PDbd{|!<>53P77Zavg@|LE2JWyEPXd@g;krwRaS~28rfw6urg?X08di5#z9Rd&+ zwQ$6*y%~lpG`a1K$b;SCo- z;e5$b`&MUu2G<8Xya!C!x=tTg+6kMb-uXpUTcUEUI<;<4TBtfOLrr z-7y6W5|R?qAT83}3|#^ek_yrxjdXWNNq4s}fYK->Ao?3T_nf16?)}}nAO4uV=H2`K z?)9#BZFqRrXB9~pqh{}O?5JLoDQpq3=sDTA7MMG|*C90(p-Ylm+*LUw7T>;d^CDyM zmdwJ}rWMTU+)wTY(;vt&=bPP`V!Oxe&G4JOw!8FI43bCH(5v@hq_e$_IOx%AJ%=po z6(d}>#KHGT$s+auGmC9h@Th`&bh}ltnerXDmLGDIRC^c95Tni`VcH%FI}t8QVfCcS zn$zne8LUFgD6rS~irDg{(+kSWf?Oick|c^MYm4gY0biG2E|B-#Zr++kzm3;FM>2%i zex;`jUXCCLVT}?86d&VSjFd~+}TBu0<5K-x_BrPI>vn@@n ztKBNSc@T0tSw@lU3m9s&Xxtc!SGGYK^ogkE8@tCFrNBtE#plJzD`+`wcJH?^SHKPT z6IVa_Dfnz5{{kD7bH&`iyQA`k;^l@01l5J?Saq2ZEPe7KYM<}TvyIktRVf4$g!<-t z8Z^mbh+IL^#0hS1UbbB9KrWZC-^_}(blsS!Hprk<@F`mhzoG*rIgfzILzdk`9jw%2UpZa43Aru(cy(~*j^0l;ScdfjwIyS)rqt$BO3f3kh5Vumn{xPEtdfNEs1#KNZ47VGXizlgLw3=y?DG$77wgwiqWEYiTq6-`$ zaS0pk*#1YBFnQ1U1Cyvuxu;bo&OxC|>lX}bP0f?CBL81W07j0oFes#qOD17{)H{ z5w9iclPx!-4M$Rnl%^jA*vvR{lHBSqH$dQBpW&e!;YmSyV90(613(*qAkX_H#s$u}A5&_0tn4$vYK<*aI?mswvb zxtc@{4)5cVqQU0o)qVmX^`D>rCEuY%mJV7qyW*FKS{MhR?H4Dc4{2 z)UowrCyY4RSJ4XqPUDDuPTPcL@Qz2+G396CIH}3*nq>EIe|~?<*xxMy-oiVqY^)O` zxt4`ztUlzl5m~2N6si&^IdAA!8h3&2b;ix;qFsNYrJ8m>^+V${qV4e8F01BIt)5C_ z!00P|7Dm9$m*OcXY$?=q04+ClJ}aRP z(KDwQxn!w&Aq4mn;10qBWa7A1E7SXFm#vE<2~K?|-YzSYlG*ZQ#~Dq`8$n3dD->LY z#9Xkx7?!ID7~)_YQ*5@{FO811CIBh4hlJf<|8mNjliRv%<00*K?VyXwyHx;MMZKI| z@OIwGrx3i%zrY`U>N4E#a*J4-ci{2t!r4}7M>fZTMD14+dUTX*rO%afHiAT$kaq>! zMHap)pYO+HGgUnodF0|J*6nZ(4^4euFm4$T%#120w=Fjia8#OC_9cv+8?Lg>QSfYF z%ev3$6N>cnBGui;iJ$IAI#6ihif|4Y2?O1@V~ch)CEgE@Pzj~-)Vm6o=Nr<8+`vkm z=i&J3EJWgd7csdmhc)8k?>_Vkz zW1g{GaePpJKLPakY9sT4kw5n!koSV?}}{Ftpu(d=eQ^N9YdY;(+k zw5DXLyw~1YIAwzfRbQWHjo-{0WPIi3VKxG;y3%cUY-2ijYOPq0J?j;#4 zC>Dy+q`(@bNU65s>+9PBaD6nkJFk6y;O*4nw8&8%e{Kp-Y$mIYdC4zO_Vt5ES$#4M z*(gZ-)z&8K0kKu1j~C^4@jQJ#nNvr}di$HP(B1Iz2$9qD|r0ctM|_8Z=!y0@cU zTXu`3pMB|j@7m|h>n73D-)c>a*DHH9!zL=u7PSZU$M}tm66krx-|ys{ zX|owQsHGjI0o8WYw-rb*uO!`hpx`g66z|85@*>_<)N4TWBspm=tnzd9?rO?60OLSu zlP=4vgM0Fh?P=1C*Kbu%CGyV~tK}wWr@e3v2YDnsO;#8ne;HR#;zcxfmw`>8B^5#R`Y#0jCQ&Vl4;ZtAXEv-kNV!mzJ5oKVDWf&+Dag*zTyL zlKb{8s&|dWZ=9-AQ^=>ElIq4w-v^xwh4p6VrLSj>DehG~R;?p42s7S2<(j%jB;V}L zJT-#e>gJ}QoK8et4m%A{xRJSxEA3uxi_s0PvtH=74?H@s%U^B6lOeu!LoVbovjeW6 z=hSzo^X z)ScK}ksL+Fe8ezgY#zN-J?Z)3Uc(lu(sunfGNF~RHiCJ$F?0OcNRfewz~0@@_Q{BQ zs3is$+pqNwKWqz358{|}HT&K6{J19iX7%wMPaZ~-lrpqQAz9&90!!P5n0H^V7oH6) z{p&hF+^U-W+sVgzB+Tzr;X8ZUJZ|1^-?wjXp|*#iq25r8 zJMv_*6+NjEsyYy~pVhPpKfYhyIF(zjDb=0LZ{s;_#M{-duEbavmOx0=!MUMc&65F@ z#nNS{g+uRgJiVnuvD$O4OrFqzHHYU#b>yKIjEZ&-57`>gwU|V>H<+OaLCX_YUe{q^ zjaR_%bxe+wP%QY_4pxyo5glffQ4odqlkK_^RUU)058azFV!|sgdm$wz*VA1#n{_!( zSRVG`S{boxpWHoA1V;B-!j#$i0+TK7&$oMoA_ZJLIvZN-*Y^8p@QT zD+Rq49*+9>uz53CDuZ*VQ*iUgmfrpLJM7M6i)yM4XE*8vUhjcSiB9Q+ zg~^A{Z>_U@cFa;ZO^sqNpcfy;AP~-{g$2`m7T7yfr7=p;9ZPl_({Fxp!=g>$bq*r1 z(QmLn6KyB~M}DRF$vj5dY7Xo!es1Pu#zX*AWg~B5*>hMuUoRT{c3ap8Eu%991Aa}n zUz!zr?Jnn8*m@DBKN)u0#Sl?sMq?+=(&v?4x%8M>pYI)S(&E{+lRsG4vFQbJ%O~2a zNl%u`eMepTK37v^SiwXg80Znv&ke(4Xk*!~^rDB+6F$c&ip+Co1PZ&n1N9Zor5Kqt z-<2Z4s>TWY_$Ex`5xE!R0Po(CtOD(w1{{sn#Rht{u?74GAe>lrDS^yZFVoje*}mwS zEOC5^iMn947b@%nGuN^qZ`?Z#NY>xdXej6kvmG5%)>P}P2-;3Hn~y=4XGFViM~k#AIUs|fY)@k{8oTvL zrd3=243@mEU5d6W-%Y~cz%OJP$E+%-I`YS;dV3to4pxrO8pmB2##dan8#OcDmz|vp zF+Cks3W8c^QH8{kc2PS_t%o(+bzd7HP}knu0GE?k%&q4aw$?#o zZU|&A?m>``uIns^kT{nIAv&z8f$WUaOS z&Nz%WA$+$8J#rb>WyJhi<$EmimF6mISU|>)Hmuq6vlEJxOkD4IqtGo8659+XpTitW zbYz9o%wsxvQs!kj`S#b`fc4tuoZ$LwsaoF%Ojq`=Q64@bRwv~#?Lnl3J)%t1w|Qy} zR&ZGg5n|t+D)BiK^AjnQo+Rb^SFJYOyd$xB7%tN*tnFUPa3Iz@M7zZ2J~!GoVBH28 zf8XaaQ#xac$h08pCB;g67&-WbfXs5OM-$*p)8cxDSrGVbZznV`x^Zx8?1_^Z7 zxSUMP{+Ykxn3sO+DekW8J!5(6TtO-NH$jvc8(#iyok=~-Z6X~{yD$w?9&A(=z&v^lYOe;?A&$x_QIMpSBH-<5aD0yJE-VYwK;t&A4wBOVA9 z`qauNF7d#lrs}SPI4{q-6+!{rnl&DA9 zrXRGcmY*DMFJ$BtlcOS8I;{CnBXhXR!qHvqE{MCUXj4Xkhxg^~`+Gy_8^zpy&CRt8 zcjd2{Eg!m8Ww6{a{i^2b5ann)S4U)cSDytRF5G;PQUl zZD8PmmgOL@#7v^0tJ7mcF_s)%l?C58JeaiTpIeT>(K&wQHg3}KUg}Gc z)XSoly=Y63aEwnfItl}0xc&VeVpf()FN{ugPE0b^5{|Tos9^TwQ#AG(LM5T$omsMm z!(CSK7D3@C#29JzWLxP==dbKuq<9zGirTVpCKU`bdnlfgt$#2vH`yjhPbL3&&GsJR zj`HNkw|R7gjQcY^oln5WPXVJ7LpI3_c)Gh|%emj^m08h~$>|iqKzx#uReLl- zHkWu$$@Tl)L%hxEHYS3vnhH$mZel#YJ7*ND{@5~NV}-&SbWeDbE|r?wA3c&>p|bis zWK&1k{RubIjlv8^?p*S2Pd65Zn|rdsKC83m_FIg47%7R$DrjkRwI2t{J`WfscoF-2 zGTY~U-{50Q=RHsDHL#GXpXwmW7G6ywd{IQ}ge}&X_S$VGNuBDg+y$Es6}-x>l!QhWagnmK&y@8PleRy9bzn zHzSm^do^WRSOZ1A;&IroV^DW5c}@D3&3nR4y`s|%87Jr@Zz6Q3M3d=mK3tQvhlpr} zqA0BgFzwbSWk-w3;4lNM2wl=Q8haE8`Kg#w4Y&k}eR=3c9nSlAlix)j2dDQ=a6aqA zHN;VbcaPU7!>v{$jKkHfFrOffZpU`gym)Zu@!9CBs<^?3P7e8#WT};1-D1{ZUpp1f zt_QL5C(zyxsVPGzlw+yh`s5r<*Ylq?wlS?8sQCmotjVE484Y9g(`4Z_ETm5D;$&ABDb^g0$L-FR6O3j+ea(^uutF!O~ zT+S)P>43~cZdX%qdElEW(_S0u#y$LcK?k{v=e*=O9aO`mbYeBgXYqF?~#rxn?!cEKQFncEVeJO}`6=T)$y@ z%E$3h+t@Z&LjHZy*46|O`-gWKfHcQAD%WsPLqDSXwT6BB=-Hyozrbtm(f^*YCI5n$ z#+;mj4s~CQ(!VQ&mk+g9 zTO7|Jc_besp&@}W(qe}8K@sof}xlU#iH!pNhK+r+sRA&ctS_ZGW=opl@s_9 zI{B}QVTVoOmgthko#Ag8#XJ@bV>x;iVda(dNKM#%JZ*!w)U#iw>*=AsO*}kKpr+HE z6>GkQ!-56aA9rGTA%UzB*%~8J^ftvG3I$p z6AY2*!X*O1a`JH0{3^z8F37ZikC}W|7HGTRpC}u_o{W2LLgPaG&d7FDLc|h&A<*X) zy@wr}wTDGoZ$TTXejMQ6CblfBnrSh4!>?pp)jj4F&ce!ecZo1u+|fbkIJ<>?GYyC2 zJuOE-iBDR?zU1P*9Th3xfKeMoTiG3cq3H~V*eTJC=PCvaIq}gru9C6kRa`1@eLD2` z6q>JYK8O&}r%^#Y6ToTeO{bwdnJ*!yj3C~;T_wUyaF3A}Cl>QYdORX7mrJp<#x6A3 zkj3XqfRj!SXg7yIgPt_()XVZKtFHx9L0c}jo~mP@A4E;n96WrR_M&V^(3Bz{OJOI> z-hGfVR)EVY-jLOXF}%N2TrXaB#~*Z~qLJlRJ!VZn$f;EDgqszx+A7rp`eDLiBYk6`w+?z?Of*rkyZB7 z?|AvNq80y8ehK@D)b{^j=^jXnNy;f-mS3v=oAS%c>PsZ;6pDnn@xXq9((wS1Y}21; ztCy#L(N;kqB|}0bWc)XmT;J&uO|EZf>1d_zXomdc@B>tC{DS~~i7ZE=!I8k&|41*lwX(HAg3GO~ z^^ujK{|;Gh%4OEK$q0upSAp4Q~O_Pc_<~PEc-*tWpH1Sa#^MP zs}$tq|0o4`xubrT^3Mg%|H&;Xni3My@<=JlmsH~`O8&V0Pfmd#(Zv6#1jKzs$v-0~ z|C5qm`waZ5|55@*p8TogkC+k?0vOvEAq8Olb1ME%%X6h3{)&*_ zVixkV5+De<A{MapkM3;tz!K!1A$blC>u=j{Xhy)TBMzNxVz z@_k|pM2Qb?inW!3TZ~!?W+?-%!O~2S>0!Jn)W~BAcQ)H?YM`m>Zvp7G98_3HI zK{nvv0|FsHE#wF}TcdyfrK*Fzot?1}fJ;)}%F!69O;tjJQxa}vWuR|kb2+`LnYkkX z`SXVi0Nl~s#uQ*>ZeV9?XJ=*Xzz%qH+1tX_1_0(n&Ig5o{-u-y#0dg0s~a1D!~ndU zP);5efTf*2GHn{`1DyZ5RWBKoB4ARV_d;1a{T;AS7)5 zs{cR`2=~=Fz(8Ie5uzBlldMhy%0*czH#5k&DU)76Xbx zMIbzUKv5p3C`eoqBqkyOgGmSh{{JDm03jhPM<;y;ryqNokDCYCIEsNmLO~Mi{{V)7 BpppOp literal 0 HcmV?d00001 diff --git a/elpa/org-plus-contrib-20170407/orgtbl-sqlinsert.el b/elpa/org-plus-contrib-20170407/orgtbl-sqlinsert.el new file mode 100644 index 00000000..8fba18f4 --- /dev/null +++ b/elpa/org-plus-contrib-20170407/orgtbl-sqlinsert.el @@ -0,0 +1,118 @@ +;;; orgtbl-sqlinsert.el --- orgtbl to SQL insert statements. + +;; Copyright (C) 2008-2017 Free Software Foundation + +;; Author: Jason Riedy +;; Keywords: org, tables, sql + +;; This file is not part of GNU Emacs. + +;; 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 . + +;;; Commentary: + +;; Converts an orgtbl to a sequence of SQL insertion commands. +;; Table cells are quoted and escaped very conservatively. + +;;; Code: + +(defun orgtbl-to-sqlinsert (table params) + "Convert the orgtbl-mode TABLE to SQL insert statements. +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. + +Names and strings are modified slightly by default. Single-ticks +are doubled as per SQL's standard mechanism. Backslashes and +dollar signs are deleted. And tildes are changed to spaces. +These modifications were chosed for use with TeX. See +ORGTBL-SQL-STRIP-AND-QUOTE. + +Supports all parameters from ORGTBL-TO-GENERIC. New to this function +are: + +:sqlname The name of the database table; defaults to the name of the + target region. + +:nowebname If not nil, used as a wrapping noweb fragment name. + +The most important parameters of ORGTBL-TO-GENERIC for SQL are: + +:splice When set to t, return only insert statements, don't wrap + them in a transaction. Default is nil. + +:tstart, :tend + The strings used to begin and commit the transaction. + +:hfmt A function that gathers the quoted header names into a + dynamically scoped variable HDRLIST. Probably should + not be changed by the user. + +The general parameters :skip and :skipcols have already been applied when +this function is called." + (let* (hdrlist + (alignment (mapconcat (lambda (x) (if x "r" "l")) + org-table-last-alignment "")) + (nowebname (plist-get params :nowebname)) + (breakvals (plist-get params :breakvals)) + (firstheader t) + (*orgtbl-default-fmt* 'orgtbl-sql-strip-and-quote) + (params2 + (list + :sqlname (plist-get params :sqlname) + :tstart (lambda () (concat (if nowebname + (format "<<%s>>= \n" nowebname) + "") + "BEGIN TRANSACTION;")) + :tend (lambda () (concat "COMMIT;" (if nowebname "\n@ " ""))) + :hfmt (lambda (f) (progn (if firstheader (push f hdrlist) ""))) + :hlfmt (lambda (&rest cells) (setq firstheader nil)) + :lstart (lambda () (concat "INSERT INTO " + sqlname "( " + (mapconcat 'identity (reverse hdrlist) + ", ") + " )" (if breakvals "\n" " ") + "VALUES ( ")) + :lend " );" + :sep " , " + :hline nil + :remove-nil-lines t)) + (params (org-combine-plists params2 params)) + (sqlname (plist-get params :sqlname))) + (orgtbl-to-generic table params))) + +(defun orgtbl-sql-quote (str) + "Convert single ticks to doubled single ticks and wrap in single ticks." + (concat "'" (mapconcat 'identity (split-string str "'") "''") "'")) + +(defun orgtbl-sql-strip-dollars-escapes-tildes (str) + "Strip dollarsigns and backslash escapes, replace tildes with spaces." + (mapconcat 'identity + (split-string (mapconcat 'identity + (split-string str "\\$\\|\\\\") + "") + "~") + " ")) + +(defun orgtbl-sql-strip-and-quote (str) + "Apply ORGBTL-SQL-QUOTE and ORGTBL-SQL-STRIP-DOLLARS-ESCAPES-TILDES +to sanitize STR for use in SQL statements." + (cond ((stringp str) + (orgtbl-sql-quote (orgtbl-sql-strip-dollars-escapes-tildes str))) + ((sequencep str) (mapcar 'orgtbl-sql-strip-and-quote str)) + (t nil))) + +(provide 'orgtbl-sqlinsert) + +;;; orgtbl-sqlinsert.el ends here diff --git a/elpa/org-plus-contrib-20150831/ox-ascii.el b/elpa/org-plus-contrib-20170407/ox-ascii.el similarity index 85% rename from elpa/org-plus-contrib-20150831/ox-ascii.el rename to elpa/org-plus-contrib-20170407/ox-ascii.el index 5cc70bda..2a129e9d 100644 --- a/elpa/org-plus-contrib-20150831/ox-ascii.el +++ b/elpa/org-plus-contrib-20170407/ox-ascii.el @@ -1,6 +1,6 @@ -;;; ox-ascii.el --- ASCII Back-End for Org Export Engine +;;; ox-ascii.el --- ASCII Back-End for Org Export Engine -*- lexical-binding: t; -*- -;; Copyright (C) 2012-2015 Free Software Foundation, Inc. +;; Copyright (C) 2012-2017 Free Software Foundation, Inc. ;; Author: Nicolas Goaziou ;; Keywords: outlines, hypermedia, calendar, wp @@ -27,18 +27,18 @@ ;;; Code: -(eval-when-compile (require 'cl)) (require 'ox) (require 'ox-publish) +(require 'cl-lib) (declare-function aa2u "ext:ascii-art-to-unicode" ()) ;;; Define Back-End ;; -;; The following setting won't allow to modify preferred charset +;; The following setting won't allow modifying 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 +;; will appear in communication channel nonetheless, it allows +;; overriding `org-ascii-charset' variable on the fly by the ext-plist ;; mechanism. ;; ;; We also install a filter for headlines and sections, in order to @@ -93,7 +93,6 @@ (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" @@ -189,7 +188,7 @@ This margin is applied on both sides of the text." This margin applies to top level list only, not to its sub-lists." :group 'org-export-ascii - :version "25.1" + :version "26.1" :package-version '(Org . "8.3") :type 'integer) @@ -370,7 +369,7 @@ Otherwise, place it right after it." :type 'string) (defcustom org-ascii-format-drawer-function - (lambda (name contents width) contents) + (lambda (_name contents _width) contents) "Function called to format a drawer in ASCII. The function must accept three parameters: @@ -512,7 +511,7 @@ that is according to the widest non blank line in CONTENTS." ;; possible. (save-excursion (while (not (eobp)) - (unless (org-looking-at-p "[ \t]*$") + (unless (looking-at-p "[ \t]*$") (end-of-line) (let ((column (current-column))) (cond @@ -525,8 +524,8 @@ that is according to the widest non blank line in CONTENTS." (if (eq how 'right) 1 2)))) (if (zerop offset) (throw 'exit contents) (while (not (eobp)) - (unless (org-looking-at-p "[ \t]*$") - (org-indent-to-column offset)) + (unless (looking-at-p "[ \t]*$") + (indent-to-column offset)) (forward-line))))) (buffer-string)))))))) @@ -550,23 +549,24 @@ INFO is a plist used as a communication channel." (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) + (pcase (org-element-type element) ;; Elements with an absolute width: `headline' and `inlinetask'. - (inlinetask (plist-get info :ascii-inlinetask-width)) - (headline + (`inlinetask (plist-get info :ascii-inlinetask-width)) + (`headline (- (plist-get info :ascii-text-width) (let ((low-level-rank (org-export-low-level-p element info))) (if low-level-rank (* low-level-rank 2) (plist-get info :ascii-global-margin))))) ;; Elements with a relative width: store maximum text width in ;; TOTAL-WIDTH. - (otherwise + (_ (let* ((genealogy (org-element-lineage element nil t)) ;; 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)) + (if (cl-some (lambda (parent) + (eq (org-element-type parent) 'inlinetask)) + genealogy) (plist-get info :ascii-inlinetask-width) ;; No inlinetask: Remove global margin from text width. (- (plist-get info :ascii-text-width) @@ -585,19 +585,20 @@ INFO is a plist used as a communication channel." (- total-width ;; Each `quote-block' 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 verse-block)) - count parent) - 2 (plist-get info :ascii-quote-margin)) + (+ (* (cl-count-if (lambda (parent) + (memq (org-element-type parent) + '(quote-block verse-block))) + genealogy) + 2 + (plist-get info :ascii-quote-margin)) ;; Apply list margin once per "top-level" plain-list ;; containing current line - (* (let ((count 0)) - (dolist (e genealogy count) - (and (eq (org-element-type e) 'plain-list) - (not (eq (org-element-type (org-export-get-parent e)) - 'item)) - (incf count)))) + (* (cl-count-if + (lambda (e) + (and (eq (org-element-type e) 'plain-list) + (not (eq (org-element-type (org-export-get-parent e)) + 'item)))) + genealogy) (plist-get info :ascii-list-margin)) ;; Text width within a plain-list is restricted by ;; indentation of current item. If that's the case, @@ -605,9 +606,9 @@ INFO is a plist used as a communication channel." ;; parent item, if any. (let ((item (if (eq (org-element-type element) 'item) element - (loop for parent in genealogy - when (eq (org-element-type parent) 'item) - return parent)))) + (cl-find-if (lambda (parent) + (eq (org-element-type parent) 'item)) + genealogy)))) (if (not item) 0 ;; Compute indentation offset of the current item, ;; that is the sum of the difference between its @@ -634,9 +635,9 @@ Return value is a symbol among `left', `center', `right' and (let (justification) (while (and (not justification) (setq element (org-element-property :parent element))) - (case (org-element-type element) - (center-block (setq justification 'center)) - (special-block + (pcase (org-element-type element) + (`center-block (setq justification 'center)) + (`special-block (let ((name (org-element-property :type element))) (cond ((string= name "JUSTIFYRIGHT") (setq justification 'right)) ((string= name "JUSTIFYLEFT") (setq justification 'left))))))) @@ -712,7 +713,7 @@ possible. It doesn't apply to `inlinetask' elements." (char-width under-char)) under-char)))))))) -(defun org-ascii--has-caption-p (element info) +(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'." @@ -734,9 +735,9 @@ caption keyword." (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:")) + (pcase (org-element-type element) + (`table "Table %d:") + (`src-block "Listing %d:")) info))) (org-ascii--fill-string (concat (format title-fmt reference) @@ -807,7 +808,7 @@ generation. INFO is a plist used as a communication channel." ;; filling (like contents of a description list item). (let* ((initial-text (format (org-ascii--translate "Listing %d:" info) - (incf count))) + (cl-incf count))) (initial-width (string-width initial-text))) (concat initial-text " " @@ -847,7 +848,7 @@ generation. INFO is a plist used as a communication channel." ;; filling (like contents of a description list item). (let* ((initial-text (format (org-ascii--translate "Table %d:" info) - (incf count))) + (cl-incf count))) (initial-width (string-width initial-text))) (concat initial-text " " @@ -868,78 +869,105 @@ 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 - ;; Normalize description in footprints. - (cons (org-element-property :raw-link link) - (let ((contents (org-element-contents link))) - (and contents - (replace-regexp-in-string - "[ \r\t\n]+" " " - (org-trim - (org-element-interpret-data contents)))))))) - ;; 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))) + ;; Return LINK if it wasn't referenced so far, or nil. + ;; Update SEEN links along the way. + (lambda (link) + (let ((footprint + ;; Normalize description in footprints. + (cons (org-element-property :raw-link link) + (let ((contents (org-element-contents link))) + (and contents + (replace-regexp-in-string + "[ \r\t\n]+" " " + (org-trim + (org-element-interpret-data contents)))))))) + ;; 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))))) + (org-element-map (if (eq (org-element-type element) 'section) + element + ;; In a headline, only retrieve links in title + ;; and relative section, not in children. + (list (org-element-property :title element) + (car (org-element-contents element)))) + 'link unique-link-p info nil 'headline t))) + +(defun org-ascii--describe-datum (datum info) + "Describe DATUM object or element. +If DATUM is a string, consider it to be a file name, per +`org-export-resolve-id-link'. INFO is the communication channel, +as a plist." + (pcase (org-element-type datum) + (`plain-text (format "See file %s" datum)) ;External file + (`headline + (format (org-ascii--translate "See section %s" info) + (if (org-export-numbered-headline-p datum info) + (mapconcat #'number-to-string + (org-export-get-headline-number datum info) + ".") + (org-export-data (org-element-property :title datum) info)))) + (_ + (let ((number (org-export-get-ordinal + datum info nil #'org-ascii--has-caption-p)) + ;; If destination is a target, make sure we can name the + ;; container it refers to. + (enumerable + (org-element-lineage datum '(headline paragrah src-block table) t))) + (pcase (org-element-type enumerable) + (`headline + (format (org-ascii--translate "See section %s" info) + (if (org-export-numbered-headline-p enumerable info) + (mapconcat #'number-to-string number ".") + (org-export-data + (org-element-property :title enumerable) info)))) + ((guard (not number)) + (org-ascii--translate "Unknown reference" info)) + (`paragraph + (format (org-ascii--translate "See figure %s" info) number)) + (`src-block + (format (org-ascii--translate "See listing %s" info) number)) + (`table + (format (org-ascii--translate "See table %s" info) number)) + (_ (org-ascii--translate "Unknown reference" info))))))) (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))))) + (let* ((type (org-element-property :type link)) + (description (org-element-contents link)) + (anchor (org-export-data + (or description (org-element-property :raw-link link)) + info))) (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) - (if (org-export-numbered-headline-p dest info) - (mapconcat #'number-to-string - (org-export-get-headline-number dest info) ".") - (org-export-data (org-element-property :title dest) info))))) - width info) "\n\n"))) + ((member type '("coderef" "radio")) nil) + ((member type '("custom-id" "fuzzy" "id")) + ;; Only links with a description need an entry. Other are + ;; already handled in `org-ascii-link'. + (when description + (let ((dest (if (equal type "fuzzy") + (org-export-resolve-fuzzy-link link info) + (org-export-resolve-id-link link info)))) + (concat + (org-ascii--fill-string + (format "[%s] %s" anchor (org-ascii--describe-datum 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) ;; Do not add a link already handled by custom export ;; functions. - ((let ((protocol (nth 2 (assoc type org-link-protocols))) - (path (org-element-property :path link))) - (and (functionp protocol) - (funcall protocol (org-link-unescape path) anchor 'ascii))) - nil) + ((org-export-custom-protocol-maybe link anchor 'ascii) nil) (t (concat (org-ascii--fill-string @@ -952,10 +980,10 @@ channel." "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 "☒ " "[-] "))))) + (pcase (org-element-property :checkbox item) + (`on (if utf8p "☑ " "[X] ")) + (`off (if utf8p "☐ " "[ ] ")) + (`trans (if utf8p "☒ " "[-] "))))) @@ -1078,7 +1106,8 @@ holding export options." ;; full-fledged definitions. (org-trim (let ((def (nth 2 ref))) - (if (eq (org-element-type def) 'org-data) + (if (org-element-map def org-element-all-elements + #'identity info 'first-match) ;; Full-fledged definition: footnote ID is ;; inserted inside the first parsed ;; paragraph (FIRST), if any, to be sure @@ -1138,7 +1167,7 @@ INFO is a plist used as a communication channel." ;;;; Bold -(defun org-ascii-bold (bold contents info) +(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." @@ -1147,7 +1176,7 @@ contextual information." ;;;; Center Block -(defun org-ascii-center-block (center-block contents info) +(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." @@ -1158,7 +1187,7 @@ holding contextual information." ;;;; Clock -(defun org-ascii-clock (clock contents info) +(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." @@ -1176,7 +1205,7 @@ information." ;;;; Code -(defun org-ascii-code (code contents info) +(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." @@ -1198,7 +1227,7 @@ holding contextual information." ;;;; Dynamic Block -(defun org-ascii-dynamic-block (dynamic-block contents info) +(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." @@ -1207,7 +1236,7 @@ holding contextual information." ;;;; Entity -(defun org-ascii-entity (entity contents info) +(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." @@ -1218,7 +1247,7 @@ contextual information." ;;;; Example Block -(defun org-ascii-example-block (example-block contents info) +(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--justify-element @@ -1229,7 +1258,7 @@ CONTENTS is nil. INFO is a plist holding contextual information." ;;;; Export Snippet -(defun org-ascii-export-snippet (export-snippet contents info) +(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) @@ -1238,7 +1267,7 @@ CONTENTS is nil. INFO is a plist holding contextual information." ;;;; Export Block -(defun org-ascii-export-block (export-block contents info) +(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") @@ -1248,7 +1277,7 @@ CONTENTS is nil. INFO is a plist holding contextual information." ;;;; Fixed Width -(defun org-ascii-fixed-width (fixed-width contents info) +(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--justify-element @@ -1266,7 +1295,7 @@ CONTENTS is nil. INFO is a plist holding contextual information." ;;;; Footnote Reference -(defun org-ascii-footnote-reference (footnote-reference contents info) +(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))) @@ -1281,51 +1310,55 @@ 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)) + (let* ((low-level (org-export-low-level-p headline info)) (width (org-ascii--current-text-width headline info)) + ;; Export title early so that any link in it can be + ;; exported and seen in `org-ascii--unique-links'. + (title (org-ascii--build-title headline info width (not low-level))) ;; Blank lines between headline and its contents. ;; `org-ascii-headline-spacing', when set, overwrites ;; original buffer's spacing. (pre-blanks - (make-string - (or (car (plist-get info :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)))))) + (make-string (or (car (plist-get info :ascii-headline-spacing)) + (org-element-property :pre-blank headline) + 0) + ?\n)) + (links (and (plist-get info :ascii-links-to-notes) + (org-ascii--describe-links + (org-ascii--unique-links headline info) width info))) + ;; Re-build contents, inserting section links at the right + ;; place. The cost is low since build results are cached. + (body + (if (not (org-string-nw-p links)) contents + (let* ((contents (org-element-contents headline)) + (section (let ((first (car contents))) + (and (eq (org-element-type first) 'section) + first)))) + (concat (and section + (concat (org-element-normalize-string + (org-export-data section info)) + "\n\n")) + links + (mapconcat (lambda (e) (org-export-data e info)) + (if section (cdr contents) contents) + "")))))) ;; Deep subtree: export it as a list item. - (if low-level-rank - (concat - ;; Bullet. - (let ((bullets (cdr (assq (plist-get info :ascii-charset) - (plist-get info :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)) + (if low-level + (let* ((bullets (cdr (assq (plist-get info :ascii-charset) + (plist-get info :ascii-bullets)))) + (bullet + (format "%c " + (nth (mod (1- low-level) (length bullets)) bullets)))) + (concat bullet title "\n" pre-blanks + ;; Contents, indented by length of bullet. + (org-ascii--indent-string body (length bullet)))) ;; Else: Standard headline. - (concat - (org-ascii--build-title headline info width 'underline) - "\n" pre-blanks - (concat (when (org-string-nw-p links) links) contents)))))) + (concat title "\n" pre-blanks body))))) ;;;; Horizontal Rule -(defun org-ascii-horizontal-rule (horizontal-rule contents info) +(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." @@ -1342,7 +1375,7 @@ information." ;;;; Inline Src Block -(defun org-ascii-inline-src-block (inline-src-block contents info) +(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." @@ -1353,7 +1386,7 @@ contextual information." ;;;; Inlinetask (defun org-ascii-format-inlinetask-default - (todo type priority name tags contents width inlinetask info) + (_todo _type _priority _name _tags contents width inlinetask info) "Format an inline task element for ASCII export. See `org-ascii-format-inlinetask-function' for a description of the parameters." @@ -1408,7 +1441,7 @@ holding contextual information." ;;;; Italic -(defun org-ascii-italic (italic contents info) +(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." @@ -1428,12 +1461,12 @@ contextual information." ;; First parent of ITEM is always the plain-list. Get ;; `:type' property from it. (org-list-bullet-string - (case list-type - (descriptive + (pcase list-type + (`descriptive (concat checkbox (org-export-data (org-element-property :tag item) info) ": ")) - (ordered + (`ordered ;; Return correct number for ITEM, paying attention to ;; counters. (let* ((struct (org-element-property :structure item)) @@ -1445,7 +1478,7 @@ contextual information." (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))) + (_ (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 @@ -1467,7 +1500,7 @@ contextual information." ;;;; Keyword -(defun org-ascii-keyword (keyword contents info) +(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." @@ -1479,21 +1512,21 @@ information." (org-ascii--justify-element (let ((case-fold-search t)) (cond - ((org-string-match-p "\\" value) + ((string-match-p "\\" value) (let ((depth (and (string-match "\\<[0-9]+\\>" value) (string-to-number (match-string 0 value)))) - (localp (org-string-match-p "\\" value))) + (localp (string-match-p "\\" value))) (org-ascii--build-toc info depth keyword localp))) - ((org-string-match-p "\\" value) + ((string-match-p "\\" value) (org-ascii--list-tables keyword info)) - ((org-string-match-p "\\" value) + ((string-match-p "\\" value) (org-ascii--list-listings keyword info)))) keyword info))))) ;;;; Latex Environment -(defun org-ascii-latex-environment (latex-environment contents info) +(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." @@ -1505,7 +1538,7 @@ information." ;;;; Latex Fragment -(defun org-ascii-latex-fragment (latex-fragment contents info) +(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." @@ -1515,7 +1548,7 @@ information." ;;;; Line Break -(defun org-ascii-line-break (line-break contents info) +(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) @@ -1538,24 +1571,33 @@ INFO is a plist holding contextual information." ;; Do not apply a special syntax on radio links. Though, use ;; transcoded target's contents as output. ((string= type "radio") desc) - ;; 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))) - (if number - (if (atom number) (number-to-string number) - (mapconcat #'number-to-string number ".")) - ;; Unnumbered headline. - (when (eq 'headline (org-element-type destination)) - (format "[%s]" - (org-export-data - (org-element-property :title destination) - info))))))))) + ((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)))) + (pcase (org-element-type destination) + ((guard desc) + (if (plist-get info :ascii-links-to-notes) + (format "[%s]" desc) + (concat desc + (format " (%s)" + (org-ascii--describe-datum destination info))))) + ;; External file. + (`plain-text destination) + (`headline + (if (org-export-numbered-headline-p destination info) + (mapconcat #'number-to-string + (org-export-get-headline-number destination info) + ".") + (org-export-data (org-element-property :title destination) info))) + ;; Handle enumerable elements and targets within them. + ((and (let number (org-export-get-ordinal + destination info nil #'org-ascii--has-caption-p)) + (guard number)) + (if (atom number) (number-to-string number) + (mapconcat #'number-to-string number "."))) + ;; Don't know what to do. Signal it. + (_ "???")))) (t (let ((raw-link (org-element-property :raw-link link))) (if (not (org-string-nw-p desc)) (format "[%s]" raw-link) @@ -1566,7 +1608,7 @@ INFO is a plist holding contextual information." ;;;; Node Properties -(defun org-ascii-node-property (node-property contents info) +(defun org-ascii-node-property (node-property _contents _info) "Transcode a NODE-PROPERTY element from Org to ASCII. CONTENTS is nil. INFO is a plist holding contextual information." @@ -1629,7 +1671,7 @@ INFO is a plist used as a communication channel." ;;;; Planning -(defun org-ascii-planning (planning contents info) +(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." @@ -1665,7 +1707,7 @@ holding contextual information." ;;;; Quote Block -(defun org-ascii-quote-block (quote-block contents info) +(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." @@ -1674,7 +1716,7 @@ holding contextual information." ;;;; Radio Target -(defun org-ascii-radio-target (radio-target contents info) +(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." @@ -1687,25 +1729,26 @@ contextual information." "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 (plist-get info :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 - (plist-get info :ascii-inner-margin))))) + (let ((links + (and (plist-get info :ascii-links-to-notes) + ;; Take care of links in first section of the document. + (not (org-element-lineage section '(headline))) + (org-ascii--describe-links + (org-ascii--unique-links section info) + (org-ascii--current-text-width section info) + info)))) + (org-ascii--indent-string + (if (not (org-string-nw-p links)) contents + (concat (org-element-normalize-string contents) "\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 + (plist-get info :ascii-inner-margin)))))) ;;;; Special Block -(defun org-ascii-special-block (special-block contents info) +(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." @@ -1717,7 +1760,7 @@ holding contextual information." ;;;; Src Block -(defun org-ascii-src-block (src-block contents info) +(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." @@ -1735,7 +1778,7 @@ contextual information." ;;;; Statistics Cookie -(defun org-ascii-statistics-cookie (statistics-cookie contents info) +(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)) @@ -1743,7 +1786,7 @@ CONTENTS is nil. INFO is a plist holding contextual information." ;;;; Subscript -(defun org-ascii-subscript (subscript contents info) +(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." @@ -1754,7 +1797,7 @@ contextual information." ;;;; Superscript -(defun org-ascii-superscript (superscript contents info) +(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." @@ -1765,7 +1808,7 @@ contextual information." ;;;; Strike-through -(defun org-ascii-strike-through (strike-through contents info) +(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." @@ -1935,7 +1978,7 @@ a communication channel." ;;;; Timestamp -(defun org-ascii-timestamp (timestamp contents info) +(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)) @@ -1943,7 +1986,7 @@ CONTENTS is nil. INFO is a plist holding contextual information." ;;;; Underline -(defun org-ascii-underline (underline contents info) +(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." @@ -1952,7 +1995,7 @@ holding contextual information." ;;;; Verbatim -(defun org-ascii-verbatim (verbatim contents info) +(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 (plist-get info :ascii-verbatim-format) @@ -1965,21 +2008,20 @@ CONTENTS is nil. INFO is a plist holding contextual information." "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-element contents verse-block info) - (plist-get info :ascii-quote-margin)))) + (org-ascii--indent-string + (org-ascii--justify-element contents verse-block info) + (plist-get info :ascii-quote-margin))) ;;; Filters -(defun org-ascii-filter-headline-blank-lines (headline back-end info) +(defun org-ascii-filter-headline-blank-lines (headline _backend 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. +HEADLINE is a string representing a transcoded headline. BACKEND +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." @@ -1988,10 +2030,10 @@ This function only applies to `ascii' back-end. See (let ((blanks (make-string (1+ (cdr headline-spacing)) ?\n))) (replace-regexp-in-string "\n\\(?:\n[ \t]*\\)*\\'" blanks headline))))) -(defun org-ascii-filter-paragraph-spacing (tree back-end info) +(defun org-ascii-filter-paragraph-spacing (tree _backend info) "Filter controlling number of blank lines between paragraphs. -TREE is the parse tree. BACK-END is the symbol specifying +TREE is the parse tree. BACKEND is the symbol specifying back-end used for export. INFO is a plist used as a communication channel. @@ -2005,9 +2047,9 @@ See `org-ascii-paragraph-spacing' for information." (org-element-put-property p :post-blank paragraph-spacing)))))) tree) -(defun org-ascii-filter-comment-spacing (tree backend info) +(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 +TREE is the parse tree. BACKEND 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) diff --git a/elpa/org-plus-contrib-20150831/ox-beamer.el b/elpa/org-plus-contrib-20170407/ox-beamer.el similarity index 87% rename from elpa/org-plus-contrib-20150831/ox-beamer.el rename to elpa/org-plus-contrib-20170407/ox-beamer.el index 3119bd47..82651d38 100644 --- a/elpa/org-plus-contrib-20150831/ox-beamer.el +++ b/elpa/org-plus-contrib-20170407/ox-beamer.el @@ -1,6 +1,6 @@ -;;; ox-beamer.el --- Beamer Back-End for Org Export Engine +;;; ox-beamer.el --- Beamer Back-End for Org Export Engine -*- lexical-binding: t; -*- -;; Copyright (C) 2007-2015 Free Software Foundation, Inc. +;; Copyright (C) 2007-2017 Free Software Foundation, Inc. ;; Author: Carsten Dominik ;; Nicolas Goaziou @@ -29,7 +29,7 @@ ;;; Code: -(eval-when-compile (require 'cl)) +(require 'cl-lib) (require 'ox-latex) ;; Install a default set-up for Beamer export. @@ -140,7 +140,7 @@ You might want to put e.g. \"allowframebreaks=0.9\" here." The format string should have at most one \"%s\"-expression, which is replaced with the subtitle." :group 'org-export-beamer - :version "25.1" + :version "26.1" :package-version '(Org . "8.3") :type '(string :tag "Format string")) @@ -202,19 +202,14 @@ TYPE is a symbol among the following: `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)))) + (cl-case type + (action (format "<%s>" (org-unbracket-string "<" ">" argument))) + (defaction + (format "[<%s>]" + (org-unbracket-string "<" ">" (org-unbracket-string "[" "]" argument)))) + (option (format "[%s]" (org-unbracket-string "[" "]" argument))) + (otherwise (error "Invalid `type' argument to `org-beamer--normalize-argument': %s" + type))))) (defun org-beamer--element-has-overlay-p (element) "Non-nil when ELEMENT has an overlay specified. @@ -224,14 +219,14 @@ 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))))) + (and (string-prefix-p "<" value) (string-suffix-p ">" value) + value))))) ;;; 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) @@ -265,7 +260,6 @@ Return overlay specification, as a string, or nil." (link . org-beamer-link) (plain-list . org-beamer-plain-list) (radio-target . org-beamer-radio-target) - (target . org-beamer-target) (template . org-beamer-template))) @@ -274,7 +268,7 @@ Return overlay specification, as a string, or nil." ;;;; Bold -(defun org-beamer-bold (bold contents info) +(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." @@ -285,7 +279,7 @@ a communication channel." ;;;; Export Block -(defun org-beamer-export-block (export-block contents info) +(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." @@ -295,7 +289,7 @@ channel." ;;;; Export Snippet -(defun org-beamer-export-snippet (export-snippet contents info) +(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." @@ -331,13 +325,21 @@ channel." 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 (stringp opt) - (string-match "\\(?:^\\|,\\)label=\\(.*?\\)\\(?:$\\|,\\)" opt)) - (match-string 1 opt) - (format "{sec:%s}" (org-export-get-reference headline info))))) +property, the custom ID, if there is one and +`:latex-prefer-user-labels' property has a non nil value, or +a unique internal label. This function assumes HEADLINE will be +treated as a frame." + (cond + ((let ((opt (org-element-property :BEAMER_OPT headline))) + (and (stringp opt) + (string-match "\\(?:^\\|,\\)label=\\(.*?\\)\\(?:$\\|,\\)" opt) + (let ((label (match-string 1 opt))) + (if (string-match-p "\\`{.*}\\'" label) + (substring label 1 -1) + label))))) + ((and (plist-get info :latex-prefer-user-labels) + (org-element-property :CUSTOM_ID headline))) + (t (format "sec:%s" (org-export-get-reference headline info))))) (defun org-beamer--frame-level (headline info) "Return frame level in subtree containing HEADLINE. @@ -441,8 +443,13 @@ used as a communication channel." (or (string-match "\\(^\\|,\\)label=" beamer-opt) (string-match "allowframebreaks" beamer-opt))) (list - (format "label=%s" - (org-beamer--get-label headline info))))))) + (let ((label (org-beamer--get-label headline info))) + ;; Labels containing colons need to be + ;; wrapped within braces. + (format (if (string-match-p ":" label) + "label={%s}" + "label=%s") + label))))))) ;; Change options list into a string. (org-beamer--normalize-argument (mapconcat @@ -551,7 +558,8 @@ used as a communication channel." (let ((action (org-element-property :BEAMER_ACT headline))) (cond ((not action) (list (cons "a" "") (cons "A" "") (cons "R" ""))) - ((string-match "\\`\\[.*\\]\\'" action) + ((and (string-prefix-p "[" action) + (string-suffix-p "]" action)) (list (cons "A" (org-beamer--normalize-argument action 'defaction)) (cons "a" "") @@ -597,28 +605,27 @@ as a communication channel." (when overlay (org-beamer--normalize-argument overlay - (if (string-match "^\\[.*\\]$" overlay) 'defaction + (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)))) + ;; property. This is done by building a minimal + ;; fake link and calling the appropriate resolve + ;; function, depending on the reference syntax. + (let ((target + (if (string-match "\\`\\(id:\\|#\\)" ref) + (org-export-resolve-id-link + `(link (:path ,(substring ref (match-end 0)))) + info) + (org-export-resolve-fuzzy-link + `(link (:path + ;; Look for headlines only. + ,(if (eq (string-to-char ref) ?*) ref + (concat "*" ref)))) + info)))) ;; Now use user-defined label provided in TARGET ;; headline, or fallback to standard one. (format "{%s}" (org-beamer--get-label target info))))))) @@ -668,7 +675,7 @@ contextual information." (list (cons 'item - (lambda (item c i) + (lambda (item _c _i) (let ((action (let ((first (car (org-element-contents item)))) (and (eq (org-element-type first) 'paragraph) @@ -712,47 +719,16 @@ channel." "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))) - (cond - ;; Link type is handled by a special function. - ((org-export-custom-protocol-maybe link contents 'beamer)) - ;; Use \hyperlink command for all internal links. - ((equal type "radio") - (let ((destination (org-export-resolve-radio-link link info))) - (if (not destination) contents - (format "\\hyperlink%s{%s}{%s}" - (or (org-beamer--element-has-overlay-p link) "") - (org-export-get-reference destination info) - contents)))) - ((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 ((ref (org-export-get-reference destination info))) - (if (not contents) (format "\\ref{%s}" ref) - (format "\\hyperlink%s{%s}{%s}" - (or (org-beamer--element-has-overlay-p link) "") - ref - contents)))))))) - ;; Otherwise, use `latex' back-end. - (t (org-export-with-backend 'latex link contents info))))) + (or (org-export-custom-protocol-maybe link contents 'beamer) + ;; Fall-back to LaTeX export. However, prefer "\hyperlink" over + ;; "\hyperref" since the former handles overlay specifications. + (let ((latex-link (org-export-with-backend 'latex link contents info))) + (if (string-match "\\`\\\\hyperref\\[\\(.*?\\)\\]" latex-link) + (replace-match + (format "\\\\hyperlink%s{\\1}" + (or (org-beamer--element-has-overlay-p link) "")) + nil nil latex-link) + latex-link)))) ;;;; Plain List @@ -803,15 +779,6 @@ contextual information." 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 "\\label{%s}" (org-export-get-reference target info))) - - ;;;; Template ;; ;; Template used is similar to the one used in `latex' back-end, @@ -824,34 +791,14 @@ holding export options." (let ((title (org-export-data (plist-get info :title) info)) (subtitle (org-export-data (plist-get info :subtitle) info))) (concat - ;; 1. Time-stamp. + ;; 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)))))) - info))) - ;; 3. Insert themes. + ;; LaTeX compiler + (org-latex--insert-compiler info) + ;; Document class and packages. + (org-latex-make-preamble info) + ;; Insert themes. (let ((format-theme (function (lambda (prop command) @@ -871,11 +818,11 @@ holding export options." (:beamer-inner-theme "\\useinnertheme") (:beamer-outer-theme "\\useoutertheme")) "")) - ;; 4. Possibly limit depth for headline numbering. + ;; 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. + ;; Author. (let ((author (and (plist-get info :with-author) (let ((auth (plist-get info :author))) (and auth (org-export-data auth info))))) @@ -884,14 +831,14 @@ holding export options." (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))))) - ;; 6. Date. + ;; 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 + ;; Title (format "\\title{%s}\n" title) (when (org-string-nw-p subtitle) (concat (format (plist-get info :beamer-subtitle-format) subtitle) "\n")) - ;; 8. Beamer-header + ;; Beamer-header (let ((beamer-header (plist-get info :beamer-header))) (when beamer-header (format "%s\n" (plist-get info :beamer-header)))) @@ -899,9 +846,9 @@ holding export options." (let ((template (plist-get info :latex-hyperref-template))) (and (stringp template) (format-spec template (org-latex--format-spec info)))) - ;; 10. Document start. + ;; Document start. "\\begin{document}\n\n" - ;; 11. Title command. + ;; Title command. (org-element-normalize-string (cond ((not (plist-get info :with-title)) nil) ((string= "" title) nil) @@ -910,7 +857,7 @@ holding export options." org-latex-title-command) (format org-latex-title-command title)) (t org-latex-title-command))) - ;; 12. Table of contents. + ;; Table of contents. (let ((depth (plist-get info :with-toc))) (when depth (concat @@ -922,13 +869,13 @@ holding export options." (format "\\setcounter{tocdepth}{%d}\n" depth)) "\\tableofcontents\n" "\\end{frame}\n\n"))) - ;; 13. Document's body. + ;; Document's body. contents - ;; 14. Creator. + ;; Creator. (if (plist-get info :with-creator) (concat (plist-get info :creator) "\n") "") - ;; 15. Document end. + ;; Document end. "\\end{document}"))) @@ -964,7 +911,7 @@ value." (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)) + (let ((tags (cl-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)) @@ -1116,7 +1063,7 @@ aid, but the tag does not have any semantic meaning." (let* ((envs (append org-beamer-environments-special org-beamer-environments-extra org-beamer-environments-default)) - (org-tag-alist + (org-current-tag-alist (append '((:startgroup)) (mapcar (lambda (e) (cons (concat "B_" (car e)) (string-to-char (nth 1 e)))) @@ -1175,9 +1122,13 @@ Return output file name." ;; working directory and then moved to publishing directory. (org-publish-attachment plist - (org-latex-compile - (org-publish-org-to - 'beamer filename ".tex" plist (file-name-directory filename))) + ;; Default directory could be anywhere when this function is + ;; called. We ensure it is set to source file directory during + ;; compilation so as to not break links to external documents. + (let ((default-directory (file-name-directory filename))) + (org-latex-compile + (org-publish-org-to + 'beamer filename ".tex" plist (file-name-directory filename)))) pub-dir)) diff --git a/elpa/org-plus-contrib-20150831/ox-bibtex.el b/elpa/org-plus-contrib-20170407/ox-bibtex.el similarity index 97% rename from elpa/org-plus-contrib-20150831/ox-bibtex.el rename to elpa/org-plus-contrib-20170407/ox-bibtex.el index 07198669..fb34a5ee 100644 --- a/elpa/org-plus-contrib-20150831/ox-bibtex.el +++ b/elpa/org-plus-contrib-20170407/ox-bibtex.el @@ -92,7 +92,7 @@ ;; Initialization -(eval-when-compile (require 'cl)) +(require 'cl-lib) ;;; Internal Functions @@ -136,7 +136,7 @@ contains a list of strings to be passed as options to (defun org-bibtex-citation-p (object) "Non-nil when OBJECT is a citation." - (case (org-element-type object) + (cl-case (org-element-type object) (link (equal (org-element-property :type object) "cite")) (latex-fragment (string-match "\\`\\\\cite{" (org-element-property :value object))))) @@ -159,9 +159,7 @@ to `org-bibtex-citation-p' predicate." (defun org-bibtex-goto-citation (&optional citation) "Visit a citation given its ID." (interactive) - (let ((citation (or citation - (org-icompleting-read "Citation: " - (obe-citations))))) + (let ((citation (or citation (completing-read "Citation: " (obe-citations))))) (find-file (or org-bibtex-file (error "`org-bibtex-file' has not been configured"))) (goto-char (point-min)) @@ -169,7 +167,7 @@ to `org-bibtex-citation-p' predicate." (outline-previous-visible-heading 1) t))) -(let ((jump-fn (car (org-remove-if-not #'fboundp '(ebib org-bibtex-goto-citation))))) +(let ((jump-fn (car (cl-remove-if-not #'fboundp '(ebib org-bibtex-goto-citation))))) (org-add-link-type "cite" jump-fn)) @@ -237,7 +235,7 @@ Return new parse tree." ;; Update `org-bibtex-html-entries-alist'. (goto-char (point-min)) (while (re-search-forward - "a name=\"\\([-_a-zA-Z0-9:]+\\)\">\\(\\w+\\)" nil t) + "a name=\"\\([-_a-zA-Z0-9:]+\\)\">\\([^<]+\\)" nil t) (push (cons (match-string 1) (match-string 2)) org-bibtex-html-entries-alist))) ;; Open produced HTML file, wrap references within a block and @@ -248,6 +246,7 @@ Return new parse tree." (insert (format "
\n

%s

\n" (org-export-translate "References" :html info))) (insert-file-contents (concat out-file ".html")) + (goto-char (point-max)) (insert "\n
")) ((org-export-derived-backend-p backend 'ascii) ;; convert HTML references to text w/pandoc @@ -304,7 +303,7 @@ the HTML and ASCII backends." next) (while (and (setq next (org-export-get-next-element object info)) (or (and (stringp next) - (not (org-string-match-p "\\S-" next))) + (not (string-match-p "\\S-" next))) (org-bibtex-citation-p next))) (unless (stringp next) (push (org-bibtex-get-citation-key next) keys)) diff --git a/elpa/org-plus-contrib-20150831/ox-confluence.el b/elpa/org-plus-contrib-20170407/ox-confluence.el similarity index 72% rename from elpa/org-plus-contrib-20150831/ox-confluence.el rename to elpa/org-plus-contrib-20170407/ox-confluence.el index 9b96d5f4..a9fac5e2 100644 --- a/elpa/org-plus-contrib-20150831/ox-confluence.el +++ b/elpa/org-plus-contrib-20170407/ox-confluence.el @@ -39,15 +39,18 @@ ;; Define the backend itself (org-export-define-derived-backend 'confluence 'ascii :translate-alist '((bold . org-confluence-bold) + (code . org-confluence-code) (example-block . org-confluence-example-block) (fixed-width . org-confluence-fixed-width) (footnote-definition . org-confluence-empty) (footnote-reference . org-confluence-empty) (headline . org-confluence-headline) (italic . org-confluence-italic) - (item . org-confluence-item) + (item . org-confluence-item) (link . org-confluence-link) + (paragraph . org-confluence-paragraph) (property-drawer . org-confluence-property-drawer) + (quote-block . org-confluence-quote-block) (section . org-confluence-section) (src-block . org-confluence-src-block) (strike-through . org-confluence-strike-through) @@ -55,7 +58,14 @@ (table-cell . org-confluence-table-cell) (table-row . org-confluence-table-row) (template . org-confluence-template) - (underline . org-confluence-underline))) + (timestamp . org-confluence-timestamp) + (underline . org-confluence-underline) + (verbatim . org-confluence-verbatim))) + +(defcustom org-confluence-lang-alist + '(("sh" . "bash")) + "Map from org-babel language name to confluence wiki language name" + :type '(alist :key-type string :value-type string)) ;; All the functions we use (defun org-confluence-bold (bold contents info) @@ -73,22 +83,43 @@ (format "_%s_" contents)) (defun org-confluence-item (item contents info) - (concat (make-string (1+ (org-confluence--li-depth item)) ?\-) - " " - (org-trim contents))) + (let* ((plain-list (org-export-get-parent item)) + (type (org-element-property :type plain-list)) + (bullet (if (eq type 'ordered) ?\# ?\-))) + (concat (make-string (1+ (org-confluence--li-depth item)) bullet) + " " + (if (eq type 'descriptive) + (concat "*" + (org-export-data (org-element-property :tag item) info) + "* - ")) + (org-trim contents)))) (defun org-confluence-fixed-width (fixed-width contents info) - (format "\{\{%s\}\}" contents)) + (org-confluence--block + "none" + "Confluence" + (org-trim (org-element-property :value fixed-width)))) + +(defun org-confluence-verbatim (verbatim contents info) + (format "\{\{%s\}\}" (org-element-property :value verbatim))) + +(defun org-confluence-code (code contents info) + (format "\{\{%s\}\}" (org-element-property :value code))) (defun org-confluence-headline (headline contents info) - (let ((low-level-rank (org-export-low-level-p headline info)) - (text (org-export-data (org-element-property :title headline) - info)) - (level (org-export-get-relative-level headline info))) + (let* ((low-level-rank (org-export-low-level-p headline info)) + (text (org-export-data (org-element-property :title headline) + info)) + (todo (org-export-data (org-element-property :todo-keyword headline) + info)) + (level (org-export-get-relative-level headline info)) + (todo-text (if (or (not (plist-get info :with-todo-keywords)) + (string= todo "")) + "" + (format "*{{%s}}* " todo)))) ;; Else: Standard headline. - (format "h%s. %s\n%s" level text - (if (org-string-nw-p contents) contents - "")))) + (format "h%s. %s%s\n%s" level todo-text text + (if (org-string-nw-p contents) contents "")))) (defun org-confluence-link (link desc info) (let ((raw-link (org-element-property :raw-link link))) @@ -101,18 +132,26 @@ raw-link)) "]"))) +(defun org-confluence-paragraph (paragraph contents info) + "Transcode PARAGRAPH element for Confluence. +CONTENTS is the paragraph contents. INFO is a plist used as +a communication channel." + contents) + (defun org-confluence-property-drawer (property-drawer contents info) (and (org-string-nw-p contents) (format "\{\{%s\}\}" contents))) +(defun org-confluence-quote-block (quote-block contents info) + (format "{quote}\n%s{quote}" contents)) + (defun org-confluence-section (section contents info) contents) (defun org-confluence-src-block (src-block contents info) ;; FIXME: provide a user-controlled variable for theme (let* ((lang (org-element-property :language src-block)) - (language (if (string= lang "sh") "bash" ;; FIXME: provide a mapping of some sort - lang)) + (language (or (cdr (assoc lang org-confluence-lang-alist)) lang)) (content (org-export-format-code-default src-block info))) (org-confluence--block language "Emacs" content))) @@ -132,14 +171,21 @@ (defun org-confluence-table-cell (table-cell contents info) (let ((table-row (org-export-get-parent table-cell))) (concat - (when (org-export-table-row-starts-header-p table-row info) - "|") - contents "|"))) + (and (org-export-table-row-starts-header-p table-row info) "|") + " " contents "|"))) (defun org-confluence-template (contents info) (let ((depth (plist-get info :with-toc))) (concat (when depth "\{toc\}\n\n") contents))) +(defun org-confluence-timestamp (timestamp _contents _info) + "Transcode a TIMESTAMP object from Org to Confluence. +CONTENTS and INFO are ignored." + (let ((translated (org-timestamp-translate timestamp))) + (if (string-prefix-p "[" translated) + (concat "(" (substring translated 1 -1) ")") + translated))) + (defun org-confluence-underline (underline contents info) (format "+%s+" contents)) diff --git a/elpa/org-plus-contrib-20150831/ox-deck.el b/elpa/org-plus-contrib-20170407/ox-deck.el similarity index 100% rename from elpa/org-plus-contrib-20150831/ox-deck.el rename to elpa/org-plus-contrib-20170407/ox-deck.el diff --git a/elpa/org-plus-contrib-20150831/ox-extra.el b/elpa/org-plus-contrib-20170407/ox-extra.el similarity index 99% rename from elpa/org-plus-contrib-20150831/ox-extra.el rename to elpa/org-plus-contrib-20170407/ox-extra.el index e6d45cc6..85dae471 100644 --- a/elpa/org-plus-contrib-20150831/ox-extra.el +++ b/elpa/org-plus-contrib-20170407/ox-extra.el @@ -37,9 +37,9 @@ ;; for export. These blocks should be tagged with #+header: :header ;; yes. For example: ;; #+header: :header yes -;; #+begin_latex +;; #+begin_export latex ;; ... -;; #+end_latex +;; #+end_export ;; - `ignore-headlines' -- allow a headline (but not its children) to ;; be ignored. Any headline tagged with the 'ignore' tag will be diff --git a/elpa/org-plus-contrib-20150831/ox-freemind.el b/elpa/org-plus-contrib-20170407/ox-freemind.el similarity index 99% rename from elpa/org-plus-contrib-20150831/ox-freemind.el rename to elpa/org-plus-contrib-20170407/ox-freemind.el index 3287d5d2..a2bf129c 100644 --- a/elpa/org-plus-contrib-20150831/ox-freemind.el +++ b/elpa/org-plus-contrib-20170407/ox-freemind.el @@ -1,6 +1,6 @@ ;;; ox-freemind.el --- Freemind Mindmap Back-End for Org Export Engine -;; Copyright (C) 2013, 2014 Free Software Foundation, Inc. +;; Copyright (C) 2013-2017 Free Software Foundation, Inc. ;; Author: Jambunathan K ;; Keywords: outlines, hypermedia, calendar, wp @@ -43,7 +43,6 @@ ;;; Define Back-End (org-export-define-derived-backend 'freemind 'html - :export-block "FREEMIND" :menu-entry '(?f "Export to Freemind Mindmap" ((?f "As Freemind Mindmap file" org-freemind-export-to-freemind) diff --git a/elpa/org-plus-contrib-20150831/ox-groff.el b/elpa/org-plus-contrib-20170407/ox-groff.el similarity index 98% rename from elpa/org-plus-contrib-20150831/ox-groff.el rename to elpa/org-plus-contrib-20170407/ox-groff.el index ade3478b..555a89d7 100644 --- a/elpa/org-plus-contrib-20150831/ox-groff.el +++ b/elpa/org-plus-contrib-20170407/ox-groff.el @@ -1,6 +1,6 @@ ;;; ox-groff.el --- Groff Back-End for Org Export Engine -;; Copyright (C) 2011-2015 Free Software Foundation, Inc. +;; Copyright (C) 2011-2017 Free Software Foundation, Inc. ;; Author: Nicolas Goaziou ;; Author: Luis R Anaya @@ -92,7 +92,6 @@ (underline . org-groff-underline) (verbatim . org-groff-verbatim) (verse-block . org-groff-verse-block)) - :export-block "GROFF" :menu-entry '(?g "Export to GROFF" ((?g "As GROFF file" org-groff-export-to-groff) @@ -824,9 +823,7 @@ information." (concat (format "\\fB%s\\fP " org-clock-string) (format org-groff-inactive-timestamp-format - (concat (org-translate-time - (org-element-property :raw-value - (org-element-property :value clock))) + (concat (org-timestamp-translate (org-element-property :value clock)) (let ((time (org-element-property :duration clock))) (and time (format " (%s)" time))))))) @@ -1066,9 +1063,7 @@ contextual information." (let* ((code (org-element-property :value inline-src-block))) (cond (org-groff-source-highlight - (let* ((tmpdir (if (featurep 'xemacs) - temp-directory - temporary-file-directory)) + (let* ((tmpdir temporary-file-directory) (in-file (make-temp-name (expand-file-name "srchilite" tmpdir))) (out-file (make-temp-name @@ -1412,22 +1407,19 @@ information." (concat (format "\\fR %s \\fP" org-closed-string) (format org-groff-inactive-timestamp-format - (org-translate-time - (org-element-property :raw-value closed)))))) + (org-timestamp-translate closed))))) (let ((deadline (org-element-property :deadline planning))) (when deadline (concat (format "\\fB %s \\fP" org-deadline-string) (format org-groff-active-timestamp-format - (org-translate-time - (org-element-property :raw-value deadline)))))) + (org-timestamp-translate deadline))))) (let ((scheduled (org-element-property :scheduled planning))) (when scheduled (concat (format "\\fR %s \\fP" org-scheduled-string) (format org-groff-active-timestamp-format - (org-translate-time - (org-element-property :raw-value scheduled)))))))) + (org-timestamp-translate scheduled))))))) "") "")) @@ -1489,9 +1481,7 @@ contextual information." (custom-env (and lang (cadr (assq (intern lang) org-groff-custom-lang-environments)))) - (num-start (case (org-element-property :number-lines src-block) - (continued (org-export-get-loc src-block info)) - (new 0))) + (num-start (org-export-get-loc src-block info)) (retain-labels (org-element-property :retain-labels src-block)) (caption (and (not (org-export-read-attribute :attr_groff src-block :disable-caption)) @@ -1507,9 +1497,7 @@ contextual information." ;; Case 2. Source fontification. (org-groff-source-highlight - (let* ((tmpdir (if (featurep 'xemacs) - temp-directory - temporary-file-directory)) + (let* ((tmpdir temporary-file-directory) (in-file (make-temp-name (expand-file-name "srchilite" tmpdir))) (out-file (make-temp-name @@ -1903,6 +1891,7 @@ 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)) + (time (current-time)) ;; Properly set working directory for compilation. (default-directory (if (file-name-absolute-p file) (file-name-directory full-name) @@ -1937,7 +1926,12 @@ Return PDF file name or an error if it couldn't be produced." (let ((pdffile (concat out-dir base-name ".pdf"))) ;; Check for process failure. Provide collected errors if ;; possible. - (if (not (file-exists-p pdffile)) + (if (or (not (file-exists-p pdffile)) + ;; Only compare times up to whole seconds as some + ;; filesystems (e.g. HFS+) do not retain any finer + ;; granularity. + (time-less-p (cl-subseq (nth 5 (file-attributes pdffile)) 0 2) + (cl-subseq time 0 2))) (error (concat (format "PDF file %s wasn't produced" pdffile) (when errors (concat ": " errors)))) ;; Else remove log files, when specified, and signal end of diff --git a/elpa/org-plus-contrib-20150831/ox-html.el b/elpa/org-plus-contrib-20170407/ox-html.el similarity index 78% rename from elpa/org-plus-contrib-20150831/ox-html.el rename to elpa/org-plus-contrib-20170407/ox-html.el index 45984b9c..251e1be5 100644 --- a/elpa/org-plus-contrib-20150831/ox-html.el +++ b/elpa/org-plus-contrib-20170407/ox-html.el @@ -1,6 +1,6 @@ -;;; ox-html.el --- HTML Back-End for Org Export Engine +;;; ox-html.el --- HTML Back-End for Org Export Engine -*- lexical-binding: t; -*- -;; Copyright (C) 2011-2015 Free Software Foundation, Inc. +;; Copyright (C) 2011-2017 Free Software Foundation, Inc. ;; Author: Carsten Dominik ;; Jambunathan K @@ -30,20 +30,24 @@ ;;; Dependencies +(require 'cl-lib) +(require 'format-spec) (require 'ox) (require 'ox-publish) -(require 'format-spec) -(eval-when-compile (require 'cl) (require 'table nil 'noerror)) +(require 'table) ;;; 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" ()) +(defvar htmlize-css-name-prefix) +(defvar htmlize-output-type) +(defvar htmlize-output-type) +(defvar htmlize-css-name-prefix) + ;;; Define Back-End (org-export-define-backend 'html @@ -96,8 +100,8 @@ (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-parse-tree . org-html-image-link-filter) (:filter-final-output . org-html-final-function)) :menu-entry '(?h "Export to HTML" @@ -117,7 +121,6 @@ (: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-link-use-abs-url nil "html-link-use-abs-url" org-html-link-use-abs-url) (: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) @@ -165,8 +168,14 @@ (:html-viewport nil nil org-html-viewport) (:html-inline-images nil nil org-html-inline-images) (:html-table-attributes nil nil org-html-table-default-attributes) - (:html-table-row-tags nil nil org-html-table-row-tags) + (:html-table-row-open-tag nil nil org-html-table-row-open-tag) + (:html-table-row-close-tag nil nil org-html-table-row-close-tag) (:html-xml-declaration nil nil org-html-xml-declaration) + (:html-klipsify-src nil nil org-html-klipsify-src) + (:html-klipse-css nil nil org-html-klipse-css) + (:html-klipse-js nil nil org-html-klipse-js) + (:html-klipse-keep-old-src nil nil org-html-keep-old-src) + (:html-klipse-selection-script nil nil org-html-klipse-selection-script) (:infojs-opt "INFOJS_OPT" nil nil) ;; Redefine regular options. (:creator "CREATOR" nil org-html-creator-string) @@ -226,7 +235,7 @@ property on the headline itself.") @licstart The following is the entire license notice for the JavaScript code in this tag. -Copyright (C) 2012-2013 Free Software Foundation, Inc. +Copyright (C) 2012-2017 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 @@ -314,13 +323,98 @@ for the JavaScript code in this tag. border: 1px solid black; } pre.src:hover:before { display: inline;} - pre.src-sh:before { content: 'sh'; } - pre.src-bash:before { content: 'sh'; } + /* Languages per Org manual */ + pre.src-asymptote:before { content: 'Asymptote'; } + pre.src-awk:before { content: 'Awk'; } + pre.src-C:before { content: 'C'; } + /* pre.src-C++ doesn't work in CSS */ + pre.src-clojure:before { content: 'Clojure'; } + pre.src-css:before { content: 'CSS'; } + pre.src-D:before { content: 'D'; } + pre.src-ditaa:before { content: 'ditaa'; } + pre.src-dot:before { content: 'Graphviz'; } + pre.src-calc:before { content: 'Emacs Calc'; } 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'; } + pre.src-fortran:before { content: 'Fortran'; } + pre.src-gnuplot:before { content: 'gnuplot'; } + pre.src-haskell:before { content: 'Haskell'; } + pre.src-hledger:before { content: 'hledger'; } + pre.src-java:before { content: 'Java'; } + pre.src-js:before { content: 'Javascript'; } + pre.src-latex:before { content: 'LaTeX'; } + pre.src-ledger:before { content: 'Ledger'; } + pre.src-lisp:before { content: 'Lisp'; } + pre.src-lilypond:before { content: 'Lilypond'; } + pre.src-lua:before { content: 'Lua'; } + pre.src-matlab:before { content: 'MATLAB'; } + pre.src-mscgen:before { content: 'Mscgen'; } + pre.src-ocaml:before { content: 'Objective Caml'; } + pre.src-octave:before { content: 'Octave'; } + pre.src-org:before { content: 'Org mode'; } + pre.src-oz:before { content: 'OZ'; } + pre.src-plantuml:before { content: 'Plantuml'; } + pre.src-processing:before { content: 'Processing.js'; } + pre.src-python:before { content: 'Python'; } + pre.src-R:before { content: 'R'; } + pre.src-ruby:before { content: 'Ruby'; } + pre.src-sass:before { content: 'Sass'; } + pre.src-scheme:before { content: 'Scheme'; } + pre.src-screen:before { content: 'Gnu Screen'; } + pre.src-sed:before { content: 'Sed'; } + pre.src-sh:before { content: 'shell'; } + pre.src-sql:before { content: 'SQL'; } + pre.src-sqlite:before { content: 'SQLite'; } + /* additional languages in org.el's org-babel-load-languages alist */ + pre.src-forth:before { content: 'Forth'; } + pre.src-io:before { content: 'IO'; } + pre.src-J:before { content: 'J'; } + pre.src-makefile:before { content: 'Makefile'; } + pre.src-maxima:before { content: 'Maxima'; } + pre.src-perl:before { content: 'Perl'; } + pre.src-picolisp:before { content: 'Pico Lisp'; } + pre.src-scala:before { content: 'Scala'; } + pre.src-shell:before { content: 'Shell Script'; } + pre.src-ebnf2ps:before { content: 'ebfn2ps'; } + /* additional language identifiers per \"defun org-babel-execute\" + in ob-*.el */ + pre.src-cpp:before { content: 'C++'; } + pre.src-abc:before { content: 'ABC'; } + pre.src-coq:before { content: 'Coq'; } + pre.src-groovy:before { content: 'Groovy'; } + /* additional language identifiers from org-babel-shell-names in + ob-shell.el: ob-shell is the only babel language using a lambda to put + the execution function name together. */ + pre.src-bash:before { content: 'bash'; } + pre.src-csh:before { content: 'csh'; } + pre.src-ash:before { content: 'ash'; } + pre.src-dash:before { content: 'dash'; } + pre.src-ksh:before { content: 'ksh'; } + pre.src-mksh:before { content: 'mksh'; } + pre.src-posh:before { content: 'posh'; } + /* Additional Emacs modes also supported by the LaTeX listings package */ + pre.src-ada:before { content: 'Ada'; } + pre.src-asm:before { content: 'Assembler'; } + pre.src-caml:before { content: 'Caml'; } + pre.src-delphi:before { content: 'Delphi'; } + pre.src-html:before { content: 'HTML'; } + pre.src-idl:before { content: 'IDL'; } + pre.src-mercury:before { content: 'Mercury'; } + pre.src-metapost:before { content: 'MetaPost'; } + pre.src-modula-2:before { content: 'Modula-2'; } + pre.src-pascal:before { content: 'Pascal'; } + pre.src-ps:before { content: 'PostScript'; } + pre.src-prolog:before { content: 'Prolog'; } + pre.src-simula:before { content: 'Simula'; } + pre.src-tcl:before { content: 'tcl'; } + pre.src-tex:before { content: 'TeX'; } + pre.src-plain-tex:before { content: 'Plain TeX'; } + pre.src-verilog:before { content: 'Verilog'; } + pre.src-vhdl:before { content: 'VHDL'; } + pre.src-xml:before { content: 'XML'; } + pre.src-nxml:before { content: 'XML'; } + /* add a generic configuration mode; LaTeX export needs an additional + (add-to-list 'org-latex-listings-langs '(conf \" \")) in .emacs */ + pre.src-conf:before { content: 'Configuration File'; } table { border-collapse:collapse; } caption.t-above { caption-side: top; } @@ -353,6 +447,7 @@ for the JavaScript code in this tag. { font-size: 10px; font-weight: bold; white-space: nowrap; } .org-info-js_search-highlight { background-color: #ffff00; color: #000000; font-weight: bold; } + .org-svg { width: 90%; } /*]]>*/--> " "The default style specification for exported HTML files. @@ -492,7 +587,7 @@ Option settings will replace the %MANAGER-OPTIONS cookie." :package-version '(Org . "8.0") :type 'string) -(defun org-html-infojs-install-script (exp-plist backend) +(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." @@ -529,21 +624,21 @@ export back-end currently used." 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))))) + (pcase 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)))) + (_ (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 @@ -609,7 +704,7 @@ Warning: non-nil may break indentation of source code blocks." ;;;; Drawers -(defcustom org-html-format-drawer-function (lambda (name contents) contents) +(defcustom org-html-format-drawer-function (lambda (_name contents) contents) "Function called to format a drawer in HTML code. The function must accept two parameters: @@ -680,7 +775,7 @@ INFO the export options (plist). The function result will be used in the section format string." :group 'org-export-html - :version "25.1" + :version "26.1" :package-version '(Org . "8.3") :type 'function) @@ -712,7 +807,7 @@ The function must accept seven parameters: The function should return the string to be exported." :group 'org-export-html - :version "25.1" + :version "26.1" :package-version '(Org . "8.3") :type 'function) @@ -727,24 +822,20 @@ 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'." + nil Ignore math snippets. + `verbatim' Keep everything in verbatim + `mathjax', t Do MathJax preprocessing and arrange for MathJax.js to + be loaded. + SYMBOL Any symbol defined in `org-preview-latex-process-alist', + e.g., `dvipng'." :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 "Leave math verbatim" verbatim) (const :tag "Use MathJax to display math" mathjax) - (const :tag "Leave math verbatim" verbatim))) + (symbol :tag "Convert to image to display math" :value dvipng))) ;;;; Links :: Generic @@ -752,11 +843,11 @@ t Synonym for `mathjax'." "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 +However, links to other Org 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." +When nil, the links still point to the plain \".org\" file." :group 'org-export-html :type 'boolean) @@ -811,7 +902,7 @@ 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." +`\\[org-html-htmlize-generate-css]' to extract class definitions." :group 'org-export-html :type '(choice (const css) (const inline-css) (const nil))) @@ -854,43 +945,50 @@ 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 '("" . "") - "The opening and ending tags for table rows. +(defcustom org-html-table-row-open-tag "" + "The opening tag for table rows. This is customizable so that alignment options can be specified. -Instead of strings, these can be Lisp forms that will be +Instead of strings, these can be a Lisp function 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: +The function will be called with these arguments: - `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 + `number': row number (0 is the first row) + `group-number': group number of current row + `start-group?': non-nil means the row starts a group + `end-group?': non-nil means the row ends a group + `top?': non-nil means this is the top row + `bottom?': non-nil means this is the bottom row For example: -\(setq org-html-table-row-tags - (cons '(cond (top-row-p \"\") - (bottom-row-p \"\") - (t (if (= (mod row-number 2) 1) - \"\" - \"\"))) - \"\")) + (setq org-html-table-row-open-tag + (lambda (number group-number start-group? end-group-p top? bottom?) + (cond (top? \"\") + (bottom? \"\") + (t (if (= (mod number 2) 1) + \"\" + \"\"))))) 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)))) + :type '(choice :tag "Opening tag" + (string :tag "Specify") + (function))) + +(defcustom org-html-table-row-close-tag "" + "The closing tag for table rows. +This is customizable so that alignment options can be specified. +Instead of strings, this can be a Lisp function that will be +evaluated for each row in order to construct the table row tags. + +See documentation of `org-html-table-row-open-tag'." + :group 'org-export-html + :type '(choice :tag "Closing tag" + (string :tag "Specify") + (function))) (defcustom org-html-table-align-individual-fields t "Non-nil means attach style attributes for alignment to each table field. @@ -997,7 +1095,7 @@ org-info.js for your website." (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 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. @@ -1088,10 +1186,10 @@ linebreaks Let MathJax perform automatic linebreaks. Valid values indent If align is not center, how far from the left/right side? Valid values are \"left\" and \"right\" multlinewidth The width of the multline environment. -autonumber How to number equations. Valid values are \"None\", +autonumber How to number equations. Valid values are \"None\", \"all\" and \"AMS Math\". tagindent The amount tags are indented. -tagside Which side to show tags/labels on. Valid values are +tagside Which side to show tags/labels on. Valid values are \"left\" and \"right\" You can also customize this for each buffer, using something like @@ -1116,14 +1214,14 @@ MathJax CDN Terms of Service. (list :tag "align (alignment of displayed equations)" (const :format " " align) (string)) (list :tag "font (used to display math)" - (const :format " " font) - (choice (const "TeX") - (const "STIX-Web") - (const "Asana-Math") - (const "Neo-Euler") - (const "Gyre-Pagella") - (const "Gyre-Termes") - (const "Latin-Modern"))) + (const :format " " font) + (choice (const "TeX") + (const "STIX-Web") + (const "Asana-Math") + (const "Neo-Euler") + (const "Gyre-Pagella") + (const "Gyre-Termes") + (const "Latin-Modern"))) (list :tag "linebreaks (automatic line-breaking)" (const :format " " linebreaks) (choice (const "true") @@ -1176,7 +1274,7 @@ MathJax CDN Terms of Service. (defcustom org-html-postamble 'auto "Non-nil means insert a postamble in HTML export. -When set to 'auto, check against the +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 @@ -1326,8 +1424,6 @@ ignored." ;;;; 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 @@ -1339,8 +1435,6 @@ not be modified." ;;;; 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 @@ -1353,7 +1447,6 @@ style information." ;;;###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. @@ -1425,7 +1518,7 @@ The viewport meta tag is inserted if this variable is non-nil. See the following site for a reference: https://developer.mozilla.org/en-US/docs/Mozilla/Mobile/Viewport_meta_tag" :group 'org-export-html - :version "25.1" + :version "26.1" :package-version '(Org . "8.3") :type '(choice (const :tag "Disable" nil) (list :tag "Enable" @@ -1451,6 +1544,46 @@ https://developer.mozilla.org/en-US/docs/Mozilla/Mobile/Viewport_meta_tag" (const "true") (const "false")))))) +;; Handle source code blocks with Klipse + +(defcustom org-html-klipsify-src nil + "When non-nil, source code blocks are editable in exported presentation." + :group 'org-export-html + :package-version '(Org . "9.1") + :type 'boolean) + +(defcustom org-html-klipse-css + "https://storage.googleapis.com/app.klipse.tech/css/codemirror.css" + "Location of the codemirror CSS file for use with klipse." + :group 'org-export-html + :package-version '(Org . "9.1") + :type 'string) + +(defcustom org-html-klipse-js + "https://storage.googleapis.com/app.klipse.tech/plugin_prod/js/klipse_plugin.min.js" + "Location of the klipse javascript file." + :group 'org-export-html + :type 'string) + +(defcustom org-html-klipse-selection-script + "window.klipse_settings = {selector_eval_html: '.src-html', + selector_eval_js: '.src-js', + selector_eval_python_client: '.src-python', + selector_eval_scheme: '.src-scheme', + selector: '.src-clojure', + selector_eval_ruby: '.src-ruby'};" + "Javascript snippet to activate klipse." + :group 'org-export-html + :package-version '(Org . "9.1") + :type 'string) + +(defcustom org-html-keep-old-src nil + "When non-nil, use
 instead of 
."
+  :group 'org-export-html
+  :package-version '(Org . "9.1")
+  :type 'boolean)
+
+
 ;;;; Todos
 
 (defcustom org-html-todo-kwd-class-prefix ""
@@ -1462,7 +1595,7 @@ CSS classes, then this prefix can be very useful."
   :group 'org-export-html
   :type 'string)
 
-
+
 ;;; Internal Functions
 
 (defun org-html-xhtml-p (info)
@@ -1480,21 +1613,26 @@ INFO is the current state of the export process, as a plist."
        (org-html-html5-p info)))
 
 (defun org-html-close-tag (tag attr info)
-  (concat "<" tag " " attr
+  "Return close-tag for string TAG.
+ATTR specifies additional attributes.  INFO is a property list
+containing current export state."
+  (concat "<" tag
+	  (org-string-nw-p (concat " " 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."
+  "Return correct HTML doctype tag.
+INFO is a plist used as a communication channel.  Doctype tag is
+extracted from `org-html-doctype-alist', or the literal value
+of :html-doctype from INFO if :html-doctype is not found in the
+alist."
   (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."
+ATTRIBUTES is a plist where values are either strings or nil.  An
+attribute with a nil value will be omitted from the result."
   (let (output)
     (dolist (item attributes (mapconcat 'identity (nreverse output) " "))
       (cond ((null item) (pop output))
@@ -1510,12 +1648,12 @@ 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 (org-html--html5-fancy-p info)))
-    (format (if html5-fancy "\n%s%s\n"
-	      "\n%s%s\n
") + (format (if html5-fancy "\n\n%s%s\n" + "\n\n%s%s\n") ;; ID. (if (org-string-nw-p label) (format " id=\"%s\"" label) "") ;; Contents. - (format "\n

%s

" contents) + (if html5-fancy contents (format "

%s

" contents)) ;; Caption. (if (not (org-string-nw-p caption)) "" (format (if html5-fancy "\n
%s
" @@ -1543,21 +1681,27 @@ a communication channel." info))) (defun org-html--svg-image (source attributes info) - "Return \"object\" appropriate for embedding svg file SOURCE -with assoicated ATTRIBUTES. INFO is a plist used as a -communication channel. + "Return \"object\" embedding svg file SOURCE with given ATTRIBUTES. +INFO is a plist used as a communication channel. -The special attribute \"fallback\" can be used to specify a fallback -image file to use if the object embedding is not supported." +The special attribute \"fallback\" can be used to specify a +fallback image file to use if the object embedding is not +supported. CSS class \"org-svg\" is assigned as the class of the +object unless a different class is specified with an attribute." (let ((fallback (plist-get attributes :fallback)) (attrs (org-html--make-attribute-string - (plist-put attributes :fallback nil)))) - (format "\n%s" - source attrs - (if fallback - (org-html-close-tag - "img" (format "src=\"%s\" %s" fallback attrs) info) - "Sorry, your browser does not support SVG.")))) + (org-combine-plists + ;; Remove fallback attribute, which is not meant to + ;; appear directly in the attributes string, and + ;; provide a default class if none is set. + '(:class "org-svg") attributes '(:fallback nil))))) + (format "\n%s" + source + attrs + (if fallback + (org-html-close-tag + "img" (format "src=\"%s\" %s" fallback attrs) info) + "Sorry, your browser does not support SVG.")))) (defun org-html--textarea-block (element) "Transcode ELEMENT into a textarea block. @@ -1569,7 +1713,7 @@ ELEMENT is either a src block or an example block." (or (plist-get attr :height) (org-count-lines code)) code))) -(defun org-html--has-caption-p (element &optional info) +(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 @@ -1616,7 +1760,7 @@ produce code that uses these same face definitions." (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*") + (pop-to-buffer-same-window "*html*") (goto-char (point-min)) (if (re-search-forward "%s" - (org-trim (org-export-data raw info)))))))) + (cl-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 "
%s
" + (org-trim (org-export-data raw info)))))))) (when fn-alist (format (plist-get info :html-footnotes-section) @@ -1705,45 +1846,45 @@ INFO is a plist used as a communication channel." " -->\n"))) (format (if (org-html-html5-p info) - (org-html-close-tag "meta" " charset=\"%s\"" info) + (org-html-close-tag "meta" "charset=\"%s\"" info) (org-html-close-tag - "meta" " http-equiv=\"Content-Type\" content=\"text/html;charset=%s\"" + "meta" "http-equiv=\"Content-Type\" content=\"text/html;charset=%s\"" info)) charset) "\n" (let ((viewport-options - (org-remove-if-not (lambda (cell) (org-string-nw-p (cadr cell))) + (cl-remove-if-not (lambda (cell) (org-string-nw-p (cadr cell))) (plist-get info :html-viewport)))) (and viewport-options (concat (org-html-close-tag "meta" - (format " name=\"viewport\" content=\"%s\"" + (format "name=\"viewport\" content=\"%s\"" (mapconcat (lambda (elm) (format "%s=%s" (car elm) (cadr elm))) viewport-options ", ")) info) "\n"))) (format "%s\n" title) - (org-html-close-tag "meta" " name=\"generator\" content=\"Org-mode\"" info) + (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\"" + (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" + (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\"" + (format "name=\"keywords\" content=\"%s\"" (funcall protect-string keywords)) info) "\n"))))) @@ -1760,7 +1901,7 @@ INFO is a plist used as a communication channel." (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\"" + (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)))) @@ -1773,45 +1914,41 @@ INFO is a plist used as a communication channel." '(latex-fragment latex-environment) 'identity info t)) (let ((template (plist-get info :html-mathjax-template)) (options (plist-get info :html-mathjax-options)) - (in-buffer (or (plist-get info :html-mathjax) "")) - name val 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))) - (while (string-match (concat "%" (upcase (symbol-name name))) template) - (setq template (replace-match val t t template)))) - options) - ;; Return the modified template. - (org-element-normalize-string template)))) + (in-buffer (or (plist-get info :html-mathjax) ""))) + (dolist (e options (org-element-normalize-string template)) + (let ((name (car e)) + (val (nth 1 e))) + (when (string-match (concat "\\<" (symbol-name name) ":") in-buffer) + (setq val + (car (read-from-string (substring in-buffer (match-end 0)))))) + (unless (stringp val) (setq val (format "%s" val))) + (while (string-match (concat "%" (upcase (symbol-name name))) + template) + (setq template (replace-match val t t 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)) - (?s . ,(org-export-data (plist-get info :subtitle) info)) - (?d . ,(org-export-data (org-export-get-date info) info)) - (?T . ,(format-time-string - (plist-get info :html-metadata-timestamp-format))) - (?a . ,(org-export-data (plist-get info :author) info)) - (?e . ,(mapconcat - (lambda (e) - (format "
%s" e e)) - (split-string (plist-get info :email) ",+ *") - ", ")) - (?c . ,(plist-get info :creator)) - (?C . ,(let ((file (plist-get info :input-file))) - (format-time-string - (plist-get info :html-metadata-timestamp-format) - (when file (nth 5 (file-attributes file)))))) - (?v . ,(or (plist-get info :html-validation-link) "")))) + "Return format specification for preamble and postamble. +INFO is a plist used as a communication channel." + (let ((timestamp-format (plist-get info :html-metadata-timestamp-format))) + `((?t . ,(org-export-data (plist-get info :title) info)) + (?s . ,(org-export-data (plist-get info :subtitle) info)) + (?d . ,(org-export-data (org-export-get-date info timestamp-format) + info)) + (?T . ,(format-time-string timestamp-format)) + (?a . ,(org-export-data (plist-get info :author) info)) + (?e . ,(mapconcat + (lambda (e) (format "%s" e e)) + (split-string (plist-get info :email) ",+ *") + ", ")) + (?c . ,(plist-get info :creator)) + (?C . ,(let ((file (plist-get info :input-file))) + (format-time-string timestamp-format + (and file (nth 5 (file-attributes file)))))) + (?v . ,(or (plist-get info :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 +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))) @@ -1825,7 +1962,6 @@ communication channel." (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) @@ -1854,15 +1990,17 @@ communication channel." (format "

%s

\n" validation-link)))) (t (format-spec - (or (cadr (assoc + (or (cadr (assoc-string (plist-get info :language) (eval (intern - (format "org-html-%s-format" type))))) + (format "org-html-%s-format" type))) + t)) (cadr - (assoc + (assoc-string "en" (eval - (intern (format "org-html-%s-format" type)))))) + (intern (format "org-html-%s-format" type))) + t))) spec)))))) (let ((div (assq type (plist-get info :html-divs)))) (when (org-string-nw-p section-contents) @@ -1909,10 +2047,12 @@ holding export options." (org-html-doctype info) "\n" (concat "\n") "\n" (org-html--build-meta-info info) @@ -1953,6 +2093,13 @@ holding export options." (format "\n" (nth 1 (assq 'content (plist-get info :html-divs)))) ;; Postamble. (org-html--build-pre/postamble 'postamble info) + ;; Possibly use the Klipse library live code blocks. + (if (plist-get info :html-klipsify-src) + (concat "")) ;; Closing document. "\n")) @@ -1978,13 +2125,13 @@ INFO is a plist used as a communication channel." (when todo (format "%s" (if (member todo org-done-keywords) "done" "todo") - (plist-get info :html-todo-kwd-class-prefix) + (or (plist-get info :html-todo-kwd-class-prefix) "") (org-html-fix-class-name todo) todo))) ;;;; Priority -(defun org-html--priority (priority info) +(defun org-html--priority (priority _info) "Format a priority into HTML. PRIORITY is the character code of the priority or nil. INFO is a plist containing export options." @@ -2047,7 +2194,7 @@ is the language used for CODE, as a string, or nil." (funcall lang-mode) (insert code) ;; Fontify buffer. - (font-lock-ensure) + (org-font-lock-ensure) ;; Remove formatting on newline characters. (save-excursion (let ((beg (point-min)) @@ -2115,9 +2262,7 @@ a plist used as a communication channel." ;; 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)))) + (num-start (org-export-get-loc element info))) (org-html-do-format-code code lang refs retain-labels num-start))) @@ -2164,8 +2309,7 @@ and value is its relative level, as an integer." (level (cdr entry))) (concat (let* ((cnt (- level prev-level)) - (times (if (> cnt 0) (1- cnt) (- cnt))) - rtn) + (times (if (> cnt 0) (1- cnt) (- cnt)))) (setq prev-level level) (concat (org-html--make-string @@ -2241,10 +2385,12 @@ of listings as a string, or nil if it is empty." (concat "
  • " (if (not label) - (concat (format initial-fmt (incf count)) " " title) + (concat (format initial-fmt (cl-incf count)) + " " + title) (format "%s %s" label - (format initial-fmt (incf count)) + (format initial-fmt (cl-incf count)) title)) "
  • "))) lol-entries "\n")) @@ -2278,10 +2424,12 @@ of tables as a string, or nil if it is empty." (concat "
  • " (if (not label) - (concat (format initial-fmt (incf count)) " " title) + (concat (format initial-fmt (cl-incf count)) + " " + title) (format "%s %s" label - (format initial-fmt (incf count)) + (format initial-fmt (cl-incf count)) title)) "
  • "))) lol-entries "\n")) @@ -2292,7 +2440,7 @@ of tables as a string, or nil if it is empty." ;;;; Bold -(defun org-html-bold (bold contents info) +(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." @@ -2301,7 +2449,7 @@ contextual information." ;;;; Center Block -(defun org-html-center-block (center-block contents info) +(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." @@ -2309,7 +2457,7 @@ holding contextual information." ;;;; Clock -(defun org-html-clock (clock contents info) +(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." @@ -2325,7 +2473,7 @@ channel." ;;;; Code -(defun org-html-code (code contents info) +(defun org-html-code (code _contents info) "Transcode CODE from Org to HTML. CONTENTS is nil. INFO is a plist holding contextual information." @@ -2344,7 +2492,7 @@ holding contextual information." ;;;; Dynamic Block -(defun org-html-dynamic-block (dynamic-block contents info) +(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'." @@ -2352,7 +2500,7 @@ holding contextual information. See `org-export-data'." ;;;; Entity -(defun org-html-entity (entity contents info) +(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." @@ -2360,18 +2508,25 @@ contextual information." ;;;; Example Block -(defun org-html-example-block (example-block contents info) +(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 "
    \n%s
    " - (org-html-format-code example-block info)))) + (let ((attributes (org-export-read-attribute :attr_html example-block))) + (if (plist-get attributes :textarea) + (org-html--textarea-block example-block) + (format "
    \n%s
    " + (let* ((name (org-element-property :name example-block)) + (a (org-html--make-attribute-string + (if (or (not name) (plist-member attributes :id)) + attributes + (plist-put attributes :id name))))) + (if (org-string-nw-p a) (concat " " a) "")) + (org-html-format-code example-block info))))) ;;;; Export Snippet -(defun org-html-export-snippet (export-snippet contents info) +(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." @@ -2380,7 +2535,7 @@ information." ;;;; Export Block -(defun org-html-export-block (export-block contents info) +(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") @@ -2388,7 +2543,7 @@ CONTENTS is nil. INFO is a plist holding contextual information." ;;;; Fixed Width -(defun org-html-fixed-width (fixed-width contents info) +(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 "
    \n%s
    " @@ -2398,7 +2553,7 @@ CONTENTS is nil. INFO is a plist holding contextual information." ;;;; Footnote Reference -(defun org-html-footnote-reference (footnote-reference contents info) +(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 @@ -2427,8 +2582,6 @@ holding contextual information." (unless (org-element-property :footnote-section-p headline) (let* ((numberedp (org-export-numbered-headline-p headline info)) (numbers (org-export-get-headline-number headline info)) - (section-number (and numbers - (mapconcat #'number-to-string numbers "-"))) (level (+ (org-export-get-relative-level headline info) (1- (plist-get info :html-toplevel-hlevel)))) (todo (and (plist-get info :with-todo-keywords) @@ -2457,21 +2610,22 @@ holding contextual information." (cdr ids) ""))) (if (org-export-low-level-p headline info) ;; This is a deep sub-tree: export it as a list item. - (let* ((type (if numberedp 'ordered 'unordered)) - (itemized-body - (org-html-format-list-item - contents type nil info nil + (let* ((html-type (if numberedp "ol" "ul"))) + (concat + (and (org-export-first-sibling-p headline info) + (apply #'format "<%s class=\"org-%s\">\n" + (make-list 2 html-type))) + (org-html-format-list-item + contents (if numberedp 'ordered 'unordered) + nil info nil (concat (org-html--anchor preferred-id nil nil info) extra-ids - 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)))) + full-text)) "\n" + (and (org-export-last-sibling-p headline info) + (format "\n" html-type)))) + ;; Standard headline. Export it as a section. (let ((extra-class (org-element-property :HTML_CONTAINER_CLASS headline)) (first-content (car (org-element-contents headline)))) - ;; Standard headline. Export it as a section. (format "<%s id=\"%s\" class=\"%s\">%s%s\n" (org-html--container headline info) (concat "outline-container-" @@ -2500,7 +2654,7 @@ holding contextual information." (org-html--container headline info))))))) (defun org-html-format-headline-default-function - (todo todo-type priority text tags info) + (todo _todo-type priority text tags info) "Default format function for a headline. See `org-html-format-headline-function' for details." (let ((todo (org-html--todo todo info)) @@ -2519,19 +2673,19 @@ See `org-html-format-headline-function' for details." ;;;; Horizontal Rule -(defun org-html-horizontal-rule (horizontal-rule contents info) +(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) +(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 ((lang (org-element-property :language inline-src-block)) - (code (org-html-format-code inline-src-block info)) + (code (org-element-property :value inline-src-block)) (label (let ((lbl (and (org-element-property :name inline-src-block) (org-export-get-reference inline-src-block info)))) @@ -2568,7 +2722,7 @@ See `org-html-format-inlinetask-function' for details." ;;;; Italic -(defun org-html-italic (italic contents info) +(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." @@ -2587,30 +2741,31 @@ INFO is a plist holding contextual information. See org-html-checkbox-types))))) (defun org-html-format-list-item (contents type checkbox info - &optional term-counter-id - headline) + &optional term-counter-id + headline) "Format a list item into HTML." (let ((class (if checkbox (format " class=\"%s\"" (symbol-name checkbox)) "")) (checkbox (concat (org-html-checkbox checkbox info) (and checkbox " "))) - (br (org-html-close-tag "br" nil info))) + (br (org-html-close-tag "br" nil info)) + (extra-newline (if (and (org-string-nw-p contents) headline) "\n" ""))) (concat - (case type - (ordered + (pcase type + (`ordered (let* ((counter term-counter-id) (extra (if counter (format " value=\"%s\"" counter) ""))) (concat (format "" class extra) (when headline (concat headline br))))) - (unordered + (`unordered (let* ((id term-counter-id) (extra (if id (format " id=\"%s\"" id) ""))) (concat (format "" class extra) (when headline (concat headline br))))) - (descriptive + (`descriptive (let* ((term term-counter-id)) (setq term (or term "(no term)")) ;; Check-boxes in descriptive lists are associated to tag. @@ -2618,11 +2773,13 @@ INFO is a plist holding contextual information. See class (concat checkbox term)) "
    ")))) (unless (eq type 'descriptive) checkbox) - (and contents (org-trim contents)) - (case type - (ordered "") - (unordered "") - (descriptive "
    "))))) + extra-newline + (and (org-string-nw-p contents) (org-trim contents)) + extra-newline + (pcase type + (`ordered "") + (`unordered "") + (`descriptive ""))))) (defun org-html-item (item contents info) "Transcode an ITEM element from Org to HTML. @@ -2639,7 +2796,7 @@ contextual information." ;;;; Keyword -(defun org-html-keyword (keyword contents info) +(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)) @@ -2652,7 +2809,7 @@ CONTENTS is nil. INFO is a plist holding contextual information." ((string-match "\\" value) (let ((depth (and (string-match "\\<[0-9]+\\>" value) (string-to-number (match-string 0 value)))) - (localp (org-string-match-p "\\" value))) + (localp (string-match-p "\\" value))) (org-html-toc depth info (and localp keyword)))) ((string= "listings" value) (org-html-list-of-listings info)) ((string= "tables" value) (org-html-list-of-tables info)))))))) @@ -2661,10 +2818,11 @@ CONTENTS is nil. INFO is a plist holding contextual information." (defun org-html-format-latex (latex-frag processing-type info) "Format a LaTeX fragment LATEX-FRAG into HTML. -PROCESSING-TYPE designates the tool used for conversion. It is -a symbol among `mathjax', `dvipng', `imagemagick', `verbatim' nil -and t. See `org-html-with-latex' for more information. INFO is -a plist containing export properties." +PROCESSING-TYPE designates the tool used for conversion. It can +be `mathjax', `verbatim', nil, t or symbols in +`org-preview-latex-process-alist', e.g., `dvipng', `dvisvgm' or +`imagemagick'. See `org-html-with-latex' for more information. +INFO is a plist containing export properties." (let ((cache-relpath "") (cache-dir "")) (unless (eq processing-type 'mathjax) (let ((bfn (or (buffer-file-name) @@ -2679,7 +2837,7 @@ a plist containing export properties." "\n") "\n"))))) (setq cache-relpath - (concat "ltxpng/" + (concat (file-name-as-directory org-preview-latex-image-directory) (file-name-sans-extension (file-name-nondirectory bfn))) cache-dir (file-name-directory bfn)) @@ -2689,57 +2847,60 @@ a plist containing export properties." (setq latex-frag (concat latex-header latex-frag)))) (with-temp-buffer (insert latex-frag) - (org-format-latex cache-relpath cache-dir nil "Creating LaTeX Image..." - nil processing-type) + (org-format-latex cache-relpath nil nil cache-dir nil + "Creating LaTeX Image..." nil processing-type) (buffer-string)))) -(defun org-html-latex-environment (latex-environment contents info) +(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 info)) - ((dvipng imagemagick) - (let ((formula-link - (org-html-format-latex latex-frag processing-type info))) - (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)))) + (cond + ((memq processing-type '(t mathjax)) + (org-html-format-latex latex-frag 'mathjax info)) + ((assq processing-type org-preview-latex-process-alist) + (let ((formula-link + (org-html-format-latex latex-frag processing-type info))) + (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) +(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 info)) - ((dvipng imagemagick) - (let ((formula-link - (org-html-format-latex latex-frag processing-type info))) - (when (and formula-link (string-match "file:\\([^]]*\\)" formula-link)) - (org-html--format-image (match-string 1 formula-link) nil info)))) - (t latex-frag)))) + (cond + ((memq processing-type '(t mathjax)) + (org-html-format-latex latex-frag 'mathjax info)) + ((assq processing-type org-preview-latex-process-alist) + (let ((formula-link + (org-html-format-latex latex-frag processing-type info))) + (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) +(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-image-link-filter (data _backend info) + (org-export-insert-image-links data info org-html-inline-image-rules)) + (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 @@ -2754,13 +2915,13 @@ if its description is a single link targeting an image file." (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 (plist-get info :html-inline-image-rules))))) - (otherwise t))) + (pcase (org-element-type obj) + (`plain-text (org-string-nw-p obj)) + (`link (if (= link-count 1) t + (cl-incf link-count) + (not (org-export-inline-image-p + obj (plist-get info :html-inline-image-rules))))) + (_ t))) info t))))) (defvar org-html-standalone-image-predicate) @@ -2781,10 +2942,10 @@ 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))))) + (lambda (paragraph) (org-element-property :caption paragraph))" + (let ((paragraph (pcase (org-element-type element) + (`paragraph element) + (`link (org-export-get-parent element))))) (and (eq (org-element-type paragraph) 'paragraph) (or (not (fboundp 'org-html-standalone-image-predicate)) (funcall org-html-standalone-image-predicate paragraph)) @@ -2792,13 +2953,13 @@ images, set it to: (let ((link-count 0)) (org-element-map (org-element-contents paragraph) (cons 'plain-text org-element-all-objects) - #'(lambda (obj) - (when (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)) - (throw 'exit nil))) + (lambda (obj) + (when (pcase (org-element-type obj) + (`plain-text (org-string-nw-p obj)) + (`link (or (> (cl-incf link-count) 1) + (not (org-html-inline-image-p obj info)))) + (_ t)) + (throw 'exit nil))) info nil 'link) (= link-count 1)))))) @@ -2811,27 +2972,24 @@ INFO is a plist holding contextual information. See (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 (plist-get info :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))))) + (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 (plist-get info :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")) - (org-html-encode-plain-text - (org-link-escape-browser - (org-link-unescape (concat type ":" raw-path))))) + ((member type '("http" "https" "ftp" "mailto" "news")) + (url-encode-url (org-link-unescape (concat type ":" raw-path)))) ((string= type "file") ;; Treat links to ".org" files as ".html", if needed. (setq raw-path @@ -2844,15 +3002,19 @@ INFO is a plist holding contextual information. See ((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, a headline title a name, - ;; a target or a radio-target. + ;; relative to a custom-id, a headline title, a name or + ;; a target. (let ((option (org-element-property :search-option link))) - (if (not option) raw-path - (concat raw-path - "#" - (org-publish-resolve-external-link - option - (org-element-property :path link)))))) + (cond ((not option) raw-path) + ;; Since HTML back-end use custom-id value as-is, + ;; resolving is them is trivial. + ((eq (string-to-char option) ?#) (concat raw-path option)) + (t + (concat raw-path + "#" + (org-publish-resolve-external-link + option + (org-element-property :path link))))))) (t raw-path))) ;; Extract attributes from parent's paragraph. HACK: Only do ;; this for the first link in parent (inner image link for @@ -2893,9 +3055,9 @@ INFO is a plist holding contextual information. See (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) + (pcase (org-element-type destination) ;; ID link points to an external file. - (plain-text + (`plain-text (let ((fragment (concat "ID-" path)) ;; Treat links to ".org" files as ".html", if needed. (path (funcall link-org-files-as-html-maybe @@ -2903,13 +3065,13 @@ INFO is a plist holding contextual information. See (format "%s" path fragment attributes (or desc destination)))) ;; Fuzzy link points nowhere. - ((nil) + (`nil (format "%s" (or desc (org-export-data (org-element-property :raw-link link) info)))) ;; Link points to a headline. - (headline + (`headline (let ((href (or (org-element-property :CUSTOM_ID destination) (org-export-get-reference destination info))) ;; What description to use? @@ -2929,7 +3091,7 @@ INFO is a plist holding contextual information. See (org-element-property :title destination) info))))) (format "%s" href attributes desc))) ;; Fuzzy link points to a target or an element. - (t + (_ (let* ((ref (org-export-get-reference destination info)) (org-html-standalone-image-predicate #'org-html--has-caption-p) @@ -2950,27 +3112,32 @@ INFO is a plist holding contextual information. See ;; Coderef: replace link with the reference name or the ;; equivalent line number. ((string= type "coderef") - (let ((fragment (concat "coderef-" path))) - (format "%s" + (let ((fragment (concat "coderef-" (org-html-encode-plain-text path)))) + (format "%s" fragment - (org-trim - (format (concat "class=\"coderef\"" - " onmouseover=\"CodeHighlightOn(this, '%s');\"" - " onmouseout=\"CodeHighlightOff(this, '%s');\"") - fragment fragment)) + (format "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))))) ;; External link with a description part. - ((and path desc) (format "%s" path attributes desc)) + ((and path desc) (format "%s" + (org-html-encode-plain-text path) + attributes + desc)) ;; External link without a description part. - (path (format "%s" path attributes path)) + (path (let ((path (org-html-encode-plain-text path))) + (format "%s" + path + attributes + (org-link-unescape path)))) ;; No path, only description. Try to do something useful. (t (format "%s" desc))))) ;;;; Node Property -(defun org-html-node-property (node-property contents info) +(defun org-html-node-property (node-property _contents _info) "Transcode a NODE-PROPERTY element from Org to HTML. CONTENTS is nil. INFO is a plist holding contextual information." @@ -3007,16 +3174,16 @@ the plist used as a communication channel." (let ((raw (org-export-data (org-export-get-caption paragraph) info)) (org-html-standalone-image-predicate - 'org-html--has-caption-p)) + #'org-html--has-caption-p)) (if (not (org-string-nw-p raw)) raw - (concat - "" - (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)) - " " raw)))) + (concat "" + (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)) + " " + raw)))) (label (and (org-element-property :name paragraph) (org-export-get-reference paragraph info)))) (org-html--wrap-image contents info caption label))) @@ -3028,47 +3195,36 @@ the plist used as a communication channel." ;;;; Plain List -;; FIXME Maybe arg1 is not needed because
  • 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 "
      " - (if arg1 (format " start=\"%d\"" arg1) ""))) - (unordered "
        ") - (descriptive "
        "))) - -(defun org-html-end-plain-list (type) - "Insert the end of the HTML list depending on TYPE." - (case type - (ordered "
    ") - (unordered "") - (descriptive ""))) - -(defun org-html-plain-list (plain-list contents info) +(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)))) + (let* ((type (pcase (org-element-property :type plain-list) + (`ordered "ol") + (`unordered "ul") + (`descriptive "dl") + (other (error "Unknown HTML list type: %s" other)))) + (class (format "org-%s" type)) + (attributes (org-export-read-attribute :attr_html plain-list))) + (format "<%s %s>\n%s" + type + (org-html--make-attribute-string + (plist-put attributes :class + (org-trim + (mapconcat #'identity + (list class (plist-get attributes :class)) + " ")))) + contents + 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)) + (dolist (a org-html-special-string-regexps string) + (let ((re (car a)) + (rpl (cdr a))) + (setq string (replace-regexp-in-string re rpl string t))))) (defun org-html-encode-plain-text (text) "Convert plain text characters from TEXT to HTML equivalent. @@ -3102,34 +3258,31 @@ contextual information." ;; Planning -(defun org-html-planning (planning contents info) +(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 "%s %s")) - (format - "

    %s

    " - (mapconcat - 'identity - (delq nil - (list - (let ((closed (org-element-property :closed planning))) - (when closed - (format span-fmt org-closed-string - (org-timestamp-translate closed)))) - (let ((deadline (org-element-property :deadline planning))) - (when deadline - (format span-fmt org-deadline-string - (org-timestamp-translate deadline)))) - (let ((scheduled (org-element-property :scheduled planning))) - (when scheduled - (format span-fmt org-scheduled-string - (org-timestamp-translate scheduled)))))) - " ")))) + (format + "

    %s

    " + (org-trim + (mapconcat + (lambda (pair) + (let ((timestamp (cdr pair))) + (when timestamp + (let ((string (car pair))) + (format "%s \ +%s " + string + (org-html-plain-text (org-timestamp-translate timestamp) + info)))))) + `((,org-closed-string . ,(org-element-property :closed planning)) + (,org-deadline-string . ,(org-element-property :deadline planning)) + (,org-scheduled-string . ,(org-element-property :scheduled planning))) + "")))) ;;;; Property Drawer -(defun org-html-property-drawer (property-drawer contents info) +(defun org-html-property-drawer (_property-drawer contents _info) "Transcode a PROPERTY-DRAWER element from Org to HTML. CONTENTS holds the contents of the drawer. INFO is a plist holding contextual information." @@ -3138,11 +3291,19 @@ holding contextual information." ;;;; Quote Block -(defun org-html-quote-block (quote-block contents info) +(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 "
    \n%s
    " contents)) + (format "\n%s" + (let* ((name (org-element-property :name quote-block)) + (attributes (org-export-read-attribute :attr_html quote-block)) + (a (org-html--make-attribute-string + (if (or (not name) (plist-member attributes :id)) + attributes + (plist-put attributes :id name))))) + (if (org-string-nw-p a) (concat " " a) "")) + contents)) ;;;; Section @@ -3162,7 +3323,7 @@ holding contextual information." #'number-to-string (org-export-get-headline-number parent info) "-")))) ;; Build return value. - (format "
    \n%s
    " + (format "
    \n%s
    \n" class-num (or (org-element-property :CUSTOM_ID parent) section-number @@ -3185,48 +3346,67 @@ contextual information." CONTENTS holds the contents of the block. INFO is a plist holding contextual information." (let* ((block-type (org-element-property :type special-block)) - (contents (or contents "")) - (html5-fancy (and (org-html--html5-fancy-p info) - (member block-type org-html-html5-elements))) - (attributes (org-export-read-attribute :attr_html special-block))) + (html5-fancy (and (org-html--html5-fancy-p info) + (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" block-type attributes - contents block-type) - (format "\n%s\n" attributes contents)))) + (setq attributes (plist-put attributes :class + (if class (concat class " " block-type) + block-type))))) + (let* ((contents (or contents "")) + (name (org-element-property :name special-block)) + (a (org-html--make-attribute-string + (if (or (not name) (plist-member attributes :id)) + attributes + (plist-put attributes :id name)))) + (str (if (org-string-nw-p a) (concat " " a) ""))) + (if html5-fancy + (format "<%s%s>\n%s" block-type str contents block-type) + (format "\n%s\n" str contents))))) ;;;; Src Block -(defun org-html-src-block (src-block contents info) +(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)) + (let* ((lang (org-element-property :language src-block)) (code (org-html-format-code src-block info)) (label (let ((lbl (and (org-element-property :name src-block) (org-export-get-reference src-block info)))) - (if lbl (format " id=\"%s\"" lbl) "")))) + (if lbl (format " id=\"%s\"" lbl) ""))) + (klipsify (and (plist-get info :html-klipsify-src) + (member lang '("javascript" "js" + "ruby" "scheme" "clojure" "php" "html"))))) (if (not lang) (format "
    \n%s
    " label code) - (format - "
    \n%s%s\n
    " - (if (not caption) "" - (format "" - (org-export-data caption info))) - (format "\n
    %s
    " lang label code)))))) + (format "
    \n%s%s\n
    " + ;; Build caption. + (let ((caption (org-export-get-caption src-block))) + (if (not caption) "" + (let ((listing-number + (format + "%s " + (format + (org-html--translate "Listing %d:" info) + (org-export-get-ordinal + src-block info nil #'org-html--has-caption-p))))) + (format "" + listing-number + (org-trim (org-export-data caption info)))))) + ;; Contents. + (let ((open (if org-html-keep-old-src "" "
  • "))) + (format "%s class=\"src src-%s\"%s%s>%s%s" + open lang label (if (and klipsify (string= lang "html")) + " data-editor-type=\"html\"" "") + code close))))))) ;;;; Statistics Cookie -(defun org-html-statistics-cookie (statistics-cookie contents info) +(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))) @@ -3234,7 +3414,7 @@ CONTENTS is nil. INFO is a plist holding contextual information." ;;;; Strike-Through -(defun org-html-strike-through (strike-through contents info) +(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." @@ -3245,7 +3425,7 @@ holding contextual information." ;;;; Subscript -(defun org-html-subscript (subscript contents info) +(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." @@ -3253,7 +3433,7 @@ contextual information." ;;;; Superscript -(defun org-html-superscript (superscript contents info) +(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." @@ -3302,40 +3482,45 @@ 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 + (let* ((group (org-export-table-row-group table-row info)) + (number (org-export-table-row-number table-row info)) + (start-group-p (org-export-table-row-starts-rowgroup-p table-row info)) - (end-rowgroup-p + (end-group-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 + (topp (and (equal start-group-p '(top)) + (equal end-group-p '(below top)))) + (bottomp (and (equal start-group-p '(above)) + (equal end-group-p '(bottom above)))) + (row-open-tag + (pcase (plist-get info :html-table-row-open-tag) + ((and accessor (pred functionp)) + (funcall accessor + number group start-group-p end-group-p topp bottomp)) + (accessor accessor))) + (row-close-tag + (pcase (plist-get info :html-table-row-close-tag) + ((and accessor (pred functionp)) + (funcall accessor + number group start-group-p end-group-p topp bottomp)) + (accessor accessor))) + (group-tags (cond - ;; Case 1: Row belongs to second or subsequent rowgroups. - ((not (= 1 rowgroup-number)) - '("" . "\n")) - ;; Case 2: Row is from first rowgroup. Table has >=1 rowgroups. + ;; Row belongs to second or subsequent groups. + ((not (= 1 group)) '("" . "\n")) + ;; Row is from first group. Table has >=1 groups. ((org-export-table-has-header-p (org-export-get-parent-table table-row) info) '("" . "\n")) - ;; Case 2: Row is from first and only row group. + ;; Row is from first and only group. (t '("" . "\n"))))) - (concat - ;; Begin a rowgroup? - (when start-rowgroup-p (car rowgroup-tags)) - ;; Actual table row - (concat "\n" (eval (car (plist-get info :html-table-row-tags))) - contents - "\n" - (eval (cdr (plist-get info :html-table-row-tags)))) - ;; End a rowgroup? - (when end-rowgroup-p (cdr rowgroup-tags)))))) + (concat (and start-group-p (car group-tags)) + (concat "\n" + row-open-tag + contents + "\n" + row-close-tag) + (and end-group-p (cdr group-tags)))))) ;;;; Table @@ -3351,7 +3536,7 @@ INFO is a plist used as a communication channel." (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) +(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) @@ -3372,63 +3557,61 @@ INFO is a plist used as a communication channel." "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* ((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 (org-element-property :name table) - (list :id (org-export-get-reference table info))) - (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=\"org-%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") - ;; 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")))) - (org-html-table-first-row-data-cells table info) "\n"))))) - (format "\n%s\n%s\n%s" - (if (equal attributes "") "" (concat " " attributes)) - (if (not caption) "" - (format (if (plist-get info :html-table-caption-above) - "%s" - "%s") - (concat - "" - (format (org-html--translate "Table %d:" info) number) - " " (org-export-data caption info)))) - (funcall table-column-specs table info) - contents))))) + (if (eq (org-element-property :type table) 'table.el) + ;; "table.el" table. Convert it using appropriate tools. + (org-html-table--table.el-table table info) + ;; Standard table. + (let* ((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 (org-element-property :name table) + (list :id (org-export-get-reference table info))) + (and (not (org-html-html5-p info)) + (plist-get info :html-table-attributes)) + (org-export-read-attribute :attr_html table)))) + (alignspec + (if (bound-and-true-p org-html-format-table-no-css) + "align=\"%s\"" + "class=\"org-%s\"")) + (table-column-specs + (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") + ;; Add a column. Also specify its 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")))) + (org-html-table-first-row-data-cells table info) "\n")))) + (format "\n%s\n%s\n%s" + (if (equal attributes "") "" (concat " " attributes)) + (if (not caption) "" + (format (if (plist-get info :html-table-caption-above) + "%s" + "%s") + (concat + "" + (format (org-html--translate "Table %d:" info) number) + " " (org-export-data caption info)))) + (funcall table-column-specs table info) + contents)))) ;;;; Target -(defun org-html-target (target contents info) +(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." @@ -3437,7 +3620,7 @@ information." ;;;; Timestamp -(defun org-html-timestamp (timestamp contents info) +(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." @@ -3447,7 +3630,7 @@ information." ;;;; Underline -(defun org-html-underline (underline contents info) +(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." @@ -3457,7 +3640,7 @@ holding contextual information." ;;;; Verbatim -(defun org-html-verbatim (verbatim contents info) +(defun org-html-verbatim (verbatim _contents info) "Transcode VERBATIM from Org to HTML. CONTENTS is nil. INFO is a plist holding contextual information." @@ -3466,30 +3649,25 @@ information." ;;;; Verse Block -(defun org-html-verse-block (verse-block contents info) +(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 " ")))))) - (setq contents (replace-match ws nil t contents)))) - (format "

    \n%s

    " contents)) + (format "

    \n%s

    " + ;; Replace leading white spaces with non-breaking spaces. + (replace-regexp-in-string + "^[ \t]+" (lambda (m) (org-html--make-string (length m) " ")) + ;; Replace each newline character with line break. Also + ;; remove any trailing "br" close-tag so as to avoid + ;; duplicates. + (let* ((br (org-html-close-tag "br" nil info)) + (re (format "\\(?:%s\\)?[ \t]*\n" (regexp-quote br)))) + (replace-regexp-in-string re (concat br "\n") contents))))) ;;; Filter Functions -(defun org-html-final-function (contents backend info) +(defun org-html-final-function (contents _backend info) "Filter to indent the HTML and convert HTML entities." (with-temp-buffer (insert contents) @@ -3539,10 +3717,10 @@ is non-nil." ;;;###autoload (defun org-html-convert-region-to-html () - "Assume the current region has org-mode syntax, and convert it to HTML. + "Assume the current region has Org 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." +itemized list in Org syntax in an HTML buffer and use this command +to convert it." (interactive) (org-export-replace-region-by 'html)) diff --git a/elpa/org-plus-contrib-20150831/ox-icalendar.el b/elpa/org-plus-contrib-20170407/ox-icalendar.el similarity index 93% rename from elpa/org-plus-contrib-20150831/ox-icalendar.el rename to elpa/org-plus-contrib-20170407/ox-icalendar.el index ae161517..966353a1 100644 --- a/elpa/org-plus-contrib-20150831/ox-icalendar.el +++ b/elpa/org-plus-contrib-20170407/ox-icalendar.el @@ -1,6 +1,6 @@ -;;; ox-icalendar.el --- iCalendar Back-End for Org Export Engine +;;; ox-icalendar.el --- iCalendar Back-End for Org Export Engine -*- lexical-binding: t; -*- -;; Copyright (C) 2004-2015 Free Software Foundation, Inc. +;; Copyright (C) 2004-2017 Free Software Foundation, Inc. ;; Author: Carsten Dominik ;; Nicolas Goaziou @@ -31,7 +31,7 @@ ;;; Code: -(eval-when-compile (require 'cl)) +(require 'cl-lib) (require 'ox-ascii) (declare-function org-bbdb-anniv-export-ical "org-bbdb" nil) @@ -46,7 +46,7 @@ (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]. +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) @@ -76,8 +76,8 @@ for timed events. If non-zero, alarms are created. (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 +This variable allows specifying different exclude tags from other +back-ends. It can also be set with the ICALENDAR_EXCLUDE_TAGS keyword." :group 'org-export-icalendar :type '(repeat (string :tag "Tag"))) @@ -396,7 +396,8 @@ Universal Time, ignoring `org-icalendar-date-time-format'." ;; 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))))))) + (and (or utc (and with-time-p (org-icalendar-use-UTC-date-time-p))) + t))))) (defun org-icalendar-dtstamp () "Return DTSTAMP property, as a string." @@ -407,27 +408,25 @@ Universal Time, ignoring `org-icalendar-date-time-format'." ENTRY is a headline or an inlinetask element. INFO is a plist used as a communication channel." (mapconcat - 'identity + #'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))) ",")) + (dolist (type org-icalendar-categories (nreverse categories)) + (cl-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))))))) + ",")) (defun org-icalendar-transcode-diary-sexp (sexp uid summary) "Transcode a diary sexp into iCalendar format. @@ -450,7 +449,7 @@ or subject for the event." ;; characters with literal \n. (replace-regexp-in-string "[ \t]*\n" "\\n" - (replace-regexp-in-string "[\\,;]" "\\\&" s) + (replace-regexp-in-string "[\\,;]" "\\\\\\&" s) nil t))) (defun org-icalendar-fold-string (s) @@ -459,7 +458,7 @@ or subject for the event." (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. + ;; longer, fold it by using "\r\n " as a continuation marker. (let ((len (length line))) (if (<= len 75) line (let ((folded-line (substring line 0 75)) @@ -469,17 +468,17 @@ or subject for the event." ;; line, real contents must be split at 74 chars. (while (< (setq chunk-end (+ chunk-start 74)) len) (setq folded-line - (concat folded-line "\n " + (concat folded-line "\r\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"))) + (concat folded-line "\r\n " (substring line chunk-start)))))) + (org-split-string s "\n") "\r\n"))) ;;; Filters -(defun org-icalendar-clear-blank-lines (headline back-end info) +(defun org-icalendar-clear-blank-lines (headline _back-end _info) "Remove blank lines in HEADLINE export. HEADLINE is a string representing a transcoded headline. BACK-END and INFO are ignored." @@ -576,11 +575,11 @@ inlinetask within the section." 'timestamp (lambda (ts) (when (let ((type (org-element-property :type ts))) - (case (plist-get info :with-timestamps) + (cl-case (plist-get info :with-timestamps) (active (memq type '(active active-range))) (inactive (memq type '(inactive inactive-range))) ((t) t))) - (let ((uid (format "TS%d-%s" (incf counter) uid))) + (let ((uid (format "TS%d-%s" (cl-incf counter) uid))) (org-icalendar--vevent entry ts uid summary loc desc cat)))) info nil (and (eq type 'headline) 'inlinetask)) @@ -589,7 +588,7 @@ inlinetask within the section." ;; so, call `org-icalendar--vtodo' to transcode it into ;; a "VTODO" component. (when (and todo-type - (case (plist-get info :icalendar-include-todo) + (cl-case (plist-get info :icalendar-include-todo) (all t) (unblocked (and (eq type 'headline) @@ -611,7 +610,7 @@ inlinetask within the section." (lambda (sexp) (org-icalendar-transcode-diary-sexp (org-element-property :value sexp) - (format "DS%d-%s" (incf counter) uid) + (format "DS%d-%s" (cl-incf counter) uid) summary)) info nil (and (eq type 'headline) 'inlinetask)) ""))))) @@ -627,7 +626,7 @@ inlinetask within the section." contents)))) (defun org-icalendar--vevent - (entry timestamp uid summary location description categories) + (entry timestamp uid summary location description categories) "Create a VEVENT component. ENTRY is either a headline or an inlinetask element. TIMESTAMP @@ -651,7 +650,7 @@ Return VEVENT component as a string." ;; RRULE. (when (org-element-property :repeater-type timestamp) (format "RRULE:FREQ=%s;INTERVAL=%d\n" - (case (org-element-property :repeater-unit timestamp) + (cl-case (org-element-property :repeater-unit timestamp) (hour "HOURLY") (day "DAILY") (week "WEEKLY") (month "MONTHLY") (year "YEARLY")) (org-element-property :repeater-value timestamp))) @@ -836,27 +835,23 @@ external process." ;; 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)))) + (let ((files (cl-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)) + (dolist (f results) (org-export-add-to-stack f 'icalendar))) `(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))) + (dolist (file ',files outputfiles) + (with-current-buffer (org-get-agenda-file-buffer file) + (push (expand-file-name (org-icalendar-export-to-ics)) + 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) + (dolist (file files) + (catch 'nextfile + (org-check-agenda-file file) + (with-current-buffer (org-get-agenda-file-buffer file) + (org-icalendar-export-to-ics)))) (org-release-buffers org-agenda-new-buffers))))) ;;;###autoload @@ -871,20 +866,20 @@ 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)))) + (let ((files (cl-remove-if-not #'file-exists-p (org-agenda-files t)))) (org-export-async-start - (lambda (dummy) + (lambda (_) (org-export-add-to-stack (expand-file-name org-icalendar-combined-agenda-file) 'icalendar)) - `(apply 'org-icalendar--combine-files ',files))) - (apply 'org-icalendar--combine-files (org-agenda-files t)))) + `(apply #'org-icalendar--combine-files ',files))) + (apply #'org-icalendar--combine-files (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. + (let* ((org-export-use-babel) ; Don't evaluate Babel block. (contents (org-export-string-as (with-output-to-string @@ -901,14 +896,16 @@ This function assumes major mode for current buffer is (buffer-substring (point) (progn (outline-next-heading) (point))))))))) (forward-line))))) - 'icalendar t '(:ascii-charset utf-8 :ascii-links-to-notes nil)))) + 'icalendar t + '(:ascii-charset utf-8 :ascii-links-to-notes nil + :icalendar-include-todo all)))) (with-temp-file file (insert (org-icalendar--vcalendar org-icalendar-combined-name user-full-name - org-icalendar-combined-description (or (org-string-nw-p org-icalendar-timezone) (cadr (current-time-zone))) + org-icalendar-combined-description contents))) (run-hook-with-args 'org-icalendar-after-save-hook file))) diff --git a/elpa/org-plus-contrib-20150831/ox-koma-letter.el b/elpa/org-plus-contrib-20170407/ox-koma-letter.el similarity index 78% rename from elpa/org-plus-contrib-20150831/ox-koma-letter.el rename to elpa/org-plus-contrib-20170407/ox-koma-letter.el index 8ba380c8..37da54cb 100644 --- a/elpa/org-plus-contrib-20150831/ox-koma-letter.el +++ b/elpa/org-plus-contrib-20170407/ox-koma-letter.el @@ -1,6 +1,6 @@ ;;; ox-koma-letter.el --- KOMA Scrlttr2 Back-End for Org Export Engine -;; Copyright (C) 2007-2015 Free Software Foundation, Inc. +;; Copyright (C) 2007-2017 Free Software Foundation, Inc. ;; Author: Nicolas Goaziou ;; Alan Schmitt @@ -41,13 +41,14 @@ ;; - PHONE_NUMBER: see `org-koma-letter-phone-number', ;; - SIGNATURE: see `org-koma-letter-signature', ;; - PLACE: see `org-koma-letter-place', +;; - LOCATION: see `org-koma-letter-location', ;; - TO_ADDRESS: If unspecified this is set to "\mbox{}". ;; -;; TO_ADDRESS and FROM_ADDRESS can also be specified using heading -;; with the special tags specified in -;; `org-koma-letter-special-tags-in-letter', namely "to" and "from". -;; LaTeX line breaks are not necessary if using these headings. If -;; both a headline and a keyword specify a to or from address the +;; TO_ADDRESS, FROM_ADDRESS, LOCATION, CLOSING, and SIGNATURE can also +;; be specified using "special headings" with the special tags +;; specified in `org-koma-letter-special-tags-in-letter'. LaTeX line +;; breaks are not necessary for TO_ADDRESS, FROM_ADDRESS and LOCATION. +;; If both a headline and a keyword specify a to or from address the ;; value is determined in accordance with ;; `org-koma-letter-prefer-special-headings'. ;; @@ -58,6 +59,7 @@ ;; - phone (see `org-koma-letter-use-phone') ;; - email (see `org-koma-letter-use-email') ;; - place (see `org-koma-letter-use-place') +;; - location (see `org-koma-letter-use-location') ;; - subject, a list of format options ;; (see `org-koma-letter-subject-format') ;; - after-closing-order, a list of the ordering of headings with @@ -80,9 +82,9 @@ ;; `org-koma-letter-special-tags-after-closing' used as macros and the ;; content of the headline is the argument. ;; -;; Headlines with two and from may also be used rather than the -;; keyword approach described above. If both a keyword and a headline -;; with information is present precedence is determined by +;; Headlines with to and from may also be used rather than the keyword +;; approach described above. If both a keyword and a headline with +;; information is present precedence is determined by ;; `org-koma-letter-prefer-special-headings'. ;; ;; You need an appropriate association in `org-latex-classes' in order @@ -188,17 +190,35 @@ This option can also be set with the PLACE keyword." :group 'org-export-koma-letter :type 'string) +(defcustom org-koma-letter-location "" + "Sender's extension field, as a string. + +This option can also be set with the LOCATION keyword. +Moreover, when: + (1) Either `org-koma-letter-prefer-special-headings' is non-nil + or there is no LOCATION keyword or the LOCATION keyword is + empty; + (2) the letter contains a headline with the special + tag \"location\"; +then the location will be set as the content of the location +special heading. + +The location field is typically printed right of the address +field (See Figure 4.9. in the English manual of 2015-10-03)." + :group 'org-export-koma-letter + :type 'string) + (defcustom org-koma-letter-opening "" "Letter's opening, as a string. This option can also be set with the OPENING keyword. Moreover, when: - (1) this value is the empty string; - (2) there's no OPENING keyword or it is empty; - (3) `org-koma-letter-headline-is-opening-maybe' is non-nil; - (4) the letter contains a headline without a special + (1) Either `org-koma-letter-prefer-special-headings' is non-nil + or the CLOSING keyword is empty + (2) `org-koma-letter-headline-is-opening-maybe' is non-nil; + (3) the letter contains a headline without a special tag (e.g. \"to\" or \"ps\"); -then the opening will be implicitly set as the headline title." +then the opening will be implicitly set as the untagged headline title." :group 'org-export-koma-letter :type 'string) @@ -206,12 +226,13 @@ then the opening will be implicitly set as the headline title." "Letter's closing, as a string. This option can also be set with the CLOSING keyword. Moreover, when: - (1) there's no CLOSING keyword or it is empty; + (1) Either `org-koma-letter-prefer-special-headings' is non-nil + or the CLOSING keyword is empty; (2) `org-koma-letter-headline-is-opening-maybe' is non-nil; (3) the letter contains a headline with the special - tag closing; + tag \"closing\"; then the opening will be set as the title of the closing special -heading." +heading title." :group 'org-export-koma-letter :type 'string) @@ -219,12 +240,15 @@ heading." "Signature, as a string. This option can also be set with the SIGNATURE keyword. Moreover, when: - (1) there's no CLOSING keyword or it is empty; + (1) Either `org-koma-letter-prefer-special-headings' is non-nil + or there is no CLOSING keyword or the CLOSING keyword is empty; (2) `org-koma-letter-headline-is-opening-maybe' is non-nil; (3) the letter contains a headline with the special - tag closing; + tag \"closing\"; then the signature will be set as the content of the -closing special heading." +closing special heading. + +Note if the content is empty the signature will not be set." :group 'org-export-koma-letter :type 'string) @@ -359,9 +383,9 @@ The value must be a member of `org-latex-classes'." :type 'string) (defcustom org-koma-letter-headline-is-opening-maybe t - "Non-nil means a headline may be used as an opening. -A headline is only used if #+OPENING is not set. See also -`org-koma-letter-opening'." + "Non-nil means a headline may be used as an opening and closing. +See also `org-koma-letter-opening' and +`org-koma-letter-closing'." :group 'org-export-koma-letter :type 'boolean) @@ -372,14 +396,17 @@ e.g. \"title-subject:t\"." :group 'org-export-koma-letter :type 'boolean) -(defconst org-koma-letter-special-tags-in-letter '(to from closing) +(defconst org-koma-letter-special-tags-in-letter '(to from closing location) "Header tags related to the letter itself.") -(defconst org-koma-letter-special-tags-after-closing '(ps encl cc) - "Header tags to be inserted after closing.") +(defconst org-koma-letter-special-tags-after-closing '(after_closing ps encl cc) + "Header tags to be inserted in the letter after closing.") + +(defconst org-koma-letter-special-tags-as-macro '(ps encl cc) + "Header tags to be inserted as macros") (defconst org-koma-letter-special-tags-after-letter '(after_letter) - "Header tags to be inserted after closing.") + "Header tags to be inserted after the letter.") (defvar org-koma-letter-special-contents nil "Holds special content temporarily.") @@ -402,20 +429,18 @@ e.g. \"title-subject:t\"." (:email "EMAIL" nil (org-koma-letter--get-value org-koma-letter-email) t) (:to-address "TO_ADDRESS" nil nil newline) (:place "PLACE" nil org-koma-letter-place) + (:location "LOCATION" nil org-koma-letter-location) (:subject "SUBJECT" nil nil parse) (:opening "OPENING" nil org-koma-letter-opening parse) (:closing "CLOSING" nil org-koma-letter-closing parse) (:signature "SIGNATURE" nil org-koma-letter-signature newline) - (:special-headings nil "special-headings" - org-koma-letter-prefer-special-headings) - (:special-tags nil nil (append - org-koma-letter-special-tags-in-letter - org-koma-letter-special-tags-after-closing - org-koma-letter-special-tags-after-letter)) - (:with-after-closing nil "after-closing-order" - org-koma-letter-special-tags-after-closing) - (:with-after-letter nil "after-letter-order" - org-koma-letter-special-tags-after-letter) + (:special-headings nil "special-headings" org-koma-letter-prefer-special-headings) + (:special-tags-as-macro nil nil org-koma-letter-special-tags-as-macro) + (:special-tags-in-letter nil nil org-koma-letter-special-tags-in-letter) + (:special-tags-after-closing nil "after-closing-order" + org-koma-letter-special-tags-after-closing) + (:special-tags-after-letter nil "after-letter-order" + org-koma-letter-special-tags-after-letter) (:with-backaddress nil "backaddress" org-koma-letter-use-backaddress) (:with-email nil "email" org-koma-letter-use-email) (:with-foldmarks nil "foldmarks" org-koma-letter-use-foldmarks) @@ -428,19 +453,22 @@ e.g. \"title-subject:t\"." ;; They are used to prioritize in-buffer settings over "lco" ;; files. See `org-koma-letter-template'. (:inbuffer-author "AUTHOR" nil 'koma-letter:empty) + (:inbuffer-from "FROM" nil 'koma-letter:empty) (:inbuffer-email "EMAIL" nil 'koma-letter:empty) (:inbuffer-phone-number "PHONE_NUMBER" nil 'koma-letter:empty) (:inbuffer-place "PLACE" nil 'koma-letter:empty) + (:inbuffer-location "LOCATION" nil 'koma-letter:empty) (:inbuffer-signature "SIGNATURE" nil 'koma-letter:empty) (:inbuffer-with-backaddress nil "backaddress" 'koma-letter:empty) (:inbuffer-with-email nil "email" 'koma-letter:empty) (:inbuffer-with-foldmarks nil "foldmarks" 'koma-letter:empty) - (:inbuffer-with-phone nil "phone" 'koma-letter:empty)) + (:inbuffer-with-phone nil "phone" 'koma-letter:empty) + (:inbuffer-with-place nil "place" 'koma-letter:empty)) :translate-alist '((export-block . org-koma-letter-export-block) - (export-snippet . org-koma-letter-export-snippet) - (headline . org-koma-letter-headline) - (keyword . org-koma-letter-keyword) - (template . org-koma-letter-template)) + (export-snippet . org-koma-letter-export-snippet) + (headline . org-koma-letter-headline) + (keyword . org-koma-letter-keyword) + (template . org-koma-letter-template)) :menu-entry '(?k "Export with KOMA Scrlttr2" ((?L "As LaTeX buffer" org-koma-letter-export-as-latex) @@ -465,8 +493,9 @@ e.g. \"title-subject:t\"." (defun org-koma-letter--get-tagged-contents (key) "Get contents from a headline tagged with KEY. The contents is stored in `org-koma-letter-special-contents'." - (cdr (assoc-string (org-koma-letter--get-value key) - org-koma-letter-special-contents))) + (let ((value (cdr (assoc-string (org-koma-letter--get-value key) + org-koma-letter-special-contents)))) + (when value (org-string-nw-p (org-trim value))))) (defun org-koma-letter--get-value (value) "Turn value into a string whenever possible. @@ -478,46 +507,31 @@ return a string or nil." ((symbolp value) (symbol-name value)) (t value)))) -(defun org-koma-letter--special-contents-as-macro - (keywords &optional keep-newlines no-tag) +(defun org-koma-letter--special-contents-inline (keywords info) "Process KEYWORDS members of `org-koma-letter-special-contents'. KEYWORDS is a list of symbols. Return them as a string to be formatted. The function is used for inserting content of special headings -such as PS. - -If KEEP-NEWLINES is non-nil leading and trailing newlines are not -removed. If NO-TAG is non-nil the content in -`org-koma-letter-special-contents' are not wrapped in a macro -named whatever the members of KEYWORDS are called." +such as the one tagged with PS. +" (mapconcat (lambda (keyword) (let* ((name (org-koma-letter--get-value keyword)) - (value (org-koma-letter--get-tagged-contents name))) + (value (org-koma-letter--get-tagged-contents name)) + (macrop (memq keyword (plist-get info :special-tags-as-macro)))) (cond ((not value) nil) - (no-tag (if keep-newlines value (org-trim value))) - (t (format "\\%s{%s}\n" - name - (if keep-newlines value (org-trim value))))))) + (macrop (format "\\%s{%s}\n" name value)) + (t value)))) keywords - "")) + "\n")) -(defun org-koma-letter--determine-to-and-from (info key) - "Given INFO determine KEY for the letter. -KEY should be `to' or `from'. -`ox-koma-letter' allows two ways to specify TO and FROM. If both -are present return the preferred one as determined by -`org-koma-letter-prefer-special-headings'." - (let ((option (org-string-nw-p - (plist-get info (if (eq key 'to) :to-address :from-address)))) - (headline (org-koma-letter--get-tagged-contents key))) - (replace-regexp-in-string - "\n" "\\\\\\\\\n" - (org-trim - (if (plist-get info :special-headings) (or headline option "") - (or option headline "")))))) +(defun org-koma-letter--add-latex-newlines (string) + "Replace regular newlines with LaTeX newlines (i.e. `\\\\')" + (let ((str (org-trim string))) + (when (org-string-nw-p str) + (replace-regexp-in-string "\n" "\\\\\\\\\n" str)))) @@ -575,12 +589,35 @@ appropriate place." "Non-nil if HEADLINE is a special headline. INFO is a plist holding contextual information. Return first special tag headline." - (let ((special-tags (plist-get info :special-tags))) + (let ((special-tags (append + (plist-get info :special-tags-in-letter) + (plist-get info :special-tags-after-closing) + (plist-get info :special-tags-after-letter)))) (catch 'exit (dolist (tag (org-export-get-tags headline info)) (let ((tag (assoc-string tag special-tags))) (when tag (throw 'exit tag))))))) +(defun org-koma-letter--keyword-or-headline (plist-key pred info) + "Return the correct version of opening or closing. +PLIST-KEY should be a key in info, typically :opening +or :closing. PRED is a predicate run on headline to determine +which title to use which takes two arguments, a headline element +and an info plist. INFO is a plist holding contextual +information. Return the preferred candidate for the exported of +PLIST-KEY." + (let* ((keyword-candidate (plist-get info plist-key)) + (headline-candidate (when (and (plist-get info :with-headline-opening) + (or (plist-get info :special-headings) + (not keyword-candidate))) + (org-element-map (plist-get info :parse-tree) + 'headline + (lambda (head) + (when (funcall pred head info) + (org-element-property :title head))) + info t)))) + (org-export-data (or headline-candidate keyword-candidate "") info))) + ;;;; Template (defun org-koma-letter-template (contents info) @@ -591,8 +628,10 @@ holding export options." ;; Time-stamp. (and (plist-get info :time-stamp-file) (format-time-string "%% Created %Y-%m-%d %a %H:%M\n")) + ;; LaTeX compiler + (org-latex--insert-compiler info) ;; Document class and packages. - (org-latex--make-header info) + (org-latex-make-preamble info) ;; Settings. They can come from three locations, in increasing ;; order of precedence: global variables, LCO files and in-buffer ;; settings. Thus, we first insert settings coming from global @@ -603,10 +642,6 @@ holding export options." (org-split-string (or (plist-get info :lco) "") " ") "") (org-koma-letter--build-settings 'buffer info) - ;; From address. - (let ((from-address (org-koma-letter--determine-to-and-from info 'from))) - (when (org-string-nw-p from-address) - (format "\\setkomavar{fromaddress}{%s}\n" from-address))) ;; Date. (format "\\date{%s}\n" (org-export-data (org-export-get-date info) info)) ;; Hyperref, document start, and subject and title. @@ -642,40 +677,33 @@ holding export options." (when title (format "\\setkomavar{title}{%s}\n" title)) (when (or (org-string-nw-p title) (org-string-nw-p subject)) "\n"))) ;; Letter start. - (format "\\begin{letter}{%%\n%s}\n\n" - (org-koma-letter--determine-to-and-from info 'to)) + (let ((keyword-val (plist-get info :to-address)) + (heading-val (org-koma-letter--get-tagged-contents 'to))) + (format "\\begin{letter}{%%\n%s}\n\n" + (org-koma-letter--add-latex-newlines + (or (if (plist-get info :special-headings) + (or heading-val keyword-val) + (or keyword-val heading-val)) + "\\\\mbox{}")))) ;; Opening. (format "\\opening{%s}\n\n" - (org-export-data - (or (org-string-nw-p (plist-get info :opening)) - (when (plist-get info :with-headline-opening) - (org-element-map (plist-get info :parse-tree) 'headline - (lambda (head) - (unless (org-koma-letter--special-tag head info) - (org-element-property :title head))) - info t)) - "") + (org-koma-letter--keyword-or-headline + :opening (lambda (h i) (not (org-koma-letter--special-tag h i))) info)) ;; Letter body. contents ;; Closing. - (format "\n\\closing{%s}\n" - (org-export-data - (or (org-string-nw-p (plist-get info :closing)) - (when (plist-get info :with-headline-opening) - (org-element-map (plist-get info :parse-tree) 'headline - (lambda (head) - (when (eq (org-koma-letter--special-tag head info) - 'closing) - (org-element-property :title head))) - info t))) + (format "\\closing{%s}\n" + (org-koma-letter--keyword-or-headline + :closing (lambda (h i) (eq (org-koma-letter--special-tag h i) + 'closing)) info)) - (org-koma-letter--special-contents-as-macro - (plist-get info :with-after-closing)) + (org-koma-letter--special-contents-inline + (plist-get info :special-tags-after-closing) info) ;; Letter end. "\n\\end{letter}\n" - (org-koma-letter--special-contents-as-macro - (plist-get info :with-after-letter) t t) + (org-koma-letter--special-contents-inline + (plist-get info :special-tags-after-letter) info) ;; Document end. "\n\\end{document}")) @@ -683,14 +711,24 @@ holding export options." "Build settings string according to type. SCOPE is either `global' or `buffer'. INFO is a plist used as a communication channel." - (let ((check-scope - (function - ;; Non-nil value when SETTING was defined in SCOPE. - (lambda (setting) - (let ((property (intern (format ":inbuffer-%s" setting)))) - (if (eq scope 'global) - (eq (plist-get info property) 'koma-letter:empty) - (not (eq (plist-get info property) 'koma-letter:empty)))))))) + (let* ((check-scope + (function + ;; Non-nil value when SETTING was defined in SCOPE. + (lambda (setting) + (let ((property (intern (format ":inbuffer-%s" setting)))) + (if (eq scope 'global) + (eq (plist-get info property) 'koma-letter:empty) + (not (eq (plist-get info property) 'koma-letter:empty))))))) + (heading-or-key-value + (function + (lambda (heading key &optional scoped) + (let* ((heading-val + (org-koma-letter--get-tagged-contents heading)) + (key-val (org-string-nw-p (plist-get info key))) + (scopedp (funcall check-scope (or scoped heading)))) + (and (or (and key-val scopedp) heading-val) + (not (and (eq scope 'global) heading-val)) + (if scopedp key-val heading-val))))))) (concat ;; Name. (let ((author (plist-get info :author))) @@ -698,6 +736,11 @@ a communication channel." (funcall check-scope 'author) (format "\\setkomavar{fromname}{%s}\n" (org-export-data author info)))) + ;; From. + (let ((from (funcall heading-or-key-value 'from :from-address))) + (and from + (format "\\setkomavar{fromaddress}{%s}\n" + (org-koma-letter--add-latex-newlines from)))) ;; Email. (let ((email (plist-get info :email))) (and email @@ -734,9 +777,17 @@ a communication channel." (format "\\KOMAoption{backaddress}{%s}\n" (if (plist-get info :with-backaddress) "true" "false"))) ;; Place. - (and (funcall check-scope 'place) - (format "\\setkomavar{place}{%s}\n" - (if (plist-get info :with-place) (plist-get info :place) ""))) + (let ((with-place-set (funcall check-scope 'with-place)) + (place-set (funcall check-scope 'place))) + (and (or (and with-place-set place-set) + (and (eq scope 'buffer) (or with-place-set place-set))) + (format "\\setkomavar{place}{%s}\n" + (if (plist-get info :with-place) (plist-get info :place) + "")))) + ;; Location. + (let ((location (funcall heading-or-key-value 'location :location))) + (and location + (format "\\setkomavar{location}{%s}\n" location))) ;; Folding marks. (and (funcall check-scope 'with-foldmarks) (let ((foldmarks (plist-get info :with-foldmarks))) diff --git a/elpa/org-plus-contrib-20150831/ox-latex.el b/elpa/org-plus-contrib-20170407/ox-latex.el similarity index 80% rename from elpa/org-plus-contrib-20150831/ox-latex.el rename to elpa/org-plus-contrib-20170407/ox-latex.el index ddbbd336..58657c73 100644 --- a/elpa/org-plus-contrib-20150831/ox-latex.el +++ b/elpa/org-plus-contrib-20170407/ox-latex.el @@ -1,6 +1,6 @@ -;;; ox-latex.el --- LaTeX Back-End for Org Export Engine +;;; ox-latex.el --- LaTeX Back-End for Org Export Engine -*- lexical-binding: t; -*- -;; Copyright (C) 2011-2015 Free Software Foundation, Inc. +;; Copyright (C) 2011-2017 Free Software Foundation, Inc. ;; Author: Nicolas Goaziou ;; Keywords: outlines, hypermedia, calendar, wp @@ -26,7 +26,7 @@ ;;; Code: -(eval-when-compile (require 'cl)) +(require 'cl-lib) (require 'ox) (require 'ox-publish) @@ -90,7 +90,6 @@ ;; Pseudo objects and elements. (latex-math-block . org-latex-math-block) (latex-matrices . org-latex-matrices)) - :export-block '("LATEX" "TEX") :menu-entry '(?l "Export to LaTeX" ((?L "As LaTeX buffer" org-latex-export-as-latex) @@ -101,8 +100,11 @@ (if a (org-latex-export-to-pdf t s v b) (org-open-file (org-latex-export-to-pdf nil s v b))))))) :filters-alist '((:filter-options . org-latex-math-block-options-filter) + (:filter-paragraph . org-latex-clean-invalid-line-breaks) (:filter-parse-tree org-latex-math-block-tree-filter - org-latex-matrices-tree-filter)) + org-latex-matrices-tree-filter + org-latex-image-link-filter) + (:filter-verse-block . org-latex-clean-invalid-line-breaks)) :options-alist '((:latex-class "LATEX_CLASS" nil org-latex-default-class t) (:latex-class-options "LATEX_CLASS_OPTIONS" nil nil t) @@ -119,6 +121,7 @@ (:latex-default-table-environment nil nil org-latex-default-table-environment) (:latex-default-table-mode nil nil org-latex-default-table-mode) (:latex-diary-timestamp-format nil nil org-latex-diary-timestamp-format) + (:latex-footnote-defined-format nil nil org-latex-footnote-defined-format) (:latex-footnote-separator nil nil org-latex-footnote-separator) (:latex-format-drawer-function nil nil org-latex-format-drawer-function) (:latex-format-headline-function nil nil org-latex-format-headline-function) @@ -127,6 +130,7 @@ (:latex-image-default-height nil nil org-latex-image-default-height) (:latex-image-default-option nil nil org-latex-image-default-option) (:latex-image-default-width nil nil org-latex-image-default-width) + (:latex-images-centered nil nil org-latex-images-centered) (:latex-inactive-timestamp-format nil nil org-latex-inactive-timestamp-format) (:latex-inline-image-rules nil nil org-latex-inline-image-rules) (:latex-link-with-unknown-path-format nil nil org-latex-link-with-unknown-path-format) @@ -144,6 +148,7 @@ (:latex-text-markup-alist nil nil org-latex-text-markup-alist) (:latex-title-command nil nil org-latex-title-command) (:latex-toc-command nil nil org-latex-toc-command) + (:latex-compiler "LATEX_COMPILER" nil org-latex-compiler) ;; Redefine regular options. (:date "DATE" nil "\\today" parse))) @@ -327,7 +332,7 @@ Otherwise, place it near the end. When value is a list of symbols, put caption above selected elements only. Allowed symbols are: `image', `table', `src-block' and `special-block'." :group 'org-export-latex - :version "25.1" + :version "26.1" :package-version '(Org . "8.3") :type '(choice (const :tag "For all elements" t) @@ -363,9 +368,9 @@ For example, when this variable is non-nil, a headline like this: :CUSTOM_ID: sec:foo :END: This is section [[#sec:foo]]. - #+BEGIN_LATEX + #+BEGIN_EXPORT latex And this is still section \\ref{sec:foo}. - #+END_LATEX + #+END_EXPORT will be exported to LaTeX as: @@ -390,7 +395,7 @@ labeling scheme to generate labels and resolve links into proper references." :group 'org-export-latex :type 'boolean - :version "25.1" + :version "26.1" :package-version '(Org . "8.3")) ;;;; Preamble @@ -426,9 +431,9 @@ references." If #+LATEX_CLASS is set in the buffer, use its value and the associated information. Here is the structure of each cell: - \(class-name + (class-name header-string - \(numbered-section . unnumbered-section) + (numbered-section . unnumbered-section) ...) The header string @@ -499,11 +504,11 @@ 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) + (numbered-open numbered-close) or - \(numbered-open numbered-close unnumbered-open unnumbered-close) + (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 @@ -572,14 +577,14 @@ precedence over this variable." The format string should have at most one \"%s\"-expression, which is replaced with the subtitle." :group 'org-export-latex - :version "25.1" + :version "26.1" :package-version '(Org . "8.3") :type '(string :tag "Format string")) (defcustom org-latex-subtitle-separate nil "Non-nil means the subtitle is not typeset as part of title." :group 'org-export-latex - :version "25.1" + :version "26.1" :package-version '(Org . "8.3") :type 'boolean) @@ -616,12 +621,10 @@ inserted. Setting :latex-hyperref-template in publishing projects will take precedence over this variable." :group 'org-export-latex - :version "25.1" + :version "26.1" :package-version '(Org . "8.3") :type '(choice (const :tag "No template" nil) (string :tag "Format string"))) -(define-obsolete-variable-alias - 'org-latex-with-hyperref 'org-latex-hyperref-template "25.1") ;;;; Headline @@ -651,6 +654,16 @@ The function result will be used in the section format string." :group 'org-export-latex :type 'string) +(defcustom org-latex-footnote-defined-format "\\textsuperscript{\\ref{%s}}" + "Format string used to format reference to footnote already defined. +%s will be replaced by the label of the referred footnote." + :group 'org-export-latex + :type '(choice + (const :tag "Use plain superscript (default)" "\\textsuperscript{\\ref{%s}}") + (const :tag "Use Memoir/KOMA-Script footref" "\\footref{%s}") + (string :tag "Other format string")) + :version "26.1" + :package-version '(Org . "9.0")) ;;;; Timestamps @@ -672,6 +685,14 @@ The function result will be used in the section format string." ;;;; Links +(defcustom org-latex-images-centered t + "When non-nil, images are centered." + :group 'org-export-latex + :version "26.1" + :package-version '(Org . "9.0") + :type 'boolean + :safe #'booleanp) + (defcustom org-latex-image-default-option "" "Default option for images." :group 'org-export-latex @@ -697,13 +718,17 @@ environment." :package-version '(Org . "8.0") :type 'string) -(defcustom org-latex-default-figure-position "htb" - "Default position for latex figures." +(defcustom org-latex-default-figure-position "htbp" + "Default position for LaTeX figures." :group 'org-export-latex - :type 'string) + :type 'string + :version "26.1" + :package-version '(Org . "9.0") + :safe #'stringp) (defcustom org-latex-inline-image-rules - '(("file" . "\\.\\(pdf\\|jpeg\\|jpg\\|png\\|ps\\|eps\\|tikz\\|pgf\\|svg\\)\\'")) + `(("file" . ,(regexp-opt + '("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 @@ -821,7 +846,7 @@ 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 - :version "25.1" + :version "26.1" :package-version '(Org . "8.3") :type 'alist :options '(bold code italic strike-through underline verbatim)) @@ -829,8 +854,7 @@ returned as-is." ;;;; Drawers -(defcustom org-latex-format-drawer-function - (lambda (name contents) contents) +(defcustom org-latex-format-drawer-function (lambda (_ contents) contents) "Function called to format a drawer in LaTeX code. The function must accept two parameters: @@ -864,7 +888,7 @@ The function must accept seven parameters: The function should return the string to be exported." :group 'org-export-latex :type 'function - :version "25.1" + :version "26.1" :package-version '(Org . "8.3")) @@ -879,21 +903,21 @@ 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\")) + (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) + (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 '(\"newfloat\" \"minted\")) + (require \\='ox-latex) + (add-to-list \\='org-latex-packages-alist \\='(\"newfloat\" \"minted\")) In addition, it is necessary to install pygments \(http://pygments.org), and to configure the variable @@ -923,7 +947,8 @@ into previewing problems, please consult (gnuplot "Gnuplot") (ocaml "Caml") (caml "Caml") (sql "SQL") (sqlite "sql") - (makefile "make")) + (makefile "make") + (R "r")) "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 @@ -946,9 +971,9 @@ These options are supplied as a comma-separated list to the 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\"))) + (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. @@ -999,8 +1024,8 @@ These options are supplied within square brackets in 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\"))) + (setq org-latex-minted-options + \\='((\"bgcolor\" \"bg\") (\"frame\" \"lines\"))) will result in src blocks being exported with @@ -1020,34 +1045,119 @@ block-specific options, you may use the following syntax: (string :tag "Minted option name ") (string :tag "Minted option value")))) -(defvar org-latex-custom-lang-environments nil +(defcustom 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, +latex packages. The environment may be a simple string, composed of +only letters and numbers. In this case, the string is directly the +name of the latex environment to use. The environment may also be +a format string. In this case the format string will be directly +exported. This format string may contain these elements: + + %s for the formatted source + %c for the caption + %f for the float attribute + %l for an appropriate label + %o for the LaTeX attributes + +For example, + + (setq org-latex-custom-lang-environments + \\='((python \"pythoncode\") + (ocaml \"\\\\begin{listing} +\\\\begin{minted}[%o]{ocaml} +%s\\\\end{minted} +\\\\caption{%c} +\\\\label{%l}\"))) + +would have the effect that if Org encounters a Python source block +during LaTeX export it will produce - \(setq org-latex-custom-lang-environments - '\(\(python \"pythoncode\"\)\)\) + \\begin{pythoncode} + + \\end{pythoncode} -would have the effect that if org encounters begin_src python -during latex export it will output +and if Org encounters an Ocaml source block during LaTeX export it +will produce - \\begin{pythoncode} + \\begin{listing} + \\begin{minted}[]{ocaml} - \\end{pythoncode}") + \\end{minted} + \\caption{} + \\label{