瀏覽代碼

Merge branch 'master' of git://repo.or.cz/org-mode

Dan Davison 14 年之前
父節點
當前提交
2fc7a551e8

+ 127 - 91
Makefile

@@ -7,7 +7,7 @@
 # To create the PDF and HTML documentation files, type `make doc'.
 
 ##----------------------------------------------------------------------
-##  YOU MUST EDIT THE FOLLOWING LINES 
+##  YOU MUST EDIT THE FOLLOWING LINES
 ##----------------------------------------------------------------------
 
 # Name of your emacs binary
@@ -17,7 +17,9 @@ EMACS=emacs
 prefix=/usr/local
 
 # Where local lisp files go.
-lispdir = $(prefix)/share/emacs/site-lisp
+lispdir   = $(prefix)/share/emacs/site-lisp
+lispbdir  = $(lispdir)/babel
+lispbldir = $(lispbdir)/langs
 
 # Where info files go.
 infodir = $(prefix)/share/info
@@ -62,83 +64,109 @@ INSTALL_INFO=install-info
 ##----------------------------------------------------------------------
 
 # The following variables need to be defined by the maintainer
-LISPF      = 	org.el				\
-		org-agenda.el			\
-		org-ascii.el			\
-	     	org-attach.el			\
-	     	org-archive.el			\
-		org-bbdb.el			\
-		org-beamer.el			\
-		org-bibtex.el			\
-	     	org-capture.el			\
-	     	org-clock.el			\
-	     	org-colview.el			\
-	     	org-colview-xemacs.el		\
-	     	org-compat.el			\
-	     	org-crypt.el			\
-	     	org-ctags.el			\
-	     	org-datetree.el			\
-	     	org-docview.el			\
-	     	org-entities.el			\
-		org-exp.el			\
-		org-exp-blocks.el		\
-		org-docbook.el			\
-		org-faces.el			\
-		org-feed.el			\
-		org-footnote.el			\
-		org-freemind.el			\
-		org-gnus.el			\
-		org-habit.el			\
-		org-html.el			\
-		org-icalendar.el		\
-		org-id.el			\
-		org-indent.el			\
-		org-info.el			\
-		org-inlinetask.el		\
-		org-jsinfo.el			\
-		org-irc.el			\
-		org-latex.el			\
-		org-list.el			\
-		org-mac-message.el		\
-	     	org-macs.el			\
-		org-mew.el              	\
-		org-mhe.el			\
-		org-mks.el			\
-		org-mobile.el			\
-		org-mouse.el			\
-		org-publish.el			\
-		org-plot.el			\
-		org-protocol.el			\
-		org-remember.el			\
-		org-rmail.el			\
-		org-src.el			\
-		org-table.el			\
-		org-taskjuggler.el		\
-		org-timer.el			\
-		org-vm.el			\
-		org-w3m.el              	\
-		org-wl.el			\
-		org-xoxo.el			\
-		babel/ob.el			\
-		babel/ob-table.el		\
-		babel/ob-lob.el			\
-		babel/ob-ref.el			\
-		babel/ob-exp.el			\
-		babel/ob-tangle.el		\
-		babel/ob-comint.el		\
-		babel/ob-keys.el		\
-		babel/langs/ob-emacs-lisp.el
-
-LISPFILES0 = $(LISPF:%=lisp/%)
-LISPFILES  = $(LISPFILES0) lisp/org-install.el
-ELCFILES0  = $(LISPFILES0:.el=.elc)
-ELCFILES   = $(LISPFILES:.el=.elc)
-DOCFILES   = doc/org.texi doc/org.pdf doc/org doc/dir \
-             doc/pdflayout.sty doc/.nosearch \
-             doc/orgguide.texi doc/orgguide.pdf
-CARDFILES  = doc/orgcard.tex doc/orgcard.pdf doc/orgcard_letter.pdf
-TEXIFILES  = doc/org.texi
-INFOFILES  = doc/org
+LISPF      = 	org.el			\
+		org-agenda.el		\
+		org-ascii.el		\
+	     	org-attach.el		\
+	     	org-archive.el		\
+		org-bbdb.el		\
+		org-beamer.el		\
+		org-bibtex.el		\
+	     	org-capture.el		\
+	     	org-clock.el		\
+	     	org-colview.el		\
+	     	org-colview-xemacs.el	\
+	     	org-compat.el		\
+	     	org-crypt.el		\
+	     	org-ctags.el		\
+	     	org-datetree.el		\
+	     	org-docview.el		\
+	     	org-entities.el		\
+		org-exp.el		\
+		org-exp-blocks.el	\
+		org-docbook.el		\
+		org-faces.el		\
+		org-feed.el		\
+		org-footnote.el		\
+		org-freemind.el		\
+		org-gnus.el		\
+		org-habit.el		\
+		org-html.el		\
+		org-icalendar.el	\
+		org-id.el		\
+		org-indent.el		\
+		org-info.el		\
+		org-inlinetask.el	\
+		org-jsinfo.el		\
+		org-irc.el		\
+		org-latex.el		\
+		org-list.el		\
+		org-mac-message.el	\
+	     	org-macs.el		\
+		org-mew.el              \
+		org-mhe.el		\
+		org-mks.el		\
+		org-mobile.el		\
+		org-mouse.el		\
+		org-publish.el		\
+		org-plot.el		\
+		org-protocol.el		\
+		org-remember.el		\
+		org-rmail.el		\
+		org-src.el		\
+		org-table.el		\
+		org-taskjuggler.el	\
+		org-timer.el		\
+		org-vm.el		\
+		org-w3m.el              \
+		org-wl.el		\
+		org-xoxo.el
+
+LISPBF     = 	ob.el			\
+		ob-table.el		\
+		ob-lob.el		\
+		ob-ref.el		\
+		ob-exp.el		\
+		ob-tangle.el		\
+		ob-comint.el		\
+		ob-keys.el
+
+LISPBLF   =	ob-C.el			\
+		ob-ditaa.el		\
+		ob-haskell.el		\
+		ob-perl.el		\
+		ob-sh.el		\
+		ob-R.el			\
+		ob-dot.el		\
+		ob-latex.el		\
+		ob-python.el		\
+		ob-sql.el		\
+		ob-asymptote.el		\
+		ob-emacs-lisp.el	\
+		ob-matlab.el		\
+		ob-ruby.el		\
+		ob-sqlite.el		\
+		ob-clojure.el		\
+		ob-ocaml.el		\
+		ob-sass.el		\
+		ob-css.el		\
+		ob-gnuplot.el		\
+		ob-octave.el		\
+		ob-screen.el
+
+LISPFILES0  = $(LISPF:%=lisp/%)
+LISPFILES   = $(LISPFILES0) lisp/org-install.el
+LISPBFILES  = $(LISPBF:%=lisp/babel/%)
+LISPBLFILES = $(LISPBLF:%=lisp/babel/langs/%)
+ELCFILES0   = $(LISPFILES0:.el=.elc)
+ELCFILES    = $(LISPFILES:.el=.elc)
+ELCBFILES   = $(LISPBFILES:.el=.elc)
+DOCFILES    = doc/org.texi doc/org.pdf doc/org doc/dir \
+              doc/pdflayout.sty doc/.nosearch \
+              doc/orgguide.texi doc/orgguide.pdf
+CARDFILES   = doc/orgcard.tex doc/orgcard.pdf doc/orgcard_letter.pdf
+TEXIFILES   = doc/org.texi
+INFOFILES   = doc/org
 
 
 .SUFFIXES: .el .elc .texi
@@ -148,9 +176,9 @@ SHELL = /bin/sh
 DISTFILES_extra=  Makefile ChangeLog request-assign-future.txt contrib
 DISTFILES_xemacs=  xemacs/noutline.el xemacs/ps-print-invisible.el xemacs/README
 
-default: $(ELCFILES)
+default: $(ELCFILES) $(ELCBFILES)
 
-all:	$(ELCFILES) $(INFOFILES)
+all:	$(ELCFILES) $(ELCBFILES) $(INFOFILES)
 
 up2:	update
 	sudo ${MAKE} install
@@ -160,7 +188,7 @@ update:
 	${MAKE} clean
 	${MAKE} all
 
-compile: $(ELCFILES0)
+compile: $(ELCFILES0) $(ELCBFILES)
 
 install: install-lisp
 
@@ -172,10 +200,15 @@ p:
 g:
 	${MAKE} pdf && open doc/orgguide.pdf
 
-install-lisp: $(LISPFILES) $(ELCFILES)
+install-lisp: $(LISPFILES) $(LISPBFILES) $(ELCFILES)
 	if [ ! -d $(lispdir) ]; then $(MKDIR) $(lispdir); else true; fi ;
-	$(CP) $(LISPFILES) $(lispdir)
-	$(CP) $(ELCFILES)  $(lispdir)
+	if [ ! -d $(lispbdir) ]; then $(MKDIR) $(lispbdir); else true; fi ;
+	if [ ! -d $(lispbldir) ]; then $(MKDIR) $(lispbldir); else true; fi ;
+	$(CP) $(LISPFILES)  $(lispdir)
+	$(CP) $(ELCFILES)   $(lispdir)
+	$(CP) $(LISPBFILES) $(lispbdir)
+	$(CP) $(ELCBFILES)  $(lispbdir)
+	$(CP) $(LISPBLFILES) $(lispbldir)
 
 install-info: $(INFOFILES)
 	if [ ! -d $(infodir) ]; then $(MKDIR) $(infodir); else true; fi ;
@@ -191,13 +224,13 @@ install-noutline: xemacs/noutline.elc
 
 autoloads: lisp/org-install.el
 
-lisp/org-install.el: $(LISPFILES0) Makefile
+lisp/org-install.el: $(LISPFILES0) $(LISPBFILES) Makefile
 	$(BATCH) --eval "(require 'autoload)" \
 		--eval '(find-file "org-install.el")'  \
 		--eval '(erase-buffer)' \
-		--eval '(mapc (lambda (x) (generate-file-autoloads (symbol-name x))) (quote ($(LISPFILES0))))' \
-		--eval "(insert \"(add-to-list 'load-path (expand-file-name \\\"babel\\\" (file-name-directory (or (buffer-file-name) load-file-name))))\")" \
-		--eval "(insert \"\n(add-to-list 'load-path (expand-file-name \\\"langs\\\" (expand-file-name \\\"babel\\\" (file-name-directory (or (buffer-file-name) load-file-name)))))\")\n" \
+		--eval '(mapc (lambda (x) (generate-file-autoloads (symbol-name x))) (quote ($(LISPFILES0) $(LISPBFILES))))' \
+		--eval "(insert \"(add-to-list 'load-path (expand-file-name \\\"babel\\\" (file-name-directory (or load-file-name (buffer-file-name)))))\")" \
+		--eval "(insert \"\n(add-to-list 'load-path (expand-file-name \\\"langs\\\" (expand-file-name \\\"babel\\\" (file-name-directory (or load-file-name (buffer-file-name))))))\")\n" \
 		--eval '(insert "\n(provide (quote org-install))\n")' \
 		--eval '(save-buffer)'
 	mv org-install.el lisp
@@ -267,7 +300,10 @@ distfile:
 	$(MKDIR) org-$(TAG)/xemacs
 	$(MKDIR) org-$(TAG)/doc
 	$(MKDIR) org-$(TAG)/lisp
+	$(MKDIR) org-$(TAG)/lisp/babel
+	$(MKDIR) org-$(TAG)/lisp/babel/langs
 	cp -r $(LISPFILES) org-$(TAG)/lisp
+	cp -r $(LISPBFILES) org-$(TAG)/lisp/babel
 	cp -r $(DOCFILES) $(CARDFILES) org-$(TAG)/doc
 	cp -r $(DISTFILES_extra) org-$(TAG)/
 	cp -r README_DIST org-$(TAG)/README
@@ -374,7 +410,7 @@ lisp/org-crypt.elc:	lisp/org-crypt.el lisp/org.el
 lisp/org-ctags.elc:	lisp/org.el
 lisp/org-datetree.elc:	lisp/org.el
 lisp/org-docview.elc:	lisp/org.el
-lisp/org-entities.elc:	
+lisp/org-entities.elc:
 lisp/org-exp.elc:	lisp/org.el lisp/org-agenda.el
 lisp/org-exp-blocks.elc: lisp/org.el
 lisp/org-latex.elc:	lisp/org.el lisp/org-exp.el lisp/org-beamer.el
@@ -398,7 +434,7 @@ lisp/org-mac-message.elc:	lisp/org.el
 lisp/org-macs.elc:
 lisp/org-mew.elc:	lisp/org.el
 lisp/org-mhe.elc:	lisp/org.el
-lisp/org-mks.elc:	
+lisp/org-mks.elc:
 lisp/org-mobile.elc:	lisp/org.el
 lisp/org-mouse.elc:	lisp/org.el
 lisp/org-plot.elc:	lisp/org.el lisp/org-exp.el lisp/org-table.el

+ 2 - 1
UTILITIES/guidesplit.pl

@@ -27,7 +27,8 @@ $contents = <<EOF;
 <li><a name="toc_Markup" href="Markup.html#Markup">11 Markup</a>
 <li><a name="toc_Exporting" href="Exporting.html#Exporting">12 Exporting</a>
 <li><a name="toc_Publishing" href="Publishing.html#Publishing">13 Publishing</a>
-<li><a name="toc_Miscellaneous" href="Miscellaneous.html#Miscellaneous">14 Miscellaneous</a>
+<li><a name="toc_Working-with-source-code" href="Working-with-source-code.html#Working-with-source-code">14 Source code</a>
+<li><a name="toc_Miscellaneous" href="Miscellaneous.html#Miscellaneous">15 Miscellaneous</a>
 </li></ul>
 </div>
 </div>

+ 2 - 1
UTILITIES/mansplit.pl

@@ -27,7 +27,8 @@ $contents = <<EOF;
 <li><a name="toc_Markup" href="Markup.html#Markup">11 Markup</a>
 <li><a name="toc_Exporting" href="Exporting.html#Exporting">12 Exporting</a>
 <li><a name="toc_Publishing" href="Publishing.html#Publishing">13 Publishing</a>
-<li><a name="toc_Miscellaneous" href="Miscellaneous.html#Miscellaneous">14 Miscellaneous</a>
+<li><a name="toc_Working-with-source-code" href="Working-with-source-code.html#Working-with-source-code">14 Source Code</a>
+<li><a name="toc_Miscellaneous" href="Miscellaneous.html#Miscellaneous">15 Miscellaneous</a>
 <li><a name="toc_Hacking" href="Hacking.html#Hacking">A Hacking</a>
 <li><a name="toc_MobileOrg" href="MobileOrg.html#MobileOrg">B MobileOrg</a>
 <li><a name="toc_History-and-Acknowledgments" href="History-and-Acknowledgments.html#History-and-Acknowledgments">C History and Thanks</a>

+ 112 - 6
UTILITIES/pw

@@ -29,13 +29,22 @@ import subprocess
 import base64
 import ConfigParser
 import datetime
+import smtplib
+import urllib
 import re
 
+from email.mime.text import MIMEText
+
+notify_on_state_change = {
+    'Accepted': 'emacs-orgmode@gnu.org',
+    'RFC':      'emacs-orgmode@gnu.org'
+}
+
 # Default Patchwork remote XML-RPC server URL
 # This script will check the PW_XMLRPC_URL environment variable
 # for the URL to access.  If that is unspecified, it will fallback to
 # the hardcoded default value specified here.
-DEFAULT_URL = "http://patchwork/xmlrpc/"
+DEFAULT_URL = "http://patchwork.newartisans.com/xmlrpc/"
 CONFIG_FILES = [os.path.expanduser('~/.pwclientrc')]
 
 class Filter:
@@ -267,7 +276,8 @@ def action_apply(rpc, patch_id):
         sys.stderr.write("Error: No patch content found\n")
         sys.exit(1)
 
