Forráskód Böngészése

Merge branch 'master' of orgmode.org:org-mode

Luis Anaya 12 éve
szülő
commit
5da2745fb8

+ 2 - 3
contrib/lisp/org-e-html.el

@@ -2835,10 +2835,9 @@ contextual information."
   				   (org-export-solidify-link-text label)))))))
        ;; Remove last blank line.
        (setq contents (substring contents 0 -1))
-       ;; FIXME: splice
-       (format "<table%s>\n<caption>%s</caption>\n%s\n%s\n</table>"
+       (format "<table%s>\n%s\n%s\n%s\n</table>"
   	       table-attributes
-  	       (or caption "")
+	       (if (not caption) "" (format "<caption>%s</caption>" caption))
   	       (funcall table-column-specs table info)
   	       contents)))))
 

+ 1 - 1
contrib/lisp/org-e-odt.el

@@ -6,7 +6,7 @@
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
 
-;; This file is part of GNU Emacs.
+;; This file is not part of GNU Emacs.
 
 ;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by

+ 1 - 1
contrib/lisp/org-e-publish.el

@@ -5,7 +5,7 @@
 ;; Maintainer: Carsten Dominik <carsten DOT dominik AT gmail DOT com>
 ;; Keywords: hypermedia, outlines, wp
 
-;; This file is part of GNU Emacs.
+;; This file is not part of GNU Emacs.
 ;;
 ;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by

+ 96 - 156
contrib/lisp/org-e-texinfo.el

@@ -1,8 +1,11 @@
 ;;; org-e-texinfo.el --- Texinfo Back-End For Org Export Engine
 
+;; Copyright (C) 2012  Jonathan Leech-Pepin
 ;; Author: Jonathan Leech-Pepin <jonathan.leechpepin at gmail dot com>
 ;; Keywords: outlines, hypermedia, calendar, wp
-
+;;
+;; This file is not part of GNU Emacs.
+;;
 ;; This program is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
 ;; the Free Software Foundation, either version 3 of the License, or
@@ -36,7 +39,7 @@
 ;; To include inline code snippets (for example for generating @kbd{}
 ;; and @key{} commands), the following export-snippet keys are
 ;; accepted:
-;; 
+;;
 ;;     info
 ;;     e-info
 ;;     e-texinfo
@@ -49,8 +52,7 @@
 ;;                 '("e-texinfo" . "e-texinfo"))
 ;;    (add-to-list 'org-export-snippet-translation-alist
 ;;                 '("info" . "e-texinfo"))
-;; 
-
+;;
 
 ;;; Code:
 
@@ -140,7 +142,6 @@ and title information beyond the initial variable.")
   "Alist between filters keywords and back-end specific filters.
   See `org-export-filters-alist' for more information")
 
-
 
 ;;; Internal Variables
 
@@ -155,8 +156,7 @@ and title information beyond the initial variable.")
   :tag "Org Export Texinfo"
   :group 'org-export)
 
-
-;;;; Preamble
+;;; Preamble
 
 (defcustom org-e-texinfo-filename nil
   "Default filename for texinfo output."
@@ -208,8 +208,7 @@ a format string in which the section title will be added."
 			       (string :tag "unnumbered"))
 			 (function :tag "Hook computing sectioning"))))))
 
-
-;;;; Headline
+;;; Headline
 
 (defcustom org-e-texinfo-format-headline-function nil
   "Function to format headline text.
@@ -240,11 +239,11 @@ order to reproduce the default set-up:
   :type 'function)
 
 
-;;;; Footnotes
+;;; Footnotes
 ;;
 ;; Footnotes are inserted directly
 
-;;;; Timestamps
+;;; Timestamps
 
 (defcustom org-e-texinfo-active-timestamp-format "@emph{%s}"
   "A printf format string to be applied to active timestamps."
@@ -261,15 +260,14 @@ order to reproduce the default set-up:
   :group 'org-export-e-texinfo
   :type 'string)
 
-;;;; Links
+;;; Links
 
 (defcustom org-e-texinfo-link-with-unknown-path-format "@indicateurl{%s}"
   "Format string for links with unknown path type."
   :group 'org-export-e-texinfo
   :type 'string)
 
-
-;;;; Tables
+;;; Tables
 
 (defcustom org-e-texinfo-tables-verbatim nil
   "When non-nil, tables are exported verbatim."
@@ -290,13 +288,13 @@ When nil, no transformation is made."
 (defcustom org-e-texinfo-def-table-markup "@samp"
   "Default setting for @table environments.")
 
-;;;; Text markup
+;;; Text markup
 
 (defcustom org-e-texinfo-text-markup-alist '((bold . "@strong{%s}")
-					   (code . code)
-					   (italic . "@emph{%s}")
-					   (verbatim . verb)
-					   (comment . "@c %s"))
+					     (code . code)
+					     (italic . "@emph{%s}")
+					     (verbatim . verb)
+					     (comment . "@c %s"))
   "Alist of Texinfo expressions to convert text markup.
 
 The key must be a symbol among `bold', `italic' and `comment'.
@@ -314,8 +312,7 @@ returned as-is."
   :type 'alist
   :options '(bold code italic verbatim comment))
 
-
-;;;; Drawers
+;;; Drawers
 
 (defcustom org-e-texinfo-format-drawer-function nil
   "Function called to format a drawer in Texinfo code.
@@ -335,8 +332,7 @@ in order to mimic default behaviour:
   :group 'org-export-e-texinfo
   :type 'function)
 
-
-;;;; Inlinetasks
+;;; Inlinetasks
 
 (defcustom org-e-texinfo-format-inlinetask-function nil
   "Function called to format an inlinetask in Texinfo code.
@@ -372,12 +368,11 @@ in order to mimic default behaviour:
   :group 'org-export-e-texinfo
   :type 'function)
 
-
-;;;; Src blocks
+;;; Src blocks
 ;;
 ;; Src Blocks are example blocks, except for LISP
 
-;;;; Plain text
+;;; Plain text
 
 (defcustom org-e-texinfo-quotes
   '(("quotes"
@@ -407,8 +402,7 @@ string defines the replacement string for this quote."
 		(string :tag "Regexp for char before")
 		(string :tag "Replacement quote     "))))
 
-
-;;;; Compilation
+;;; Compilation
 
 (defcustom org-e-texinfo-info-process
   '("makeinfo %f")
@@ -504,7 +498,7 @@ See `org-e-texinfo-text-markup-alist' for details."
      ;; Else use format string.
      (t (format fmt text)))))
 
-;;;; Menu creation
+;;; Menu creation
 
 (defun org-e-texinfo--build-menu (tree level info &optional detailed)
   "Create the @menu/@end menu information from TREE at headline
@@ -633,15 +627,13 @@ of the longest menu entry."
                           (concat "* " title ":: "
                                   (make-string
 				   (- (+ 3 max-length) length)
-                                               ?\s)
+				   ?\s)
                                   (if desc
                                       (concat desc)))
                         (concat "\n" title "\n"))))
 		  text-menu))
     output))
 
-
-
 ;;; Template
 
 (defun org-e-texinfo-template (contents info)
@@ -681,7 +673,7 @@ holding export options."
 	 (concat "\n"
 		 texinfo-header
 		 "\n"))
-     
+
      "@c %**end of header\n"
      "@finalout\n"
      "\n\n"
@@ -728,7 +720,7 @@ holding export options."
      "@top " title " Manual\n"
      "@insertcopying\n"
      "@end ifnottex\n\n"
-     
+
      ;; Menu
      "@menu\n"
      (org-e-texinfo-make-menu info 'main)
@@ -741,7 +733,7 @@ holding export options."
      "@end detailmenu\n"
      "@end menu\n"
      "\n\n"
-     
+
      ;; Document's body.
      contents
      "\n"
@@ -759,12 +751,11 @@ holding export options."
 
 ;;; Transcode Functions
 
-;;;; Babel Call
+;;; Babel Call
 ;;
 ;; Babel Calls are ignored.
 
-
-;;;; Bold
+;;; Bold
 
 (defun org-e-texinfo-bold (bold contents info)
   "Transcode BOLD from Org to Texinfo.
@@ -772,13 +763,11 @@ CONTENTS is the text with bold markup.  INFO is a plist holding
 contextual information."
   (org-e-texinfo--text-markup contents 'bold))
 
-
-;;;; Center Block
+;;; Center Block
 ;;
 ;; Center blocks are ignored
 
-
-;;;; Clock
+;;; Clock
 
 (defun org-e-texinfo-clock (clock contents info)
   "Transcode a CLOCK element from Org to Texinfo.
@@ -793,8 +782,7 @@ information."
 		     (and time (format " (%s)" time)))))
    "@*"))
 
-
-;;;; Code
+;;; Code
 
 (defun org-e-texinfo-code (code contents info)
   "Transcode a CODE object from Org to Texinfo.
@@ -802,7 +790,7 @@ CONTENTS is nil.  INFO is a plist used as a communication
 channel."
   (org-e-texinfo--text-markup (org-element-property :value code) 'code))
 
-;;;; Comment
+;;; Comment
 
 (defun org-e-texinfo-comment (comment contents info)
   "Transcode a COMMENT object from Org to Texinfo.
@@ -810,7 +798,7 @@ CONTENTS is the text in the comment.  INFO is a plist holding
 contextual information."
   (org-e-texinfo--text-markup (org-element-property :value comment) 'comment))
 
-;;;; Comment Block
+;;; Comment Block
 
 (defun org-e-texinfo-comment-block (comment-block contents info)
   "Transcode a COMMENT-BLOCK object from Org to Texinfo.
@@ -818,7 +806,7 @@ CONTENTS is the text within the block.  INFO is a plist holding
 contextual information."
   (format "@ignore\n%s@end ignore" (org-element-property :value comment-block)))
 
-;;;; Drawer
+;;; Drawer
 
 (defun org-e-texinfo-drawer (drawer contents info)
   "Transcode a DRAWER element from Org to Texinfo.
@@ -833,8 +821,7 @@ holding contextual information."
 		   contents)))
     output))
 
