Browse Source

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

Bastien Guerry 10 years ago
parent
commit
c9fdd7f8b1
5 changed files with 232 additions and 276 deletions
  1. 7 6
      etc/ORG-NEWS
  2. 13 12
      lisp/org-agenda.el
  3. 2 1
      lisp/org.el
  4. 136 168
      lisp/ox-icalendar.el
  5. 74 89
      lisp/ox-latex.el

+ 7 - 6
etc/ORG-NEWS

@@ -50,12 +50,13 @@ defining export blocks.
    Note that If BACKEND is a derived back-end and doesn't implement
    Note that If BACKEND is a derived back-end and doesn't implement
    its own special block translator already, there is nothing to
    its own special block translator already, there is nothing to
    change.  The parent back-end will take care of such blocks.
    change.  The parent back-end will take care of such blocks.
-*** ~org-html-format-headline-function~ requires an additional argument
+*** Signature changes
-The function provided is required to accept export options, as
+The following functions require an additional argument.  See their
-a plist, as its final (sixth) argument.
+docstring for more information.
-*** ~org-html-format-inlinetask-function~ requires an additional argument
+- ~org-html-format-headline-function~
-The function provided is required to accept export options, as
+- ~org-html-format-inlinetask-function~
-a plist, as its final (seventh) argument.
+- ~org-latex-format-headline-function~
+- ~org-latex-format-inlinetask-function~
 ** Removed functions
 ** Removed functions
 *** Removed function ~org-beamer-insert-options-template~
 *** Removed function ~org-beamer-insert-options-template~
 This function inserted a Beamer specific template at point or in
 This function inserted a Beamer specific template at point or in

+ 13 - 12
lisp/org-agenda.el

@@ -3312,19 +3312,20 @@ This ensures the export commands can easily use it."
 (defvar org-agenda-write-buffer-name "Agenda View")
 (defvar org-agenda-write-buffer-name "Agenda View")
 (defun org-agenda-write (file &optional open nosettings agenda-bufname)
 (defun org-agenda-write (file &optional open nosettings agenda-bufname)
   "Write the current buffer (an agenda view) as a file.
   "Write the current buffer (an agenda view) as a file.
+
 Depending on the extension of the file name, plain text (.txt),
 Depending on the extension of the file name, plain text (.txt),
 HTML (.html or .htm), PDF (.pdf) or Postscript (.ps) is produced.
 HTML (.html or .htm), PDF (.pdf) or Postscript (.ps) is produced.
-If the extension is .ics, run icalendar export over all files used
+If the extension is .ics, translate visible agenda into iCalendar
-to construct the agenda and limit the export to entries listed in the
+format.  If the extension is .org, collect all subtrees
-agenda now.
+corresponding to the agenda entries and add them in an .org file.
-If the extension is .org, collect all subtrees corresponding to the
+
-agenda entries and add them in an .org file.
+With prefix argument OPEN, open the new file immediately.  If
-With prefix argument OPEN, open the new file immediately.
+NOSETTINGS is given, do not scope the settings of
-If NOSETTINGS is given, do not scope the settings of
+`org-agenda-exporter-settings' into the export commands.  This is
-`org-agenda-exporter-settings' into the export commands.  This is used when
+used when the settings have already been scoped and we do not
-the settings have already been scoped and we do not wish to overrule other,
+wish to overrule other, higher priority settings.  If
-higher priority settings.
+AGENDA-BUFFER-NAME is provided, use this as the buffer name for
-If AGENDA-BUFFER-NAME, use this as the buffer name for the agenda to write."
+the agenda to write."
   (interactive "FWrite agenda to file: \nP")
   (interactive "FWrite agenda to file: \nP")
   (if (or (not (file-writable-p file))
   (if (or (not (file-writable-p file))
 	  (and (file-exists-p file)
 	  (and (file-exists-p file)
@@ -3359,7 +3360,7 @@ If AGENDA-BUFFER-NAME, use this as the buffer name for the agenda to write."
 			   content)))
 			   content)))
 		 (find-file file)
 		 (find-file file)
 		 (erase-buffer)
 		 (erase-buffer)
-		 (mapcar (lambda (s) (org-paste-subtree 1 s)) (reverse content))
+		 (dolist (s content) (org-paste-subtree 1 s))
 		 (write-file file)
 		 (write-file file)
 		 (kill-buffer (current-buffer))
 		 (kill-buffer (current-buffer))
 		 (message "Org file written to %s" file)))
 		 (message "Org file written to %s" file)))

+ 2 - 1
lisp/org.el

@@ -6820,7 +6820,8 @@ in special contexts.
       (setq org-cycle-global-status 'overview)
       (setq org-cycle-global-status 'overview)
       (run-hook-with-args 'org-cycle-hook 'overview)))))
       (run-hook-with-args 'org-cycle-hook 'overview)))))
 
 