-def action_update_patch(rpc, patch_id, state = None, commit = None):
+def action_update_patch(rpc, patch_id, state = None, commit = None,
+                        delegate_str = "", archived = False):
     patch = rpc.patch_get(patch_id)
     if patch == {}:
         sys.stderr.write("Error getting information on patch ID %d\n" % \
@@ -276,6 +286,16 @@ def action_update_patch(rpc, patch_id, state = None, commit = None):
 
     params = {}
 
+    delegate_id = None
+    if delegate_str != "":
+        params['delegate'] = delegate_str
+        ids = person_ids_by_name(rpc, delegate_str)
+        if len(ids) == 0:
+            sys.stderr.write("Note: Nobody found matching *%s*\n"% \
+                             delegate_str)
+        else:
+            delegate_id = ids[0]
+
     if state:
         state_id = state_id_by_name(rpc, state)
         if state_id == 0:
@@ -283,11 +303,55 @@ def action_update_patch(rpc, patch_id, state = None, commit = None):
             sys.exit(1)
         params['state'] = state_id
 
+        if state in notify_on_state_change:
+            if not delegate_id:
+                sys.stderr.write("Error: Delete (-d) required for this update\n")
+                sys.exit(1)
+                
+            person = rpc.person_get(delegate_id)
+            submitter = rpc.person_get(patch['submitter_id'])
+
+            from_addr = '%s <%s>' % (person['name'], person['email'])
+            cc_addr   = '%s <%s>' % (submitter['name'], submitter['email'])
+            to_addr   = notify_on_state_change[state]
+
+            longdesc = '''Patch %s (http://patchwork.newartisans.com/patch/%s/) is now %s.
+
+This relates to the following submission:
+
+http://mid.gmane.org/%s''' % \
+                (patch['id'], patch['id'], state, urllib.quote(patch['msgid']))
+            shortdesc = 'Patch %s %s' % (patch['id'], state)
+
+            msg = MIMEText(longdesc)
+
+            msg['Subject']    = 'Patchwork: ' + shortdesc
+            msg['From']       = from_addr
+            msg['To']         = to_addr
+            #msg['Cc']         = cc_addr
+            msg['References'] = patch['msgid']
+
+            # Send the message via our own SMTP server, but don't include
+            # the envelope header.
+            try:
+                s = smtplib.SMTP('localhost')
+                print "Sending e-mail to: %s, %s" % (to_addr, cc_addr)
+                s.sendmail(from_addr, [to_addr, cc_addr], msg.as_string())
+                s.quit()
+            except:
+                sys.stderr.write("Warning: Failed to send e-mail " +
+                                 "(no SMTP server listening at localhost?)\n")
+
     if commit:
         params['commit_ref'] = commit
 
+    if archived:
+        params['archived'] = archived
+
     success = False
     try:
+        print "Updating patch %d to state '%s', delegate %s" % \
+            (patch_id, state, delegate_str)
         success = rpc.patch_set(patch_id, params)
     except xmlrpclib.Fault, f:
         sys.stderr.write("Error updating patch: %s\n" % f.faultString)
@@ -308,7 +372,7 @@ def patch_id_from_hash(rpc, project, hash):
 
     return patch['id']
 
-def branch_with(patch_id, rpc):
+def branch_with(patch_id, rpc, delegate_str):
     s = rpc.patch_get_mbox(patch_id)
     if len(s) > 0:
         print unicode(s).encode("utf-8")
@@ -356,12 +420,45 @@ def branch_with(patch_id, rpc):
         os.waitpid(proc.pid, 0)
         return
 
+    # If it succeeded this far, mark the patch as "Under Review" by the
+    # invoking user.
+    action_update_patch(rpc, patch_id, state = 'Under Review',
+                        delegate_str = delegate_str)
+
     proc = subprocess.Popen(['git', 'rebase', 'master'])
     sts = os.waitpid(proc.pid, 0)
 
     print sha
 
-auth_actions = ['update']
+def merge_with(patch_id, rpc, delegate_str):
+    s = rpc.patch_get_mbox(patch_id)
+    if len(s) > 0:
+        print unicode(s).encode("utf-8")
+
+    proc = subprocess.Popen(['git', 'checkout', 'master'])
+    sts = os.waitpid(proc.pid, 0)
+    if sts[1] != 0:
+        sys.stderr.write("Failed to checkout master branch\n")
+        return
+
+    proc = subprocess.Popen(['git', 'merge', '--ff', 't/patch%s' % patch_id])
+    sts = os.waitpid(proc.pid, 0)
+    if sts[1] != 0:
+        sys.stderr.write("Failed to merge t/patch%s into master\n" % patch_id)
+        return
+
+    proc = subprocess.Popen(['git', 'rev-parse', 'master'],
+                            stdout = subprocess.PIPE)
+    sha = proc.stdout.read()[:-1]
+
+    # If it succeeded this far, mark the patch as "Accepted" by the invoking
+    # user.
+    action_update_patch(rpc, patch_id, state = 'Accepted', commit = sha,
+                        delegate_str = delegate_str, archived = True)
+
+    print sha
+
+auth_actions = ['update', 'branch', 'merge']
 
 def main():
     try:
@@ -478,7 +575,16 @@ def main():
             sys.stderr.write("Invalid patch ID given\n")
             sys.exit(1)
 
-        branch_with(patch_id, rpc)
+        branch_with(patch_id, rpc, config.get('auth', 'username'))
+
+    elif action == 'merge':
+        try:
+            patch_id = patch_id or int(args[0])
+        except:
+            sys.stderr.write("Invalid patch ID given\n")
+            sys.exit(1)
+
+        merge_with(patch_id, rpc, config.get('auth', 'username'))
 
     elif action == 'view':
         try:
@@ -517,7 +623,7 @@ def main():
             sys.exit(1)
 
         action_update_patch(rpc, patch_id, state = state_str,
-                commit = commit_str)
+                            commit = commit_str, delegate_str = delegate_str)
 
     else:
         sys.stderr.write("Unknown action '%s'\n" % action)

+ 11 - 8
contrib/README

@@ -9,9 +9,11 @@ Please put your contribution in one of these three directories:
 
 LISP (emacs-lisp code)
 ======================
-
+htmlize.el               --- Convert buffer text and decorations to HTML
+org2rem.el               --- Convert org appointments into reminders
 org-annotate-file.el     --- Annotate a file with org syntax
 org-bookmark.el          --- Links to bookmarks
+org-checklist.el         --- org functions for checklist handling
 org-choose.el            --- Use TODO keywords to mark decision states
 org-collector.el         --- Collect properties into tables
 org-contribdir.el        --- Dummy file to mark the org contrib Lisp directory
@@ -19,29 +21,30 @@ org-depend.el            --- TODO dependencies for Org-mode
 org-elisp-symbol.el      --- Org links to emacs-lisp symbols
 org-eval.el              --- The <lisp> tag, adapted from Muse
 org-eval-light.el        --- Evaluate in-buffer code on demand
-org-expiry.el 	         --- Expiry mechanism for Org entries
 org-exp-bibtex.el        --- Export citations to LaTeX and HTML
+org-expiry.el 	         --- Expiry mechanism for Org entries
 org-export-generic.el    --- Export framework for configurable backends
 org-git-link.el          --- Provide org links to specific file version
 org-interactive-query.el --- Interactive modification of tags query
 org-invoice.el           --- Help manage client invoices in OrgMode
 org-jira.el              --- Add a jira:ticket protocol to Org
 org-learn.el             --- SuperMemo's incremental learning algorithm
-org-mairix.el 	         --- Hook mairix search into Org for different MUAs
 org-mac-iCal.el          --- Imports events from iCal.app to the Emacs diary
 org-mac-link-grabber.el  --- Grab links and URLs from various Mac applications
+org-mairix.el 	         --- Hook mairix search into Org for different MUAs
 org-man.el 	         --- Support for links to manpages in Org-mode
+org-mime.el              --- org html export for text/html MIME emails
 org-mtags.el 	         --- Support for some Muse-like tags in Org-mode
 org-panel.el 	         --- Simple routines for us with bad memory
-org-R.el                 --- Computation using the R language
 org-registry.el          --- A registry for Org links
-org2rem.el               --- Convert org appointments into reminders
 org-screen.el            --- Visit screen sessions through Org-mode links
 org-secretary.el         --- Team management with org-mode
 org-special-blocks.el    --- Turn blocks into LaTeX envs and HTML divs
-org-track.el             --- Keep up with Org development
+orgtbl-sqlinsert.el      --- Convert Org-mode tables to SQL insertions
 org-toc.el 	         --- Table of contents for Org-mode buffer
-orgtbl-sqlinsert.el      --- Convert Org-mode tables to SQL insertions.
+org-track.el             --- Keep up with Org development
+
+
 
 PACKAGES
 ========
@@ -51,4 +54,4 @@ SCRIPTS (shell, bash, etc.)
 
 dir2org.zsh          --- Org compatible fs structure output
 org2hpda	     --- Generate hipster pda style printouts from Org-mode
-ditaa.jar            --- ASCII to PNG converter by Stathis Sideris, GPL
+ditaa.jar            --- ASCII to PNG converter by Stathis Sideris, GPL

+ 90 - 2
contrib/babel/library-of-babel.org

@@ -96,9 +96,97 @@ plot(data)
 
 ** Gnuplot
 