-
-;;;; Dynamic Block
+;;; Dynamic Block
 
 (defun org-e-texinfo-dynamic-block (dynamic-block contents info)
   "Transcode a DYNAMIC-BLOCK element from Org to Texinfo.
@@ -842,8 +829,7 @@ CONTENTS holds the contents of the block.  INFO is a plist
 holding contextual information.  See `org-export-data'."
   contents)
 
-
-;;;; Entity
+;;; Entity
 
 (defun org-e-texinfo-entity (entity contents info)
   "Transcode an ENTITY object from Org to Texinfo.
@@ -852,8 +838,7 @@ contextual information."
   (let ((ent (org-element-property :latex entity)))
     (if (org-element-property :latex-math-p entity) (format "@math{%s}" ent) ent)))
 
-
-;;;; Example Block
+;;; Example Block
 
 (defun org-e-texinfo-example-block (example-block contents info)
   "Transcode an EXAMPLE-BLOCK element from Org to Texinfo.
@@ -862,8 +847,7 @@ information."
   (format "@verbatim\n%s@end verbatim"
 	  (org-export-format-code-default example-block info)))
 
-
-;;;; Export Block
+;;; Export Block
 
 (defun org-e-texinfo-export-block (export-block contents info)
   "Transcode a EXPORT-BLOCK element from Org to Texinfo.
@@ -871,8 +855,7 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
   (when (string= (org-element-property :type export-block) "TEXINFO")
     (org-remove-indentation (org-element-property :value export-block))))
 
-
-;;;; Export Snippet
+;;; Export Snippet
 
 (defun org-e-texinfo-export-snippet (export-snippet contents info)
   "Transcode a EXPORT-SNIPPET object from Org to Texinfo.
@@ -880,8 +863,7 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
   (when (eq (org-export-snippet-backend export-snippet) 'e-texinfo)
     (org-element-property :value export-snippet)))
 
-
-;;;; Fixed Width
+;;; Fixed Width
 
 (defun org-e-texinfo-fixed-width (fixed-width contents info)
   "Transcode a FIXED-WIDTH element from Org to Texinfo.
@@ -890,13 +872,11 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
 	  (org-remove-indentation
 	   (org-element-property :value fixed-width))))
 
-
-;;;; Footnote Definition
+;;; Footnote Definition
 ;;
 ;; Footnote Definitions are ignored.
 
-
-;;;; Footnote Reference
+;;; Footnote Reference
 ;;
 
 (defun org-e-texinfo-footnote-reference (footnote contents info)
@@ -908,7 +888,7 @@ plist holding contextual information."
     (format "@footnote{%s}"
 	    (org-trim (org-export-data def info)))))
 
-;;;; Headline
+;;; Headline
 
 (defun org-e-texinfo-headline (headline contents info)
   "Transcode an HEADLINE element from Org to Texinfo.
@@ -1016,7 +996,7 @@ holding contextual information."
      (index
       (format
        section-fmt full-text
-       (concat pre-blanks contents "\n" 
+       (concat pre-blanks contents "\n"
 	       (if (member index '("cp" "fn" "ky" "pg" "tp" "vr"))
 		   (concat "@printindex " index)))))
      ;; Case 4: This is a deep sub-tree: export it as a list item.
@@ -1068,17 +1048,15 @@ holding contextual information."
 	(format (replace-regexp-in-string "%]" "%%]" section-fmt) full-text
 		(concat pre-blanks contents))))))))
 
-
-;;;; Horizontal Rule
+;;; Horizontal Rule
 ;;
 ;; Horizontal rules are ignored
 
-;;;; Inline Babel Call
+;;; Inline Babel Call
 ;;
 ;; Inline Babel Calls are ignored.
 
-
-;;;; Inline Src Block
+;;; Inline Src Block
 
 (defun org-e-texinfo-inline-src-block (inline-src-block contents info)
   "Transcode an INLINE-SRC-BLOCK element from Org to Texinfo.
@@ -1088,8 +1066,7 @@ contextual information."
 	 (separator (org-e-texinfo--find-verb-separator code)))
     (concat "@verb{" separator code separator "}")))
 
-
-;;;; Inlinetask
+;;; Inlinetask
 
 (defun org-e-texinfo-inlinetask (inlinetask contents info)
   "Transcode an INLINETASK element from Org to Texinfo.
@@ -1122,8 +1099,7 @@ holding contextual information."
 			"\n")
 		full-title contents)))))
 
-
-;;;; Italic
+;;; Italic
 
 (defun org-e-texinfo-italic (italic contents info)
   "Transcode ITALIC from Org to Texinfo.
@@ -1131,7 +1107,7 @@ CONTENTS is the text with italic markup.  INFO is a plist holding
 contextual information."
   (org-e-texinfo--text-markup contents 'italic))
 
-;;;; Item
+;;; Item
 
 (defun org-e-texinfo-item (item contents info)
   "Transcode an ITEM element from Org to Texinfo.
@@ -1139,11 +1115,10 @@ CONTENTS holds the contents of the item.  INFO is a plist holding
 contextual information."
   (let* ((tag (org-element-property :tag item))
 	 (desc (org-export-data tag info)))
-   (concat "\n@item " (if tag desc) "\n"
-	   (org-trim contents) "\n")))
-
+    (concat "\n@item " (if tag desc) "\n"
+	    (org-trim contents) "\n")))
 
-;;;; Keyword
+;;; Keyword
 
 (defun org-e-texinfo-keyword (keyword contents info)
   "Transcode a KEYWORD element from Org to Texinfo.
@@ -1157,29 +1132,24 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
      ((string= key "KINDEX") (format "@kindex %s" value))
      ((string= key "PINDEX") (format "@pindex %s" value))
      ((string= key "TINDEX") (format "@tindex %s" value))
-     ((string= key "VINDEX") (format "@vindex %s" value))
-     )))
-
+     ((string= key "VINDEX") (format "@vindex %s" value)))))
 
-;;;; Latex Environment
+;;; Latex Environment
 ;;
 ;; Latex environments are ignored
 
-
-;;;; Latex Fragment
+;;; Latex Fragment
 ;;
 ;; Latex fragments are ignored.
 
-
-;;;; Line Break
+;;; Line Break
 
 (defun org-e-texinfo-line-break (line-break contents info)
   "Transcode a LINE-BREAK object from Org to Texinfo.
 CONTENTS is nil.  INFO is a plist holding contextual information."
   "@*")
 
-
-;;;; Link
+;;; Link
 
 (defun org-e-texinfo-link (link desc info)
   "Transcode a LINK object from Org to Texinfo.
@@ -1204,7 +1174,7 @@ INFO is a plist holding contextual information.  See
 	 (email (if (string= type "mailto")
 		    (let ((text (replace-regexp-in-string
 				 "@" "@@" raw-path)))
-		     (concat text (if desc (concat "," desc))))))
+		      (concat text (if desc (concat "," desc))))))
 	 protocol)
     (cond
      ;; Links pointing to an headline: Find destination and build
@@ -1251,8 +1221,7 @@ INFO is a plist holding contextual information.  See
      ;; No path, only description.  Try to do something useful.
      (t (format org-e-texinfo-link-with-unknown-path-format desc)))))
 
-
-;;;; Macro
+;;; Macro
 
 (defun org-e-texinfo-macro (macro contents info)
   "Transcode a MACRO element from Org to Texinfo.
@@ -1260,8 +1229,7 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
   ;; Use available tools.
   (org-export-expand-macro macro info))
 
-
-;;;; Menu
+;;; Menu
 
 (defun org-e-texinfo-make-menu (info level)
   "Create the menu for inclusion in the texifo document.
@@ -1291,8 +1259,7 @@ are generated directly."
      ;; Otherwise do nothing
      (t))))
 
-
-;;;; Paragraph
+;;; Paragraph
 
 (defun org-e-texinfo-paragraph (paragraph contents info)
   "Transcode a PARAGRAPH element from Org to Texinfo.
@@ -1300,8 +1267,7 @@ CONTENTS is the contents of the paragraph, as a string.  INFO is
 the plist used as a communication channel."
   contents)
 
-
-;;;; Plain List
+;;; Plain List
 
 (defun org-e-texinfo-plain-list (plain-list contents info)
   "Transcode a PLAIN-LIST element from Org to Texinfo.
@@ -1324,12 +1290,11 @@ contextual information."
     (format "@%s%s\n@end %s"
 	    (if (eq type 'descriptive)
 		(concat list-type " " indic)
-	     list-type)
+	      list-type)
 	    contents
 	    list-type)))
 
-
-;;;; Plain Text
+;;; Plain Text
 
 (defun org-e-texinfo-plain-text (text info)
   "Transcode a TEXT string from Org to Texinfo.
@@ -1359,8 +1324,7 @@ contextual information."
   ;; Return value.
   text)
 
-
-;;;; Planning
+;;; Planning
 
 (defun org-e-texinfo-planning (planning contents info)
   "Transcode a PLANNING element from Org to Texinfo.
@@ -1393,8 +1357,7 @@ information."
     " ")
    "@*"))
 
-
-;;;; Property Drawer
+;;; Property Drawer
 
 (defun org-e-texinfo-property-drawer (property-drawer contents info)
   "Transcode a PROPERTY-DRAWER element from Org to Texinfo.
@@ -1404,24 +1367,19 @@ information."
   ;; lines nonetheless.
   "")
 
-
-;;;; Quote Block
+;;; Quote Block
 
 (defun org-e-texinfo-quote-block (quote-block contents info)
   "Transcode a QUOTE-BLOCK element from Org to Texinfo.
 CONTENTS holds the contents of the block.  INFO is a plist
 holding contextual information."
-  
   (let* ((title (org-element-property :name quote-block))
 	 (start-quote (concat "@quotation"
-
 			      (if title
-				 (format " %s" title)))))
-    
+				  (format " %s" title)))))
     (format "%s\n%s@end quotation" start-quote contents)))
 
-
-;;;; Quote Section
+;;; Quote Section
 
 (defun org-e-texinfo-quote-section (quote-section contents info)
   "Transcode a QUOTE-SECTION element from Org to Texinfo.
@@ -1430,8 +1388,7 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
 		(org-element-property :value quote-section))))
     (when value (format "@verbatim\n%s@end verbatim" value))))
 
-
-;;;; Radio Target
+;;; Radio Target
 
 (defun org-e-texinfo-radio-target (radio-target text info)
   "Transcode a RADIO-TARGET object from Org to Texinfo.
@@ -1442,8 +1399,7 @@ contextual information."
 	   (org-element-property :value radio-target))
 	  text))
 
-
-;;;; Section
+;;; Section
 
 (defun org-e-texinfo-section (section contents info)
   "Transcode a SECTION element from Org to Texinfo.
@@ -1451,12 +1407,11 @@ CONTENTS holds the contents of the section.  INFO is a plist
 holding contextual information."
   contents)
 
-
-;;;; Special Block
+;;; Special Block
 ;;
 ;; Are ignored at the moment
 
-;;;; Src Block
+;;; Src Block
 
 (defun org-e-texinfo-src-block (src-block contents info)
   "Transcode a SRC-BLOCK element from Org to Texinfo.
@@ -1474,21 +1429,18 @@ contextual information."
       (format "@example\n%s\n@end example"
 	      (org-export-format-code-default src-block info))))))
 
-
-;;;; Statistics Cookie
+;;; Statistics Cookie
 
 (defun org-e-texinfo-statistics-cookie (statistics-cookie contents info)
   "Transcode a STATISTICS-COOKIE object from Org to Texinfo.
 CONTENTS is nil.  INFO is a plist holding contextual information."
   (org-element-property :value statistics-cookie))
 
-
-;;;; Strike-Through
+;;; Strike-Through
 ;;
 ;; Strikethrough is ignored
 
-
-;;;; Subscript
+;;; Subscript
 
 (defun org-e-texinfo-subscript (subscript contents info)
   "Transcode a SUBSCRIPT object from Org to Texinfo.
@@ -1496,8 +1448,7 @@ CONTENTS is the contents of the object.  INFO is a plist holding
 contextual information."
   (format "@math{_%s}" contents))
 
-
-;;;; Superscript
+;;; Superscript
 
 (defun org-e-texinfo-superscript (superscript contents info)
   "Transcode a SUPERSCRIPT object from Org to Texinfo.
@@ -1505,8 +1456,7 @@ CONTENTS is the contents of the object.  INFO is a plist holding
 contextual information."
   (format "@math{^%s}" contents))
 
-
-;;;; Table
+;;; Table
 ;;
 ;; `org-e-texinfo-table' is the entry point for table transcoding.  It
 ;; takes care of tables with a "verbatim" attribute.  Otherwise, it
@@ -1552,19 +1502,18 @@ a communication channel."
 	 cells counts)
     (loop for row in collected do
 	  (push (mapcar (lambda (ref)
-		     (let* ((start (org-element-property :contents-begin ref))
-			    (end (org-element-property :contents-end ref))
-			    (length (- end start)))
-		       length)) row) cells))
+			  (let* ((start (org-element-property :contents-begin ref))
+				 (end (org-element-property :contents-end ref))
+				 (length (- end start)))
+			    length)) row) cells))
     (setq cells (remove-if #'null cells))
     (push (loop for count from 0 to (- number-cells 1) collect
-		   (loop for item in cells collect
-			 (nth count item))) counts)
+		(loop for item in cells collect
+		      (nth count item))) counts)
     (mapconcat '(lambda (size)
 		  (make-string size ?a)) (mapcar (lambda (ref)
-				   (apply 'max `,@ref)) (car counts))
-	       "} {")
-  ))
+						   (apply 'max `,@ref)) (car counts))
+		  "} {")))
 
 (defun org-e-texinfo-table--org-table (table contents info)
   "Return appropriate Texinfo code for an Org table.
@@ -1597,8 +1546,7 @@ This function assumes TABLE has `org' as its `:type' attribute."
 Rather than return an invalid table, nothing is returned."
   'nil)
 
-
-;;;; Table Cell
+;;; Table Cell
 
 (defun org-e-texinfo-table-cell (table-cell contents info)
   "Transcode a TABLE-CELL element from Org to Texinfo.
@@ -1615,8 +1563,7 @@ a communication channel."
 	    contents)
 	  (when (org-export-get-next-element table-cell info) "\n@tab ")))
 
-
-;;;; Table Row
+;;; Table Row
 
 (defun org-e-texinfo-table-row (table-row contents info)
   "Transcode a TABLE-ROW element from Org to Texinfo.
@@ -1624,11 +1571,10 @@ CONTENTS is the contents of the row.  INFO is a plist used as
 a communication channel."
   ;; Rules are ignored since table separators are deduced from
   ;; borders of the current row.
-  (when (eq (org-element-property :type table-row) 'standard) 
+  (when (eq (org-element-property :type table-row) 'standard)
     (concat "@item " contents "\n")))
 
-
-;;;; Target
+;;; Target
 
 (defun org-e-texinfo-target (target contents info)
   "Transcode a TARGET object from Org to Texinfo.
@@ -1637,8 +1583,7 @@ information."
   (format "@anchor{%s}"
 	  (org-export-solidify-link-text (org-element-property :value target))))
 
-
-;;;; Timestamp
+;;; Timestamp
 
 (defun org-e-texinfo-timestamp (timestamp contents info)
   "Transcode a TIMESTAMP object from Org to Texinfo.
@@ -1652,13 +1597,11 @@ information."
 	   (format org-e-texinfo-inactive-timestamp-format value))
 	  (t (format org-e-texinfo-diary-timestamp-format value)))))
 
-
-;;;; Underline
+;;; Underline
 ;;
 ;; Underline is ignored
 
-
-;;;; Verbatim
+;;; Verbatim
 
 (defun org-e-texinfo-verbatim (verbatim contents info)
   "Transcode a VERBATIM object from Org to Texinfo.
@@ -1666,8 +1609,7 @@ CONTENTS is nil.  INFO is a plist used as a communication
 channel."
   (org-e-texinfo--text-markup (org-element-property :value verbatim) 'verbatim))
 
-
-;;;; Verse Block
+;;; Verse Block
 
 (defun org-e-texinfo-verse-block (verse-block contents info)
   "Transcode a VERSE-BLOCK element from Org to Texinfo.
@@ -1688,7 +1630,6 @@ contextual information."
 	(setq contents (replace-match new-str nil t contents))))
     (format "\\begin{verse}\n%s\\end{verse}" contents)))
 
-
 
 ;;; Interactive functions
 
@@ -1843,6 +1784,5 @@ none."
 	    (setq errors (concat errors " [unexpected error]")))
 	  (and (org-string-nw-p errors) (org-trim errors)))))))
 
