Browse Source

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

Dan Davison 15 years ago
parent
commit
3cfe6d565b
77 changed files with 1108 additions and 458 deletions
  1. 4 0
      ChangeLog
  2. 2 0
      Makefile
  3. 157 81
      ORGWEBPAGE/Changes.org
  4. 4 8
      ORGWEBPAGE/index.org
  5. 1 1
      README_DIST
  6. 7 5
      contrib/babel/lisp/langs/org-babel-C.el
  7. 11 4
      contrib/babel/lisp/langs/org-babel-R.el
  8. 6 5
      contrib/babel/lisp/langs/org-babel-clojure.el
  9. 6 5
      contrib/babel/lisp/langs/org-babel-haskell.el
  10. 7 10
      contrib/babel/lisp/langs/org-babel-latex.el
  11. 26 6
      contrib/babel/lisp/langs/org-babel-octave.el
  12. 1 7
      contrib/babel/lisp/langs/org-babel-perl.el
  13. 6 5
      contrib/babel/lisp/langs/org-babel-python.el
  14. 7 5
      contrib/babel/lisp/langs/org-babel-ruby.el
  15. 6 5
      contrib/babel/lisp/langs/org-babel-sh.el
  16. 8 4
      contrib/babel/lisp/org-babel-ref.el
  17. 3 1
      contrib/babel/lisp/org-babel-tangle.el
  18. 31 27
      contrib/babel/lisp/org-babel.el
  19. 235 0
      contrib/lisp/org-mime.el
  20. 14 0
      doc/ChangeLog
  21. 58 36
      doc/org.texi
  22. 1 1
      doc/orgcard.tex
  23. 82 0
      lisp/ChangeLog
  24. 2 2
      lisp/org-agenda.el
  25. 2 2
      lisp/org-archive.el
  26. 3 3
      lisp/org-ascii.el
  27. 4 4
      lisp/org-attach.el
  28. 2 2
      lisp/org-bbdb.el
  29. 2 2
      lisp/org-beamer.el
  30. 2 2
      lisp/org-bibtex.el
  31. 2 2
      lisp/org-clock.el
  32. 2 2
      lisp/org-colview-xemacs.el
  33. 2 2
      lisp/org-colview.el
  34. 2 2
      lisp/org-compat.el
  35. 2 2
      lisp/org-crypt.el
  36. 21 1
      lisp/org-ctags.el
  37. 2 2
      lisp/org-datetree.el
  38. 29 14
      lisp/org-docbook.el
  39. 2 2
      lisp/org-docview.el
  40. 12 4
      lisp/org-entities.el
  41. 2 1
      lisp/org-exp-blocks.el
  42. 9 4
      lisp/org-exp.el
  43. 2 2
      lisp/org-faces.el
  44. 2 2
      lisp/org-feed.el
  45. 3 3
      lisp/org-footnote.el
  46. 2 2
      lisp/org-freemind.el
  47. 24 15
      lisp/org-gnus.el
  48. 2 2
      lisp/org-habit.el
  49. 2 2
      lisp/org-html.el
  50. 2 2
      lisp/org-icalendar.el
  51. 2 2
      lisp/org-id.el
  52. 2 2
      lisp/org-indent.el
  53. 2 2
      lisp/org-info.el
  54. 2 2
      lisp/org-inlinetask.el
  55. 2 2
      lisp/org-irc.el
  56. 2 2
      lisp/org-jsinfo.el
  57. 86 47
      lisp/org-latex.el
  58. 2 2
      lisp/org-list.el
  59. 2 2
      lisp/org-mac-message.el
  60. 2 2
      lisp/org-macs.el
  61. 2 2
      lisp/org-mew.el
  62. 2 2
      lisp/org-mhe.el
  63. 5 2
      lisp/org-mobile.el
  64. 2 2
      lisp/org-mouse.el
  65. 2 2
      lisp/org-plot.el
  66. 2 2
      lisp/org-protocol.el
  67. 5 3
      lisp/org-publish.el
  68. 2 2
      lisp/org-remember.el
  69. 2 2
      lisp/org-rmail.el
  70. 2 2
      lisp/org-src.el
  71. 2 2
      lisp/org-table.el
  72. 2 2
      lisp/org-timer.el
  73. 2 2
      lisp/org-vm.el
  74. 2 2
      lisp/org-w3m.el
  75. 2 2
      lisp/org-wl.el
  76. 2 2
      lisp/org-xoxo.el
  77. 140 59
      lisp/org.el

+ 4 - 0
ChangeLog

@@ -1,3 +1,7 @@
+2010-04-05  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* ORGWEBPAGE/Changes.org: More details on LaTeX headers.
+
 2010-03-05  Carsten Dominik  <carsten.dominik@gmail.com>
 
 	* Makefile: Process reference card using pdflayout.sty.  Change

+ 2 - 0
Makefile

@@ -73,6 +73,7 @@ LISPF      = 	org.el			\
 	     	org-ctags.el		\
 	     	org-datetree.el		\
 	     	org-docview.el		\
+	     	org-entities.el		\
 		org-exp.el		\
 		org-exp-blocks.el	\
 		org-docbook.el		\
@@ -333,6 +334,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-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

+ 157 - 81
ORGWEBPAGE/Changes.org

@@ -6,7 +6,7 @@
 
 #+STARTUP: indent hidestars
 
-* Version 6.35 (in preparation)
+* Version 6.35
  :PROPERTIES:
  :VISIBILITY: content
  :CUSTOM_ID: v6.35
@@ -16,32 +16,49 @@
 
 *** Changes to the intended use of =org-export-latex-classes=
 
-So far this variable has been used to specify the
-=\documentclass= macro as well as all the =\usepackage= calls
+So far this variable has been used to specify the complete header
+of the LaTeX document, including all the =\usepackage= calls
 necessary for the document.  This setup makes it difficult to
 maintain the list of packages that Org itself would like to call,
-for example for the special symbol support it needs.
+for example for the special symbol support it needs.  Each time I
+have to add a package, I have to ask people to revise the
+configuration of this variable.  In this release, I have tried to
+fix this.
+
+First of all, you can *opt out of this change* in the following
+way: You can say: /I want to have full control over headers, and
+I will take responsibility to include the packages Org needs/.
+If that is what you want, add this to your configuration and skip
+the rest of this section (except maybe for the description of the
+=[EXTRA]= place holder):
+
+#+begin_src emacs-lisp
+  (setq org-export-latex-default-packages-alist nil
+        org-export-latex-packages-alist nil)
+#+end_src
+
+/Continue to read here if you want to go along with the modified
+setup./
 
 There are now two variables that should be used to list the LaTeX
 packages that need to be included in all classes.  The header
-definition in =org-export-latex-classes= should then only contain
-the =\documentclass= macro, and packages for this specific class
-definition.
+definition in =org-export-latex-classes= should then not contain
+the corresponding =\usepackage= calls (see below).
 
-The two variables are:
+The two new variables are:
 
 1. =org-export-latex-default-packages-alist= :: This is the
      variable where Org-mode itself puts the packages it needs.
-     If possible, you should not change this variable - in fact,
-     I have considered to make this a constant and to not allow
-     it customized.  However, there is one exception when it
-     might be necessary to change it: if one of the packages
+     Normally you should not change this variable.  The only
+     reason to change it anyway is when one of these packages
      causes a conflict with another package you want to use.
+     Then you can remove that packages and hope that you are not
+     using Org-mode functionality that needs it.
 
 2. =org-export-latex-packages-alist= :: This is the variable
-     where you should put the packages that you'd like to use
-     across all classes.  For example, I am putting =amsmath= and
-     =tikz= here, because I always want to have them.
+     where you can put the packages that you'd like to use across
+     all classes.  For example, I am putting =amsmath= and =tikz=
+     here, because I always want to have them.
 
 The sequence how these customizations will show up in the LaTeX
 document are:
@@ -50,12 +67,57 @@ document are:
 3. =org-export-latex-packages-alist=
 4. Buffer-specific things set with =#+LaTeX_HEADER:=
 
-If you have currently customized =org-export-latex-classes=, you
-should revise that customization and remove any package call that
-are covered by =org-export-latex-default-packages-alist=, and you
-should consider to move packages that you use in all classes to
-=org-export-latex-packages-alist=.
+If you want more control about which segment is placed where, or
+if you want, for a specific class, have full control over the
+header and exclude some of the automatic building blocks, you can
+put the following macro-like place holders into the header:
 
+#+begin_example
+[DEFAULT-PACKAGES]      \usepackage statements for default packages
+[NO-DEFAULT-PACKAGES]   do not include any of the default packages
+[PACKAGES]              \usepackage statements for packages 
+[NO-PACKAGES]           do not include the packages
+[EXTRA]                 the stuff from #+LaTeX_HEADER
+[NO-EXTRA]              do not include #+LaTeX_HEADER stuff
+#+end_example
+
+If you have currently customized =org-export-latex-classes=, you
+should revise that customization and remove any package calls that
+are covered by =org-export-latex-default-packages-alist=.  This
+applies to the following packages:
+
+- inputenc
+- fontenc
+- fixltx2e
+- graphicx
+- longtable
+- float
+- wrapfig
+- soul
+- t1enc
+- textcomp
+- marvosym
+- wasysym
+- latexsym
+- amssymb
+- hyperref
+- microtype
+
+If one of these packages creates a conflict with another package
+you are using, you can remove it from
+=org-export-latex-default-packages-alist=.  But then you risk
+that some of the advertised export features of Org will not work
+properly.
+
+You can also consider moving packages that you use in all classes
+to =org-export-latex-packages-alist=.  If necessary, put the
+place holders so that the packages get loaded in the right
+sequence.  As said above, for backward compatibility, if you omit
+the place holders, all the variables will dump their content at
+the end of the header.
+
+Damn, this has become more complex than I wanted it to be.  I
+hope that in practice, this will not be complicated at all.
 
 *** The constant =org-html-entities= is obsolete
 
@@ -77,12 +139,12 @@ org-document-title
 org-document-info
 org-document-info-keyword
     
-In addition, the variable org-hidden-keywords can be used to make the
-corresponding keywords disappear.
+In addition, the variable =org-hidden-keywords= can be used to
+make the corresponding keywords disappear.
 
-Patch by Dan Davison
+Thanks to Dan Davison for this feature.
 
-*** Implement a simpler way to specify faces for tags and todo keywords
+*** Simpler way to specify faces for tags and todo keywords
     
 The variables =org-todo-keyword-faces=, =org-tag-faces=, and
 =org-priority-faces= now accept simple color names as
@@ -96,16 +158,16 @@ The change is based on an idea and patch by Ryan Thompson.
 
 *** <N> in tables now means fixed width, not maximum width
     
-Requested by Michael Brand
+Requested by Michael Brand.
 
-*** Improve level cycling function
+*** Better level cycling function
 
 =TAB= in an empty headline cycles the level of that headline
 through likely states.  Ryan Thompson implemented an improved
 version of this function, which does not depend upon when exactly
 this command is used.  Thanks to Ryan for this improvement.
 
-*** Improve adaptive filling
+*** Adaptive filling
     
 For paragraph text, =org-adaptive-fill-function= did not handle the
 base case of regular text which needed to be filled.  This is now
@@ -114,13 +176,13 @@ to be filled correctly.
 
 Thanks to Dan Hackney for this patch.    
 
-*** Make `org-reveal' (=C-c C-r=) also decrypt encrypted entries
+*** `org-reveal' (=C-c C-r=) also decrypts encrypted entries (org-crypt.el)
     
 Thanks to Richard Riley for triggering this change.
 
-*** Improve automatic letter selection for TODO keywords
+*** Better automatic letter selection for TODO keywords
     
-When all first letters of keywords have been used, Org no assigns
+When all first letters of keywords have been used, Org now assigns
 more meaningful characters based on the keywords.
 
 Thanks to Mikael Fornius for this patch.
@@ -140,23 +202,23 @@ possible.
 The coding system of the LaTeX class will now be set to the value
 corresponding to the buffer's file coding system.  This happens
 if your setup sets up the file to have a line
-=\usepackage[AUTO]{inputenc}=.
+=\usepackage[AUTO]{inputenc}= (the default setup does this).
 
 *** New exporters to Latin-1 and UTF-8
 
-While Ulf was going through the entities list to improve the
-LaTeX export, he had the great idea to provide representations for
-many of the entities in Latin-1, and for all of them in UTF-8.
-This means that we can now export files rich in special symbols
-to Latin-1 and to UTF-8 files.  These new exporters can be
-reached with the commands =C-c C-e n= and =C-c C-e u=,
-respectively.
+While Ulf Stegemann was going through the entities list to
+improve the LaTeX export, he had the great idea to provide
+representations for many of the entities in Latin-1, and for all
+of them in UTF-8.  This means that we can now export files rich
+in special symbols to Latin-1 and to UTF-8 files.  These new
+exporters can be reached with the commands =C-c C-e n= and =C-c
+C-e u=, respectively.
 
 When there is no representation for a given symbol in the
 targeted coding system, you can choose to keep the TeX-macro-like
 representation, or to get an "explanatory" representation.  For
 example, =\simeq= could be represented as "[approx. equal to]".
-Please use the variable `org-entities-ascii-explanatory' to state
+Please use the variable =org-entities-ascii-explanatory= to state
 your preference.
 
 *** Full label/reference support in HTML, Docbook, and LaTeX backends
@@ -231,12 +293,13 @@ C-u M-x org-publish-all
 
 Whenever an Org file is published in this project, a new file
 with the extension "orgx" will be written.  It contains the index
-entries.  When all project files are published, Org will produce
-a new file "theindex.inc" containing the index as a to-level
-tree.  This file can be included into any project file using
+entries and corresponding jump target names.  When all project
+files are published, Org will produce a new file "theindex.inc"
+containing the index as a to-level tree.  This file can be
+included into any project file using
 
 #+begin_src org
-#+include: "theindex.inc"
+  ,#+include: "theindex.inc"
 #+end_src
 
 Org-mode will also create a file "theindex.org" with this include
@@ -247,7 +310,7 @@ overwritten by Org.
 
 Thanks to Stefan Vollmar for initiating and driving this feature.
 
-FIXME: Still need to do the LaTeX portion
+*** TODO Still need to do the LaTeX portion
 
 ** MobileOrg
 
@@ -278,8 +341,8 @@ considered for this command by binding =org-agenda-entry-types=
 temporarily in the options section of the command.  This can lead
 to significant speedups, because instead of laboriously finding
 entries and then rejecting them, a whole search cycle is skipped.
-For more information see the new section in [[http://orgmode.org/worg/org-tutorials/org-custom-agenda-commands.php#sec-5][Matt Lundin's agenda
-custom command tutorial]].
+For more information see the new section in
+[[http://orgmode.org/worg/org-tutorials/org-custom-agenda-commands.php#sec-5][Matt Lundin's agenda custom command tutorial]].
 
 Thanks to Matt Lundin for this feature.
 
@@ -329,6 +392,12 @@ the time is moved into the time stamp.
 
 Thanks to Stephen Eglen for this feature.
 
+*** The customization group org-font-lock has been renamed
+
+The new name is `org-appearance'.
+
+Thanks to Dan Davison for a patch to this effect.
+
 *** The TODO list: Allow skipping scheduled or deadlined entries
 
 Skipping TODO entries in the global TODO list based on whether
