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

This commit is contained in:
Bastien Guerry 2012-12-19 00:23:46 +01:00
commit 77a6acff0b
4 changed files with 90 additions and 67 deletions

View File

@ -153,7 +153,7 @@ KEYWORD is a string representing a buffer keyword, or nil. Each
property).
OPTION is a string that could be found in an #+OPTIONS: line.
DEFAULT is the default value for the property.
BEHAVIOUR determine how Org should handle multiple keywords for
BEHAVIOUR determines how Org should handle multiple keywords for
the same property. It is a symbol among:
nil Keep old value and discard the new one.
t Replace old value with the new one.
@ -163,7 +163,8 @@ BEHAVIOUR determine how Org should handle multiple keywords for
`split' Split values at white spaces, and cons them to the
previous list.
KEYWORD and OPTION have precedence over DEFAULT.
Values set through KEYWORD and OPTION have precedence over
DEFAULT.
All these properties should be back-end agnostic. Back-end
specific properties are set through `org-export-define-backend'.
@ -2591,7 +2592,7 @@ Return the updated communication channel."
;; associated to the file, that is before parsing.
(defun org-export-as
(backend &optional subtreep visible-only body-only ext-plist noexpand)
(backend &optional subtreep visible-only body-only ext-plist)
"Transcode current Org buffer into BACKEND code.
If narrowing is active in the current buffer, only transcode its
@ -2613,9 +2614,6 @@ Optional argument EXT-PLIST, when provided, is a property list
with external parameters overriding Org default settings, but
still inferior to file-local settings.
Optional argument NOEXPAND, when non-nil, prevents included files
to be expanded and Babel code to be executed.
Return code as a string."
;; Barf if BACKEND isn't registered.
(org-export-barf-if-invalid-backend backend)
@ -2634,20 +2632,19 @@ Return code as a string."
;; Initialize communication channel with original buffer
;; attributes, unavailable in its copy.
(let ((info (org-export--get-buffer-attributes)) tree)
;; Update communication channel and get parse tree. Buffer
;; isn't parsed directly. Instead, a temporary copy is
;; created, where include keywords, macros are expanded and
;; code blocks are evaluated.
(org-export-with-buffer-copy
;; Run first hook with current back-end as argument.
(run-hook-with-args 'org-export-before-processing-hook backend)
;; Update communication channel and get parse tree. Buffer
;; isn't parsed directly. Instead, a temporary copy is
;; created, where include keywords, macros are expanded and
;; code blocks are evaluated.
(unless noexpand
(org-export-expand-include-keyword)
;; Update macro templates since #+INCLUDE keywords might
;; have added some new ones.
(org-macro-initialize-templates)
(org-macro-replace-all org-macro-templates)
(org-export-execute-babel-code))
(org-export-expand-include-keyword)
;; Update macro templates since #+INCLUDE keywords might have
;; added some new ones.
(org-macro-initialize-templates)
(org-macro-replace-all org-macro-templates)
(org-export-execute-babel-code)
;; Update radio targets since keyword inclusion might have
;; added some more.
(org-update-radio-target-regexp)
@ -2664,16 +2661,15 @@ Return code as a string."
;; {{{date}}}, {{{email}}} and {{{title}}}. It must be done
;; once regular macros have been expanded, since document
;; keywords may contain one of them.
(unless noexpand
(org-macro-replace-all
(list (cons "author"
(org-element-interpret-data (plist-get info :author)))
(cons "date"
(org-element-interpret-data (plist-get info :date)))
;; EMAIL is not a parsed keyword: store it as-is.
(cons "email" (or (plist-get info :email) ""))
(cons "title"
(org-element-interpret-data (plist-get info :title))))))
(org-macro-replace-all
(list (cons "author"
(org-element-interpret-data (plist-get info :author)))
(cons "date"
(org-element-interpret-data (plist-get info :date)))
;; EMAIL is not a parsed keyword: store it as-is.
(cons "email" (or (plist-get info :email) ""))
(cons "title"
(org-element-interpret-data (plist-get info :title)))))
;; Eventually parse buffer. Call parse-tree filters to get
;; the final tree.
(setq tree
@ -2705,7 +2701,7 @@ Return code as a string."
output)))))
(defun org-export-to-buffer
(backend buffer &optional subtreep visible-only body-only ext-plist noexpand)
(backend buffer &optional subtreep visible-only body-only ext-plist)
"Call `org-export-as' with output to a specified buffer.
BACKEND is the back-end used for transcoding, as a symbol.
@ -2713,13 +2709,12 @@ BACKEND is the back-end used for transcoding, as a symbol.
BUFFER is the output buffer. If it already exists, it will be
erased first, otherwise, it will be created.
Optional arguments SUBTREEP, VISIBLE-ONLY, BODY-ONLY, EXT-PLIST
and NOEXPAND are similar to those used in `org-export-as', which
Optional arguments SUBTREEP, VISIBLE-ONLY, BODY-ONLY and
EXT-PLIST are similar to those used in `org-export-as', which
see.
Return buffer."
(let ((out (org-export-as
backend subtreep visible-only body-only ext-plist noexpand))
(let ((out (org-export-as backend subtreep visible-only body-only ext-plist))
(buffer (get-buffer-create buffer)))
(with-current-buffer buffer
(erase-buffer)
@ -2728,14 +2723,14 @@ Return buffer."
buffer))
(defun org-export-to-file
(backend file &optional subtreep visible-only body-only ext-plist noexpand)
(backend file &optional subtreep visible-only body-only ext-plist)
"Call `org-export-as' with output to a specified file.
BACKEND is the back-end used for transcoding, as a symbol. FILE
is the name of the output file, as a string.
Optional arguments SUBTREEP, VISIBLE-ONLY, BODY-ONLY, EXT-PLIST
and NOEXPAND are similar to those used in `org-export-as', which
Optional arguments SUBTREEP, VISIBLE-ONLY, BODY-ONLY and
EXT-PLIST are similar to those used in `org-export-as', which
see.
Return output file's name."
@ -2743,8 +2738,7 @@ Return output file's name."
;; we'd rather avoid needless transcoding of parse tree.
(unless (file-writable-p file) (error "Output file not writable"))
;; Insert contents to a temporary buffer and write it to FILE.
(let ((out (org-export-as
backend subtreep visible-only body-only ext-plist noexpand)))
(let ((out (org-export-as backend subtreep visible-only body-only ext-plist)))
(with-temp-buffer
(insert out)
(let ((coding-system-for-write org-export-coding-system))

View File

@ -358,6 +358,11 @@ still has an entry since one of its properties (`:title') does.")
(footnote-reference . :inline-definition))
"Alist between element types and location of secondary value.")
(defconst org-element-object-variables '(org-link-abbrev-alist-local)
"List of buffer-local variables used when parsing objects.
These variables are copied to the temporary buffer created by
`org-export-secondary-string'.")
;;; Accessors and Setters
@ -2998,10 +3003,10 @@ Assume point is at the beginning of the link."
contents-end (match-end 3)
link-end (match-end 0)
;; RAW-LINK is the original link.
raw-link (org-match-string-no-properties 1)
link (org-translate-link
(org-link-expand-abbrev
(org-link-unescape raw-link))))
raw-link (org-translate-link
(org-link-expand-abbrev
(org-match-string-no-properties 1)))
link (org-link-unescape raw-link))
;; Determine TYPE of link and set PATH accordingly.
(cond
;; File type.
@ -3930,14 +3935,22 @@ looked after.
Optional argument PARENT, when non-nil, is the element or object
containing the secondary string. It is used to set correctly
`:parent' property within the string."
(with-temp-buffer
(insert string)
(let ((secondary (org-element--parse-objects
(point-min) (point-max) nil restriction)))
(when parent
(mapc (lambda (obj) (org-element-put-property obj :parent parent))
secondary))
secondary)))
;; Copy buffer-local variables listed in
;; `org-element-object-variables' into temporary buffer. This is
;; required since object parsing is dependent on these variables.
(let ((pairs (delq nil (mapcar (lambda (var)
(when (boundp var)
(cons var (symbol-value var))))
org-element-object-variables))))
(with-temp-buffer
(mapc (lambda (pair) (org-set-local (car pair) (cdr pair))) pairs)
(insert string)
(let ((secondary (org-element--parse-objects
(point-min) (point-max) nil restriction)))
(when parent
(mapc (lambda (obj) (org-element-put-property obj :parent parent))
secondary))
secondary))))
(defun org-element-map
(data types fun &optional info first-match no-recursion with-affiliated)

View File

@ -21485,22 +21485,18 @@ width for filling.
For convenience, when point is at a plain list, an item or
a footnote definition, try to fill the first paragraph within."
(interactive)
(cond ;; First ensure filling in correct in message-mode
((and (derived-mode-p 'message-mode)
(or (not (message-in-body-p))
(save-excursion (move-beginning-of-line 1)
(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))))
(fill-paragraph nil)))
;; Correct filling in source block
((org-in-src-block-p)
(org-babel-do-key-sequence-in-edit-buffer (kbd "M-q")))
(t
(if (and (derived-mode-p 'message-mode)
(or (not (message-in-body-p))
(save-excursion (move-beginning-of-line 1)
(looking-at message-cite-prefix-regexp))))
;; First ensure filling is correct in message-mode.
(let ((fill-paragraph-function
(cadadr (assoc 'fill-paragraph-function org-fb-vars)))
(fill-prefix (cadadr (assoc 'fill-prefix org-fb-vars)))
(paragraph-start (cadadr (assoc 'paragraph-start org-fb-vars)))
(paragraph-separate
(cadadr (assoc 'paragraph-separate org-fb-vars))))
(fill-paragraph nil))
(save-excursion
;; Move to end of line in order to get the first paragraph
;; within a plain list or a footnote definition.
@ -21510,6 +21506,8 @@ a footnote definition, try to fill the first paragraph within."
;; the buffer. In that case, ignore filling.
(if (< (point) (org-element-property :begin element)) t
(case (org-element-type element)
;; Use major mode filling function is src blocks.
(src-block (org-babel-do-key-sequence-in-edit-buffer (kbd "M-q")))
;; Align Org tables, leave table.el tables as-is.
(table-row (org-table-align) t)
(table
@ -21586,7 +21584,7 @@ a footnote definition, try to fill the first paragraph within."
;; Fill comments.
(comment (fill-comment-paragraph justify))
;; Ignore every other element.
(otherwise t))))))))
(otherwise t)))))))
(defun org-auto-fill-function ()
"Auto-fill function."

View File

@ -1260,7 +1260,25 @@ e^{i\\pi}+1=0
;; 4. Angular link.
(should
(org-test-with-temp-text "A link: <http://orgmode.org>"
(org-element-map (org-element-parse-buffer) 'link 'identity nil t))))
(org-element-map (org-element-parse-buffer) 'link 'identity nil t)))
;; Link abbreviation.
(should
(equal "http"
(org-test-with-temp-text
"#+LINK: orgmode http://www.orgmode.org/\n[[orgmode:#docs]]"
(progn (org-mode-restart)
(goto-char (point-max))
(org-element-property :type (org-element-context))))))
;; Link abbreviation in a secondary string.
(should
(equal "http"
(org-test-with-temp-text
"#+LINK: orgmode http://www.orgmode.org/\n* H [[orgmode:#docs]]"
(progn (org-mode-restart)
(org-element-map
(org-element-parse-buffer) 'link
(lambda (link) (org-element-property :type link))
nil t nil t))))))
;;;; Macro