-
 (provide 'org-e-texinfo)
 ;;; org-e-texinfo.el ends here

+ 11 - 6
contrib/lisp/org-export.el

@@ -138,6 +138,7 @@
     (:with-entities nil "e" org-export-with-entities)
     (:with-fixed-width nil ":" org-export-with-fixed-width)
     (:with-footnotes nil "f" org-export-with-footnotes)
+    (:with-inlinetasks nil "inline" org-export-with-inlinetasks)
     (:with-plannings nil "p" org-export-with-planning)
     (:with-priority nil "pri" org-export-with-priority)
     (:with-special-strings nil "-" org-export-with-special-strings)
@@ -405,9 +406,7 @@ e.g. \"f:nil\"."
 (defcustom org-export-headline-levels 3
   "The last level which is still exported as a headline.
 
-Inferior levels will produce itemize lists when exported.  Note
-that a numeric prefix argument to an exporter function overrides
-this setting.
+Inferior levels will produce itemize lists when exported.
 
 This option can also be set with the #+OPTIONS line, e.g. \"H:2\"."
   :group 'org-export-general
@@ -444,6 +443,13 @@ e.g. \"e:nil\"."
   :group 'org-export-general
   :type 'boolean)
 
+(defcustom org-export-with-inlinetasks t
+  "Non-nil means inlinetasks should be exported.
+This option can also be set with the #+OPTIONS line,
+e.g. \"inline:nil\"."
+  :group 'org-export-general
+  :type 'boolean)
+
 (defcustom org-export-with-planning nil
   "Non-nil means include planning info in export.
 This option can also be set with the #+OPTIONS: line,
@@ -453,9 +459,6 @@ e.g. \"p:t\"."
 
 (defcustom org-export-with-priority nil
   "Non-nil means include priority cookies in export.
-
-When nil, remove priority cookies for export.
-
 This option can also be set with the #+OPTIONS line,
 e.g. \"pri:t\"."
   :group 'org-export-general
@@ -1814,6 +1817,8 @@ tag."
 		 (and (memq with-tasks '(todo done))
 		      (not (eq todo-type with-tasks)))
 		 (and (consp with-tasks) (not (member todo with-tasks))))))))
+    ;; Check inlinetask.
+    (inlinetask (not (plist-get options :with-inlinetasks)))
     ;; Check timestamp.
     (timestamp
      (case (plist-get options :with-timestamps)

+ 1 - 1
contrib/lisp/org-learn.el

@@ -7,7 +7,7 @@
 ;; Homepage: http://orgmode.org
 ;; Version: 6.32trans
 ;;
-;; This file is part of GNU Emacs.
+;; This file is not part of GNU Emacs.
 ;;
 ;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by

+ 1 - 1
contrib/lisp/org-md.el

@@ -334,7 +334,7 @@ a communication channel."
   (let ((first-object (car (org-element-contents paragraph))))
     ;; If paragraph starts with a #, protect it.
     (if (and (stringp first-object) (string-match "\\`#" first-object))
-	(replace-match "\\#" nil t first-object)
+	(replace-regexp-in-string "\\`#" "\\#" contents nil t)
       contents)))
 
 

+ 1 - 1
contrib/lisp/org-track.el

@@ -14,7 +14,7 @@
 ;; Released under the GNU General Public License version 3
 ;; see: http://www.gnu.org/licenses/gpl-3.0.html
 ;;
-;; This file is part of GNU Emacs.
+;; This file is not part of GNU Emacs.
 ;;
 ;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by

+ 1 - 1
contrib/lisp/org-wikinodes.el

@@ -7,7 +7,7 @@
 ;; Homepage: http://orgmode.org
 ;; Version: 7.01trans
 ;;
-;; This file is part of GNU Emacs.
+;; This file is not part of GNU Emacs.
 ;;
 ;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by

+ 6 - 9
doc/org.texi

@@ -1775,19 +1775,16 @@ state of the checkbox.  In any case, verify bullets and indentation
 consistency in the whole list.
 @kindex C-c -
 @vindex org-plain-list-ordered-item-terminator
-@vindex org-list-automatic-rules
 @item C-c -
 Cycle the entire list level through the different itemize/enumerate bullets
 (@samp{-}, @samp{+}, @samp{*}, @samp{1.}, @samp{1)}) or a subset of them,
 depending on @code{org-plain-list-ordered-item-terminator}, the type of list,
-and its position@footnote{See @code{bullet} rule in
-@code{org-list-automatic-rules} for more information.}.  With a numeric
-prefix argument N, select the Nth bullet from this list.  If there is an
-active region when calling this, selected text will be changed into an item.
-With a prefix argument, all lines will be converted to list items.  If the
-first line already was a list item, any item marker will be removed from the
-list.  Finally, even without an active region, a normal line will be
-converted into a list item.
+and its indentation.  With a numeric prefix argument N, select the Nth bullet
+from this list.  If there is an active region when calling this, selected
+text will be changed into an item.  With a prefix argument, all lines will be
+converted to list items.  If the first line already was a list item, any item
+marker will be removed from the list.  Finally, even without an active
+region, a normal line will be converted into a list item.
 @kindex C-c *
 @item C-c *
 Turn a plain list item into a headline (so that it becomes a subheading at

+ 2 - 2
lisp/ob-ref.el

@@ -240,8 +240,8 @@ to \"0:-1\"."
 			   (funcall wrap (string-to-number (match-string 2 portion)))
 			   (funcall wrap (string-to-number (match-string 3 portion))))
 			(list (funcall wrap 0) (funcall wrap -1)))))