@@ -365,7 +434,7 @@ Extension: \.pdf::\([0-9]+\)\'
 Command:   evince "%s" -p %1
 #+end_example
 
-Thanks to Jan Böker for a patch to this effect.
+Thanks to Jan Böcker for a patch to this effect.
 
 ** Clocking
 
@@ -399,7 +468,7 @@ tables to be broken.
 
 ** Misc
 
-*** Add logging support for refiling
+*** New logging support for refiling
 
 Whenever you refile an item, a time stamp and even a note can be
 added to this entry.  For details, see the new option
@@ -419,7 +488,7 @@ org-table-current-line
 org-table-goto-line
 #+end_example
 
-*** Tables: Introduce field coordinates for formulas, improve docs
+*** Tables: Field coordinates for formulas, and improved docs
     
 Calc and Emacs-Lisp formulas for tables can access the current
 field coordinates with =@#= and =$#= for row and column,
@@ -427,6 +496,9 @@ respectively.  These can be useful in some formulas.  For
 example, to sequentially number the fields in a column, use
 ~=@#~ as column equation.
 
+One application is to copy a column from a different table.  See
+the manual for details.
+
 Thanks to Michael Brand for this feature.
 
 *** Archiving: Allow to reverse order in target node
@@ -460,11 +532,11 @@ So when you are prompted for a date, you can now answer like this
 2/5           --> <CURRENT-YEAR>-02-05
 #+end_example    
 
-*** Update org-timer.el so that we only allow one timer.
+*** org-timer.el now allows just one timer
 
 There is now only a single free timer supported by org-timer.el.
 Thanks to Bastien for cleaning this up, after a bug report in
-this area by Frederic Couchet.
+this area by Frédéric Couchet.
 
 *** Remember: Allow to file as sibling of current clock
     
@@ -473,38 +545,40 @@ last filed entry.
 
 Patch by Lukasz Stelmach.
 
-*** Org-reveal: Double prefix arg show the entire subtree of the parent
+*** Org-reveal: Double prefix arg shows the entire subtree of the parent
     
 This can help to get out of an inconsistent state produced for
 example by viewing from the agenda.
 
-This was a request my Matt Lundin.
+This was a request by Matt Lundin.
 
 *** Add org-secretary.el by Juan Reyero to the contrib directory
 
-Org-secretary is a possible setup for group work using Org-mode.
+org-secretary.el is a possible setup for group work using
+Org-mode.
 
 Thanks to Juan Reyero for this contribution.
 
 ** Babel
-Eric has compiled the following list of changes in and around
-org-babel.
-
-- added support for Matlab and Octave
-- added support for C and C++ code blocks
-- added support for the Oz programming language
-- can now force literal interpretation of table cell contents
-  with extra "$" in table formula
-- variable references which look like lisp forms are now
-  evaluated
-- inline source blocks will always return string output
-- no longer adding extension during tangling when filename is
-  provided
-- code block parameters are now available when initializing a
-  session
-- added `org-babel-execute-hook' which runs after code block
-  execution
-- working directories and remote execution
+
+Eric and Dan have compiled the following list of changes in and
+around org-babel.
+
+- Added support for Matlab and Octave.
+- Added support for C and C++ code blocks.
+- Added support for the Oz programming language.
+  Thanks to Torsten Anders for this contribution
+- Can now force literal interpretation of table cell contents
+  with extra "$" in table formula.
+  Thanks to Maurizio Vitale for this suggestion.
+- Variable references which look like lisp forms are now
+  evaluated.
+- No longer adding extension during tangling when filename is
+  provided.
+  Thanks to Martin G. Skjæveland and Nicolas Girard for prompting this.
+- Added `org-babel-execute-hook' which runs after code block
+  execution.
+- Working directories and remote execution
 
   This introduces a new header argument :dir. For the duration of
   source block execution, default-directory is set to the value
@@ -520,14 +594,16 @@ org-babel.
   interpreter executable will be sought in tramp-remote-path, and
   if found will execute on the remote machine in the specified
   remote directory.
-- Remove org-R from contrib
+- Tramp syntax can be used to tangle to remote files.
+  Thanks to Maurizio Vitale and Rémi Vanicat.
+- org-R removed from contrib.
 - gnuplot can now return it's string output -- when session is
-  set to "none"
-- prevent quoting of strings in shell variables
-- now including source code block arguments w/source name on
-  export
-- now able to reference file links as results
-- allow pdf/png generation directly from latex source blocks
+  set to "none".
+- Now including source code block arguments w/source name on
+  export.
+- Now able to reference file links as results.
+- Allow pdf/png generation directly from latex source blocks
+  with :file header argument.
 
 
 * Version 6.34
@@ -573,7 +649,7 @@ call function to do something special with text links.
 
 Thanks to Paul Sexton for this contribution.
 
-**** Add Jan Böker's org-docview.el
+**** Add Jan Böcker's org-docview.el
 
 This new module allows links to various file types using docview,
 where Emacs displays images of document pages.  Docview link
@@ -582,7 +658,7 @@ page 131 of the Org-mode manual:
 
 : [[docview:~/.elisp/org/doc/org.pdf::131][Org-Mode Manual]]
 
-Thanks to Jan Böker for this contribution.
+Thanks to Jan Böcker for this contribution.
     
 **** New link types that force special ways of opening the file
     

+ 4 - 8
ORGWEBPAGE/index.org