-(defvar org-called-with-limited-levels);Dyn-bound in ̀org-with-limited-levels'.
+(defvar org-called-with-limited-levels nil
+  "Non-nil when `org-with-limited-levels' is currently active.")
 
 
 (defun org-cycle-internal-local ()
 (defun org-cycle-internal-local ()
   "Do the local cycling action."
   "Do the local cycling action."

+ 136 - 168
lisp/ox-icalendar.el

@@ -269,11 +269,7 @@ re-read the iCalendar file.")
     (:icalendar-store-UID nil nil org-icalendar-store-UID)
     (:icalendar-store-UID nil nil org-icalendar-store-UID)
     (:icalendar-timezone nil nil org-icalendar-timezone)
     (:icalendar-timezone nil nil org-icalendar-timezone)
     (:icalendar-use-deadline nil nil org-icalendar-use-deadline)
     (:icalendar-use-deadline nil nil org-icalendar-use-deadline)
-    (:icalendar-use-scheduled nil nil org-icalendar-use-scheduled)
+    (:icalendar-use-scheduled nil nil org-icalendar-use-scheduled))
-    ;; The following property will be non-nil when export has been
-    ;; started from org-agenda-mode.  In this case, any entry without
-    ;; a non-nil "ICALENDAR_MARK" property will be ignored.
-    (:icalendar-agenda-view nil nil nil))
   :filters-alist
   :filters-alist
   '((:filter-headline . org-icalendar-clear-blank-lines))
   '((:filter-headline . org-icalendar-clear-blank-lines))
   :menu-entry
   :menu-entry
@@ -288,22 +284,18 @@ re-read the iCalendar file.")
 
 
 ;;; Internal Functions
 ;;; Internal Functions
 
 