-* Table/Matrix manipulation
+* Tables
+** LaTeX Table export
+*** booktabs
+This block can be used to wrap a table in the latex =booktabs=
+environment, it takes the following arguments -- all but the first two
+are optional.
+| arg   | description                                |
+|-------+--------------------------------------------|
+| table | a reference to the table                   |
+| align | optional alignment string                  |
+| env   | optional environment, default to "tabular" |
+| width | optional width specification string        |
+
+#+srcname: booktabs
+#+begin_src emacs-lisp :var table='((:head) hline (:body)) :var align='() :var env="tabular" :var width='() :noweb yes :results latex
+  (flet ((to-tab (tab)
+                 (orgtbl-to-generic
+                  (mapcar (lambda (lis)
+                            (if (listp lis)
+                                (mapcar (lambda (el)
+                                          (if (stringp el)
+                                              el
+                                            (format "%S" el))) lis)
+                              lis)) tab)
+                  (list :lend " \\\\" :sep " & " :hline "\\hline"))))
+    (org-fill-template
+     "
+  \\begin{%env}%width%align
+  \\toprule
+  %table
+  \\bottomrule
+  \\end{%env}\n"
+     (list
+      (cons "env"       (or env "table"))
+      (cons "width"     (if width (format "{%s}" width) ""))
+      (cons "align"     (if align (format "{%s}" align) ""))
+      (cons "table"
+            ;; only use \midrule if it looks like there are column headers
+            (if (equal 'hline (second table))
+                (concat (to-tab (list (first table)))
+                        "\n\\midrule\n"
+                        (to-tab (cddr table)))
+              (to-tab table))))))
+#+end_src
+
+*** longtable
+This block can be used to wrap a table in the latex =longtable=
+environment, it takes the following arguments -- all but the first two
+are optional.
+| arg       | description                                                 |
+|-----------+-------------------------------------------------------------|
+| table     | a reference to the table                                    |
+| align     | optional alignment string                                   |
+| width     | optional width specification string                         |
+| hline     | the string to use as hline separator, defaults to "\\hline" |
+| head      | optional "head" string                                      |
+| firsthead | optional "firsthead" string                                 |
+| foot      | optional "foot" string                                      |
+| lastfoot  | optional "lastfoot" string                                  |
+
+#+srcname: longtable
+#+begin_src emacs-lisp :var table='((:table)) :var align='() :var width='() :var hline="\\hline" :var firsthead='() :var head='() :var foot='() :var lastfoot='() :noweb yes :results latex
+  (org-fill-template
+   "
+  \\begin{longtable}%width%align
+  %firsthead
+  %head
+  %foot
+  %lastfoot
+  
+  %table
+  \\end{longtable}\n"
+   (list
+    (cons "width"     (if width (format "{%s}" width) ""))
+    (cons "align"     (if align (format "{%s}" align) ""))
+    (cons "firsthead" (if firsthead (concat firsthead "\n\\endfirsthead\n") ""))
+    (cons "head"      (if head (concat head "\n\\endhead\n") ""))
+    (cons "foot"      (if foot (concat foot "\n\\endfoot\n") ""))
+    (cons "lastfoot"  (if lastfoot (concat lastfoot "\n\\endlastfoot\n") ""))
+    (cons "table" (orgtbl-to-generic
+                   (mapcar (lambda (lis)
+                             (if (listp lis)
+                                 (mapcar (lambda (el)
+                                           (if (stringp el)
+                                               el
+                                             (format "%S" el))) lis)
+                               lis)) table)
+                   (list :lend " \\\\" :sep " & " :hline hline)))))
+#+end_src
 
-Elegant lisp code for transposing a matrix.
+** Elegant lisp for transposing a matrix.
 
 #+tblname: transpose-example
 | 1 | 2 | 3 |

+ 3 - 3
contrib/lisp/org-mac-link-grabber.el

@@ -318,7 +318,7 @@ applications and inserting them in org documents"
 
 (defun org-mac-together-item-open (uid)
   "Open the given uid, which is a reference to an item in Together"
-  (shell-command (concat "open \"x-together-item:" uid "\"")))
+  (shell-command (concat "open -a Together \"x-together-item:" uid "\"")))
 
 (defun as-get-selected-together-items ()
   (do-applescript
@@ -378,9 +378,9 @@ applications and inserting them in org documents"
 ;;
 ;;
 
-(org-add-link-type "addressbook" 'org-mac-together-item-open)
+(org-add-link-type "addressbook" 'org-mac-addressbook-item-open)
 
-(defun org-mac-together-item-open (uid)
+(defun org-mac-addressbook-item-open (uid)
   "Open the given uid, which is a reference to an item in Together"
   (shell-command (concat "open \"addressbook:" uid "\"")))
 

+ 84 - 29
doc/org.texi

@@ -452,6 +452,7 @@ Miscellaneous
 
 * Completion::			M-TAB knows what you need
 * Speed keys::			Electic commands at the beginning of a headline
+* Code evaluation security::	Org mode files evaluate inline code
 * Customization::		Adapting Org to your taste
 * In-buffer settings::		Overview of the #+KEYWORDS
 * The very busy C-c C-c key::	When in doubt, press C-c C-c
@@ -527,41 +528,39 @@ structured ASCII file, as HTML, or (TODO and agenda items only) as an
 iCalendar file.  It can also serve as a publishing tool for a set of
 linked web pages.
 
-An important design aspect that distinguishes Org from, for example,
-Planner/Muse is that it encourages you to store every piece of information
-only once.  In Planner, you have project pages, day pages and possibly
-other files, duplicating some information such as tasks.  In Org,
-you only have notes files.  In your notes you mark entries as tasks, and
-label them with tags and timestamps.  All necessary lists, like a
-schedule for the day, the agenda for a meeting, tasks lists selected by
-tags, etc., are created dynamically when you need them.
+As a project planning environment, Org works by adding metadata to outline
+nodes.  Based on this data, specific entries can be extracted in queries and
+create dynamic @i{agenda views}.
+
+Org mode contains the Org Babel environment which allows to work with
+embedded source code block in a file, to facilitate code evaluation,
+documentation, and tangling.
+
+Org's automatic, context-sensitive table editor with spreadsheet
+capabilities can be integrated into any major mode by activating the
+minor Orgtbl mode.  Using a translation step, it can be used to maintain
+tables in arbitrary file types, for example in La@TeX{}.  The structure
+editing and list creation capabilities can be used outside Org with
+the minor Orgstruct mode.
 
 Org keeps simple things simple.  When first fired up, it should
 feel like a straightforward, easy to use outliner.  Complexity is not
 imposed, but a large amount of functionality is available when you need
-it.  Org is a toolbox and can be used in different ways, for
-example as:
+it.  Org is a toolbox and can be used in different ways and for different
+ends, for example:
 
 @example
 @r{@bullet{} an outline extension with visibility cycling and structure editing}
 @r{@bullet{} an ASCII system and table editor for taking structured notes}
-@r{@bullet{} an ASCII table editor with spreadsheet-like capabilities}
 @r{@bullet{} a TODO list editor}
 @r{@bullet{} a full agenda and planner with deadlines and work scheduling}
 @pindex GTD, Getting Things Done
 @r{@bullet{} an environment in which to implement David Allen's GTD system}
-@r{@bullet{} a basic database application}
 @r{@bullet{} a simple hypertext system, with HTML and La@TeX{} export}
 @r{@bullet{} a publishing tool to create a set of interlinked webpages}
 @r{@bullet{} an environment for literate programming}
 @end example
 
-Org's automatic, context-sensitive table editor with spreadsheet
-capabilities can be integrated into any major mode by activating the
-minor Orgtbl mode.  Using a translation step, it can be used to maintain
-tables in arbitrary file types, for example in La@TeX{}.  The structure
-editing and list creation capabilities can be used outside Org with
-the minor Orgstruct mode.
 
 @cindex FAQ
 There is a website for Org which provides links to the newest
@@ -8739,7 +8738,7 @@ Visit the include file at point.
 @end table
 
 @node Index entries, Macro replacement, Include files, Markup
-@section Index enries
+@section Index entries
 @cindex index entries, for publishing
 
 You can specify entries that will be used for generating an index during
@@ -12116,32 +12115,32 @@ In an Org-mode buffer, the following key bindings are active:
 @multitable @columnfractions 0.45 0.55
 @kindex C-c C-v a
 @kindex C-c C-v C-a
-@item @kbd{C-c C-v a} @r{or} @kbd{C-c C-v C-a} @tab org-babel-sha1-hash
+@item @kbd{C-c C-v a} @ @ @r{or} @ @ @kbd{C-c C-v C-a} @tab org-babel-sha1-hash
 @kindex C-c C-v b
 @kindex C-c C-v C-b
-@item @kbd{C-c C-v b} @r{or} @kbd{C-c C-v C-b} @tab org-babel-execute-buffer
+@item @kbd{C-c C-v b} @ @ @r{or} @ @ @kbd{C-c C-v C-b} @tab org-babel-execute-buffer
 @kindex C-c C-v f
 @kindex C-c C-v C-f
-@item @kbd{C-c C-v f} @r{or} @kbd{C-c C-v C-f} @tab org-babel-tangle-file
+@item @kbd{C-c C-v f} @ @ @r{or} @ @ @kbd{C-c C-v C-f} @tab org-babel-tangle-file
 @kindex C-c C-v g
 @item @kbd{C-c C-v g} @tab org-babel-goto-named-source-block
 @kindex C-c C-v h
 @item @kbd{C-c C-v h} @tab org-babel-describe-bindings
 @kindex C-c C-v l
 @kindex C-c C-v C-l
-@item @kbd{C-c C-v l} @r{or} @kbd{C-c C-v C-l} @tab org-babel-lob-ingest
+@item @kbd{C-c C-v l} @ @ @r{or} @ @ @kbd{C-c C-v C-l} @tab org-babel-lob-ingest
 @kindex C-c C-v p
 @kindex C-c C-v C-p
-@item @kbd{C-c C-v p} @r{or} @kbd{C-c C-v C-p} @tab org-babel-expand-src-block
+@item @kbd{C-c C-v p} @ @ @r{or} @ @ @kbd{C-c C-v C-p} @tab org-babel-expand-src-block
 @kindex C-c C-v s
 @kindex C-c C-v C-s
-@item @kbd{C-c C-v s} @r{or} @kbd{C-c C-v C-s} @tab org-babel-execute-subtree
+@item @kbd{C-c C-v s} @ @ @r{or} @ @ @kbd{C-c C-v C-s} @tab org-babel-execute-subtree
 @kindex C-c C-v t
 @kindex C-c C-v C-t
-@item @kbd{C-c C-v t} @r{or} @kbd{C-c C-v C-t} @tab org-babel-tangle
+@item @kbd{C-c C-v t} @ @ @r{or} @ @ @kbd{C-c C-v C-t} @tab org-babel-tangle
 @kindex C-c C-v z
 @kindex C-c C-v C-z
-@item @kbd{C-c C-v z} @r{or} @kbd{C-c C-v C-z} @tab org-babel-switch-to-session
+@item @kbd{C-c C-v z} @ @ @r{or} @ @ @kbd{C-c C-v C-z} @tab org-babel-switch-to-session
 @end multitable
 
 @c When possible these keybindings were extended to work when the control key is
@@ -12199,6 +12198,7 @@ emacsclient \
 @menu
 * Completion::			M-TAB knows what you need
 * Speed keys::			Electic commands at the beginning of a headline
+* Code evaluation security::	Org mode files evaluate inline code
 * Customization::		Adapting Org to your taste
 * In-buffer settings::		Overview of the #+KEYWORDS
 * The very busy C-c C-c key::	When in doubt, press C-c C-c
@@ -12270,7 +12270,7 @@ Elsewhere, complete dictionary words using Ispell.
 @end itemize
 @end table
 
-@node Speed keys, Customization, Completion, Miscellaneous
+@node Speed keys, Code evaluation security, Completion, Miscellaneous
 @section Speed keys
 @cindex speed keys
 @vindex org-use-speed-commands
@@ -12288,7 +12288,62 @@ or on a small mobile device with a limited keyboard.
 To see which commands are available, activate the feature and press @kbd{?}
 with the cursor at the beginning of a headline.
 
-@node Customization, In-buffer settings, Speed keys, Miscellaneous
+@node Code evaluation security, Customization, Speed keys, Miscellaneous
+@section Code evaluation and security issues
+
+Org provides tool to work with the code snippets, including evaluating them.
+
+Running code on your machine always comes with a security risk.  Badly
+written or malicious code can be executed on purpose or by accident.  Org has
+default settings which will only evaluate such code if you give explicit
+permission to do so, and as a casual user of these features you should leave
+these precautions intact.
+
+For people who regularly work with such code, the confirmation prompts can
+become annoying, and you might want to turn them off.  This can be done, but
+you must be aware of the risks that are involved.
+
+Code evaluation can happen under the following circumstances:
+
+@table @i
+@item Source code blocks
+Source code blocks can be evaluated during export, or when pressing @kbd{C-c
+C-c} in the block.  The most important thing to realize here is that Org mode
+files which contain code snippets are in a certain sense like executable
+files.  So you should accept them and load them into Emacs only from trusted
+sources - just like you would do with a program you install on your computer.
+
+Make sure you know what you are doing before customizing the variables
+which take of the default security brakes.
+
+@defopt org-confirm-babel-evaluate
+Does code evaluation have to be acknowledged by the user?
+@end defopt
+
+@item Following @code{shell} and @code{elisp} links
+Org has two link types that can directly evaluate code (@pxref{External
+links}).  These links can be problematic because the code to be evaluated his
+not visible.
+
+@defopt org-confirm-shell-link-function
+Function to queries user about shell link execution.
+@end defopt
+@defopt org-confirm-elisp-link-function
+Functions to query user for Emacs Lisp link execution.
+@end defopt
+
+@item Following @code{shell} and @code{elisp} links
+Org has two link types that can directly evaluate code (@pxref{External
+links}).  These links can be problematic because the code to be evaluated his
+not visible.  @b{Security advice:}  Do not use these links, use source code
+blocks which make the associated actions much more transparent.
+
+@item Formulas in tables
+Formulas in tables (@pxref{The spreadsheet}) are code that is evaluated
+either by the @i{calc} interpreter, or by the @i{Emacs Lisp} interpreter.
+@end table
+
+@node Customization, In-buffer settings, Code evaluation security, Miscellaneous
 @section Customization
 @cindex customization
 @cindex options, for customization

+ 16 - 5
doc/orgguide.texi

@@ -102,13 +102,14 @@ license to the document, as described in section 6 of the license.
 * Hyperlinks::			Notes in context
 * TODO Items::			Every tree branch can be a TODO item
 * Tags::			Tagging headlines and matching sets of tags
-* Properties::			
+* Properties::			Properties
 * Dates and Times::		Making items useful for planning
 * Capture - Refile - Archive::	The ins and outs for projects
 * Agenda Views::		Collecting information into views
 * Markup::			Prepare text for rich export
 * Exporting::			Sharing and publishing of notes
 * Publishing::			Create a web site of linked Org files
+* Working With Source Code::	Source code snippets embedded in Org
 * Miscellaneous::		All the rest which did not fit elsewhere
 
 @detailmenu
@@ -2439,7 +2440,7 @@ Dye's LaTeX export tutorial}
 @uref{http://orgmode.org/worg/org-tutorials/org-beamer/tutorial.php, Eric
 Fraga's BEAMER presentation tutorial}}
 
-@node Publishing, Miscellaneous, Exporting, Top
+@node Publishing, Working With Source Code, Exporting, Top
 @chapter Publishing
 
 Org includes a publishing management system that allows you to configure
@@ -2479,14 +2480,24 @@ publishing of all files by giving a prefix argument to any of the commands
 above.
 
 @seealso{
-@uref{http://orgmode.org/manual/Publishing.html#Publishing, Chapter 12 of the
+@uref{http://orgmode.org/manual/Publishing.html#Publishing, Chapter 13 of the
 manual}@*
 @uref{http://orgmode.org/worg/org-tutorials/org-publish-html-tutorial.php,
 Sebastian Rose's publishing tutorial}@*
 @uref{http://orgmode.org/worg/org-tutorials/org-jekyll.php, Ian Barton's
 Jekyll/blogging setup}}
 
-@node Miscellaneous,  , Publishing, Top
+@node Working With Source Code, Miscellaneous, Publishing, Top
+@chapter Working with source code
+
+TBD
+
+@seealso{
+@uref{http://orgmode.org/manual/Working-with-source-code.html#Working-with-source-code,Chapter 14 of the manual}@*
+@uref{http://orgmode.org/worg/org-contrib/babel/index.php,
+The Babel site on Worg}}
+
+@node Miscellaneous,  , Working With Source Code, Top
 @chapter Miscellaneous
 
 @menu
@@ -2557,7 +2568,7 @@ devices, developed by Richard Moreland.  For details, see the Org-mode
 manual.
 
 @seealso{
-@uref{http://orgmode.org/manual/Miscellaneous.html#Miscellaneous, Chapter 14
+@uref{http://orgmode.org/manual/Miscellaneous.html#Miscellaneous, Chapter 15
 of the manual}@*
 @uref{http://orgmode.org/manual/MobileOrg.html#MobileOrg, Appendix B of the
 manual}@*

+ 30 - 20
lisp/babel/langs/ob-haskell.el

@@ -54,10 +54,12 @@
 
 (defun org-babel-expand-body:haskell (body params &optional processed-params)
   "Expand BODY according to PARAMS, return the expanded body."
-  (let (vars (nth 1 (or processed-params (org-babel-process-params params))))
+  (let ((vars (nth 1 (or processed-params (org-babel-process-params params)))))
     (concat
      (mapconcat
-      (lambda (pair) (format "let %s = %s;" (car pair) (cdr pair)))
+      (lambda (pair) (format "let %s = %s"
+			(car pair)
+			(org-babel-haskell-var-to-haskell (cdr pair))))
       vars "\n") "\n" body "\n")))
 
 (defun org-babel-execute:haskell (body params)
@@ -68,7 +70,7 @@
          (vars (nth 1 processed-params))
          (result-type (nth 3 processed-params))
          (full-body (org-babel-expand-body:haskell body params processed-params))
-         (session (org-babel-prep-session:haskell session 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))
@@ -96,34 +98,35 @@
   "If there is not a current inferior-process-buffer in SESSION
 then create one.  Return the initialized session."
   ;; TODO: make it possible to have multiple sessions
-  (run-haskell) (current-buffer))
+  (or (get-buffer "*haskell*")
+      (save-window-excursion (run-haskell) (sleep-for 0.25) (current-buffer))))
 
-(defun org-babel-load-session:haskell (session body params)
+(defun org-babel-load-session:haskell
+  (session body params &optional processed-params)
   "Load BODY into SESSION."
   (save-window-excursion
-    (let* ((buffer (org-babel-prep-session:haskell session params))
+    (let* ((buffer (org-babel-prep-session:haskell
+		    session params processed-params))
            (load-file (concat (make-temp-file "org-babel-haskell-load") ".hs")))
       (with-temp-buffer
         (insert body) (write-file load-file)
         (haskell-mode) (inferior-haskell-load-file))
       buffer)))
 
-(defun org-babel-prep-session:haskell (session params)
+(defun org-babel-prep-session:haskell
+  (session params &optional processesed-params)
   "Prepare SESSION according to the header arguments specified in PARAMS."
   (save-window-excursion
-    (org-babel-haskell-initiate-session session)
-    (let* ((vars (org-babel-ref-variables params))
-           (var-lines (mapconcat ;; define any variables
-                       (lambda (pair)
-                         (format "%s=%s"
-                                 (car pair)
-                                 (org-babel-ruby-var-to-ruby (cdr pair))))
-                       vars "\n"))
-           (vars-file (concat (make-temp-file "org-babel-haskell-vars") ".hs")))
-      (when vars
-        (with-temp-buffer
-          (insert var-lines) (write-file vars-file)
-          (haskell-mode) (inferior-haskell-load-file)))
+    (let ((pp (or processed-params (org-babel-process-params params)))
+	  (buffer (org-babel-haskell-initiate-session session)))
+      (org-babel-comint-in-buffer buffer
+      	(mapcar
+      	 (lambda (pair)
+      	   (insert (format "let %s = %s"
+      			   (car pair)
+      			   (org-babel-haskell-var-to-haskell (cdr pair))))
+      	   (comint-send-input nil t))
+      	 (nth 1 pp)))
       (current-buffer))))
 
 (defun org-babel-haskell-table-or-string (results)
@@ -140,6 +143,13 @@ Emacs-lisp table, otherwise return the results as a string."
                                                 "'" "\"" results))))))
      results)))
 
+(defun org-babel-haskell-var-to-haskell (var)
+  "Convert an elisp var into a string of haskell source code
+specifying a var of the same value."
+  (if (listp var)
+      (concat "[" (mapconcat #'org-babel-haskell-var-to-haskell var ", ") "]")
+    (format "%S" var)))
+
 (defun org-babel-haskell-export-to-lhs (&optional arg)
   "Export to a .lhs file with all haskell code blocks escaped
 appropriately.  When called with a prefix argument the resulting

+ 8 - 6
lisp/babel/langs/ob-python.el

@@ -101,7 +101,11 @@ specifying a var of the same value."
 (defun org-babel-python-table-or-string (results)
   "If the results look like a list or tuple, then convert them into an
 Emacs-lisp table, otherwise return the results as a string."
-  (org-babel-read
+  ((lambda (res)
+     (if (listp res)
+	 (mapcar (lambda (el) (if (equal el 'None) 'hline el)) res)
+       res))
+   (org-babel-read
    (if (or (string-match "^\\[.+\\]$" results)
 	   (string-match "^(.+)$" results))
        (org-babel-read
@@ -110,12 +114,10 @@ Emacs-lisp table, otherwise return the results as a string."
                  "\\[" "(" (replace-regexp-in-string
                             "\\]" ")" (replace-regexp-in-string
                                        ", " " " (replace-regexp-in-string
-                                                 "'" "\""
-						 (replace-regexp-in-string
-						  "None" "hline" results t)))))))
-     results)))
+                                                 "'" "\"" results t))))))
+     results))))
 
-(defvar org-babel-python-buffers '(:default . nil))
+(defvar org-babel-python-buffers '((:default . nil)))
 
 (defun org-babel-python-session-buffer (session)
   "Return the buffer associated with SESSION."

+ 1 - 0
lisp/babel/ob.el

@@ -30,6 +30,7 @@
 
 ;;; Code:
 (eval-when-compile (require 'cl))
+(require 'org-macs)
 
 (defvar org-babel-call-process-region-original)
 (declare-function show-all "outline" ())

+ 9 - 9
lisp/org-agenda.el

@@ -2450,7 +2450,7 @@ higher priority settings."
    ((string-match "\\.html?\\'" file) (require 'htmlize))
    ((string-match "\\.ps\\'" file) (require 'ps-print)))
   (org-let (if nosettings nil org-agenda-exporter-settings)
-    '(save-excursion
+    `(save-excursion
        (save-window-excursion
 	 (org-agenda-mark-filtered-text)
 	 (let ((bs (copy-sequence (buffer-string))) beg)
@@ -2482,14 +2482,14 @@ higher priority settings."
 	       (message "HTML written to %s" file))
 	      ((string-match "\\.ps\\'" file)
 	       (require 'ps-print)
-	       (flet ((ps-get-buffer-name () "Agenda View"))
-		 (ps-print-buffer-with-faces file))
+	       ,(flet ((ps-get-buffer-name () "Agenda View"))
+		  (ps-print-buffer-with-faces file))
 	       (message "Postscript written to %s" file))
 	      ((string-match "\\.pdf\\'" file)
 	       (require 'ps-print)
-	       (flet ((ps-get-buffer-name () "Agenda View"))
-		 (ps-print-buffer-with-faces
-		  (concat (file-name-sans-extension file) ".ps")))
+	       ,(flet ((ps-get-buffer-name () "Agenda View"))
+		  (ps-print-buffer-with-faces
+		   (concat (file-name-sans-extension file) ".ps")))
 	       (call-process "ps2pdf" nil nil nil
 			     (expand-file-name
 			      (concat (file-name-sans-extension file) ".ps"))
@@ -4502,15 +4502,15 @@ be skipped."
 		     (setq clocked (match-string 2 rest)))
 	    (setq clocked "-")))
 	(save-excursion
+	  (setq extra nil)
 	  (cond
-	   ((not org-agenda-log-mode-add-notes) (setq extra nil))
+	   ((not org-agenda-log-mode-add-notes))
 	   (statep
 	    (and (looking-at ".*\n[ \t]*\\([^-\n \t].*?\\)[ \t]*$")
 		 (setq extra (match-string 1))))
 	   (clockp
 	    (and (looking-at ".*\n[ \t]*-[ \t]+\\([^-\n \t].*?\\)[ \t]*$")
-		 (setq extra (match-string 1))))
-	   (t (setq extra nil)))
+		 (setq extra (match-string 1)))))
 	  (if (not (re-search-backward "^\\*+ " nil t))
 	      (setq txt org-agenda-no-heading-message)
 	    (goto-char (match-beginning 0))

+ 58 - 14
lisp/org-capture.el

@@ -56,6 +56,7 @@
 (declare-function org-datetree-find-date-create "org-datetree"
 		  (DATE &optional KEEP-RESTRICTION))
 (declare-function org-table-get-specials "org-table" ())
+(declare-function org-table-goto-line "org-table" (N))
 (defvar org-remember-default-headline)
 (defvar org-remember-templates)
 (defvar org-table-hlines)
@@ -386,7 +387,16 @@ bypassed."
 	(if (equal goto 0)
 	    ;;insert at point
 	    (org-capture-insert-template-here)
-	  (org-capture-place-template)
+	  (condition-case error
+	      (org-capture-place-template)
+	    ((error quit)
+	     (if (and (buffer-base-buffer (current-buffer))
+		      (string-match "\\`CAPTURE-" (buffer-name)))
+		 (kill-buffer (current-buffer)))
+	     (set-window-configuration (org-capture-get :return-to-wconf))
+	     (error "Capture template `%s': %s"
+		    (org-capture-get :key)
+		    (nth 1 error))))
 	  (if (org-capture-get :immediate-finish)
 	      (org-capture-finalize)
 	    (if (and (org-mode-p)
@@ -463,14 +473,8 @@ bypassed."
       ;; 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.
-      (let ((pos (point)))
-	(with-current-buffer (buffer-base-buffer (current-buffer))
-	  (save-excursion
-	    (save-restriction
-	      (widen)
-	      (goto-char pos)
-	      (bookmark-set "org-capture-last-stored")
-	      (move-marker org-capture-last-stored-marker (point))))))
+      (org-capture-bookmark-last-stored-position)
+
       ;; Run the hook
       (run-hooks 'org-capture-before-finalize-hook)
       )
@@ -583,7 +587,7 @@ already gone."
 
        ((eq (car target) 'file+function)
 	(set-buffer (org-capture-target-buffer (nth 1 target)))
-	(funcall (nth 1 target))
+	(funcall (nth 2 target))
 	(setq target-entry-p (and (org-mode-p) (org-at-heading-p))))
 
        ((eq (car target) 'clock)
@@ -659,6 +663,7 @@ already gone."
     (setq beg (point))
     (org-paste-subtree level txt 'for-yank)
     (org-capture-empty-lines-after 1)
+    (org-capture-position-for-last-stored beg)
     (outline-next-heading)
     (setq end (point))
     (org-capture-mark-kill-region beg (1- end))
@@ -711,6 +716,7 @@ already gone."
     (insert txt)
     (or (bolp) (insert "\n"))
     (org-capture-empty-lines-after 1)
+    (org-capture-position-for-last-stored beg)
     (forward-char 1)
     (setq end (point))
     (org-capture-mark-kill-region beg (1- end))
@@ -739,8 +745,8 @@ already gone."
 	      (forward-line 1))
 	  (narrow-to-region b (point)))
       (goto-char end)
-      (insert "\n\n")
-      (narrow-to-region (1- (point)) (point)))
+      (insert "\n|   |\n|----|\n|    |\n")
+      (narrow-to-region (1+ end) (point)))
     ;; We are narrowed to the table, or to an empty line if there was no table
 
     ;; Check if the template is good
@@ -756,7 +762,7 @@ already gone."
 	    ll)
 	;; The user wants a special position in the table
 	(org-table-get-specials)
-	(setq ll (aref org-table-hlines nh))
+	(setq ll (ignore-errors (aref org-table-hlines nh)))
 	(unless ll (error "Invalid table line specification \"%s\""
 			  table-line-pos))
 	(setq ll (+ ll delta (if (< delta 0) 0 -1)))
@@ -790,6 +796,7 @@ already gone."
       (insert txt)
       (setq end (point))))
     (goto-char beg)
+    (org-capture-position-for-last-stored 'table-line)
     (if (re-search-forward "%\\?" end t) (replace-match ""))
     (org-table-align)))
 
@@ -803,6 +810,7 @@ already gone."
     (setq beg (point))
     (insert txt)
     (org-capture-empty-lines-after 1)
+    (org-capture-position-for-last-stored beg)
     (setq end (point))
     (org-capture-mark-kill-region beg (1- end))
     (org-capture-narrow beg (1- end))
@@ -815,6 +823,41 @@ already gone."
     (org-capture-put :begin-marker m1)
     (org-capture-put :end-marker m2)))
 
+(defun org-capture-position-for-last-stored (where)
+  "Memorize the position that should later become the position of last capture."
+  (cond
+   ((integerp where)
+    (org-capture-put :position-for-last-stored
+		     (move-marker (make-marker) where
+				  (or (buffer-base-buffer (current-buffer))
+				      (current-buffer)))))
+   ((eq where 'table-line)
+    (org-capture-put :position-for-last-stored
+		     (list 'table-line
+			   (org-table-current-dline))))
+   (t (error "This should not happen"))))
+
+(defun org-capture-bookmark-last-stored-position ()
+  "Bookmark the last-captured position."
+  (let* ((where (org-capture-get :position-for-last-stored 'local))
+	 (pos (cond
+	       ((markerp where)
+		(prog1 (marker-position where)
+		  (move-marker where nil)))
+	       ((and (listp where) (eq (car where) 'table-line))
+		(if (org-at-table-p)
+		    (save-excursion
+		      (org-table-goto-line (nth 1 where))
+		      (point-at-bol))
+		  (point))))))
+    (with-current-buffer (buffer-base-buffer (current-buffer))
+      (save-excursion
+	(save-restriction
+	  (widen)
+	  (goto-char pos)
+	  (bookmark-set "org-capture-last-stored")
+	  (move-marker org-capture-last-stored-marker (point)))))))
+
 (defun org-capture-narrow (beg end)
   "Narrow, unless configuraion says not to narrow."
   (unless (org-capture-get :unnarrowed)
@@ -1140,8 +1183,9 @@ The template may still contain \"%?\" for cursor positioning."
 	   (char
 	    ;; These are the date/time related ones
 	    (setq org-time-was-given (equal (upcase char) char))
-	    (setq time (org-read-date (equal (upcase char) "U") t nil
+	    (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)))

+ 294 - 240
lisp/org-entities.el

@@ -78,221 +78,238 @@ loaded, add these packages to `org-export-latex-packages-alist'."
 	   (string :tag "utf-8 "))))
 
 (defconst org-entities
-  '(("nbsp" "~" nil "&nbsp;" " " " " " ")
-    ("iexcl" "!`" nil "&iexcl;" "!" "¡" "¡")
-    ("cent" "\\textcent{}" nil "&cent;" "cent" "¢" "¢")
-    ("pound" "\\pounds{}" nil "&pound;" "pound" "£" "£")
-    ("curren" "\\textcurrency{}" nil "&curren;" "curr." "¤" "¤")
-    ("yen" "\\textyen{}" nil "&yen;" "yen" "¥" "¥")
-    ("brvbar" "\\textbrokenbar{}" nil "&brvbar;" "|" "¦" "¦")
-    ("vert" "\\vert{}" t "&#124;" "|" "|" "|")
-    ("sect" "\\S" nil "&sect;" "paragraph" "§" "§")
-    ("uml" "\\textasciidieresis{}" nil "&uml;" "[diaeresis]" "¨" "¨")
-    ("copy" "\\textcopyright{}" nil "&copy;" "(c)" "©" "©")
-    ("ordf" "\\textordfeminine{}" nil "&ordf;" "_a_" "ª" "ª")
-    ("laquo" "\\guillemotleft{}" nil "&laquo;" "<<" "«" "«")
-    ("not" "\\textlnot{}" nil "&not;" "[angled dash]" "¬" "¬")
-    ("shy" "\\-" nil "&shy;" "" "" "")
-    ("reg" "\\textregistered{}" nil "&reg;" "(r)" "®" "®")
-    ("macr" "\\textasciimacron{}" nil "&macr;" "[macron]" "¯" "¯")
-    ("deg" "\\textdegree{}" nil "deg" "degree" "°" "°")
-    ("pm" "\\textpm{}" nil "&plusmn;" "+-" "±" "±")
-    ("plusmn" "\\textpm{}" nil "&plusmn;" "+-" "±" "±")
-    ("sup2" "\\texttwosuperior{}" nil "&sup2;" "^2" "²" "²")
-    ("sup3" "\\textthreesuperior{}" nil "&sup3;" "^3" "³" "³")
-    ("acutex" "\\acute x" t "&acute;x" "'x" "'x" "𝑥́")
-    ("micro" "\\textmu{}" nil "&micro;" "micro" "µ" "µ")
-    ("para" "\\P{}" nil "&para;" "[pilcrow]" "¶" "¶")
-    ("middot" "\\textperiodcentered{}" nil "&middot;" "." "·" "·")
-    ("odot" "\\odot" t "o" "[circled dot]" "[circled dot]" "ʘ")
-    ("star" "\\star" t "*" "*" "*" "⋆")
-    ("cedil" "\\c{}" nil "&cedil;" "[cedilla]" "¸" "¸")
-    ("sup1" "\\textonesuperior{}" nil "&sup1;" "^1" "¹" "¹")
-    ("ordm" "\\textordmasculine{}" nil "&ordm;" "_o_" "º" "º")
-    ("raquo" "\\guillemotright{}" nil "&raquo;" ">>" "»" "»")
-    ("iquest" "?`" nil "&iquest;" "?" "¿" "¿")
+  '(
+    "* Letters"
+    "** Latin"
     ("Agrave" "\\`{A}" nil "&Agrave;" "A" "À" "À")
+    ("agrave" "\\`{a}" nil "&agrave;" "a" "à" "à")
     ("Aacute" "\\'{A}" nil "&Aacute;" "A" "Á" "Á")
+    ("aacute" "\\'{a}" nil "&aacute;" "a" "á" "á")
     ("Acirc" "\\^{A}" nil "&Acirc;" "A" "Â" "Â")
+    ("acirc" "\\^{a}" nil "&acirc;" "a" "â" "â")
     ("Atilde" "\\~{A}" nil "&Atilde;" "A" "Ã" "Ã")
+    ("atilde" "\\~{a}" nil "&atilde;" "a" "ã" "ã")
     ("Auml" "\\\"{A}" nil "&Auml;" "Ae" "Ä" "Ä")
+    ("auml" "\\\"{a}" nil "&auml;" "ae" "ä" "ä")
     ("Aring" "\\AA{}" nil "&Aring;" "A" "Å" "Å")
     ("AA" "\\AA{}" nil "&Aring;" "A" "Å" "Å")
-    ("AElig" "\\AE{}" nil "&AElig;" "AE" "Æ" "Æ")
-    ("Ccedil" "\\c{C}" nil "&Ccedil;" "C" "Ç" "Ç")
-    ("Egrave" "\\`{E}" nil "&Egrave;" "E" "È" "È")
-    ("Eacute" "\\'{E}" nil "&Eacute;" "E" "É" "É")
-    ("Ecirc" "\\^{E}" nil "&Ecirc;" "E" "Ê" "Ê")
-    ("Euml" "\\\"{E}" nil "&Euml;" "E" "Ë" "Ë")
-    ("Igrave" "\\`{I}" nil "&Igrave;" "I" "Ì" "Ì")
-    ("Iacute" "\\'{I}" nil "&Iacute;" "I" "Í" "Í")
-    ("Icirc" "\\^{I}" nil "&Icirc;" "I" "Î" "Î")
-    ("Iuml" "\\\"{I}" nil "&Iuml;" "I" "Ï" "Ï")
-    ("ETH" "\\DH{}" nil "&ETH;" "D" "Ð" "Ð")
-    ("Ntilde" "\\~{N}" nil "&Ntilde;" "N" "Ñ" "Ñ")
-    ("Ograve" "\\`{O}" nil "&Ograve;" "O" "Ò" "Ò")
-    ("Oacute" "\\'{O}" nil "&Oacute;" "O" "Ó" "Ó")
-    ("Ocirc" "\\^{O}" nil "&Ocirc;" "O" "Ô" "Ô")
-    ("Otilde" "\\~{O}" nil "&Otilde;" "O" "Õ" "Õ")
-    ("Ouml" "\\\"{O}" nil "&Ouml;" "Oe" "Ö" "Ö")
-    ("times" "\\texttimes{}" nil "&times;" "*" "×" "×")
-    ("Oslash" "\\O" nil "&Oslash;" "O" "Ø" "Ø")
-    ("Ugrave" "\\`{U}" nil "&Ugrave;" "U" "Ù" "Ù")
-    ("Uacute" "\\'{U}" nil "&Uacute;" "U" "Ú" "Ú")
-    ("Ucirc" "\\^{U}" nil "&Ucirc;" "U" "Û" "Û")
-    ("Uuml" "\\\"{U}" nil "&Uuml;" "Ue" "Ü" "Ü")
-    ("Yacute" "\\'{Y}" nil "&Yacute;" "Y" "Ý" "Ý")
-    ("THORN" "\\TH{}" nil "&THORN;" "TH" "Þ" "Þ")
-    ("szlig" "\\ss{}" nil "&szlig;" "ss" "ß" "ß")
-    ("agrave" "\\`{a}" nil "&agrave;" "a" "à" "à")
-    ("aacute" "\\'{a}" nil "&aacute;" "a" "á" "á")
-    ("acirc" "\\^{a}" nil "&acirc;" "a" "â" "â")
-    ("atilde" "\\~{a}" nil "&atilde;" "a" "ã" "ã")
-    ("auml" "\\\"{a}" nil "&auml;" "ae" "ä" "ä")
     ("aring" "\\aa{}" nil "&aring;" "a" "å" "å")
+    ("AElig" "\\AE{}" nil "&AElig;" "AE" "Æ" "Æ")
     ("aelig" "\\ae{}" nil "&aelig;" "ae" "æ" "æ")
+    ("Ccedil" "\\c{C}" nil "&Ccedil;" "C" "Ç" "Ç")
     ("ccedil" "\\c{c}" nil "&ccedil;" "c" "ç" "ç")
-    ("checkmark" "\\checkmark" t "&#10003;" "[checkmark]" "[checkmark]" "✓")
+    ("Egrave" "\\`{E}" nil "&Egrave;" "E" "È" "È")
     ("egrave" "\\`{e}" nil "&egrave;" "e" "è" "è")
+    ("Eacute" "\\'{E}" nil "&Eacute;" "E" "É" "É")
     ("eacute" "\\'{e}" nil "&eacute;" "e" "é" "é")
+    ("Ecirc" "\\^{E}" nil "&Ecirc;" "E" "Ê" "Ê")
     ("ecirc" "\\^{e}" nil "&ecirc;" "e" "ê" "ê")
+    ("Euml" "\\\"{E}" nil "&Euml;" "E" "Ë" "Ë")
     ("euml" "\\\"{e}" nil "&euml;" "e" "ë" "ë")
+    ("Igrave" "\\`{I}" nil "&Igrave;" "I" "Ì" "Ì")
     ("igrave" "\\`{i}" nil "&igrave;" "i" "ì" "ì")
+    ("Iacute" "\\'{I}" nil "&Iacute;" "I" "Í" "Í")
     ("iacute" "\\'{i}" nil "&iacute;" "i" "í" "í")
+    ("Icirc" "\\^{I}" nil "&Icirc;" "I" "Î" "Î")
     ("icirc" "\\^{i}" nil "&icirc;" "i" "î" "î")
+    ("Iuml" "\\\"{I}" nil "&Iuml;" "I" "Ï" "Ï")
     ("iuml" "\\\"{i}" nil "&iuml;" "i" "ï" "ï")
-    ("eth" "\\dh{}" nil "&eth;" "dh" "ð" "ð")
+    ("Ntilde" "\\~{N}" nil "&Ntilde;" "N" "Ñ" "Ñ")
     ("ntilde" "\\~{n}" nil "&ntilde;" "n" "ñ" "ñ")
+    ("Ograve" "\\`{O}" nil "&Ograve;" "O" "Ò" "Ò")
     ("ograve" "\\`{o}" nil "&ograve;" "o" "ò" "ò")
+    ("Oacute" "\\'{O}" nil "&Oacute;" "O" "Ó" "Ó")
     ("oacute" "\\'{o}" nil "&oacute;" "o" "ó" "ó")
+    ("Ocirc" "\\^{O}" nil "&Ocirc;" "O" "Ô" "Ô")
     ("ocirc" "\\^{o}" nil "&ocirc;" "o" "ô" "ô")
+    ("Otilde" "\\~{O}" nil "&Otilde;" "O" "Õ" "Õ")
     ("otilde" "\\~{o}" nil "&otilde;" "o" "õ" "õ")
+    ("Ouml" "\\\"{O}" nil "&Ouml;" "Oe" "Ö" "Ö")
     ("ouml" "\\\"{o}" nil "&ouml;" "oe" "ö" "ö")
+    ("Oslash" "\\O" nil "&Oslash;" "O" "Ø" "Ø")
     ("oslash" "\\o{}" nil "&oslash;" "o" "ø" "ø")
+    ("OElig" "\\OE{}" nil "&OElig;" "OE" "OE" "Œ")
+    ("oelig" "\\oe{}" nil "&oelig;" "oe" "oe" "œ")
+    ("Scaron" "\\v{S}" nil "&Scaron;" "S" "S" "Š")
+    ("scaron" "\\v{s}" nil "&scaron;" "s" "s" "š")
+    ("szlig" "\\ss{}" nil "&szlig;" "ss" "ß" "ß")
+    ("Ugrave" "\\`{U}" nil "&Ugrave;" "U" "Ù" "Ù")
     ("ugrave" "\\`{u}" nil "&ugrave;" "u" "ù" "ù")
+    ("Uacute" "\\'{U}" nil "&Uacute;" "U" "Ú" "Ú")
     ("uacute" "\\'{u}" nil "&uacute;" "u" "ú" "ú")
+    ("Ucirc" "\\^{U}" nil "&Ucirc;" "U" "Û" "Û")
     ("ucirc" "\\^{u}" nil "&ucirc;" "u" "û" "û")
+    ("Uuml" "\\\"{U}" nil "&Uuml;" "Ue" "Ü" "Ü")
     ("uuml" "\\\"{u}" nil "&uuml;" "ue" "ü" "ü")
+    ("Yacute" "\\'{Y}" nil "&Yacute;" "Y" "Ý" "Ý")
     ("yacute" "\\'{y}" nil "&yacute;" "y" "ý" "ý")
-    ("thorn" "\\th{}" nil "&thorn;" "th" "þ" "þ")
+    ("Yuml" "\\\"{Y}" nil "&Yuml;" "Y" "Y" "Ÿ")
     ("yuml" "\\\"{y}" nil "&yuml;" "y" "ÿ" "ÿ")
+
+    "** Latin (special face)"
     ("fnof" "\\textit{f}" nil "&fnof;" "f" "f" "ƒ")
+    ("real" "\\Re" t "&real;" "R" "R" "ℜ")
+    ("image" "\\Im" t "&image;" "I" "I" "ℑ")
+    ("weierp" "\\wp" t "&weierp;" "P" "P" "℘")
+
+    "** Greek"
     ("Alpha" "A" nil "&Alpha;" "Alpha" "Alpha" "Α")
-    ("Beta" "B" nil "&Beta;" "Beta" "Beta" "Β")
-    ("Gamma" "\\Gamma" t "&Gamma;" "Gamma" "Gamma" "Γ")
-    ("Delta" "\\Delta" t "&Delta;" "Delta" "Gamma" "Δ")
-    ("Epsilon" "E" nil "&Epsilon;" "Epsilon" "Epsilon" "Ε")
-    ("Zeta" "Z" nil "&Zeta;" "Zeta" "Zeta" "Ζ")
-    ("Eta" "H" nil "&Eta;" "Eta" "Eta" "Η")
-    ("Theta" "\\Theta" t "&Theta;" "Theta" "Theta" "Θ")
-    ("Iota" "I" nil "&Iota;" "Iota" "Iota" "Ι")
-    ("Kappa" "K" nil "&Kappa;" "Kappa" "Kappa" "Κ")
-    ("Lambda" "\\Lambda" t "&Lambda;" "Lambda" "Lambda" "Λ")
-    ("Mu" "M" nil "&Mu;" "Mu" "Mu" "Μ")
-    ("Nu" "N" nil "&Nu;" "Nu" "Nu" "Ν")
-    ("Xi" "\\Xi" t "&Xi;" "Xi" "Xi" "Ξ")
-    ("Omicron" "O" nil "&Omicron;" "Omicron" "Omicron" "Ο")
-    ("Pi" "\\Pi" t "&Pi;" "Pi" "Pi" "Π")
-    ("Rho" "P" nil "&Rho;" "Rho" "Rho" "Ρ")
-    ("Sigma" "\\Sigma" t "&Sigma;" "Sigma" "Sigma" "Σ")
-    ("Tau" "T" nil "&Tau;" "Tau" "Tau" "Τ")
-    ("Upsilon" "\\Upsilon" t "&Upsilon;" "Upsilon" "Upsilon" "Υ")
-    ("Phi" "\\Phi" t "&Phi;" "Phi" "Phi" "Φ")
-    ("Chi" "X" nil "&Chi;" "Chi" "Chi" "Χ")
-    ("Psi" "\\Psi" t "&Psi;" "Psi" "Psi" "Ψ")
-    ("Omega" "\\Omega" t "&Omega;" "Omega" "Omega" "Ω")
     ("alpha" "\\alpha" t "&alpha;" "alpha" "alpha" "α")
+    ("Beta" "B" nil "&Beta;" "Beta" "Beta" "Β")
     ("beta" "\\beta" t "&beta;" "beta" "beta" "β")
+    ("Gamma" "\\Gamma" t "&Gamma;" "Gamma" "Gamma" "Γ")
     ("gamma" "\\gamma" t "&gamma;" "gamma" "gamma" "γ")
+    ("Delta" "\\Delta" t "&Delta;" "Delta" "Gamma" "Δ")
     ("delta" "\\delta" t "&delta;" "delta" "delta" "δ")
+    ("Epsilon" "E" nil "&Epsilon;" "Epsilon" "Epsilon" "Ε")
     ("epsilon" "\\epsilon" t "&epsilon;" "epsilon" "epsilon" "ε")
     ("varepsilon" "\\varepsilon" t "&epsilon;" "varepsilon" "varepsilon" "ε")
+    ("Zeta" "Z" nil "&Zeta;" "Zeta" "Zeta" "Ζ")
     ("zeta" "\\zeta" t "&zeta;" "zeta" "zeta" "ζ")
+    ("Eta" "H" nil "&Eta;" "Eta" "Eta" "Η")
     ("eta" "\\eta" t "&eta;" "eta" "eta" "η")
+    ("Theta" "\\Theta" t "&Theta;" "Theta" "Theta" "Θ")
     ("theta" "\\theta" t "&theta;" "theta" "theta" "θ")
+    ("thetasym" "\\vartheta" t "&thetasym;" "theta" "theta" "ϑ")
+    ("vartheta" "\\vartheta" t "&thetasym;" "theta" "theta" "ϑ")
+    ("Iota" "I" nil "&Iota;" "Iota" "Iota" "Ι")
     ("iota" "\\iota" t "&iota;" "iota" "iota" "ι")
+    ("Kappa" "K" nil "&Kappa;" "Kappa" "Kappa" "Κ")
     ("kappa" "\\kappa" t "&kappa;" "kappa" "kappa" "κ")
+    ("Lambda" "\\Lambda" t "&Lambda;" "Lambda" "Lambda" "Λ")
     ("lambda" "\\lambda" t "&lambda;" "lambda" "lambda" "λ")
+    ("Mu" "M" nil "&Mu;" "Mu" "Mu" "Μ")
     ("mu" "\\mu" t "&mu;" "mu" "mu" "μ")
     ("nu" "\\nu" t "&nu;" "nu" "nu" "ν")
+    ("Nu" "N" nil "&Nu;" "Nu" "Nu" "Ν")
+    ("Xi" "\\Xi" t "&Xi;" "Xi" "Xi" "Ξ")
     ("xi" "\\xi" t "&xi;" "xi" "xi" "ξ")
+    ("Omicron" "O" nil "&Omicron;" "Omicron" "Omicron" "Ο")
     ("omicron" "\\textit{o}" nil "&omicron;" "omicron" "omicron" "ο")
+    ("Pi" "\\Pi" t "&Pi;" "Pi" "Pi" "Π")
     ("pi" "\\pi" t "&pi;" "pi" "pi" "π")
+    ("Rho" "P" nil "&Rho;" "Rho" "Rho" "Ρ")
     ("rho" "\\rho" t "&rho;" "rho" "rho" "ρ")
+    ("Sigma" "\\Sigma" t "&Sigma;" "Sigma" "Sigma" "Σ")
+    ("sigma" "\\sigma" t "&sigma;" "sigma" "sigma" "σ")
     ("sigmaf" "\\varsigma" t "&sigmaf;" "sigmaf" "sigmaf" "ς")
     ("varsigma" "\\varsigma" t "&sigmaf;" "varsigma" "varsigma" "ς")
-    ("sigma" "\\sigma" t "&sigma;" "sigma" "sigma" "σ")
-    ("tau" "\\tau" t "&tau;" "tau" "tau" "τ")
+    ("Tau" "T" nil "&Tau;" "Tau" "Tau" "Τ")
+    ("Upsilon" "\\Upsilon" t "&Upsilon;" "Upsilon" "Upsilon" "Υ")
+    ("upsih" "\\Upsilon" t "&upsih;" "upsilon" "upsilon" "ϒ")
     ("upsilon" "\\upsilon" t "&upsilon;" "upsilon" "upsilon" "υ")
+    ("Phi" "\\Phi" t "&Phi;" "Phi" "Phi" "Φ")
     ("phi" "\\phi" t "&phi;" "phi" "phi" "φ")
+    ("Chi" "X" nil "&Chi;" "Chi" "Chi" "Χ")
     ("chi" "\\chi" t "&chi;" "chi" "chi" "χ")
+    ("acutex" "\\acute x" t "&acute;x" "'x" "'x" "𝑥́")
+    ("Psi" "\\Psi" t "&Psi;" "Psi" "Psi" "Ψ")
     ("psi" "\\psi" t "&psi;" "psi" "psi" "ψ")
+    ("tau" "\\tau" t "&tau;" "tau" "tau" "τ")
+    ("Omega" "\\Omega" t "&Omega;" "Omega" "Omega" "Ω")
     ("omega" "\\omega" t "&omega;" "omega" "omega" "ω")
-    ("thetasym" "\\vartheta" t "&thetasym;" "theta" "theta" "ϑ")
-    ("vartheta" "\\vartheta" t "&thetasym;" "theta" "theta" "ϑ")
-    ("upsih" "\\Upsilon" t "&upsih;" "upsilon" "upsilon" "ϒ")
     ("piv" "\\varpi" t "&piv;" "omega-pi" "omega-pi" "ϖ")
-    ("bull" "\\textbullet{}" nil "&bull;" "*" "*" "•")
-    ("bullet" "\\textbullet{}" nil "&bull;" "*" "*" "•")
-    ("hellip" "\\dots{}" nil "&hellip;" "..." "..." "…")
+    ("partial" "\\partial" t "&part;" "[partial differential]" "[partial differential]" "∂")
+
+    "** Hebrew"
+    ("alefsym" "\\aleph" t "&alefsym;" "aleph" "aleph" "ℵ")
+
+    "** Dead languages"
+    ("ETH" "\\DH{}" nil "&ETH;" "D" "Ð" "Ð")
+    ("eth" "\\dh{}" nil "&eth;" "dh" "ð" "ð")
+    ("THORN" "\\TH{}" nil "&THORN;" "TH" "Þ" "Þ")
+    ("thorn" "\\th{}" nil "&thorn;" "th" "þ" "þ")
+
+    "* Punctuation"
+    "** Dots and Marks"
     ("dots" "\\dots{}" nil "&hellip;" "..." "..." "…")
-    ("prime" "\\prime" t "&prime;" "'" "'" "′")
-    ("Prime" "\\prime{}\\prime" t "&Prime;" "''" "''" "″")
-    ("oline" "\\overline{~}" t "&oline;" "[overline]" "¯" "‾")
-    ("frasl" "/" nil "&frasl;" "/" "/" "⁄")
-    ("weierp" "\\wp" t "&weierp;" "P" "P" "℘")
-    ("image" "\\Im" t "&image;" "I" "I" "ℑ")
-    ("real" "\\Re" t "&real;" "R" "R" "ℜ")
+    ("hellip" "\\dots{}" nil "&hellip;" "..." "..." "…")
+    ("middot" "\\textperiodcentered{}" nil "&middot;" "." "·" "·")
+    ("iexcl" "!`" nil "&iexcl;" "!" "¡" "¡")
+    ("iquest" "?`" nil "&iquest;" "?" "¿" "¿")
+
+    "** Dash-like"
+    ("shy" "\\-" nil "&shy;" "" "" "")
+    ("ndash" "--" nil "&ndash;" "-" "-" "–")
+    ("mdash" "---" nil "&mdash;" "--" "--" "—")
+
+    "** Quotations"
+    ("quot" "\\textquotedbl{}" nil "&quot;" "\"" "\"" "\"")
+    ("acute" "\\textasciiacute{}" nil "&acute;" "'" "´" "´")
+    ("ldquo" "\\textquotedblleft{}" nil "&ldquo;" "\"" "\"" "“")
+    ("rdquo" "\\textquotedblright{}" nil "&rdquo;" "\"" "\"" "”")
+    ("bdquo" "\\quotedblbase{}" nil "&bdquo;" "\"" "\"" "„")
+    ("lsquo" "\\textquoteleft{}" nil "&lsquo;" "`" "`" "‘")
+    ("rsquo" "\\textquoteright{}" nil "&rsquo;" "'" "'" "’")
+    ("sbquo" "\\quotesinglbase{}" nil "&sbquo;" "," "," "‚")
+    ("laquo" "\\guillemotleft{}" nil "&laquo;" "<<" "«" "«")
+    ("raquo" "\\guillemotright{}" nil "&raquo;" ">>" "»" "»")
+    ("lsaquo" "\\guilsinglleft{}" nil "&lsaquo;" "<" "<" "‹")
+    ("rsaquo" "\\guilsinglright{}" nil "&rsaquo;" ">" ">" "›")
+
+    "* Other"
+    "** Misc. (often used)"
+    ("circ" "\\circ" t "&circ;" "^" "^" "ˆ")
+    ("vert" "\\vert{}" t "&#124;" "|" "|" "|")
+    ("brvbar" "\\textbrokenbar{}" nil "&brvbar;" "|" "¦" "¦")
+    ("sect" "\\S" nil "&sect;" "paragraph" "§" "§")
+    ("amp" "\\&" nil "&amp;" "&" "&" "&")
+    ("lt" "\\textless{}" nil "&lt;" "<" "<" "<")
+    ("gt" "\\textgreater{}" nil "&gt;" ">" ">" ">")
+    ("tilde" "\\~{}" nil "&tilde;" "~" "~" "~")
+    ("dagger" "\\textdagger{}" nil "&dagger;" "[dagger]" "[dagger]" "†")
+    ("Dagger" "\\textdaggerdbl{}" nil "&Dagger;" "[doubledagger]" "[doubledagger]" "‡")
+
+    "** Whitespace"
+    ("nbsp" "~" nil "&nbsp;" " " " " " ")
+    ("ensp" "\\hspace*{.5em}" nil "&ensp;" " " " " " ")
+    ("emsp" "\\hspace*{1em}" nil "&emsp;" " " " " " ")
+    ("thinsp" "\\hspace*{.2em}" nil "&thinsp;" " " " " " ")
+
+    "** Currency"
+    ("curren" "\\textcurrency{}" nil "&curren;" "curr." "¤" "¤")
+    ("cent" "\\textcent{}" nil "&cent;" "cent" "¢" "¢")
+    ("pound" "\\pounds{}" nil "&pound;" "pound" "£" "£")
+    ("yen" "\\textyen{}" nil "&yen;" "yen" "¥" "¥")
+    ("euro" "\\texteuro{}" nil "&euro;" "EUR" "EUR" "€")
+    ("EUR" "\\EUR{}" nil "&euro;" "EUR" "EUR" "€")
+    ("EURdig" "\\EURdig{}" nil "&euro;" "EUR" "EUR" "€")
+    ("EURhv" "\\EURhv{}" nil "&euro;" "EUR" "EUR" "€")
+    ("EURcr" "\\EURcr{}" nil "&euro;" "EUR" "EUR" "€")
+    ("EURtm" "\\EURtm{}" nil "&euro;" "EUR" "EUR" "€")
+
+    "** Property Marks"
+    ("copy" "\\textcopyright{}" nil "&copy;" "(c)" "©" "©")
+    ("reg" "\\textregistered{}" nil "&reg;" "(r)" "®" "®")
     ("trade" "\\texttrademark{}" nil "&trade;" "TM" "TM" "™")
-    ("alefsym" "\\aleph" t "&alefsym;" "aleph" "aleph" "ℵ")
-    ("larr" "\\leftarrow" t "&larr;" "<-" "<-" "←")
-    ("leftarrow" "\\leftarrow" t "&larr;"  "<-" "<-" "←")
-    ("gets" "\\gets" t "&larr;"  "<-" "<-" "←")
-    ("uarr" "\\uparrow" t "&uarr;" "[uparrow]" "[uparrow]" "↑")
-    ("uparrow" "\\uparrow" t "&uarr;" "[uparrow]" "[uparrow]" "↑")
-    ("rarr" "\\rightarrow" t "&rarr;" "->" "->" "→")
-    ("to" "\\to" t "&rarr;" "->" "->" "→")
-    ("rightarrow" "\\rightarrow" t "&rarr;"  "->" "->" "→")
-    ("darr" "\\downarrow" t "&darr;" "[downarrow]" "[downarrow]" "↓")
-    ("downarrow" "\\downarrow" t "&darr;" "[downarrow]" "[downarrow]" "↓")
-    ("harr" "\\leftrightarrow" t "&harr;" "<->" "<->" "↔")
-    ("leftrightarrow" "\\leftrightarrow" t "&harr;"  "<->" "<->" "↔")
-    ("crarr" "\\hookleftarrow" t "&crarr;" "<-'" "<-'" "↵")
-    ("hookleftarrow" "\\hookleftarrow" t "&crarr;"  "<-'" "<-'" "↵")
-    ("lArr" "\\Leftarrow" t "&lArr;" "<=" "<=" "⇐")
-    ("Leftarrow" "\\Leftarrow" t "&lArr;" "<=" "<=" "⇐")
-    ("uArr" "\\Uparrow" t "&uArr;" "[dbluparrow]" "[dbluparrow]" "⇑")
-    ("Uparrow" "\\Uparrow" t "&uArr;" "[dbluparrow]" "[dbluparrow]" "⇑")
-    ("rArr" "\\Rightarrow" t "&rArr;" "=>" "=>" "⇒")
-    ("Rightarrow" "\\Rightarrow" t "&rArr;" "=>" "=>" "⇒")
-    ("dArr" "\\Downarrow" t "&dArr;" "[dbldownarrow]" "[dbldownarrow]" "⇓")
-    ("Downarrow" "\\Downarrow" t "&dArr;" "[dbldownarrow]" "[dbldownarrow]" "⇓")
-    ("hArr" "\\Leftrightarrow" t "&hArr;" "<=>" "<=>" "⇔")
-    ("Leftrightarrow" "\\Leftrightarrow" t "&hArr;" "<=>" "<=>" "⇔")
-    ("forall" "\\forall" t "&forall;" "[for all]" "[for all]" "∀")
-    ("partial" "\\partial" t "&part;" "[partial differential]" "[partial differential]" "∂")
-    ("exist" "\\exists" t "&exist;" "[there exists]" "[there exists]" "∃")
-    ("exists" "\\exists" t "&exist;" "[there exists]" "[there exists]" "∃")
-    ("empty" "\\empty" t "&empty;" "[empty set]" "[empty set]" "∅")
-    ("emptyset" "\\emptyset" t "&empty;" "[empty set]" "[empty set]" "∅")
-    ("nabla" "\\nabla" t "&nabla;" "[nabla]" "[nabla]" "∇")
-    ("isin" "\\in" t "&isin;" "[element of]" "[element of]" "∈")
-    ("in" "\\in" t "&isin;" "[element of]" "[element of]" "∈")
-    ("notin" "\\notin" t "&notin;" "[not an element of]" "[not an element of]" "∉")
-    ("ni" "\\ni" t "&ni;" "[contains as member]" "[contains as member]" "∋")
-    ("prod" "\\prod" t "&prod;" "[product]" "[n-ary product]" "∏")
-    ("sum" "\\sum" t "&sum;" "[sum]" "[sum]" "∑")
-;   ("minus" "\\minus" t "&minus;" "-" "-" "−")
-    ("minus" "-" t "&minus;" "-" "-" "−")
-    ("lowast" "\\ast" t "&lowast;" "*" "*" "∗")
-    ("ast" "\\ast" t "&lowast;" "*" "*" "*")
+
+    "** Science et al."
+    ("minus" "\\minus" t "&minus;" "-" "-" "−")
+    ("pm" "\\textpm{}" nil "&plusmn;" "+-" "±" "±")
+    ("plusmn" "\\textpm{}" nil "&plusmn;" "+-" "±" "±")
+    ("times" "\\texttimes{}" nil "&times;" "*" "×" "×")
+    ("frasl" "/" nil "&frasl;" "/" "/" "⁄")
+    ("div" "\\textdiv{}" nil "&divide;" "/" "÷" "÷")
+    ("frac12" "\\textonehalf{}" nil "&frac12;" "1/2" "½" "½")
+    ("frac14" "\\textonequarter{}" nil "&frac14;" "1/4" "¼" "¼")
+    ("frac34" "\\textthreequarters{}" nil "&frac34;" "3/4" "¾" "¾")
+    ("permil" "\\textperthousand{}" nil "&permil;" "per thousand" "per thousand" "‰")
+    ("sup1" "\\textonesuperior{}" nil "&sup1;" "^1" "¹" "¹")
+    ("sup2" "\\texttwosuperior{}" nil "&sup2;" "^2" "²" "²")
+    ("sup3" "\\textthreesuperior{}" nil "&sup3;" "^3" "³" "³")
     ("radic" "\\sqrt{\\,}" t "&radic;" "[square root]" "[square root]" "√")
-    ("prop" "\\propto" t "&prop;" "[proportional to]" "[proportional to]" "∝")
-    ("proptp" "\\propto" t "&prop;" "[proportional to]" "[proportional to]" "∝")
+    ("sum" "\\sum" t "&sum;" "[sum]" "[sum]" "∑")
+    ("prod" "\\prod" t "&prod;" "[product]" "[n-ary product]" "∏")
+    ("micro" "\\textmu{}" nil "&micro;" "micro" "µ" "µ")
+    ("macr" "\\textasciimacron{}" nil "&macr;" "[macron]" "¯" "¯")
+    ("deg" "\\textdegree{}" nil "deg" "degree" "°" "°")
+    ("prime" "\\prime" t "&prime;" "'" "'" "′")
+    ("Prime" "\\prime{}\\prime" t "&Prime;" "''" "''" "″")
     ("infin" "\\propto" t "&infin;" "[infinity]" "[infinity]" "∞")
     ("infty" "\\infty" t "&infin;" "[infinity]" "[infinity]" "∞")
-    ("ang" "\\angle" t "&ang;" "[angle]" "[angle]" "∠")
-    ("angle" "\\angle" t "&ang;" "[angle]" "[angle]" "∠")
+    ("prop" "\\propto" t "&prop;" "[proportional to]" "[proportional to]" "∝")
+    ("proptp" "\\propto" t "&prop;" "[proportional to]" "[proportional to]" "∝")
+    ("not" "\\textlnot{}" nil "&not;" "[angled dash]" "¬" "¬")
     ("land" "\\land" t "&and;" "[logical and]" "[logical and]" "∧")
     ("wedge" "\\wedge" t "&and;" "[logical and]" "[logical and]" "∧")
     ("lor" "\\lor" t "&or;" "[logical or]" "[logical or]" "∨")
@@ -300,7 +317,6 @@ loaded, add these packages to `org-export-latex-packages-alist'."
     ("cap" "\\cap" t "&cap;" "[intersection]" "[intersection]" "∩")
     ("cup" "\\cup" t "&cup;" "[union]" "[union]" "∪")
     ("int" "\\int" t "&int;" "[integral]" "[integral]" "∫")
-;   ("there4" "\\uptherefore" t "&there4;" "[therefore]" "[therefore]" "∴")
     ("there4" "\\therefore" t "&there4;" "[therefore]" "[therefore]" "∴")
     ("sim" "\\sim" t "&sim;" "~" "~" "∼")
     ("cong" "\\cong" t "&cong;" "[approx. equal to]" "[approx. equal to]" "≅")
@@ -318,9 +334,20 @@ loaded, add these packages to `org-export-latex-packages-alist'."
     ("supset" "\\supset" t "&sup;" "[superset of]" "[superset of]" "⊃")
     ("nsub" "\\not\\subset" t "&nsub;" "[not a subset of]" "[not a subset of" "⊄")
     ("sube" "\\subseteq" t "&sube;" "[subset of or equal to]" "[subset of or equal to]" "⊆")
+    ("nsup" "\\not\\supset" t "&nsup;" "[not a superset of]" "[not a superset of]" "⊅")
     ("supe" "\\supseteq" t "&supe;" "[superset of or equal to]" "[superset of or equal to]" "⊇")
-    ("oplus" "\\oplus" t "&oplus;" "[circled plus]" "[circled plus]" "⊕")
-    ("otimes" "\\otimes" t "&otimes;" "[circled times]" "[circled times]" "⊗")
+    ("forall" "\\forall" t "&forall;" "[for all]" "[for all]" "∀")
+    ("exist" "\\exists" t "&exist;" "[there exists]" "[there exists]" "∃")
+    ("exists" "\\exists" t "&exist;" "[there exists]" "[there exists]" "∃")
+    ("empty" "\\empty" t "&empty;" "[empty set]" "[empty set]" "∅")
+    ("emptyset" "\\emptyset" t "&empty;" "[empty set]" "[empty set]" "∅")
+    ("isin" "\\in" t "&isin;" "[element of]" "[element of]" "∈")
+    ("in" "\\in" t "&isin;" "[element of]" "[element of]" "∈")
+    ("notin" "\\notin" t "&notin;" "[not an element of]" "[not an element of]" "∉")
+    ("ni" "\\ni" t "&ni;" "[contains as member]" "[contains as member]" "∋")
+    ("nabla" "\\nabla" t "&nabla;" "[nabla]" "[nabla]" "∇")
+    ("ang" "\\angle" t "&ang;" "[angle]" "[angle]" "∠")
+    ("angle" "\\angle" t "&ang;" "[angle]" "[angle]" "∠")
     ("perp" "\\perp" t "&perp;" "[up tack]" "[up tack]" "⊥")
     ("sdot" "\\cdot" t "&sdot;" "[dot]" "[dot]" "⋅")
     ("cdot" "\\cdot" t "&sdot;" "[dot]" "[dot]" "⋅")
@@ -330,56 +357,34 @@ loaded, add these packages to `org-export-latex-packages-alist'."
     ("rfloor" "\\rfloor" t "&rfloor;" "[right floor]" "[right floor]" "⌋")
     ("lang" "\\langle" t "&lang;" "<" "<" "⟨")
     ("rang" "\\rangle" t "&rang;" ">" ">" "⟩")
-    ("loz" "\\diamond" t "&loz;" "[lozenge]" "[lozenge]" "◊")
-    ("Diamond" "\\diamond" t "&diamond;" "[diamond]" "[diamond]" "⋄")
-    ("spades" "\\spadesuit" t "&spades;" "[spades]" "[spades]" "♠")
-    ("spadesuit" "\\spadesuit" t "&spades;" "[spades]" "[spades]" "♠")
-    ("clubs" "\\clubsuit" t "&clubs;" "[clubs]" "[clubs]" "♣")
-    ("clubsuit" "\\clubsuit" t "&clubs;" "[clubs]" "[clubs]" "♣")
-    ("hearts" "\\heartsuit" t "&hearts;" "[hearts]" "[hearts]" "♥")
-    ("heartsuit" "\\heartsuit" t "&heartsuit;" "[hearts]" "[hearts]" "♥")
-    ("diamondsuit" "\\diamondsuit" t "&diams;" "[diamonds]" "[diamonds]" "♦")
-    ("diams" "\\diamondsuit" t "&diams;" "[diamonds]" "[diamonds]" "♦")
-    ("smile" "\\smile" t "&#9786;" ":-)" ":-)" "⌣")
-    ("blacksmile" "\\blacksmiley{}" nil "&#9787;" ":-)" ":-)" "☻")
-    ("sad" "\\frownie{}" nil "&#9785;" ":-(" ":-(" "☹")
-    ("quot" "\\textquotedbl{}" nil "&quot;" "\"" "\"" "\"")
-    ("amp" "\\&" nil "&amp;" "&" "&" "&")
-    ("lt" "\\textless{}" nil "&lt;" "<" "<" "<")
-    ("gt" "\\textgreater{}" nil "&gt;" ">" ">" ">")
-    ("OElig" "\\OE{}" nil "&OElig;" "OE" "OE" "Œ")
-    ("oelig" "\\oe{}" nil "&oelig;" "oe" "oe" "œ")
-    ("Scaron" "\\v{S}" nil "&Scaron;" "S" "S" "Š")
-    ("scaron" "\\v{s}" nil "&scaron;" "s" "s" "š")
-    ("Yuml" "\\\"{Y}" nil "&Yuml;" "Y" "Y" "Ÿ")
-    ("circ" "\\circ" t "&circ;" "^" "^" "ˆ")
-    ("tilde" "\\~{}" nil "&tilde;" "~" "~" "~")
-    ("ensp" "\\hspace*{.5em}" nil "&ensp;" " " " " " ")
-    ("emsp" "\\hspace*{1em}" nil "&emsp;" " " " " " ")
-    ("thinsp" "\\hspace*{.2em}" nil "&thinsp;" " " " " " ")
-    ("zwnj" "\\/{}" nil "&zwnj;" "" "" "‌")
-    ("zwj" "" nil "&zwj;" "" "" "‍")
-    ("lrm" "" nil "&lrm;" "" "" "‎")
-    ("rlm" "" nil "&rlm;" "" "" "‏")
-    ("ndash" "--" nil "&ndash;" "-" "-" "–")
-    ("mdash" "---" nil "&mdash;" "--" "--" "—")
-    ("lsquo" "\\textquoteleft{}" nil "&lsquo;" "`" "`" "‘")
-    ("rsquo" "\\textquoteright{}" nil "&rsquo;" "'" "'" "’")
-    ("sbquo" "\\quotesinglbase{}" nil "&sbquo;" "," "," "‚")
-    ("ldquo" "\\textquotedblleft{}" nil "&ldquo;" "\"" "\"" "“")
-    ("rdquo" "\\textquotedblright{}" nil "&rdquo;" "\"" "\"" "”")
-    ("bdquo" "\\quotedblbase{}" nil "&bdquo;" "\"" "\"" "„")
-    ("dagger" "\\textdagger{}" nil "&dagger;" "[dagger]" "[dagger]" "†")
-    ("Dagger" "\\textdaggerdbl{}" nil "&Dagger;" "[doubledagger]" "[doubledagger]" "‡")
-    ("permil" "\\textperthousand{}" nil "&permil;" "per thousand" "per thousand" "‰")
-    ("lsaquo" "\\guilsinglleft{}" nil "&lsaquo;" "<" "<" "‹")
-    ("rsaquo" "\\guilsinglright{}" nil "&rsaquo;" ">" ">" "›")
-    ("euro" "\\texteuro{}" nil "&euro;" "EUR" "EUR" "€")
-    ("EUR" "\\EUR{}" nil "&euro;" "EUR" "EUR" "€")
-    ("EURdig" "\\EURdig{}" nil "&euro;" "EUR" "EUR" "€")
-    ("EURhv" "\\EURhv{}" nil "&euro;" "EUR" "EUR" "€")
-    ("EURcr" "\\EURcr{}" nil "&euro;" "EUR" "EUR" "€")
-    ("EURtm" "\\EURtm{}" nil "&euro;" "EUR" "EUR" "€")
+
+    "** Arrows"
+    ("larr" "\\leftarrow" t "&larr;" "<-" "<-" "←")
+    ("leftarrow" "\\leftarrow" t "&larr;"  "<-" "<-" "←")
+    ("gets" "\\gets" t "&larr;"  "<-" "<-" "←")
+    ("lArr" "\\Leftarrow" t "&lArr;" "<=" "<=" "⇐")
+    ("Leftarrow" "\\Leftarrow" t "&lArr;" "<=" "<=" "⇐")
+    ("uarr" "\\uparrow" t "&uarr;" "[uparrow]" "[uparrow]" "↑")
+    ("uparrow" "\\uparrow" t "&uarr;" "[uparrow]" "[uparrow]" "↑")
+    ("uArr" "\\Uparrow" t "&uArr;" "[dbluparrow]" "[dbluparrow]" "⇑")
+    ("Uparrow" "\\Uparrow" t "&uArr;" "[dbluparrow]" "[dbluparrow]" "⇑")
+    ("rarr" "\\rightarrow" t "&rarr;" "->" "->" "→")
+    ("to" "\\to" t "&rarr;" "->" "->" "→")
+    ("rightarrow" "\\rightarrow" t "&rarr;"  "->" "->" "→")
+    ("rArr" "\\Rightarrow" t "&rArr;" "=>" "=>" "⇒")
+    ("Rightarrow" "\\Rightarrow" t "&rArr;" "=>" "=>" "⇒")
+    ("darr" "\\downarrow" t "&darr;" "[downarrow]" "[downarrow]" "↓")
+    ("downarrow" "\\downarrow" t "&darr;" "[downarrow]" "[downarrow]" "↓")
+    ("dArr" "\\Downarrow" t "&dArr;" "[dbldownarrow]" "[dbldownarrow]" "⇓")
+    ("Downarrow" "\\Downarrow" t "&dArr;" "[dbldownarrow]" "[dbldownarrow]" "⇓")
+    ("harr" "\\leftrightarrow" t "&harr;" "<->" "<->" "↔")
+    ("leftrightarrow" "\\leftrightarrow" t "&harr;"  "<->" "<->" "↔")
+    ("hArr" "\\Leftrightarrow" t "&hArr;" "<=>" "<=>" "⇔")
+    ("Leftrightarrow" "\\Leftrightarrow" t "&hArr;" "<=>" "<=>" "⇔")
+    ("crarr" "\\hookleftarrow" t "&crarr;" "<-'" "<-'" "↵")
+    ("hookleftarrow" "\\hookleftarrow" t "&crarr;"  "<-'" "<-'" "↵")
+
+    "** Function names"
     ("arccos" "\\arccos" t "arccos" "arccos" "arccos" "arccos")
     ("arcsin" "\\arcsin" t "arcsin" "arcsin" "arcsin" "arcsin")
     ("arctan" "\\arctan" t "arctan" "arctan" "arctan" "arctan")
@@ -412,13 +417,47 @@ loaded, add these packages to `org-export-latex-packages-alist'."
     ("sup" "\\sup" t "&sup;" "sup" "sup" "sup")
     ("tan" "\\tan" t "tan" "tan" "tan" "tan")
     ("tanh" "\\tanh" t "tanh" "tanh" "tanh" "tanh")
-    ("frac12" "\\textonehalf{}" nil "&frac12;" "1/2" "½" "½")
-    ("frac14" "\\textonequarter{}" nil "&frac14;" "1/4" "¼" "¼")
-    ("frac34" "\\textthreequarters{}" nil "&frac34;" "3/4" "¾" "¾")
-    ("div" "\\textdiv{}" nil "&divide;" "/" "÷" "÷")
-    ("acute" "\\textasciiacute{}" nil "&acute;" "'" "´" "´")
-    ("nsup" "\\not\\supset" t "&nsup;" "[not a superset of]" "[not a superset of]" "⊅")
+
+    "** Signs & Symbols"
+    ("bull" "\\textbullet{}" nil "&bull;" "*" "*" "•")
+    ("bullet" "\\textbullet{}" nil "&bull;" "*" "*" "•")
+    ("star" "\\star" t "*" "*" "*" "⋆")
+    ("lowast" "\\ast" t "&lowast;" "*" "*" "∗")
+    ("ast" "\\ast" t "&lowast;" "*" "*" "*")
+    ("odot" "\\odot" t "o" "[circled dot]" "[circled dot]" "ʘ")
+    ("oplus" "\\oplus" t "&oplus;" "[circled plus]" "[circled plus]" "⊕")
+    ("otimes" "\\otimes" t "&otimes;" "[circled times]" "[circled times]" "⊗")
+    ("checkmark" "\\checkmark" t "&#10003;" "[checkmark]" "[checkmark]" "✓")
+
+    "** Miscellaneous (seldom used)"
+    ("para" "\\P{}" nil "&para;" "[pilcrow]" "¶" "¶")
+    ("ordf" "\\textordfeminine{}" nil "&ordf;" "_a_" "ª" "ª")
+    ("ordm" "\\textordmasculine{}" nil "&ordm;" "_o_" "º" "º")
+    ("cedil" "\\c{}" nil "&cedil;" "[cedilla]" "¸" "¸")
+    ("oline" "\\overline{~}" t "&oline;" "[overline]" "¯" "‾")
+    ("uml" "\\textasciidieresis{}" nil "&uml;" "[diaeresis]" "¨" "¨")
+    ("zwnj" "\\/{}" nil "&zwnj;" "" "" "‌")
+    ("zwj" "" nil "&zwj;" "" "" "‍")
+    ("lrm" "" nil "&lrm;" "" "" "‎")
+    ("rlm" "" nil "&rlm;" "" "" "‏")
+
+    "** Smilies"
+    ("smile" "\\smile" t "&#9786;" ":-)" ":-)" "⌣")
     ("smiley" "\\smiley{}" nil "&#9786;" ":-)" ":-)" "☺")
+    ("blacksmile" "\\blacksmiley{}" nil "&#9787;" ":-)" ":-)" "☻")
+    ("sad" "\\frownie{}" nil "&#9785;" ":-(" ":-(" "☹")
+
+    "** Suits"
+    ("clubs" "\\clubsuit" t "&clubs;" "[clubs]" "[clubs]" "♣")
+    ("clubsuit" "\\clubsuit" t "&clubs;" "[clubs]" "[clubs]" "♣")
+    ("spades" "\\spadesuit" t "&spades;" "[spades]" "[spades]" "♠")
+    ("spadesuit" "\\spadesuit" t "&spades;" "[spades]" "[spades]" "♠")
+    ("hearts" "\\heartsuit" t "&hearts;" "[hearts]" "[hearts]" "♥")
+    ("heartsuit" "\\heartsuit" t "&heartsuit;" "[hearts]" "[hearts]" "♥")
+    ("diams" "\\diamondsuit" t "&diams;" "[diamonds]" "[diamonds]" "♦")
+    ("diamondsuit" "\\diamondsuit" t "&diams;" "[diamonds]" "[diamonds]" "♦")
+    ("Diamond" "\\diamond" t "&diamond;" "[diamond]" "[diamond]" "⋄")
+    ("loz" "\\diamond" t "&loz;" "[lozenge]" "[lozenge]" "◊")
     )
   "Default entities used in Org-mode to preduce special characters.
 For details see `org-entities-user'.")
@@ -457,46 +496,61 @@ Kind can be any of `latex', `html', `ascii', `latin1', or `utf8'."
 	e latex mathp html latin utf8 name ascii)
     (insert "|Name|LaTeX code|LaTeX|HTML code |HTML|ASCII|Latin1|UTF-8\n|-\n")
     (while ll
-      (setq e (pop ll))
-      (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"))
+      (when (listp e)
+	(setq e (pop ll))
+	(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")))
     (goto-char pos)
     (org-table-align)))
 
 (defun org-entities-help ()
   "Create a Help buffer with all available entities"
   (interactive)
-  (with-output-to-temp-buffer "*Help*"
+  (with-output-to-temp-buffer "*Org Entity Help*"
     (princ "Org-mode entities\n=================\n\n")
     (let ((ll (append org-entities-user org-entities))
-	  e latex mathp html latin utf8 name ascii)
-      (princ "Symbol   Org entity        LaTeX code             HTML code\n")
-      (princ "-----------------------------------------------------------\n")
+	  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))
-	(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))))))
+	(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))))))
+  (with-current-buffer "*Org Entity Help*"
+    (org-mode))
+  (select-window (get-buffer-window "*Org Entity Help*")))
+
 
 (defun replace-amp ()
   "Postprocess HTML file to unescape the ampersant."

+ 55 - 16
lisp/org-exp.el

@@ -1161,6 +1161,9 @@ on this string to produce the exported version."
       ;; Remove or replace comments
       (org-export-handle-comments (plist-get parameters :comments))
 
+      ;; Remove #+TBLFM and #+TBLNAME lines
+      (org-export-handle-table-metalines)
+      
       ;; Run the final hook
       (run-hooks 'org-export-preprocess-final-hook)
 
@@ -1526,15 +1529,25 @@ from the buffer."
 
     (while formatters
       (setq fmt (pop formatters))
-      (when (eq (car fmt) backend)
-	;; This is selected code, put it into the file for real
-	(goto-char (point-min))
-	(while (re-search-forward (concat "^\\([ \t]*\\)#\\+" (cadr fmt)
-					  ":[ \t]*\\(.*\\)") nil t)
+      ;; Handle #+Backend: stuff
+      (goto-char (point-min))
+      (while (re-search-forward (concat "^\\([ \t]*\\)#\\+" (cadr fmt)
+					":[ \t]*\\(.*\\)") nil t)
+	(if (not (eq (car fmt) backend))
+	    (delete-region (point-at-bol) (min (1+ (point-at-eol)) (point-max)))
 	  (replace-match "\\1\\2" t)
 	  (add-text-properties
 	   (point-at-bol) (min (1+ (point-at-eol)) (point-max))
 	   '(org-protected t))))
+      ;; Delete #+attr_Backend: stuff of another backend. Those
+      ;; matching the current backend will be taken care of by
+      ;; `org-export-attach-captions-and-attributes'
+      (goto-char (point-min))
+      (while (re-search-forward (concat "^\\([ \t]*\\)#\\+attr_" (cadr fmt)
+					":[ \t]*\\(.*\\)") nil t)
+	(when (not (eq (car fmt) backend))
+	  (delete-region (point-at-bol) (min (1+ (point-at-eol)) (point-max)))))
+      ;; Handle #+begin_Backend and #+end_Backend stuff
       (goto-char (point-min))
       (while (re-search-forward (concat "^[ \t]*#\\+" (caddr fmt) "\\>.*\n?")
 				nil t)
@@ -1568,8 +1581,8 @@ These special cookies will later be interpreted by the backend."
       (setq beg (match-beginning 0)
 	    beg1 (1+ (match-end 0)))
       (when (re-search-forward (concat "^[ \t]*#\\+end_" type "\\>.*") nil t)
-	(setq end (+ (point-at-eol) (if (looking-at "\n$") 1 0))
-	      end1 (1- (match-beginning 0)))
+	(setq end1 (1- (match-beginning 0))
+	      end (+ (point-at-eol) (if (looking-at "\n$") 1 0)))
 	(setq content (org-remove-indentation (buffer-substring beg1 end1)))
 	(setq content (concat "ORG-" (upcase t1) "-START\n"
 			      content "\n"
@@ -1594,15 +1607,24 @@ table line.  If it is a link, add it to the line containing the link."
 		    "^[ \t]*\\(|[^-]\\)"
 		    "\\|"
 		    "^[ \t]*\\[\\[.*\\]\\][ \t]*$"))
-	cap attr label end)
+	cap shortn attr label end)
     (while (re-search-forward re nil t)
       (cond
        ((match-end 1)
-	(setq cap (concat cap (if cap " " "") (org-trim (match-string 1)))))
+	(progn
+	  (setq cap (concat cap (if cap " " "") (org-trim (match-string 1))))
+	  (when (string-match "\\[\\(.*\\)\\]{\\(.*\\)}" cap)
+	    (setq shortn (match-string 1 cap)
+		  cap (match-string 2 cap)))
+	  (delete-region (point-at-bol) (min (1+ (point-at-eol)) (point-max)))))
        ((match-end 2)
-	(setq attr (concat attr (if attr " " "") (org-trim (match-string 2)))))
+	(progn
+	  (setq attr (concat attr (if attr " " "") (org-trim (match-string 2))))
+	  (delete-region (point-at-bol) (min (1+ (point-at-eol)) (point-max)))))
        ((match-end 3)
-	(setq label (org-trim (match-string 3))))
+	(progn
+	  (setq label (org-trim (match-string 3)))
+	  (delete-region (point-at-bol) (min (1+ (point-at-eol)) (point-max)))))
        (t
 	(setq end (if (match-end 4)
 		      (let ((ee (org-table-end)))
@@ -1610,6 +1632,7 @@ table line.  If it is a link, add it to the line containing the link."
 		    (point-at-eol)))
 	(add-text-properties (point-at-bol) end
 			     (list 'org-caption cap
+				   'org-caption-shortn shortn
 				   'org-attributes attr
 				   'org-label label))
 	(if label (push (cons label label) target-alist))
@@ -1644,11 +1667,27 @@ When it is nil, all comments will be removed."
     (while (or (looking-at re)
 	       (re-search-forward re nil t))
       (setq pos (match-beginning 0))
-      (if (and commentsp
-	       (not (equal (char-before (match-end 1)) ?+)))
-	  (progn (add-text-properties
-		  (match-beginning 0) (match-end 0) '(org-protected t))
-		 (replace-match (format commentsp (match-string 2)) t t))
+      (if (get-text-property pos 'org-protected)
+	  (goto-char (1+ pos))
+	(if (and commentsp
+		 (not (equal (char-before (match-end 1)) ?+)))
+	    (progn (add-text-properties
+		    (match-beginning 0) (match-end 0) '(org-protected t))
+		   (replace-match (format commentsp (match-string 2)) t t))
+	  (goto-char (1+ pos))
+	  (replace-match "")
+	  (goto-char (max (point-min) (1- pos))))))))
+
+(defun org-export-handle-table-metalines ()
+  "Remove table specific metalines #+TBLNAME: and #+TBLFM:."
+  (let ((re "^[ \t]*#\\+TBL\\(NAME\\|FM\\):\\(.*\n?\\)")
+	pos)
+    (goto-char (point-min))
+    (while (or (looking-at re)
+	       (re-search-forward re nil t))
+      (setq pos (match-beginning 0))
+      (if (get-text-property (point) 'org-protected)
+	  (goto-char (1+ pos))
 	(goto-char (1+ pos))
 	(replace-match "")
 	(goto-char (max (point-min) (1- pos)))))))

+ 19 - 7
lisp/org-feed.el

@@ -99,6 +99,7 @@
 (declare-function xml-get-children "xml" (node child-name))
 (declare-function xml-get-attribute "xml" (node attribute))
 (declare-function xml-get-attribute-or-nil "xml" (node attribute))
+(defvar xml-entity-alist)
 
 (defgroup org-feed  nil
   "Options concerning RSS feeds as inputs for Org files."
@@ -267,6 +268,16 @@ have been saved."
 (defvar org-feed-buffer "*Org feed*"
   "The buffer used to retrieve a feed.")
 
+(defun org-feed-unescape (s)
+  "Unescape protected entities in S."
+  (let ((re (concat "&\\("
+		    (mapconcat 'car xml-entity-alist "\\|")
+		    "\\);")))
+    (while (string-match re s)
+      (setq s (replace-match
+	       (cdr (assoc (match-string 1 s) xml-entity-alist)) nil nil s)))
+    s))
+
 ;;;###autoload
 (defun org-feed-update-all ()
   "Get inbox items from all feeds in `org-feed-alist'."
@@ -579,11 +590,12 @@ 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'."
-  (let (entries beg end item guid entry)
+  (let ((case-fold-search t)
+	entries beg end item guid entry)
     (with-current-buffer buffer
       (widen)
       (goto-char (point-min))
-      (while (re-search-forward "<item>" nil t)
+      (while (re-search-forward "<item\\>.*?>" nil t)
 	(setq beg (point)
 	      end (and (re-search-forward "</item>" nil t)
 		       (match-beginning 0)))
@@ -605,7 +617,7 @@ containing the properties `:guid' and `:item-full-text'."
 			      nil t)
       (setq entry (plist-put entry
 			     (intern (concat ":" (match-string 1)))
-			     (match-string 2))))
+			     (org-feed-unescape (match-string 2)))))
     (goto-char (point-min))
     (unless (re-search-forward "isPermaLink[ \t]*=[ \t]*\"false\"" nil t)
       (setq entry (plist-put entry :guid-permalink t))))
@@ -638,18 +650,18 @@ formatted as a string, not the original XML data."
                             'href)))
     ;; Add <title/> as :title.
     (setq entry (plist-put entry :title
-                           (car (xml-node-children
-                                 (car (xml-get-children xml 'title))))))
+			   (org-feed-unescape (car (xml-node-children
+						    (car (xml-get-children xml 'title)))))))
     (let* ((content (car (xml-get-children xml 'content)))
            (type (xml-get-attribute-or-nil content 'type)))
       (when content
         (cond
          ((string= type "text")
           ;; We like plain text.
-          (setq entry (plist-put entry :description (car (xml-node-children content)))))
+	  (setq entry (plist-put entry :description (org-feed-unescape (car (xml-node-children content))))))
          ((string= type "html")
           ;; TODO: convert HTML to Org markup.
-          (setq entry (plist-put entry :description (car (xml-node-children content)))))
+	  (setq entry (plist-put entry :description (org-feed-unescape (car (xml-node-children content))))))
          ((string= type "xhtml")
           ;; TODO: convert XHTML to Org markup.
           (setq entry (plist-put entry :description (prin1-to-string (xml-node-children content)))))

+ 4 - 2
lisp/org-habit.el

@@ -178,8 +178,10 @@ This list represents a \"habit\" for the rest of this module."
 (defsubst org-habit-deadline (habit)
   (let ((deadline (nth 2 habit)))
     (or deadline
-	(+ (org-habit-scheduled habit)
-	   (1- (org-habit-scheduled-repeat habit))))))
+	(if (nth 3 habit)
+	    (+ (org-habit-scheduled habit)
+	       (1- (org-habit-scheduled-repeat habit)))
+	  (org-habit-scheduled habit)))))
 (defsubst org-habit-deadline-repeat (habit)
   (or (nth 3 habit)
       (org-habit-scheduled-repeat habit)))

+ 2 - 1
lisp/org-html.el

@@ -433,7 +433,8 @@ This may also be a function, building and inserting the postamble.")
      (concat "ltxpng/" (file-name-sans-extension
 			(file-name-nondirectory
 			 org-current-export-file)))
-     org-current-export-dir nil "Creating LaTeX image %s"))
+     org-current-export-dir nil "Creating LaTeX image %s"
+     nil nil (eq (plist-get parameters :LaTeX-fragments) 'verbatim)))
   (goto-char (point-min))
   (let (label l1)
     (while (re-search-forward "\\\\ref{\\([^{}\n]+\\)}" nil t)

+ 27 - 21
lisp/org-latex.el

@@ -1537,20 +1537,20 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
   "When OPT is non-nil convert fixed-width sections to LaTeX."
   (goto-char (point-min))
   (while (re-search-forward "^[ \t]*:\\([ \t]\\|$\\)" nil t)
-    (if opt
-	(progn (goto-char (match-beginning 0))
-	       (insert "\\begin{verbatim}\n")
-	       (while (looking-at "^\\([ \t]*\\):\\(\\([ \t]\\|$\\).*\\)$")
-		 (replace-match (concat (match-string 1)
-					(match-string 2)) t t)
-		 (forward-line))
-	       (insert "\\end{verbatim}\n\n"))
-      (progn (goto-char (match-beginning 0))
-	     (while (looking-at "^\\([ \t]*\\):\\(\\([ \t]\\|$\\).*\\)$")
-	       (replace-match (concat "%" (match-string 1)
-				      (match-string 2)) t t)
-	       (forward-line))))))
-
+    (unless (get-text-property (point) 'org-example)
+     (if opt
+	 (progn (goto-char (match-beginning 0))
+		(insert "\\begin{verbatim}\n")
+		(while (looking-at "^\\([ \t]*\\):\\(\\([ \t]\\|$\\).*\\)$")
+		  (replace-match (concat (match-string 1)
+					 (match-string 2)) t t)
+		  (forward-line))
+		(insert "\\end{verbatim}\n\n"))
+       (progn (goto-char (match-beginning 0))
+	      (while (looking-at "^\\([ \t]*\\):\\(\\([ \t]\\|$\\).*\\)$")
+		(replace-match (concat "%" (match-string 1)
+				       (match-string 2)) t t)
+		(forward-line)))))))
 
 (defvar org-table-last-alignment) ; defined in org-table.el
 (defvar org-table-last-column-widths) ; defined in org-table.el
@@ -1576,7 +1576,7 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
              (org-table-last-column-widths (copy-sequence
                                             org-table-last-column-widths))
              fnum fields line lines olines gr colgropen line-fmt align
-             caption label attr floatp longtblp)
+             caption shortn label attr floatp longtblp)
         (if org-export-latex-tables-verbatim
             (let* ((tbl (concat "\\begin{verbatim}\n" raw-table
                                 "\\end{verbatim}\n")))
@@ -1585,6 +1585,8 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
           (progn
             (setq caption (org-find-text-property-in-string
                            'org-caption raw-table)
+		  shortn (org-find-text-property-in-string
+			  'org-caption-shortn raw-table)
                   attr (org-find-text-property-in-string
                         'org-attributes raw-table)
                   label (org-find-text-property-in-string
@@ -1652,8 +1654,8 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
                           (if floatp "\\begin{table}[htb]\n"))
                         (if floatp
                             (format
-                             "\\caption{%s%s}"
-                             (if label (concat "\\\label{" label "}") "")
+                             "\\caption%s{%s%s}"
+                             (if shortn (concat "[" shortn "]") "")
                              (or caption "")))
                         (if (and longtblp caption) "\\\\\n" "\n")
                         (if (and org-export-latex-tables-centered (not longtblp))
@@ -1680,10 +1682,11 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
 
 (defun org-export-latex-convert-table.el-table ()
   "Replace table.el table at point with LaTeX code."
-  (let (tbl caption label line floatp attr align rmlines)
+  (let (tbl caption shortn label line floatp attr align rmlines)
     (setq line (buffer-substring (point-at-bol) (point-at-eol))
 	  label (org-get-text-property-any 0 'org-label line)
 	  caption (org-get-text-property-any 0 'org-caption line)
+	  shortn (org-get-text-property-any 0 'org-caption-shortn line)
 	  attr (org-get-text-property-any 0 'org-attributes line)
 	  align (and attr (stringp attr)
 		     (string-match "\\<align=\\([^ \t\n\r,]+\\)" attr)
@@ -1721,7 +1724,8 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
       (setq tbl (concat "\\begin{center}\n" tbl "\\end{center}")))
     (when floatp
       (setq tbl (concat "\\begin{table}\n"
-			(format "\\caption{%s%s}\n"
+			(format "\\caption%s{%s%s}\n"
+				(if shortn (format "[%s]" shortn) "")
 				(if label (format "\\label{%s}" label) "")
 				(or caption ""))
 			tbl
@@ -1822,6 +1826,7 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
 			  "file")))
 	    (coderefp (equal type "coderef"))
 	    (caption (org-find-text-property-in-string 'org-caption raw-path))
+	    (shortn (org-find-text-property-in-string 'org-caption-shortn raw-path))
 	    (attr (or (org-find-text-property-in-string 'org-attributes raw-path)
 		      (plist-get org-export-latex-options-plist :latex-image-options)))
 	    (label (org-find-text-property-in-string 'org-label raw-path))
@@ -1859,7 +1864,7 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
 		   (plist-get org-export-latex-options-plist :inline-images))
 	      ;; OK, we need to inline an image
 	      (insert
-	       (org-export-latex-format-image raw-path caption label attr)))
+	       (org-export-latex-format-image raw-path caption label attr shortn)))
 	     (coderefp
 	      (insert (format
 		       (org-export-get-coderef-format path desc)
@@ -1922,7 +1927,7 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
 	   (wrapp "\\begin{wrapfigure}%placement
 \\centering
 \\includegraphics[%attr]{%path}
-\\caption{%labelcmd%caption}
+\\caption%shortn{%labelcmd%caption}
 \\end{wrapfigure}")
 	   (multicolumnp "\\begin{figure*}%placement
 \\centering
@@ -1953,6 +1958,7 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
 			 (expand-file-name path)
 		       path))
 	       (cons "attr" attr)
+	       (cons "shortn" (if shortn (format "[%s]" shortn) ""))
 	       (cons "labelcmd" (if label (format "\\label{%s}"
 						  label)""))
 	       (cons "caption" (or caption ""))

+ 0 - 3
lisp/org-protocol.el

@@ -126,8 +126,6 @@
 (eval-when-compile
   (require 'cl))
 
-(declare-function org-publish-initialize-files-alist "org-publish"
-		  (&optional refresh))
 (declare-function org-publish-get-project-from-filename "org-publish"
 		  (filename &optional up))
 (declare-function server-edit "server" (&optional arg))
@@ -647,7 +645,6 @@ This works, if the file visited is part of a publishing project in
 most of the work."
   (interactive)
   (require 'org-publish)
-  (org-publish-initialize-files-alist)
   (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?"

+ 1 - 1
lisp/org-publish.el

@@ -931,7 +931,7 @@ and return it."
 	   " in `org-publish-initialize-cache'"))
 
   (unless (file-exists-p org-publish-timestamp-directory)
-    (make-directory org-publish-timestamp-directory))
+    (make-directory org-publish-timestamp-directory t))
   (if (not (file-directory-p org-publish-timestamp-directory))
       (error "Org publish timestamp: %s is not a directory"
 	     org-publish-timestamp-directory))

+ 9 - 3
lisp/org-table.el

@@ -4119,6 +4119,7 @@ directly by `orgtbl-send-table'.  See manual."
   (let* ((splicep (plist-get params :splice))
 	 (hline (plist-get params :hline))
 	 (remove-nil-linesp (plist-get params :remove-nil-lines))
+	 (remove-newlines (plist-get params :remove-newlines))
 	 (*orgtbl-hline* hline)
 	 (*orgtbl-table* table)
 	 (*orgtbl-sep* (plist-get params :sep))
@@ -4173,9 +4174,13 @@ directly by `orgtbl-send-table'.  See manual."
 	(let ((tend (orgtbl-eval-str (plist-get params :tend))))
 	  (if tend (push tend *orgtbl-rtn*)))))
 
-    (mapconcat 'identity (nreverse (if remove-nil-linesp
-				       (remq nil *orgtbl-rtn*)
-				     *orgtbl-rtn*)) "\n")))
+    (mapconcat (if remove-newlines
+		   (lambda (tend)
+		     (replace-regexp-in-string "[\n\r\t\f]" "\\\\n" tend))
+		 'identity)
+	       (nreverse (if remove-nil-linesp
+			     (remq nil *orgtbl-rtn*)
+			   *orgtbl-rtn*)) "\n")))
 
 (defun orgtbl-to-tsv (table params)
   "Convert the orgtbl-mode table to TAB separated material."
@@ -4301,6 +4306,7 @@ and :tend suppress strings without splicing; they can be set to
 provide ORGTBL directives for the generated table."
   (let* ((params2
 	  (list
+	   :remove-newlines t
 	   :tstart nil :tend nil
 	   :hline "|---"
 	   :sep " | "

+ 37 - 27
lisp/org-wl.el

@@ -62,6 +62,11 @@ googlegroups otherwise."
   :type 'boolean
   :group 'org-wl)
 
+(defcustom org-wl-disable-folder-check t
+  "Disable check for new messages when open a link."
+  :type 'boolean
+  :group 'org-wl)
+
 (defcustom org-wl-namazu-default-index nil
   "Default namazu search index."
   :type 'directory
@@ -94,6 +99,7 @@ googlegroups otherwise."
 (defvar wl-summary-buffer-elmo-folder)
 (defvar wl-summary-buffer-folder-name)
 (defvar wl-folder-group-regexp)
+(defvar wl-auto-check-folder-name)
 
 (defconst org-wl-folder-types
   '(("%" . imap) ("-" . nntp) ("+" . mh) ("=" . spool)
@@ -233,33 +239,37 @@ with `org-wl-namazu-default-index' as search index.  When called
 with two prefixes or `org-wl-namazu-default-index' is nil, ask
 for namazu index."
   (require 'wl)
-  (unless wl-init (wl))
-  ;; XXX: The imap-uw's MH folder names start with "%#".
-  (if (not (string-match "\\`\\(\\(?:%#\\)?[^#]+\\)\\(#\\(.*\\)\\)?" path))
-      (error "Error in Wanderlust link"))
-  (let ((folder (match-string 1 path))
-	(article (match-string 3 path)))
-    ;; maybe open message in namazu search folder
-    (when current-prefix-arg
-      (setq folder (concat "[" article "]"
-			   (if (and (equal current-prefix-arg '(4))
-				    org-wl-namazu-default-index)
-			       org-wl-namazu-default-index
-			     (read-directory-name "Namazu index: ")))))
-    (if (not (elmo-folder-exists-p (org-no-warnings
-				    (wl-folder-get-elmo-folder folder))))
-	(error "No such folder: %s" folder))
-    (let ((old-buf (current-buffer))
-	  (old-point (point-marker)))
-      (wl-folder-goto-folder-subr folder)
-      (with-current-buffer old-buf
-	;; XXX: `wl-folder-goto-folder-subr' moves point to the
-	;; beginning of the current line.  So, restore the point
-	;; in the old buffer.
-	(goto-char old-point))
-      (and article (wl-summary-jump-to-msg-by-message-id (org-add-angle-brackets
-							  article))
-	   (wl-summary-redisplay)))))
+  (let ((wl-auto-check-folder-name
+	 (if org-wl-disable-folder-check
+	     'none
+	   wl-auto-check-folder-name)))
+    (unless wl-init (wl))
+    ;; XXX: The imap-uw's MH folder names start with "%#".
+    (if (not (string-match "\\`\\(\\(?:%#\\)?[^#]+\\)\\(#\\(.*\\)\\)?" path))
+	(error "Error in Wanderlust link"))
+    (let ((folder (match-string 1 path))
+	  (article (match-string 3 path)))
+      ;; maybe open message in namazu search folder
+      (when current-prefix-arg
+	(setq folder (concat "[" article "]"
+			     (if (and (equal current-prefix-arg '(4))
+				      org-wl-namazu-default-index)
+				 org-wl-namazu-default-index
+			       (read-directory-name "Namazu index: ")))))
+      (if (not (elmo-folder-exists-p (org-no-warnings
+				      (wl-folder-get-elmo-folder folder))))
+	  (error "No such folder: %s" folder))
+      (let ((old-buf (current-buffer))
+	    (old-point (point-marker)))
+	(wl-folder-goto-folder-subr folder)
+	(with-current-buffer old-buf
+	  ;; XXX: `wl-folder-goto-folder-subr' moves point to the
+	  ;; beginning of the current line.  So, restore the point
+	  ;; in the old buffer.
+	  (goto-char old-point))
+	(and article (wl-summary-jump-to-msg-by-message-id (org-add-angle-brackets
+							    article))
+	     (wl-summary-redisplay))))))
 
 (provide 'org-wl)
 

+ 130 - 95
lisp/org.el

@@ -1386,8 +1386,9 @@ Changing this requires a restart of Emacs to work correctly."
 
 (defcustom org-link-frame-setup
   '((vm . vm-visit-folder-other-frame)
-    (gnus . gnus-other-frame)
-    (file . find-file-other-window))
+    (gnus . org-gnus-no-new-news)
+    (file . find-file-other-window)
+    (wl . wl-other-frame))
   "Setup the frame configuration for following links.
 When following a link with Emacs, it may often be useful to display
 this link in another window or frame.  This variable can be used to
@@ -1403,6 +1404,9 @@ For FILE, use any of
     `find-file'
     `find-file-other-window'
     `find-file-other-frame'
+For Wanderlust use any of
+    `wl'
+    `wl-other-frame'
 For the calendar, use the variable `calendar-setup'.
 For BBDB, it is currently only possible to display the matches in
 another window."
@@ -1422,7 +1426,11 @@ another window."
 		(choice
 		 (const find-file)
 		 (const find-file-other-window)
-		 (const find-file-other-frame)))))
+		 (const find-file-other-frame)))
+	  (cons (const wl)
+		(choice
+		 (const wl)
+		 (const wl-other-frame)))))
 
 (defcustom org-display-internal-link-with-indirect-buffer nil
   "Non-nil means use indirect buffer to display infile links.
@@ -1480,6 +1488,9 @@ single keystroke rather than having to type \"yes\"."
 	  (const :tag "with yes-or-no (safer)" yes-or-no-p)
 	  (const :tag "with y-or-n (faster)" y-or-n-p)
 	  (const :tag "no confirmation (dangerous)" nil)))
+(put 'org-confirm-shell-link-function
+     'safe-local-variable
+     '(lambda (x) (member x '(yes-or-no-p y-or-n-p))))
 
 (defcustom org-confirm-elisp-link-function 'yes-or-no-p
   "Non-nil means ask for confirmation before executing Emacs Lisp links.
@@ -1497,6 +1508,9 @@ single keystroke rather than having to type \"yes\"."
 	  (const :tag "with yes-or-no (safer)" yes-or-no-p)
 	  (const :tag "with y-or-n (faster)" y-or-n-p)
 	  (const :tag "no confirmation (dangerous)" nil)))
+(put 'org-confirm-shell-link-function
+     'safe-local-variable
+     '(lambda (x) (member x '(yes-or-no-p y-or-n-p))))
 
 (defconst org-file-apps-defaults-gnu
   '((remote . emacs)
@@ -1657,10 +1671,8 @@ following situations:
 
 (defcustom org-default-notes-file (convert-standard-filename "~/.notes")
   "Default target for storing notes.
-Used by the hooks for remember.el.  This can be a string, or nil to mean
-the value of `remember-data-file'.
-You can set this on a per-template basis with the variable
-`org-remember-templates'."
+Used as a fall back file for org-remember.el and org-capture.el, for
+templates that do not specify a target file."
   :group 'org-refile
   :group 'org-remember
   :type '(choice
@@ -5181,13 +5193,17 @@ will be prompted for."
 	  (if org-export-with-TeX-macros
 	      (list (concat "\\\\"
 			    (regexp-opt
-			     (append (mapcar 'car (append org-entities-user
-							  org-entities))
-				     (if (boundp 'org-latex-entities)
-					 (mapcar (lambda (x)
-						   (or (car-safe x) x))
-						 org-latex-entities)
-				       nil))
+			     (append
+
+			      (delq nil
+				    (mapcar 'car-safe
+					    (append org-entities-user
+						    org-entities)))
+			      (if (boundp 'org-latex-entities)
+				  (mapcar (lambda (x)
+					    (or (car-safe x) x))
+					  org-latex-entities)
+				nil))
 			     'words))) ; FIXME
 	    ))
     ;;			(list "\\\\\\(?:[a-zA-Z]+\\)")))
@@ -10665,7 +10681,7 @@ For calling through lisp, arg is also interpreted in the following way:
 	    (looking-at " *"))
 	(let* ((match-data (match-data))
 	       (startpos (point-at-bol))
-	       (logging (save-match-data (org-entry-get nil "LOGGING" t)))
+	       (logging (save-match-data (org-entry-get nil "LOGGING" t t)))
 	       (org-log-done org-log-done)
 	       (org-log-repeat org-log-repeat)
 	       (org-todo-log-states org-todo-log-states)
@@ -13380,7 +13396,7 @@ when a \"nil\" value can supercede a non-nil value higher up the hierarchy."
     (if (and inherit (if (eq inherit 'selective)
 			 (org-property-inherit-p property)
 		       t))
-	(org-entry-get-with-inheritance property)
+	(org-entry-get-with-inheritance property literal-nil)
       (if (member property org-special-properties)
 	  ;; We need a special property.  Use `org-entry-properties' to
 	  ;; retrieve it, but specify the wanted property
@@ -13490,8 +13506,12 @@ no match, the marker will point nowhere.
 Note that also `org-entry-get' calls this function, if the INHERIT flag
 is set.")
 
-(defun org-entry-get-with-inheritance (property)
-  "Get entry property, and search higher levels if not present."
+(defun org-entry-get-with-inheritance (property &optional literal-nil)
+  "Get entry property, and search higher levels if not present.
+The search will stop at the first ancestor which has the property defined.
+If the value found is \"nil\", return nil to show that the property
+should be considered as undefined (this is the meaning of nil here).
+However, if LITERAL-NIL is set, return the string value \"nil\" instead."
   (move-marker org-entry-property-inherited-from nil)
   (let (tmp)
     (save-excursion
@@ -13504,11 +13524,11 @@ is set.")
 	      (move-marker org-entry-property-inherited-from (point))
 	      (throw 'ex tmp))
 	    (or (org-up-heading-safe) (throw 'ex nil)))))
-      (org-not-nil
-       (or tmp
-	   (cdr (assoc property org-file-properties))
-	   (cdr (assoc property org-global-properties))
-	   (cdr (assoc property org-global-properties-fixed)))))))
+      (setq tmp (or tmp
+		    (cdr (assoc property org-file-properties))
+		    (cdr (assoc property org-global-properties))
+		    (cdr (assoc property org-global-properties-fixed))))
+      (if literal-nil tmp (org-not-nil tmp)))))
 
 (defvar org-property-changed-functions nil
   "Hook called when the value of a property has changed.
@@ -14738,16 +14758,17 @@ If there is a specifyer 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."
-  (cond
-   ((and daynr (string-match "\\`%%\\((.*)\\)" s))
-    (if (org-diary-sexp-entry (match-string 1 s) "" date)
-	daynr
-      (+ daynr 1000)))
-   ((and daynr (string-match "\\+[0-9]+[dwmy]" s))
-    (org-closest-date s (if (and (boundp 'daynr) (integerp daynr)) daynr
-			  (time-to-days (current-time))) (match-string 0 s)
-			  prefer show-all))
-   (t (time-to-days (apply 'encode-time (org-parse-time-string s))))))
+  (let ((today (calendar-absolute-from-gregorian (calendar-current-date))))
+    (cond
+     ((and daynr (string-match "\\`%%\\((.*)\\)" s))
+      (if (org-diary-sexp-entry (match-string 1 s) "" date)
+	  daynr
+	(+ daynr 1000)))
+     ((and daynr (not (eq daynr today)) (string-match "\\+[0-9]+[dwmy]" s))
+	   (org-closest-date s (if (and (boundp 'daynr) (integerp daynr)) daynr
+				 (time-to-days (current-time))) (match-string 0 s)
+				 prefer show-all))
+      (t (time-to-days (apply 'encode-time (org-parse-time-string s)))))))
 
 (defun org-days-to-iso-week (days)
   "Return the iso week number."
@@ -15217,21 +15238,31 @@ changes from another.  I believe the procedure must be like this:
 ;;;; Agenda files
 
 ;;;###autoload
-(defun org-iswitchb (&optional arg)
-  "Use `org-icompleting-read' to prompt for an Org buffer to switch to.
+(defun org-switchb (&optional arg)
+  "Switch between Org buffers.
 With a prefix argument, restrict available to files.
-With two prefix arguments, restrict available buffers to agenda 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."
   (interactive "P")
   (let ((blist (cond ((equal arg '(4))  (org-buffer-list 'files))
                      ((equal arg '(16)) (org-buffer-list 'agenda))
-                     (t                 (org-buffer-list)))))
+                     (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))
     (switch-to-buffer
      (org-icompleting-read "Org buffer: "
-                              (mapcar 'list (mapcar 'buffer-name blist))
-                              nil t))))
+			   (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-ido-switchb 'org-iswitchb)
+(defalias 'org-iswitchb 'org-switchb)
 
 (defun org-buffer-list (&optional predicate exclude-tmp)
   "Return a list of Org buffers.
@@ -15718,7 +15749,8 @@ The images can be removed again with \\[org-ctrl-c-ctrl-c]."
     ("$$" "\\$\\$[^\000]*?\\$\\$" 0 nil))
   "Regular expressions for matching embedded LaTeX.")
 
-(defun org-format-latex (prefix &optional dir overlays msg at forbuffer)
+(defun org-format-latex (prefix &optional dir overlays msg at
+				forbuffer protect-only)
   "Replace LaTeX fragments with links to an image, and produce images.
 Some of the options can be changed using the variable
 `org-format-latex-options'."
@@ -15748,60 +15780,63 @@ Some of the options can be changed using the variable
 			 (not (eq (get-char-property (match-beginning n)
 						     'org-overlay-type)
 				  'org-latex-overlay))))
-	    (setq txt (match-string n)
-		  beg (match-beginning n) end (match-end n)
-		  cnt (1+ cnt))
-	    (let (print-length print-level) ; make sure full list is printed
-	      (setq hash (sha1 (prin1-to-string
-				(list org-format-latex-header
-				      org-format-latex-header-extra
-				      org-export-latex-default-packages-alist
-				      org-export-latex-packages-alist
-				      org-format-latex-options
-				      forbuffer txt)))
-		    linkfile (format "%s_%s.png" prefix hash)
-		    movefile (format "%s_%s.png" absprefix hash)))
-            (setq link (concat block "[[file:" linkfile "]]" block))
-	    (if msg (message msg cnt))
-	    (goto-char beg)
-	    (unless checkdir ; make sure the directory exists
-	      (setq checkdir t)
-	      (or (file-directory-p todir) (make-directory todir)))
-
-	    (unless executables-checked
-	      (org-check-external-command
-	       "latex" "needed to convert LaTeX fragments to images")
-	      (org-check-external-command
-	       "dvipng" "needed to convert LaTeX fragments to images")
-	      (setq executables-checked t))
-
-            (unless (file-exists-p movefile)
-              (org-create-formula-image
-               txt movefile opt forbuffer))
-	    (if overlays
-		(progn
-		  (mapc (lambda (o)
-			  (if (eq (overlay-get o 'org-overlay-type)
-				  'org-latex-overlay)
-			      (delete-overlay o)))
-			(overlays-in beg end))
-		  (setq ov (make-overlay beg end))
-		  (overlay-put ov 'org-overlay-type 'org-latex-overlay)
-		  (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 "\"" "" txt)))))))))))
+	    (if protect-only
+		(add-text-properties (match-beginning n) (match-end n)
+				     '(org-protected t))
+	      (setq txt (match-string n)
+		    beg (match-beginning n) end (match-end n)
+		    cnt (1+ cnt))
+	      (let (print-length print-level) ; make sure full list is printed
+		(setq hash (sha1 (prin1-to-string
+				  (list org-format-latex-header
+					org-format-latex-header-extra
+					org-export-latex-default-packages-alist
+					org-export-latex-packages-alist
+					org-format-latex-options
+					forbuffer txt)))
+		      linkfile (format "%s_%s.png" prefix hash)
+		      movefile (format "%s_%s.png" absprefix hash)))
+	      (setq link (concat block "[[file:" linkfile "]]" block))
+	      (if msg (message msg cnt))
+	      (goto-char beg)
+	      (unless checkdir ; make sure the directory exists
+		(setq checkdir t)
+		(or (file-directory-p todir) (make-directory todir)))
+	      
+	      (unless executables-checked
+		(org-check-external-command
+		 "latex" "needed to convert LaTeX fragments to images")
+		(org-check-external-command
+		 "dvipng" "needed to convert LaTeX fragments to images")
+		(setq executables-checked t))
+	      
+	      (unless (file-exists-p movefile)
+		(org-create-formula-image
+		 txt movefile opt forbuffer))
+	      (if overlays
+		  (progn
+		    (mapc (lambda (o)
+			    (if (eq (overlay-get o 'org-overlay-type)
+				    'org-latex-overlay)
+				(delete-overlay o)))
+			  (overlays-in beg end))
+		    (setq ov (make-overlay beg end))
+		    (overlay-put ov 'org-overlay-type 'org-latex-overlay)
+		    (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 "\"" "" txt))))))))))))
 
 ;; This function borrows from Ganesh Swami's latex2png.el
 (defun org-create-formula-image (string tofile options buffer)