@@ -117,18 +117,14 @@ a look at our [[http://orgmode.org/worg/org-quotes.php][collected quotes about O
 #+ATTR_HTML: style="float:right;"
   [[http://mobileorg.ncogni.to/][http://mobileorg.ncogni.to/images/screenshot-browse.png]]
 
+- <2010-04-06 Tue>: Release 6.35
 - <2010-01-10 Sun>: Release 6.34
 - <2009-12-15 Tue>: iPhone App [[http://mobileorg.ncogni.to/][MobileOrg]] version 1.1 available
 - <2009-11-13 Fri>: Release 6.33
-- <2009-11-03 Tue>: iPhone App [[http://mobileorg.ncogni.to/][MobileOrg]] available in the AppStore
-- <2009-10-26 Mon>: Release 6.32
-- <2009-09-30 Wed>: Release 6.31
-- <2009-09-01 Tue>: Release 6.30
-- <2009-08-04 Tue>: Release 6.29
 
-* Current Version (6.34c)
+* Current Version (6.35g)
 
-The current version is 6.34c.  To see what has changed in recent
+The current version is 6.35g.  To see what has changed in recent
 releases, check this detailed list of [[file:Changes.html][user-visible changes]].
 
 This package works on Emacs 23 and 22, and (with minor restrictions)
@@ -140,7 +136,7 @@ recent version, but may lag a bit behind the website release.
 
 ** The standard distribution
 
-Download as [[file:org-6.34c.zip][zip file]] or [[file:org-6.34c.tar.gz][gzipped tar archive]].  These archives contain
+Download as [[file:org-6.35g.zip][zip file]] or [[file:org-6.35g.tar.gz][gzipped tar archive]].  These archives contain
 both the Lisp file org.el and the documentation in PDF and (TeX)Info
 formats.  Follow the instructions for [[http://orgmode.org/manual/Installation.html#Installation][Installation]] and [[http://orgmode.org/manual/Activation.html#Activation][Activation]].
 

+ 1 - 1
README_DIST

@@ -1,7 +1,7 @@
 The is a distribution of Org, a plain text notes and project planning
 tool for Emacs.
 
-The version of this release is: 6.34trans
+The version of this release is: 6.35g
 
 The homepage of Org is at http://orgmode.org
 

+ 7 - 5
contrib/babel/lisp/langs/org-babel-C.el

@@ -77,11 +77,11 @@ called by `org-babel-execute-src-block'."
          (cmdline (cdr (assoc :cmdline params)))
          (flags (cdr (assoc :flags params)))
          (vars (second processed-params))
-         (includes (org-babel-read
-                    (or (cdr (assoc :includes params))
-                        (org-entry-get nil "includes" t))))
+         (main-p (not (string= (cdr (assoc :main params)) "no")))
+         (includes (or (cdr (assoc :includes params))
+                       (org-entry-get nil "includes" t)))
          (defines (org-babel-read
-                   (or (cdr (assoc :includes params))
+                   (or (cdr (assoc :defines params))
                        (org-entry-get nil "defines" t))))
          (full-body (mapconcat 'identity
                      (list
@@ -96,7 +96,9 @@ called by `org-babel-execute-src-block'."
                       ;; variables
                       (mapconcat 'org-babel-C-var-to-C vars "\n")
                       ;; body
-                      "\n" (org-babel-C-ensure-main-wrap body) "\n") "\n"))
+                      "\n" (if main-p
+                               (org-babel-C-ensure-main-wrap body)
+                             body) "\n") "\n"))
          (error-buf (get-buffer-create "*Org-Babel Error Output*"))
          (compile
           (progn

+ 11 - 4
contrib/babel/lisp/langs/org-babel-R.el

@@ -59,8 +59,14 @@ called by `org-babel-execute-src-block'."
 (defun org-babel-prep-session:R (session params)
   "Prepare SESSION according to the header arguments specified in PARAMS."
   (let* ((session (org-babel-R-initiate-session session params))
-         (vars (org-babel-ref-variables params)))
-    (mapc (lambda (pair) (org-babel-R-assign-elisp session (car pair) (cdr pair))) vars)
+	 (vars (org-babel-ref-variables params))
+	 (var-lines
+	  (mapcar
+	   (lambda (pair) (org-babel-R-assign-elisp (car pair) (cdr pair))) vars)))
+    (org-babel-comint-in-buffer session
+      (mapc (lambda (var)
+              (move-end-of-line 1) (insert var) (comint-send-input nil t)
+              (org-babel-comint-wait-for-output session)) var-lines))
     session))
 
 (defun org-babel-load-session:R (session body params)
@@ -81,7 +87,7 @@ called by `org-babel-execute-src-block'."
     (format "%S" s)))
 
 (defun org-babel-R-assign-elisp (name value)
-  "Read the elisp VALUE into a variable named NAME."
+  "Construct R code assigning the elisp VALUE to a variable named NAME."
   (if (listp value)
       (let ((transition-file (make-temp-file "org-babel-R-import")))
         ;; ensure VALUE has an orgtbl structure (depth of at least 2)
@@ -113,6 +119,7 @@ called by `org-babel-execute-src-block'."
 	   (:jpeg . "jpeg")
 	   (:tiff . "tiff")
 	   (:png . "png")
+	   (:svg . "svg")
 	   (:pdf . "pdf")
 	   (:ps . "postscript")
 	   (:postscript . "postscript")))
@@ -123,7 +130,7 @@ called by `org-babel-execute-src-block'."
 	(device (and (string-match ".+\\.\\([^.]+\\)" out-file) (match-string 1 out-file)))
 	(extra-args (cdr (assq :R-dev-args params))) filearg args)
     (setq device (or (and device (cdr (assq (intern (concat ":" device)) devices))) "png"))
-    (setq filearg (if (member device '("pdf" "postscript")) "file" "filename"))
+    (setq filearg (if (member device '("pdf" "postscript" "svg")) "file" "filename"))
     (setq args (mapconcat (lambda (pair)
 			    (if (member (car pair) allowed-args)
 				(format ",%s=%s" (substring (symbol-name (car pair)) 1) (cdr pair)) ""))

+ 6 - 5
contrib/babel/lisp/langs/org-babel-clojure.el

@@ -107,11 +107,12 @@ Emacs-lisp table, otherwise return the results as a string."
   (org-babel-read
    (if (string-match "^\\[.+\\]$" results)
        (org-babel-read
-        (replace-regexp-in-string
-         "\\[" "(" (replace-regexp-in-string
-                    "\\]" ")" (replace-regexp-in-string
-                               ", " " " (replace-regexp-in-string
-                                         "'" "\"" results)))))
+        (concat "'"
+                (replace-regexp-in-string
+                 "\\[" "(" (replace-regexp-in-string
+                            "\\]" ")" (replace-regexp-in-string
+                                       ", " " " (replace-regexp-in-string
+                                                 "'" "\"" results))))))
      results)))
 
 (defun org-babel-clojure-var-to-clojure (var)

+ 6 - 5
contrib/babel/lisp/langs/org-babel-haskell.el

@@ -125,11 +125,12 @@ Emacs-lisp table, otherwise return the results as a string."
   (org-babel-read
    (if (and (stringp results) (string-match "^\\[.+\\]$" results))
        (org-babel-read
-        (replace-regexp-in-string
-         "\\[" "(" (replace-regexp-in-string
-                    "\\]" ")" (replace-regexp-in-string
-                               "," " " (replace-regexp-in-string
-                                         "'" "\"" results)))))
+        (concat "'"
+                (replace-regexp-in-string
+                 "\\[" "(" (replace-regexp-in-string
+                            "\\]" ")" (replace-regexp-in-string
+                                       "," " " (replace-regexp-in-string
+                                                "'" "\"" results))))))
      results)))
 
 (defun org-babel-haskell-export-to-lhs (&optional arg)

+ 7 - 10
contrib/babel/lisp/langs/org-babel-latex.el

@@ -81,16 +81,13 @@ called by `org-babel-execute-src-block'."
 (defun org-babel-latex-body-to-tex-file (tex-file body &optional height width)
   "Extracted from `org-create-formula-image' in org.el."
   (with-temp-file tex-file
-    (insert org-format-latex-header
-            (if org-export-latex-packages-alist
-                (concat "\n"
-                        (mapconcat (lambda(p)
-                                     (if (equal "" (car p))
-                                         (format "\\usepackage{%s}" (cadr p))
-                                       (format "\\usepackage[%s]{%s}"
-                                               (car p) (cadr p))))
-                                   org-export-latex-packages-alist "\n"))
-              "")
+    (insert (org-splice-latex-header
+	       org-format-latex-header
+	       (remove-if
+                (lambda (el) (and (listp el) (string= "hyperref" (cadr el))))
+                org-export-latex-default-packages-alist)
+	       org-export-latex-packages-alist
+	       org-format-latex-header-extra)
             (if height (concat "\n" (format "\\pdfpageheight %s" height)) "")
             (if width (concat "\n" (format "\\pdfpagewidth %s" width)) "")
             (if org-format-latex-header-extra

+ 26 - 6
contrib/babel/lisp/langs/org-babel-octave.el

@@ -100,9 +100,16 @@ then create. Return the initialized session."
 	  (rename-buffer (if (bufferp session) (buffer-name session)
 			   (if (stringp session) session (buffer-name)))) (current-buffer))))))
 
- (defvar org-babel-octave-wrapper-method
+(defvar org-babel-octave-wrapper-method
    "%s
-save -ascii %s ans")
+if ischar(ans)
+   fid = fopen('%s', 'w')
+   fprintf(fid, ans)
+   fprintf(fid, '\\n')
+   fclose(fid)
+else
+   save -ascii %s ans
+end")
 
 (defvar org-babel-octave-eoe-indicator "\'org_babel_eoe\'")
 
@@ -130,12 +137,12 @@ value of the last statement in BODY, as elisp."
 	 (let* ((tmp-file (make-temp-file "org-babel-results-")) exit-code
 		(stderr
 		 (with-temp-buffer
-		   (insert (format org-babel-octave-wrapper-method body tmp-file))
+		   (insert (format org-babel-octave-wrapper-method body tmp-file tmp-file))
 		   (setq exit-code (org-babel-shell-command-on-region
 				    (point-min) (point-max) cmd nil 'replace (current-buffer)))
 		   (buffer-string))))
 	   (if (> exit-code 0) (org-babel-error-notify exit-code stderr))
-	   (org-babel-import-elisp-from-file (org-babel-maybe-remote-file tmp-file))))))))
+	   (org-babel-octave-import-elisp-from-file (org-babel-maybe-remote-file tmp-file))))))))
 
 (defun org-babel-octave-evaluate-session (session body result-type &optional matlabp)
   (let* ((tmp-file (make-temp-file "org-babel-results-"))
@@ -148,13 +155,13 @@ value of the last statement in BODY, as elisp."
 	    (value
 	     (mapconcat
 	      #'org-babel-chomp
-	      (list (format org-babel-octave-wrapper-method body tmp-file) org-babel-octave-eoe-indicator) "\n"))))
+	      (list (format org-babel-octave-wrapper-method body tmp-file tmp-file) org-babel-octave-eoe-indicator) "\n"))))
 	 (raw (org-babel-comint-with-output session
 		  (if matlabp org-babel-octave-eoe-indicator org-babel-octave-eoe-output) t
 		(insert full-body) (comint-send-input nil t))) results)
     (case result-type
       (value
-       (org-babel-import-elisp-from-file (org-babel-maybe-remote-file tmp-file)))
+       (org-babel-octave-import-elisp-from-file (org-babel-maybe-remote-file tmp-file)))
       (output
        (progn
 	 (setq results
@@ -166,6 +173,19 @@ value of the last statement in BODY, as elisp."
 					       (mapcar #'org-babel-trim raw)))))))
 	 (mapconcat #'identity (reverse results) "\n"))))))
 
+(defun org-babel-octave-import-elisp-from-file (file-name)
+  "Import data written to file by octave.
+This removes initial blank and comment lines and then calls
+`org-babel-import-elisp-from-file'."
+  (let ((temp-file (make-temp-file "org-babel-results-")) beg end)
+    (with-temp-file temp-file
+      (insert-file-contents file-name)
+      (re-search-forward "^[ \t]*[^# \t]" nil t)
+      (if (< (setq beg (point-min))
+	     (setq end (point-at-bol)))
+	  (delete-region beg end)))
+    (org-babel-import-elisp-from-file temp-file)))
+
 (defun org-babel-octave-read-string (string)
   "Strip \\\"s from around octave string"
   (if (string-match "^\"\\([^\000]+\\)\"$" string)

+ 1 - 7
contrib/babel/lisp/langs/org-babel-perl.el

@@ -108,13 +108,7 @@ last statement in BODY, as elisp."
 		     (format
 		      (if (member "pp" result-params)
 			  (error "Pretty-printing not implemented for perl")
-			org-babel-perl-wrapper-method)
-		      (mapconcat
-		       (lambda (line) (format "\t%s" line))
-		       (split-string
-			(org-remove-indentation (org-babel-trim body)) "[\r\n]") "\n")
-		      tmp-file))
-		    ;; (message "buffer=%s" (buffer-string)) ;; debugging
+			org-babel-perl-wrapper-method) body tmp-file))
 		    (setq exit-code
 			  (org-babel-shell-command-on-region
 			   (point-min) (point-max) "perl" nil 'replace (current-buffer)))

+ 6 - 5
contrib/babel/lisp/langs/org-babel-python.el

@@ -97,11 +97,12 @@ Emacs-lisp table, otherwise return the results as a string."
    (if (or (string-match "^\\[.+\\]$" results)
 	   (string-match "^(.+)$" results))
        (org-babel-read
-        (replace-regexp-in-string
-         "\\[" "(" (replace-regexp-in-string
-                    "\\]" ")" (replace-regexp-in-string
-                               ", " " " (replace-regexp-in-string
-                                         "'" "\"" results)))))
+        (concat "'"
+                (replace-regexp-in-string
+                 "\\[" "(" (replace-regexp-in-string
+                            "\\]" ")" (replace-regexp-in-string
+                                       ", " " " (replace-regexp-in-string
+                                                 "'" "\"" results))))))
      results)))
 
 (defvar org-babel-python-buffers '(:default . nil))

+ 7 - 5
contrib/babel/lisp/langs/org-babel-ruby.el

@@ -105,14 +105,16 @@ specifying a var of the same value."
 (defun org-babel-ruby-table-or-string (results)
   "If the results look like a table, then convert them into an
 Emacs-lisp table, otherwise return the results as a string."
+  (message "converting %S" results)
   (org-babel-read
    (if (and (stringp results) (string-match "^\\[.+\\]$" results))
        (org-babel-read
-        (replace-regexp-in-string
-         "\\[" "(" (replace-regexp-in-string
-                    "\\]" ")" (replace-regexp-in-string
-                               ", " " " (replace-regexp-in-string
-                                         "'" "\"" results)))))
+        (concat "'"
+                (replace-regexp-in-string
+                 "\\[" "(" (replace-regexp-in-string
+                            "\\]" ")" (replace-regexp-in-string
+                                       ", " " " (replace-regexp-in-string
+                                                 "'" "\"" results))))))
      results)))
 
 (defun org-babel-ruby-initiate-session (&optional session params)

+ 6 - 5
contrib/babel/lisp/langs/org-babel-sh.el

@@ -104,11 +104,12 @@ Emacs-lisp table, otherwise return the results as a string."
   (org-babel-read
    (if (string-match "^\\[.+\\]$" results)
        (org-babel-read
-        (replace-regexp-in-string
-         "\\[" "(" (replace-regexp-in-string
-                    "\\]" ")" (replace-regexp-in-string
-                               ", " " " (replace-regexp-in-string
-                                         "'" "\"" results)))))
+        (concat "'"
+                (replace-regexp-in-string
+                 "\\[" "(" (replace-regexp-in-string
+                            "\\]" ")" (replace-regexp-in-string
+                                       ", " " " (replace-regexp-in-string
+                                                 "'" "\"" results))))))
      results)))
 
 (defun org-babel-sh-initiate-session (&optional session params)

+ 8 - 4
contrib/babel/lisp/org-babel-ref.el

@@ -172,11 +172,15 @@ which case the entire range is returned."
         (flet ((wrap (num) (if (< num 0) (+ length num) num)))
           (mapcar
            (lambda (sub-lis) (org-babel-ref-index-list remainder sub-lis))
-           (if (string-match "\\([-[:digit:]]+\\):\\([-[:digit:]]+\\)" portion)
+           (if (string-match "\\(\\([-[:digit:]]+\\):\\([-[:digit:]]+\\)\\|\*\\)"
+                             portion)
                (mapcar (lambda (n) (nth n lis))
-                       (number-sequence
-                        (wrap (string-to-number (match-string 1 portion)))
-                        (wrap (string-to-number (match-string 2 portion)))))
+                       (apply 'number-sequence
+                              (if (match-string 2 portion)
+                                  (list
+                                   (wrap (string-to-number (match-string 2 portion)))
+                                   (wrap (string-to-number (match-string 3 portion))))
+                                (list (wrap 0) (wrap -1)))))
              (list (nth (wrap (string-to-number portion)) lis))))))
     lis))
 

+ 3 - 1
contrib/babel/lisp/org-babel-tangle.el

@@ -172,8 +172,10 @@ code blocks by language."
              (source-name (intern (or (fifth info)
                                       (format "block-%d" block-counter))))
              (src-lang (first info))
-             (body (org-babel-expand-noweb-references info))
              (params (third info))
+	     (body (if (equal "no" (cdr (assoc :noweb params)))
+		       (second info)
+		     (org-babel-expand-noweb-references info)))
              (spec (list link source-name params body (third (cdr (assoc src-lang org-babel-tangle-langs)))))
              by-lang)
         (unless (string= (cdr (assoc :tangle params)) "no") ;; maybe skip

+ 31 - 27
contrib/babel/lisp/org-babel.el

@@ -226,27 +226,28 @@ block."
 	  (if (boundp 'call-process-region-original) call-process-region-original
 	    (symbol-function 'call-process-region)))
          result)
-    ;; (message "params=%S" params) ;; debugging
-    (flet ((call-process-region (&rest args)
-				(apply 'org-babel-tramp-handle-call-process-region args)))
-      (unless (member lang org-babel-interpreters)
-	(error "Language is not in `org-babel-interpreters': %s" lang))
-      (if (and (not arg) new-hash (equal new-hash old-hash))
-	  (save-excursion ;; return cached result
-	    (goto-char (org-babel-where-is-src-block-result nil info))
-	    (move-end-of-line 1) (forward-char 1)
-	    (setq result (org-babel-read-result))
-	    (message (replace-regexp-in-string "%" "%%" (format "%S" result))) result)
-	(setq result (funcall cmd body params))
-	(if (eq result-type 'value)
-	    (setq result (if (and (or (member "vector" result-params)
-				      (member "table" result-params))
-				  (not (listp result)))
-			     (list (list result))
-			   result)))
-	(org-babel-insert-result result result-params info new-hash)
-	(run-hooks 'org-babel-after-execute-hook)
-	result))))
+    (unwind-protect
+        (flet ((call-process-region (&rest args)
+                                    (apply 'org-babel-tramp-handle-call-process-region args)))
+          (unless (member lang org-babel-interpreters)
+            (error "Language is not in `org-babel-interpreters': %s" lang))
+          (if (and (not arg) new-hash (equal new-hash old-hash))
+              (save-excursion ;; return cached result
+                (goto-char (org-babel-where-is-src-block-result nil info))
+                (move-end-of-line 1) (forward-char 1)
+                (setq result (org-babel-read-result))
+                (message (replace-regexp-in-string "%" "%%" (format "%S" result))) result)
+            (setq result (funcall cmd body params))
+            (if (eq result-type 'value)
+                (setq result (if (and (or (member "vector" result-params)
+                                          (member "table" result-params))
+                                      (not (listp result)))
+                                 (list (list result))
+                               result)))
+            (org-babel-insert-result result result-params info new-hash)
+            (run-hooks 'org-babel-after-execute-hook)
+            result))
+      (setq call-process-region 'call-process-region-original))))
 
 (defun org-babel-load-in-session (&optional arg info)
   "Load the body of the current source-code block.  Evaluate the
@@ -575,7 +576,7 @@ may be specified in the properties of the current outline entry."
 	       (if (string-match "\\([^ \f\t\n\r\v]+\\)[ \f\t\n\r\v]+\\([^ \f\t\n\r\v]+.*\\)" arg)
 		   (cons (intern (concat ":" (match-string 1 arg)))
                          (let ((raw (org-babel-chomp (match-string 2 arg))))
-                           (if (org-babel-number-p raw) raw (eval (org-babel-read raw)))))
+                           (if (org-babel-number-p raw) raw (org-babel-read raw))))
 		 (cons (intern (concat ":" arg)) nil)))
 	     (split-string (concat " " arg-string) "[ \f\t\n\r\v]+:" t)))))
 
@@ -775,19 +776,21 @@ code ---- the results are extracted in the syntax of the source
         (setq result (concat result "\n")))
       (save-excursion
 	(let ((existing-result (org-babel-where-is-src-block-result t info hash))
-	      (results-switches (cdr (assoc :results_switches (third info)))))
+	      (results-switches (cdr (assoc :results_switches (third info)))) beg)
 	  (when existing-result (goto-char existing-result) (forward-line 1))
 	  (setq results-switches
                 (if results-switches (concat " " results-switches) ""))
 	  (cond
 	   ;; assume the result is a table if it's not a string
 	   ((not (stringp result))
+	    (setq beg (point))
 	    (insert (concat (orgtbl-to-orgtbl
-			     (if (and (listp (car result))
-                                      (listp (cdr (car result))))
+			     (if (or (eq 'hline (car result))
+				     (and (listp (car result))
+					  (listp (cdr (car result)))))
 				 result (list result))
 			     '(:fmt (lambda (cell) (format "%s" cell)))) "\n"))
-	    (forward-line -1) (org-cycle))
+	    (goto-char beg) (org-cycle))
 	   ((member "file" result-params)
 	    (insert result))
 	   ((member "html" result-params)
@@ -1055,7 +1058,8 @@ This is taken almost directly from `org-read-prop'."
   (if (and (stringp cell) (not (equal cell "")))
       (or (org-babel-number-p cell)
           (if (or (equal "(" (substring cell 0 1))
-                  (equal "'" (substring cell 0 1)))
+                  (equal "'" (substring cell 0 1))
+                  (equal "`" (substring cell 0 1)))
               (eval (read cell))
             (progn (set-text-properties 0 (length cell) nil cell) cell)))
     cell))

+ 235 - 0
contrib/lisp/org-mime.el

@@ -0,0 +1,235 @@
+;;; org-mime.el --- org html export for text/html MIME emails
+
+;; Copyright (C) 2010 Eric Schulte
+
+;; Author: Eric Schulte
+;; Keywords: mime, mail, email, html
+;; Homepage: http://orgmode.org/worg/org-contrib/org-mime.php
+;; Version: 0.01
+
+;;; License:
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+;;
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
+
+;;; Commentary:
+
+;; WYSWYG, html mime composition using org-mode
+;;
+;; For mail composed using the orgstruct-mode minor mode, this
+;; provides a function for converting all or part of your mail buffer
+;; to embedded html as exported by org-mode.  Call `org-mime-htmlize'
+;; in a message buffer to convert either the active region or the
+;; entire buffer to html.
+;;
+;; Similarly the `org-mime-org-buffer-htmlize' function can be called
+;; from within an org-mode buffer to convert the buffer to html, and
+;; package the results into an email handling with appropriate MIME
+;; encoding.
+;;
+;; you might want to bind this to a key with something like the
+;; following message-mode binding
+;; 
+;;   (add-hook 'message-mode-hook
+;;             (lambda ()
+;;               (local-set-key "\C-c\M-o" 'org-mime-htmlize)))
+;;
+;; and the following org-mode binding
+;; 
+;;   (add-hook 'org-mode-hook
+;;             (lambda ()
+;;               (local-set-key "\C-c\M-o" 'org-mime-org-buffer-htmlize)))
+
+;;; Code:
+(defcustom org-mime-default-header
+  "#+OPTIONS: latex:t\n"
+  "Default header to control html export options, and ensure
+  first line isn't assumed to be a title line."
+  :group 'org-mime
+  :type 'string)
+
+(defcustom org-mime-library 'mml
+  "Library to use for marking up MIME elements."
+  :group 'org-mime
+  :type '(choice 'mml 'semi 'vm))
+
+(defcustom org-mime-preserve-breaks t
+  "Used as temporary value of `org-export-preserve-breaks' during
+  mime encoding."
+  :group 'org-mime
+  :type 'boolean)
+
+(defcustom org-mime-fixedwith-wrap
+  "<pre style=\"font-family: courier, monospace;\">\n%s</pre>\n"
+  "Format string used to wrap a fixedwidth HTML email."
+  :group 'org-mime
+  :type 'string)
+
+(defcustom org-mime-html-hook nil
+  "Hook to run over the html buffer before attachment to email.
+  This could be used for example to post-process html elements."
+  :group 'org-mime
+  :type 'hook)
+
+;; example hook, for setting a dark background in <pre style="background-color: #EEE;"> elements
+(defun org-mime-change-element-style (element style)
+  "Set new default htlm style for <ELEMENT> elements in exported html."
+  (while (re-search-forward (format "<%s" element) nil t)
+    (replace-match (format "<%s style=\"%s;\"" element style))))
+
+;; ;; example addition to `org-mime-html-hook' adding a dark background
+;; ;; color to <pre> elements
+;; (add-hook 'org-mime-html-hook
+;;           (lambda ()
+;;             (org-mime-change-element-style
+;;              "pre" (format "color: %s; background-color: %s"
+;;                            "#E6E1DC" "#232323"))))
+
+(defun org-mime-file (ext path id)
+  "Markup a file for attachment."
+  (case org-mime-library
+    ('mml (format
+           "<#part type=\"%s\" filename=\"%s\" id=\"<%s>\">\n<#/part>\n"
+           ext path id))
+    ('semi (format
+            "--[[application/octet-stream; type=%s\nContent-ID: %s; filename=\"%s\"][base64]]"
+            ext id path))
+    ('vm "?")))
+
+(defun org-mime-multipart (plain html)
+  "Markup a multipart/alternative with text/plain and text/html
+  alternatives."
+  (case org-mime-library
+    ('mml (format (concat "<#multipart type=alternative><#part type=text/plain>"
+                          "%s<#part type=text/html>%s<#/multipart>\n")
+                  plain html))
+    ('semi (format (concat "--<<alternative>>-{\n--[[text/plain;%s\n--]]\n"
+                           "--[[text/html;%s\n--]]\n--}-<<alternative>>\n")
+                   plain html))
+    ('vm "?")))
+
+(defun org-mime-replace-images (str current-file)
+  "Replace images in html files with cid links."
+  (let (html-images)
+    (cons
+     (replace-regexp-in-string ;; replace images in html
+      "src=\"\\([^\"]+\\)\""
+      (lambda (text)
+        (format
+         "src=\"cid:%s\""
+         (let* ((url (and (string-match "src=\"\\([^\"]+\\)\"" text)
+                          (match-string 1 text)))
+                (path (expand-file-name
+                       url (file-name-directory current-file)))
+                (ext (file-name-extension path))
+                (id (replace-regexp-in-string "[\/\\\\]" "_" path)))
+           (add-to-list 'html-images
+                        (org-mime-file (concat "image/" ext) path id))
+           id)))
+      str)
+     html-images)))
+
+(defun org-mime-htmlize (arg)
+  "Export a portion of an email body composed using `mml-mode' to
+html using `org-mode'.  If called with an active region only
+export that region, otherwise export the entire body."
+  (interactive "P")
+  (let* ((region-p (org-region-active-p))
+         (html-start (or (and region-p (region-beginning))
+                         (save-excursion
+                           (goto-char (point-min))
+                           (search-forward mail-header-separator)
+                           (+ (point) 1))))
+         (html-end (or (and region-p (region-end))
+                       ;; TODO: should catch signature...
+                       (point-max)))
+         (raw-body (buffer-substring html-start html-end))
+         (tmp-file (make-temp-name (expand-file-name "mail" "/tmp/")))
+         (body (org-mime-org-export "org" raw-body tmp-file))
+         ;; because we probably don't want to skip part of our mail
+         (org-export-skip-text-before-1st-heading nil)
+         ;; because we probably don't want to export a huge style file
+         (org-export-htmlize-output-type 'inline-css)
+         ;; makes the replies with ">"s look nicer
+         (org-export-preserve-breaks org-mime-preserve-breaks)
+         ;; to hold attachments for inline html images
+         (html-and-images
+          (org-mime-replace-images
+           (org-mime-org-export "html" raw-body tmp-file)
+           tmp-file))
+         (html-images (unless arg (cdr html-and-images)))
+         (html (org-mime-apply-html-hook
+                (if arg
+                    (format org-mime-fixedwith-wrap body)
+                  (car html-and-images)))))
+    (delete-region html-start html-end)
+    (save-excursion
+      (goto-char html-start)
+      (insert (org-mime-multipart body html)
+              (mapconcat 'identity html-images "\n")))))
+
+(defun org-mime-org-export (fmt body tmp-file)
+  "Org-Export BODY to format FMT with the file name set to
+TMP-FILE during export."
+  (save-excursion
+    (with-temp-buffer
+      (insert org-mime-default-header)
+      (insert body)
+      (write-file tmp-file)
+      (substring
+       (eval ;; convert to fmt -- mimicing `org-run-like-in-org-mode'
+        (list 'let org-local-vars
+              (list (intern (concat "org-export-as-" fmt))
+                    nil nil nil ''string t)))
+       (if (string= fmt "org") (length org-mime-default-header) 0)))))
+
+(defun org-mime-apply-html-hook (html)
+  (when org-mime-html-hook
+    (with-temp-buffer
+      (insert html)
+      (goto-char (point-min))
+      (run-hooks 'org-mime-html-hook)
+      (buffer-string))))
+
+(defun org-mime-org-buffer-htmlize ()
+  "Export the current org-mode buffer to HTML using
+`org-export-as-html' and package the results into an email
+handling with appropriate MIME encoding."
+  (interactive)
+  (require 'reporter)
+  (let* ((region-p (org-region-active-p))
+         (current-file (buffer-file-name (current-buffer)))
+         (html-start (or (and region-p (region-beginning))
+                         (save-excursion
+                           (goto-char (point-min)))))
+         (html-end (or (and region-p (region-end))
+                       (point-max)))
+         (body (org-export-as-org nil nil nil 'string t))
+         (org-link-file-path-type 'absolute)
+         ;; because we probably don't want to export a huge style file
+         (org-export-htmlize-output-type 'inline-css)
+         ;; to hold attachments for inline html images
+         (html-and-images (org-mime-replace-images
+                           (org-export-as-html nil nil nil 'string t)
+                           current-file))
+         (html-images (cdr html-and-images))
+         (html (org-mime-apply-html-hook (car html-and-images))))
+    ;; dump the exported html into a fresh message buffer
+    (reporter-compose-outgoing)
+    (goto-char (point-max))
+    (insert (org-mime-multipart body html)
+            (mapconcat 'identity html-images "\n"))))
+
+(provide 'org-mime)

+ 14 - 0
doc/ChangeLog

@@ -1,3 +1,17 @@
+2010-04-07  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org.texi (LaTeX and PDF export): Add a footnote about xetex.
+
+2010-04-05  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org.texi (LaTeX/PDF export commands): Section renamed and
+	moved.
+
+2010-04-04  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org.texi (Sectioning structure): Update.
+	(References): New use case for field coordinates.
+
 2010-04-01  Carsten Dominik  <carsten.dominik@gmail.com>
 
 	* org.texi (The export dispatcher): Renamed from ASCII export.

+ 58 - 36
doc/org.texi

@@ -3,8 +3,8 @@
 @setfilename ../../info/org
 @settitle The Org Manual
 
-@set VERSION 6.34trans
-@set DATE January 2010
+@set VERSION 6.35g
+@set DATE April 2010
 
 @c Version and Contact Info
 @set MAINTAINERSITE @uref{http://orgmode.org,maintainers webpage}
@@ -356,8 +356,8 @@ HTML export
 La@TeX{} and PDF export
 
 * LaTeX/PDF export commands::   Which key invokes which commands
+* Header and sectioning::       Setting up the export file structure
 * Quoting LaTeX code::          Incorporating literal La@TeX{} code
-* Sectioning structure::        Changing sectioning in La@TeX{} output
 * Tables in LaTeX export::      Options for exporting tables to La@TeX{}
 * Images in LaTeX export::      How to insert figures into La@TeX{} output
 * Beamer class export::         Turning the file into a presentation
@@ -2061,12 +2061,19 @@ see the @samp{E} mode switch below).  If there are no non-empty fields,
 For Calc formulas and Lisp formulas @code{@@#} and @code{$#} can be used to
 get the row or column number of the field where the formula result goes.
 The traditional Lisp formula equivalents are @code{org-table-current-dline}
-and @code{org-table-current-column}.  Example:
+and @code{org-table-current-column}.  Examples:
 
 @example
-if(@@# % 2, $#, string(""))      @r{column number on odd lines only}
+if(@@# % 2, $#, string(""))   @r{column number on odd lines only}
+$3 = remote(FOO, @@@@#$2)      @r{copy column 2 from table FOO into}
+                             @r{column 3 of the current table}
 @end example
 
+@noindent For the second example, table FOO must have at least as many rows
+as the current table.  Inefficient@footnote{The computation time scales as
+O(N^2) because table FOO is parsed for each field to be copied.} for large
+number of rows.
+
 @subsubheading Named references
 @cindex named references
 @cindex references, named
@@ -9495,20 +9502,25 @@ pages, configure the variable @code{org-export-html-use-infojs}.
 @cindex Guerry, Bastien
 
 Org mode contains a La@TeX{} exporter written by Bastien Guerry.  With
-further processing, this backend is also used to produce PDF output.  Since
-the La@TeX{} output uses @file{hyperref} to implement links and cross
-references, the PDF output file will be fully linked.
+further processing@footnote{The default LaTeX output is designed for
+processing with pdftex or latex.  It includes packages that are not
+compatible with xetex and possibly luatex.  See the variables
+@code{org-export-latex-default-packages-alist} and
+@code{org-export-latex-packages-alist}.}, this backend is also used to
+produce PDF output.  Since the La@TeX{} output uses @file{hyperref} to
+implement links and cross references, the PDF output file will be fully
+linked.
 
 @menu
 * LaTeX/PDF export commands::   Which key invokes which commands
+* Header and sectioning::       Setting up the export file structure
 * Quoting LaTeX code::          Incorporating literal La@TeX{} code
-* Sectioning structure::        Changing sectioning in La@TeX{} output
 * Tables in LaTeX export::      Options for exporting tables to La@TeX{}
 * Images in LaTeX export::      How to insert figures into La@TeX{} output
 * Beamer class export::         Turning the file into a presentation
 @end menu
 
-@node LaTeX/PDF export commands, Quoting LaTeX code, LaTeX and PDF export, LaTeX and PDF export
+@node LaTeX/PDF export commands, Header and sectioning, LaTeX and PDF export, LaTeX and PDF export
 @subsection La@TeX{} export commands
 
 @cindex region, active
@@ -9567,7 +9579,41 @@ with a numeric prefix argument. For example,
 @noindent
 creates two levels of headings and does the rest as items.
 
-@node Quoting LaTeX code, Sectioning structure, LaTeX/PDF export commands, LaTeX and PDF export
+@node Header and sectioning, Quoting LaTeX code, LaTeX/PDF export commands, LaTeX and PDF export
+@subsection Header and sectioning structure
+@cindex La@TeX{} class
+@cindex La@TeX{} sectioning structure
+@cindex La@TeX{} header
+@cindex header, for LaTeX files
+@cindex sectioning structure, for LaTeX export
+
+By default, the La@TeX{} output uses the class @code{article}.
+
+@vindex org-export-latex-default-class
+@vindex org-export-latex-classes
+@vindex org-export-latex-default-packages-alist
+@vindex org-export-latex-packages-alist
+@cindex #+LATEX_HEADER
+@cindex #+LATEX_CLASS
+@cindex #+LATEX_CLASS_OPTIONS
+@cindex property, LATEX_CLASS
+@cindex property, LATEX_CLASS_OPTIONS
+You can change this globally by setting a different value for
+@code{org-export-latex-default-class} or locally by adding an option like
+@code{#+LaTeX_CLASS: myclass} in your file, or with a @code{:LaTeX_CLASS:}
+property that applies when exporting a region containing only this (sub)tree.
+The class must be listed in @code{org-export-latex-classes}.  This variable
+defines a header template for each class@footnote{Into which the values of
+@code{org-export-latex-default-packages-alist} and
+@code{org-export-latex-packages-alist} are spliced.}, and allows you to
+define the sectioning structure for each class.  You can also define your own
+classes there.  @code{#+LaTeX_CLASS_OPTIONS} or a @code{LaTeX_CLASS_OPTIONS}
+property can specify the options for the @code{\documentclass} macro.  You
+can also use @code{#+LATEX_HEADER: \usepackage@{xyz@}} to add lines to the
+header.  See the docstring of @code{org-export-latex-classes} for more
+information.
+
+@node Quoting LaTeX code, Tables in LaTeX export, Header and sectioning, LaTeX and PDF export
 @subsection Quoting La@TeX{} code
 
 Embedded La@TeX{} as described in @ref{Embedded LaTeX}, will be correctly
@@ -9591,32 +9637,8 @@ All lines between these markers are exported literally
 #+END_LaTeX
 @end example
 
-@node  Sectioning structure, Tables in LaTeX export, Quoting LaTeX code, LaTeX and PDF export
-@subsection Sectioning structure
-@cindex La@TeX{} class
-@cindex La@TeX{} sectioning structure
 
-By default, the La@TeX{} output uses the class @code{article}.
-
-@vindex org-export-latex-default-class
-@vindex org-export-latex-classes
-@cindex #+LATEX_HEADER
-@cindex #+LATEX_CLASS
-@cindex #+LATEX_CLASS_OPTIONS
-@cindex property, LATEX_CLASS
-@cindex property, LATEX_CLASS_OPTIONS
-You can change this globally by setting a different value for
-@code{org-export-latex-default-class} or locally by adding an option like
-@code{#+LaTeX_CLASS: myclass} in your file, or with a @code{:LaTeX_CLASS:}
-property that applies when exporting a region containing only this (sub)tree.
-The class should be listed in @code{org-export-latex-classes}, where you can
-also define the sectioning structure for each class, as well as defining
-additional classes.  In a similar way, @code{#+LaTeX_CLASS_OPTIONS} or a
-@code{LaTeX_CLASS_OPTIONS} property can specify the options for the
-@code{\documentclass} macro.  You can also use @code{#+LATEX_HEADER:
-\usepackage@{xyz@}} to add lines to the header.
-
-@node Tables in LaTeX export, Images in LaTeX export, Sectioning structure, LaTeX and PDF export
+@node Tables in LaTeX export, Images in LaTeX export, Quoting LaTeX code, LaTeX and PDF export
 @subsection Tables in La@TeX{} export
 @cindex tables, in La@TeX{} export
 

+ 1 - 1
doc/orgcard.tex

@@ -1,5 +1,5 @@
 % Reference Card for Org Mode
-\def\orgversionnumber{6.34trans}
+\def\orgversionnumber{6.35g}
 \def\versionyear{2010}          % latest update
 \def\year{2010}                 % latest copyright year
 

+ 82 - 0
lisp/ChangeLog

@@ -1,5 +1,87 @@
+2010-04-09  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org-mobile.el (org-mobile-check-setup): Make sure that there is
+	a binary to compute checksums.
+
+2010-04-08  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org.el (org-insert-link): Find the link buffer on visible
+	frames.
+	(org-export-latex-default-packages-alist): hyperref must be loaded
+	late.
+	(org-open-file): More care with the new matching for file links.
+
+2010-04-07  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org-latex.el (org-export-latex-preprocess): Do not yet protect
+	defined entities - these will be taken care of later.
+	(org-export-latex-special-chars): Post-process entity replacement.
+	(org-export-latex-fontify-headline): Do not yet protect defined
+	entities - these will be taken care of later.
+	(org-export-latex-tables, org-export-latex-links): Format the
+	caption properly.
+
+	* org-entities.el (org-entities-user): Fix typo.
+
+	* org.el (org-prepare-agenda-buffers): Uniquify TODO keywords
+
+	* org-entities.el (org-entities-user): Improve docstring.
+
+2010-04-06  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org-entities.el (org-macs): Require org-macs, to be sure that we
+	have `declare-function' defined.
+
+2010-04-05  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org-latex.el (org-export-latex-classes): Update docstring.
+
+	* org.el (org-format-latex-header): Add cookies to the header.
+	(org-splice-latex-header): Implement placement according to
+	cookies.
+
+2010-04-04  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org-publish.el (org-publish-aux-preprocess): Control case
+	sensitivity.
+
+2010-04-04  Bastien Guerry  <bzg@altern.org>
+
+	* org.el (org-splice-latex-header): Fix typo.
+
+2010-04-04  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org-latex.el (org-export-latex-make-header): Use
+	`org-splice-latex-header' to build the header.
+	(org-export-latex-classes): Update docstring.
+
+	* org.el (org-splice-latex-header): New function.
+	(org-create-formula-image): Use `org-splice-latex-header' to build
+	the header.
+
+	* org-gnus.el (org-gnus-follow-link): Handle nndoc backend.
+
+2010-04-03  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org.el (org-export-latex-packages-alist)
+	(org-export-latex-default-packages-alist): Fix docstring to
+	reflect the expected structure.
+
+	* org-docbook.el (org-docbook-do-expand): Fix bug with variable names.
+	(org-export-docbook-finalize-table): Make use of label for tables.
+
+2010-04-02  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org-attach.el (org-attach-commit): Split on newlines.
+
+	* org.el (org-export-latex-default-packages-alist): Use list
+	instead of cons for the entries.
+
 2010-04-01  Carsten Dominik  <carsten.dominik@gmail.com>
 
+	* org-entities.el (org-entity-get-representation): Catch the case
+	that there is not entry in the list.
+
 	* org-mobile.el (org-mobile-use-encryption)
 	(org-mobile-encryption-tempfile, org-mobile-encryption-password):
 	New options.

+ 2 - 2
lisp/org-agenda.el

@@ -1,12 +1,12 @@
 ;;; org-agenda.el --- Dynamic task and appointment lists for Org
 
-;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
+;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
 ;;   Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.34trans
+;; Version: 6.35g
 ;;
 ;; This file is part of GNU Emacs.
 ;;

+ 2 - 2
lisp/org-archive.el

@@ -1,12 +1,12 @@
 ;;; org-archive.el --- Archiving for Org-mode
 
-;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
+;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
 ;;   Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.34trans
+;; Version: 6.35g
 ;;
 ;; This file is part of GNU Emacs.
 ;;

+ 3 - 3
lisp/org-ascii.el

@@ -1,12 +1,12 @@
 ;;; org-ascii.el --- ASCII export for Org-mode
 
-;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
+;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
 ;;   Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.34trans
+;; Version: 6.35g
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -581,7 +581,7 @@ publishing directory."
   (let (e)
     (while (re-search-forward "\\\\\\([a-zA-Z]+[0-9]*\\)" nil t)
       (org-if-unprotected-at (match-beginning 1)
-	(setq e (org-entity-get-representation (match-string 1 line)
+	(setq e (org-entity-get-representation (match-string 1)
 					       org-export-ascii-entities))
 	(and e (replace-match e t t))))))
 

+ 4 - 4
lisp/org-attach.el

@@ -1,10 +1,10 @@
 ;;; org-attach.el --- Manage file attachments to org-mode tasks
 
-;; Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+;; Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <johnw@newartisans.com>
 ;; Keywords: org data task
-;; Version: 6.34trans
+;; Version: 6.35g
 
 ;; This file is part of GNU Emacs.
 ;;
@@ -245,12 +245,12 @@ This checks for the existence of a \".git\" directory in that directory."
       (with-temp-buffer
 	(cd dir)
 	(shell-command "git add .")
-	(shell-command "git ls-files --deleted -z" t)
+	(shell-command "git ls-files --deleted" t)
 	(mapc '(lambda (file)
 		 (unless (string= file "")
 		   (shell-command
 		    (concat "git rm \"" file "\""))))
-	      (split-string (buffer-string) ""))
+	      (split-string (buffer-string) "\n"))
 	(shell-command "git commit -m 'Synchronized attachments'")))))
 
 (defun org-attach-tag (&optional off)

+ 2 - 2
lisp/org-bbdb.el

@@ -1,13 +1,13 @@
 ;;; org-bbdb.el --- Support for links to BBDB entries from within Org-mode
 
-;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
+;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
 ;;   Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>,
 ;;         Thomas Baumann <thomas dot baumann at ch dot tum dot de>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.34trans
+;; Version: 6.35g
 ;;
 ;; This file is part of GNU Emacs.
 ;;

+ 2 - 2
lisp/org-beamer.el

@@ -1,8 +1,8 @@
 ;;; org-beamer.el --- Beamer-specific LaTeX export for org-mode
 ;;
-;; Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
+;; Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 ;;
-;; Version: 6.34trans
+;; Version: 6.35g
 ;; Author: Carsten Dominik <carsten.dominik AT gmail DOT com>
 ;; Maintainer: Carsten Dominik <carsten.dominik AT gmail DOT com>
 ;; Keywords: org, wp, tex

+ 2 - 2
lisp/org-bibtex.el

@@ -1,11 +1,11 @@
 ;;; org-bibtex.el --- Org links to BibTeX entries
 ;;
-;; Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
+;; Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 ;;
 ;; Author: Bastien Guerry <bzg at altern dot org>
 ;;         Carsten Dominik <carsten dot dominik at gmail dot com>
 ;; Keywords: org, wp, remember
-;; Version: 6.34trans
+;; Version: 6.35g
 ;;
 ;; This file is part of GNU Emacs.
 ;;

+ 2 - 2
lisp/org-clock.el

@@ -1,12 +1,12 @@
 ;;; org-clock.el --- The time clocking code for Org-mode
 
-;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
+;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
 ;;   Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.34trans
+;; Version: 6.35g
 ;;
 ;; This file is part of GNU Emacs.
 ;;

+ 2 - 2
lisp/org-colview-xemacs.el

@@ -1,12 +1,12 @@
 ;;; org-colview-xemacs.el --- Column View in Org-mode, XEmacs-specific version
 
-;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
+;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
 ;;   Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.34trans
+;; Version: 6.35g
 ;;
 ;; This file is part of GNU Emacs.
 ;;

+ 2 - 2
lisp/org-colview.el

@@ -1,12 +1,12 @@
 ;;; org-colview.el --- Column View in Org-mode
 
-;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
+;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
 ;;   Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.34trans
+;; Version: 6.35g
 ;;
 ;; This file is part of GNU Emacs.
 ;;

+ 2 - 2
lisp/org-compat.el

@@ -1,12 +1,12 @@
 ;;; org-compat.el --- Compatibility code for Org-mode
 
-;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
+;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
 ;;   Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.34trans
+;; Version: 6.35g
 ;;
 ;; This file is part of GNU Emacs.
 ;;

+ 2 - 2
lisp/org-crypt.el

@@ -1,10 +1,10 @@
 ;;; org-crypt.el --- Public key encryption for org-mode entries
 
-;; Copyright (C) 2007, 2009  Free Software Foundation, Inc.
+;; Copyright (C) 2007, 2009, 2010  Free Software Foundation, Inc.
 
 ;; Emacs Lisp Archive Entry
 ;; Filename: org-crypt.el
-;; Version: 6.34trans
+;; Version: 6.35g
 ;; Keywords: org-mode
 ;; Author: John Wiegley <johnw@gnu.org>
 ;; Maintainer: Peter Jones <pjones@pmade.com>

+ 21 - 1
lisp/org-ctags.el

@@ -1,8 +1,28 @@
 ;;; org-ctags.el - Integrate Emacs "tags" facility with org mode.
 ;;;
+;; Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+
 ;;; Author: Paul Sexton <eeeickythump@gmail.com>
 ;;; Version: 1.0
-;;; Repository at http://bitbucket.org/eeeickythump/org-ctags/
+
+;; Keywords: org, wp
+;; Version: 6.35g
+;;
+;; This file is part of GNU Emacs.
+;;
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+
 ;;;
 ;;; Synopsis
 ;;; ========

+ 2 - 2
lisp/org-datetree.el

@@ -1,11 +1,11 @@
 ;;; org-datetree.el --- Create date entries in a tree
 
-;; Copyright (C) 2009 Free Software Foundation, Inc.
+;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.34trans
+;; Version: 6.35g
 ;;
 ;; This file is part of GNU Emacs.
 ;;

+ 29 - 14
lisp/org-docbook.el

@@ -1,10 +1,10 @@
 ;;; org-docbook.el --- DocBook exporter for org-mode
 ;;
-;; Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
+;; Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 ;;
 ;; Emacs Lisp Archive Entry
 ;; Filename: org-docbook.el
-;; Version: 6.34trans
+;; Version: 6.35g
 ;; Author: Baoqiu Cui <cbaoqiu AT yahoo DOT com>
 ;; Maintainer: Baoqiu Cui <cbaoqiu AT yahoo DOT com>
 ;; Keywords: org, wp, docbook
@@ -1259,13 +1259,13 @@ string, don't modify these."
   (if org-export-with-sub-superscripts
       (setq s (org-export-docbook-convert-sub-super s)))
   (if org-export-with-TeX-macros
-      (let ((start 0) wd rep ass)
+      (let ((start 0) wd rep)
 	(while (setq start (string-match "\\\\\\([a-zA-Z]+\\)\\({}\\)?"
 					 s start))
 	  (if (get-text-property (match-beginning 0) 'org-protected s)
 	      (setq start (match-end 0))
 	    (setq wd (match-string 1 s))
-	    (if (setq ass (org-entity-get-representation wd 'html))
+	    (if (setq rep (org-entity-get-representation wd 'html))
 		(setq s (replace-match rep t t s))
 	      (setq start (+ start (length wd))))))))
   s)
@@ -1349,18 +1349,33 @@ string, don't modify these."
 	(replace-match ""))))
 
 (defun org-export-docbook-finalize-table (table)
-  "Change TABLE to informaltable if caption does not exist.
+  "Clean up TABLE and turn it into DocBook format.
+This function adds a label to the table if it is available, and
+also changes TABLE to informaltable if caption does not exist.
 TABLE is a string containing the HTML code generated by
 `org-format-table-html' for a table in Org-mode buffer."
-  (if (string-match
-       "^<table \\(\\(.\\|\n\\)+\\)<caption></caption>\n\\(\\(.\\|\n\\)+\\)</table>"
-       table)
-      (replace-match (concat "<informaltable "
-			     (match-string 1 table)
-			     (match-string 3 table)
-			     "</informaltable>")
-		     nil nil table)
-    table))
+  (let (table-with-label)
+    ;; Get the label if it exists, and move it into the <table> element.
+    (setq table-with-label
+	  (if (string-match
+	       "^<table \\(\\(.\\|\n\\)+\\)<a name=\"\\(.+\\)\" id=\".+\"></a>\n\\(\\(.\\|\n\\)+\\)</table>"
+	       table)
+	      (replace-match (concat "<table xml:id=\"" (match-string 3 table) "\" "
+				     (match-string 1 table)
+				     (match-string 4 table)
+				     "</table>")
+			     nil nil table)
+	    table))
+    ;; Change <table> into <informaltable> if caption does not exist.
+    (if (string-match
+	 "^<table \\(\\(.\\|\n\\)+\\)<caption></caption>\n\\(\\(.\\|\n\\)+\\)</table>"
+	 table-with-label)
+	(replace-match (concat "<informaltable "
+			       (match-string 1 table-with-label)
+			       (match-string 3 table-with-label)
+			       "</informaltable>")
+		       nil nil table-with-label)
+      table-with-label)))
 
 ;; Note: This function is very similar to
 ;; org-export-html-convert-sub-super.  They can be merged in the future.

+ 2 - 2
lisp/org-docview.el

@@ -1,12 +1,12 @@
 ;;; org-docview.el --- support for links to doc-view-mode buffers
 
-;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
+;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
 ;;   Free Software Foundation, Inc.
 
 ;; Author: Jan Böcker <jan.boecker at jboecker dot de>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.34trans
+;; Version: 6.35g
 ;;
 ;; This file is part of GNU Emacs.
 ;;

+ 12 - 4
lisp/org-entities.el

@@ -6,7 +6,7 @@
 ;;         Ulf Stegemann <ulf at zeitform dot de>
 ;; Keywords: outlines, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.34trans
+;; Version: 6.35g
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -26,6 +26,10 @@
 ;;
 ;;; Commentary:
 
+(require 'org-macs)
+
+(declare-function org-table-align "org-table" ())
+
 (eval-when-compile
   (require 'cl))
 
@@ -58,7 +62,10 @@ ASCII replacement    Plain ASCII, no extensions.  Symbols that cannot be
                      represented will be written out as an explanatory text.
                      But see the variable `org-entities-ascii-keep-macro-form'.
 Latin1 replacement   Use the special characters available in latin1.
-utf-8 replacement    Use special character available in utf-8."
+utf-8 replacement    Use special character available in utf-8.
+
+If you define new entities here that require specific LaTeX packages to be
+loaded, add these packages to `org-export-latex-packages-alist'."
   :group 'org-entities
   :type '(repeat
 	  (list
@@ -429,7 +436,8 @@ Kind can be any of `latex', `html', `ascii', `latin1', or `utf8'."
 	 (n (cdr (assq kind '((latex . 1) (html . 3) (ascii . 4)
 			      (latin1 . 5) (utf8 . 6)))))
 	 (r (and e n (nth n e))))
-    (if (and (not org-entities-ascii-explanatory)
+    (if (and e r
+	     (not org-entities-ascii-explanatory)
 	     (memq kind '(ascii latin1 utf8))
 	     (= (string-to-char r) ?\[))
 	(concat "\\" name)
@@ -446,7 +454,7 @@ Kind can be any of `latex', `html', `ascii', `latin1', or `utf8'."
   (interactive)
   (let ((ll org-entities)
 	(pos (point))
-	e latex mathp html latin 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))

+ 2 - 1
lisp/org-exp-blocks.el

@@ -1,9 +1,10 @@
 ;;; org-exp-blocks.el --- pre-process blocks when exporting org files
 
-;; Copyright (C) 2009
+;; Copyright (C) 2009, 2010
 ;;   Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
+;; Version: 6.35g
 
 ;; This file is part of GNU Emacs.
 ;;

+ 9 - 4
lisp/org-exp.el

@@ -1,12 +1,12 @@
 ;;; org-exp.el --- ASCII, HTML, XOXO and iCalendar export for Org-mode
 
-;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
+;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
 ;;   Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.34trans
+;; Version: 6.35g
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -2490,7 +2490,8 @@ directory."
 			  filename)))
 	 (backup-inhibited t)
 	 (buffer (find-file-noselect filename))
-	 (region (buffer-string)))
+	 (region (buffer-string))
+         str-ret)
     (save-excursion
       (switch-to-buffer buffer)
       (erase-buffer)
@@ -2536,7 +2537,11 @@ directory."
 	    (write-file (concat filename ".html")))
 	  (kill-buffer newbuf)))
       (set-buffer-modified-p nil)
-      (kill-buffer (current-buffer)))))
+      (if (equal to-buffer 'string)
+          (progn (setq str-ret (buffer-string))
+                 (kill-buffer (current-buffer))
+                 str-ret)
+        (kill-buffer (current-buffer))))))
 
 (defvar org-archive-location)  ;; gets loaded with the org-archive require.
 (defun org-get-current-options ()

+ 2 - 2
lisp/org-faces.el

@@ -1,12 +1,12 @@
 ;;; org-faces.el --- Face definitions for Org-mode.
 
-;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
+;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
 ;;   Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.34trans
+;; Version: 6.35g
 ;;
 ;; This file is part of GNU Emacs.
 ;;

+ 2 - 2
lisp/org-feed.el

@@ -1,11 +1,11 @@
 ;;; org-feed.el --- Add RSS feed items to Org files
 ;;
-;; Copyright (C) 2009 Free Software Foundation, Inc.
+;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
 ;;
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.34trans
+;; Version: 6.35g
 ;;
 ;; This file is part of GNU Emacs.
 ;;

+ 3 - 3
lisp/org-footnote.el

@@ -1,11 +1,11 @@
 ;;; org-footnote.el --- Footnote support in Org and elsewhere
 ;;
-;; Copyright (C) 2009 Free Software Foundation, Inc.
+;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
 ;;
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.34trans
+;; Version: 6.35g
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -183,7 +183,7 @@ with start and label of the footnote if there is a definition at point."
       (message "Edit definition and go back with `C-c &' or, if unique, with `C-c C-c'."))))
 
 (defun org-footnote-goto-next-reference (label)
-  "Find the definition of the footnote with label LABEL."
+  "Find the next reference of the footnote with label LABEL."
   (interactive "sLabel: ")
   (org-mark-ring-push)
   (setq label (org-footnote-normalize-label label))

+ 2 - 2
lisp/org-freemind.el

@@ -1,11 +1,11 @@
 ;;; org-freemind.el --- Export Org files to freemind
 
-;; Copyright (C) 2009 Free Software Foundation, Inc.
+;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
 
 ;; Author: Lennart Borgman (lennart O borgman A gmail O com)
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.34trans
+;; Version: 6.35g
 ;;
 ;; This file is part of GNU Emacs.
 ;;

+ 24 - 15
lisp/org-gnus.el

@@ -1,13 +1,13 @@
 ;;; org-gnus.el --- Support for links to Gnus groups and messages from within Org-mode
 
-;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
+;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
 ;;   Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;;         Tassilo Horn <tassilo at member dot fsf dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.34trans
+;; Version: 6.35g
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -169,19 +169,28 @@ If `org-store-link' was called with a prefix arg the meaning of
   (cond ((and group article)
 	 (gnus-activate-group group t)
 	 (condition-case nil
-	     (let ((articles 1)
-		   group-opened)
-	       (while (and (not group-opened)
-			   ;; stop on integer overflows
-			   (> articles 0))
-		 (setq group-opened (gnus-group-read-group articles nil group)
-		       articles (if (< articles 16)
-				    (1+ articles)
-				  (* articles 2))))
-	       (if group-opened
-		   (gnus-summary-goto-article article nil t)
-		 (message "Couldn't follow gnus link.  %s"
-			  "The summary couldn't be opened.")))
+	     (let ((backend (car (gnus-find-method-for-group group))))
+	       (cond
+		((eq backend 'nndoc)
+		 (if (gnus-group-read-group t nil group)
+		     (gnus-summary-goto-article article nil t)
+		   (message "Couldn't follow gnus link.  %s"
+			    "The summary couldn't be opened.")))
+		(t
+		 (let ((articles 1)
+		       group-opened)
+		   (while (and (not group-opened)
+			       ;; stop on integer overflows
+			       (> articles 0))
+		     (setq group-opened (gnus-group-read-group
+					 articles nil group)
+			   articles (if (< articles 16)
+					(1+ articles)
+				      (* articles 2))))
+		   (if group-opened
+		       (gnus-summary-goto-article article nil t)
+		     (message "Couldn't follow gnus link.  %s"
+			      "The summary couldn't be opened."))))))
 	   (quit (message "Couldn't follow gnus link.  %s"
 			  "The linked group is empty."))))
 	(group (gnus-group-jump-to-group group))))

+ 2 - 2
lisp/org-habit.el

@@ -1,11 +1,11 @@
 ;;; org-habit.el --- The habit tracking code for Org-mode
 
-;; Copyright (C) 2009 Free Software Foundation, Inc.
+;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <johnw at gnu dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.34trans
+;; Version: 6.35g
 ;;
 ;; This file is part of GNU Emacs.
 ;;

+ 2 - 2
lisp/org-html.el

@@ -1,12 +1,12 @@
 ;;; org-html.el --- HTML export for Org-mode
 
-;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
+;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
 ;;   Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.34trans
+;; Version: 6.35g
 ;;
 ;; This file is part of GNU Emacs.
 ;;

+ 2 - 2
lisp/org-icalendar.el

@@ -1,12 +1,12 @@
 ;;; org-icalendar.el --- iCalendar export for Org-mode
 
-;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
+;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
 ;;   Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.34trans
+;; Version: 6.35g
 ;;
 ;; This file is part of GNU Emacs.
 ;;

+ 2 - 2
lisp/org-id.el

@@ -1,11 +1,11 @@
 ;;; org-id.el --- Global identifiers for Org-mode entries
 ;;
-;; Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+;; Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
 ;;
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.34trans
+;; Version: 6.35g
 ;;
 ;; This file is part of GNU Emacs.
 ;;

+ 2 - 2
lisp/org-indent.el

@@ -1,10 +1,10 @@
 ;;; org-indent.el --- Dynamic indentation for  Org-mode
-;; Copyright (C) 2009 Free Software Foundation, Inc.
+;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
 ;;
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.34trans
+;; Version: 6.35g
 ;;
 ;; This file is part of GNU Emacs.
 ;;

+ 2 - 2
lisp/org-info.el

@@ -1,12 +1,12 @@
 ;;; org-info.el --- Support for links to Info nodes from within Org-Mode
 
-;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
+;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
 ;;   Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.34trans
+;; Version: 6.35g
 ;;
 ;; This file is part of GNU Emacs.
 ;;

+ 2 - 2
lisp/org-inlinetask.el

@@ -1,11 +1,11 @@
 ;;; org-inlinetask.el --- Tasks independent of outline hierarchy
 
-;; Copyright (C) 2009 Free Software Foundation, Inc.
+;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
 ;;
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.34trans
+;; Version: 6.35g
 
 ;; This file is part of GNU Emacs.
 

+ 2 - 2
lisp/org-irc.el

@@ -1,10 +1,10 @@
 ;;; org-irc.el --- Store links to IRC sessions
 ;;
-;; Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+;; Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
 ;;
 ;; Author: Philip Jackson <emacs@shellarchive.co.uk>
 ;; Keywords: erc, irc, link, org
-;; Version: 6.34trans
+;; Version: 6.35g
 ;;
 ;; This file is part of GNU Emacs.
 ;;

+ 2 - 2
lisp/org-jsinfo.el

@@ -1,12 +1,12 @@
 ;;; org-jsinfo.el --- Support for org-info.js Javascript in Org HTML export
 
-;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
+;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
 ;;   Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.34trans
+;; Version: 6.35g
 ;;
 ;; This file is part of GNU Emacs.
 ;;

+ 86 - 47
lisp/org-latex.el

@@ -1,10 +1,10 @@
 ;;; org-latex.el --- LaTeX exporter for org-mode
 ;;
-;; Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
+;; Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 ;;
 ;; Emacs Lisp Archive Entry
 ;; Filename: org-latex.el
-;; Version: 6.34trans
+;; Version: 6.35g
 ;; Author: Bastien Guerry <bzg AT altern DOT org>
 ;; Maintainer: Carsten Dominik <carsten.dominik AT gmail DOT com>
 ;; Keywords: org, wp, tex
@@ -128,13 +128,40 @@ The header string
 -----------------
 
 The HEADER-STRING is the header that will be inserted into the LaTeX file.
-It should really only contain the contain the \\documentclass macro, and
-setup code that is specific to this class.  This will be augmented by
-call to \\usepackage for all packages mentioned in the variables
-`org-export-latex-default-packages-alist' and
-`org-export-latex-packages-alist'.  Lines specified via \"#+LaTeX_HEADER:\"
-are also added.
-`org-export-latex-default-packages-alist' contains
+It should contain the \\documentclass macro, and anything else that is needed
+for this setup.  To this header, the following commands will be added:
+
+- Calls to \\usepackage for all packages mentioned in the variables
+  `org-export-latex-default-packages-alist' and
+  `org-export-latex-packages-alist'.  Thus, your header definitions should
+  avoid to also request these packages.
+
+- Lines specified via \"#+LaTeX_HEADER:\"
+
+If you need more control about the sequence in which the header is built
+up, or if you want to exclude one of these building blocks for a particular
+class, you can use the following macro-like placeholders.
+
+ [DEFAULT-PACKAGES]      \\usepackage statements for default packages
+ [NO-DEFAULT-PACKAGES]   do not include any of the default packages
+ [PACKAGES]              \\usepackage statements for packages 
+ [NO-PACKAGES]           do not include the packages
+ [EXTRA]                 the stuff from #+LaTeX_HEADER
+ [NO-EXTRA]              do not include #+LaTeX_HEADER stuff
+
+So a header like
+
+  \\documentclass{article}
+  [NO-DEFAULT-PACKAGES]
+  [EXTRA]
+  \\providecommand{\\alert}[1]{\\textbf{#1}}
+  [PACKAGES]
+
+will omit the default packages, and will include the #+LaTeX_HEADER lines,
+then have a call to \\providecommand, and then place \\usepackage commands
+based on the content of `org-export-latex-packages-alist'.
+
+If your header or `org-export-latex-default-packages-alist' inserts
 \"\\usepackage[AUTO]{inputenc}\", AUTO will automatically be replaced with
 a coding system derived from `buffer-file-coding-system'.  See also the
 variable `org-export-latex-inputenc-alist' for a way to influence this
@@ -144,7 +171,7 @@ The sectioning structure
 ------------------------
 
 The sectioning structure of the class is given by the elements following
-the header string.  For ech sectioning level, a number of strings is
+the header string.  For each sectioning level, a number of strings is
 specified.  A %s formatter is mandatory in each section string and will
 be replaced by the title of the section.
 
@@ -157,14 +184,14 @@ or
 
   (numbered-open numbered-close unnumbered-open unnumbered-close)
 
-providing opening and closing strings for an environment that should
+providing opening and closing strings for a LaTeX environment that should
 represent the document section.  The opening clause should have a %s
 to represent the section title.
 
 Instead of a list of sectioning commands, you can also specify a
 function name.  That function will be called with two parameters,
-the (reduced) level of the headline, and the headline text.  The functions
-returns a cons cell with the (possibly modified) headline text, and the
+the (reduced) level of the headline, and the headline text.  The function
+must return a cons cell with the (possibly modified) headline text, and the
 sectioning list in the cdr."
   :group 'org-export-latex
   :type '(repeat
@@ -557,6 +584,7 @@ simply return the content of \begin{document}...\end{document},
 without even the \begin{document} and \end{document} commands.
 when PUB-DIR is set, use this as the publishing directory."
   (interactive "P")
+  (when (and (not body-only) (listp arg)) (setq body-only t))
   (run-hooks 'org-export-first-hook)
 
   ;; Make sure we have a file name when we need it.
@@ -1113,28 +1141,17 @@ OPT-PLIST is the options plist for current buffer."
     (concat
      (if (plist-get opt-plist :time-stamp-file)
 	 (format-time-string "%% Created %Y-%m-%d %a %H:%M\n"))
-     ;; insert LaTeX custom header
-     (org-export-apply-macros-in-string org-export-latex-header)
-     "\n"
-     ;; insert information on LaTeX packages
-     (when (or org-export-latex-default-packages-alist
-	       org-export-latex-packages-alist)
-       (concat
-	(mapconcat (lambda(p)
-		     (if (equal "" (car p))
-			 (format "\\usepackage{%s}" (cadr p))
-		       (format "\\usepackage[%s]{%s}"
-			       (car p) (cadr p))))
-		   (append org-export-latex-default-packages-alist
-			   org-export-latex-packages-alist)
-		   "\n")
-	"\n"))
-     ;; insert additional commands in the header
-     (org-export-apply-macros-in-string
-      (plist-get opt-plist :latex-header-extra))
+     ;; insert LaTeX custom header and packages from the list
+     (org-splice-latex-header
+      (org-export-apply-macros-in-string org-export-latex-header)
+      org-export-latex-default-packages-alist
+      org-export-latex-packages-alist
+      (org-export-apply-macros-in-string
+       (plist-get opt-plist :latex-header-extra)))
+     ;; append another special variable
      (org-export-apply-macros-in-string org-export-latex-append-header)
      ;; define align if not yet defined
-     "\\providecommand{\\alert}[1]{\\textbf{#1}}"
+     "\n\\providecommand{\\alert}[1]{\\textbf{#1}}"
      ;; insert the title
      (format
       "\n\n\\title{%s}\n"
@@ -1296,7 +1313,7 @@ links, keywords, lists, tables, fixed-width"
     ;; the beginning of the buffer - inserting "\n" is safe here though.
     (insert "\n" string)
     (goto-char (point-min))
-    (let ((re (concat "\\\\[a-zA-Z]+"
+    (let ((re (concat "\\\\\\([a-zA-Z]+\\)"
 		      "\\(?:<[^<>\n]*>\\)*"
 		      "\\(?:\\[[^][\n]*?\\]\\)*"
 		      "\\(?:<[^<>\n]*>\\)*"
@@ -1304,8 +1321,12 @@ links, keywords, lists, tables, fixed-width"
 		      (org-create-multibrace-regexp "{" "}" 3)
 		      "\\)\\{1,3\\}")))
       (while (re-search-forward re nil t)
-	(unless (save-excursion (goto-char (match-beginning 0))
-				(equal (char-after (point-at-bol)) ?#))
+	(unless (or
+		 ;; check for comment line
+		 (save-excursion (goto-char (match-beginning 0))
+				 (equal (char-after (point-at-bol)) ?#))
+		 ;; Check if this is a defined entity, so that is may need conversion
+		 (org-entity-get (match-string 1)))
 	  (add-text-properties (match-beginning 0) (match-end 0)
 			       '(org-protected t)))))
     (when (plist-get org-export-latex-options-plist :emphasize)
@@ -1390,6 +1411,17 @@ See the `org-export-latex.el' code for a complete conversion table."
 					     (match-string 1)
 					     (or (match-string 3) "")))
 					  "") t t)
+		       (when (and (get-text-property (1- (point)) 'org-entity)
+				  (looking-at "{}"))
+			 ;; OK, this was an entity replacement, and the user
+			 ;; had terminated the entity with {}.  Make sure
+			 ;; {} is protected as well, and remove the extra {}
+			 ;; inserted by the conversion.
+			 (put-text-property (point) (+ 2 (point)) 'org-protected t)
+			 (if (save-excursion (goto-char (max (- (point) 2) (point-min)))
+					     (looking-at "{}"))
+			     (replace-match ""))
+			 (forward-char 2))
 		       (backward-char 1))
 		      ((member (match-string 2) '("_" "^"))
 		       (replace-match (or (save-match-data
@@ -1456,12 +1488,14 @@ Convert CHAR depending on STRING-BEFORE and STRING-AFTER."
 The conversion is made depending of STRING-BEFORE and STRING-AFTER."
   (let  ((ass (org-entity-get string-after)))
     (cond
-     (ass (if (nth 2 ass)
-	      (concat string-before
-		      (org-export-latex-protect-string
-		       (concat "$" (nth 1 ass) "$")))
-	    (concat string-before (org-export-latex-protect-string
-				   (nth 1 ass)))))
+     (ass (org-add-props
+	      (if (nth 2 ass)
+		  (concat string-before
+			  (org-export-latex-protect-string
+			   (concat "$" (nth 1 ass) "$")))
+		(concat string-before (org-export-latex-protect-string
+				       (nth 1 ass))))
+	      nil 'org-entity t))
      ((and (not (string-match "^[ \n\t]" string-after))
 	   (not (string-match "[ \t]\\'\\|^" string-before)))
       ;; backslash is inside a word
@@ -1556,7 +1590,7 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
                              (string-match "\\<align=\\([^ \t\n\r,]+\\)" attr)
                              (match-string 1 attr))
                   floatp (or caption label))
-	    (setq caption (and caption (org-export-latex-content caption)))
+	    (setq caption (and caption (org-export-latex-fontify-headline caption)))
             (setq lines (org-split-string raw-table "\n"))
             (apply 'delete-region (list beg end))
             (when org-export-table-remove-special-lines
@@ -1813,7 +1847,7 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
 				       raw-path))))))))
        ;; process with link inserting
        (apply 'delete-region remove)
-       (setq caption (and caption (org-export-latex-content caption)))
+       (setq caption (and caption (org-export-latex-fontify-headline caption)))
        (cond ((and imgp
 		   (plist-get org-export-latex-options-plist :inline-images))
 	      ;; OK, we need to inline an image
@@ -2013,14 +2047,19 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
   ;; Protect LaTeX commands like \command[...]{...} or \command{...}
   (goto-char (point-min))
   (let ((re (concat
-	     "\\\\[a-zA-Z]+"
+	     "\\\\\\([a-zA-Z]+\\)"
 	     "\\(?:<[^<>\n]*>\\)*"
 	     "\\(?:\\[[^][\n]*?\\]\\)*"
 	     "\\(?:<[^<>\n]*>\\)*"
 	     "\\(" (org-create-multibrace-regexp "{" "}" 3) "\\)\\{1,3\\}")))
     (while (re-search-forward re nil t)
-      (unless (save-excursion (goto-char (match-beginning 0))
-			      (equal (char-after (point-at-bol)) ?#))
+      (unless (or 
+	       ;; check for comment line
+	       (save-excursion (goto-char (match-beginning 0))
+			       (equal (char-after (point-at-bol)) ?#))
+	       ;; Check if this is a defined entity, so that is may need conversion
+	       (org-entity-get (match-string 1))
+	       )
 	(add-text-properties (match-beginning 0) (match-end 0)
 			     '(org-protected t)))))
 

+ 2 - 2
lisp/org-list.el

@@ -1,13 +1,13 @@
 ;;; org-list.el --- Plain lists for Org-mode
 ;;
-;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
+;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
 ;;   Free Software Foundation, Inc.
 ;;
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;;	   Bastien Guerry <bzg AT altern DOT org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.34trans
+;; Version: 6.35g
 ;;
 ;; This file is part of GNU Emacs.
 ;;

+ 2 - 2
lisp/org-mac-message.el

@@ -1,11 +1,11 @@
 ;;; org-mac-message.el --- Links to Apple Mail.app messages from within Org-mode
 
-;; Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+;; Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <johnw@gnu.org>
 ;;         Christopher Suckling <suckling at gmail dot com>
 
-;; Version: 6.34trans
+;; Version: 6.35g
 ;; Keywords: outlines, hypermedia, calendar, wp
 
 ;; This file is part of GNU Emacs.

+ 2 - 2
lisp/org-macs.el

@@ -1,12 +1,12 @@
 ;;; org-macs.el --- Top-level definitions for Org-mode
 
-;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
+;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
 ;;   Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.34trans
+;; Version: 6.35g
 ;;
 ;; This file is part of GNU Emacs.
 ;;

+ 2 - 2
lisp/org-mew.el

@@ -1,11 +1,11 @@
 ;;; org-mew.el --- Support for links to Mew messages from within Org-mode
 
-;; Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+;; Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
 
 ;; Author: Tokuya Kameshima <kames at fa2 dot so-net dot ne dot jp>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.34trans
+;; Version: 6.35g
 
 ;; This file is part of GNU Emacs.
 

+ 2 - 2
lisp/org-mhe.el

@@ -1,12 +1,12 @@
 ;;; org-mhe.el --- Support for links to MH-E messages from within Org-mode
 
-;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
+;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
 ;;   Free Software Foundation, Inc.
 
 ;; Author: Thomas Baumann <thomas dot baumann at ch dot tum dot de>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.34trans
+;; Version: 6.35g
 ;;
 ;; This file is part of GNU Emacs.
 ;;

+ 5 - 2
lisp/org-mobile.el

@@ -1,10 +1,10 @@
 ;;; org-mobile.el --- Code for asymmetric sync with a mobile device
-;; Copyright (C) 2009 Free Software Foundation, Inc.
+;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
 ;;
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.34trans
+;; Version: 6.35g
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -349,6 +349,9 @@ agenda view showing the flagged items."
 		(file-name-directory org-mobile-inbox-for-pull)))
     (error
      "Variable `org-mobile-inbox-for-pull' must point to a file in an existing directory"))
+  (unless (and org-mobile-checksum-binary
+	       (string-match "\\S-" org-mobile-checksum-binary))
+    (error "No executable found to compute checksums"))
   (when org-mobile-use-encryption
     (unless (string-match "\\S-" org-mobile-encryption-password)
       (error

+ 2 - 2
lisp/org-mouse.el

@@ -1,10 +1,10 @@
 ;;; org-mouse.el --- Better mouse support for org-mode
 
-;; Copyright (C) 2006, 2007, 2008, 2009 Free Software Foundation
+;; Copyright (C) 2006, 2007, 2008, 2009, 2010 Free Software Foundation
 ;;
 ;; Author: Piotr Zielinski <piotr dot zielinski at gmail dot com>
 ;; Maintainer: Carsten Dominik <carsten at orgmode dot org>
-;; Version: 6.34trans
+;; Version: 6.35g
 ;;
 ;; This file is part of GNU Emacs.
 ;;

+ 2 - 2
lisp/org-plot.el

@@ -1,11 +1,11 @@
 ;;; org-plot.el --- Support for plotting from Org-mode
 
-;; Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+;; Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
 ;;
 ;; Author: Eric Schulte <schulte dot eric at gmail dot com>
 ;; Keywords: tables, plotting
 ;; Homepage: http://orgmode.org
-;; Version: 6.34trans
+;; Version: 6.35g
 ;;
 ;; This file is part of GNU Emacs.
 ;;

+ 2 - 2
lisp/org-protocol.el

@@ -1,6 +1,6 @@
 ;;; org-protocol.el --- Intercept calls from emacsclient to trigger custom actions.
 ;;
-;; Copyright (C) 2008, 2009
+;; Copyright (C) 2008, 2009, 2010
 ;;          Free Software Foundation, Inc.
 ;;
 ;; Author: Bastien Guerry <bzg AT altern DOT org>
@@ -9,7 +9,7 @@
 ;; Author: Ross Patterson <me AT rpatterson DOT net>
 ;; Maintainer: Sebastian Rose <sebastian_rose AT gmx DOT de>
 ;; Keywords: org, emacsclient, wp
-;; Version: 6.34trans
+;; Version: 6.35g
 
 ;; This file is part of GNU Emacs.
 ;;

+ 5 - 3
lisp/org-publish.el

@@ -1,10 +1,11 @@
 ;;; org-publish.el --- publish related org-mode files as a website
-;; Copyright (C) 2006, 2007, 2008, 2009  Free Software Foundation, Inc.
+;; Copyright (C) 2006, 2007, 2008, 2009, 2010
+;;          Free Software Foundation, Inc.
 
 ;; Author: David O'Toole <dto@gnu.org>
 ;; Maintainer: Carsten Dominik <carsten DOT dominik AT gmail DOT com>
 ;; Keywords: hypermedia, outlines, wp
-;; Version: 6.34trans
+;; Version: 6.35g
 
 ;; This file is part of GNU Emacs.
 ;;
@@ -724,7 +725,8 @@ the project."
 (defvar backend) ; dynamically scoped
 (defun org-publish-aux-preprocess ()
   "Find index entries and write them to an .orgx file."
-  (let (entry index target)
+  (let ((case-fold-search t)
+	entry index target)
     (goto-char (point-min))
     (while
 	(and

+ 2 - 2
lisp/org-remember.el

@@ -1,12 +1,12 @@
 ;;; org-remember.el --- Fast note taking in Org-mode
 
-;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
+;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
 ;;   Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.34trans
+;; Version: 6.35g
 ;;
 ;; This file is part of GNU Emacs.
 ;;

+ 2 - 2
lisp/org-rmail.el

@@ -1,12 +1,12 @@
 ;;; org-rmail.el --- Support for links to Rmail messages from within Org-mode
 
-;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
+;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
 ;;   Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.34trans
+;; Version: 6.35g
 ;;
 ;; This file is part of GNU Emacs.
 ;;

+ 2 - 2
lisp/org-src.el

@@ -1,6 +1,6 @@
 ;;; org-src.el --- Source code examples in Org
 ;;
-;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
+;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
 ;;   Free Software Foundation, Inc.
 ;;
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
@@ -8,7 +8,7 @@
 ;;         Dan Davison <davison at stats dot ox dot ac dot uk>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.34trans
+;; Version: 6.35g
 ;;
 ;; This file is part of GNU Emacs.
 ;;

+ 2 - 2
lisp/org-table.el

@@ -1,12 +1,12 @@
 ;;; org-table.el --- The table editor for Org-mode
 
-;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
+;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
 ;;   Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.34trans
+;; Version: 6.35g
 ;;
 ;; This file is part of GNU Emacs.
 ;;

+ 2 - 2
lisp/org-timer.el

@@ -1,11 +1,11 @@
 ;;; org-timer.el --- The relative timer code for Org-mode
 
-;; Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+;; Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.34trans
+;; Version: 6.35g
 ;;
 ;; This file is part of GNU Emacs.
 ;;

+ 2 - 2
lisp/org-vm.el

@@ -1,12 +1,12 @@
 ;;; org-vm.el --- Support for links to VM messages from within Org-mode
 
-;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
+;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
 ;;   Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.34trans
+;; Version: 6.35g
 ;;
 ;; This file is part of GNU Emacs.
 ;;

+ 2 - 2
lisp/org-w3m.el

@@ -1,11 +1,11 @@
 ;;; org-w3m.el --- Support from copy and paste from w3m to Org-mode
 
-;; Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+;; Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
 
 ;; Author: Andy Stewart <lazycat dot manatee at gmail dot com>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.34trans
+;; Version: 6.35g
 ;;
 ;; This file is part of GNU Emacs.
 ;;

+ 2 - 2
lisp/org-wl.el

@@ -1,12 +1,12 @@
 ;;; org-wl.el --- Support for links to Wanderlust messages from within Org-mode
 
-;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
+;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
 ;;   Free Software Foundation, Inc.
 
 ;; Author: Tokuya Kameshima <kames at fa2 dot so-net dot ne dot jp>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.34trans
+;; Version: 6.35g
 ;;
 ;; This file is part of GNU Emacs.
 ;;

+ 2 - 2
lisp/org-xoxo.el

@@ -1,12 +1,12 @@
 ;;; org-xoxo.el --- XOXO export for Org-mode
 
-;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
+;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
 ;;   Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.34trans
+;; Version: 6.35g
 ;;
 ;; This file is part of GNU Emacs.
 ;;

+ 140 - 59
lisp/org.el

@@ -1,12 +1,12 @@
 ;;; org.el --- Outline-based notes management and organizer
 ;; Carstens outline-mode for keeping track of everything.
-;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
+;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
 ;;   Free Software Foundation, Inc.
 ;;
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.34trans
+;; Version: 6.35g
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -96,7 +96,7 @@
 
 ;;; Version
 
-(defconst org-version "6.34trans"
+(defconst org-version "6.35g"
   "The version number of the file org.el.")
 
 (defun org-version (&optional here)
@@ -2911,6 +2911,8 @@ When nil, just push out a message."
 \\usepackage{amsmath}
 \\usepackage[mathscr]{eucal}
 \\pagestyle{empty}             % do not remove
+\[PACKAGES]
+\[DEFAULT-PACKAGES]
 % The settings below are copied from fullpage.sty
 \\setlength{\\textwidth}{\\paperwidth}
 \\addtolength{\\textwidth}{-3cm}
@@ -2926,7 +2928,10 @@ When nil, just push out a message."
 \\addtolength{\\topmargin}{-2.54cm}"
   "The document header used for processing LaTeX fragments.
 It is imperative that this header make sure that no page number
-appears on the page."
+appears on the page.  The package defined in the variables
+`org-export-latex-default-packages-alist' and `org-export-latex-packages-alist'
+will either replace the placeholder \"[PACKAGES]\" in this header, or they
+will be appended."
   :group 'org-latex
   :type 'string)
 
@@ -2936,43 +2941,67 @@ appears on the page."
 ;; when formatting latex fragments.  Originally it was part of the
 ;; LaTeX exporter, which is why the name includes "export".
 (defcustom org-export-latex-default-packages-alist
-  '(("AUTO" . "inputenc")
-    ("T1"   . "fontenc")
-    (""     . "graphicx")
-    (""     . "longtable")
-    (""     . "float")
-    (""     . "wrapfig")
-    (""     . "soul")
-    (""     . "t1enc")
-    (""     . "textcomp")
-    (""     . "marvosym")
-    (""     . "wasysym")
-    (""     . "latexsym")
-    (""     . "amssymb")
-    (""     . "hyperref"))
-  "Alist of default packages to be inserted in the header. DON'T CHANGE THIS.
-Unless abslutely necessary that is.
-All the packages in this list are needed by one part or another of Org-mode
-to function properly.  Therefore you should, not modify this variable unless
-you know what you are doing.  The one reason to change it anyway is that
-you might be loading some other package that conflicts with one of the default
-packages.
-Each cell is of the format \( \"options\" . \"package\" \)."
+  '(("AUTO" "inputenc")
+    ("T1"   "fontenc")
+    (""     "fixltx2e")
+    (""     "graphicx")
+    (""     "longtable")
+    (""     "float")
+    (""     "wrapfig")
+    (""     "soul")
+    (""     "t1enc")
+    (""     "textcomp")
+    (""     "marvosym")
+    (""     "wasysym")
+    (""     "latexsym")
+    (""     "amssymb")
+    (""     "microtype")
+    (""     "hyperref")
+    "\\tolerance=1000"
+    )
+  "Alist of default packages to be inserted in the header.
+Change this only if one of the packages here causes an incompatibility
+with another package you are using.
+The packages in this list are needed by one part or another of Org-mode
+to function properly.  
+
+- inputenc, fontenc, t1enc: for basic font and character selection
+- textcomp, marvosymb, wasysym, latexsym, amssym: for various symbols used
+  for interpreting the entities in `org-entities'.  You can skip some of these
+  packages if you don't use any of the symbols in it.
+- graphicx: for including images
+- float, wrapfig: for figure placement
+- longtable: for long tables
+- hyperref: for cross references
+
+Therefore you should not modify this variable unless you know what you
+are doing.  The one reason to change it anyway is that you might be loading
+some other package that conflicts with one of the default packages.
+Each cell is of the format \( \"options\" \"package\" \)."
   :group 'org-export-latex
   :type '(repeat
-	  (list
-	   (string :tag "options")
-	   (string :tag "package"))))
+	  (choice 
+	   (string :tag "A line of LaTeX")
+	   (list :tag "options/package pair"
+		 (string :tag "options")
+		 (string :tag "package")))))
 
 (defcustom org-export-latex-packages-alist nil
-  "Alist of packages to be inserted in the header.
+  "Alist of packages to be inserted in every LaTeX the header.
 These will be inserted after `org-export-latex-default-packages-alist'.
-Each cell is of the format \( \"options\" . \"package\" \)."
+Each cell is of the format \( \"options\" \"package\" \).
+Make sure that you only lis packages here which:
+- you want in every file
+- do not conflict with the default packages in
+  `org-export-latex-default-packages-alist'
+- do not conflict with the setup in `org-format-latex-header'."
   :group 'org-export-latex
   :type '(repeat
-	  (list
-	   (string :tag "options")
-	   (string :tag "package"))))
+	  (choice 
+	   (string :tag "A line of LaTeX")
+	   (list :tag "options/package pair"
+		 (string :tag "options")
+		 (string :tag "package")))))
 
 (defgroup org-appearance nil
   "Settings for Org-mode appearance."
@@ -8181,7 +8210,7 @@ Use TAB to complete link prefixes, then RET for type-specific completion support
 		    (if (nth 1 x) (concat (car x) " (" (nth 1 x) ")") (car x)))
 		  (reverse org-stored-links) "\n"))))
       (let ((cw (selected-window)))
-	(select-window (get-buffer-window "*Org Links*"))
+	(select-window (get-buffer-window "*Org Links*" 'visible))
 	(setq truncate-lines t)
 	(unless (pos-visible-in-window-p (point-max))
 	  (org-fit-window-to-buffer))
@@ -9143,13 +9172,19 @@ If the file does not exist, an error is thrown."
 		    (and dirp (cdr (assoc 'directory apps)))
 		    ;; if we find a match in org-file-apps, store the match
 		    ;; data for later
-		    (let ((match (assoc-default dlink (org-apps-regexp-alist
-						       apps a-m-a-p)
-						'string-match)))
-		      (if match
+		    (let* ((re-list1 (org-apps-regexp-alist apps nil))
+			   (re-list2 
+			    (if a-m-a-p
+				(org-apps-regexp-alist apps a-m-a-p)
+			      re-list1))
+			   (private-match
+			    (assoc-default dlink re-list1 'string-match))
+			   (general-match
+			    (assoc-default dfile re-list2 'string-match)))
+		      (if private-match
 			  (progn (setq link-match-data (match-data))
-				 match)
-			nil))
+				 private-match)
+			general-match))
 		    (cdr (assoc ext apps))
 		    (cdr (assoc t apps))))))
     (when (eq cmd 'system)
@@ -14931,6 +14966,8 @@ When a buffer is unmodified, it is just killed.  When modified, it is saved
 		(add-text-properties
 		 (match-beginning 0) (org-end-of-subtree t) pc)))
 	    (set-buffer-modified-p bmp)))))
+    (setq org-todo-keywords-for-agenda
+          (org-uniquify org-todo-keywords-for-agenda))
     (setq org-todo-keyword-alist-for-agenda
 	  (org-uniquify org-todo-keyword-alist-for-agenda)
 	  org-tag-alist-for-agenda (org-uniquify org-tag-alist-for-agenda))))
@@ -15241,24 +15278,14 @@ Some of the options can be changed using the variable
     (if (eq fg 'default) (setq fg (org-dvipng-color :foreground)))
     (if (eq bg 'default) (setq bg (org-dvipng-color :background)))
     (with-temp-file texfile
-      (insert org-format-latex-header
-	      (if (or org-export-latex-default-packages-alist
-		      org-export-latex-packages-alist)
-		  (concat "\n"
-			  (mapconcat (lambda(p)
-				       (if (equal "" (car p))
-					   (format "\\usepackage{%s}" (cadr p))
-					 (format "\\usepackage[%s]{%s}"
-						 (car p) (cadr p))))
-				     (append
-				      org-export-latex-default-packages-alist
-				      org-export-latex-packages-alist)
-				     "\n"))
-		"")
-	      (if org-format-latex-header-extra
-		  (concat "\n" org-format-latex-header-extra)
-		"")
-	      "\n\\begin{document}\n" string "\n\\end{document}\n"))
+      (insert (org-splice-latex-header
+	       org-format-latex-header
+	       org-export-latex-default-packages-alist
+	       org-export-latex-packages-alist
+	       org-format-latex-header-extra))
+      (insert "\n\\begin{document}\n" string "\n\\end{document}\n")
+      (require 'org-latex)
+      (org-export-latex-fix-inputenc))
     (let ((dir default-directory))
       (condition-case nil
 	  (progn
@@ -15288,6 +15315,60 @@ Some of the options can be changed using the variable
 	      (delete-file (concat texfilebase e)))
 	pngfile))))
 
+(defun org-splice-latex-header (tpl def-pkg pkg &optional extra)
+  "Fill a LaTeX header template TPL.
+In the template, the following place holders will be recognized:
+
+ [DEFAULT-PACKAGES]      \\usepackage statements for DEF-PKG
+ [NO-DEFAULT-PACKAGES]   do not include DEF-PKG
+ [PACKAGES]              \\usepackage statements for PKG 
+ [NO-PACKAGES]           do not include PKG
+ [EXTRA]                 the string EXTRA
+ [NO-EXTRA]              do not include EXTRA
+
+For backward compatibility, if both the positive and the negative place
+holder is missing, the positive one (without the \"NO-\") will be
+assumed to be present at the end of the template.
+DEF-PKG and PKG are assumed to be alists of options/packagename lists.
+EXTRA is a string."
+  (let (rpl (end ""))
+    (if (string-match "^[ \t]*\\[\\(NO-\\)?DEFAULT-PACKAGES\\][ \t]*\n?" tpl)
+	(setq rpl (if (or (match-end 1) (not def-pkg))
+		      "" (org-latex-packages-to-string def-pkg t))
+	      tpl (replace-match rpl t t tpl))
+      (if def-pkg (setq end (org-latex-packages-to-string def-pkg))))
+    
+    (if (string-match "\\[\\(NO-\\)?PACKAGES\\][ \t]*\n?" tpl)
+	(setq rpl (if (or (match-end 1) (not pkg))
+		      "" (org-latex-packages-to-string pkg t))
+	      tpl (replace-match rpl t t tpl))
+      (if pkg (setq end (concat end "\n" (org-latex-packages-to-string pkg)))))
+
+    (if (string-match "\\[\\(NO-\\)?EXTRA\\][ \t]*\n?" tpl)
+	(setq rpl (if (or (match-end 1) (not extra))
+		      "" (concat extra "\n"))
+	      tpl (replace-match rpl t t tpl))
+      (if (and extra (string-match "\\S-" extra))
+	  (setq end (concat end "\n" extra))))
+
+    (if (string-match "\\S-" end)
+	(concat tpl "\n" end)
+      tpl)))
+
+(defun org-latex-packages-to-string (pkg &optional newline)
+  "Turn an alist of packages into a string with the \\usepackage macros."
+  (setq pkg (mapconcat (lambda(p)
+			 (cond
+			  ((stringp p) p)
+			  ((equal "" (car p))
+			   (format "\\usepackage{%s}" (cadr p)))
+			  (t
+			   (format "\\usepackage[%s]{%s}"
+				   (car p) (cadr p)))))
+		       pkg
+		       "\n"))
+  (if newline (concat pkg "\n") pkg))
+
 (defun org-dvipng-color (attr)
   "Return an rgb color specification for dvipng."
   (apply 'format "rgb %s %s %s"