-(defun org-icalendar-create-uid (file &optional bell h-markers)
+(defun org-icalendar-create-uid (file &optional bell)
   "Set ID property on headlines missing it in FILE.
   "Set ID property on headlines missing it in FILE.
 When optional argument BELL is non-nil, inform the user with
 When optional argument BELL is non-nil, inform the user with
-a message if the file was modified.  With optional argument
+a message if the file was modified."
-H-MARKERS non-nil, it is a list of markers for the headlines
+  (let (modified-flag)
-which will be updated."
-  (let ((pt (if h-markers (goto-char (car h-markers)) (point-min)))
-	modified-flag)
     (org-map-entries
     (org-map-entries
      (lambda ()
      (lambda ()
        (let ((entry (org-element-at-point)))
        (let ((entry (org-element-at-point)))
-	 (unless (or (< (point) pt) (org-element-property :ID entry))
+	 (unless (org-element-property :ID entry)
 	   (org-id-get-create)
 	   (org-id-get-create)
 	   (setq modified-flag t)
 	   (setq modified-flag t)
-	   (forward-line))
+	   (forward-line))))
-	 (when h-markers (setq org-map-continue-from (pop h-markers)))))
      nil nil 'comment)
      nil nil 'comment)
     (when (and bell modified-flag)
     (when (and bell modified-flag)
       (message "ID properties created in file \"%s\"" file)
       (message "ID properties created in file \"%s\"" file)
@@ -534,99 +526,97 @@ inlinetask within the section."
 		     (cons 'org-data
 		     (cons 'org-data
 			   (cons nil (org-element-contents first))))))))
 			   (cons nil (org-element-contents first))))))))
       (concat
       (concat
-       (unless (and (plist-get info :icalendar-agenda-view)
+       (let ((todo-type (org-element-property :todo-type entry))
-		    (not (org-element-property :ICALENDAR-MARK entry)))
+	     (uid (or (org-element-property :ID entry) (org-id-new)))
-	 (let ((todo-type (org-element-property :todo-type entry))
+	     (summary (org-icalendar-cleanup-string
-	       (uid (or (org-element-property :ID entry) (org-id-new)))
+		       (or (org-element-property :SUMMARY entry)
-	       (summary (org-icalendar-cleanup-string
+			   (org-export-data
-			 (or (org-element-property :SUMMARY entry)
+			    (org-element-property :title entry) info))))
-			     (org-export-data
+	     (loc (org-icalendar-cleanup-string
-			      (org-element-property :title entry) info))))
+		   (org-element-property :LOCATION entry)))
-	       (loc (org-icalendar-cleanup-string
+	     ;; Build description of the entry from associated section
-		     (org-element-property :LOCATION entry)))
+	     ;; (headline) or contents (inlinetask).
-	       ;; Build description of the entry from associated
+	     (desc
-	       ;; section (headline) or contents (inlinetask).
+	      (org-icalendar-cleanup-string
-	       (desc
+	       (or (org-element-property :DESCRIPTION entry)
-		(org-icalendar-cleanup-string
+		   (let ((contents (org-export-data inside info)))
-		 (or (org-element-property :DESCRIPTION entry)
+		     (cond
-		     (let ((contents (org-export-data inside info)))
+		      ((not (org-string-nw-p contents)) nil)
-		       (cond
+		      ((wholenump org-icalendar-include-body)
-			((not (org-string-nw-p contents)) nil)
+		       (let ((contents (org-trim contents)))
-			((wholenump org-icalendar-include-body)
+			 (substring
-			 (let ((contents (org-trim contents)))
+			  contents 0 (min (length contents)
-			   (substring
+					  org-icalendar-include-body))))
-			    contents 0 (min (length contents)
+		      (org-icalendar-include-body (org-trim contents)))))))
-					    org-icalendar-include-body))))
+	     (cat (org-icalendar-get-categories entry info)))
-			(org-icalendar-include-body (org-trim contents)))))))
+	 (concat
-	       (cat (org-icalendar-get-categories entry info)))
+	  ;; Events: Delegate to `org-icalendar--vevent' to generate
-	   (concat
+	  ;; "VEVENT" component from scheduled, deadline, or any
-	    ;; Events: Delegate to `org-icalendar--vevent' to
+	  ;; timestamp in the entry.
-	    ;; generate "VEVENT" component from scheduled, deadline,
+	  (let ((deadline (org-element-property :deadline entry)))
-	    ;; or any timestamp in the entry.
+	    (and deadline
-	    (let ((deadline (org-element-property :deadline entry)))
+		 (memq (if todo-type 'event-if-todo 'event-if-not-todo)
-	      (and deadline
+		       org-icalendar-use-deadline)
-		   (memq (if todo-type 'event-if-todo 'event-if-not-todo)
+		 (org-icalendar--vevent
-			 org-icalendar-use-deadline)
+		  entry deadline (concat "DL-" uid)
-		   (org-icalendar--vevent
+		  (concat "DL: " summary) loc desc cat)))
-		    entry deadline (concat "DL-" uid)
+	  (let ((scheduled (org-element-property :scheduled entry)))
-		    (concat "DL: " summary) loc desc cat)))
+	    (and scheduled
-	    (let ((scheduled (org-element-property :scheduled entry)))
+		 (memq (if todo-type 'event-if-todo 'event-if-not-todo)
-	      (and scheduled
+		       org-icalendar-use-scheduled)
-		   (memq (if todo-type 'event-if-todo 'event-if-not-todo)
+		 (org-icalendar--vevent
-			 org-icalendar-use-scheduled)
+		  entry scheduled (concat "SC-" uid)
-		   (org-icalendar--vevent
+		  (concat "S: " summary) loc desc cat)))
-		    entry scheduled (concat "SC-" uid)
+	  ;; When collecting plain timestamps from a headline and its
-		    (concat "S: " summary) loc desc cat)))
+	  ;; title, skip inlinetasks since collection will happen once
-	    ;; When collecting plain timestamps from a headline and
+	  ;; ENTRY is one of them.
-	    ;; its title, skip inlinetasks since collection will
+	  (let ((counter 0))
-	    ;; happen once ENTRY is one of them.
+	    (mapconcat
+	     #'identity
+	     (org-element-map (cons (org-element-property :title entry)
+				    (org-element-contents inside))
+		 'timestamp
+	       (lambda (ts)
+		 (when (let ((type (org-element-property :type ts)))
+			 (case (plist-get info :with-timestamps)
+			   (active (memq type '(active active-range)))
+			   (inactive (memq type '(inactive inactive-range)))
+			   ((t) t)))
+		   (let ((uid (format "TS%d-%s" (incf counter) uid)))
+		     (org-icalendar--vevent
+		      entry ts uid summary loc desc cat))))
+	       info nil (and (eq type 'headline) 'inlinetask))
+	     ""))
+	  ;; Task: First check if it is appropriate to export it.  If
+	  ;; so, call `org-icalendar--vtodo' to transcode it into
+	  ;; a "VTODO" component.
+	  (when (and todo-type
+		     (case (plist-get info :icalendar-include-todo)
+		       (all t)
+		       (unblocked
+			(and (eq type 'headline)
+			     (not (org-icalendar-blocked-headline-p
+				   entry info))))
+		       ((t) (eq todo-type 'todo))))
+	    (org-icalendar--vtodo entry uid summary loc desc cat))
+	  ;; Diary-sexp: Collect every diary-sexp element within ENTRY
+	  ;; and its title, and transcode them.  If ENTRY is
+	  ;; a headline, skip inlinetasks: they will be handled
+	  ;; separately.
+	  (when org-icalendar-include-sexps
 	    (let ((counter 0))
 	    (let ((counter 0))
-	      (mapconcat
+	      (mapconcat #'identity
-	       #'identity
+			 (org-element-map
-	       (org-element-map (cons (org-element-property :title entry)
+			     (cons (org-element-property :title entry)
-				      (org-element-contents inside))
+				   (org-element-contents inside))
-		   'timestamp
+			     'diary-sexp
-		 (lambda (ts)
+			   (lambda (sexp)
-		   (when (let ((type (org-element-property :type ts)))
+			     (org-icalendar-transcode-diary-sexp
-			   (case (plist-get info :with-timestamps)
+			      (org-element-property :value sexp)
-			     (active (memq type '(active active-range)))
+			      (format "DS%d-%s" (incf counter) uid)
-			     (inactive (memq type '(inactive inactive-range)))
+			      summary))
-			     ((t) t)))
+			   info nil (and (eq type 'headline) 'inlinetask))
-		     (let ((uid (format "TS%d-%s" (incf counter) uid)))
+			 "")))))
-		       (org-icalendar--vevent
-			entry ts uid summary loc desc cat))))
-		 info nil (and (eq type 'headline) 'inlinetask))
-	       ""))
-	    ;; Task: First check if it is appropriate to export it.
-	    ;; If so, call `org-icalendar--vtodo' to transcode it
-	    ;; into a "VTODO" component.
-	    (when (and todo-type
-		       (case (plist-get info :icalendar-include-todo)
-			 (all t)
-			 (unblocked
-			  (and (eq type 'headline)
-			       (not (org-icalendar-blocked-headline-p
-				     entry info))))
-			 ((t) (eq todo-type 'todo))))
-	      (org-icalendar--vtodo entry uid summary loc desc cat))
-	    ;; Diary-sexp: Collect every diary-sexp element within
-	    ;; ENTRY and its title, and transcode them.  If ENTRY is
-	    ;; a headline, skip inlinetasks: they will be handled
-	    ;; separately.
-	    (when org-icalendar-include-sexps
-	      (let ((counter 0))
-		(mapconcat #'identity
-			   (org-element-map
-			       (cons (org-element-property :title entry)
-				     (org-element-contents inside))
-			       'diary-sexp
-			     (lambda (sexp)
-			       (org-icalendar-transcode-diary-sexp
-				(org-element-property :value sexp)
-				(format "DS%d-%s" (incf counter) uid)
-				summary))
-			     info nil (and (eq type 'headline) 'inlinetask))
-			   ""))))))
        ;; If ENTRY is a headline, call current function on every
        ;; If ENTRY is a headline, call current function on every
        ;; inlinetask within it.  In agenda export, this is independent
        ;; inlinetask within it.  In agenda export, this is independent
        ;; from the mark (or lack thereof) on the entry.
        ;; from the mark (or lack thereof) on the entry.
@@ -833,7 +823,8 @@ Return ICS file name."
   ;; links will not be collected at the end of sections.
   ;; links will not be collected at the end of sections.
   (let ((outfile (org-export-output-file-name ".ics" subtreep)))
   (let ((outfile (org-export-output-file-name ".ics" subtreep)))
     (org-export-to-file 'icalendar outfile
     (org-export-to-file 'icalendar outfile
-      async subtreep visible-only body-only '(:ascii-charset utf-8)
+      async subtreep visible-only body-only
+      '(:ascii-charset utf-8 :ascii-links-to-notes nil)
       (lambda (file)
       (lambda (file)
 	(run-hook-with-args 'org-icalendar-after-save-hook file) nil))))
 	(run-hook-with-args 'org-icalendar-after-save-hook file) nil))))
 
 
@@ -888,50 +879,44 @@ The file is stored under the name chosen in
 	      (org-export-add-to-stack
 	      (org-export-add-to-stack
 	       (expand-file-name org-icalendar-combined-agenda-file)
 	       (expand-file-name org-icalendar-combined-agenda-file)
 	       'icalendar))
 	       'icalendar))
-	  `(apply 'org-icalendar--combine-files nil ',files)))
+	  `(apply 'org-icalendar--combine-files ',files)))
-    (apply 'org-icalendar--combine-files nil (org-agenda-files t))))
+    (apply 'org-icalendar--combine-files (org-agenda-files t))))
 
 
 (defun org-icalendar-export-current-agenda (file)
 (defun org-icalendar-export-current-agenda (file)
   "Export current agenda view to an iCalendar FILE.
   "Export current agenda view to an iCalendar FILE.
 This function assumes major mode for current buffer is
 This function assumes major mode for current buffer is
 `org-agenda-mode'."
 `org-agenda-mode'."
-  (let (org-export-babel-evaluate ; Don't evaluate Babel block
+  (let* ((org-export-babel-evaluate)	; Don't evaluate Babel block.
-	(org-icalendar-combined-agenda-file file)
+	 (contents
-	(marker-list
+	  (org-export-string-as
-	 ;; Collect the markers pointing to entries in the current
+	   (with-output-to-string
-	 ;; agenda buffer.
+	     (save-excursion
-	 (let (markers)
+	       (let ((p (point-min)))
-	   (save-excursion
+		 (while (setq p (next-single-property-change p 'org-hd-marker))
-	     (goto-char (point-min))
+		   (let ((m (get-text-property p 'org-hd-marker)))
-	     (while (not (eobp))
+		     (when m
-	       (let ((m (or (org-get-at-bol 'org-hd-marker)
+		       (with-current-buffer (marker-buffer m)
-			    (org-get-at-bol 'org-marker))))
+			 (org-with-wide-buffer
-		 (and m (push m markers)))
+			  (goto-char (marker-position m))
-	       (beginning-of-line 2)))
+			  (princ
-	   (nreverse markers))))
+			   (org-element-normalize-string
-    (apply 'org-icalendar--combine-files
+			    (buffer-substring
-	   ;; Build restriction alist.
+			     (point) (progn (outline-next-heading) (point)))))))))
-	   (let (restriction)
+		   (forward-line)))))
-	     ;; Sort markers in each association within RESTRICTION.
+	   'icalendar file)))
-	     (mapcar (lambda (x) (setcdr x (sort (copy-sequence (cdr x)) '<)) x)
+    (with-temp-file file
-		     (dolist (m marker-list restriction)
+      (insert
-		       (let* ((pos (marker-position m))
+       (org-icalendar--vcalendar
-			      (file (buffer-file-name
+	org-icalendar-combined-name
-				     (org-base-buffer (marker-buffer m))))
+	user-full-name
-			      (file-markers (assoc file restriction)))
+	org-icalendar-combined-description
-			 ;; Add POS in FILE association if one exists
+	(or (org-string-nw-p org-icalendar-timezone) (cadr (current-time-zone)))
-			 ;; or create a new association for FILE.
+	contents)))
-			 (if file-markers (push pos (cdr file-markers))
+    (run-hook-with-args 'org-icalendar-after-save-hook file)))
-			   (push (list file pos) restriction))))))
+
-	   (org-agenda-files nil 'ifmode))))
+(defun org-icalendar--combine-files (&rest files)
-
-(defun org-icalendar--combine-files (restriction &rest files)
   "Combine entries from multiple files into an iCalendar file.
   "Combine entries from multiple files into an iCalendar file.
-RESTRICTION, when non-nil, is an alist where key is a file name
+FILES is a list of files to build the calendar from."
-and value a list of buffer positions pointing to entries that
-should appear in the calendar.  It only makes sense if the
-function was called from an agenda buffer.  FILES is a list of
-files to build the calendar from."
   (org-agenda-prepare-buffers files)
   (org-agenda-prepare-buffers files)
   (unwind-protect
   (unwind-protect
       (progn
       (progn
@@ -955,29 +940,12 @@ files to build the calendar from."
 		(catch 'nextfile
 		(catch 'nextfile
 		  (org-check-agenda-file file)
 		  (org-check-agenda-file file)
 		  (with-current-buffer (org-get-agenda-file-buffer file)
 		  (with-current-buffer (org-get-agenda-file-buffer file)
-		    (let ((marks (cdr (assoc (expand-file-name file)
+		    ;; Create ID if necessary.
-					     restriction))))
+		    (when org-icalendar-store-UID
-		      ;; Create ID if necessary.
+		      (org-icalendar-create-uid file t))
-		      (when org-icalendar-store-UID
+		    (org-export-as
-			(org-icalendar-create-uid file t marks))
+		     'icalendar nil nil t
-		      (unless (and restriction (not marks))
+		     '(:ascii-charset utf-8 :ascii-links-to-notes nil)))))
-			;; Add a hook adding :ICALENDAR_MARK: property
-			;; to each entry appearing in agenda view.
-			;; Use `apply-partially' because the function
-			;; still has to accept one argument.
-			(let ((org-export-before-processing-hook
-			       (cons (apply-partially
-				      (lambda (m-list dummy)
-					(mapc (lambda (m)
-						(org-entry-put
-						 m "ICALENDAR-MARK" "t"))
-					      m-list))
-				      (sort marks '>))
-				     org-export-before-processing-hook)))
-			  (org-export-as
-			   'icalendar nil nil t
-			   (list :ascii-charset 'utf-8
-				 :icalendar-agenda-view restriction))))))))
 	      files "")
 	      files "")
 	     ;; BBDB anniversaries.
 	     ;; BBDB anniversaries.
 	     (when (and org-icalendar-include-bbdb-anniversaries
 	     (when (and org-icalendar-include-bbdb-anniversaries

+ 74 - 89
lisp/ox-latex.el

@@ -400,17 +400,15 @@ Set it to the empty string to ignore the command completely."
   'org-latex-format-headline-default-function
   'org-latex-format-headline-default-function
   "Function for formatting the headline's text.
   "Function for formatting the headline's text.
 
 
-This function will be called with 5 arguments:
+This function will be called with six arguments:
-TODO      the todo keyword (string or nil).
+TODO      the todo keyword (string or nil)
 TODO-TYPE the type of todo (symbol: `todo', `done', nil)
 TODO-TYPE the type of todo (symbol: `todo', `done', nil)
 PRIORITY  the priority of the headline (integer or nil)
 PRIORITY  the priority of the headline (integer or nil)
-TEXT      the main headline text (string).
+TEXT      the main headline text (string)
-TAGS      the tags as a list of strings (list of strings or nil).
+TAGS      the tags (list of strings or nil)
+INFO      the export options (plist)
 
 
-The function result will be used in the section format string.
+The function result will be used in the section format string."
-
-Use `org-latex-format-headline-default-function' by default,
-which format headlines like for Org version prior to 8.0."
   :group 'org-export-latex
   :group 'org-export-latex
   :version "24.4"
   :version "24.4"
   :package-version '(Org . "8.0")
   :package-version '(Org . "8.0")
@@ -683,17 +681,16 @@ The default function simply returns the value of CONTENTS."
   'org-latex-format-inlinetask-default-function
   'org-latex-format-inlinetask-default-function
   "Function called to format an inlinetask in LaTeX code.
   "Function called to format an inlinetask in LaTeX code.
 
 
-The function must accept six parameters:
+The function must accept seven parameters:
-  TODO      the todo keyword, as a string
+  TODO      the todo keyword (string or nil)
-  TODO-TYPE the todo type, a symbol among `todo', `done' and nil.
+  TODO-TYPE the todo type (symbol: `todo', `done', nil)
-  PRIORITY  the inlinetask priority, as a string
+  PRIORITY  the inlinetask priority (integer or nil)
-  NAME      the inlinetask name, as a string.
+  NAME      the inlinetask name (string)
-  TAGS      the inlinetask tags, as a list of strings.
+  TAGS      the inlinetask tags (list of strings or nil)
-  CONTENTS  the contents of the inlinetask, as a string.
+  CONTENTS  the contents of the inlinetask (string or nil)
-
+  INFO      the export options (plist)
-The function should return the string to be exported.
 
 
-Use `org-latex-format-headline-default-function' by default."
+The function should return the string to be exported."
   :group 'org-export-latex
   :group 'org-export-latex
   :type 'function
   :type 'function
   :version "24.5"
   :version "24.5"
@@ -1466,7 +1463,7 @@ holding contextual information."
 	   ;; Create the headline text along with a no-tag version.
 	   ;; Create the headline text along with a no-tag version.
 	   ;; The latter is required to remove tags from toc.
 	   ;; The latter is required to remove tags from toc.
 	   (full-text (funcall (plist-get info :latex-format-headline-function)
 	   (full-text (funcall (plist-get info :latex-format-headline-function)
-			       todo todo-type priority text tags))
+			       todo todo-type priority text tags info))
 	   ;; Associate \label to the headline for internal links.
 	   ;; Associate \label to the headline for internal links.
 	   (headline-label
 	   (headline-label
 	    (let ((custom-label
 	    (let ((custom-label
@@ -1514,7 +1511,8 @@ holding contextual information."
 			(org-export-data-with-backend
 			(org-export-data-with-backend
 			 (org-export-get-alt-title headline info)
 			 (org-export-get-alt-title headline info)
 			 section-back-end info)
 			 section-back-end info)
-			(and (eq (plist-get info :with-tags) t) tags))))
+			(and (eq (plist-get info :with-tags) t) tags)
+			info)))
 	  (if (and numberedp opt-title
 	  (if (and numberedp opt-title
 		   (not (equal opt-title full-text))
 		   (not (equal opt-title full-text))
 		   (string-match "\\`\\\\\\(.*?[^*]\\){" section-fmt))
 		   (string-match "\\`\\\\\\(.*?[^*]\\){" section-fmt))
@@ -1532,7 +1530,7 @@ holding contextual information."
 		    (concat headline-label pre-blanks contents))))))))
 		    (concat headline-label pre-blanks contents))))))))
 
 
 (defun org-latex-format-headline-default-function
 (defun org-latex-format-headline-default-function
-  (todo todo-type priority text tags)
+  (todo todo-type priority text tags info)
   "Default format function for a headline.
   "Default format function for a headline.
 See `org-latex-format-headline-function' for details."
 See `org-latex-format-headline-function' for details."
   (concat
   (concat
@@ -1540,7 +1538,9 @@ See `org-latex-format-headline-function' for details."
    (and priority (format "\\framebox{\\#%c} " priority))
    (and priority (format "\\framebox{\\#%c} " priority))
    text
    text
    (and tags
    (and tags
-	(format "\\hfill{}\\textsc{%s}" (mapconcat 'identity tags ":")))))
+	(format "\\hfill{}\\textsc{%s}"
+		(mapconcat (lambda (tag) (org-latex-plain-text tag info))
+			   tags ":")))))
 
 
 
 
 ;;;; Horizontal Rule
 ;;;; Horizontal Rule
@@ -1621,18 +1621,21 @@ holding contextual information."
 		     (and label (format "\\label{%s}\n" label)))
 		     (and label (format "\\label{%s}\n" label)))
 		   contents)))
 		   contents)))
     (funcall (plist-get info :latex-format-inlinetask-function)
     (funcall (plist-get info :latex-format-inlinetask-function)
-	     todo todo-type priority title tags contents)))
+	     todo todo-type priority title tags contents info)))
 
 
 (defun org-latex-format-inlinetask-default-function
 (defun org-latex-format-inlinetask-default-function
-  (todo todo-type priority title tags contents)
+  (todo todo-type priority title tags contents info)
   "Default format function for a inlinetasks.
   "Default format function for a inlinetasks.
 See `org-latex-format-inlinetask-function' for details."
 See `org-latex-format-inlinetask-function' for details."
   (let ((full-title
   (let ((full-title
 	 (concat (when todo (format "\\textbf{\\textsf{\\textsc{%s}}} " todo))
 	 (concat (when todo (format "\\textbf{\\textsf{\\textsc{%s}}} " todo))
 		 (when priority (format "\\framebox{\\#%c} " priority))
 		 (when priority (format "\\framebox{\\#%c} " priority))
 		 title
 		 title
-		 (when tags (format "\\hfill{}\\textsc{:%s:}"
+		 (when tags
-				    (mapconcat #'identity tags ":"))))))
+		   (format "\\hfill{}\\textsc{:%s:}"
+			   (mapconcat
+			    (lambda (tag) (org-latex-plain-text tag info))
+			    tags ":"))))))
     (concat "\\begin{center}\n"
     (concat "\\begin{center}\n"
 	    "\\fbox{\n"
 	    "\\fbox{\n"
 	    "\\begin{minipage}[c]{.6\\textwidth}\n"
 	    "\\begin{minipage}[c]{.6\\textwidth}\n"
@@ -2045,47 +2048,35 @@ contextual information."
   "Transcode a TEXT string from Org to LaTeX.
   "Transcode a TEXT string from Org to LaTeX.
 TEXT is the string to transcode.  INFO is a plist holding
 TEXT is the string to transcode.  INFO is a plist holding
 contextual information."
 contextual information."
-  (let ((specialp (plist-get info :with-special-strings))
+  (let* ((specialp (plist-get info :with-special-strings))
-	(output text))
+	 (output
-    ;; Protect %, #, &, $, _, { and }.
+	  ;; Turn LaTeX into \LaTeX{} and TeX into \TeX{}.
-    (while (string-match "\\([^\\]\\|^\\)\\([%$#&{}_]\\)" output)
+	  (let ((case-fold-search nil))
-      (setq output
-	    (replace-match
-	     (format "\\%s" (match-string 2 output)) nil t output 2)))
-    ;; Protect ^.
-    (setq output
-	  (replace-regexp-in-string
-	   "\\([^\\]\\|^\\)\\(\\^\\)" "\\\\^{}" output nil nil 2))
-    ;; Protect \.  If special strings are used, be careful not to
-    ;; protect "\" in "\-" constructs.
-    (let ((symbols (if specialp "-%$#&{}^_\\" "%$#&{}^_\\")))
-      (setq output
 	    (replace-regexp-in-string
 	    (replace-regexp-in-string
-	     (format "\\(?:[^\\]\\|^\\)\\(\\\\\\)\\(?:[^%s]\\|$\\)" symbols)
+	     "\\<\\(?:La\\)?TeX\\>" "\\\\\\&{}"
-	     "$\\backslash$" output nil t 1)))
+	     ;; Protect ^, ~, %, #, &, $, _, { and }.  Also protect \.
-    ;; Protect ~.
+	     ;; However, if special strings are used, be careful not
-    (setq output
+	     ;; to protect "\" in "\-" constructs.
-	  (replace-regexp-in-string
+	     (replace-regexp-in-string
-	   "\\([^\\]\\|^\\)\\(~\\)" "\\textasciitilde{}" output nil t 2))
+	      (concat "[%$#&{}_~^]\\|\\\\" (and specialp "\\(?:[^-]\\|$\\)"))
+	      (lambda (m)
+		(case (aref m 0)
+		  (?\\ "$\\\\backslash$")
+		  (?~ "\\\\textasciitilde{}")
+		  (?^ "\\\\^{}")
+		  (t "\\\\\\&")))
+	      text)))))
     ;; Activate smart quotes.  Be sure to provide original TEXT string
     ;; Activate smart quotes.  Be sure to provide original TEXT string
     ;; since OUTPUT may have been modified.
     ;; since OUTPUT may have been modified.
     (when (plist-get info :with-smart-quotes)
     (when (plist-get info :with-smart-quotes)
       (setq output (org-export-activate-smart-quotes output :latex info text)))
       (setq output (org-export-activate-smart-quotes output :latex info text)))
-    ;; LaTeX into \LaTeX{} and TeX into \TeX{}.
-    (let ((case-fold-search nil)
-	  (start 0))
-      (while (string-match "\\<\\(\\(?:La\\)?TeX\\)\\>" output start)
-	(setq output (replace-match
-		      (format "\\%s{}" (match-string 1 output)) nil t output)
-	      start (match-end 0))))
     ;; Convert special strings.
     ;; Convert special strings.
     (when specialp
     (when specialp
-      (setq output
+      (setq output (replace-regexp-in-string "\\.\\.\\." "\\\\ldots{}" output)))
-	    (replace-regexp-in-string "\\.\\.\\." "\\ldots{}" output nil t)))
     ;; Handle break preservation if required.
     ;; Handle break preservation if required.
     (when (plist-get info :preserve-breaks)
     (when (plist-get info :preserve-breaks)
       (setq output (replace-regexp-in-string
       (setq output (replace-regexp-in-string
-		    "\\(\\\\\\\\\\)?[ \t]*\n" " \\\\\\\\\n" output)))
+		    "\\(?:[ \t]*\\\\\\\\\\)?[ \t]*\n" "\\\\\n" output nil t)))
     ;; Return value.
     ;; Return value.
     output))
     output))
 
 
@@ -2874,15 +2865,14 @@ information."
   "Transcode a TIMESTAMP object from Org to LaTeX.
   "Transcode a TIMESTAMP object from Org to LaTeX.
 CONTENTS is nil.  INFO is a plist holding contextual
 CONTENTS is nil.  INFO is a plist holding contextual
 information."
 information."
-  (let ((value (org-latex-plain-text
+  (let ((value (org-latex-plain-text (org-timestamp-translate timestamp) info)))
-		(org-timestamp-translate timestamp) info)))
+    (format
-    (case (org-element-property :type timestamp)
+     (plist-get info
-      ((active active-range)
+		(case (org-element-property :type timestamp)
-       (format (plist-get info :latex-active-timestamp-format) value))
+		  ((active active-range) :latex-active-timestamp-format)
-      ((inactive inactive-range)
+		  ((inactive inactive-range) :latex-inactive-timestamp-format)
-       (format (plist-get info :latex-inactive-timestamp-format) value))
+		  (otherwise :latex-diary-timestamp-format)))
-      (otherwise
+     value)))
-       (format (plist-get info :latex-diary-timestamp-format) value)))))
 
 
 
 
 ;;;; Underline
 ;;;; Underline
@@ -2916,16 +2906,14 @@ contextual information."
    ;; character and change each white space at beginning of a line
    ;; character and change each white space at beginning of a line
    ;; into a space of 1 em.  Also change each blank line with
    ;; into a space of 1 em.  Also change each blank line with
    ;; a vertical space of 1 em.
    ;; a vertical space of 1 em.
-   (progn
+   (format "\\begin{verse}\n%s\\end{verse}"
-     (setq contents (replace-regexp-in-string
+	   (replace-regexp-in-string
-		     "^ *\\\\\\\\$" "\\\\vspace*{1em}"
+	    "^[ \t]+" (lambda (m) (format "\\hspace*{%dem}" (length m)))
-		     (replace-regexp-in-string
+	    (replace-regexp-in-string
-		      "\\(\\\\\\\\\\)?[ \t]*\n" " \\\\\\\\\n" contents)))
+	     "^[ \t]*\\\\\\\\$" "\\vspace*{1em}"
-     (while (string-match "^[ \t]+" contents)
+	     (replace-regexp-in-string
-       (let ((new-str (format "\\hspace*{%dem}"
+	      "\\([ \t]*\\\\\\\\\\)?[ \t]*\n" "\\\\\n"
-			      (length (match-string 0 contents)))))
+	      contents nil t) nil t) nil t))))
-	 (setq contents (replace-match new-str nil t contents))))
-     (format "\\begin{verse}\n%s\\end{verse}" contents))))
 
 
 
 
 
 
@@ -3074,17 +3062,15 @@ Return PDF file name or an error if it couldn't be produced."
        ((consp org-latex-pdf-process)
        ((consp org-latex-pdf-process)
 	(let ((outbuf (and (not snippet)
 	(let ((outbuf (and (not snippet)
 			   (get-buffer-create "*Org PDF LaTeX Output*"))))
 			   (get-buffer-create "*Org PDF LaTeX Output*"))))
-	  (mapc
+	  (dolist (command org-latex-pdf-process)
-	   (lambda (command)
+	    (shell-command
-	     (shell-command
+	     (replace-regexp-in-string
+	      "%b" (shell-quote-argument base-name)
 	      (replace-regexp-in-string
 	      (replace-regexp-in-string
-	       "%b" (shell-quote-argument base-name)
+	       "%f" (shell-quote-argument full-name)
 	       (replace-regexp-in-string
 	       (replace-regexp-in-string
-		"%f" (shell-quote-argument full-name)
+		"%o" (shell-quote-argument out-dir) command t t) t t) t t)
-		(replace-regexp-in-string
+	     outbuf))
-		 "%o" (shell-quote-argument out-dir) command t t) t t) t t)
-	      outbuf))
-	   org-latex-pdf-process)
 	  ;; Collect standard errors from output buffer.
 	  ;; Collect standard errors from output buffer.
 	  (setq warnings (and (not snippet)
 	  (setq warnings (and (not snippet)
 			      (org-latex--collect-warnings outbuf)))))
 			      (org-latex--collect-warnings outbuf)))))
@@ -3126,10 +3112,9 @@ encountered or nil if there was none."
 	  (let ((case-fold-search t)
 	  (let ((case-fold-search t)
 		(warnings ""))
 		(warnings ""))
 	    (dolist (warning org-latex-known-warnings)
 	    (dolist (warning org-latex-known-warnings)
-	      (save-excursion
+	      (when (save-excursion (re-search-forward (car warning) nil t))
-		(when (save-excursion (re-search-forward (car warning) nil t))
+		(setq warnings (concat warnings " " (cdr warning)))))
-		  (setq warnings (concat warnings " " (cdr warning))))))
+	    (org-string-nw-p (org-trim warnings))))))))
-	    (and (org-string-nw-p warnings) (org-trim warnings))))))))
 
 
 ;;;###autoload
 ;;;###autoload
 (defun org-latex-publish-to-latex (plist filename pub-dir)
 (defun org-latex-publish-to-latex (plist filename pub-dir)