-	    (list (nth (funcall wrap (string-to-number portion)) lis)))))))
-  lis)
+	    (list (nth (funcall wrap (string-to-number portion)) lis))))))
+    lis))
 
 (defun org-babel-ref-split-args (arg-string)
   "Split ARG-STRING into top-level arguments of balanced parenthesis."

+ 10 - 19
lisp/org-agenda.el

@@ -886,7 +886,7 @@ you want to use two-columns display (see `org-agenda-menu-two-columns')."
   :version "24.1"
   :type 'boolean)
 
-(make-obsolete-variable 'org-agenda-menu-two-column 'org-agenda-menu-two-columns "24.2")
+(make-obsolete-variable 'org-agenda-menu-two-column 'org-agenda-menu-two-columns "24.3")
 
 (defcustom org-agenda-menu-two-columns nil
   "Non-nil means, use two columns to show custom commands in the dispatcher.
@@ -5718,8 +5718,7 @@ FRACTION is what fraction of the head-warning time has passed."
                                      ((= d1 d0)
 				      (concat "<" start-time ">"))
 				     ((= d2 d0)
-				      (concat "<" end-time ">"))
-				     (t nil))
+				      (concat "<" end-time ">")))
 			       remove-re))))
 		(org-add-props txt props
 		  'org-marker marker 'org-hd-marker hdmarker
@@ -6178,8 +6177,7 @@ could bind the variable in the options section of a custom command.")
   (let ((pa (or (get-text-property 1 'priority a) 0))
 	(pb (or (get-text-property 1 'priority b) 0)))
     (cond ((> pa pb) +1)
-	  ((< pa pb) -1)
-	  (t nil))))
+	  ((< pa pb) -1))))
 
 (defsubst org-cmp-effort (a b)
   "Compare the effort values of string A and B."
@@ -6187,16 +6185,14 @@ could bind the variable in the options section of a custom command.")
 	 (ea (or (get-text-property 1 'effort-minutes a) def))
 	 (eb (or (get-text-property 1 'effort-minutes b) def)))
     (cond ((> ea eb) +1)
-	  ((< ea eb) -1)
-	  (t nil))))
+	  ((< ea eb) -1))))
 
 (defsubst org-cmp-category (a b)
   "Compare the string values of categories of strings A and B."
   (let ((ca (or (get-text-property 1 'org-category a) ""))
 	(cb (or (get-text-property 1 'org-category b) "")))
     (cond ((string-lessp ca cb) -1)
-	  ((string-lessp cb ca) +1)
-	  (t nil))))
+	  ((string-lessp cb ca) +1))))
 
 (defsubst org-cmp-todo-state (a b)
   "Compare the todo states of strings A and B."
@@ -6218,8 +6214,7 @@ could bind the variable in the options section of a custom command.")
     (cond ((and donepa (not donepb)) -1)
 	  ((and (not donepa) donepb) +1)
 	  ((< la lb) -1)
-	  ((< lb la) +1)
-	  (t nil))))
+	  ((< lb la) +1))))
 
 (defsubst org-cmp-alpha (a b)
   "Compare the headlines, alphabetically."
@@ -6240,8 +6235,7 @@ could bind the variable in the options section of a custom command.")
     (cond ((not ta) +1)
 	  ((not tb) -1)
 	  ((string-lessp ta tb) -1)
-	  ((string-lessp tb ta) +1)
-	  (t nil))))
+	  ((string-lessp tb ta) +1))))
 
 (defsubst org-cmp-tag (a b)
   "Compare the string values of the first tags of A and B."
@@ -6250,8 +6244,7 @@ could bind the variable in the options section of a custom command.")
     (cond ((not ta) +1)
 	  ((not tb) -1)
 	  ((string-lessp ta tb) -1)
-	  ((string-lessp tb ta) +1)
-	  (t nil))))
+	  ((string-lessp tb ta) +1))))
 
 (defsubst org-cmp-time (a b)
   "Compare the time-of-day values of strings A and B."
@@ -6259,16 +6252,14 @@ could bind the variable in the options section of a custom command.")
 	 (ta (or (get-text-property 1 'time-of-day a) def))
 	 (tb (or (get-text-property 1 'time-of-day b) def)))
     (cond ((< ta tb) -1)
-	  ((< tb ta) +1)
-	  (t nil))))
+	  ((< tb ta) +1))))
 
 (defsubst org-cmp-habit-p (a b)
   "Compare the todo states of strings A and B."
   (let ((ha (get-text-property 1 'org-habit-p a))
 	(hb (get-text-property 1 'org-habit-p b)))
     (cond ((and ha (not hb)) -1)
-	  ((and (not ha) hb) +1)
-	  (t nil))))
+	  ((and (not ha) hb) +1))))
 
 (defsubst org-em (x y list) (or (memq x list) (memq y list)))
 

+ 3 - 3
lisp/org-capture.el

@@ -368,7 +368,7 @@ The capture buffer is current and still narrowed."
   "When non-nil, add a bookmark pointing at the last stored
 position when capturing."
   :group 'org-capture
-  :version "24.2"
+  :version "24.3"
   :type 'boolean)
 
 ;;; The property list for keeping information about the capture process
@@ -1081,8 +1081,8 @@ it.  When it is a variable, retrieve the value.  Return whatever we get."
       (setq end (point))))
     (goto-char beg)
     (org-capture-position-for-last-stored 'table-line)
-    (if (or (re-search-backward "%\\?" end t)
-	    (re-search-forward "%\\?" beg t))
+    (if (or (re-search-backward "%\\?" beg t)
+	    (re-search-forward "%\\?" end t))
 	(replace-match ""))
     (org-table-align)))
 

+ 2 - 2
lisp/org-clock.el

@@ -1798,8 +1798,8 @@ will be easy to remove."
     (org-move-to-column c)
     (unless (eolp) (skip-chars-backward "^ \t"))
     (skip-chars-backward " \t")
-    (setq ov (make-overlay (1- (point)) (point-at-eol))
-	  tx (concat (buffer-substring (1- (point)) (point))
+    (setq ov (make-overlay (point-at-bol) (point-at-eol))
+    	  tx (concat (buffer-substring (point-at-bol) (point))
 		     (make-string (+ off (max 0 (- c (current-column)))) ?.)
 		     (org-add-props (if org-time-clocksum-use-fractional
 					(format fmt

+ 1 - 1
lisp/org-datetree.el

@@ -41,7 +41,7 @@ so the base level will be properly adjusted.")
 (defcustom org-datetree-add-timestamp nil
   "When non-nil, add a time stamp when create a datetree entry."
   :group 'org-capture
-  :version "24.2"
+  :version "24.3"
   :type '(choice
 	  (const :tag "Do not add a time stamp" nil)
 	  (const :tag "Add an inactive time stamp" inactive)

+ 135 - 91
lisp/org-element.el

@@ -131,11 +131,12 @@
           "[ \t]*\\(?:"
           ;; Empty lines.
           "$" "\\|"
-          ;; Comments, blocks (any type), keywords, Babel calls,
-	  ;; drawers (any type) and tables.
-          "[|#]" "\\|"
-          ;; Fixed width areas.
-          ":\\(?:[ \t]\\|$\\)" "\\|"
+	  ;; Tables (any type).
+	  "\\(?:|\\|\\+-[-+]\\)" "\\|"
+          ;; Blocks (any type), Babel calls, drawers (any type),
+	  ;; fixed-width areas and keywords.  Note: this is only an
+	  ;; indication and need some thorough check.
+          "[#:]" "\\|"
           ;; Horizontal rules.
           "-\\{5,\\}[ \t]*$" "\\|"
           ;; LaTeX environments.
@@ -153,7 +154,10 @@
             (concat "\\(?:[-+*]\\|\\(?:[0-9]+" alpha "\\)" term "\\)"
                     "\\(?:[ \t]\\|$\\)"))
           "\\)\\)")
-  "Regexp to separate paragraphs in an Org buffer.")
+  "Regexp to separate paragraphs in an Org buffer.
+In the case of lines starting with \"#\" and \":\", this regexp
+is not sufficient to know if point is at a paragraph ending.  See
+`org-element-paragraph-parser' for more information.")
 
 (defconst org-element-all-elements
   '(center-block clock comment comment-block drawer dynamic-block example-block
@@ -342,7 +346,7 @@ still has an entry since one of its properties (`:title') does.")
 ;; Setter functions allow to modify elements by side effect.  There is
 ;; `org-element-put-property', `org-element-set-contents',
 ;; `org-element-set-element' and `org-element-adopt-element'.  Note
-;; that `org-element-set-element' and `org-element-adopt-element' are
+;; that `org-element-set-element' and `org-element-adopt-elements' are
 ;; higher level functions since also update `:parent' property.
 
 (defsubst org-element-type (element)
@@ -389,38 +393,39 @@ Return modified element."
 (defsubst org-element-set-element (old new)
   "Replace element or object OLD with element or object NEW.
 The function takes care of setting `:parent' property for NEW."
-  ;; OLD can belong to the contents of PARENT or to its secondary
-  ;; string.
-  (let* ((parent (org-element-property :parent old))
-	 (sec-loc (cdr (assq (org-element-type parent)
-			     org-element-secondary-value-alist)))
-	 (sec-value (and sec-loc (org-element-property sec-loc parent)))
-	 (place (or (memq old sec-value) (memq old parent))))
-    ;; Make sure NEW has correct `:parent' property.
-    (org-element-put-property new :parent parent)
-    ;; Replace OLD with NEW in PARENT.
-    (setcar place new)))
-
-(defsubst org-element-adopt-element (parent child &optional append)
-  "Add an element to the contents of another element.
-
-PARENT is an element or object.  CHILD is an element, an object,
-or a string.
-
-CHILD is added at the beginning of PARENT contents, unless the
-optional argument APPEND is non-nil, in which case CHILD is added
-at the end.
+  ;; Since OLD is going to be changed into NEW by side-effect, first
+  ;; make sure that every element or object within NEW has OLD as
+  ;; parent.
+  (mapc (lambda (blob) (org-element-put-property blob :parent old))
+	(org-element-contents new))
+  ;; Transfer contents.
+  (apply 'org-element-set-contents old (org-element-contents new))
+  ;; Ensure NEW has same parent as OLD, then overwrite OLD properties
+  ;; with NEW's.
+  (org-element-put-property new :parent (org-element-property :parent old))
+  (setcar (cdr old) (nth 1 new))
+  ;; Transfer type.
+  (setcar old (car new)))
+
+(defsubst org-element-adopt-elements (parent &rest children)
+  "Append elements to the contents of another element.
+
+PARENT is an element or object.  CHILDREN can be elements,
+objects, or a strings.
 
 The function takes care of setting `:parent' property for CHILD.
 Return parent element."
-  (if (not parent) (list child)
-    (let ((contents (org-element-contents parent)))
-      (apply 'org-element-set-contents
-	     parent
-	     (if append (append contents (list child)) (cons child contents))))
-    ;; Link the CHILD element with PARENT.
-    (when (consp child) (org-element-put-property child :parent parent))
-    ;; Return the parent element.
+  (if (not parent) children
+    ;; Link every child to PARENT.
+    (mapc (lambda (child)
+	    (unless (stringp child)
+	      (org-element-put-property child :parent parent)))
+	  children)
+    ;; Add CHILDREN at the end of PARENT contents.
+    (apply 'org-element-set-contents
+	   parent
+	   (nconc (org-element-contents parent) children))
+    ;; Return modified PARENT element.
     parent))
 
 
@@ -474,8 +479,8 @@ Assume point is at the beginning of the block."
   (let ((case-fold-search t))
     (if (not (save-excursion
 	       (re-search-forward "^[ \t]*#\\+END_CENTER" limit t)))
-	;; Incomplete block: parse it as a comment.
-	(org-element-comment-parser limit)
+	;; Incomplete block: parse it as a paragraph.
+	(org-element-paragraph-parser limit)
       (let ((block-end-line (match-beginning 0)))
 	(let* ((keywords (org-element--collect-affiliated-keywords))
 	       (begin (car keywords))
@@ -574,8 +579,8 @@ containing `:block-name', `:begin', `:end', `:hiddenp',
 Assume point is at beginning of dynamic block."
   (let ((case-fold-search t))
     (if (not (save-excursion (re-search-forward org-dblock-end-re limit t)))
-	;; Incomplete block: parse it as a comment.
-	(org-element-comment-parser limit)
+	;; Incomplete block: parse it as a paragraph.
+	(org-element-paragraph-parser limit)
       (let ((block-end-line (match-beginning 0)))
 	(save-excursion
 	  (let* ((name (progn (looking-at org-dblock-start-re)
@@ -979,34 +984,39 @@ string instead.
 Assume point is at the beginning of the item."
   (save-excursion
     (beginning-of-line)
+    (looking-at org-list-full-item-re)
     (let* ((begin (point))
-	   (bullet (org-list-get-bullet (point) struct))
-	   (checkbox (let ((box (org-list-get-checkbox begin struct)))
+	   (bullet (org-match-string-no-properties 1))
+	   (checkbox (let ((box (org-match-string-no-properties 3)))
 		       (cond ((equal "[ ]" box) 'off)
 			     ((equal "[X]" box) 'on)
 			     ((equal "[-]" box) 'trans))))
-	   (counter (let ((c (org-list-get-counter begin struct)))
-		      (cond
-		       ((not c) nil)
-		       ((string-match "[A-Za-z]" c)
-			(- (string-to-char (upcase (match-string 0 c)))
-			   64))
-		       ((string-match "[0-9]+" c)
-			(string-to-number (match-string 0 c))))))
+	   (counter (let ((c (org-match-string-no-properties 2)))
+		      (save-match-data
+			(cond
+			 ((not c) nil)
+			 ((string-match "[A-Za-z]" c)
+			  (- (string-to-char (upcase (match-string 0 c)))
+			     64))
+			 ((string-match "[0-9]+" c)
+			  (string-to-number (match-string 0 c)))))))
 	   (end (save-excursion (goto-char (org-list-get-item-end begin struct))
 				(unless (bolp) (forward-line))
 				(point)))
-	   (contents-begin (progn (looking-at org-list-full-item-re)
-				  (goto-char (match-end 0))
-				  (skip-chars-forward " \r\t\n" limit)
-				  ;; If first line isn't empty,
-				  ;; contents really start at the text
-				  ;; after item's meta-data.
-				  (if (= (point-at-bol) begin) (point)
-				    (point-at-bol))))
+	   (contents-begin
+	    (progn (goto-char
+		    ;; Ignore tags in un-ordered lists: they are just
+		    ;; a part of item's body.
+		    (if (and (match-beginning 4)
+			     (save-match-data (string-match "[.)]" bullet)))
+			(match-beginning 4)
+		      (match-end 0)))
+		   (skip-chars-forward " \r\t\n" limit)
+		   ;; If first line isn't empty, contents really start
+		   ;; at the text after item's meta-data.
+		   (if (= (point-at-bol) begin) (point) (point-at-bol))))
 	   (hidden (progn (forward-line)
-			  (and (not (= (point) end))
-			       (org-invisible-p2))))
+			  (and (not (= (point) end)) (org-invisible-p2))))
 	   (contents-end (progn (goto-char end)
 				(skip-chars-backward " \r\t\n")
 				(forward-line)
@@ -1128,8 +1138,8 @@ Assume point is at the beginning of the block."
   (let ((case-fold-search t))
     (if (not (save-excursion
 	       (re-search-forward "^[ \t]*#\\+END_QUOTE" limit t)))
-	;; Incomplete block: parse it as a comment.
-	(org-element-comment-parser limit)
+	;; Incomplete block: parse it as a paragraph.
+	(org-element-paragraph-parser limit)
       (let ((block-end-line (match-beginning 0)))
 	(save-excursion
 	  (let* ((keywords (org-element--collect-affiliated-keywords))
@@ -1210,8 +1220,8 @@ Assume point is at the beginning of the block."
 		      (upcase (match-string-no-properties 1)))))
     (if (not (save-excursion
 	       (re-search-forward (concat "^[ \t]*#\\+END_" type) limit t)))
-	;; Incomplete block: parse it as a comment.
-	(org-element-comment-parser limit)
+	;; Incomplete block: parse it as a paragraph.
+	(org-element-paragraph-parser limit)
       (let ((block-end-line (match-beginning 0)))
 	(save-excursion
 	  (let* ((keywords (org-element--collect-affiliated-keywords))
@@ -1359,8 +1369,6 @@ Assume point is at comment beginning."
   (save-excursion
     (let* ((keywords (org-element--collect-affiliated-keywords))
 	   (begin (car keywords))
-	   ;; Match first line with a loose regexp since it might as
-	   ;; well be an ill-defined keyword.
 	   (value (prog2 (looking-at "[ \t]*# ?")
 		      (buffer-substring-no-properties
 		       (match-end 0) (line-end-position))
@@ -1410,8 +1418,8 @@ Assume point is at comment block beginning."
   (let ((case-fold-search t))
     (if (not (save-excursion
 	       (re-search-forward "^[ \t]*#\\+END_COMMENT" limit t)))
-	;; Incomplete block: parse it as a comment.
-	(org-element-comment-parser limit)
+	;; Incomplete block: parse it as a paragraph.
+	(org-element-paragraph-parser limit)
       (let ((contents-end (match-beginning 0)))
 	(save-excursion
 	  (let* ((keywords (org-element--collect-affiliated-keywords))
@@ -1455,8 +1463,8 @@ containing `:begin', `:end', `:number-lines', `:preserve-indent',
   (let ((case-fold-search t))
     (if (not (save-excursion
 	       (re-search-forward "^[ \t]*#\\+END_EXAMPLE" limit t)))
-	;; Incomplete block: parse it as a comment.
-	(org-element-comment-parser limit)
+	;; Incomplete block: parse it as a paragraph.
+	(org-element-paragraph-parser limit)
       (let ((contents-end (match-beginning 0)))
 	(save-excursion
 	  (let* ((switches
@@ -1534,8 +1542,8 @@ Assume point is at export-block beginning."
 		      (upcase (org-match-string-no-properties 1)))))
     (if (not (save-excursion
 	       (re-search-forward (concat "^[ \t]*#\\+END_" type) limit t)))
-	;; Incomplete block: parse it as a comment.
-	(org-element-comment-parser limit)
+	;; Incomplete block: parse it as a paragraph.
+	(org-element-paragraph-parser limit)
       (let ((contents-end (match-beginning 0)))
 	(save-excursion
 	  (let* ((keywords (org-element--collect-affiliated-keywords))
@@ -1732,12 +1740,45 @@ Assume point is at the beginning of the paragraph."
 	   (keywords (org-element--collect-affiliated-keywords))
 	   (begin (car keywords))
 	   (before-blank
-	    (progn (end-of-line)
-		   (if (re-search-forward org-element-paragraph-separate
-					  limit
-					  'm)
-		       (goto-char (match-beginning 0))
-		     (point))))
+	    (let ((case-fold-search t))
+	      (end-of-line)
+	      (re-search-forward org-element-paragraph-separate limit 'm)
+	      (while (and (/= (point) limit)
+			  (cond
+			   ;; Skip non-existent or incomplete drawer.
+			   ((save-excursion
+			      (beginning-of-line)
+			      (and (looking-at "[ \t]*:\\S-")
+				   (or (not (looking-at org-drawer-regexp))
+				       (not (save-excursion
+					      (re-search-forward
+					       "^[ \t]*:END:" limit t)))))))
+			   ;; Stop at comments.
+			   ((save-excursion
+			      (beginning-of-line)
+			      (not (looking-at "[ \t]*#\\S-"))) nil)
+			   ;; Skip incomplete dynamic blocks.
+			   ((save-excursion
+			      (beginning-of-line)
+			      (looking-at "[ \t]*#\\+BEGIN: "))
+			    (not (save-excursion
+				   (re-search-forward
+				    "^[ \t]*\\+END:" limit t))))
+			   ;; Skip incomplete blocks.
+			   ((save-excursion
+			      (beginning-of-line)
+			      (looking-at "[ \t]*#\\+BEGIN_\\(\\S-+\\)"))
+			    (not (save-excursion
+				   (re-search-forward
+				    (concat "^[ \t]*#\\+END_"
+					    (match-string 1))
+				    limit t))))
+			   ;; Skip ill-formed keywords.
+			   ((not (save-excursion
+				   (beginning-of-line)
+				   (looking-at "[ \t]*#\\+\\S-+:"))))))
+		(re-search-forward org-element-paragraph-separate limit 'm))
+	      (if (eobp) (point) (goto-char (line-beginning-position)))))
 	   (contents-end (progn (skip-chars-backward " \r\t\n" contents-begin)
 				(forward-line)
 				(point)))
@@ -1913,8 +1954,8 @@ containing `:language', `:switches', `:parameters', `:begin',
 Assume point is at the beginning of the block."
   (let ((case-fold-search t))
     (if (not (save-excursion (re-search-forward "^[ \t]*#\\+END_SRC" limit t)))
-	;; Incomplete block: parse it as a comment.
-	(org-element-comment-parser limit)
+	;; Incomplete block: parse it as a paragraph.
+	(org-element-paragraph-parser limit)
       (let ((contents-end (match-beginning 0)))
 	(save-excursion
 	  (let* ((keywords (org-element--collect-affiliated-keywords))
@@ -2118,8 +2159,8 @@ Assume point is at beginning of the block."
   (let ((case-fold-search t))
     (if (not (save-excursion
 	       (re-search-forward "^[ \t]*#\\+END_VERSE" limit t)))
-	;; Incomplete block: parse it as a comment.
-	(org-element-comment-parser limit)
+	;; Incomplete block: parse it as a paragraph.
+	(org-element-paragraph-parser limit)
       (let ((contents-end (match-beginning 0)))
 	(save-excursion
 	  (let* ((keywords (org-element--collect-affiliated-keywords))
@@ -3325,13 +3366,16 @@ element it has to parse."
        ;; Keywords.
        ((looking-at "[ \t]*#")
 	(goto-char (match-end 0))
-	(cond ((looking-at "\\+BEGIN_\\(\\S-+\\)")
+	(cond ((looking-at "\\(?: \\|$\\)")
+	       (beginning-of-line)
+	       (org-element-comment-parser limit))
+	      ((looking-at "\\+BEGIN_\\(\\S-+\\)")
 	       (beginning-of-line)
 	       (let ((parser (assoc (upcase (match-string 1))
 				    org-element-block-name-alist)))
 		 (if parser (funcall (cdr parser) limit)
 		   (org-element-special-block-parser limit))))
-	      ((looking-at "\\+CALL")
+	      ((looking-at "\\+CALL:")
 	       (beginning-of-line)
 	       (org-element-babel-call-parser limit))
 	      ((looking-at "\\+BEGIN:? ")
@@ -3342,7 +3386,7 @@ element it has to parse."
 	       (org-element-keyword-parser limit))
 	      (t
 	       (beginning-of-line)
-	       (org-element-comment-parser limit))))
+	       (org-element-paragraph-parser limit))))
        ;; Footnote Definition.
        ((looking-at org-footnote-definition-re)
         (org-element-footnote-definition-parser limit))
@@ -3700,7 +3744,7 @@ Elements are accumulated into ACC."
 	  (org-element--parse-objects
 	   cbeg (org-element-property :contents-end element) element
 	   (org-element-restriction type))))
-	(org-element-adopt-element acc element t)))
+	(org-element-adopt-elements acc element)))
     ;; Return result.
     acc))
 
@@ -3727,11 +3771,11 @@ current object."
 	  (let ((obj-beg (org-element-property :begin next-object)))
 	    (unless (= (point) obj-beg)
 	      (setq acc
-		    (org-element-adopt-element
+		    (org-element-adopt-elements
 		     acc
 		     (replace-regexp-in-string
 		      "\t" (make-string tab-width ? )
-		      (buffer-substring-no-properties (point) obj-beg)) t))))
+		      (buffer-substring-no-properties (point) obj-beg))))))
 	  ;; 2. Object...
 	  (let ((obj-end (org-element-property :end next-object))
 		(cont-beg (org-element-property :contents-begin next-object)))
@@ -3746,16 +3790,16 @@ current object."
 		(org-element--parse-objects
 		 (point-min) (point-max) next-object
 		 (org-element-restriction next-object))))
-	    (setq acc (org-element-adopt-element acc next-object t))
+	    (setq acc (org-element-adopt-elements acc next-object))
 	    (goto-char obj-end))))
       ;; 3. Text after last object.  Untabify it.
       (unless (= (point) end)
 	(setq acc
-	      (org-element-adopt-element
+	      (org-element-adopt-elements
 	       acc
 	       (replace-regexp-in-string
 		"\t" (make-string tab-width ? )
-		(buffer-substring-no-properties (point) end)) t)))
+		(buffer-substring-no-properties (point) end)))))
       ;; Result.
       acc)))
 

+ 24 - 38
lisp/org-exp.el

@@ -1,4 +1,4 @@
-;;; org-exp.el --- ASCII, HTML, XOXO and iCalendar export for Org-mode
+;;; org-exp.el --- Export internals for Org-mode
 
 ;; Copyright (C) 2004-2012 Free Software Foundation, Inc.
 
@@ -731,8 +731,7 @@ Each element is a list of 3 items:
       (setq s (nth 2 e)
 	    v (cond
 	       ((assq s letbind) (nth 1 (assq s letbind)))
-	       ((boundp s) (symbol-value s))
-	       (t nil))
+	       ((boundp s) (symbol-value s)))
 	    rtn (cons (car e) (cons v rtn))))
     rtn))
 
@@ -1318,11 +1317,8 @@ on this string to produce the exported version."
       ;; Remove or replace comments
       (org-export-handle-comments (plist-get parameters :comments))
 
-      ;; Remove #+TBLFM and #+TBLNAME lines
-      (org-export-handle-table-metalines)
-
-      ;; Remove #+results and #+name lines
-      (org-export-res/src-name-cleanup)
+      ;; Remove #+TBLFM #+TBLNAME #+NAME #+RESULTS lines
+      (org-export-handle-metalines)
 
       ;; Run the final hook
       (run-hooks 'org-export-preprocess-final-hook)
@@ -2009,9 +2005,11 @@ When it is nil, all comments will be removed."
 	  (replace-match "")
 	  (goto-char (max (point-min) (1- pos))))))))
 
-(defun org-export-handle-table-metalines ()
-  "Remove table specific metalines #+TBLNAME: and #+TBLFM:."
-  (let ((re "^[ \t]*#\\+tbl\\(name\\|fm\\):\\(.*\n?\\)")
+(defun org-export-handle-metalines ()
+  "Remove tables and source blocks metalines.
+This function should only be called after all block processing
+has taken place."
+  (let ((re "^[ \t]*#\\+\\(tbl\\(?:name\\|fm\\)\\|results\\(?:\\[[a-z0-9]+\\]\\)?\\|name\\):\\(.*\n?\\)")
 	(case-fold-search t)
 	pos)
     (goto-char (point-min))
@@ -2024,18 +2022,6 @@ When it is nil, all comments will be removed."
 	(replace-match "")
 	(goto-char (max (point-min) (1- pos)))))))
 
-(defun org-export-res/src-name-cleanup ()
-  "Clean up #+results and #+name lines for export.
-This function should only be called after all block processing
-has taken place."
-  (interactive)
-  (save-excursion
-    (goto-char (point-min))
-    (let ((case-fold-search t))
-      (while (org-re-search-forward-unprotected
-	      "#\\+\\(name\\|results\\(\\[[a-z0-9]+\\]\\)?\\):" nil t)
-	(delete-region (match-beginning 0) (progn (forward-line) (point)))))))
-
 (defun org-export-mark-radio-links ()
   "Find all matches for radio targets and turn them into internal links."
   (let ((re-radio (and org-target-link-regexp
@@ -3273,8 +3259,7 @@ If yes remove the column and the special lines."
 			 (mapcar (lambda (x)
 				   (cond ((member x '("<" "&lt;")) :start)
 					 ((member x '(">" "&gt;")) :end)
-					 ((member x '("<>" "&lt;&gt;")) :startend)
-					 (t nil)))
+					 ((member x '("<>" "&lt;&gt;")) :startend)))
 				 (org-split-string x "[ \t]*|[ \t]*")))
 		   nil)
 		  ((org-table-cookie-line-p x)
@@ -3295,8 +3280,7 @@ If yes remove the column and the special lines."
 		     (mapcar (lambda (x)
 			       (cond ((member x '("<" "&lt;")) :start)
 				     ((member x '(">" "&gt;")) :end)
-				     ((member x '("<>" "&lt;&gt;")) :startend)
-				     (t nil)))
+				     ((member x '("<>" "&lt;&gt;")) :startend)))
 			     (cdr (org-split-string x "[ \t]*|[ \t]*"))))
 	       nil)
 	      ((org-table-cookie-line-p x)
@@ -3313,18 +3297,20 @@ If yes remove the column and the special lines."
 
 (defun org-export-cleanup-toc-line (s)
   "Remove tags and timestamps from lines going into the toc."
-  (when (memq org-export-with-tags '(not-in-toc nil))
-    (if (string-match (org-re " +:[[:alnum:]_@#%:]+: *$") s)
+  (if (not s)
+      "" ; Return a string when argument is nil
+    (when (memq org-export-with-tags '(not-in-toc nil))
+      (if (string-match (org-re " +:[[:alnum:]_@#%:]+: *$") s)
+	  (setq s (replace-match "" t t s))))
+    (when org-export-remove-timestamps-from-toc
+      (while (string-match org-maybe-keyword-time-regexp s)
 	(setq s (replace-match "" t t s))))
-  (when org-export-remove-timestamps-from-toc
-    (while (string-match org-maybe-keyword-time-regexp s)
-      (setq s (replace-match "" t t s))))
-  (while (string-match org-bracket-link-regexp s)
-    (setq s (replace-match (match-string (if (match-end 3) 3 1) s)
-			   t t s)))
-  (while (string-match "\\[\\([0-9]\\|fn:[^]]*\\)\\]" s)
-    (setq s (replace-match "" t t s)))
-  s)
+    (while (string-match org-bracket-link-regexp s)
+      (setq s (replace-match (match-string (if (match-end 3) 3 1) s)
+			     t t s)))
+    (while (string-match "\\[\\([0-9]\\|fn:[^]]*\\)\\]" s)
+      (setq s (replace-match "" t t s)))
+    s))
 
 
 (defun org-get-text-property-any (pos prop &optional object)

+ 6 - 6
lisp/org-html.el

@@ -698,8 +698,7 @@ The default is an extended format of the ISO 8601 specification."
       ((eq (plist-get parameters :LaTeX-fragments) 'mathjax ) 'mathjax)
       ((eq (plist-get parameters :LaTeX-fragments) t        ) 'mathjax)
       ((eq (plist-get parameters :LaTeX-fragments) 'imagemagick) 'imagemagick)
-      ((eq (plist-get parameters :LaTeX-fragments) 'dvipng  ) 'dvipng)
-      (t nil))))
+      ((eq (plist-get parameters :LaTeX-fragments) 'dvipng  ) 'dvipng))))
   (goto-char (point-min))
   (let (label l1)
     (while (re-search-forward "\\\\ref{\\([^{}\n]+\\)}" nil t)
@@ -1704,7 +1703,7 @@ PUB-DIR is set, use this as the publishing directory."
 	    ;; This is a headline
 	    (setq level (org-tr-level (- (match-end 1) (match-beginning 1)
 					 level-offset))
-		  txt (match-string 2 org-line))
+		  txt (or (match-string 2 org-line) ""))
 	    (if (string-match quote-re0 txt)
 		(setq txt (replace-match "" t t txt)))
 	    (if (<= level (max umax umax-toc))
@@ -2141,9 +2140,10 @@ for formatting.  This is required for the DocBook exporter."
       (if colgropen (setq html (cons (car html)
 				     (cons "</colgroup>" (cdr html)))))
       ;; Since the output of HTML table formatter can also be used in
-      ;; DocBook document, we want to always include the caption to make
-      ;; DocBook XML file valid.
-      (push (format "<caption>%s</caption>" (or caption "")) html)
+      ;; DocBook document, include empty captions for the DocBook
+      ;; export only so that it produces valid XML.
+      (when (or caption (eq org-export-current-backend 'docbook))
+	(push (format "<caption>%s</caption>" (or caption "")) html))
       (when label
 	(setq html-table-tag (org-export-splice-attributes html-table-tag (format "id=\"%s\"" (org-solidify-link-text label)))))
       (push html-table-tag html))

+ 15 - 17
lisp/org-icalendar.el

@@ -28,8 +28,7 @@
 
 (require 'org-exp)
 
-(eval-when-compile
-  (require 'cl))
+(eval-when-compile (require 'cl))
 
 (declare-function org-bbdb-anniv-export-ical "org-bbdb" nil)
 
@@ -288,20 +287,19 @@ file and store it under the name `org-combined-agenda-icalendar-file'."
 	  (let ((standard-output ical-buffer))
 	    (if combine
 		(and (not started) (setq started t)
-		     (org-start-icalendar-file org-icalendar-combined-name))
-	      (org-start-icalendar-file category))
-	    (org-print-icalendar-entries combine)
+		     (org-icalendar-start-file org-icalendar-combined-name))
+	      (org-icalendar-start-file category))
+	    (org-icalendar-print-entries combine)
 	    (when (or (and combine (not files)) (not combine))
 	      (when (and combine org-icalendar-include-bbdb-anniversaries)
 		(require 'org-bbdb)
 		(org-bbdb-anniv-export-ical))
-	      (org-finish-icalendar-file)
+	      (org-icalendar-finish-file)
 	      (set-buffer ical-buffer)
 	      (run-hooks 'org-before-save-iCalendar-file-hook)
 	      (save-buffer)
 	      (run-hooks 'org-after-save-iCalendar-file-hook)
-	      (and (boundp 'org-wait) (numberp org-wait) (sit-for org-wait))
-	      ))))
+	      (and (boundp 'org-wait) (numberp org-wait) (sit-for org-wait))))))
       (org-release-buffers org-agenda-new-buffers))))
 
 (defvar org-before-save-iCalendar-file-hook nil
@@ -315,13 +313,13 @@ A good way to use this is to tell a desktop calendar application to re-read
 the iCalendar file.")
 
 (defvar org-agenda-default-appointment-duration) ; defined in org-agenda.el
-(defun org-print-icalendar-entries (&optional combine)
+(defun org-icalendar-print-entries (&optional combine)
   "Print iCalendar entries for the current Org-mode file to `standard-output'.
 When COMBINE is non nil, add the category to each line."
   (require 'org-agenda)
   (let ((re1 (concat org-ts-regexp "\\|<%%([^>\n]+>"))
 	(re2 (concat "--?-?\\(" org-ts-regexp "\\)"))
-	(dts (org-ical-ts-to-string
+	(dts (org-icalendar-ts-to-string
 	      (format-time-string (cdr org-time-stamp-formats) (current-time))
 	      "DTSTART"))
 	hd ts ts2 state status (inc t) pos b sexp rrule
@@ -448,8 +446,8 @@ SUMMARY:%s%s%s
 CATEGORIES:%s%s
 END:VEVENT\n"
 			   (concat prefix uid)
-			   (org-ical-ts-to-string ts "DTSTART")
-			   (org-ical-ts-to-string ts2 "DTEND" inc)
+			   (org-icalendar-ts-to-string ts "DTSTART")
+			   (org-icalendar-ts-to-string ts2 "DTEND" inc)
 			   rrule summary
 			   (if (and desc (string-match "\\S-" desc))
 			       (concat "\nDESCRIPTION: " desc) "")
@@ -532,8 +530,8 @@ END:VEVENT\n"
 		    uid (if org-icalendar-store-UID
 			    (org-id-get-create)
 			  (or (org-id-get) (org-id-new))))
-	      (and due (setq due (org-ical-ts-to-string due "DUE")))
-	      (and start (setq start (org-ical-ts-to-string start "DTSTART")))
+	      (and due (setq due (org-icalendar-ts-to-string due "DUE")))
+	      (and start (setq start (org-icalendar-ts-to-string start "DTSTART")))
 
 	      (if (string-match org-bracket-link-regexp hd)
 		  (setq hd (replace-match (if (match-end 3) (match-string 3 hd)
@@ -636,7 +634,7 @@ not used right now."
     (when (string-match "[;,:]" s) (setq s (concat "\"" s "\"")))
     s))
 
-(defun org-start-icalendar-file (name)
+(defun org-icalendar-start-file (name)
   "Start an iCalendar file by inserting the header."
   (let ((user user-full-name)
 	(name (or name "unknown"))
@@ -653,11 +651,11 @@ X-WR-TIMEZONE:%s
 X-WR-CALDESC:%s
 CALSCALE:GREGORIAN\n" name user timezone description))))
 
-(defun org-finish-icalendar-file ()
+(defun org-icalendar-finish-file ()
   "Finish an iCalendar file by inserting the END statement."
   (princ "END:VCALENDAR\n"))
 
-(defun org-ical-ts-to-string (s keyword &optional inc)
+(defun org-icalendar-ts-to-string (s keyword &optional inc)
   "Take a time string S and convert it to iCalendar format.
 KEYWORD is added in front, to make a complete line like DTSTART....
 When INC is non-nil, increase the hour by two (if time string contains

+ 1 - 2
lisp/org-id.el

@@ -216,8 +216,7 @@ In any case, the ID of the entry is returned."
 	(setq id (org-id-new prefix))
 	(org-entry-put pom "ID" id)
 	(org-id-add-location id (buffer-file-name (buffer-base-buffer)))
-	id)
-       (t nil)))))
+	id)))))
 
 ;;;###autoload
 (defun org-id-get-with-outline-path-completion (&optional targets)

+ 2 - 2
lisp/org-latex.el

@@ -330,7 +330,7 @@ its description and the Org's version number, as a string.  Set
 this option to the empty string if you don't want to include
 hyperref options altogether."
   :type 'string
-  :version "24.2"
+  :version "24.3"
   :group 'org-export-latex)
 
 (defcustom org-export-latex-footnote-separator "\\textsuperscript{,}\\,"
@@ -649,7 +649,7 @@ and `org-export-with-tags' instead."
 (defcustom org-export-latex-link-with-unknown-path-format "\\texttt{%s}"
   "Format string for links with unknown path type."
   :group 'org-export-latex
-  :version "24.2"
+  :version "24.3"
   :type 'string)
 
 (defcustom org-export-latex-inline-image-extensions

+ 33 - 26
lisp/org-list.el

@@ -236,8 +236,7 @@ Otherwise, two of them will be necessary."
   :group 'org-plain-lists
   :type 'boolean)
 
-(defcustom org-list-automatic-rules '((bullet . t)
-				      (checkbox . t)
+(defcustom org-list-automatic-rules '((checkbox . t)
 				      (indent . t))
   "Non-nil means apply set of rules when acting on lists.
 By default, automatic actions are taken when using
@@ -247,9 +246,6 @@ By default, automatic actions are taken when using
  \\[org-insert-todo-heading].  You can disable individually these
  rules by setting them to nil.  Valid rules are:
 
-bullet    when non-nil, cycling bullet do not allow lists at
-          column 0 to have * as a bullet and descriptions lists
-          to be numbered.
 checkbox  when non-nil, checkbox statistics is updated each time
           you either insert a new checkbox or toggle a checkbox.
 indent    when non-nil, indenting or outdenting list top-item
@@ -261,7 +257,6 @@ indent    when non-nil, indenting or outdenting list top-item
   :type '(alist :tag "Sets of rules"
 		:key-type
 		(choice
-		 (const :tag "Bullet" bullet)
 		 (const :tag "Checkbox" checkbox)
 		 (const :tag "Indent" indent))
 		:value-type
@@ -626,12 +621,15 @@ Assume point is at an item."
 	     ;; Return association at point.
 	     (lambda (ind)
 	       (looking-at org-list-full-item-re)
-	       (list (point)
-		     ind
-		     (match-string-no-properties 1)	; bullet
-		     (match-string-no-properties 2)	; counter
-		     (match-string-no-properties 3)	; checkbox
-		     (match-string-no-properties 4)))))	; description tag
+	       (let ((bullet (match-string-no-properties 1)))
+		 (list (point)
+		       ind
+		       bullet
+		       (match-string-no-properties 2) ; counter
+		       (match-string-no-properties 3) ; checkbox
+		       ;; Description tag.
+		       (and (save-match-data (string-match "[-+*]" bullet))
+			    (match-string-no-properties 4)))))))
 	   (end-before-blank
 	    (function
 	     ;; Ensure list ends at the first blank line.
@@ -1013,8 +1011,8 @@ Possible types are `descriptive', `ordered' and `unordered'.  The
 type is determined by the first item of the list."
   (let ((first (org-list-get-list-begin item struct prevs)))
     (cond
-     ((org-list-get-tag first struct) 'descriptive)
      ((string-match "[[:alnum:]]" (org-list-get-bullet first struct)) 'ordered)
+     ((org-list-get-tag first struct) 'descriptive)
      (t 'unordered))))
 
 (defun org-list-get-item-number (item struct prevs parents)
@@ -1258,8 +1256,15 @@ This function modifies STRUCT."
     (let* ((item (progn (goto-char pos) (goto-char (org-list-get-item-begin))))
 	   (item-end (org-list-get-item-end item struct))
 	   (item-end-no-blank (org-list-get-item-end-before-blank item struct))
-	   (beforep (and (looking-at org-list-full-item-re)
-			 (<= pos (match-end 0))))
+	   (beforep
+	    (progn
+	      (looking-at org-list-full-item-re)
+	      ;; Do not count tag in a non-descriptive list.
+	      (<= pos (if (and (match-beginning 4)
+			       (save-match-data
+				 (string-match "[.)]" (match-string 1))))
+			  (match-beginning 4)
+			(match-end 0)))))
 	   (split-line-p (org-get-alist-option org-M-RET-may-split-line 'item))
 	   (blank-nb (org-list-separating-blank-lines-number
 		      pos struct prevs))
@@ -2192,14 +2197,19 @@ item is invisible."
 				       (org-list-struct)))
 	       (prevs (org-list-prevs-alist struct))
 	       ;; If we're in a description list, ask for the new term.
-	       (desc (when (org-list-get-tag itemp struct)
+	       (desc (when (eq (org-list-get-list-type itemp struct prevs)
+			       'descriptive)
 		       (concat (read-string "Term: ") " :: "))))
 	  (setq struct
 		(org-list-insert-item pos struct prevs checkbox desc))
 	  (org-list-write-struct struct (org-list-parents-alist struct))
 	  (when checkbox (org-update-checkbox-count-maybe))
 	  (looking-at org-list-full-item-re)
-	  (goto-char (match-end 0))
+	  (goto-char (if (and (match-beginning 4)
+			      (save-match-data
+				(string-match "[.)]" (match-string 1))))
+			 (match-beginning 4)
+		       (match-end 0)))
 	  t)))))
 
 (defun org-list-repair ()
@@ -2228,7 +2238,6 @@ is an integer, 0 means `-', 1 means `+' etc.  If WHICH is
            (prevs (org-list-prevs-alist struct))
            (list-beg (org-list-get-first-item (point) struct prevs))
            (bullet (org-list-get-bullet list-beg struct))
-	   (bullet-rule-p (cdr (assq 'bullet org-list-automatic-rules)))
 	   (alpha-p (org-list-use-alpha-bul-p list-beg struct prevs))
 	   (case-fold-search nil)
 	   (current (cond
@@ -2243,22 +2252,21 @@ is an integer, 0 means `-', 1 means `+' etc.  If WHICH is
 	   (bullet-list
 	    (append '("-" "+" )
 		    ;; *-bullets are not allowed at column 0.
-		    (unless (and bullet-rule-p
-				 (looking-at "\\S-")) '("*"))
+		    (unless (looking-at "\\S-") '("*"))
 		    ;; Description items cannot be numbered.
 		    (unless (or (eq org-plain-list-ordered-item-terminator ?\))
-				(and bullet-rule-p (org-at-item-description-p)))
+				(org-at-item-description-p))
 		      '("1."))
 		    (unless (or (eq org-plain-list-ordered-item-terminator ?.)
-				(and bullet-rule-p (org-at-item-description-p)))
+				(org-at-item-description-p))
 		      '("1)"))
 		    (unless (or (not alpha-p)
 				(eq org-plain-list-ordered-item-terminator ?\))
-				(and bullet-rule-p (org-at-item-description-p)))
+				(org-at-item-description-p))
 		      '("a." "A."))
 		    (unless (or (not alpha-p)
 				(eq org-plain-list-ordered-item-terminator ?.)
-				(and bullet-rule-p (org-at-item-description-p)))
+				(org-at-item-description-p))
 		      '("a)" "A)"))))
 	   (len (length bullet-list))
 	   (item-index (- len (length (member current bullet-list))))
@@ -2814,8 +2822,7 @@ COMPARE-FUNC to compare entries."
 	     (sort-func (cond
 			 ((= dcst ?a) 'string<)
 			 ((= dcst ?f) compare-func)
-			 ((= dcst ?t) '<)
-			 (t nil)))
+			 ((= dcst ?t) '<)))
 	     (next-record (lambda ()
 			    (skip-chars-forward " \r\t\n")
 			    (beginning-of-line)))

+ 1 - 2
lisp/org-lparse.el

@@ -1929,8 +1929,7 @@ See `org-xhtml-entity-format-callbacks-alist' for more information."
 		  (cond
 		   ((string= align "l") "left")
 		   ((string= align "r") "right")
-		   ((string= align "c") "center")
-		   (t nil))))))))
+		   ((string= align "c") "center"))))))))
   (incf org-lparse-table-rownum)
   (let ((i -1))
     (org-lparse-format

+ 1 - 2
lisp/org-mobile.el

@@ -451,8 +451,7 @@ agenda view showing the flagged items."
 			      ((eq (car x) :startgroup) "{")
 			      ((eq (car x) :endgroup) "}")
 			      ((eq (car x) :newline) nil)
-			      ((listp x) (car x))
-			      (t nil)))
+			      ((listp x) (car x))))
 		      def-tags))
       (setq def-tags (delq nil def-tags))
       (setq tags (org-delete-all def-tags tags))

+ 167 - 155
lisp/org.el

@@ -1409,7 +1409,7 @@ description to use."
 (defcustom org-url-hexify-p t
   "When non-nil, hexify URL when creating a link."
   :type 'boolean
-  :version "24.2"
+  :version "24.3"
   :group 'org-link-store)
 
 (defcustom org-email-link-description-format "Email %c: %.30s"
@@ -1853,7 +1853,7 @@ For more examples, see the system specific constants
 (defcustom org-doi-server-url "http://dx.doi.org/"
   "The URL of the DOI server."
   :type 'string
-  :version "24.2"
+  :version "24.3"
   :group 'org-link-follow)
 
 (defgroup org-refile nil
@@ -2752,8 +2752,8 @@ This affects the following situations:
 If you set this variable to the symbol `time', then also the following
 will work:
 
-3. If the user gives a time, but no day.  If the time is before now,
-   to will be interpreted as tomorrow.
+3. If the user gives a time.
+   If the time is before now, it will be interpreted as tomorrow.
 
 Currently none of this works for ISO week specifications.
 
@@ -3425,7 +3425,7 @@ imagemagick     Convert the LaTeX fragments to pdf files and use imagemagick
    directories relative to the processed org files paths.  An absolute path
    puts all preview images at the same place."
   :group 'org-latex
-  :version "24.2"
+  :version "24.3"
   :type 'string)
 
 (defun org-format-latex-mathml-available-p ()
@@ -3611,7 +3611,7 @@ The default use of these custom properties is to let the user
 hide them with `org-toggle-custom-properties-visibility'."
   :group 'org-properties
   :group 'org-appearance
-  :version "24.2"
+  :version "24.3"
   :type '(repeat (string :tag "Property Name")))
 
 (defcustom org-fontify-done-headline nil
@@ -4307,7 +4307,7 @@ Otherwise, these types are allowed:
 		 (const :tag "Only scheduled timestamps" scheduled)
 		 (const :tag "Only deadline timestamps" deadline))
   :group 'org-sparse-trees
-  :version "24.2")
+  :version "24.3")
 
 (defun org-cycle-hide-archived-subtrees (state)
   "Re-hide all archived subtrees after a visibility state change."
@@ -5090,8 +5090,8 @@ The following commands are available:
   (org-update-radio-target-regexp)
   ;; Comments
   (org-set-local 'comment-use-syntax nil)
-  (org-set-local 'comment-start "#")
-  (org-set-local 'comment-start-skip "# ?")
+  (org-set-local 'comment-start "# ")
+  (org-set-local 'comment-start-skip "#\\(?:[ \t]\\|$\\)")
   (org-set-local 'comment-insert-comment-function 'org-insert-comment)
   (org-set-local 'comment-region-function 'org-comment-or-uncomment-region)
   (org-set-local 'uncomment-region-function 'org-comment-or-uncomment-region)
@@ -5450,7 +5450,12 @@ will be prompted for."
   "Run through the buffer and add overlays to links."
   (catch 'exit
     (let (f)
-      (if (re-search-forward org-plain-link-re limit t)
+      (if (and (re-search-forward (concat org-plain-link-re) limit t)
+	       (or (not (member 'bracket org-activate-links))
+		   (save-excursion
+		     (save-match-data
+		       (goto-char (match-beginning 0))
+		       (not (looking-back "\\[\\["))))))
 	  (progn
 	    (org-remove-flyspell-overlays-in (match-beginning 0) (match-end 0))
 	    (setq f (get-text-property (match-beginning 0) 'face))
@@ -5579,7 +5584,8 @@ by a #."
 	     (if (string-equal dc1 "+title:")
 		 '(font-lock-fontified t face org-document-title)
 	       '(font-lock-fontified t face org-document-info))))
-	   ((or (member dc1 '("+begin:" "+end:" "+caption:" "+label:"
+	   ((or (equal dc1 "+results")
+		(member dc1 '("+begin:" "+end:" "+caption:" "+label:"
 			      "+orgtbl:" "+tblfm:" "+tblname:" "+results:"
 			      "+call:" "+header:" "+headers:" "+name:"))
 		(and (match-end 4) (equal dc3 "+attr")))
@@ -5772,8 +5778,7 @@ by a #."
 	   ((equal org-export-with-sub-superscripts '{})
 	    (list org-match-substring-with-braces-regexp))
 	   (org-export-with-sub-superscripts
-	    (list org-match-substring-regexp))
-	   (t nil)))
+	    (list org-match-substring-regexp))))
 	 (re-latex
 	  (if org-export-with-LaTeX-fragments
 	      (mapcar (lambda (x) (nth 1 x)) latexs)))
@@ -5992,7 +5997,6 @@ needs to be inserted at a specific position in the font-lock sequence.")
 				 org-comment-string "\\|" org-quote-string
 				 "\\)"))
 		 '(2 'org-special-keyword t))
-	   '("^[ \t]*#.*" (0 'font-lock-comment-face t))
 	   ;; Blocks and meta lines
 	   '(org-fontify-meta-lines-and-blocks)
 	   )))
@@ -7920,8 +7924,7 @@ the inserted text when done."
 			      (- (match-end 1) (match-beginning 1)))
 			     ((and (bolp)
 				   (looking-at org-outline-regexp))
-			      (- (match-end 0) (point) 1))
-			     (t nil)))
+			      (- (match-end 0) (point) 1))))
 	  (previous-level (save-excursion
 			    (condition-case nil
 				(progn
@@ -8373,8 +8376,7 @@ WITH-CASE, the sorting considers case as well."
          (cond
           ((= dcst ?a) 'string<)
           ((= dcst ?f) compare-func)
-          ((member dcst '(?p ?t ?s ?d ?c)) '<)
-          (t nil)))))
+          ((member dcst '(?p ?t ?s ?d ?c)) '<)))))
     (run-hooks 'org-after-sorting-entries-or-items-hook)
     (message "Sorting entries...done")))
 
@@ -8697,7 +8699,8 @@ call CMD."
 
 (defun org-refresh-category-properties ()
   "Refresh category text properties in the buffer."
-  (let ((inhibit-read-only t)
+  (let ((case-fold-search t)
+	(inhibit-read-only t)
 	(def-cat (cond
 		  ((null org-category)
 		   (if buffer-file-name
@@ -8960,8 +8963,7 @@ For file links, arg negates `org-context-in-file-links'."
 	   (setq txt (cond
 		      ((org-at-heading-p) nil)
 		      ((org-region-active-p)
-		       (buffer-substring (region-beginning) (region-end)))
-		      (t nil)))
+		       (buffer-substring (region-beginning) (region-end)))))
 	   (when (or (null txt) (string-match "\\S-" txt))
 	     (setq cpltxt
 		   (concat cpltxt "::"
@@ -9783,7 +9785,8 @@ application the system uses for this file type."
 
 	  (save-excursion
 	    (when (or (org-in-regexp org-angle-link-re)
-		      (org-in-regexp org-plain-link-re))
+		      (and (goto-char (car (org-in-regexp org-plain-link-re)))
+			   (save-match-data (not (looking-back "\\[\\[")))))
 	      (setq type (match-string 1)
 		    path (org-link-unescape (match-string 2)))
 	      (throw 'match t)))
@@ -9923,15 +9926,13 @@ application the system uses for this file type."
 	    (let ((cmd `(org-link-search
 			 ,path
 			 ,(cond ((equal arg '(4)) ''occur)
-				((equal arg '(16)) ''org-occur)
-				(t nil))
+				((equal arg '(16)) ''org-occur))
 			 ,pos)))
 	      (condition-case nil (let ((org-link-search-inhibit-query t))
 				    (eval cmd))
 		(error (progn (widen) (eval cmd))))))
 
-	   (t
-	    (browse-url-at-point)))))))
+	   (t (browse-url-at-point)))))))
     (move-marker org-open-link-marker nil)
     (run-hook-with-args 'org-follow-link-hook)))
 
@@ -10558,8 +10559,7 @@ on the system \"/user@host:\"."
          (tramp-handle-file-remote-p file))
         ((and (boundp 'ange-ftp-name-format)
               (string-match (car ange-ftp-name-format) file))
-         t)
-        (t nil)))
+         t)))
 
 
 ;;;; Refiling
@@ -11157,20 +11157,20 @@ this is used for the GOTO interface."
 (defun org-find-dblock (name)
   "Find the first dynamic block with name NAME in the buffer.
 If not found, stay at current position and return nil."
-  (let (pos)
+  (let ((case-fold-search t) pos)
     (save-excursion
       (goto-char (point-min))
-      (setq pos (and (re-search-forward (concat "^[ \t]*#\\+BEGIN:[ \t]+" name "\\>")
-					nil t)
+      (setq pos (and (re-search-forward
+		      (concat "^[ \t]*#\\+\\(?:BEGIN\\|begin\\):[ \t]+" name "\\>") nil t)
 		     (match-beginning 0))))
     (if pos (goto-char pos))
     pos))
 
 (defconst org-dblock-start-re
-  "^[ \t]*#\\+BEGIN:[ \t]+\\(\\S-+\\)\\([ \t]+\\(.*\\)\\)?"
+  "^[ \t]*#\\+\\(?:BEGIN\\|begin\\):[ \t]+\\(\\S-+\\)\\([ \t]+\\(.*\\)\\)?"
   "Matches the start line of a dynamic block, with parameters.")
 
-(defconst org-dblock-end-re "^[ \t]*#\\+END\\([: \t\r\n]\\|$\\)"
+(defconst org-dblock-end-re "^[ \t]*#\\+\\(?:END\\|end\\)\\([: \t\r\n]\\|$\\)"
   "Matches the end of a dynamic block.")
 
 (defun org-create-dblock (plist)
@@ -11322,7 +11322,7 @@ This function can be used in a hook."
   '("TITLE:" "AUTHOR:" "EMAIL:" "DATE:"
     "DESCRIPTION:" "KEYWORDS:" "LANGUAGE:" "OPTIONS:"
     "EXPORT_SELECT_TAGS:" "EXPORT_EXCLUDE_TAGS:"
-    "LINK_UP:" "LINK_HOME:" "LINK:"
+    "LINK_UP:" "LINK_HOME:" "LINK:" "TODO:"
     "XSLT:" "CATEGORY:" "SEQ_TODO:" "TYP_TODO:"
     "PRIORITIES:" "DRAWERS:" "STARTUP:" "TAGS:"
     "FILETAGS:" "ARCHIVE:"))
@@ -12537,8 +12537,7 @@ EXTRA is additional text that will be inserted into the notes buffer."
   (let* ((org-log-into-drawer (org-log-into-drawer))
 	 (drawer (cond ((stringp org-log-into-drawer)
 			org-log-into-drawer)
-		       (org-log-into-drawer "LOGBOOK")
-		       (t nil))))
+		       (org-log-into-drawer "LOGBOOK"))))
     (save-restriction
       (save-excursion
 	(when findpos
@@ -13645,8 +13644,7 @@ If DATA is nil or the empty string, any tags will be removed."
 	  (concat ":" (mapconcat 'identity (org-split-string data ":+") ":")
 		  ":"))
 	 ((listp data)
-	  (concat ":" (mapconcat 'identity data ":") ":"))
-	 (t nil)))
+	  (concat ":" (mapconcat 'identity data ":") ":"))))
   (when data
     (save-excursion
       (org-back-to-heading t)
@@ -13962,8 +13960,7 @@ Returns the new tags string, or nil to not change the current settings."
 				   ((not (assoc tg table))
 				    (org-get-todo-face tg))
 				   ((member tg current) c-face)
-				   ((member tg inherited) i-face)
-				   (t nil))))
+				   ((member tg inherited) i-face))))
 	  (if (and (= cnt 0) (not ingroup)) (insert "  "))
 	  (insert "[" c "] " tg (make-string
 				 (- fwidth 4 (length tg)) ?\ ))
@@ -15557,10 +15554,11 @@ user."
       (setq ans "+0"))
 
     (when (setq delta (org-read-date-get-relative ans (current-time) org-def))
-      (setq ans (replace-match "" t t ans)
-	    deltan (car delta)
-	    deltaw (nth 1 delta)
-            deltadef (nth 2 delta)))
+      (unless (save-match-data (string-match org-plain-time-of-day-regexp ans))
+	(setq ans (replace-match "" t t ans)
+	      deltan (car delta)
+	      deltaw (nth 1 delta)
+	      deltadef (nth 2 delta))))
 
     ;; Check if there is an iso week date in there
     ;; If yes, store the info and postpone interpreting it until the rest
@@ -15713,7 +15711,6 @@ user."
 	    ((equal deltaw "m") (setq month (+ month deltan)))
 	    ((equal deltaw "y") (setq year (+ year deltan)))))
      ((and wday (not (nth 3 tl)))
-      (setq futurep nil)
       ;; Weekday was given, but no day, so pick that day in the week
       ;; on or after the derived date.
       (setq wday1 (nth 6 (decode-time (encode-time 0 0 0 day month year))))
@@ -16210,8 +16207,7 @@ D may be an absolute day number, or a calendar-type list (month day year)."
 		(stringp (cdr result))) (cdr result))
 	  ((and (consp result)
 		(stringp (car result))) result)
-	  (result entry)
-          (t nil))))
+	  (result entry))))
 
 (defun org-diary-to-ical-string (frombuf)
   "Get iCalendar entries from diary entries in buffer FROMBUF.
@@ -20351,21 +20347,22 @@ and :keyword."
       (push (list :table-table) clist)))
     (goto-char p)
 
-    ;; New the "medium" contexts: clocktables, source blocks
-    (cond ((org-in-clocktable-p)
-	   (push (list :clocktable
-		       (and (or (looking-at "#\\+BEGIN: clocktable")
-				(search-backward "#+BEGIN: clocktable" nil t))
-			    (match-beginning 0))
-		       (and (re-search-forward "#\\+END:?" nil t)
-			    (match-end 0))) clist))
-	  ((org-in-src-block-p)
-	   (push (list :src-block
-		       (and (or (looking-at "#\\+BEGIN_SRC")
-				(search-backward "#+BEGIN_SRC" nil t))
-			    (match-beginning 0))
-		       (and (search-forward "#+END_SRC" nil t)
-			    (match-beginning 0))) clist)))
+    (let ((case-fold-search t))
+      ;; New the "medium" contexts: clocktables, source blocks
+      (cond ((org-in-clocktable-p)
+	     (push (list :clocktable
+			 (and (or (looking-at "#\\+BEGIN: clocktable")
+				  (search-backward "#+BEGIN: clocktable" nil t))
+			      (match-beginning 0))
+			 (and (re-search-forward "#\\+END:?" nil t)
+			      (match-end 0))) clist))
+	    ((org-in-src-block-p)
+	     (push (list :src-block
+			 (and (or (looking-at "#\\+BEGIN_SRC")
+				  (search-backward "#+BEGIN_SRC" nil t))
+			      (match-beginning 0))
+			 (and (search-forward "#+END_SRC" nil t)
+			      (match-beginning 0))) clist))))
     (goto-char p)
 
     ;; Now the small context
@@ -20960,53 +20957,54 @@ hierarchy of headlines by UP levels before marking the subtree."
   "Compute a fill prefix for the line at point P.
 Return fill prefix, as a string, or nil if current line isn't
 meant to be filled."
-  (unless (and (derived-mode-p 'message-mode) (not (message-in-body-p)))
-    ;; FIXME: Prevent an error for users who forgot to make autoloads?
-    ;; See also `org-fill-paragraph', which has the same.
-    (require 'org-element)
-    ;; FIXME: This is really the job of orgstruct++-mode
-    (save-excursion
-      (goto-char p)
-      (beginning-of-line)
-      (let* ((element (org-element-at-point))
-	     (type (org-element-type element))
-	     (post-affiliated
-	      (progn
-		(goto-char (org-element-property :begin element))
-		(while (looking-at org-element--affiliated-re) (forward-line))
-		(point))))
-	(unless (< p post-affiliated)
-	  (case type
-	    (comment (looking-at "[ \t]*# ?") (match-string 0))
-	    (footnote-definition "")
-	    ((item plain-list)
-	     (make-string (org-list-item-body-column
-			   (org-element-property :begin element))
-			  ? ))
-	    (paragraph
-	     ;; Fill prefix is usually the same as the current line,
-	     ;; except if the paragraph is at the beginning of an item.
-	     (let ((parent (org-element-property :parent element)))
-	       (cond ((eq (org-element-type parent) 'item)
-		      (make-string (org-list-item-body-column
-				    (org-element-property :begin parent))
-				   ? ))
-		     ((looking-at "\\s-+") (match-string 0))
-		     (t  ""))))
-	    ((comment-block verse-block)
-	     ;; Only fill contents if P is within block boundaries.
-	     (let* ((cbeg (save-excursion (goto-char post-affiliated)
-					  (forward-line)
-					  (point)))
-		    (cend (save-excursion
-			    (goto-char (org-element-property :end element))
-			    (skip-chars-backward " \r\t\n")
-			    (line-beginning-position))))
-	       (when (and (>= p cbeg) (< p cend))
-		 (if (looking-at "\\s-+") (match-string 0) ""))))))))))
-
-(defvar org-element-paragraph-separate)  ; From org-element.el
-(defvar org-element-all-objects)         ; From org-element.el
+  (org-with-wide-buffer
+   (unless (and (derived-mode-p 'message-mode) (not (message-in-body-p)))
+     ;; FIXME: Prevent an error for users who forgot to make autoloads?
+     ;; See also `org-fill-paragraph', which has the same.
+     (require 'org-element)
+     ;; FIXME: This is really the job of orgstruct++-mode
+     (goto-char p)
+     (beginning-of-line)
+     (let* ((element (org-element-at-point))
+	    (type (org-element-type element))
+	    (post-affiliated
+	     (progn
+	       (goto-char (org-element-property :begin element))
+	       (while (looking-at org-element--affiliated-re) (forward-line))
+	       (point))))
+       (unless (< p post-affiliated)
+	 (case type
+	   (comment (looking-at "[ \t]*# ?") (match-string 0))
+	   (footnote-definition "")
+	   ((item plain-list)
+	    (make-string (org-list-item-body-column
+			  (org-element-property :begin element))
+			 ? ))
+	   (paragraph
+	    ;; Fill prefix is usually the same as the current line,
+	    ;; except if the paragraph is at the beginning of an item.
+	    (let ((parent (org-element-property :parent element)))
+	      (cond ((eq (org-element-type parent) 'item)
+		     (make-string (org-list-item-body-column
+				   (org-element-property :begin parent))
+				  ? ))
+		    ((looking-at "\\s-+") (match-string 0))
+		    (t  ""))))
+	   ((comment-block verse-block)
+	    ;; Only fill contents if P is within block boundaries.
+	    (let* ((cbeg (save-excursion (goto-char post-affiliated)
+					 (forward-line)
+					 (point)))
+		   (cend (save-excursion
+			   (goto-char (org-element-property :end element))
+			   (skip-chars-backward " \r\t\n")
+			   (line-beginning-position))))
+	      (when (and (>= p cbeg) (< p cend))
+		(if (looking-at "\\s-+") (match-string 0) ""))))))))))
+
+(declare-function message-goto-body "message" ())
+(defvar message-cite-prefix-regexp)	; From message.el
+(defvar org-element-all-objects)	; From org-element.el
 (defun org-fill-paragraph (&optional justify)
   "Fill element at point, when applicable.
 
@@ -21027,11 +21025,13 @@ a footnote definition, try to fill the first paragraph within."
   (if (and (derived-mode-p 'message-mode)
 	   (or (not (message-in-body-p))
 	       (save-excursion (move-beginning-of-line 1)
-			       (looking-at "^>+ "))))
-      (let ((fill-paragraph-function (cadadr (assoc 'fill-paragraph-function org-fb-vars)))
+			       (looking-at message-cite-prefix-regexp))))
+      (let ((fill-paragraph-function
+	     (cadadr (assoc 'fill-paragraph-function org-fb-vars)))
 	    (fill-prefix (cadadr (assoc 'fill-prefix org-fb-vars)))
 	    (paragraph-start (cadadr (assoc 'paragraph-start org-fb-vars)))
-	    (paragraph-separate (cadadr (assoc 'paragraph-separate org-fb-vars))))
+	    (paragraph-separate
+	     (cadadr (assoc 'paragraph-separate org-fb-vars))))
 	(fill-paragraph))
     (save-excursion
       ;; Move to end of line in order to get the first paragraph within
@@ -21050,50 +21050,62 @@ a footnote definition, try to fill the first paragraph within."
 	     t)
 	    ;; Elements that may contain `line-break' type objects.
 	    ((paragraph verse-block)
-	     (let ((beg (org-element-property :contents-begin element))
-		   (end (org-element-property :contents-end element))
+	     (let ((beg (max (point-min)
+			     (org-element-property :contents-begin element)))
+		   (end (min (point-max)
+			     (org-element-property :contents-end element)))
 		   (type (org-element-type element)))
 	       ;; Do nothing if point is at an affiliated keyword or at
 	       ;; verse block markers.
 	       (if (or (< (point) beg)
 		       (and (eq type 'verse-block) (>= (point) end)))
 		   t
-		 ;; At a verse block, first narrow to current "paragraph"
-		 ;; and set current element to that paragraph.
-		 (save-restriction
-		   (when (eq type 'verse-block)
-		     (narrow-to-region beg end)
-		     (save-excursion
-		       (let ((bol-pos (point-at-bol)))
-			 (re-search-backward
-			  org-element-paragraph-separate nil 'm)
-			 (unless (or (bobp) (= (point-at-bol) bol-pos))
-			   (forward-line))
-			 (setq element (org-element-paragraph-parser end)
-			       beg (org-element-property :contents-begin element)
-			       end (org-element-property
-				    :contents-end element)))))
-		   ;; Fill paragraph, taking line breaks into consideration.
-		   ;; For that, slice the paragraph using line breaks as
-		   ;; separators, and fill the parts in reverse order to
-		   ;; avoid messing with markers.
+		 ;; In verse blocks and `message-mode', boundaries of
+		 ;; region to fill have to be tweaked.
+		 (cond
+		  ;; At a verse block, fill current "paragraph", that
+		  ;; is part of text separated by blank lines.
+		  ((eq type 'verse-block)
 		   (save-excursion
-		     (goto-char end)
-		     (mapc
-		      (lambda (pos)
-			(let ((fill-prefix (org-fill-context-prefix pos)))
-			  (fill-region-as-paragraph pos (point) justify))
-			(goto-char pos))
-		      ;; Find the list of ending positions for line breaks
-		      ;; in the current paragraph.  Add paragraph beginning
-		      ;; to include first slice.
-		      (nreverse
-		       (cons beg
-			     (org-element-map
-			      (org-element--parse-objects
-			       beg end nil org-element-all-objects)
-			      'line-break
-			      (lambda (lb) (org-element-property :end lb))))))))
+		     (when (looking-at "[ \t]*$")
+		       (skip-chars-backward " \r\t\n" beg))
+		     (when (re-search-backward "^[ \t]*$" beg t)
+		       (forward-line)
+		       (setq beg (point))))
+		   (when (save-excursion (re-search-forward "^[ \t]*$" end t))
+		     (setq end (match-beginning 0))))
+		  ;; In `message-mode', do not fill following citation
+		  ;; in current paragraph nor text before message
+		  ;; body.
+		  ((derived-mode-p 'message-mode)
+		   (let ((body-start (save-excursion (message-goto-body))))
+		     (when body-start (setq beg (max body-start beg))))
+		   (when (save-excursion
+			   (re-search-forward
+			    (concat "^" message-cite-prefix-regexp) end t))
+		     (setq end (match-beginning 0)))))
+		 ;; Fill paragraph, taking line breaks into consideration.
+		 ;; For that, slice the paragraph using line breaks as
+		 ;; separators, and fill the parts in reverse order to
+		 ;; avoid messing with markers.
+		 (save-excursion
+		   (goto-char end)
+		   (mapc
+		    (lambda (pos)
+		      (let ((fill-prefix (org-fill-context-prefix pos)))
+			(fill-region-as-paragraph pos (point) justify))
+		      (goto-char pos))
+		    ;; Find the list of ending positions for line breaks
+		    ;; in the current paragraph.  Add paragraph beginning
+		    ;; to include first slice.
+		    (nreverse
+		     (cons
+		      beg
+		      (org-element-map
+		       (org-element--parse-objects
+			beg end nil org-element-all-objects)
+		       'line-break
+		       (lambda (lb) (org-element-property :end lb)))))))
 		 t)))
 	    ;; Contents of `comment-block' type elements should be filled as
 	    ;; plain text.
@@ -21103,7 +21115,8 @@ a footnote definition, try to fill the first paragraph within."
 		 (fill-region-as-paragraph
 		  (progn
 		    (goto-char (org-element-property :begin element))
-		    (while (looking-at org-element--affiliated-re) (forward-line))
+		    (while (looking-at org-element--affiliated-re)
+		      (forward-line))
 		    (forward-line)
 		    (point))
 		  (progn
@@ -21118,7 +21131,8 @@ a footnote definition, try to fill the first paragraph within."
 		 (fill-region-as-paragraph
 		  (progn
 		    (goto-char (org-element-property :begin element))
-		    (while (looking-at org-element--affiliated-re) (forward-line))
+		    (while (looking-at org-element--affiliated-re)
+		      (forward-line))
 		    (point))
 		  (progn
 		    (goto-char (org-element-property :end element))
@@ -22061,12 +22075,10 @@ Show the heading too, if it is currently invisible."
 (defun org-make-options-regexp (kwds &optional extra)
   "Make a regular expression for keyword lines."
   (concat
-   "^"
-   "#?[ \t]*\\+\\("
+   "^#\\+\\("
    (mapconcat 'regexp-quote kwds "\\|")
    (if extra (concat "\\|" extra))
-   "\\):[ \t]*"
-   "\\(.*\\)"))
+   "\\):[ \t]*\\(.*\\)"))
 
 ;; Make isearch reveal the necessary context
 (defun org-isearch-end ()

+ 42 - 21
testing/lisp/test-org-element.el

@@ -128,34 +128,25 @@ Some other text
 			      (org-element-map tree 'italic 'identity nil t))
 	(org-element-map tree 'paragraph 'identity nil t))))))
 
-(ert-deftest test-org-element/adopt-element ()
-  "Test `org-element-adopt-element' specifications."
+(ert-deftest test-org-element/adopt-elements ()
+  "Test `org-element-adopt-elements' specifications."
   ;; Adopt an element.
   (should
-   (equal '(italic plain-text)
+   (equal '(plain-text italic)
 	  (org-test-with-temp-text "* Headline\n *a*"
 	    (let ((tree (org-element-parse-buffer)))
-	      (org-element-adopt-element
+	      (org-element-adopt-elements
 	       (org-element-map tree 'bold 'identity nil t) '(italic nil "a"))
 	      (mapcar (lambda (blob) (org-element-type blob))
 		      (org-element-contents
 		       (org-element-map tree 'bold 'identity nil t)))))))
   ;; Adopt a string.
-  (should
-   (equal '("b" "a")
-	  (org-test-with-temp-text "* Headline\n *a*"
-	    (let ((tree (org-element-parse-buffer)))
-	      (org-element-adopt-element
-	       (org-element-map tree 'bold 'identity nil t) "b")
-	      (org-element-contents
-	       (org-element-map tree 'bold 'identity nil t))))))
-  ;; Test APPEND optional argument.
   (should
    (equal '("a" "b")
 	  (org-test-with-temp-text "* Headline\n *a*"
 	    (let ((tree (org-element-parse-buffer)))
-	      (org-element-adopt-element
-	       (org-element-map tree 'bold 'identity nil t) "b" t)
+	      (org-element-adopt-elements
+	       (org-element-map tree 'bold 'identity nil t) "b")
 	      (org-element-contents
 	       (org-element-map tree 'bold 'identity nil t)))))))
 
@@ -297,10 +288,6 @@ CLOCK: [2012-01-01 sun. 00:01]--[2012-01-01 sun. 00:02] =>  0:01"
      (org-test-with-temp-text "# First part\n# \n#\n# Second part"
        (org-element-map (org-element-parse-buffer) 'comment 'identity nil t)))
     "First part\n\n\nSecond part"))
-  ;; Keywords without colons are treated as comments.
-  (should
-   (org-test-with-temp-text "#+wrong_keyword something"
-     (org-element-map (org-element-parse-buffer) 'comment 'identity)))
   ;; Do not mix comments and keywords.
   (should
    (eq 1
@@ -903,6 +890,12 @@ DEADLINE: <2012-03-29 thu.>"
      :tag
      (org-test-with-temp-text "- tag :: description"
        (org-element-map (org-element-parse-buffer) 'item 'identity nil t)))))
+  ;; No tags in ordered lists.
+  (should-not
+   (org-element-property
+    :tag
+    (org-test-with-temp-text "1. tag :: description"
+      (org-element-map (org-element-parse-buffer) 'item 'identity nil t))))
   ;; Check-boxes
   (should
    (equal
@@ -1147,7 +1140,35 @@ e^{i\\pi}+1=0
 	 (org-element-map
 	  (org-element-parse-buffer) 'paragraph
 	  (lambda (p) (char-after (org-element-property :end p)))
-	  nil t)))))
+	  nil t))))
+  ;; Include ill-formed Keywords.
+  (should
+   (org-test-with-temp-text "#+wrong_keyword something"
+     (org-element-map (org-element-parse-buffer) 'paragraph 'identity)))
+  ;; Include incomplete-drawers.
+  (should
+   (let ((org-drawers '("TEST")))
+     (org-test-with-temp-text ":TEST:\nParagraph"
+       (let ((elem (org-element-at-point)))
+	 (and (eq (org-element-type elem) 'paragraph)
+	      (= (point-max) (org-element-property :end elem)))))))
+  ;; Include non-existent drawers.
+  (should
+   (let ((org-drawers '("TEST")))
+     (org-test-with-temp-text ":NONAME:"
+       (org-element-map (org-element-parse-buffer) 'paragraph 'identity))))
+  ;; Include incomplete blocks.
+  (should
+   (org-test-with-temp-text "#+BEGIN_CENTER\nParagraph"
+     (let ((elem (org-element-at-point)))
+       (and (eq (org-element-type elem) 'paragraph)
+	    (= (point-max) (org-element-property :end elem))))))
+  ;; Include incomplete dynamic blocks.
+  (should
+   (org-test-with-temp-text "#+BEGIN: \nParagraph"
+     (let ((elem (org-element-at-point)))
+       (and (eq (org-element-type elem) 'paragraph)
+	    (= (point-max) (org-element-property :end elem)))))))
 
 
 ;;;; Plain List
@@ -1776,7 +1797,7 @@ CLOCK: [2012-01-01 sun. 00:01]--[2012-01-01 sun. 00:02] =>  0:01"))
 (ert-deftest test-org-element/comment-interpreter ()
   "Test comment interpreter."
   ;; Regular comment.
-  (should (equal (org-test-parse-and-interpret "#Comment") "# Comment\n"))
+  (should (equal (org-test-parse-and-interpret "# Comment") "# Comment\n"))
   ;; Inline comment.
   (should (equal (org-test-parse-and-interpret "  # Comment")
 		 "# Comment\n"))

+ 22 - 5
testing/lisp/test-org-export.el

@@ -65,14 +65,14 @@ already filled in `info'."
    (equal
     (org-export--parse-option-keyword
      "H:1 num:t \\n:t timestamp:t arch:t author:t creator:t d:t email:t
- *:t e:t ::t f:t pri:t -:t ^:t toc:t |:t tags:t tasks:t <:t todo:t")
+ *:t e:t ::t f:t pri:t -:t ^:t toc:t |:t tags:t tasks:t <:t todo:t inline:nil")
     '(:headline-levels
       1 :preserve-breaks t :section-numbers t :time-stamp-file t
       :with-archived-trees t :with-author t :with-creator t :with-drawers t
       :with-email t :with-emphasize t :with-entities t :with-fixed-width t
-      :with-footnotes t :with-priority t :with-special-strings t
-      :with-sub-superscript t :with-toc t :with-tables t :with-tags t
-      :with-tasks t :with-timestamps t :with-todo-keywords t)))
+      :with-footnotes t :with-inlinetasks nil :with-priority t
+      :with-special-strings t :with-sub-superscript t :with-toc t :with-tables t
+      :with-tags t :with-tasks t :with-timestamps t :with-todo-keywords t)))
   ;; Test some special values.
   (should
    (equal
@@ -265,7 +265,24 @@ Paragraph"
 		"CLOSED: [2012-04-29 sun. 10:45]\n"))
 	(should
 	 (equal (org-export-as 'test nil nil nil '(:with-plannings nil))
-		""))))))
+		"")))))
+  ;; Inlinetasks.
+  (when (featurep 'org-inlinetask)
+    (should
+     (equal
+      (let ((org-inlinetask-min-level 15))
+	(org-test-with-temp-text "*************** Task"
+	  (org-test-with-backend test
+	    (org-export-as 'test nil nil nil '(:with-inlinetasks nil)))))
+      ""))
+    (should
+     (equal
+      (let ((org-inlinetask-min-level 15))
+	(org-test-with-temp-text
+	    "*************** Task\nContents\n*************** END"
+	  (org-test-with-backend test
+	    (org-export-as 'test nil nil nil '(:with-inlinetasks nil)))))
+      ""))))
 
 (ert-deftest test-org-export/comment-tree ()
   "Test if export process ignores commented trees."

+ 105 - 0
testing/lisp/test-org-list.el

@@ -113,6 +113,111 @@
 	(org-previous-item)
 	(should (looking-at "  - item 1.3"))))))
 
+(ert-deftest test-org-list/cycle-bullet ()
+  "Test `org-cycle-list-bullet' specifications."
+  ;; Error when not at an item.
+  (should-error
+   (org-test-with-temp-text "Paragraph"
+     (org-cycle-list-bullet)))
+  ;; Cycle through "-", "+", "*", "1.", "1)".
+  (org-test-with-temp-text "  - item"
+    (org-cycle-list-bullet)
+    (should (looking-at "[ \t]+\\+"))
+    (org-cycle-list-bullet)
+    (should (looking-at "[ \t]+\\*"))
+    (let ((org-plain-list-ordered-item-terminator t))
+      (org-cycle-list-bullet))
+    (should (looking-at "[ \t]+1\\."))
+    (let ((org-plain-list-ordered-item-terminator t))
+      (org-cycle-list-bullet))
+    (should (looking-at "[ \t]+1)")))
+  ;; Argument is a valid bullet: cycle to that bullet directly.
+  (should
+   (equal "1. item"
+	  (org-test-with-temp-text "- item"
+	    (let ((org-plain-list-ordered-item-terminator t))
+	      (org-cycle-list-bullet "1.")
+	      (buffer-string)))))
+  ;; Argument is an integer N: cycle to the Nth allowed bullet.
+  (should
+   (equal "+ item"
+	  (org-test-with-temp-text "1. item"
+	    (let ((org-plain-list-ordered-item-terminator t))
+	      (org-cycle-list-bullet 1)
+	      (buffer-string)))))
+  ;; Argument is `previous': cycle backwards.
+  (should
+   (equal "- item"
+	  (org-test-with-temp-text "+ item"
+	    (let ((org-plain-list-ordered-item-terminator t))
+	      (org-cycle-list-bullet 'previous)
+	      (buffer-string)))))
+  ;; Do not cycle to "*" bullets when item is at column 0.
+  (should
+   (equal "1. item"
+	  (org-test-with-temp-text "+ item"
+	    (let ((org-plain-list-ordered-item-terminator t))
+	      (org-cycle-list-bullet)
+	      (buffer-string)))))
+  ;; Do not cycle to numbered bullets in a description list.
+  (should-not
+   (equal "1. tag :: item"
+	  (org-test-with-temp-text "+ tag :: item"
+	    (let ((org-plain-list-ordered-item-terminator t))
+	      (org-cycle-list-bullet)
+	      (buffer-string)))))
+  ;; Do not cycle to ordered item terminators if they are not allowed
+  ;; in `org-plain-list-ordered-item-terminator'.
+  (should
+   (equal "  1) item"
+	  (org-test-with-temp-text "  * item"
+	    (let ((org-plain-list-ordered-item-terminator 41))
+	      (org-cycle-list-bullet)
+	      (buffer-string)))))
+  ;; When `org-alphabetical-lists' is non-nil, cycle to alpha bullets.
+  (should
+   (equal "a. item"
+	  (org-test-with-temp-text "1) item"
+	    (let ((org-plain-list-ordered-item-terminator t)
+		  (org-alphabetical-lists t))
+	      (org-cycle-list-bullet)
+	      (buffer-string)))))
+  ;; Do not cycle to alpha bullets when list has more than 26
+  ;; elements.
+  (should-not
+   (equal "a. item 1"
+	  (org-test-with-temp-text "1) item 1
+2) item 2
+3) item 3
+4) item 4
+5) item 5
+6) item 6
+7) item 7
+8) item 8
+9) item 9
+10) item 10
+11) item 11
+12) item 12
+13) item 13
+14) item 14
+15) item 15
+16) item 16
+17) item 17
+18) item 18
+19) item 19
+20) item 20
+21) item 21
+22) item 22
+23) item 23
+24) item 24
+25) item 25
+26) item 26
+27) item 27"
+	    (let ((org-plain-list-ordered-item-terminator t)
+		  (org-alphabetical-lists t))
+	      (org-cycle-list-bullet)
+	      (buffer-substring (point) (line-end-position)))))))
+
 (ert-deftest test-org-list/indent-item ()
   "Test `org-indent-item' specifications."
   ;; 1. Error when not at an item.

+ 8 - 0
testing/lisp/test-org.el

@@ -160,6 +160,14 @@ http://article.gmane.org/gmane.emacs.orgmode/21459/"
 	      (end-of-line)
 	      (org-fill-paragraph)
 	      (buffer-string)))))
+  ;; Correctly fill an element in a narrowed buffer.
+  (should
+   (equal "01234\n6"
+	  (org-test-with-temp-text "01234 6789"
+	    (let ((fill-column 5))
+	      (narrow-to-region 1 8)
+	      (org-fill-paragraph)
+	      (buffer-string)))))
   ;; Special case: Fill first paragraph when point is at an item or
   ;; a plain-list or a footnote reference.
   (should