Merged origin/master into max-sticky-agenda

This commit is contained in:
Max Mikhanosha 2012-04-13 18:15:18 -04:00
commit 7212801808
82 changed files with 4035 additions and 4273 deletions

View File

@ -50,6 +50,7 @@
(declare-function org-export-collect-tables "org-export" (info))
(declare-function org-export-data "org-export" (data backend info))
(declare-function org-export-expand-macro "org-export" (macro info))
(declare-function org-export-format-code-default "org-export" (element info))
(declare-function org-export-get-coderef-format "org-export" (path desc))
(declare-function org-export-get-footnote-number "org-export" (footnote info))
(declare-function org-export-get-headline-number "org-export" (headline info))
@ -57,8 +58,6 @@
(element info &optional types predicate))
(declare-function org-export-get-parent-headline "org-export" (blob info))
(declare-function org-export-get-relative-level "org-export" (headline info))
(declare-function org-export-handle-code
"org-export" (element info &optional num-fmt ref-fmt delayed))
(declare-function org-export-included-file "org-export" (keyword backend info))
(declare-function org-export-low-level-p "org-export" (headline info))
(declare-function org-export-output-file-name "org-export"
@ -1082,7 +1081,8 @@ contextual information."
(defun org-e-ascii-example-block (example-block contents info)
"Transcode a EXAMPLE-BLOCK element from Org to ASCII.
CONTENTS is nil. INFO is a plist holding contextual information."
(org-e-ascii--box-string (org-export-handle-code example-block info) info))
(org-e-ascii--box-string
(org-export-format-code-default example-block info) info))
;;;; Export Snippet
@ -1312,11 +1312,11 @@ contextual information."
"Transcode a KEYWORD element from Org to ASCII.
CONTENTS is nil. INFO is a plist holding contextual
information."
(let ((key (downcase (org-element-property :key keyword)))
(let ((key (org-element-property :key keyword))
(value (org-element-property :value keyword)))
(cond
((string= key "ascii") value)
((string= key "toc")
((string= key "ASCII") value)
((string= key "TOC")
(let ((value (downcase value)))
(cond
((string-match "\\<headlines\\>" value)
@ -1546,7 +1546,8 @@ contextual information."
(let ((caption (org-e-ascii--build-caption src-block info)))
(concat
(when (and caption org-e-ascii-caption-above) (concat caption "\n"))
(org-e-ascii--box-string (org-export-handle-code src-block info) info)
(org-e-ascii--box-string
(org-export-format-code-default src-block info) info)
(when (and caption (not org-e-ascii-caption-above))
(concat "\n" caption)))))

View File

@ -1505,8 +1505,7 @@ This function shouldn't be used for floats. See
(defun org-e-html-style (info)
(concat
(when (plist-get info :style-include-default)
org-e-html-style-default)
"\n" (when (plist-get info :style-include-default) org-e-html-style-default)
(plist-get info :style)
(plist-get info :style-extra)
"\n"
@ -1727,6 +1726,8 @@ original parsed data. INFO is a plist holding export options."
;;; Transcode Helpers
;;;; Todo
(defun org-e-html--todo (todo)
(when todo
(format "<span class=\"%s %s%s\">%s</span>"
@ -1734,6 +1735,8 @@ original parsed data. INFO is a plist holding export options."
org-e-html-todo-kwd-class-prefix (org-e-html-fix-class-name todo)
todo)))
;;;; Tags
(defun org-e-html--tags (tags)
(when tags
(format "<span class=\"tag\">%s</span>"
@ -1745,6 +1748,8 @@ original parsed data. INFO is a plist holding export options."
tag))
(org-split-string tags ":") "&nbsp;"))))
;;;; Headline
(defun* org-e-html-format-headline
(todo todo-type priority text tags
&key level section-number headline-label &allow-other-keys)
@ -1757,6 +1762,98 @@ original parsed data. INFO is a plist holding export options."
(concat section-number todo (and todo " ") text
(and tags "&nbsp;&nbsp;&nbsp;") tags)))
;;;; Src Code
(defun org-e-html-fontify-code (code lang)
(when code
(cond
;; Case 1: No lang. Possibly an example block.
((not lang)
;; Simple transcoding.
(org-e-html-encode-plain-text code))
;; Case 2: No htmlize or an inferior version of htmlize
((not (and (require 'htmlize nil t) (fboundp 'htmlize-region-for-paste)))
;; Emit a warning.
(message "Cannot fontify src block (htmlize.el >= 1.34 required)")
;; Simple transcoding.
(org-e-html-encode-plain-text code))
(t
;; Map language
(setq lang (or (assoc-default lang org-src-lang-modes) lang))
(let* ((lang-mode (and lang (intern (format "%s-mode" lang)))))
(cond
;; Case 1: Language is not associated with any Emacs mode
((not (functionp lang-mode))
;; Simple transcoding.
(org-e-html-encode-plain-text code))
;; Case 2: Default. Fotify code.
(t
;; htmlize
(setq code (with-temp-buffer
(insert code)
(funcall lang-mode)
(font-lock-fontify-buffer)
;; markup each line separately
(org-remove-formatting-on-newlines-in-region
(point-min) (point-max))
(org-src-mode)
(set-buffer-modified-p nil)
(org-export-e-htmlize-region-for-paste
(point-min) (point-max))))
;; Strip any encolosing <pre></pre> tags
(if (string-match "<pre[^>]*>\n*\\([^\000]*\\)</pre>" code)
(match-string 1 code)
code))))))))
(defun org-e-html-do-format-code
(code &optional lang refs retain-labels num-start textarea-p)
(when textarea-p
(setq num-start nil refs nil lang nil))
(let* ((code-lines (org-split-string code "\n"))
(code-length (length code-lines))
(num-fmt
(and num-start
(format "%%%ds: "
(length (number-to-string (+ code-length num-start))))))
(code (org-e-html-fontify-code code lang)))
(assert (= code-length (length (org-split-string code "\n"))))
(org-export-format-code
code
(lambda (loc line-num ref)
(setq loc
(concat
;; Add line number, if needed.
(when num-start
(format "<span class=\"linenr\">%s</span>"
(format num-fmt line-num)))
;; Transcoded src line.
loc
;; Add label, if needed.
(when (and ref retain-labels) (format " (%s)" ref))))
;; Mark transcoded line as an anchor, if needed.
(if (not ref) loc
(format "<span id=\"coderef-%s\" class=\"coderef-off\">%s</span>"
ref loc)))
num-start refs)))
(defun org-e-html-format-code (element info)
(let* ((lang (org-element-property :language element))
;; (switches (org-element-property :switches element))
(switches nil) ; FIXME
(textarea-p (and switches (string-match "-t\\>" switches)))
;; Extract code and references.
(code-info (org-export-unravel-code element))
(code (car code-info))
(refs (cdr code-info))
;; Does the src block contain labels?
(retain-labels (org-element-property :retain-labels element))
;; Does it have line numbers?
(num-start (case (org-element-property :number-lines element)
(continued (org-export-get-loc element info))
(new 0))))
(org-e-html-do-format-code
code lang refs retain-labels num-start textarea-p)))
;;; Transcode Functions
@ -1824,175 +1921,37 @@ holding contextual information.."
"Transcode an ENTITY object from Org to HTML.
CONTENTS are the definition itself. INFO is a plist holding
contextual information."
;; (let ((ent (org-element-property :latex entity)))
;; (if (org-element-property :latex-math-p entity)
;; (format "$%s$" ent)
;; ent))
(org-element-property :html entity))
;;;; Example Block
(defun org-e-html-format-source-line-with-line-number-and-label (line)
(let ((ref (org-find-text-property-in-string 'org-coderef line))
(num (org-find-text-property-in-string 'org-loc line)))
(when num
(setq line (format "<span class=\"linenr\">%d: </span>%s (%s)"
num line ref)))
(when ref
(setq line
(format
"<span id=\"coderef-%s\" class=\"coderef-off\">%s (%s)</span>"
ref line ref)))
line))
(defun org-e-html-format-source-code-or-example-plain
(lines lang caption textareap cols rows num cont rpllbl fmt)
(format
"\n<pre class=\"example\">\n%s\n</pre>"
(cond
(textareap
(format "<p>\n<textarea cols=\"%d\" rows=\"%d\">%s\n</textarea>\n</p>\n"
cols rows lines))
(t (mapconcat
(lambda (line)
(org-e-html-format-source-line-with-line-number-and-label
(org-e-html-encode-plain-text line)))
(org-split-string lines "\n")
"\n")))))
(defun org-e-html-format-source-code-or-example-colored
(lines lang caption textareap cols rows num cont rpllbl fmt)
(let* ((lang-m (when lang
(or (cdr (assoc lang org-src-lang-modes))
lang)))
(mode (and lang-m (intern
(concat
(if (symbolp lang-m)
(symbol-name lang-m)
lang-m)
"-mode"))))
(org-inhibit-startup t)
(org-startup-folded nil))
(setq lines
(with-temp-buffer
(insert lines)
(if (functionp mode)
(funcall mode)
(fundamental-mode))
(font-lock-fontify-buffer)
;; markup each line separately
(org-remove-formatting-on-newlines-in-region
(point-min) (point-max))
(org-src-mode)
(set-buffer-modified-p nil)
(org-export-e-htmlize-region-for-paste
(point-min) (point-max))))
(when (string-match "<pre\\([^>]*\\)>\n*" lines)
(setq lines (replace-match
(format "<pre class=\"src src-%s\">\n" lang) t t lines)))
(when caption
(setq lines
(concat
"<div class=\"org-src-container\">"
(format "<label class=\"org-src-name\">%s</label>" caption)
lines "</div>")))
(unless textareap
(setq lines
(mapconcat
(lambda (line)
(org-e-html-format-source-line-with-line-number-and-label line))
(org-split-string lines "\n") "\n")))
;; (when (string-match "\\(\\`<[^>]*>\\)\n" lines)
;; (setq lines (replace-match "\\1" t nil lines)))
lines))
(defun org-e-html-format-source-code-or-example
(lang code &optional opts indent caption)
"Format CODE from language LANG and return it formatted for export.
The CODE is marked up in `org-export-current-backend' format.
Check if a function by name
\"org-<backend>-format-source-code-or-example\" is bound. If yes,
use it as the custom formatter. Otherwise, use the default
formatter. Default formatters are provided for docbook, html,
latex and ascii backends. For example, use
`org-e-html-format-source-code-or-example' to provide a custom
formatter for export to \"html\".
If LANG is nil, do not add any fontification.
OPTS contains formatting options, like `-n' for triggering numbering lines,
and `+n' for continuing previous numbering.
Code formatting according to language currently only works for HTML.
Numbering lines works for all three major backends (html, latex, and ascii).
INDENT was the original indentation of the block."
(save-match-data
(let* ((backend-formatter 'org-e-html-format-source-code-or-example-plain)
num cont rtn rpllbl keepp textareap preserve-indentp cols rows fmt)
(setq opts (or opts "")
num (string-match "[-+]n\\>" opts)
cont (string-match "\\+n\\>" opts)
rpllbl (string-match "-r\\>" opts)
keepp (string-match "-k\\>" opts)
textareap (string-match "-t\\>" opts)
preserve-indentp (or org-src-preserve-indentation
(string-match "-i\\>" opts))
cols (if (string-match "-w[ \t]+\\([0-9]+\\)" opts)
(string-to-number (match-string 1 opts))
80)
rows (if (string-match "-h[ \t]+\\([0-9]+\\)" opts)
(string-to-number (match-string 1 opts))
(org-count-lines code))
fmt (if (string-match "-l[ \t]+\"\\([^\"\n]+\\)\"" opts)
(match-string 1 opts)))
(when (and textareap
;; (eq org-export-current-backend 'html)
)
;; we cannot use numbering or highlighting.
(setq num nil cont nil lang nil))
(if keepp (setq rpllbl 'keep))
(setq rtn (if preserve-indentp code (org-remove-indentation code)))
(when (string-match "^," rtn)
(setq rtn (with-temp-buffer
(insert rtn)
;; Free up the protected lines
(goto-char (point-min))
(while (re-search-forward "^," nil t)
(if (or (equal lang "org")
(save-match-data
(looking-at "\\([*#]\\|[ \t]*#\\+\\)")))
(replace-match ""))
(end-of-line 1))
(buffer-string))))
(when lang
(if (featurep 'xemacs)
(require 'htmlize)
(require 'htmlize nil t)))
(setq backend-formatter
(cond
((fboundp 'htmlize-region-for-paste)
'org-e-html-format-source-code-or-example-colored)
(t
(message
"htmlize.el 1.34 or later is needed for source code formatting")
'org-e-html-format-source-code-or-example-plain)))
(funcall backend-formatter rtn lang caption textareap cols rows
num cont rpllbl fmt))))
(defun org-e-html-example-block (example-block contents info)
"Transcode a EXAMPLE-BLOCK element from Org to HTML.
CONTENTS is nil. INFO is a plist holding contextual information."
(let* ((options (or (org-element-property :options example-block) ""))
(value (org-export-handle-code example-block info nil nil t)))
;; (org-e-html--wrap-label
;; example-block (format "\\begin{verbatim}\n%s\\end{verbatim}" value))
(org-e-html--wrap-label
example-block (org-e-html-format-source-code-or-example nil value))))
(lang (org-element-property :language example-block))
(caption (org-element-property :caption example-block))
(label (org-element-property :name example-block))
(caption-str (org-e-html--caption/label-string caption label info))
(attr (mapconcat #'identity
(org-element-property :attr_html example-block)
" "))
;; (switches (org-element-property :switches example-block))
(switches nil) ; FIXME
(textarea-p (and switches (string-match "-t\\>" switches)))
(code (org-e-html-format-code example-block info)))
(cond
(textarea-p
(let ((cols (if (not (string-match "-w[ \t]+\\([0-9]+\\)" switches))
80 (string-to-number (match-string 1 switches))))
(rows (if (string-match "-h[ \t]+\\([0-9]+\\)" switches)
(string-to-number (match-string 1 switches))
(org-count-lines code))))
(format
"\n<p>\n<textarea cols=\"%d\" rows=\"%d\">\n%s\n</textarea>\n</p>"
cols rows code)))
(t (format "\n<pre class=\"example\">\n%s\n</pre>" code)))))
;;;; Export Snippet
@ -2023,7 +1982,8 @@ CONTENTS is nil. INFO is a plist holding contextual information."
"^[ \t]*: ?" ""
(org-element-property :value fixed-width)))))
(org-e-html--wrap-label
fixed-width (org-e-html-format-source-code-or-example nil value))))
fixed-width (format "\n<pre class=\"example\">\n%s\n</pre>"
(org-e-html-do-format-code value)))))
;;;; Footnote Definition
@ -2094,7 +2054,7 @@ holding contextual information."
(funcall org-e-html-format-headline-function
todo todo-type priority text tags))))
(t 'org-e-html-format-headline))))
(apply format-function
(apply format-function
todo todo-type priority text tags
:headline-label headline-label :level level
:section-number section-number extra-keys)))
@ -2217,7 +2177,7 @@ holding contextual information."
inlinetask info format-function :contents contents)))
;; Otherwise, use a default template.
(t (org-e-html--wrap-label
inlinetask
inlinetask
(format
"\n<div class=\"inlinetask\">\n<b>%s</b><br/>\n%s\n</div>"
(org-e-html-format-headline--wrap inlinetask info)
@ -2280,14 +2240,14 @@ contextual information."
(defun org-e-html-keyword (keyword contents info)
"Transcode a KEYWORD element from Org to HTML.
CONTENTS is nil. INFO is a plist holding contextual information."
(let ((key (downcase (org-element-property :key keyword)))
(let ((key (org-element-property :key keyword))
(value (org-element-property :value keyword)))
(cond
((string= key "latex") value)
((string= key "index") (format "\\index{%s}" value))
((string= key "LATEX") value)
((string= key "INDEX") (format "\\index{%s}" value))
;; Invisible targets.
((string= key "target") nil) ; FIXME
((string= key "toc")
((string= key "TARGET") nil) ; FIXME
((string= key "TOC")
(let ((value (downcase value)))
(cond
((string-match "\\<headlines\\>" value)
@ -2540,7 +2500,7 @@ INFO is a plist holding contextual information. See
;; equivalent line number.
((string= type "coderef")
(let ((fragment (concat "coderef-" path)))
(format "<a href=#%s %s>%s</a>" fragment
(format "<a href=\"#%s\" %s>%s</a>" fragment
(format (concat "class=\"coderef\""
" onmouseover=\"CodeHighlightOn(this, '%s');\""
" onmouseout=\"CodeHighlightOff(this, '%s');\"")
@ -2743,7 +2703,7 @@ holding contextual information."
TEXT is the text of the target. INFO is a plist holding
contextual information."
(let ((id (org-export-solidify-link-text
(org-element-property :raw-value radio-target))))
(org-element-property :value radio-target))))
(format "<a id=\"%s\" name=\"%s\">%s</a>" id id text)))
@ -2766,17 +2726,32 @@ holding contextual information."
CONTENTS holds the contents of the item. INFO is a plist holding
contextual information."
(let* ((lang (org-element-property :language src-block))
(code (org-export-handle-code src-block info nil nil t))
(caption (org-element-property :caption src-block))
(label (org-element-property :name src-block)))
;; FIXME: Handle caption
;; caption-str (when caption)
;; (main (org-export-secondary-string (car caption) 'e-html info))
;; (secondary (org-export-secondary-string (cdr caption) 'e-html info))
;; (caption-str (org-e-html--caption/label-string caption label info))
(org-e-html-format-source-code-or-example lang code)))
(label (org-element-property :name src-block))
(caption-str (org-e-html--caption/label-string caption label info))
(attr (mapconcat #'identity
(org-element-property :attr_html src-block)
" "))
;; (switches (org-element-property :switches src-block))
(switches nil) ; FIXME
(textarea-p (and switches (string-match "-t\\>" switches)))
(code (org-e-html-format-code src-block info)))
(cond
(lang (format
"\n<div class=\"org-src-container\">\n%s%s\n</div>"
(if (not caption) ""
(format "<label class=\"org-src-name\">%s</label>" caption-str))
(format "\n<pre class=\"src src-%s\">%s\n</pre>" lang code)))
(textarea-p
(let ((cols (if (not (string-match "-w[ \t]+\\([0-9]+\\)" switches))
80 (string-to-number (match-string 1 switches))))
(rows (if (string-match "-h[ \t]+\\([0-9]+\\)" switches)
(string-to-number (match-string 1 switches))
(org-count-lines code))))
(format
"\n<p>\n<textarea cols=\"%d\" rows=\"%d\">\n%s\n</textarea>\n</p>"
cols rows code)))
(t (format "\n<pre class=\"example\">\n%s\n</pre>" code)))))
;;;; Statistics Cookie

View File

@ -54,13 +54,16 @@
(declare-function org-export-first-sibling-p "org-export" (headline info))
(declare-function org-export-footnote-first-reference-p "org-export"
(footnote-reference info))
(declare-function org-export-format-code "org-export"
(code fun &optional num-lines ref-alist))
(declare-function org-export-format-code-default "org-export" (element info))
(declare-function org-export-get-coderef-format "org-export" (path desc))
(declare-function org-export-get-footnote-definition "org-export"
(footnote-reference info))
(declare-function org-export-get-footnote-number "org-export" (footnote info))
(declare-function org-export-get-previous-element "org-export" (blob info))
(declare-function org-export-get-relative-level "org-export" (headline info))
(declare-function org-export-handle-code
(declare-function org-export-unravel-code
"org-export" (element info &optional num-fmt ref-fmt delayed))
(declare-function org-export-included-file "org-export" (keyword backend info))
(declare-function org-export-inline-image-p "org-export"
@ -614,8 +617,14 @@ during latex export it will output
;;;; Plain text
(defcustom org-e-latex-quotes
'(("fr" ("\\(\\s-\\|[[(]\\)\"" . "«~") ("\\(\\S-\\)\"" . "") ("\\(\\s-\\|(\\)'" . "'"))
("en" ("\\(\\s-\\|[[(]\\)\"" . "``") ("\\(\\S-\\)\"" . "''") ("\\(\\s-\\|(\\)'" . "`")))
'(("fr"
("\\(\\s-\\|[[(]\\|^\\)\"" . "«~")
("\\(\\S-\\)\"" . "")
("\\(\\s-\\|(\\|^\\)'" . "'"))
("en"
("\\(\\s-\\|[[(]\\|^\\)\"" . "``")
("\\(\\S-\\)\"" . "''")
("\\(\\s-\\|(\\|^\\)'" . "`")))
"Alist for quotes to use when converting english double-quotes.
The CAR of each item in this alist is the language code.
@ -959,12 +968,13 @@ contextual information."
;;;; Example Block
(defun org-e-latex-example-block (example-block contents info)
"Transcode a EXAMPLE-BLOCK element from Org to LaTeX.
CONTENTS is nil. INFO is a plist holding contextual information."
(let* ((options (or (org-element-property :options example-block) ""))
(value (org-export-handle-code example-block info)))
(org-e-latex--wrap-label
example-block (format "\\begin{verbatim}\n%s\\end{verbatim}" value))))
"Transcode an EXAMPLE-BLOCK element from Org to LaTeX.
CONTENTS is nil. INFO is a plist holding contextual
information."
(org-e-latex--wrap-label
example-block
(format "\\begin{verbatim}\n%s\\end{verbatim}"
(org-export-format-code-default example-block info))))
;;;; Export Snippet
@ -1284,14 +1294,14 @@ contextual information."
(defun org-e-latex-keyword (keyword contents info)
"Transcode a KEYWORD element from Org to LaTeX.
CONTENTS is nil. INFO is a plist holding contextual information."
(let ((key (downcase (org-element-property :key keyword)))
(let ((key (org-element-property :key keyword))
(value (org-element-property :value keyword)))
(cond
((string= key "latex") value)
((string= key "index") (format "\\index{%s}" value))
((string= key "LATEX") value)
((string= key "INDEX") (format "\\index{%s}" value))
;; Invisible targets.
((string= key "target") nil)
((string= key "toc")
((string= key "TARGET") nil)
((string= key "TOC")
(let ((value (downcase value)))
(cond
((string-match "\\<headlines\\>" value)
@ -1651,7 +1661,7 @@ TEXT is the text of the target. INFO is a plist holding
contextual information."
(format "\\label{%s}%s"
(org-export-solidify-link-text
(org-element-property :raw-value radio-target))
(org-element-property :value radio-target))
text))
@ -1674,39 +1684,68 @@ holding contextual information."
CONTENTS holds the contents of the item. INFO is a plist holding
contextual information."
(let* ((lang (org-element-property :language src-block))
(code (org-export-handle-code src-block info))
(caption (org-element-property :caption src-block))
(label (org-element-property :name src-block))
(custom-env (and lang
(cadr (assq (intern lang)
org-e-latex-custom-lang-environments)))))
org-e-latex-custom-lang-environments))))
(num-start (case (org-element-property :number-lines src-block)
(continued (org-export-get-loc src-block info))
(new 0)))
(retain-labels (org-element-property :retain-labels src-block)))
(cond
;; No source fontification.
;; Case 1. No source fontification.
((not org-e-latex-listings)
(let ((caption-str (org-e-latex--caption/label-string
caption label info))
(let ((caption-str (org-e-latex--caption/label-string caption label info))
(float-env (when caption "\\begin{figure}[H]\n%s\n\\end{figure}")))
(format (or float-env "%s")
(concat
caption-str
(format "\\begin{verbatim}\n%s\\end{verbatim}" code)))))
;; Custom environment.
(custom-env
(format "\\begin{%s}\n%s\\end{%s}\n" custom-env code custom-env))
;; Use minted package.
(format
(or float-env "%s")
(concat caption-str
(format "\\begin{verbatim}\n%s\\end{verbatim}"
(org-export-format-code-default src-block info))))))
;; Case 2. Custom environment.
(custom-env (format "\\begin{%s}\n%s\\end{%s}\n"
custom-env
(org-export-format-code-default src-block info)
custom-env))
;; Case 3. Use minted package.
((eq org-e-latex-listings 'minted)
(let* ((mint-lang (or (cadr (assq (intern lang) org-e-latex-minted-langs))
lang))
(float-env (when (or label caption)
(format "\\begin{listing}[H]\n%%s\n%s\\end{listing}"
(org-e-latex--caption/label-string
caption label info))))
(body (format "\\begin{minted}[%s]{%s}\n%s\\end{minted}"
(org-e-latex--make-option-string
org-e-latex-minted-options)
mint-lang code)))
(let ((float-env (when (or label caption)
(format "\\begin{listing}[H]\n%%s\n%s\\end{listing}"
(org-e-latex--caption/label-string
caption label info))))
(body
(format
"\\begin{minted}[%s]{%s}\n%s\\end{minted}"
;; Options.
(org-e-latex--make-option-string
(if (not num-start) org-e-latex-minted-options
(append `(("linenos")
("firstnumber" ,(number-to-string (1+ num-start))))
org-e-latex-minted-options)))
;; Language.
(or (cadr (assq (intern lang) org-e-latex-minted-langs)) lang)
;; Source code.
(let* ((code-info (org-export-unravel-code src-block))
(max-width
(apply 'max
(mapcar 'length
(org-split-string (car code-info) "\n")))))
(org-export-format-code
(car code-info)
(lambda (loc num ref)
(concat
loc
(when ref
;; Ensure references are flushed to the right,
;; separated with 6 spaces from the widest line
;; of code.
(concat (make-string (+ (- max-width (length loc)) 6) ? )
(format "(%s)" ref)))))
nil (and retain-labels (cdr code-info)))))))
;; Return value.
(if float-env (format float-env body) body)))
;; Use listings package.
;; Case 4. Use listings package.
(t
(let ((lst-lang
(or (cadr (assq (intern lang) org-e-latex-listings-langs)) lang))
@ -1719,14 +1758,39 @@ contextual information."
"{[%s]%s}"
(org-export-secondary-string (cdr caption) 'e-latex info)
main))))))
(concat (format "\\lstset{%s}\n"
(org-e-latex--make-option-string
(append org-e-latex-listings-options
`(("language" ,lst-lang))
(when label `(("label" ,label)))
(when caption-str
`(("caption" ,caption-str))))))
(format "\\begin{lstlisting}\n%s\\end{lstlisting}" code)))))))
(concat
;; Options.
(format "\\lstset{%s}\n"
(org-e-latex--make-option-string
(append org-e-latex-listings-options
`(("language" ,lst-lang))
(when label `(("label" ,label)))
(when caption-str `(("caption" ,caption-str)))
(cond ((not num-start) '(("numbers" "none")))
((zerop num-start) '(("numbers" "left")))
(t `(("numbers" "left")
("firstnumber"
,(number-to-string (1+ num-start)))))))))
;; Source code.
(format
"\\begin{lstlisting}\n%s\\end{lstlisting}"
(let* ((code-info (org-export-unravel-code src-block))
(max-width
(apply 'max
(mapcar 'length
(org-split-string (car code-info) "\n")))))
(org-export-format-code
(car code-info)
(lambda (loc num ref)
(concat
loc
(when ref
;; Ensure references are flushed to the right,
;; separated with 6 spaces from the widest line of
;; code
(concat (make-string (+ (- max-width (length loc)) 6) ? )
(format "(%s)" ref)))))
nil (and retain-labels (cdr code-info)))))))))))
;;;; Statistics Cookie
@ -1781,9 +1845,12 @@ table."
((string-match "\\<tabular.?\\>" attr)
(org-match-string-no-properties 0 attr))
(t org-e-latex-default-table-environment)))
;; If table is a float, determine environment: table or table*.
;; If table is a float, determine environment: table, table*
;; or sidewaystable.
(float-env (cond
((string= "longtable" table-env) nil)
((and attr (string-match "\\<sidewaystable\\>" attr))
"sidewaystables")
((and attr
(or (string-match (regexp-quote "table*") attr)
(string-match "\\<multicolumn\\>" attr)))

File diff suppressed because it is too large Load Diff

View File

@ -355,18 +355,15 @@ release:
git checkout maint
git merge -s recursive -X theirs master
UTILITIES/set-version.pl $(TAG)
git commit -a -m "Release $(TAG)"
git commit -a -m "Major release $(TAG) from master"
make relup TAG=$(TAG)
make cleanrel
rm -rf org-$(TAG)
rm -f org-$(TAG)*.zip
rm -f org-$(TAG)*.tar.gz
make pushreleasetag TAG=$(TAG)
git push -f origin maint
git checkout master
git merge -s ours maint
UTILITIES/set-version.pl -a $(TAG)
git commit -a -m "Update website to show $(TAG) as current release"
git commit -a -m "Bump to version $(TAG) as current release from master"
git push
# The following target makes a release, but from the stuff that is on
@ -381,20 +378,16 @@ release:
fixrelease:
git checkout maint
git merge -s recursive -X theirs master
UTILITIES/set-version.pl $(TAG)
git commit -a -m "Release $(TAG)"
git commit -a -m "Bugfix release $(TAG) from maint"
make relup TAG=$(TAG)
make cleanrel
rm -rf org-$(TAG)
rm org-$(TAG)*.zip
rm org-$(TAG)*.tar.gz
make pushreleasetag TAG=$(TAG)
git push -f origin maint
git checkout master
git merge -s ours maint
UTILITIES/set-version.pl -o $(TAG)
git commit -a -m "Update website to show $(TAG) as current release"
git commit -a -m "Bump to version $(TAG) as current release from maint"
git push
# ~$ make relup only makes sense from orgmode.org server

View File

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

View File

@ -314,7 +314,7 @@ def action_update_patch(rpc, patch_id, state = None, commit = None,
if state.lower() in notify_on_state_change:
if not delegate_id:
sys.stderr.write("Error: Delete (-d) required for this update\n")
sys.stderr.write("Error: Delegate (-d) required for this update\n")
sys.exit(1)
person = rpc.person_get(delegate_id)

View File

@ -129,7 +129,7 @@ of checkbox items"
(a2ps-buffer)))))))))
(defun org-checklist ()
(when (member state org-done-keywords)
(when (member org-state org-done-keywords) ;; org-state dynamically bound in org.el/org-todo
(org-make-checklist-export)
(org-reset-checkbox-state-maybe)))

View File

@ -131,7 +131,7 @@ preceeding the dblock, then update the contents of the dblock."
((setq idpos (org-find-entry-with-id id))
(goto-char idpos))
(t (error "Cannot find entry with :ID: %s" id))))
(org-narrow-to-subtree)
(unless (eq id 'global) (org-narrow-to-subtree))
(setq stringformat (if noquote "%s" "%S"))
(setq table (org-propview-to-table
(org-propview-collect cols stringformat conds match scope inherit

View File

@ -143,7 +143,8 @@ This overrides `org-email-link-description-format' if set."
(defun org-contacts-filter (&optional name-match tags-match)
"Search for a contact maching NAME-MATCH and TAGS-MATCH.
If both match values are nil, return all contacts."
(let ((tags-matcher
(let* (todo-only
(tags-matcher
(if tags-match
(cdr (org-make-tags-matcher tags-match))
t))
@ -161,7 +162,8 @@ If both match values are nil, return all contacts."
(error "File %s is no in `org-mode'" file))
(org-scan-tags
'(add-to-list 'markers (set-marker (make-marker) (point)))
`(and ,contacts-matcher ,tags-matcher ,name-matcher))))
`(and ,contacts-matcher ,tags-matcher ,name-matcher)
todo-only)))
(dolist (marker markers result)
(org-with-point-at marker
(add-to-list 'result
@ -388,7 +390,7 @@ This function should be called from `gnus-article-prepare-hook'."
(let ((mails (org-entry-get (point) org-contacts-email-property)))
(unless (member mail (split-string mails))
(when (yes-or-no-p
(format "Do you want to this address to %s?" (org-get-heading t)))
(format "Do you want to add this address to %s?" (org-get-heading t)))
(org-set-property org-contacts-email-property (concat mails " " mail))))))
(defun org-contacts-gnus-check-mail-address ()

File diff suppressed because it is too large Load Diff

View File

@ -325,6 +325,51 @@ in this way, it will be wrapped."
:body-bullet-list-prefix ("* " "** " "*** " "**** " "***** ")
)
;;
;; mediawiki
;;
("mediawiki"
:file-suffix ".txt"
:key-binding ?m
:header-prefix ""
:header-suffix ""
:title-format "= %s =\n"
:date-export nil
:toc-export nil
:body-header-section-numbers nil
:body-section-prefix "\n"
:body-section-header-prefix ("= " "== " "=== "
"==== " "===== " "====== ")
:body-section-header-suffix (" =\n\n" " ==\n\n" " ===\n\n"
" ====\n\n" " =====\n\n" " ======\n\n")
:body-line-export-preformated t ;; yes/no/maybe???
:body-line-format "%s\n"
:body-line-wrap 75
:body-line-fixed-format " %s\n"
:body-list-format "* %s\n"
:body-number-list-format "# %s\n"
:body-bullet-list-prefix ("* " "** " "*** " "**** " "***** ")
:body-list-checkbox-todo "&#9744; "
:body-list-checkbox-done "&#9746; "
:body-table-start "{|"
:body-table-end "|}"
:body-table-cell-start "|"
:body-table-cell-end "\n"
:body-table-last-cell-end "|-"
:body-table-hline-start ""
)
;;
;; internet-draft .xml for xml2rfc exporter
;;
("ietfid"
@ -715,7 +760,34 @@ underlined headlines. The default is 3."
(or (plist-get export-plist :body-list-checkbox-done-end) ""))
(listcheckhalfend
(or (plist-get export-plist :body-list-checkbox-half-end) ""))
(bodynewline-paragraph (plist-get export-plist :body-newline-paragraph))
(bodytablestart
(or (plist-get export-plist :body-table-start) ""))
(bodytableend
(or (plist-get export-plist :body-table-end) ""))
(bodytablerowstart
(or (plist-get export-plist :body-table-row-start) ""))
(bodytablerowend
(or (plist-get export-plist :body-table-row-end) ""))
(bodytablecellstart
(or (plist-get export-plist :body-table-cell-start) ""))
(bodytablecellend
(or (plist-get export-plist :body-table-cell-end) ""))
(bodytablefirstcellstart
(or (plist-get export-plist :body-table-first-cell-start) ""))
(bodytableinteriorcellstart
(or (plist-get export-plist :body-table-interior-cell-start) ""))
(bodytableinteriorcellend
(or (plist-get export-plist :body-table-interior-cell-end) ""))
(bodytablelastcellend
(or (plist-get export-plist :body-table-last-cell-end) ""))
(bodytablehlinestart
(or (plist-get export-plist :body-table-hline-start) " \\1"))
(bodytablehlineend
(or (plist-get export-plist :body-table-hline-end) ""))
(bodynewline-paragraph (plist-get export-plist :body-newline-paragraph))
(bodytextpre (plist-get export-plist :body-text-prefix))
(bodytextsuf (plist-get export-plist :body-text-suffix))
(bodylinewrap (plist-get export-plist :body-line-wrap))
@ -1328,16 +1400,21 @@ REVERSE means to reverse the list if the plist match is a list
(setq lines (org-table-clean-before-export lines)))
;; Get rid of the vertical lines except for grouping
(let ((vl (org-colgroup-info-to-vline-list org-table-colgroup-info))
rtn line vl1 start)
(rtn (list bodytablestart)) line vl1 start)
(while (setq line (pop lines))
(setq line (concat bodytablerowstart line))
(if (string-match org-table-hline-regexp line)
(and (string-match "|\\(.*\\)|" line)
(setq line (replace-match " \\1" t nil line)))
(setq line (replace-match (concat bodytablehlinestart bodytablehlineend) t nil line)))
(setq start 0 vl1 vl)
(if (string-match "|\\(.*\\)|" line)
(setq line (replace-match (concat bodytablefirstcellstart bodytablecellstart " \\1 " bodytablecellend bodytablelastcellend) t nil line)))
(while (string-match "|" line start)
(setq start (match-end 0))
(or (pop vl1) (setq line (replace-match " " t t line)))))
(setq start (+ (match-end 0) (length (concat bodytablecellend bodytableinteriorcellend bodytableinteriorcellstart bodytablecellstart))))
(or (pop vl1) (setq line (replace-match (concat bodytablecellend bodytableinteriorcellend bodytableinteriorcellstart bodytablecellstart) t t line)))))
(setq line (concat line bodytablerowend))
(push line rtn))
(setq rtn (cons bodytableend rtn))
(nreverse rtn))))
(defun org-colgroup-info-to-vline-list (info)

View File

@ -652,7 +652,6 @@ standard mode."
;; 1. Environment options are collected once at the very beginning of
;; the process, out of the original buffer and configuration.
;; Associated to the parse tree, they make an Org closure.
;; Collecting them is handled by `org-export-get-environment'
;; function.
;;
@ -891,6 +890,7 @@ standard mode."
;; increasing precedence order:
;;
;; - Global variables,
;; - Buffer's attributes,
;; - Options keyword symbols,
;; - Buffer keywords,
;; - Subtree properties.
@ -901,14 +901,11 @@ standard mode."
;; the different sources.
;; The internal functions doing the retrieval are:
;; `org-export-parse-option-keyword' ,
;; `org-export-get-subtree-options' ,
;; `org-export-get-inbuffer-options' and
;; `org-export-get-global-options'.
;;
;; Some properties, which do not rely on the previous sources but
;; still depend on the original buffer, are taken care of with
;; `org-export-initial-options'.
;; `org-export-get-global-options',
;; `org-export-get-buffer-attributes',
;; `org-export-parse-option-keyword',
;; `org-export-get-subtree-options' and
;; `org-export-get-inbuffer-options'
;; Also, `org-export-confirm-letbind' and `org-export-install-letbind'
;; take care of the part relative to "#+BIND:" keywords.
@ -931,13 +928,8 @@ inferior to file-local settings."
(let ((options (org-combine-plists
;; ... from global variables...
(org-export-get-global-options backend)
;; ... from buffer's name (default title)...
`(:title
,(or (let ((file (buffer-file-name (buffer-base-buffer))))
(and file
(file-name-sans-extension
(file-name-nondirectory file))))
(buffer-name (buffer-base-buffer))))
;; ... from buffer's attributes...
(org-export-get-buffer-attributes)
;; ... from an external property list...
ext-plist
;; ... from in-buffer settings...
@ -947,8 +939,6 @@ inferior to file-local settings."
(org-remove-double-quotes buffer-file-name)))
;; ... and from subtree, when appropriate.
(and subtreep (org-export-get-subtree-options)))))
;; Add initial options.
(setq options (append (org-export-initial-options) options))
;; Return plist.
options))
@ -1027,7 +1017,7 @@ Assume buffer is in Org mode. Narrowing, if any, is ignored."
(while (re-search-forward special-re nil t)
(let ((element (org-element-at-point)))
(when (eq (org-element-type element) 'keyword)
(let* ((key (upcase (org-element-property :key element)))
(let* ((key (org-element-property :key element))
(val (org-element-property :value element))
(prop
(cond
@ -1104,7 +1094,7 @@ Assume buffer is in Org mode. Narrowing, if any, is ignored."
(while (re-search-forward opt-re nil t)
(let ((element (org-element-at-point)))
(when (eq (org-element-type element) 'keyword)
(let* ((key (upcase (org-element-property :key element)))
(let* ((key (org-element-property :key element))
(val (org-element-property :value element))
(prop (cdr (assoc key alist)))
(behaviour (nth 4 (assq prop all))))
@ -1140,6 +1130,32 @@ Assume buffer is in Org mode. Narrowing, if any, is ignored."
;; 3. Return final value.
plist)))
(defun org-export-get-buffer-attributes ()
"Return properties related to buffer attributes, as a plist."
(let ((visited-file (buffer-file-name (buffer-base-buffer))))
(list
;; Store full path of input file name, or nil. For internal use.
:input-file visited-file
:title (or (and visited-file
(file-name-sans-extension
(file-name-nondirectory visited-file)))
(buffer-name (buffer-base-buffer)))
:macro-modification-time
(and visited-file
(file-exists-p visited-file)
(concat "(eval (format-time-string \"$1\" '"
(prin1-to-string (nth 5 (file-attributes visited-file)))
"))"))
;; Store input file name as a macro.
:macro-input-file (and visited-file (file-name-nondirectory visited-file))
;; `:macro-date', `:macro-time' and `:macro-property' could as
;; well be initialized as tree properties, since they don't
;; depend on buffer properties. Though, it may be more logical
;; to keep them close to other ":macro-" properties.
:macro-date "(eval (format-time-string \"$1\"))"
:macro-time "(eval (format-time-string \"$1\"))"
:macro-property "(eval (org-entry-get nil \"$1\" 'selective))")))
(defun org-export-get-global-options (&optional backend)
"Return global export options as a plist.
@ -1159,50 +1175,46 @@ process."
;; Return value.
plist))
(defun org-export-initial-options ()
"Return a plist with properties related to input buffer."
(let ((visited-file (buffer-file-name (buffer-base-buffer))))
(list
;; Store full path of input file name, or nil. For internal use.
:input-file visited-file
;; `:macro-date', `:macro-time' and `:macro-property' could as well
;; be initialized as tree properties, since they don't depend on
;; initial environment. Though, it may be more logical to keep
;; them close to other ":macro-" properties.
:macro-date "(eval (format-time-string \"$1\"))"
:macro-time "(eval (format-time-string \"$1\"))"
:macro-property "(eval (org-entry-get nil \"$1\" 'selective))"
:macro-modification-time
(and visited-file
(file-exists-p visited-file)
(concat "(eval (format-time-string \"$1\" '"
(prin1-to-string (nth 5 (file-attributes visited-file)))
"))"))
;; Store input file name as a macro.
:macro-input-file (and visited-file (file-name-nondirectory visited-file))
;; Footnotes definitions must be collected in the original buffer,
;; as there's no insurance that they will still be in the parse
;; tree, due to some narrowing.
:footnote-definition-alist
(let (alist)
(org-with-wide-buffer
(goto-char (point-min))
(while (re-search-forward org-footnote-definition-re nil t)
(let ((def (org-footnote-at-definition-p)))
(when def
(org-skip-whitespace)
(push (cons (car def)
(save-restriction
(narrow-to-region (point) (nth 2 def))
;; Like `org-element-parse-buffer', but
;; makes sure the definition doesn't start
;; with a section element.
(nconc
(list 'org-data nil)
(org-element-parse-elements
(point-min) (point-max) nil nil nil nil nil))))
alist))))
alist)))))
(defun org-export-store-footnote-definitions (info)
"Collect and store footnote definitions from current buffer in INFO.
INFO is a plist containing export options.
Footnotes definitions are stored as a alist whose CAR is
footnote's label, as a string, and CDR the contents, as a parse
tree. This alist will be consed to the value of
`:footnote-definition-alist' in INFO, if any.
The new plist is returned; use
\(setq info (org-export-store-footnote-definitions info))
to be sure to use the new value. INFO is modified by side
effects."
;; Footnotes definitions must be collected in the original buffer,
;; as there's no insurance that they will still be in the parse
;; tree, due to some narrowing.
(plist-put
info :footnote-definition-alist
(let ((alist (plist-get info :footnote-definition-alist)))
(org-with-wide-buffer
(goto-char (point-min))
(while (re-search-forward org-footnote-definition-re nil t)
(let ((def (org-footnote-at-definition-p)))
(when def
(org-skip-whitespace)
(push (cons (car def)
(save-restriction
(narrow-to-region (point) (nth 2 def))
;; Like `org-element-parse-buffer', but makes
;; sure the definition doesn't start with
;; a section element.
(nconc
(list 'org-data nil)
(org-element-parse-elements
(point-min) (point-max) nil nil nil nil nil))))
alist))))
alist))))
(defvar org-export-allow-BIND-local nil)
(defun org-export-confirm-letbind ()
@ -1293,8 +1305,7 @@ Following tree properties are set:
data '(keyword target)
(lambda (blob)
(when (or (eq (org-element-type blob) 'target)
(string= (upcase (org-element-property :key blob))
"TARGET"))
(string= (org-element-property :key blob) "TARGET"))
blob)) info)
:headline-numbering ,(org-export-collect-headline-numbering data info)
:back-end ,backend)
@ -2079,54 +2090,73 @@ to be expanded and Babel code to be executed.
Return code as a string."
(save-excursion
(save-restriction
;; Narrow buffer to an appropriate region for parsing.
;; Narrow buffer to an appropriate region or subtree for
;; parsing. If parsing subtree, be sure to remove main headline
;; too.
(cond ((org-region-active-p)
(narrow-to-region (region-beginning) (region-end)))
(subtreep (org-narrow-to-subtree)))
;; Retrieve export options (INFO) and parsed tree (RAW-DATA),
;; Then options can be completed with tree properties. Note:
;; Buffer isn't parsed directly. Instead, a temporary copy is
;; created, where include keywords are expanded and code blocks
;; are evaluated. RAW-DATA is the parsed tree of the buffer
;; resulting from that process. Eventually call
;; `org-export-filter-parse-tree-functions'.
(goto-char (point-min))
(let ((info (org-export-get-environment backend subtreep ext-plist)))
;; Remove subtree's headline from contents if subtree mode is
;; activated.
(when subtreep (forward-line) (narrow-to-region (point) (point-max)))
;; Install filters in communication channel.
(setq info (org-export-install-filters backend info))
(let ((raw-data
(org-export-filter-apply-functions
(plist-get info :filter-parse-tree)
;; If NOEXPAND is non-nil, simply parse current
;; visible part of buffer.
(if noexpand (org-element-parse-buffer nil visible-only)
(org-export-with-current-buffer-copy
(org-export-expand-include-keyword)
(let ((org-current-export-file (current-buffer)))
(org-export-blocks-preprocess))
(org-element-parse-buffer nil visible-only)))
backend info)))
;; Complete communication channel with tree properties.
(subtreep
(org-narrow-to-subtree)
(goto-char (point-min))
(forward-line)
(narrow-to-region (point) (point-max))))
;; 1. Get export environment from original buffer. Store
;; original footnotes definitions in communication channel as
;; they might not be accessible anymore in a narrowed parse
;; tree. Also install user's and developer's filters.
(let ((info (org-export-install-filters
backend
(org-export-store-footnote-definitions
(org-export-get-environment backend subtreep ext-plist))))
tree)
;; 2. Get parse tree.
(if noexpand
;; If NOEXPAND is non-nil, simply parse current visible
;; part of buffer.
(setq tree (org-element-parse-buffer nil visible-only))
;; Otherwise, buffer isn't parsed directly. Instead,
;; a temporary copy is created, where include keywords are
;; expanded and code blocks are evaluated.
(let ((buf (or (buffer-file-name (buffer-base-buffer))
(current-buffer))))
(org-export-with-current-buffer-copy
(org-export-expand-include-keyword)
;; Setting `org-current-export-file' is required by Org
;; Babel to properly resolve noweb references.
(let ((org-current-export-file buf))
(org-export-blocks-preprocess))
(setq tree (org-element-parse-buffer nil visible-only)
;; Footnote definitions must be stored again, since
;; buffer's expansion might have modified
;; boundaries of footnote definitions contained in
;; the parse tree. This way, definitions in
;; `footnote-definition-alist' are bound to
;; coincide with those in the parse tree.
info (org-export-store-footnote-definitions info)))))
;; 3. Call parse-tree filters to get the final tree.
(setq tree
(org-export-filter-apply-functions
(plist-get info :filter-parse-tree) tree backend info))
;; 4. Now tree is complete, compute its properties and add
;; them to communication channel.
(setq info
(org-combine-plists
info
(org-export-collect-tree-properties raw-data info backend)))
;; Transcode RAW-DATA. Also call
;; `org-export-filter-final-output-functions'.
(org-export-collect-tree-properties tree info backend)))
;; 5. Eventually transcode TREE. Wrap the resulting string
;; into a template, if required. Eventually call
;; final-output filter.
(let* ((body (org-element-normalize-string
(org-export-data raw-data backend info)))
(org-export-data tree backend info)))
(template (intern (format "org-%s-template" backend)))
(output (org-export-filter-apply-functions
(plist-get info :filter-final-output)
(if (or (not (fboundp template)) body-only) body
(funcall template body info))
backend info)))
;; Maybe add final OUTPUT to kill ring before returning it.
;; Maybe add final OUTPUT to kill ring, then return it.
(when org-export-copy-to-kill-ring (org-kill-new output))
output))))))
output)))))
(defun org-export-to-buffer
(backend buffer &optional subtreep visible-only body-only ext-plist noexpand)
@ -2716,10 +2746,10 @@ INFO is a plist holding contextual information.
Return value can be an object, an element, or nil:
- If LINK path matches a target object (i.e. <<path>>) or
element (i.e. \"#+target: path\"), return it.
element (i.e. \"#+TARGET: path\"), return it.
- If LINK path exactly matches the name affiliated keyword
\(i.e. #+name: path) of an element, return that element.
\(i.e. #+NAME: path) of an element, return that element.
- If LINK path exactly matches any headline name, return that
element. If more than one headline share that name, priority
@ -2738,7 +2768,7 @@ Assume LINK type is \"fuzzy\"."
(loop for target in (plist-get info :target-list)
when (string= (org-element-property :value target) path)
return target)))
;; Then try to find an element with a matching "#+name: path"
;; Then try to find an element with a matching "#+NAME: path"
;; affiliated keyword.
((and (not (eq (substring path 0 1) ?*))
(org-element-map
@ -2801,30 +2831,24 @@ INFO is a plist used as a communication channel.
Return associated line number in source code, or REF itself,
depending on src-block or example element's switches."
(org-element-map
(plist-get info :parse-tree) '(src-block example)
(plist-get info :parse-tree) '(example-block src-block)
(lambda (el)
(let ((switches (or (org-element-property :switches el) "")))
(with-temp-buffer
(insert (org-trim (org-element-property :value el)))
;; Build reference regexp.
(let* ((label
(or (and (string-match "-l +\"\\([^\"\n]+\\)\"" switches)
(match-string 1 switches))
org-coderef-label-format))
(ref-re
(format "^.*?\\S-.*?\\([ \t]*\\(%s\\)\\)[ \t]*$"
(replace-regexp-in-string "%s" ref label nil t))))
;; Element containing REF is found. Only associate REF to
;; a line number if element has "+n" or "-n" and "-k" or
;; "-r" as switches. When it has "+n", count accumulated
;; locs before, too.
(when (re-search-backward ref-re nil t)
(cond
((not (string-match "-[kr]\\>" switches)) ref)
((string-match "-n\\>" switches) (line-number-at-pos))
((string-match "\\+n\\>" switches)
(+ (org-export-get-loc el info) (line-number-at-pos)))
(t ref)))))))
(with-temp-buffer
(insert (org-trim (org-element-property :value el)))
(let* ((label-fmt (regexp-quote
(or (org-element-property :label-fmt el)
org-coderef-label-format)))
(ref-re
(format "^.*?\\S-.*?\\([ \t]*\\(%s\\)\\)[ \t]*$"
(replace-regexp-in-string "%s" ref label-fmt nil t))))
;; Element containing REF is found. Resolve it to either
;; a label or a line number, as needed.
(when (re-search-backward ref-re nil t)
(cond
((org-element-property :use-labels el) ref)
((eq (org-element-property :number-lines el) 'continued)
(+ (org-export-get-loc el info) (line-number-at-pos)))
(t (line-number-at-pos)))))))
info 'first-match))
@ -2933,8 +2957,21 @@ objects of the same type."
;; src-block or example-block elements with a "+n" switch until
;; a given element, excluded. Note: "-n" switches reset that count.
;; `org-export-handle-code' takes care of line numbering and reference
;; cleaning in source code, when appropriate.
;; `org-export-unravel-code' extracts source code (along with a code
;; references alist) from an `element-block' or `src-block' type
;; element.
;; `org-export-format-code' applies a formatting function to each line
;; of code, providing relative line number and code reference when
;; appropriate. Since it doesn't access the original element from
;; which the source code is coming, it expects from the code calling
;; it to know if lines should be numbered and if code references
;; should appear.
;; Eventually, `org-export-format-code-default' is a higher-level
;; function (it makes use of the two previous functions) which handles
;; line numbering and code references inclusion, and returns source
;; code in a format suitable for plain text or verbatim output.
(defun org-export-get-loc (element info)
"Return accumulated lines of code up to ELEMENT.
@ -2953,111 +2990,144 @@ ELEMENT is excluded from count."
;; Only count lines from src-block and example-block elements
;; with a "+n" or "-n" switch. A "-n" switch resets counter.
((not (memq (org-element-type el) '(src-block example-block))) nil)
((let ((switches (org-element-property :switches el)))
(when (and switches (string-match "\\([-+]\\)n\\>" switches))
((let ((linums (org-element-property :number-lines el)))
(when linums
;; Accumulate locs or reset them.
(let ((accumulatep (string= (match-string 1 switches) "-"))
(lines (org-count-lines
(let ((lines (org-count-lines
(org-trim (org-element-property :value el)))))
(setq loc (if accumulatep lines (+ loc lines))))))
(setq loc (if (eq linums 'new) lines (+ loc lines))))))
;; Return nil to stay in the loop.
nil)))
info 'first-match)
;; Return value.
loc))
(defun org-export-handle-code (element info &optional num-fmt ref-fmt delayed)
"Handle line numbers and code references in ELEMENT.
(defun org-export-unravel-code (element)
"Clean source code and extract references out of it.
ELEMENT has either a `src-block' an `example-block' type. INFO
is a plist used as a communication channel.
ELEMENT has either a `src-block' an `example-block' type.
If optional argument NUM-FMT is a string, it will be used as
a format string for numbers at beginning of each line.
If optional argument REF-FMT is a string, it will be used as
a format string for each line of code containing a reference.
When optional argument DELAYED is non-nil, `org-loc' and
`org-coderef' properties, set to an adequate value, are applied
to, respectively, numbered lines and lines with a reference. No
line numbering is done and all references are stripped from the
resulting string. Both NUM-FMT and REF-FMT arguments are ignored
in that situation.
Return new code as a string."
(let* ((switches (or (org-element-property :switches element) ""))
(code (org-element-property :value element))
(numberp (string-match "[-+]n\\>" switches))
(accumulatep (string-match "\\+n\\>" switches))
;; Initialize loc counter when any kind of numbering is
;; active.
(total-LOC (cond
(accumulatep (org-export-get-loc element info))
(numberp 0)))
Return a cons cell whose CAR is the source code, cleaned from any
reference and protective comma and CDR is an alist between
relative line number (integer) and name of code reference on that
line (string)."
(let* ((line 0) refs
;; Get code and clean it. Remove blank lines at its
;; beginning and end. Also remove protective commas.
(preserve-indent-p (or org-src-preserve-indentation
(string-match "-i\\>" switches)))
(replace-labels (when (string-match "-r\\>" switches)
(if (string-match "-k\\>" switches) 'keep t)))
(code (let ((c (replace-regexp-in-string
"\\`\\([ \t]*\n\\)+" ""
(replace-regexp-in-string
"\\(:?[ \t]*\n\\)*[ \t]*\\'" "\n" code))))
"\\(:?[ \t]*\n\\)*[ \t]*\\'" "\n"
(org-element-property :value element)))))
;; If appropriate, remove global indentation.
(unless preserve-indent-p (setq c (org-remove-indentation c)))
(unless (or org-src-preserve-indentation
(org-element-property :preserve-indent element))
(setq c (org-remove-indentation c)))
;; Free up the protected lines. Note: Org blocks
;; have commas at the beginning or every line.
(if (string=
(or (org-element-property :language element) "")
"org")
(if (string= (org-element-property :language element) "org")
(replace-regexp-in-string "^," "" c)
(replace-regexp-in-string
"^\\(,\\)\\(:?\\*\\|[ \t]*#\\+\\)" "" c nil nil 1))))
;; Split code to process it line by line.
(code-lines (org-split-string code "\n"))
;; If numbering is active, ensure line numbers will be
;; correctly padded before applying the format string.
(num-fmt
(when (and (not delayed) numberp)
(format (if (stringp num-fmt) num-fmt "%s: ")
(format "%%%ds"
(length (number-to-string
(+ (length code-lines) total-LOC)))))))
;; Get format used for references.
(label-fmt (or (and (string-match "-l +\"\\([^\"\n]+\\)\"" switches)
(match-string 1 switches))
org-coderef-label-format))
(label-fmt (regexp-quote
(or (org-element-property :label-fmt element)
org-coderef-label-format)))
;; Build a regexp matching a loc with a reference.
(with-ref-re (format "^.*?\\S-.*?\\([ \t]*\\(%s\\)\\)[ \t]*$"
(replace-regexp-in-string
"%s" "\\([-a-zA-Z0-9_ ]+\\)" label-fmt nil t))))
(with-ref-re
(format "^.*?\\S-.*?\\([ \t]*\\(%s\\)[ \t]*\\)$"
(replace-regexp-in-string
"%s" "\\([-a-zA-Z0-9_ ]+\\)" label-fmt nil t))))
;; Return value.
(cons
;; Code with references removed.
(org-element-normalize-string
(mapconcat
(lambda (loc)
(incf line)
(if (not (string-match with-ref-re loc)) loc
;; Ref line: remove ref, and signal its position in REFS.
(push (cons line (match-string 3 loc)) refs)
(replace-match "" nil nil loc 1)))
(org-split-string code "\n") "\n"))
;; Reference alist.
refs)))
(defun org-export-format-code (code fun &optional num-lines ref-alist)
"Format CODE by applying FUN line-wise and return it.
CODE is a string representing the code to format. FUN is
a function. It must accept three arguments: a line of
code (string), the current line number (integer) or nil and the
reference associated to the current line (string) or nil.
Optional argument NUM-LINES can be an integer representing the
number of code lines accumulated until the current code. Line
numbers passed to FUN will take it into account. If it is nil,
FUN's second argument will always be nil. This number can be
obtained with `org-export-get-loc' function.
Optional argument REF-ALIST can be an alist between relative line
number (i.e. ignoring NUM-LINES) and the name of the code
reference on it. If it is nil, FUN's third argument will always
be nil. It can be obtained through the use of
`org-export-unravel-code' function."
(let ((--locs (org-split-string code "\n"))
(--line 0))
(org-element-normalize-string
(mapconcat
(lambda (loc)
;; Maybe add line number to current line of code (LOC).
(when numberp
(incf total-LOC)
(setq loc (if delayed (org-add-props loc nil 'org-loc total-LOC)
(concat (format num-fmt total-LOC) loc))))
;; Take action if at a ref line.
(when (string-match with-ref-re loc)
(let ((ref (match-string 3 loc)))
(setq loc
;; Option "-r" without "-k" removes labels.
;; A non-nil DELAYED removes labels unconditionally.
(if (or delayed
(and replace-labels (not (eq replace-labels 'keep))))
(replace-match "" nil nil loc 1)
(replace-match (format "(%s)" ref) nil nil loc 2)))
;; Store REF in `org-coderef' property if DELAYED asks to.
(cond (delayed (setq loc (org-add-props loc nil 'org-coderef ref)))
;; If REF-FMT is defined, apply it to current LOC.
((stringp ref-fmt) (setq loc (format ref-fmt loc))))))
;; Return updated LOC for concatenation.
loc)
code-lines "\n"))))
(lambda (--loc)
(incf --line)
(let ((--ref (cdr (assq --line ref-alist))))
(funcall fun --loc (and num-lines (+ num-lines --line)) --ref)))
--locs "\n"))))
(defun org-export-format-code-default (element info)
"Return source code from ELEMENT, formatted in a standard way.
ELEMENT is either a `src-block' or `example-block' element. INFO
is a plist used as a communication channel.
This function takes care of line numbering and code references
inclusion. Line numbers, when applicable, appear at the
beginning of the line, separated from the code by two white
spaces. Code references, on the other hand, appear flushed to
the right, separated by six white spaces from the widest line of
code."
;; Extract code and references.
(let* ((code-info (org-export-unravel-code element))
(code (car code-info))
(code-lines (org-split-string code "\n"))
(refs (and (org-element-property :retain-labels element)
(cdr code-info)))
;; Handle line numbering.
(num-start (case (org-element-property :number-lines element)
(continued (org-export-get-loc element info))
(new 0)))
(num-fmt
(and num-start
(format "%%%ds "
(length (number-to-string
(+ (length code-lines) num-start))))))
;; Prepare references display, if required. Any reference
;; should start six columns after the widest line of code,
;; wrapped with parenthesis.
(max-width
(+ (apply 'max (mapcar 'length code-lines))
(if (not num-start) 0 (length (format num-fmt num-start))))))
(org-export-format-code
code
(lambda (loc line-num ref)
(let ((number-str (and num-fmt (format num-fmt line-num))))
(concat
number-str
loc
(and ref
(concat (make-string
(- (+ 6 max-width)
(+ (length loc) (length number-str))) ? )
(format "(%s)" ref))))))
num-start refs)))
;;;; For Tables

View File

@ -132,13 +132,13 @@ exported html."
(defun org-mime-file (ext path id)
"Markup a file for attachment."
(case org-mime-library
('mml (format
"<#part type=\"%s\" filename=\"%s\" id=\"<%s>\">\n<#/part>\n"
ext path id))
('mml (format (concat "<#part type=\"%s\" filename=\"%s\" "
"disposition=inline id=\"<%s>\">\n<#/part>\n")
ext path id))
('semi (concat
(format
"--[[%s\nContent-Disposition: inline;\nContent-ID: <%s>][base64]]\n"
ext id)
(format (concat "--[[%s\nContent-Disposition: "
"inline;\nContent-ID: <%s>][base64]]\n")
ext id)
(base64-encode-string
(with-temp-buffer
(set-buffer-multibyte nil)
@ -146,17 +146,26 @@ exported html."
(buffer-string)))))
('vm "?")))
(defun org-mime-multipart (plain html)
"Markup a multipart/alternative with text/plain and text/html
alternatives."
(defun org-mime-multipart (plain html &optional images)
"Markup a multipart/alternative with text/plain and text/html alternatives.
If the html portion of the message includes images wrap the html
and images in a multipart/related part."
(case org-mime-library
('mml (format (concat "<#multipart type=alternative><#part type=text/plain>"
"%s<#part type=text/html>%s<#/multipart>\n")
plain html))
('mml (concat "<#multipart type=alternative><#part type=text/plain>"
plain
(when images "<#multipart type=related>")
"<#part type=text/html>"
html
images
(when images "<#/multipart>\n")
"<#/multipart>\n"))
('semi (concat
"--" "<<alternative>>-{\n"
"--" "[[text/plain]]\n" plain
(when images (concat "--" "<<alternative>>-{\n"))
"--" "[[text/html]]\n" html
images
(when images (concat "--" "}-<<alternative>>\n"))
"--" "}-<<alternative>>\n"))
('vm "?")))
@ -206,7 +215,7 @@ export that region, otherwise export the entire body."
;; makes the replies with ">"s look nicer
(org-export-preserve-breaks org-mime-preserve-breaks)
;; dvipng for inline latex because MathJax doesn't work in mail
(org-export-with-LaTeX-fragments "dvipng")
(org-export-with-LaTeX-fragments 'dvipng)
;; to hold attachments for inline html images
(html-and-images
(org-mime-replace-images
@ -220,8 +229,8 @@ export that region, otherwise export the entire body."
(delete-region html-start html-end)
(save-excursion
(goto-char html-start)
(insert (org-mime-multipart body html)
(mapconcat 'identity html-images "\n")))))
(insert (org-mime-multipart
body html (mapconcat 'identity html-images "\n"))))))
(defun org-mime-apply-html-hook (html)
(if org-mime-html-hook

377
contrib/lisp/org-notify.el Normal file
View File

@ -0,0 +1,377 @@
;;; org-notify.el --- Notifications for Org-mode
;; Copyright (C) 2012 Free Software Foundation, Inc.
;; Author: Peter Münster <pmrb@free.fr>
;; Keywords: notification, todo-list, alarm, reminder, pop-up
;; 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
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; Get notifications, when there is something to do.
;; Sometimes, you need a reminder a few days before a deadline, e.g. to buy a
;; present for a birthday, and then another notification one hour before to
;; have enough time to choose the right clothes.
;; For other events, e.g. rolling the dustbin to the roadside once per week,
;; you probably need another kind of notification strategy.
;; This package tries to satisfy the various needs.
;; In order to activate this package, you must add the following code
;; into your .emacs:
;;
;; (require 'org-notify)
;; (org-notify-start)
;; Example setup:
;; (org-notify-add 'appt
;; '(:time "-1s" :period "20s" :duration 10
;; :actions (-message -ding))
;; '(:time "15m" :period "2m" :duration 100
;; :actions -notify)
;; '(:time "2h" :period "5m" :actions -message)
;; '(:time "3d" :actions -email))
;; This means for todo-items with `notify' property set to `appt': 3 days
;; before deadline, send a reminder-email, 2 hours before deadline, start to
;; send messages every 5 minutes, then 15 minutes before deadline, start to
;; pop up notification windows every 2 minutes. The timeout of the window is
;; set to 100 seconds. Finally, when deadline is overdue, send messages and
;; make noise."
;; Take also a look at the function `org-notify-add'.
;;; Code:
(eval-when-compile (require 'cl))
(require 'org-element)
(declare-function appt-delete-window "appt" ())
(declare-function notifications-notify "notifications" (&rest prms))
(declare-function article-lapsed-string "gnus-art" (t &optional ms))
(defgroup org-notify nil
"Options for Org-mode notifications."
:tag "Org Notify"
:group 'org)
(defcustom org-notify-audible t
"Non-nil means beep to indicate notification."
:type 'boolean
:group 'org-notify)
(defconst org-notify-actions
'("show" "show" "done" "done" "hour" "one hour later" "day" "one day later"
"week" "one week later")
"Possible actions for call-back functions.")
(defconst org-notify-window-buffer-name "*org-notify-%s*"
"Buffer-name for the `org-notify-action-window' function.")
(defvar org-notify-map nil
"Mapping between names and parameter lists.")
(defvar org-notify-timer nil
"Timer of the notification daemon.")
(defvar org-notify-parse-file nil
"Index of current file, that `org-element-parse-buffer' is parsing.")
(defvar org-notify-on-action-map nil
"Mapping between on-action identifiers and parameter lists.")
(defun org-notify-string->seconds (str)
"Convert time string STR to number of seconds."
(when str
(let* ((conv `(("s" . 1) ("m" . 60) ("h" . ,(* 60 60))
("d" . ,(* 24 60 60)) ("w" . ,(* 7 24 60 60))
("M" . ,(* 30 24 60 60))))
(letters (concat
(mapcar (lambda (x) (string-to-char (car x))) conv)))
(case-fold-search nil))
(string-match (concat "\\(-?\\)\\([0-9]+\\)\\([" letters "]\\)") str)
(* (string-to-number (match-string 2 str))
(cdr (assoc (match-string 3 str) conv))
(if (= (length (match-string 1 str)) 1) -1 1)))))
(defun org-notify-make-todo (heading &rest ignored)
"Create one todo item."
(macrolet ((get (k) `(plist-get list ,k))
(pr (k v) `(setq result (plist-put result ,k ,v))))
(let* ((list (nth 1 heading)) (notify (or (get :notify) "default"))
(deadline (get :deadline)) (heading (get :raw-value))
result)
(when (and (eq (get :todo-type) 'todo) heading deadline)
(pr :heading heading) (pr :notify (intern notify))
(pr :begin (get :begin))
(pr :file (nth org-notify-parse-file (org-agenda-files 'unrestricted)))
(pr :timestamp deadline) (pr :uid (md5 (concat heading deadline)))
(pr :deadline (- (org-time-string-to-seconds deadline)
(org-float-time))))
result)))
(defun org-notify-todo-list ()
"Create the todo-list for one org-agenda file."
(let* ((files (org-agenda-files 'unrestricted))
(max (1- (length files))))
(setq org-notify-parse-file
(if (or (not org-notify-parse-file) (>= org-notify-parse-file max))
0
(1+ org-notify-parse-file)))
(save-excursion
(with-current-buffer (find-file-noselect
(nth org-notify-parse-file files))
(org-element-map (org-element-parse-buffer 'headline)
'headline 'org-notify-make-todo)))))
(defun org-notify-maybe-too-late (diff period heading)
"Print waring message, when notified significantly later than defined by
PERIOD."
(if (> (/ diff period) 1.5)
(message "Warning: notification for \"%s\" behind schedule!" heading))
t)
(defun org-notify-process ()
"Process the todo-list, and possibly notify user about upcoming or
forgotten tasks."
(macrolet ((prm (k) `(plist-get prms ,k)) (td (k) `(plist-get todo ,k)))
(dolist (todo (org-notify-todo-list))
(let* ((deadline (td :deadline)) (heading (td :heading))
(uid (td :uid)) (last-run-sym
(intern (concat ":last-run-" uid))))
(dolist (prms (plist-get org-notify-map (td :notify)))
(when (< deadline (org-notify-string->seconds (prm :time)))
(let ((period (org-notify-string->seconds (prm :period)))
(last-run (prm last-run-sym)) (now (org-float-time))
(actions (prm :actions)) diff plist)
(when (or (not last-run)
(and period (< period (setq diff (- now last-run)))
(org-notify-maybe-too-late diff period heading)))
(setq prms (plist-put prms last-run-sym now)
plist (append todo prms))
(if (if (plist-member prms :audible)
(prm :audible)
org-notify-audible)
(ding))
(unless (listp actions)
(setq actions (list actions)))
(dolist (action actions)
(funcall (if (fboundp action) action
(intern (concat "org-notify-action"
(symbol-name action))))
plist))))
(return)))))))
(defun org-notify-add (name &rest params)
"Add a new notification type. The NAME can be used in Org-mode property
`notify'. If NAME is `default', the notification type applies for todo items
without the `notify' property. This file predefines such a default
notification type.
Each element of PARAMS is a list with parameters for a given time
distance to the deadline. This distance must increase from one element to
the next.
List of possible parameters:
:time Time distance to deadline, when this type of notification shall
start. It's a string: an integral value (positive or negative)
followed by a unit (s, m, h, d, w, M).
:actions A function or a list of functions to be called to notify the
user. Instead of a function name, you can also supply a suffix
of one of the various predefined `org-notify-action-xxx'
functions.
:period Optional: can be used to repeat the actions periodically. Same
format as :time.
:duration Some actions use this parameter to specify the duration of the
notification. It's an integral number in seconds.
:audible Overwrite the value of `org-notify-audible' for this action.
For the actions, you can use your own functions or some of the predefined
ones, whose names are prefixed with `org-notify-action-'."
(setq org-notify-map (plist-put org-notify-map name params)))
(defun org-notify-start (&optional secs)
"Start the notification daemon. If SECS is positive, it's the
period in seconds for processing the notifications of one
org-agenda file, and if negative, notifications will be checked
only when emacs is idle for -SECS seconds. The default value for
SECS is 20."
(if org-notify-timer
(org-notify-stop))
(setq secs (or secs 20)
org-notify-timer (if (< secs 0)
(run-with-idle-timer (* -1 secs) t
'org-notify-process)
(run-with-timer secs secs 'org-notify-process))))
(defun org-notify-stop ()
"Stop the notification daemon."
(when org-notify-timer
(cancel-timer org-notify-timer)
(setq org-notify-timer nil)))
(defun org-notify-on-action (plist key)
"User wants to see action."
(let ((file (plist-get plist :file))
(begin (plist-get plist :begin)))
(if (string-equal key "show")
(progn
(switch-to-buffer (find-file-noselect file))
(org-with-wide-buffer
(goto-char begin)
(show-entry))
(goto-char begin)
(search-forward "DEADLINE: <")
(if (display-graphic-p)
(x-focus-frame nil)))
(save-excursion
(with-current-buffer (find-file-noselect file)
(org-with-wide-buffer
(goto-char begin)
(search-forward "DEADLINE: <")
(cond
((string-equal key "done") (org-todo))
((string-equal key "hour") (org-timestamp-change 60 'minute))
((string-equal key "day") (org-timestamp-up-day))
((string-equal key "week") (org-timestamp-change 7 'day)))))))))
(defun org-notify-on-action-notify (id key)
"User wants to see action after mouse-click in notify window."
(org-notify-on-action (plist-get org-notify-on-action-map id) key)
(org-notify-on-close id nil))
(defun org-notify-on-action-button (button)
"User wants to see action after button activation."
(macrolet ((get (k) `(button-get button ,k)))
(org-notify-on-action (get 'plist) (get 'key))
(org-notify-delete-window (get 'buffer))
(cancel-timer (get 'timer))))
(defun org-notify-delete-window (buffer)
"Delete the notification window."
(require 'appt)
(let ((appt-buffer-name buffer)
(appt-audible nil))
(appt-delete-window)))
(defun org-notify-on-close (id reason)
"Notification window has been closed."
(setq org-notify-on-action-map (plist-put org-notify-on-action-map id nil)))
(defun org-notify-action-message (plist)
"Print a message."
(message "TODO: \"%s\" at %s!" (plist-get plist :heading)
(plist-get plist :timestamp)))
(defun org-notify-action-ding (plist)
"Make noise."
(let ((timer (run-with-timer 0 1 'ding)))
(run-with-timer (or (plist-get plist :duration) 3) nil
'cancel-timer timer)))
(defun org-notify-body-text (plist)
"Make human readable string for remaining time to deadline."
(require 'gnus-art)
(format "%s\n(%s)"
(replace-regexp-in-string
" in the future" ""
(article-lapsed-string
(time-add (current-time)
(seconds-to-time (plist-get plist :deadline))) 2))
(plist-get plist :timestamp)))
(defun org-notify-action-email (plist)
"Send email to user."
(compose-mail user-mail-address (concat "TODO: " (plist-get plist :heading)))
(insert (org-notify-body-text plist))
(funcall send-mail-function)
(flet ((yes-or-no-p (prompt) t))
(kill-buffer)))
(defun org-notify-select-highest-window ()
"Select the highest window on the frame, that is not is not an
org-notify window. Mostly copied from `appt-select-lowest-window'."
(let ((highest-window (selected-window))
(bottom-edge (nth 3 (window-edges)))
next-bottom-edge)
(walk-windows (lambda (w)
(when (and
(not (string-match "^\\*org-notify-.*\\*$"
(buffer-name
(window-buffer w))))
(> bottom-edge (setq next-bottom-edge
(nth 3 (window-edges w)))))
(setq bottom-edge next-bottom-edge
highest-window w))) 'nomini)
(select-window highest-window)))
(defun org-notify-action-window (plist)
"Pop up a window, mostly copied from `appt-disp-window'."
(save-excursion
(macrolet ((get (k) `(plist-get plist ,k)))
(let ((this-window (selected-window))
(buf (get-buffer-create
(format org-notify-window-buffer-name (get :uid)))))
(when (minibufferp)
(other-window 1)
(and (minibufferp) (display-multi-frame-p) (other-frame 1)))
(if (cdr (assq 'unsplittable (frame-parameters)))
(progn (set-buffer buf) (display-buffer buf))
(unless (or (special-display-p (buffer-name buf))
(same-window-p (buffer-name buf)))
(org-notify-select-highest-window)
(when (>= (window-height) (* 2 window-min-height))
(select-window (split-window nil nil 'above))))
(switch-to-buffer buf))
(setq buffer-read-only nil buffer-undo-list t)
(erase-buffer)
(insert (format "TODO: %s, %s.\n" (get :heading)
(org-notify-body-text plist)))
(let ((timer (run-with-timer (or (get :duration) 10) nil
'org-notify-delete-window buf)))
(dotimes (i (/ (length org-notify-actions) 2))
(let ((key (nth (* i 2) org-notify-actions))
(text (nth (1+ (* i 2)) org-notify-actions)))
(insert-button text 'action 'org-notify-on-action-button
'key key 'buffer buf 'plist plist 'timer timer)
(insert " "))))
(shrink-window-if-larger-than-buffer (get-buffer-window buf t))
(set-buffer-modified-p nil) (setq buffer-read-only t)
(raise-frame (selected-frame)) (select-window this-window)))))
(defun org-notify-action-notify (plist)
"Pop up a notification window."
(require 'notifications)
(let* ((duration (plist-get plist :duration))
(id (notifications-notify
:title (plist-get plist :heading)
:body (org-notify-body-text plist)
:timeout (if duration (* duration 1000))
:actions org-notify-actions
:on-action 'org-notify-on-action-notify)))
(setq org-notify-on-action-map
(plist-put org-notify-on-action-map id plist))))
(defun org-notify-action-notify/window (plist)
"For a graphics display, pop up a notification window, for a text
terminal an emacs window."
(if (display-graphic-p)
(org-notify-action-notify plist)
(org-notify-action-window plist)))
;;; Provide a minimal default setup.
(org-notify-add 'default '(:time "1h" :actions -notify/window
:period "2m" :duration 60))
(provide 'org-notify)
;;; org-notify.el ends here

File diff suppressed because it is too large Load Diff

View File

@ -4,8 +4,8 @@
@setfilename ../../info/org
@settitle The Org Manual
@set VERSION 7.8.03
@set DATE January 2012
@set VERSION 7.8.09
@set DATE April 2012
@c Use proper quote and backtick for code sections in PDF output
@c Cf. Texinfo manual 14.2
@ -612,28 +612,29 @@ DocBook export
OpenDocument Text export
* Pre-requisites for @acronym{ODT} export:: What packages @acronym{ODT} exporter relies on
* @acronym{ODT} export commands:: How to invoke @acronym{ODT} export
* Extending @acronym{ODT} export:: How to produce @samp{doc}, @samp{pdf} files
* Pre-requisites for ODT export:: What packages ODT exporter relies on
* ODT export commands:: How to invoke ODT export
* Extending ODT export:: How to produce @samp{doc}, @samp{pdf} files
* Applying custom styles:: How to apply custom styles to the output
* Links in @acronym{ODT} export:: How links will be interpreted and formatted
* Tables in @acronym{ODT} export:: How Tables are exported
* Images in @acronym{ODT} export:: How to insert images
* Math formatting in @acronym{ODT} export:: How @LaTeX{} fragments are formatted
* Literal examples in @acronym{ODT} export:: How source and example blocks are formatted
* Advanced topics in @acronym{ODT} export:: Read this if you are a power user
* Links in ODT export:: How links will be interpreted and formatted
* Tables in ODT export:: How Tables are exported
* Images in ODT export:: How to insert images
* Math formatting in ODT export:: How @LaTeX{} fragments are formatted
* Labels and captions in ODT export:: How captions are rendered
* Literal examples in ODT export:: How source and example blocks are formatted
* Advanced topics in ODT export:: Read this if you are a power user
Math formatting in @acronym{ODT} export
Math formatting in ODT export
* Working with @LaTeX{} math snippets:: How to embed @LaTeX{} math fragments
* Working with MathML or OpenDocument formula files:: How to embed equations in native format
Advanced topics in @acronym{ODT} export
Advanced topics in ODT export
* Configuring a document converter:: How to register a document converter
* Working with OpenDocument style files:: Explore the internals
* Creating one-off styles:: How to produce custom highlighting etc
* Customizing tables in @acronym{ODT} export:: How to define and use Table templates
* Customizing tables in ODT export:: How to define and use Table templates
* Validating OpenDocument XML:: How to debug corrupt OpenDocument files
Publishing
@ -694,6 +695,7 @@ Specific header arguments
* results:: Specify the type of results and how they will
be collected and handled
* file:: Specify a path for file output
* file-desc:: Specify a description for file results
* dir:: Specify the default (possibly remote)
directory for code block execution
* exports:: Export code and/or results
@ -1007,7 +1009,7 @@ from within Emacs, please copy and paste the content into your Email program.
Sometimes you might face a problem due to an error in your Emacs or Org mode
setup. Before reporting a bug, it is very helpful to start Emacs with minimal
customisations and reproduce the problem. Doing so often helps you determine
customizations and reproduce the problem. Doing so often helps you determine
if the problem is with your customization or with Org mode itself. You can
start a typical minimal session with a command like the example below.
@ -2261,7 +2263,8 @@ of columns, much like horizontal lines can do for groups of rows. In
order to specify column groups, you can use a special row where the
first field contains only @samp{/}. The further fields can either
contain @samp{<} to indicate that this column should start a group,
@samp{>} to indicate the end of a column, or @samp{<>} to make a column
@samp{>} to indicate the end of a column, or @samp{<>} (no space between @samp{<}
and @samp{>}) to make a column
a group of its own. Boundaries between column groups will upon export be
marked with vertical lines. Here is an example:
@ -4953,7 +4956,7 @@ TIMESTAMP_IA @r{The first inactive timestamp in the entry.}
CLOCKSUM @r{The sum of CLOCK intervals in the subtree. @code{org-clock-sum}}
@r{must be run first to compute the values in the current buffer.}
BLOCKED @r{"t" if task is currently blocked by children or siblings}
ITEM @r{The content of the entry.}
ITEM @r{The headline of the entry.}
FILE @r{The filename the entry is located in.}
@end example
@ -5718,8 +5721,8 @@ until the entry is marked DONE. An example:
@example
*** TODO write article about the Earth for the Guide
The editor in charge is [[bbdb:Ford Prefect]]
DEADLINE: <2004-02-29 Sun>
The editor in charge is [[bbdb:Ford Prefect]]
@end example
You can specify a different lead time for warnings for a specific
@ -6919,10 +6922,7 @@ Use the refile interface to jump to a heading.
Jump to the location where @code{org-refile} last moved a tree to.
@item C-2 C-c C-w
Refile as the child of the item currently being clocked.
@item C-0 C-c C-w @ @r{or} @ C-u C-u C-u C-c C-w
@orgcmdtkc{C-0 C-c C-w @ @r{or} @ C-u C-u C-u C-c C-w,C-0 C-c C-w,org-refile-cache-clear}
Clear the target cache. Caching of refile targets can be turned on by
setting @code{org-refile-use-cache}. To make the command see new possible
targets, you have to clear the cache with this command.
@ -7546,6 +7546,9 @@ So a search @samp{+LEVEL=3+boss-TODO="DONE"} lists all level three headlines
that have the tag @samp{boss} and are @emph{not} marked with the TODO keyword
DONE. In buffers with @code{org-odd-levels-only} set, @samp{LEVEL} does not
count the number of stars, but @samp{LEVEL=2} will correspond to 3 stars etc.
The ITEM special property cannot currently be used in tags/property
searches@footnote{But @pxref{x-agenda-skip-entry-regexp,
,skipping entries based on regexp}.}.
Here are more examples:
@table @samp
@ -7887,9 +7890,9 @@ the other commands, the cursor needs to be in the desired line.
@tsubheading{Motion}
@cindex motion commands in agenda
@orgcmd{n,org-agenda-next-line}
Next line (same as @key{up} and @kbd{C-p}).
Next line (same as @key{down} and @kbd{C-n}).
@orgcmd{p,org-agenda-previous-line}
Previous line (same as @key{down} and @kbd{C-n}).
Previous line (same as @key{up} and @kbd{C-p}).
@tsubheading{View/Go to Org file}
@orgcmdkkc{@key{SPC},mouse-3,org-agenda-show-and-scroll-up}
Display the original location of the item in another window.
@ -9572,12 +9575,12 @@ the web, while the XOXO format provides a solid base for exchange with a
broad range of other applications. @LaTeX{} export lets you use Org mode and
its structured editing functions to easily create @LaTeX{} files. DocBook
export makes it possible to convert Org files to many other formats using
DocBook tools. OpenDocument Text(@acronym{ODT}) export allows seamless
DocBook tools. OpenDocument Text (ODT) export allows seamless
collaboration across organizational boundaries. For project management you
can create gantt and resource charts by using TaskJuggler export. To
incorporate entries with associated times like deadlines or appointments into
a desktop calendar program like iCal, Org mode can also produce extracts in
the iCalendar format. Currently Org mode only supports export, not import of
the iCalendar format. Currently, Org mode only supports export, not import of
these different formats.
Org supports export of selected regions when @code{transient-mark-mode} is
@ -9742,7 +9745,7 @@ author: @r{turn on/off inclusion of author name/email into exported file}
email: @r{turn on/off inclusion of author email into exported file}
creator: @r{turn on/off inclusion of creator info into exported file}
timestamp: @r{turn on/off inclusion creation time into exported file}
d: @r{turn on/off inclusion of drawers}
d: @r{turn on/off inclusion of drawers, or list drawers to include}
@end example
@noindent
These options take effect in both the HTML and @LaTeX{} export, except for
@ -9837,13 +9840,13 @@ at a different level, specify it with a prefix argument. For example,
@end example
@noindent
creates only top level headlines and does the rest as items. When
creates only top level headlines and exports the rest as items. When
headlines are converted to items, the indentation of the text following
the headline is changed to fit nicely under the item. This is done with
the assumption that the first body line indicates the base indentation of
the body text. Any indentation larger than this is adjusted to preserve
the layout relative to the first line. Should there be lines with less
indentation than the first, these are left alone.
indentation than the first one, these are left alone.
@vindex org-export-ascii-links-to-notes
Links will be exported in a footnote-like style, with the descriptive part in
@ -9936,11 +9939,11 @@ creates two levels of headings and does the rest as items.
The HTML exporter lets you define a preamble and a postamble.
The default value for @code{org-export-html-preamble} is @code{t}, which
means that the preamble is inserted depending on the relevant formatting
string in @code{org-export-html-preamble-format}.
means that the preamble is inserted depending on the relevant format string
in @code{org-export-html-preamble-format}.
Setting @code{org-export-html-preamble} to a string will override the default
formatting string. Setting it to a function, will insert the output of the
format string. Setting it to a function, will insert the output of the
function, which must be a string; such a function takes no argument but you
can check against the value of @code{opt-plist}, which contains the list of
publishing properties for the current file. Setting to @code{nil} will not
@ -9952,7 +9955,7 @@ means that the HTML exporter will look for the value of
@code{org-export-creator-info} and @code{org-export-time-stamp-file},
@code{org-export-html-validation-link} and build the postamble from these
values. Setting @code{org-export-html-postamble} to @code{t} will insert the
postamble from the relevant formatting string found in
postamble from the relevant format string found in
@code{org-export-html-postamble-format}. Setting it to @code{nil} will not
insert any postamble.
@ -10234,7 +10237,7 @@ viewing options:
path: @r{The path to the script. The default is to grab the script from}
@r{@url{http://orgmode.org/org-info.js}, but you might want to have}
@r{a local copy and use a path like @samp{../scripts/org-info.js}.}
view: @r{Initial view when website is first shown. Possible values are:}
view: @r{Initial view when the website is first shown. Possible values are:}
info @r{Info-like interface with one section per page.}
overview @r{Folding interface, initially showing only top-level.}
content @r{Folding interface, starting with all headlines visible.}
@ -10836,35 +10839,36 @@ special characters included in XHTML entities:
@cindex org-modules
Orgmode@footnote{Versions 7.8 or later} supports export to OpenDocument Text
(@acronym{ODT}) format using the @file{org-odt.el} module. Documents created
(ODT) format using the @file{org-odt.el} module. Documents created
by this exporter use the @cite{OpenDocument-v1.2
specification}@footnote{@url{http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2.html,
Open Document Format for Office Applications (OpenDocument) Version 1.2}} and
are compatible with LibreOffice 3.4.
@menu
* Pre-requisites for @acronym{ODT} export:: What packages @acronym{ODT} exporter relies on
* @acronym{ODT} export commands:: How to invoke @acronym{ODT} export
* Extending @acronym{ODT} export:: How to produce @samp{doc}, @samp{pdf} files
* Pre-requisites for ODT export:: What packages ODT exporter relies on
* ODT export commands:: How to invoke ODT export
* Extending ODT export:: How to produce @samp{doc}, @samp{pdf} files
* Applying custom styles:: How to apply custom styles to the output
* Links in @acronym{ODT} export:: How links will be interpreted and formatted
* Tables in @acronym{ODT} export:: How Tables are exported
* Images in @acronym{ODT} export:: How to insert images
* Math formatting in @acronym{ODT} export:: How @LaTeX{} fragments are formatted
* Literal examples in @acronym{ODT} export:: How source and example blocks are formatted
* Advanced topics in @acronym{ODT} export:: Read this if you are a power user
* Links in ODT export:: How links will be interpreted and formatted
* Tables in ODT export:: How Tables are exported
* Images in ODT export:: How to insert images
* Math formatting in ODT export:: How @LaTeX{} fragments are formatted
* Labels and captions in ODT export:: How captions are rendered
* Literal examples in ODT export:: How source and example blocks are formatted
* Advanced topics in ODT export:: Read this if you are a power user
@end menu
@node Pre-requisites for @acronym{ODT} export, @acronym{ODT} export commands, OpenDocument Text export, OpenDocument Text export
@subsection Pre-requisites for @acronym{ODT} export
@node Pre-requisites for ODT export, ODT export commands, OpenDocument Text export, OpenDocument Text export
@subsection Pre-requisites for ODT export
@cindex zip
The @acronym{ODT} exporter relies on the @file{zip} program to create the final
The ODT exporter relies on the @file{zip} program to create the final
output. Check the availability of this program before proceeding further.
@node @acronym{ODT} export commands, Extending @acronym{ODT} export, Pre-requisites for @acronym{ODT} export, OpenDocument Text export
@subsection @acronym{ODT} export commands
@node ODT export commands, Extending ODT export, Pre-requisites for ODT export, OpenDocument Text export
@subsection ODT export commands
@subsubheading Exporting to @acronym{ODT}
@subsubheading Exporting to ODT
@anchor{x-export-to-odt}
@cindex region, active
@ -10881,7 +10885,7 @@ If @code{org-export-odt-preferred-output-format} is specified, automatically
convert the exported file to that format. @xref{x-export-to-other-formats, ,
Automatically exporting to other formats}.
For an Org file @file{myfile.org}, the @acronym{ODT} file will be
For an Org file @file{myfile.org}, the ODT file will be
@file{myfile.odt}. The file will be overwritten without warning. If there
is an active region,@footnote{This requires @code{transient-mark-mode} to be
turned on} only the region will be exported. If the selected region is a
@ -10899,10 +10903,10 @@ converted file instead. @xref{x-export-to-other-formats, , Automatically
exporting to other formats}.
@end table
@node Extending @acronym{ODT} export, Applying custom styles, @acronym{ODT} export commands, OpenDocument Text export
@subsection Extending @acronym{ODT} export
@node Extending ODT export, Applying custom styles, ODT export commands, OpenDocument Text export
@subsection Extending ODT export
The @acronym{ODT} exporter can interface with a variety of document
The ODT exporter can interface with a variety of document
converters and supports popular converters out of the box. As a result, you
can use it to export to formats like @samp{doc} or convert a document from
one format (say @samp{csv}) to another format (say @samp{ods} or @samp{xls}).
@ -10912,16 +10916,16 @@ one format (say @samp{csv}) to another format (say @samp{ods} or @samp{xls}).
If you have a working installation of LibreOffice, a document converter is
pre-configured for you and you can use it right away. If you would like to
use @file{unoconv} as your preferred converter, customize the variable
@code{org-export-odt-convert-process} to point to @code{unoconv}. If you
would like to use a converter of your own choosing or tweak the default
settings of the default @file{LibreOffice} and @samp{unoconv} converters
@xref{Configuring a document converter}.
@code{org-export-odt-convert-process} to point to @code{unoconv}. You can
also use your own favorite converter or tweak the default settings of the
@file{LibreOffice} and @samp{unoconv} converters. @xref{Configuring a
document converter}.
@subsubsection Automatically exporting to other formats
@anchor{x-export-to-other-formats}
@vindex org-export-odt-preferred-output-format
Very often, you will find yourself exporting to @acronym{ODT} format, only to
Very often, you will find yourself exporting to ODT format, only to
immediately save the exported document to other formats like @samp{doc},
@samp{docx}, @samp{rtf}, @samp{pdf} etc. In such cases, you can specify your
preferred output format by customizing the variable
@ -10934,7 +10938,7 @@ format that is of immediate interest to you.
There are many document converters in the wild which support conversion to
and from various file formats, including, but not limited to the
@acronym{ODT} format. LibreOffice converter, mentioned above, is one such
ODT format. LibreOffice converter, mentioned above, is one such
converter. Once a converter is configured, you can interact with it using
the following command.
@ -10946,12 +10950,12 @@ Convert an existing document from one format to another. With a prefix
argument, also open the newly produced file.
@end table
@node Applying custom styles, Links in @acronym{ODT} export, Extending @acronym{ODT} export, OpenDocument Text export
@node Applying custom styles, Links in ODT export, Extending ODT export, OpenDocument Text export
@subsection Applying custom styles
@cindex styles, custom
@cindex template, custom
The @acronym{ODT} exporter ships with a set of OpenDocument styles
The ODT exporter ships with a set of OpenDocument styles
(@pxref{Working with OpenDocument style files}) that ensure a well-formatted
output. These factory styles, however, may not cater to your specific
tastes. To customize the output, you can either modify the above styles
@ -10964,7 +10968,7 @@ users alike, and is described here.
@enumerate
@item
Create a sample @file{example.org} file with the below settings and export it
to @acronym{ODT} format.
to ODT format.
@example
#+OPTIONS: H:10 num:t
@ -11007,15 +11011,22 @@ met, the output is going to be less than satisfactory. So it is highly
recommended that you only work with templates that are directly derived from
the factory settings.
@node Links in @acronym{ODT} export, Tables in @acronym{ODT} export, Applying custom styles, OpenDocument Text export
@subsection Links in @acronym{ODT} export
@node Links in ODT export, Tables in ODT export, Applying custom styles, OpenDocument Text export
@subsection Links in ODT export
@cindex tables, in DocBook export
The @acronym{ODT} exporter creates cross-references (aka bookmarks) for
internal links. It creates Internet-style links for all other links.
ODT exporter creates native cross-references for internal links. It creates
Internet-style links for all other links.
@node Tables in @acronym{ODT} export, Images in @acronym{ODT} export, Links in @acronym{ODT} export, OpenDocument Text export
@subsection Tables in @acronym{ODT} export
A link with no description and destined to a regular (un-itemized) outline
heading is replaced with a cross-reference and section number of the heading.
A @samp{\ref@{label@}}-style reference to an image, table etc. is replaced
with a cross-reference and sequence number of the labeled entity.
@xref{Labels and captions in ODT export}.
@node Tables in ODT export, Images in ODT export, Links in ODT export, OpenDocument Text export
@subsection Tables in ODT export
@cindex tables, in DocBook export
Export of native Org mode tables (@pxref{Tables}) and simple @file{table.el}
@ -11035,7 +11046,7 @@ You can control the width of the table by specifying @code{:rel-width}
property using an @code{#+ATTR_ODT} line.
For example, consider the following table which makes use of all the rules
mentoned above.
mentioned above.
@example
#+ATTR_ODT: :rel-width 50
@ -11058,12 +11069,12 @@ be horizontal rules separating the header and last rows from other rows.
If you are not satisfied with the above formatting options, you can create
custom table styles and associate them with a table using the
@code{#+ATTR_ODT} line. @xref{Customizing tables in @acronym{ODT} export}.
@code{#+ATTR_ODT} line. @xref{Customizing tables in ODT export}.
@node Images in @acronym{ODT} export, Math formatting in @acronym{ODT} export, Tables in @acronym{ODT} export, OpenDocument Text export
@subsection Images in @acronym{ODT} export
@cindex images, embedding in @acronym{ODT}
@cindex embedding images in @acronym{ODT}
@node Images in ODT export, Math formatting in ODT export, Tables in ODT export, OpenDocument Text export
@subsection Images in ODT export
@cindex images, embedding in ODT
@cindex embedding images in ODT
@subsubheading Embedding images
You can embed images within the exported document by providing a link to the
@ -11161,17 +11172,17 @@ To create an image that is anchored to a page, do the following:
[[./img.png]]
@end example
@node Math formatting in @acronym{ODT} export, Literal examples in @acronym{ODT} export, Images in @acronym{ODT} export, OpenDocument Text export
@subsection Math formatting in @acronym{ODT} export
@node Math formatting in ODT export, Labels and captions in ODT export, Images in ODT export, OpenDocument Text export
@subsection Math formatting in ODT export
The @acronym{ODT} exporter has special support for handling math.
The ODT exporter has special support for handling math.
@menu
* Working with @LaTeX{} math snippets:: How to embed @LaTeX{} math fragments
* Working with MathML or OpenDocument formula files:: How to embed equations in native format
@end menu
@node Working with @LaTeX{} math snippets, Working with MathML or OpenDocument formula files, Math formatting in @acronym{ODT} export, Math formatting in @acronym{ODT} export
@node Working with @LaTeX{} math snippets, Working with MathML or OpenDocument formula files, Math formatting in ODT export, Math formatting in ODT export
@subsubsection Working with @LaTeX{} math snippets
@LaTeX{} math snippets (@pxref{@LaTeX{} fragments}) can be embedded in the ODT
@ -11237,12 +11248,12 @@ resulting images are embedded in the exported document. This method requires
that the @file{dvipng} program be available on your system.
@end enumerate
@node Working with MathML or OpenDocument formula files, , Working with @LaTeX{} math snippets, Math formatting in @acronym{ODT} export
@node Working with MathML or OpenDocument formula files, , Working with @LaTeX{} math snippets, Math formatting in ODT export
@subsubsection Working with MathML or OpenDocument formula files
For various reasons, you may find embedding @LaTeX{} math snippets in an
@acronym{ODT} document less than reliable. In that case, you can embed a
math equation by linking to its MathML(@file{.mml}) source or its
ODT document less than reliable. In that case, you can embed a
math equation by linking to its MathML (@file{.mml}) source or its
OpenDocument formula (@file{.odf}) file as shown below:
@example
@ -11255,39 +11266,74 @@ or
[[./equation.odf]]
@end example
@node Literal examples in @acronym{ODT} export, Advanced topics in @acronym{ODT} export, Math formatting in @acronym{ODT} export, OpenDocument Text export
@subsection Literal examples in @acronym{ODT} export
@node Labels and captions in ODT export, Literal examples in ODT export, Math formatting in ODT export, OpenDocument Text export
@subsection Labels and captions in ODT export
You can label and caption various category of objects - an inline image, a
table, a @LaTeX{} fragment or a Math formula - using @code{#+LABEL} and
@code{#+CAPTION} lines. @xref{Images and tables}. ODT exporter enumerates
each labeled or captioned object of a given category separately. As a
result, each such object is assigned a sequence number based on order of it's
appearance in the Org file.
In the exported document, a user-provided caption is augmented with the
category and sequence number. Consider the following inline image in an Org
file.
@example
#+CAPTION: Bell curve
#+LABEL: fig:SED-HR4049
[[./img/a.png]]
@end example
It could be rendered as shown below in the exported document.
@example
Figure 2: Bell curve
@end example
@vindex org-export-odt-category-strings
You can modify the category component of the caption by customizing the
variable @code{org-export-odt-category-strings}. For example, to tag all
embedded images with the string @samp{Illustration} (instead of the default
@samp{Figure}) use the following setting.
@lisp
(setq org-export-odt-category-strings
'(("en" "Table" "Illustration" "Equation" "Equation")))
@end lisp
With this, previous image will be captioned as below in the exported
document.
@example
Illustration 2: Bell curve
@end example
@node Literal examples in ODT export, Advanced topics in ODT export, Labels and captions in ODT export, OpenDocument Text export
@subsection Literal examples in ODT export
Export of literal examples (@pxref{Literal examples}) with full fontification
is supported. This feature is enabled by default and is activated
automatically if an enhanced version of @file{htmlfontify.el} is available in
the @code{load-path}.@footnote{The @file{htmlfontify.el} that ships with
standard Emacs <= 24.1 has no support for @acronym{ODT} fontification. A
copy of the proposed version is available as an attachment to
@url{http://debbugs.gnu.org/cgi/bugreport.cgi?msg=5;filename=htmlfontify.el;att=9;bug=9914,
Emacs Bug #9914}.}
is supported. Internally, the exporter relies on @file{htmlfontify.el} to
generate all style definitions needed for a fancy listing.@footnote{Your
@file{htmlfontify.el} library must at least be at Emacs 24.1 levels for
fontification to be turned on.} The auto-generated styles have @samp{OrgSrc}
as prefix and inherit their color from the faces used by Emacs
@code{font-lock} library for the source language.
@vindex org-export-odt-fontify-srcblocks
The character styles used for fontification of the literal blocks are
auto-generated by the exporter in conjunction with @file{htmlfontify.el}
library and need not be included in the default @file{styles.xml} file.
These auto-generated styles have the @samp{OrgSrc} prefix and inherit their color
based on the face used by Emacs @code{font-lock} library.
@vindex org-export-odt-create-custom-styles-for-srcblocks
If you prefer to use your own custom styles for fontification and disable
their auto-generation altogether, you can do so by customizing the variable
If you prefer to use your own custom styles for fontification, you can do so
by customizing the variable
@code{org-export-odt-create-custom-styles-for-srcblocks}.
You can turn off fontification support for literal examples by customizing
the variable @code{org-export-odt-fontify-srcblocks}.
@vindex org-export-odt-create-custom-styles-for-srcblocks
You can turn off fontification of literal examples by customizing the
variable @code{org-export-odt-fontify-srcblocks}.
@node Advanced topics in ODT export, , Literal examples in ODT export, OpenDocument Text export
@subsection Advanced topics in ODT export
@node Advanced topics in @acronym{ODT} export, , Literal examples in @acronym{ODT} export, OpenDocument Text export
@subsection Advanced topics in @acronym{ODT} export
If you rely heavily on @acronym{ODT} export, you may want to exploit the full
If you rely heavily on ODT export, you may want to exploit the full
set of features that the exporter offers. This section describes features
that would be of interest to power users.
@ -11295,18 +11341,18 @@ that would be of interest to power users.
* Configuring a document converter:: How to register a document converter
* Working with OpenDocument style files:: Explore the internals
* Creating one-off styles:: How to produce custom highlighting etc
* Customizing tables in @acronym{ODT} export:: How to define and use Table templates
* Customizing tables in ODT export:: How to define and use Table templates
* Validating OpenDocument XML:: How to debug corrupt OpenDocument files
@end menu
@node Configuring a document converter, Working with OpenDocument style files, Advanced topics in @acronym{ODT} export, Advanced topics in @acronym{ODT} export
@node Configuring a document converter, Working with OpenDocument style files, Advanced topics in ODT export, Advanced topics in ODT export
@subsubsection Configuring a document converter
@cindex convert
@cindex doc, docx, rtf
@cindex converter
The @acronym{ODT} exporter can work with popular converters with little or no
extra configuration from your side. @xref{Extending @acronym{ODT} export}.
The ODT exporter can work with popular converters with little or no
extra configuration from your side. @xref{Extending ODT export}.
If you are using a converter that is not supported by default or if you would
like to tweak the default converter settings, proceed as below.
@ -11319,10 +11365,9 @@ the variable @code{org-export-odt-convert-processes}. Also specify how the
converter can be invoked via command-line to effect the conversion.
@item Configure its capabilities
@vindex org-export-odt-convert-capabilities
@anchor{x-odt-converter-capabilities}
Specify the set of formats the converter can handle by customizing the
variable @code{org-export-odt-convert-capabilities}. Use the default value
for this variable as a guide for configuring your converter. As suggested by
@ -11337,12 +11382,12 @@ Select the newly added converter as the preferred one by customizing the
variable @code{org-export-odt-convert-process}.
@end enumerate
@node Working with OpenDocument style files, Creating one-off styles, Configuring a document converter, Advanced topics in @acronym{ODT} export
@node Working with OpenDocument style files, Creating one-off styles, Configuring a document converter, Advanced topics in ODT export
@subsubsection Working with OpenDocument style files
@cindex styles, custom
@cindex template, custom
This section explores the internals of the @acronym{ODT} exporter and the
This section explores the internals of the ODT exporter and the
means by which it produces styled documents. Read this section if you are
interested in exploring the automatic and custom OpenDocument styles used by
the exporter.
@ -11350,7 +11395,7 @@ the exporter.
@anchor{x-factory-styles}
@subsubheading Factory styles
The @acronym{ODT} exporter relies on two files for generating its output.
The ODT exporter relies on two files for generating its output.
These files are bundled with the distribution under the directory pointed to
by the variable @code{org-odt-styles-dir}. The two files are:
@ -11396,7 +11441,7 @@ are numbered.
@anchor{x-overriding-factory-styles}
@subsubheading Overriding factory styles
The following two variables control the location from which the @acronym{ODT}
The following two variables control the location from which the ODT
exporter picks up the custom styles and content template files. You can
customize these variables to override the factory styles used by the
exporter.
@ -11441,7 +11486,7 @@ Use this variable to specify the blank @file{content.xml} that will be used
in the final output.
@end itemize
@node Creating one-off styles, Customizing tables in @acronym{ODT} export, Working with OpenDocument style files, Advanced topics in @acronym{ODT} export
@node Creating one-off styles, Customizing tables in ODT export, Working with OpenDocument style files, Advanced topics in ODT export
@subsubsection Creating one-off styles
There are times when you would want one-off formatting in the exported
@ -11461,7 +11506,7 @@ regular text.
@end example
@strong{Hint:} To see the above example in action, edit your
@file{styles.xml}(@pxref{x-orgodtstyles-xml,,Factory styles}) and add a
@file{styles.xml} (@pxref{x-orgodtstyles-xml,,Factory styles}) and add a
custom @samp{Highlight} style as shown below.
@example
@ -11480,7 +11525,7 @@ directive. For example, to force a page break do the following:
@end example
@strong{Hint:} To see the above example in action, edit your
@file{styles.xml}(@pxref{x-orgodtstyles-xml,,Factory styles}) and add a
@file{styles.xml} (@pxref{x-orgodtstyles-xml,,Factory styles}) and add a
custom @samp{PageBreak} style as shown below.
@example
@ -11508,14 +11553,14 @@ This paragraph is specially formatted and uses bold text.
@end enumerate
@node Customizing tables in @acronym{ODT} export, Validating OpenDocument XML, Creating one-off styles, Advanced topics in @acronym{ODT} export
@subsubsection Customizing tables in @acronym{ODT} export
@node Customizing tables in ODT export, Validating OpenDocument XML, Creating one-off styles, Advanced topics in ODT export
@subsubsection Customizing tables in ODT export
@cindex tables, in ODT export
@cindex #+ATTR_ODT
You can override the default formatting of the table by specifying a custom
table style with the @code{#+ATTR_ODT} line. For a discussion on default
formatting of tables @pxref{Tables in @acronym{ODT} export}.
formatting of tables @pxref{Tables in ODT export}.
This feature closely mimics the way table templates are defined in the
OpenDocument-v1.2
@ -11541,7 +11586,7 @@ the table that follows.
@end lisp
@example
#+ATTR_ODT: TableWithHeaderRowAndColumn
#+ATTR_ODT: :style "TableWithHeaderRowAndColumn"
| Name | Phone | Age |
| Peter | 1234 | 17 |
| Anna | 4321 | 25 |
@ -11646,9 +11691,9 @@ To define a table style, create an entry for the style in the variable
@end itemize
For example, the entry below defines two different table styles
@samp{TableWithHeaderRowsAndColumns} and @samp{TableWithHeaderColumns} based
on the same template @samp{Custom}. The styles achieve their intended effect
by selectively activating the individual cell styles in that template.
@samp{TableWithHeaderRowAndColumn} and @samp{TableWithFirstRowandLastRow}
based on the same template @samp{Custom}. The styles achieve their intended
effect by selectively activating the individual cell styles in that template.
@lisp
(setq org-export-odt-table-styles
@ -11668,18 +11713,18 @@ To do this, specify the table style created in step (2) as part of
the @code{ATTR_ODT} line as shown below.
@example
#+ATTR_ODT: TableWithHeaderRowAndColumn
#+ATTR_ODT: :style "TableWithHeaderRowAndColumn"
| Name | Phone | Age |
| Peter | 1234 | 17 |
| Anna | 4321 | 25 |
@end example
@end enumerate
@node Validating OpenDocument XML, , Customizing tables in @acronym{ODT} export, Advanced topics in @acronym{ODT} export
@node Validating OpenDocument XML, , Customizing tables in ODT export, Advanced topics in ODT export
@subsubsection Validating OpenDocument XML
Occasionally, you will discover that the document created by the
@acronym{ODT} exporter cannot be opened by your favorite application. One of
ODT exporter cannot be opened by your favorite application. One of
the common reasons for this is that the @file{.odt} file is corrupt. In such
cases, you may want to validate the document against the OpenDocument RELAX
NG Compact Syntax (RNC) schema.
@ -11693,7 +11738,7 @@ general help with validation (and schema-sensitive editing) of XML files:
If you have ready access to OpenDocument @file{.rnc} files and the needed
schema-locating rules in a single folder, you can customize the variable
@code{org-export-odt-schema-dir} to point to that directory. The
@acronym{ODT} exporter will take care of updating the
ODT exporter will take care of updating the
@code{rng-schema-locating-files} for you.
@c end opendocument
@ -13067,6 +13112,7 @@ argument in lowercase letters. The following header arguments are defined:
* results:: Specify the type of results and how they will
be collected and handled
* file:: Specify a path for file output
* file-desc:: Specify a description for file results
* dir:: Specify the default (possibly remote)
directory for code block execution
* exports:: Export code and/or results
@ -13462,7 +13508,7 @@ be prepended to the existing results. Otherwise the new results will be
inserted as with @code{replace}.
@end itemize
@node file, dir, results, Specific header arguments
@node file, file-desc, results, Specific header arguments
@subsubsection @code{:file}
The header argument @code{:file} is used to specify an external file in which
@ -13478,7 +13524,16 @@ The argument to @code{:file} should be either a string specifying the path to
a file, or a list of two strings in which case the first element of the list
should be the path to a file and the second a description for the link.
@node dir, exports, file, Specific header arguments
@node file-desc, dir, file, Specific header arguments
@subsubsection @code{:file-desc}
The value of the @code{:file-desc} header argument is used to provide a
description for file code block results which are inserted as Org-mode links
(see @ref{Link format}). If the @code{:file-desc} header argument is given
with no value the link path will be placed in both the ``link'' and the
``description'' portion of the Org-mode link.
@node dir, exports, file-desc, Specific header arguments
@subsubsection @code{:dir} and remote execution
While the @code{:file} header argument can be used to specify the path to the
@ -13683,6 +13738,9 @@ references will not be expanded when the code block is exported.
``Noweb'' syntax references in the body of the code block will be expanded
before the block is evaluated or tangled. However, ``noweb'' syntax
references will not be removed when the code block is exported.
@item @code{eval}
``Noweb'' syntax references in the body of the code block will only be
expanded before the block is evaluated.
@end itemize
@subsubheading Noweb prefix lines
@ -15883,9 +15941,10 @@ Skip current entry if the TODO keyword is TODO or WAITING.
Skip current entry if the TODO keyword marks a DONE state.
@item (org-agenda-skip-entry-if 'timestamp)
Skip current entry if it has any timestamp, may also be deadline or scheduled.
@item (org-agenda-skip-entry 'regexp "regular expression")
@anchor{x-agenda-skip-entry-regexp}
@item (org-agenda-skip-entry-if 'regexp "regular expression")
Skip current entry if the regular expression matches in the entry.
@item (org-agenda-skip-entry 'notregexp "regular expression")
@item (org-agenda-skip-entry-if 'notregexp "regular expression")
Skip current entry unless the regular expression matches.
@item (org-agenda-skip-subtree-if 'regexp "regular expression")
Same as above, but check and skip the entire subtree.
@ -16596,7 +16655,7 @@ with links transformation to Org syntax.
@i{David O'Toole} wrote @file{org-publish.el} and drafted the manual
chapter about publishing.
@item
@i{Jambunathan K} contributed the @acronym{ODT} exporter.
@i{Jambunathan K} contributed the ODT exporter.
@item
@i{Sebastien Vauban} reported many issues with @LaTeX{} and BEAMER export and
enabled source code highlighting in Gnus.

View File

@ -1,5 +1,5 @@
% Reference Card for Org Mode
\def\orgversionnumber{7.8.03}
\def\orgversionnumber{7.8.09}
\def\versionyear{2012} % latest update
\def\year{2012} % latest copyright year

View File

@ -3,8 +3,8 @@
@setfilename ../../info/orgguide
@settitle The compact Org-mode Guide
@set VERSION 7.8.03
@set DATE January 2012
@set VERSION 7.8.09
@set DATE April 2012
@c Use proper quote and backtick for code sections in PDF output
@c Cf. Texinfo manual 14.2

View File

@ -31,6 +31,7 @@
\else\if1#1 % Letter
\pdfpagewidth=8.5in
\pdfpageheight=11in
\letterpaper=1
\fi\fi
\if l#2 % Landscape
\edef\oldwidth{\the\pdfpagewidth}

View File

@ -256,6 +256,7 @@
<text:sequence-decl text:display-outline-level="0" text:name="Drawing"/>
<text:sequence-decl text:display-outline-level="0" text:name="Equation"/>
<text:sequence-decl text:display-outline-level="0" text:name="Figure"/>
<text:sequence-decl text:display-outline-level="0" text:name="Listing"/>
</text:sequence-decls>
</office:text>
</office:body>

View File

@ -319,6 +319,11 @@
<style:style style:name="Table" style:family="paragraph" style:parent-style-name="Caption" style:class="extra">
<style:paragraph-properties fo:text-align="center" style:justify-single-word="false"/>
</style:style>
<style:style style:name="Listing" style:family="paragraph" style:parent-style-name="Caption" style:class="extra">
<style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false" fo:keep-with-next="always">
<style:tab-stops/>
</style:paragraph-properties>
</style:style>
<style:style style:name="Horizontal_20_Line" style:display-name="Horizontal Line" style:family="paragraph" style:parent-style-name="Standard" style:next-style-name="Text_20_body" style:class="html">
<style:paragraph-properties fo:margin-top="0cm" fo:margin-bottom="0.499cm" style:border-line-width-bottom="0.002cm 0.035cm 0.002cm" fo:padding="0cm" fo:border-left="none" fo:border-right="none" fo:border-top="none" fo:border-bottom="0.039cm double #808080" text:number-lines="false" text:line-number="0" style:join-border="false"/>
<style:text-properties fo:font-size="6pt" style:font-size-asian="6pt" style:font-size-complex="6pt"/>

View File

@ -88,7 +88,9 @@ or `org-babel-execute:C++'."
(cond
((equal org-babel-c-variant 'c) ".c")
((equal org-babel-c-variant 'cpp) ".cpp"))))
(tmp-bin-file (org-babel-temp-file "C-bin-"))
(tmp-bin-file (org-babel-temp-file
"C-bin-"
(if (equal system-type 'windows-nt) ".exe" "")))
(cmdline (cdr (assoc :cmdline params)))
(flags (cdr (assoc :flags params)))
(full-body (org-babel-C-expand body params))
@ -150,7 +152,7 @@ it's header arguments."
"Wrap body in a \"main\" function call if none exists."
(if (string-match "^[ \t]*[intvod]+[ \t\n\r]*main[ \t]*(.*)" body)
body
(format "int main() {\n%s\n}\n" body)))
(format "int main() {\n%s\nreturn(0);\n}\n" body)))
(defun org-babel-prep-session:C (session params)
"This function does nothing as C is a compiled language with no

View File

@ -40,10 +40,31 @@
(declare-function ess-eval-buffer "ext:ess-inf" (vis))
(declare-function org-number-sequence "org-compat" (from &optional to inc))
(defconst org-babel-header-arg-names:R
'(width height bg units pointsize antialias quality compression
res type family title fonts version paper encoding
pagecentre colormodel useDingbats horizontal)
(defconst org-babel-header-args:R
'((width . :any)
(height . :any)
(bg . :any)
(units . :any)
(pointsize . :any)
(antialias . :any)
(quality . :any)
(compression . :any)
(res . :any)
(type . :any)
(family . :any)
(title . :any)
(fonts . :any)
(version . :any)
(paper . :any)
(encoding . :any)
(pagecentre . :any)
(colormodel . :any)
(useDingbats . :any)
(horizontal . :any)
(results . ((file list vector table scalar verbatim)
(raw org html latex code pp wrap)
(replace silent append prepend)
(output value graphics))))
"R-specific header arguments.")
(defvar org-babel-default-header-args:R '())

View File

@ -1,6 +1,6 @@
;;; ob-asymptote.el --- org-babel functions for asymptote evaluation
;; Copyright (C) 2009-2012 Free Software Foundation, Inc.
;; Copyright (C) 2009-2012 Free Software Foundation, Inc.
;; Author: Eric Schulte
;; Keywords: literate programming, reproducible research

View File

@ -45,7 +45,7 @@
(add-to-list 'org-babel-tangle-lang-exts '("clojure" . "clj"))
(defvar org-babel-default-header-args:clojure '())
(defvar org-babel-header-arg-names:clojure '(package))
(defvar org-babel-header-args:clojure '((package . :any)))
(defun org-babel-expand-body:clojure (body params)
"Expand BODY according to PARAMS, return the expanded body."

View File

@ -2,7 +2,7 @@
;; Copyright (C) 2009-2012 Free Software Foundation, Inc.
;; Author: Eric Schulte
;; Authors: Eric Schulte
;; Dan Davison
;; Keywords: literate programming, reproducible research
;; Homepage: http://orgmode.org
@ -113,15 +113,6 @@ none ----- do not display either code or results upon export"
(if (boundp lang-headers) (eval lang-headers) nil)
raw-params))))
(setf hash (org-babel-sha1-hash info)))
;; expand noweb references in the original file
(setf (nth 1 info)
(if (string= "strip-export" (cdr (assoc :noweb (nth 2 info))))
(replace-regexp-in-string
(org-babel-noweb-wrap) "" (nth 1 info))
(if (org-babel-noweb-p (nth 2 info) :export)
(org-babel-expand-noweb-references
info (org-babel-exp-get-export-buffer))
(nth 1 info))))
(org-babel-exp-do-export info 'block hash)))))
(defcustom org-babel-exp-call-line-template
@ -260,10 +251,20 @@ replaced with its value."
(defun org-babel-exp-code (info)
"Return the original code block formatted for export."
(setf (nth 1 info)
(if (string= "strip-export" (cdr (assoc :noweb (nth 2 info))))
(replace-regexp-in-string
(org-babel-noweb-wrap) "" (nth 1 info))
(if (org-babel-noweb-p (nth 2 info) :export)
(org-babel-expand-noweb-references
info (org-babel-exp-get-export-buffer))
(nth 1 info))))
(org-fill-template
org-babel-exp-code-template
`(("lang" . ,(nth 0 info))
("body" . ,(nth 1 info))
("body" . ,(if (string= (nth 0 info) "org")
(replace-regexp-in-string "^" "," (nth 1 info))
(nth 1 info)))
,@(mapcar (lambda (pair)
(cons (substring (symbol-name (car pair)) 1)
(format "%S" (cdr pair))))
@ -280,12 +281,16 @@ inhibit insertion of results into the buffer."
(when (and org-export-babel-evaluate
(not (and hash (equal hash (org-babel-current-result-hash)))))
(let ((lang (nth 0 info))
(body (nth 1 info))
(body (if (org-babel-noweb-p (nth 2 info) :eval)
(org-babel-expand-noweb-references
info (org-babel-exp-get-export-buffer))
(nth 1 info)))
(info (copy-sequence info)))
;; skip code blocks which we can't evaluate
(when (fboundp (intern (concat "org-babel-execute:" lang)))
(org-babel-eval-wipe-error-buffer)
(prog1 nil
(setf (nth 1 info) body)
(setf (nth 2 info)
(org-babel-exp-in-export-file lang
(org-babel-process-params

View File

@ -1,11 +1,11 @@
;;; ob-fortran.el --- org-babel functions for fortran
;; Copyright (C) 2011-2012 Sergey Litvinov, Eric Schulte
;; Copyright (C) 2011-2012 Free Software Foundation, Inc.
;; Authors: Sergey Litvinov (based on ob-C.el by Eric Schulte), Eric Schulte
;; Authors: Sergey Litvinov
;; Eric Schulte
;; Keywords: literate programming, reproducible research, fortran
;; Homepage: http://orgmode.org
;; Version: 7.8.02
;; 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

View File

@ -1,6 +1,6 @@
;;; ob-js.el --- org-babel functions for Javascript
;; Copyright (C) 2010-2012 Free Software Foundation, Inc.
;; Copyright (C) 2010-2012 Free Software Foundation, Inc.
;; Author: Eric Schulte
;; Keywords: literate programming, reproducible research, js

View File

@ -4,7 +4,7 @@
;; Author: Martyn Jago
;; Keywords: babel language, literate programming
;; Homepage: https://github.com/mjago/ob-lilypond
;; Homepage: http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-lilypond.html
;; This file is part of GNU Emacs.
@ -23,24 +23,26 @@
;;; Commentary:
;; Installation / usage info, and examples are available at
;; https://github.com/mjago/ob-lilypond
;; Installation, ob-lilypond documentation, and examples are available at
;; http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-lilypond.html
;;
;; Lilypond documentation can be found at
;; http://lilypond.org/manuals.html
;;; Code:
(require 'ob)
(require 'ob-eval)
(require 'ob-tangle)
(require 'outline)
(defalias 'lilypond-mode 'LilyPond-mode)
(declare-function show-all "outline" ())
(add-to-list 'org-babel-tangle-lang-exts '("LilyPond" . "ly"))
(defvar org-babel-default-header-args:lilypond '()
"Default header arguments for js code blocks.")
(defconst ly-version "0.3"
"The version number of the file ob-lilypond.el.")
"Default header arguments for lilypond code blocks.
NOTE: The arguments are determined at lilypond compile time.
See (ly-set-header-args)")
(defvar ly-compile-post-tangle t
"Following the org-babel-tangle (C-c C-v t) command,
@ -86,6 +88,10 @@ LY-GEN-SVG to t")
"HTML generation can be turned on by default by setting
LY-GEN-HTML to t")
(defvar ly-gen-pdf nil
"PDF generation can be turned on by default by setting
LY-GEN-PDF to t")
(defvar ly-use-eps nil
"You can force the compiler to use the EPS backend by setting
LY-USE-EPS to t")
@ -203,18 +209,20 @@ FILE-NAME is full path to lilypond (.ly) file"
(arg-2 nil) ;infile
(arg-3 "*lilypond*") ;buffer
(arg-4 t) ;display
(arg-5 (if ly-gen-png "--png" "")) ;&rest...
(arg-6 (if ly-gen-html "--html" ""))
(arg-7 (if ly-use-eps "-dbackend=eps" ""))
(arg-8 (if ly-gen-svg "-dbackend=svg" ""))
(arg-9 (concat "--output=" (file-name-sans-extension file-name)))
(arg-10 file-name))
(arg-4 t) ;display
(arg-5 (if ly-gen-png "--png" "")) ;&rest...
(arg-6 (if ly-gen-html "--html" ""))
(arg-7 (if ly-gen-pdf "--pdf" ""))
(arg-8 (if ly-use-eps "-dbackend=eps" ""))
(arg-9 (if ly-gen-svg "-dbackend=svg" ""))
(arg-10 (concat "--output=" (file-name-sans-extension file-name)))
(arg-11 file-name))
(if test
`(,arg-1 ,arg-2 ,arg-3 ,arg-4 ,arg-5
,arg-6 ,arg-7 ,arg-8 ,arg-9 ,arg-10)
`(,arg-1 ,arg-2 ,arg-3 ,arg-4 ,arg-5 ,arg-6
,arg-7 ,arg-8 ,arg-9 ,arg-10 ,arg-11)
(call-process
arg-1 arg-2 arg-3 arg-4 arg-5
arg-6 arg-7 arg-8 arg-9 arg-10))))
arg-1 arg-2 arg-3 arg-4 arg-5 arg-6
arg-7 arg-8 arg-9 arg-10 arg-11))))
(defun ly-check-for-compile-error (file-name &optional test)
"Check for compile error.
@ -307,8 +315,12 @@ If TEST is non-nil, the shell command is returned and is not run"
(concat (ly-determine-pdf-path) " " pdf-file)))
(if test
cmd-string
(shell-command cmd-string)))
(message "No pdf file generated so can't display!")))))
(start-process
"\"Audition pdf\""
"*lilypond*"
(ly-determine-pdf-path)
pdf-file)))
(message "No pdf file generated so can't display!")))))
(defun ly-attempt-to-play-midi (file-name &optional test)
"Attempt to play the generated MIDI file
@ -322,7 +334,11 @@ If TEST is non-nil, the shell command is returned and is not run"
(concat (ly-determine-midi-path) " " midi-file)))
(if test
cmd-string
(shell-command cmd-string)))
(start-process
"\"Audition midi\""
"*lilypond*"
(ly-determine-midi-path)
midi-file)))
(message "No midi file generated so can't play!")))))
(defun ly-determine-ly-path (&optional test)
@ -399,6 +415,15 @@ If TEST is non-nil, it contains a simulation of the OS for test purposes"
(message (concat "HTML generation has been "
(if ly-gen-html "ENABLED." "DISABLED."))))
(defun ly-toggle-pdf-generation ()
"Toggle whether pdf will be generated by compilation"
(interactive)
(setq ly-gen-pdf
(not ly-gen-pdf))
(message (concat "PDF generation has been "
(if ly-gen-pdf "ENABLED." "DISABLED."))))
(defun ly-toggle-arrange-mode ()
"Toggle whether in Arrange mode or Basic mode"
@ -408,13 +433,7 @@ If TEST is non-nil, it contains a simulation of the OS for test purposes"
(message (concat "Arrange mode has been "
(if ly-arrange-mode "ENABLED." "DISABLED."))))
(defun ly-version (&optional insert-at-point)
(interactive)
(let ((version (format "ob-lilypond version %s" ly-version)))
(when insert-at-point (insert version))
(message version)))
(defun ly-switch-extension (file-name ext)
(defun ly-switch-extension (file-name ext)
"Utility command to swap current FILE-NAME extension with EXT"
(concat (file-name-sans-extension
@ -428,6 +447,7 @@ mode i.e. ARRANGE-MODE is t"
'((:tangle . "yes")
(:noweb . "yes")
(:results . "silent")
(:cache . "yes")
(:comments . "yes")))
(t
'((:results . "file")
@ -441,6 +461,4 @@ dependent on LY-ARRANGE-MODE"
(provide 'ob-lilypond)
;;; ob-lilypond.el ends here

View File

@ -2,9 +2,9 @@
;; Copyright (C) 2009-2012 Free Software Foundation, Inc.
;; Author: Joel Boehland
;; Eric Schulte
;; David T. O'Toole <dto@gnu.org>
;; Authors: Joel Boehland
;; Eric Schulte
;; David T. O'Toole <dto@gnu.org>
;; Keywords: literate programming, reproducible research
;; Homepage: http://orgmode.org
@ -41,7 +41,7 @@
(add-to-list 'org-babel-tangle-lang-exts '("lisp" . "lisp"))
(defvar org-babel-default-header-args:lisp '())
(defvar org-babel-header-arg-names:lisp '(package))
(defvar org-babel-header-args:lisp '((package . :any)))
(defcustom org-babel-lisp-dir-fmt
"(let ((*default-pathname-defaults* #P%S)) %%s)"

View File

@ -2,8 +2,8 @@
;; Copyright (C) 2009-2012 Free Software Foundation, Inc.
;; Author: Eric Schulte
;; Dan Davison
;; Authors: Eric Schulte
;; Dan Davison
;; Keywords: literate programming, reproducible research
;; Homepage: http://orgmode.org
@ -109,8 +109,8 @@ if so then run the appropriate source block from the Library."
(list
(format "%s%s(%s)%s"
(nonempty 3 12)
(if (not (= 0 (length (nonempty 5 13))))
(concat "[" (nonempty 5 13) "]") "")
(if (not (= 0 (length (nonempty 5 14))))
(concat "[" (nonempty 5 14) "]") "")
(or (nonempty 7 16) "")
(or (nonempty 8 19) ""))
(nonempty 9 18)))

View File

@ -3,7 +3,7 @@
;; Copyright (C) 2009-2012 Free Software Foundation, Inc.
;; Author: Eric S Fraga
;; Eric Schulte
;; Eric Schulte
;; Keywords: literate programming, reproducible research, maxima
;; Homepage: http://orgmode.org
@ -40,6 +40,11 @@
(defvar org-babel-default-header-args:maxima '())
(defcustom org-babel-maxima-command
(if (boundp 'maxima-command) maxima-command "maxima")
"Command used to call maxima on the shell."
:group 'org-babel)
(defun org-babel-maxima-expand (body params)
"Expand a block of Maxima code according to its header arguments."
(let ((vars (mapcar #'cdr (org-babel-get-header params :var))))
@ -67,8 +72,8 @@ called by `org-babel-execute-src-block'."
(result
(let* ((cmdline (cdr (assoc :cmdline params)))
(in-file (org-babel-temp-file "maxima-" ".max"))
(cmd (format "maxima --very-quiet -r 'batchload(%S)$' %s"
in-file cmdline)))
(cmd (format "%s --very-quiet -r 'batchload(%S)$' %s"
org-babel-maxima-command in-file cmdline)))
(with-temp-file in-file (insert (org-babel-maxima-expand body params)))
(message cmd)
((lambda (raw) ;; " | grep -v batch | grep -v 'replaced' | sed '/^$/d' "

View File

@ -2,8 +2,8 @@
;; Copyright (C) 2009-2012 Free Software Foundation, Inc.
;; Author: Dan Davison
;; Eric Schulte
;; Authors: Dan Davison
;; Eric Schulte
;; Keywords: literate programming, reproducible research
;; Homepage: http://orgmode.org

View File

@ -3,7 +3,7 @@
;; Copyright (C) 2010-2012 Free Software Foundation, Inc.
;; Authors: Thorsten Jolitz
;; Eric Schulte
;; Eric Schulte
;; Keywords: literate programming, reproducible research
;; Homepage: http://orgmode.org

View File

@ -2,8 +2,8 @@
;; Copyright (C) 2009-2012 Free Software Foundation, Inc.
;; Author: Eric Schulte
;; Dan Davison
;; Authors: Eric Schulte
;; Dan Davison
;; Keywords: literate programming, reproducible research
;; Homepage: http://orgmode.org

View File

@ -2,8 +2,8 @@
;; Copyright (C) 2009-2012 Free Software Foundation, Inc.
;; Author: Eric Schulte
;; Dan Davison
;; Authors: Eric Schulte
;; Dan Davison
;; Keywords: literate programming, reproducible research
;; Homepage: http://orgmode.org

View File

@ -1,6 +1,6 @@
;;; ob-scheme.el --- org-babel functions for Scheme
;; Copyright (C) 2010-2012 Free Software Foundation, Inc.
;; Copyright (C) 2010-2012 Free Software Foundation, Inc.
;; Author: Eric Schulte
;; Keywords: literate programming, reproducible research, scheme

View File

@ -56,14 +56,13 @@ This will be passed to `shell-command-on-region'")
This function is called by `org-babel-execute-src-block'."
(let* ((session (org-babel-sh-initiate-session
(cdr (assoc :session params))))
(result-params (cdr (assoc :result-params params)))
(stdin ((lambda (stdin) (when stdin (org-babel-sh-var-to-string
(org-babel-ref-resolve stdin))))
(cdr (assoc :stdin params))))
(full-body (org-babel-expand-body:generic
body params (org-babel-variable-assignments:sh params))))
(org-babel-reassemble-table
(org-babel-sh-evaluate session full-body result-params stdin)
(org-babel-sh-evaluate session full-body params stdin)
(org-babel-pick-name
(cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
(org-babel-pick-name
@ -134,29 +133,38 @@ Emacs-lisp table, otherwise return the results as a string."
(defvar org-babel-sh-eoe-output "org_babel_sh_eoe"
"String to indicate that evaluation has completed.")
(defun org-babel-sh-evaluate (session body &optional result-params stdin)
(defun org-babel-sh-evaluate (session body &optional params stdin)
"Pass BODY to the Shell process in BUFFER.
If RESULT-TYPE equals 'output then return a list of the outputs
of the statements in BODY, if RESULT-TYPE equals 'value then
return the value of the last statement in BODY."
((lambda (results)
(when results
(if (or (member "scalar" result-params)
(member "verbatim" result-params)
(member "output" result-params))
results
(let ((tmp-file (org-babel-temp-file "sh-")))
(with-temp-file tmp-file (insert results))
(org-babel-import-elisp-from-file tmp-file)))))
(let ((result-params (cdr (assoc :result-params params))))
(if (or (member "scalar" result-params)
(member "verbatim" result-params)
(member "output" result-params))
results
(let ((tmp-file (org-babel-temp-file "sh-")))
(with-temp-file tmp-file (insert results))
(org-babel-import-elisp-from-file tmp-file))))))
(cond
(stdin ; external shell script w/STDIN
(let ((script-file (org-babel-temp-file "sh-script-"))
(stdin-file (org-babel-temp-file "sh-stdin-")))
(with-temp-file script-file (insert body))
(stdin-file (org-babel-temp-file "sh-stdin-"))
(shebang (cdr (assoc :shebang params)))
(padline (not (string= "no" (cdr (assoc :padline params))))))
(with-temp-file script-file
(when shebang (insert (concat shebang "\n")))
(when padline (insert "\n"))
(insert body))
(set-file-modes script-file #o755)
(with-temp-file stdin-file (insert stdin))
(with-temp-buffer
(call-process-shell-command
(format "%s %s" org-babel-sh-command script-file)
(if shebang
script-file
(format "%s %s" org-babel-sh-command script-file))
stdin-file
(current-buffer))
(buffer-string))))
@ -182,7 +190,17 @@ return the value of the last statement in BODY."
(list org-babel-sh-eoe-indicator))))
2)) "\n"))
('otherwise ; external shell script
(org-babel-eval org-babel-sh-command (org-babel-trim body))))))
(if (cdr (assoc :shebang params))
(let ((script-file (org-babel-temp-file "sh-script-"))
(shebang (cdr (assoc :shebang params)))
(padline (not (string= "no" (cdr (assoc :padline params))))))
(with-temp-file script-file
(when shebang (insert (concat shebang "\n")))
(when padline (insert "\n"))
(insert body))
(set-file-modes script-file #o755)
(org-babel-eval script-file ""))
(org-babel-eval org-babel-sh-command (org-babel-trim body)))))))
(defun org-babel-sh-strip-weird-long-prompt (string)
"Remove prompt cruft from a string of shell output."

View File

@ -51,8 +51,9 @@
(defvar org-babel-default-header-args:sql '())
(defvar org-babel-header-arg-names:sql
'(engine out-file))
(defvar org-babel-header-args:sql
'((engine . :any)
(out-file . :any)))
(defun org-babel-expand-body:sql (body params)
"Expand BODY according to the values of PARAMS."

View File

@ -37,8 +37,18 @@
(defvar org-babel-default-header-args:sqlite '())
(defvar org-babel-header-arg-names:sqlite
'(db header echo bail csv column html line list separator nullvalue)
(defvar org-babel-header-args:sqlite
'((db . :any)
(header . :any)
(echo . :any)
(bail . :any)
(csv . :any)
(column . :any)
(html . :any)
(line . :any)
(list . :any)
(separator . :any)
(nullvalue . :any))
"Sqlite specific header args.")
(defun org-babel-expand-body:sqlite (body params)

View File

@ -2,7 +2,7 @@
;; Copyright (C) 2009-2012 Free Software Foundation, Inc.
;; Author: Eric Schulte
;; Authors: Eric Schulte
;; Dan Davison
;; Keywords: literate programming, reproducible research
;; Homepage: http://orgmode.org
@ -59,6 +59,7 @@
(declare-function org-cycle "org" (&optional arg))
(declare-function org-uniquify "org" (list))
(declare-function org-current-level "org" ())
(declare-function org-strip-protective-commas "org" (beg end))
(declare-function org-table-import "org-table" (file arg))
(declare-function org-add-hook "org-compat"
(hook function &optional append local))
@ -81,6 +82,7 @@
(declare-function org-list-struct "org-list" ())
(declare-function org-list-prevs-alist "org-list" (struct))
(declare-function org-list-get-list-end "org-list" (item struct prevs))
(declare-function org-strip-protective-commas "org" (beg end))
(defgroup org-babel nil
"Code block evaluation and management in `org-mode' documents."
@ -398,6 +400,7 @@ then run `org-babel-pop-to-session'."
(eval . ((never query)))
(exports . ((code results both none)))
(file . :any)
(file-desc . :any)
(hlines . ((no yes)))
(mkdirp . ((yes no)))
(no-expand)
@ -619,6 +622,19 @@ arguments and pop open the results in a preview buffer."
(mmin (in (1- i) j) (in i (1- j)) (in (1- i) (1- j)))))))
(in l1 l2))))
(defun org-babel-combine-header-arg-lists (original &rest others)
"Combine a number of lists of header argument names and arguments."
(let ((results (copy-sequence original)))
(dolist (new-list others)
(dolist (arg-pair new-list)
(let ((header (car arg-pair))
(args (cdr arg-pair)))
(setq results
(cons arg-pair (org-remove-if
(lambda (pair) (equal header (car pair)))
results))))))
results))
;;;###autoload
(defun org-babel-check-src-block ()
"Check for misspelled header arguments in the current code block."
@ -646,12 +662,10 @@ arguments and pop open the results in a preview buffer."
"Insert a header argument selecting from lists of common args and values."
(interactive)
(let* ((lang (car (org-babel-get-src-block-info 'light)))
(lang-headers (intern (concat "org-babel-header-arg-names:" lang)))
(headers (append (if (boundp lang-headers)
(mapcar (lambda (h) (cons h :any))
(eval lang-headers))
nil)
org-babel-common-header-args-w-values))
(lang-headers (intern (concat "org-babel-header-args:" lang)))
(headers (org-babel-combine-header-arg-lists
org-babel-common-header-args-w-values
(if (boundp lang-headers) (eval lang-headers) nil)))
(arg (org-icompleting-read
"Header Arg: "
(mapcar
@ -676,6 +690,30 @@ arguments and pop open the results in a preview buffer."
"")))
vals ""))))))))
;; Add support for completing-read insertion of header arguments after ":"
(defun org-babel-header-arg-expand ()
"Call `org-babel-enter-header-arg-w-completion' in appropriate contexts."
(when (and (= (char-before) ?\:) (org-babel-where-is-src-block-head))
(org-babel-enter-header-arg-w-completion (match-string 2))))
(defun org-babel-enter-header-arg-w-completion (&optional lang)
"Insert header argument appropriate for LANG with completion."
(let* ((lang-headers-var (intern (concat "org-babel-header-args:" lang)))
(lang-headers (when (boundp lang-headers-var) (eval lang-headers-var)))
(headers-w-values (org-babel-combine-header-arg-lists
org-babel-common-header-args-w-values lang-headers))
(headers (mapcar #'symbol-name (mapcar #'car headers-w-values)))
(header (org-completing-read "Header Arg: " headers))
(args (cdr (assoc (intern header) headers-w-values)))
(arg (when (and args (listp args))
(org-completing-read
(format "%s: " header)
(mapcar #'symbol-name (apply #'append args))))))
(insert (concat header " " (or arg "")))
(cons header arg)))
(add-hook 'org-tab-first-hook 'org-babel-header-arg-expand)
;;;###autoload
(defun org-babel-load-in-session (&optional arg info)
"Load the body of the current source-code block.
@ -1150,13 +1188,14 @@ may be specified in the properties of the current outline entry."
(cons (intern (concat ":" header-arg))
(org-babel-read val))))
(mapcar
'symbol-name
(append
org-babel-header-arg-names
(progn
(setq sym (intern (concat "org-babel-header-arg-names:"
lang)))
(and (boundp sym) (eval sym)))))))))))
#'symbol-name
(mapcar
#'car
(org-babel-combine-header-arg-lists
org-babel-common-header-args-w-values
(progn
(setq sym (intern (concat "org-babel-header-args:" lang)))
(and (boundp sym) (eval sym))))))))))))
(defvar org-src-preserve-indentation)
(defun org-babel-parse-src-block-match ()
@ -1178,7 +1217,7 @@ may be specified in the properties of the current outline entry."
;; get block body less properties, protective commas, and indentation
(with-temp-buffer
(save-match-data
(insert (org-babel-strip-protective-commas body))
(insert (org-babel-strip-protective-commas body lang))
(unless preserve-indentation (org-do-remove-indentation))
(buffer-string)))
(org-babel-merge-params
@ -1196,7 +1235,7 @@ may be specified in the properties of the current outline entry."
(lang-headers (intern (concat "org-babel-default-header-args:" lang))))
(list lang
(org-babel-strip-protective-commas
(org-babel-clean-text-properties (match-string 5)))
(org-babel-clean-text-properties (match-string 5)) lang)
(org-babel-merge-params
org-babel-default-inline-header-args
(org-babel-params-from-properties lang)
@ -1650,7 +1689,7 @@ following the source block."
(inlinep (when (org-babel-get-inline-src-block-matches)
(match-end 0)))
(name (if on-lob-line
(nth 0 (org-babel-lob-get-info))
(mapconcat #'identity (butlast (org-babel-lob-get-info)) "")
(nth 4 (or info (org-babel-get-src-block-info 'light)))))
(head (unless on-lob-line (org-babel-where-is-src-block-head)))
found beg end)
@ -1831,7 +1870,10 @@ code ---- the results are extracted in the syntax of the source
(progn
(setq result (org-babel-clean-text-properties result))
(when (member "file" result-params)
(setq result (org-babel-result-to-file result))))
(setq result (org-babel-result-to-file
result (when (assoc :file-desc (nth 2 info))
(or (cdr (assoc :file-desc (nth 2 info)))
result))))))
(unless (listp result) (setq result (format "%S" result))))
(if (and result-params (member "silent" result-params))
(progn
@ -1874,8 +1916,9 @@ code ---- the results are extracted in the syntax of the source
(setq results-switches
(if results-switches (concat " " results-switches) ""))
(flet ((wrap (start finish)
(goto-char beg) (insert (concat start "\n"))
(goto-char end) (insert (concat finish "\n"))
(goto-char beg) (insert (concat start "\n"))
(goto-char end) (goto-char (point-at-eol))
(setq end (point-marker)))
(proper-list-p (it) (and (listp it) (null (cdr (last it))))))
;; insert results based on type
@ -1976,23 +2019,20 @@ code ---- the results are extracted in the syntax of the source
(forward-line 1))))
(point)))))
(defun org-babel-result-to-file (result)
"Convert RESULT into an `org-mode' link.
(defun org-babel-result-to-file (result &optional description)
"Convert RESULT into an `org-mode' link with optional DESCRIPTION.
If the `default-directory' is different from the containing
file's directory then expand relative links."
(flet ((cond-exp (file)
(if (and default-directory
buffer-file-name
(not (string= (expand-file-name default-directory)
(expand-file-name
(file-name-directory buffer-file-name)))))
(expand-file-name file default-directory)
file)))
(if (stringp result)
(format "[[file:%s]]" (cond-exp result))
(when (and (listp result) (= 2 (length result))
(stringp (car result)) (stringp (cadr result)))
(format "[[file:%s][%s]]" (car result) (cadr result))))))
(when (stringp result)
(format "[[file:%s]%s]"
(if (and default-directory
buffer-file-name
(not (string= (expand-file-name default-directory)
(expand-file-name
(file-name-directory buffer-file-name)))))
(expand-file-name result default-directory)
result)
(if description (concat "[" description "]") ""))))
(defun org-babel-examplize-region (beg end &optional results-switches)
"Comment out region using the inline '==' or ': ' org example quote."
@ -2115,7 +2155,8 @@ parameters when merging lists."
(setq tangle (or (list (cdr pair)) tangle)))
(:noweb
(setq noweb (e-merge
'(("yes" "no" "tangle" "no-export" "strip-export"))
'(("yes" "no" "tangle" "no-export"
"strip-export" "eval"))
noweb
(split-string (or (cdr pair) "")))))
(:cache
@ -2159,7 +2200,7 @@ CONTEXT may be one of :tangle, :export or :eval."
(intersect (cdr as) bs)))))
(intersect (case context
(:tangle '("yes" "tangle" "no-export" "strip-export"))
(:eval '("yes" "no-export" "strip-export"))
(:eval '("yes" "no-export" "strip-export" "eval"))
(:export '("yes")))
(split-string (or (cdr (assoc :noweb params)) "")))))
@ -2242,7 +2283,7 @@ block but are passed literally to the \"example-block\"."
(when (org-babel-ref-goto-headline-id source-name)
(org-babel-ref-headline-body)))
;; find the expansion of reference in this buffer
(let ((rx (concat rx-prefix source-name))
(let ((rx (concat rx-prefix source-name "[ \t\n]"))
expansion)
(save-excursion
(goto-char (point-min))
@ -2295,11 +2336,15 @@ block but are passed literally to the \"example-block\"."
(when text
(set-text-properties 0 (length text) nil text) text))
(defun org-babel-strip-protective-commas (body)
(defun org-babel-strip-protective-commas (body &optional lang)
"Strip protective commas from bodies of source blocks."
(with-temp-buffer
(insert body)
(org-strip-protective-commas (point-min) (point-max))
(if (and lang (string= lang "org"))
(progn (goto-char (point-min))
(while (re-search-forward "^[ \t]*\\(,\\)" nil t)
(replace-match "" nil nil nil 1)))
(org-strip-protective-commas (point-min) (point-max)))
(buffer-string)))
(defun org-babel-script-escape (str &optional force)

View File

@ -306,11 +306,13 @@ you can \"misuse\" it to also add other text to the header. However,
(string :tag "+tag or -tag"))))
(list :tag "Set daily/weekly entry types"
(const org-agenda-entry-types)
(set :greedy t :value (:deadline :scheduled :timestamp :sexp)
(const :deadline)
(const :scheduled)
(const :timestamp)
(const :sexp)))
(list
(const :format "" quote)
(set :greedy t :value (:deadline :scheduled :timestamp :sexp)
(const :deadline)
(const :scheduled)
(const :timestamp)
(const :sexp))))
(list :tag "Standard skipping condition"
:value (org-agenda-skip-function '(org-agenda-skip-entry-if))
(const org-agenda-skip-function)
@ -1805,12 +1807,12 @@ works you probably want to add it to `org-agenda-custom-commands' for good."
(defvar org-agenda-entry-text-mode nil)
(defvar org-agenda-clockreport-mode nil)
(defvar org-agenda-show-log nil)
(defvar org-agenda-show-scoped nil) ; Used for dynamically scoping
(defvar org-agenda-redo-command nil)
(defvar org-agenda-query-string nil)
(defvar org-agenda-mode-hook nil
"Hook for `org-agenda-mode', run after the mode is turned on.")
(defvar org-agenda-type nil)
(defvar org-agenda-force-single-file nil)
(defvar org-agenda-bulk-marked-entries) ;; Defined further down in this file
@ -2684,7 +2686,7 @@ s Search for keywords * Toggle sticky agenda views
"The arguments of the previous call to `org-agenda'.")
(defun org-agenda-run-series (name series)
(org-let (nth 1 series) '(org-prepare-agenda name))
;; We need to reset agenda markers heree, because when constructing a
;; We need to reset agenda markers here, because when constructing a
;; block agenda, the individual blocks do not do that.
(org-agenda-reset-markers)
(let* ((org-agenda-multi t)
@ -2808,7 +2810,7 @@ agenda-day The day in the agenda where this is listed"
(defun org-fix-agenda-info (props)
"Make sure all properties on an agenda item have a canonical form.
This ensures the export commands can easily use it."
This ensures the export commands can easily use it."
(let (tmp re)
(when (setq tmp (plist-get props 'tags))
(setq props (plist-put props 'tags (mapconcat 'identity tmp ":"))))
@ -2845,8 +2847,8 @@ agenda-day The day in the agenda where this is listed"
((stringp res) res)
(t (prin1-to-string res))))
(while (string-match "," res)
(setq res (replace-match ";" t t res))) ;
(org-trim res)))
(setq res (replace-match ";" t t res)))
(org-trim res)))
;;;###autoload
@ -3176,7 +3178,7 @@ removed from the entry content. Currently only `planning' is allowed here."
(defvar org-agenda-name nil)
(defvar org-agenda-tag-filter nil)
(defvar org-agenda-category-filter nil)
(defvar org-agenda-tag-filter-while-redo nil) ; dynamically scoped
(defvar org-agenda-tag-filter-while-redo nil)
(defvar org-agenda-tag-filter-preset nil
"A preset of the tags filter used for secondary agenda filtering.
This must be a list of strings, each string must be a single tag preceded
@ -3250,7 +3252,6 @@ generating a new one"
(message "Sticky Agenda buffer, use `r' to refresh")
(throw 'exit nil))
(setq org-todo-keywords-for-agenda nil)
(setq org-done-keywords-for-agenda nil)
(setq org-drawers-for-agenda nil)
(unless org-agenda-persistent-filter
(setq org-agenda-tag-filter nil
@ -3270,9 +3271,10 @@ generating a new one"
(make-string (window-width) org-agenda-block-separator))
"\n"))
(narrow-to-region (point) (point-max)))
(setq org-done-keywords-for-agenda nil)
;; any org variables need to be set after being in agenda buffer
;; since they are now buffer local
;; Setting any org variables that are in org-agenda-local-vars
;; list need to be done after the prepare call
(org-prepare-agenda-window (get-buffer-create org-agenda-buffer-name))
(setq buffer-read-only nil)
(org-agenda-reset-markers)
@ -4393,7 +4395,7 @@ See `org-agenda-skip-if' for details."
(defun org-agenda-skip-if (subtree conditions)
"Checks current entity for CONDITIONS.
If SUBTREE is non-nil, the entire subtree is checked. Otherwise, only
the entry, i.e. the text before the next heading is checked.
the entry (i.e. the text before the next heading) is checked.
CONDITIONS is a list of symbols, boolean OR is used to combine the results
from different tests. Valid conditions are:
@ -4419,12 +4421,12 @@ keywords, which may include \"*\" to match any todo keyword.
would skip all entries with \"TODO\" or \"WAITING\" keywords.
Instead of a list a keyword class may be given
Instead of a list, a keyword class may be given. For example:
(org-agenda-skip-entry-if 'nottodo 'done)
would skip entries that haven't been marked with any of \"DONE\"
keywords. Possible classes are: `todo', `done', `any'.
keywords. Possible classes are: `todo', `done', `any'.
If any of these conditions is met, this function returns the end point of
the entity, causing the search to continue from there. This is a function
@ -4457,8 +4459,8 @@ that can be put into `org-agenda-skip-function' for the duration of a command."
(stringp (nth 1 m))
(not (re-search-forward (nth 1 m) end t)))
(and (or
(setq m (memq 'todo conditions))
(setq m (memq 'nottodo conditions)))
(setq m (memq 'nottodo conditions))
(setq m (memq 'todo conditions)))
(org-agenda-skip-if-todo m end)))
end)))
@ -6418,8 +6420,8 @@ When this is the global TODO list, a prefix argument will be interpreted."
(recenter window-line)))
(defvar org-global-tags-completion-table nil)
(defvar org-agenda-filtered-by-category nil)
(defvar org-agenda-filter-form nil)
(defvar org-agenda-filtered-by-category nil)
(defun org-agenda-filter-by-category (strip)
"Keep only those lines in the agenda buffer that have a specific category.
@ -6572,7 +6574,9 @@ to switch to narrowing."
(dolist (x (delete-dups
(append (get 'org-agenda-category-filter
:preset-filter) org-agenda-category-filter)))
(setq f1 (list 'equal (substring x 1) 'cat))
(if (equal "-" (substring x 0 1))
(setq f1 (list 'not (list 'equal (substring x 1) 'cat)))
(setq f1 (list 'equal (substring x 1) 'cat)))
(push f1 f))
(cons 'and (nreverse f))))
@ -6603,9 +6607,13 @@ If the line does not have an effort defined, return nil."
(let (tags cat)
(if (eq type 'tag)
(setq org-agenda-tag-filter filter)
(setq org-agenda-category-filter filter
org-agenda-filtered-by-category t))
(setq org-agenda-category-filter filter))
(setq org-agenda-filter-form (org-agenda-filter-make-matcher))
(if (and (eq type 'category)
(not (equal (substring (car filter) 0 1) "-")))
;; Only set `org-agenda-filtered-by-category' to t
;; when a unique category is used as the filter
(setq org-agenda-filtered-by-category t))
(org-agenda-set-mode-name)
(save-excursion
(goto-char (point-min))
@ -6619,7 +6627,7 @@ If the line does not have an effort defined, return nil."
(beginning-of-line 2))
(beginning-of-line 2))))
(if (get-char-property (point) 'invisible)
(org-agenda-previous-line))))
(ignore-errors (org-agenda-previous-line)))))
(defun org-agenda-filter-hide-line (type)
(let (ov)
@ -7521,7 +7529,9 @@ use the dedicated frame)."
(if (and current-prefix-arg (listp current-prefix-arg))
(org-agenda-do-tree-to-indirect-buffer)
(let ((agenda-window (selected-window))
(indirect-window (and org-last-indirect-buffer (get-buffer-window org-last-indirect-buffer))))
(indirect-window
(and org-last-indirect-buffer
(get-buffer-window org-last-indirect-buffer))))
(save-window-excursion (org-agenda-do-tree-to-indirect-buffer))
(unwind-protect
(progn
@ -7530,7 +7540,7 @@ use the dedicated frame)."
(select-window indirect-window)
(switch-to-buffer org-last-indirect-buffer :norecord)
(fit-window-to-buffer indirect-window))
(select-window agenda-window)))))
(select-window (get-buffer-window org-agenda-buffer-name))))))
(defun org-agenda-do-tree-to-indirect-buffer ()
"Same as `org-agenda-tree-to-indirect-buffer' without saving window."

View File

@ -1,6 +1,6 @@
;;; org-ascii.el --- ASCII export for Org-mode
;; Copyright (C) 2004-2012 Free Software Foundation, Inc.
;; Copyright (C) 2004-2012 Free Software Foundation, Inc.
;; Author: Carsten Dominik <carsten at orgmode dot org>
;; Keywords: outlines, hypermedia, calendar, wp
@ -36,7 +36,7 @@
:tag "Org Export ASCII"
:group 'org-export)
(defcustom org-export-ascii-underline '(?\- ?\= ?\~ ?^ ?\# ?\$)
(defcustom org-export-ascii-underline '(?\= ?\- ?\~ ?\^ ?\. ?\# ?\$)
"Characters for underlining headings in ASCII export.
In the given sequence, these characters will be used for level 1, 2, ..."
:group 'org-export-ascii
@ -438,7 +438,9 @@ publishing directory."
link (concat (match-string 1 line) path)
type (match-string 2 line)
desc0 (match-string 5 line)
desc (or desc0 link))
desc0 (replace-regexp-in-string "\\\\_" "_" desc0)
desc (or desc0 link)
desc (replace-regexp-in-string "\\\\_" "_" desc))
(if (and (> (length link) 8)
(equal (substring link 0 8) "coderef:"))
(setq line (replace-match

View File

@ -1,6 +1,6 @@
;;; org-attach.el --- Manage file attachments to org-mode tasks
;; Copyright (C) 2008-2012 Free Software Foundation, Inc.
;; Copyright (C) 2008-2012 Free Software Foundation, Inc.
;; Author: John Wiegley <johnw@newartisans.com>
;; Keywords: org data task
@ -78,12 +78,15 @@ Allowed values are:
mv rename the file to move it into the attachment directory
cp copy the file
ln create a hard link. Note that this is not supported
on all systems, and then the result is not defined.
lns create a symbol link. Note that this is not supported
on all systems, and then the result is not defined."
:group 'org-attach
:type '(choice
(const :tag "Copy" cp)
(const :tag "Move/Rename" mv)
(const :tag "Link" ln)))
(const :tag "Hard Link" ln)
(const :tag "Symbol Link" lns)))
(defcustom org-attach-expert nil
"Non-nil means do not show the splash buffer with the attach dispatcher."
@ -105,7 +108,7 @@ ln create a hard link. Note that this is not supported
:type '(choice
(const :tag "Don't store link" nil)
(const :tag "Link to origin location" t)
(const :tag "Link to the attach-dir location" 'attached)))
(const :tag "Link to the attach-dir location" attached)))
;;;###autoload
(defun org-attach ()
@ -130,7 +133,7 @@ Shows a list of commands and prompts for another key to execute a command."
(princ "Select an Attachment Command:
a Select a file and attach it to the task, using `org-attach-method'.
c/m/l Attach a file using copy/move/link method.
c/m/l/y Attach a file using copy/move/link/symbolic-link method.
n Create a new attachment, as an Emacs buffer.
z Synchronize the current task with its attachment
directory, in case you added attachments yourself.
@ -158,6 +161,8 @@ i Make children of the current entry inherit its attachment directory.")))
(let ((org-attach-method 'mv)) (call-interactively 'org-attach-attach)))
((memq c '(?l ?\C-l))
(let ((org-attach-method 'ln)) (call-interactively 'org-attach-attach)))
((memq c '(?y ?\C-y))
(let ((org-attach-method 'lns)) (call-interactively 'org-attach-attach)))
((memq c '(?n ?\C-n)) (call-interactively 'org-attach-new))
((memq c '(?z ?\C-z)) (call-interactively 'org-attach-sync))
((memq c '(?o ?\C-o)) (call-interactively 'org-attach-open))
@ -282,7 +287,8 @@ Only do this when `org-attach-store-link-p' is non-nil."
(defun org-attach-attach (file &optional visit-dir method)
"Move/copy/link FILE into the attachment directory of the current task.
If VISIT-DIR is non-nil, visit the directory with dired.
METHOD may be `cp', `mv', or `ln', default taken from `org-attach-method'."
METHOD may be `cp', `mv', `ln', or `lns' default taken from
`org-attach-method'."
(interactive "fFile to keep as an attachment: \nP")
(setq method (or method org-attach-method))
(let ((basename (file-name-nondirectory file)))
@ -294,7 +300,8 @@ METHOD may be `cp', `mv', or `ln', default taken from `org-attach-method'."
(cond
((eq method 'mv) (rename-file file fname))
((eq method 'cp) (copy-file file fname))
((eq method 'ln) (add-name-to-file file fname)))
((eq method 'ln) (add-name-to-file file fname))
((eq method 'lns) (make-symbolic-link file fname)))
(org-attach-commit)
(org-attach-tag)
(cond ((eq org-attach-store-link-p 'attached)
@ -319,6 +326,13 @@ Beware that this does not work on systems that do not support hard links.
On some systems, this apparently does copy the file instead."
(interactive)
(let ((org-attach-method 'ln)) (call-interactively 'org-attach-attach)))
(defun org-attach-attach-lns ()
"Attach a file by creating a symbolic link to it.
Beware that this does not work on systems that do not support symbolic links.
On some systems, this apparently does copy the file instead."
(interactive)
(let ((org-attach-method 'lns)) (call-interactively 'org-attach-attach)))
(defun org-attach-new (file)
"Create a new attachment FILE for the current task.

View File

@ -1,9 +1,9 @@
;;; org-bbdb.el --- Support for links to BBDB entries from within Org-mode
;; Copyright (C) 2004-2012 Free Software Foundation, Inc.
;; Copyright (C) 2004-2012 Free Software Foundation, Inc.
;; Author: Carsten Dominik <carsten at orgmode dot org>,
;; Thomas Baumann <thomas dot baumann at ch dot tum dot de>
;; Authors: Carsten Dominik <carsten at orgmode dot org>
;; Thomas Baumann <thomas dot baumann at ch dot tum dot de>
;; Keywords: outlines, hypermedia, calendar, wp
;; Homepage: http://orgmode.org
;;
@ -273,7 +273,7 @@ italicized, in all other cases it is left unchanged."
"Convert YYYY-MM-DD to (month date year).
Argument TIME-STR is the value retrieved from BBDB. If YYYY- is omitted
it will be considered unknown."
(multiple-value-bind (a b c) (values-list (bbdb-split time-str "-"))
(multiple-value-bind (a b c) (values-list (org-split-string time-str "-"))
(if (eq c nil)
(list (string-to-number a)
(string-to-number b)
@ -300,13 +300,19 @@ The hash table is created on first use.")
(defun org-bbdb-make-anniv-hash ()
"Create a hash with anniversaries extracted from BBDB, for fast access.
The anniversaries are assumed to be stored `org-bbdb-anniversary-field'."
(let (split tmp annivs)
(let ((old-bbdb (fboundp 'bbdb-record-getprop))
split tmp annivs)
(clrhash org-bbdb-anniv-hash)
(dolist (rec (bbdb-records))
(when (setq annivs (bbdb-record-getprop
rec org-bbdb-anniversary-field))
(setq annivs (bbdb-split annivs "\n"))
(when (setq annivs (if old-bbdb
(bbdb-record-getprop
rec org-bbdb-anniversary-field)
(bbdb-record-note
rec org-bbdb-anniversary-field)))
(setq annivs (if old-bbdb
(bbdb-split annivs "\n")
;; parameter order is reversed in new bbdb
(bbdb-split "\n" annivs)))
(while annivs
(setq split (org-bbdb-anniv-split (pop annivs)))
(multiple-value-bind (m d y)

View File

@ -1,6 +1,6 @@
;;; org-beamer.el --- Beamer-specific LaTeX export for org-mode
;;
;; Copyright (C) 2007-2012 Free Software Foundation, Inc.
;; Copyright (C) 2007-2012 Free Software Foundation, Inc.
;;
;; Author: Carsten Dominik <carsten.dominik AT gmail DOT com>
;; Maintainer: Carsten Dominik <carsten.dominik AT gmail DOT com>
@ -242,7 +242,7 @@ in org-export-latex-classes."
(envs (append org-beamer-environments-extra
org-beamer-environments-default))
(props (org-get-text-property-any 0 'org-props text))
(in "") (out "") option action defaction environment extra
(in "") (out "") org-beamer-option org-beamer-action org-beamer-defaction org-beamer-environment org-beamer-extra
columns-option column-option
env have-text ass tmp)
(if (= frame-level 0) (setq frame-level nil))
@ -273,10 +273,10 @@ in org-export-latex-classes."
(setq in (org-fill-template
"\\begin{frame}%a%A%o%T%S%x"
(list (cons "a" (or action ""))
(cons "A" (or defaction ""))
(cons "o" (or option org-beamer-frame-default-options ""))
(cons "x" (if extra (concat "\n" extra) ""))
(list (cons "a" (or org-beamer-action ""))
(cons "A" (or org-beamer-defaction ""))
(cons "o" (or org-beamer-option org-beamer-frame-default-options ""))
(cons "x" (if org-beamer-extra (concat "\n" org-beamer-extra) ""))
(cons "h" "%s")
(cons "T" (if (string-match "\\S-" text)
"\n\\frametitle{%s}" ""))
@ -301,10 +301,10 @@ in org-export-latex-classes."
(setq have-text (string-match "\\S-" text))
(setq in (org-fill-template
(nth 2 ass)
(list (cons "a" (or action ""))
(cons "A" (or defaction ""))
(cons "o" (or option ""))
(cons "x" (if extra (concat "\n" extra) ""))
(list (cons "a" (or org-beamer-action ""))
(cons "A" (or org-beamer-defaction ""))
(cons "o" (or org-beamer-option ""))
(cons "x" (if org-beamer-extra (concat "\n" org-beamer-extra) ""))
(cons "h" "%s")
(cons "H" (if have-text (concat "{" text "}") ""))
(cons "U" (if have-text (concat "[" text "]") ""))))
@ -328,31 +328,31 @@ in org-export-latex-classes."
(cons text (cdr (assoc level default))))
(t nil))))
(defvar extra)
(defvar option)
(defvar action)
(defvar defaction)
(defvar environment)
(defvar org-beamer-extra)
(defvar org-beamer-option)
(defvar org-beamer-action)
(defvar org-beamer-defaction)
(defvar org-beamer-environment)
(defun org-beamer-get-special (props)
"Extract an option, action, and default action string from text.
The variables option, action, defaction, extra are all scoped into
this function dynamically."
The variables org-beamer-option, org-beamer-action, org-beamer-defaction,
org-beamer-extra are all scoped into this function dynamically."
(let (tmp)
(setq environment (org-beamer-assoc-not-empty "BEAMER_env" props))
(setq extra (org-beamer-assoc-not-empty "BEAMER_extra" props))
(when extra
(setq extra (replace-regexp-in-string "\\\\n" "\n" extra)))
(setq org-beamer-environment (org-beamer-assoc-not-empty "BEAMER_env" props))
(setq org-beamer-extra (org-beamer-assoc-not-empty "BEAMER_extra" props))
(when org-beamer-extra
(setq org-beamer-extra (replace-regexp-in-string "\\\\n" "\n" org-beamer-extra)))
(setq tmp (org-beamer-assoc-not-empty "BEAMER_envargs" props))
(when tmp
(setq tmp (copy-sequence tmp))
(if (string-match "\\[<[^][<>]*>\\]" tmp)
(setq defaction (match-string 0 tmp)
(setq org-beamer-defaction (match-string 0 tmp)
tmp (replace-match "" t t tmp)))
(if (string-match "\\[[^][]*\\]" tmp)
(setq option (match-string 0 tmp)
(setq org-beamer-option (match-string 0 tmp)
tmp (replace-match "" t t tmp)))
(if (string-match "<[^<>]*>" tmp)
(setq action (match-string 0 tmp)
(setq org-beamer-action (match-string 0 tmp)
tmp (replace-match "" t t tmp))))))
(defun org-beamer-assoc-not-empty (elt list)
@ -589,7 +589,7 @@ include square brackets."
(add-hook 'org-export-preprocess-before-selecting-backend-code-hook
'org-beamer-select-beamer-code)
(defun org-insert-beamer-options-template (kind)
(defun org-insert-beamer-options-template (&optional kind)
"Insert a settings template, to make sure users do this right."
(interactive (progn
(message "Current [s]ubtree or [g]lobal?")

View File

@ -1,10 +1,10 @@
;;; org-bibtex.el --- Org links to BibTeX entries
;;
;; Copyright (C) 2007-2012 Free Software Foundation, Inc.
;; Copyright (C) 2007-2012 Free Software Foundation, Inc.
;;
;; Author: Bastien Guerry <bzg at altern dot org>
;; Carsten Dominik <carsten dot dominik at gmail dot com>
;; Eric Schulte <schulte dot eric at gmail dot com>
;; Authors: Bastien Guerry <bzg at altern dot org>
;; Carsten Dominik <carsten dot dominik at gmail dot com>
;; Eric Schulte <schulte dot eric at gmail dot com>
;; Keywords: org, wp, remember
;;
;; This file is part of GNU Emacs.
@ -112,7 +112,7 @@
(eval-when-compile
(require 'cl))
(defvar description nil) ; dynamically scoped from org.el
(defvar org-bibtex-description nil) ; dynamically scoped from org.el
(defvar org-id-locations)
(declare-function bibtex-beginning-of-entry "bibtex" ())
@ -476,7 +476,7 @@ With optional argument OPTIONAL, also prompt for optional fields."
:btype (or (cdr (assoc "=type=" entry)) "[no type]")
:type "bibtex"
:link link
:description description))))
:description org-bibtex-description))))
(defun org-create-file-search-in-bibtex ()
"Create the search string and description for a BibTeX database entry."
@ -494,7 +494,7 @@ With optional argument OPTIONAL, also prompt for optional fields."
(bibtex-autokey-titleword-case-convert-function 'identity)
(bibtex-autokey-titleword-length 'infty)
(bibtex-autokey-year-title-separator ": "))
(setq description (bibtex-generate-autokey)))
(setq org-bibtex-description (bibtex-generate-autokey)))
;; Now parse the entry, get the key and return it.
(save-excursion
(bibtex-beginning-of-entry)

View File

@ -1,6 +1,6 @@
;;; org-capture.el --- Fast note taking in Org-mode
;; Copyright (C) 2010-2012 Free Software Foundation, Inc.
;; Copyright (C) 2010-2012 Free Software Foundation, Inc.
;; Author: Carsten Dominik <carsten at orgmode dot org>
;; Keywords: outlines, hypermedia, calendar, wp

View File

@ -1,6 +1,6 @@
;;; org-clock.el --- The time clocking code for Org-mode
;; Copyright (C) 2004-2012 Free Software Foundation, Inc.
;; Copyright (C) 2004-2012 Free Software Foundation, Inc.
;; Author: Carsten Dominik <carsten at orgmode dot org>
;; Keywords: outlines, hypermedia, calendar, wp
@ -219,7 +219,8 @@ auto Automatically, either `all', or `repeat' for repeating tasks"
(const :tag "All task time" all)
(const :tag "Automatically, `all' or since `repeat'" auto)))
(defcustom org-task-overrun-text nil
(defvaralias 'org-task-overrun-text 'org-clock-task-overrun-text)
(defcustom org-clock-task-overrun-text nil
"The extra modeline text that should indicate that the clock is overrun.
The can be nil to indicate that instead of adding text, the clock time
should get a different face (`org-mode-line-clock-overrun').
@ -323,6 +324,12 @@ play with them."
:version "24.1"
:type 'boolean)
(defcustom org-clock-total-time-cell-format "*%s*"
"Format string for the total time cells."
:group 'org-clock
:version "24.1"
:type 'boolean)
(defvar org-clock-in-prepare-hook nil
"Hook run when preparing the clock.
This hook is run before anything happens to the task that
@ -495,7 +502,7 @@ pointing to it."
(insert (format "[%c] %-15s %s\n" i cat task))
(cons i marker)))))
(defvar org-task-overrun nil
(defvar org-clock-task-overrun nil
"Internal flag indicating if the clock has overrun the planned time.")
(defvar org-clock-update-period 60
"Number of seconds between mode line clock string updates.")
@ -516,7 +523,7 @@ If not, show simply the clocked time like 01:50."
(work-done-str
(org-propertize
(format org-time-clocksum-format h m)
'face (if (and org-task-overrun (not org-task-overrun-text))
'face (if (and org-clock-task-overrun (not org-clock-task-overrun-text))
'org-mode-line-clock-overrun 'org-mode-line-clock)))
(effort-str (format org-time-clocksum-format effort-h effort-m))
(clockstr (org-propertize
@ -532,7 +539,7 @@ If not, show simply the clocked time like 01:50."
(defun org-clock-update-mode-line ()
(if org-clock-effort
(org-clock-notify-once-if-expired)
(setq org-task-overrun nil))
(setq org-clock-task-overrun nil))
(setq org-mode-line-string
(org-propertize
(let ((clock-string (org-clock-get-clock-string))
@ -546,10 +553,10 @@ If not, show simply the clocked time like 01:50."
'local-map org-clock-mode-line-map
'mouse-face (if (featurep 'xemacs) 'highlight 'mode-line-highlight)
))
(if (and org-task-overrun org-task-overrun-text)
(if (and org-clock-task-overrun org-clock-task-overrun-text)
(setq org-mode-line-string
(concat (org-propertize
org-task-overrun-text
org-clock-task-overrun-text
'face 'org-mode-line-clock-overrun) org-mode-line-string)))
(force-mode-line-update))
@ -606,7 +613,7 @@ Notification is shown only once."
(when (org-clocking-p)
(let ((effort-in-minutes (org-duration-string-to-minutes org-clock-effort))
(clocked-time (org-clock-get-clocked-time)))
(if (setq org-task-overrun
(if (setq org-clock-task-overrun
(if (or (null effort-in-minutes) (zerop effort-in-minutes))
nil
(>= clocked-time effort-in-minutes)))
@ -631,8 +638,7 @@ use libnotify if available, or fall back on a message."
((stringp org-show-notification-handler)
(start-process "emacs-timer-notification" nil
org-show-notification-handler notification))
((featurep 'notifications)
(require 'notifications)
((fboundp 'notifications-notify)
(notifications-notify
:title "Org-mode message"
:body notification
@ -1698,7 +1704,7 @@ from the `before-change-functions' in the current buffer."
(remove-hook 'before-change-functions
'org-clock-remove-overlays 'local))))
(defvar state) ;; dynamically scoped into this function
(defvar org-state) ;; dynamically scoped into this function
(defun org-clock-out-if-current ()
"Clock out if the current entry contains the running clock.
This is used to stop the clock after a TODO entry is marked DONE,
@ -1707,9 +1713,9 @@ and is only done if the variable `org-clock-out-when-done' is not nil."
org-clock-out-when-done
(marker-buffer org-clock-marker)
(or (and (eq t org-clock-out-when-done)
(member state org-done-keywords))
(member org-state org-done-keywords))
(and (listp org-clock-out-when-done)
(member state org-clock-out-when-done)))
(member org-state org-clock-out-when-done)))
(equal (or (buffer-base-buffer (org-clocking-buffer))
(org-clocking-buffer))
(or (buffer-base-buffer (current-buffer))
@ -2231,11 +2237,11 @@ from the dynamic block definition."
; file column, maybe
(if level-p "|" "") ; level column, maybe
(if timestamp "|" "") ; timestamp column, maybe
(if properties (make-string (length properties) ?|) "") ;properties columns, maybe
(concat "*" (nth 7 lwords) "*| ") ; instead of a headline
"*"
(org-minutes-to-hh:mm-string (or total-time 0)) ; the time
"*|\n") ; close line
(if properties (make-string (length properties) ?|) "") ; properties columns, maybe
(concat (format org-clock-total-time-cell-format (nth 7 lwords)) "| ") ; instead of a headline
(format org-clock-total-time-cell-format
(org-minutes-to-hh:mm-string (or total-time 0))) ; the time
"|\n") ; close line
;; Now iterate over the tables and insert the data
;; but only if any time has been collected
@ -2441,6 +2447,7 @@ TIME: The sum of all time spend in this tree, in minutes. This time
(tags (plist-get params :tags))
(properties (plist-get params :properties))
(inherit-property-p (plist-get params :inherit-props))
todo-only
(matcher (if tags (cdr (org-make-tags-matcher tags))))
cc range-text st p time level hdl props tsp tbl)
@ -2463,7 +2470,9 @@ TIME: The sum of all time spend in this tree, in minutes. This time
(org-clock-sum ts te
(unless (null matcher)
(lambda ()
(let ((tags-list (org-get-tags-at)))
(let* ((tags-list (org-get-tags-at))
(org-scanner-tags tags-list)
(org-trust-scanner-tags t))
(eval matcher)))))
(goto-char (point-min))
(setq st t)

View File

@ -516,7 +516,7 @@ This is the compiled version of the format.")
'org-whitespace (* 2 (1- (org-reduced-level (- (match-end 1) (match-beginning 1))))))
(and (match-end 2) (not (assoc "TODO" fmt)) (concat " " (match-string 2 item)))
(and (match-end 3) (not (assoc "PRIORITY" fmt)) (concat " " (match-string 3 item)))
" " (save-match-data (org-columns-compact-links (match-string 4 item)))
" " (save-match-data (org-columns-compact-links (or (match-string 4 item) "")))
(and (match-end 5) (not (assoc "TAGS" fmt)) (concat " " (match-string 5 item)))))
(add-text-properties
0 (1+ (match-end 1))

View File

@ -1,6 +1,6 @@
;;; org-colview.el --- Column View in Org-mode
;; Copyright (C) 2004-2012 Free Software Foundation, Inc.
;; Copyright (C) 2004-2012 Free Software Foundation, Inc.
;; Author: Carsten Dominik <carsten at orgmode dot org>
;; Keywords: outlines, hypermedia, calendar, wp
@ -194,7 +194,9 @@ This is the compiled version of the format.")
(point-at-bol) (point-at-eol)))))
;; In agenda, just get the `txt' property
(org-no-properties
(org-get-at-bol 'txt))))
(or (org-get-at-bol 'txt)
(buffer-substring
(point) (progn (end-of-line) (point)))))))
(assoc property props))
width (or (cdr (assoc property org-columns-current-maxwidths))
(nth 2 column)
@ -355,7 +357,7 @@ CPHR is the complex heading regexp to use for parsing ITEM."
'org-whitespace (* 2 (1- (org-reduced-level (- (match-end 1) (match-beginning 1))))))
(and (match-end 2) (not (assoc "TODO" fmt)) (concat " " (match-string 2 item)))
(and (match-end 3) (not (assoc "PRIORITY" fmt)) (concat " " (match-string 3 item)))
" " (save-match-data (org-columns-compact-links (match-string 4 item)))
" " (save-match-data (org-columns-compact-links (or (match-string 4 item) "")))
(and (match-end 5) (not (assoc "TAGS" fmt)) (concat " " (match-string 5 item)))))
(add-text-properties
0 (1+ (match-end 1))
@ -928,6 +930,8 @@ Don't set this, this is meant for dynamic scoping.")
(overlay-put ov 'display (format fmt val)))))
org-columns-overlays))))
(defvar org-inlinetask-min-level
(if (featurep 'org-inlinetask) org-inlinetask-min-level 15))
(defun org-columns-compute (property)
"Sum the values of property PROPERTY hierarchically, for the entire buffer."
(interactive)
@ -942,7 +946,9 @@ Don't set this, this is meant for dynamic scoping.")
(fun (nth 6 ass))
(calc (or (nth 7 ass) 'identity))
(beg org-columns-top-level-marker)
last-level val valflag flag end sumpos sum-alist sum str str1 useval)
(inminlevel org-inlinetask-min-level)
(last-level org-inlinetask-min-level)
val valflag flag end sumpos sum-alist sum str str1 useval)
(save-excursion
;; Find the region to compute
(goto-char beg)
@ -951,16 +957,21 @@ Don't set this, this is meant for dynamic scoping.")
;; Walk the tree from the back and do the computations
(while (re-search-backward re beg t)
(setq sumpos (match-beginning 0)
last-level level
last-level (if (not (or (zerop level) (eq level inminlevel)))
level last-level)
level (org-outline-level)
val (org-entry-get nil property)
valflag (and val (string-match "\\S-" val)))
(cond
((< level last-level)
;; put the sum of lower levels here as a property
(setq sum (when (aref lvals last-level)
(apply fun (aref lvals last-level)))
flag (aref lflag last-level) ; any valid entries from children?
(setq sum (+ (if (and (/= last-level inminlevel)
(aref lvals last-level))
(apply fun (aref lvals last-level)) 0)
(if (aref lvals inminlevel)
(apply fun (aref lvals inminlevel)) 0))
flag (or (aref lflag last-level) ; any valid entries from children?
(aref lflag inminlevel)) ; or inline tasks?
str (org-columns-number-to-string sum format printf)
str1 (org-add-props (copy-sequence str) nil 'org-computed t 'face 'bold)
useval (if flag str1 (if valflag val ""))

View File

@ -1,6 +1,6 @@
;;; org-compat.el --- Compatibility code for Org-mode
;; Copyright (C) 2004-2012 Free Software Foundation, Inc.
;; Copyright (C) 2004-2012 Free Software Foundation, Inc.
;; Author: Carsten Dominik <carsten at orgmode dot org>
;; Keywords: outlines, hypermedia, calendar, wp

View File

@ -237,16 +237,20 @@ See `org-crypt-disable-auto-save'."
(defun org-encrypt-entries ()
"Encrypt all top-level entries in the current buffer."
(interactive)
(org-scan-tags
'org-encrypt-entry
(cdr (org-make-tags-matcher org-crypt-tag-matcher))))
(let (todo-only)
(org-scan-tags
'org-encrypt-entry
(cdr (org-make-tags-matcher org-crypt-tag-matcher))
todo-only)))
(defun org-decrypt-entries ()
"Decrypt all entries in the current buffer."
(interactive)
(org-scan-tags
'org-decrypt-entry
(cdr (org-make-tags-matcher org-crypt-tag-matcher))))
(let (todo-only)
(org-scan-tags
'org-decrypt-entry
(cdr (org-make-tags-matcher org-crypt-tag-matcher))
todo-only)))
(defun org-crypt-use-before-save-magic ()
"Add a hook to automatically encrypt entries before a file is saved to disk."

View File

@ -1,6 +1,6 @@
;;; org-datetree.el --- Create date entries in a tree
;; Copyright (C) 2009-2012 Free Software Foundation, Inc.
;; Copyright (C) 2009-2012 Free Software Foundation, Inc.
;; Author: Carsten Dominik <carsten at orgmode dot org>
;; Keywords: outlines, hypermedia, calendar, wp

View File

@ -1,6 +1,6 @@
;;; org-docbook.el --- DocBook exporter for org-mode
;;
;; Copyright (C) 2007-2012 Free Software Foundation, Inc.
;; Copyright (C) 2007-2012 Free Software Foundation, Inc.
;;
;; Emacs Lisp Archive Entry
;; Filename: org-docbook.el

View File

@ -3,7 +3,6 @@
;; Copyright (C) 2011-2012 Free Software Foundation, Inc.
;; Author: Konrad Hinsen <konrad.hinsen AT fastmail.net>
;; Version: 0.1
;; This file is part of GNU Emacs.

View File

@ -73,6 +73,7 @@
(eval-when-compile
(require 'cl))
(require 'org)
(require 'find-func)
(defun org-export-blocks-set (var value)
"Set the value of `org-export-blocks' and install fontification."
@ -233,7 +234,7 @@ which defaults to the value of `org-export-blocks-witheld'."
(file-name-as-directory
(expand-file-name
"../contrib"
(file-name-directory (or load-file-name buffer-file-name)))))))
(file-name-directory (find-library-name "org")))))))
"Path to the ditaa jar executable."
:group 'org-babel
:type 'string)

View File

@ -194,12 +194,27 @@ This option can also be set with the +OPTIONS line, e.g. \"-:nil\"."
("hu" "Szerz&otilde;" "D&aacute;tum" "Tartalomjegyz&eacute;k" "L&aacute;bjegyzet")
("is" "H&ouml;fundur" "Dagsetning" "Efnisyfirlit" "Aftanm&aacute;lsgreinar")
("it" "Autore" "Data" "Indice" "Note a pi&egrave; di pagina")
;; Use numeric character entities for proper rendering of non-UTF8 documents
;; ("ja" "著者" "日付" "目次" "脚注")
("ja" "&#33879;&#32773;" "&#26085;&#20184;" "&#30446;&#27425;" "&#33050;&#27880;")
("nl" "Auteur" "Datum" "Inhoudsopgave" "Voetnoten")
("no" "Forfatter" "Dato" "Innhold" "Fotnoter")
("nb" "Forfatter" "Dato" "Innhold" "Fotnoter") ;; nb = Norsk (bokm.l)
("nn" "Forfattar" "Dato" "Innhald" "Fotnotar") ;; nn = Norsk (nynorsk)
("pl" "Autor" "Data" "Spis tre&#x015b;ci" "Przypis")
("sv" "F&ouml;rfattare" "Datum" "Inneh&aring;ll" "Fotnoter"))
;; Use numeric character entities for proper rendering of non-UTF8 documents
;; ("ru" "Автор" "Дата" "Содержание" "Сноски")
("ru" "&#1040;&#1074;&#1090;&#1086;&#1088;" "&#1044;&#1072;&#1090;&#1072;" "&#1057;&#1086;&#1076;&#1077;&#1088;&#1078;&#1072;&#1085;&#1080;&#1077;" "&#1057;&#1085;&#1086;&#1089;&#1082;&#1080;")
("sv" "F&ouml;rfattare" "Datum" "Inneh&aring;ll" "Fotnoter")
;; Use numeric character entities for proper rendering of non-UTF8 documents
;; ("uk" "Автор" "Дата" "Зміст" "Примітки")
("uk" "&#1040;&#1074;&#1090;&#1086;&#1088;" "&#1044;&#1072;&#1090;&#1072;" "&#1047;&#1084;&#1110;&#1089;&#1090;" "&#1055;&#1088;&#1080;&#1084;&#1110;&#1090;&#1082;&#1080;")
;; Use numeric character entities for proper rendering of non-UTF8 documents
;; ("zh-CN" "作者" "日期" "目录" "脚注")
("zh-CN" "&#20316;&#32773;" "&#26085;&#26399;" "&#30446;&#24405;" "&#33050;&#27880;")
;; Use numeric character entities for proper rendering of non-UTF8 documents
;; ("zh-TW" "作者" "日期" "目錄" "腳註")
("zh-TW" "&#20316;&#32773;" "&#26085;&#26399;" "&#30446;&#37636;" "&#33139;&#35387;"))
"Terms used in export text, translated to different languages.
Use the variable `org-export-default-language' to set the language,
or use the +OPTION lines for a per-file setting."

View File

@ -57,7 +57,9 @@
(declare-function org-mark-ring-push "org" (&optional pos buffer))
(declare-function org-show-context "org" (&optional key))
(declare-function org-trim "org" (s))
(declare-function org-skip-whitespace "org" ())
(declare-function outline-next-heading "outline")
(declare-function org-skip-whitespace "org" ())
(defvar org-outline-regexp-bol) ; defined in org.el
(defvar org-odd-levels-only) ; defined in org.el
@ -276,9 +278,7 @@ otherwise."
(concat org-outline-regexp-bol "\\|"
org-footnote-definition-re "\\|"
"^[ \t]*$") bound 'move))
(progn (goto-char (match-beginning 0))
(org-skip-whitespace)
(point-at-bol))
(match-beginning 0)
(point)))))
(list label beg end
(org-trim (buffer-substring-no-properties beg-def end)))))))))
@ -703,7 +703,7 @@ Additional note on `org-footnote-insert-pos-for-preprocessor':
(org-combine-plists
export-props
'(:todo-keywords t :tags t :priority t))))
(org-export-preprocess-string def parameters))
(apply #'org-export-preprocess-string def parameters))
def)
;; Reference beginning position is a marker
;; to preserve it during further buffer
@ -863,8 +863,13 @@ Return the number of footnotes removed."
(ndef 0))
(while (re-search-forward def-re nil t)
(let ((full-def (org-footnote-at-definition-p)))
(delete-region (nth 1 full-def) (nth 2 full-def)))
(incf ndef))
(when full-def
;; Remove the footnote, and all blank lines before it.
(goto-char (nth 1 full-def))
(skip-chars-backward " \r\t\n")
(unless (bolp) (forward-line))
(delete-region (point) (nth 2 full-def))
(incf ndef))))
ndef)))
(defun org-footnote-delete (&optional label)

View File

@ -336,7 +336,14 @@ current time."
(let ((inhibit-read-only t) l c
(buffer-invisibility-spec '(org-link))
(moment (time-subtract (current-time)
(list 0 (* 3600 org-extend-today-until) 0))))
(list 0 (* 3600 org-extend-today-until) 0)))
disabled-overlays)
;; Disable filters; this helps with alignment if there are links.
(mapc (lambda (ol)
(when (overlay-get ol 'invisible)
(overlay-put ol 'invisible nil)
(setq disabled-overlays (cons ol disabled-overlays))))
(overlays-in (point-min) (point-max)))
(save-excursion
(goto-char (if line (point-at-bol) (point-min)))
(while (not (eobp))
@ -346,14 +353,15 @@ current time."
(delete-char (min (+ 1 org-habit-preceding-days
org-habit-following-days)
(- (line-end-position) (point))))
(insert (org-habit-build-graph
habit
(time-subtract moment
(days-to-time org-habit-preceding-days))
moment
(time-add moment
(days-to-time org-habit-following-days))))))
(forward-line)))))
(insert-before-markers
(org-habit-build-graph
habit
(time-subtract moment (days-to-time org-habit-preceding-days))
moment
(time-add moment (days-to-time org-habit-following-days))))))
(forward-line)))
(mapc (lambda (ol) (overlay-put ol 'invisible t))
disabled-overlays)))
(defun org-habit-toggle-habits ()
"Toggle display of habits in an agenda buffer."

View File

@ -382,11 +382,17 @@ precedence over this variable."
:group 'org-export-html
:type '(choice (const :tag "No preamble" nil)
(const :tag "Default preamble" t)
(string :tag "Custom formatting string")
(string :tag "Custom format string")
(function :tag "Function (must return a string)")))
(defcustom org-export-html-preamble-format '(("en" ""))
"The format for the HTML preamble.
"Alist of languages and format strings for the HTML preamble.
The first element of each list is the language code, as used for
the #+LANGUAGE keyword.
The second element of each list is a format string to format the
preamble itself. This format string can contain these elements:
%t stands for the title.
%a stands for the author's name.
@ -416,8 +422,8 @@ precedence over this variable."
:group 'org-export-html
:type '(choice (const :tag "No postamble" nil)
(const :tag "Auto preamble" 'auto)
(const :tag "Default formatting string" t)
(string :tag "Custom formatting string")
(const :tag "Default format string" t)
(string :tag "Custom format string")
(function :tag "Function (must return a string)")))
(defcustom org-export-html-postamble-format
@ -426,7 +432,13 @@ precedence over this variable."
<p class=\"creator\">Generated by %c</p>
<p class=\"xhtml-validation\">%v</p>
"))
"The format for the HTML postamble.
"Alist of languages and format strings for the HTML postamble.
The first element of each list is the language code, as used for
the #+LANGUAGE keyword.
The second element of each list is a format string to format the
postamble itself. This format string can contain these elements:
%a stands for the author's name.
%e stands for the author's email.
@ -653,6 +665,14 @@ postamble DIV."
(string :tag " Div for the content:")
(string :tag "Div for the postamble:")))
(defcustom org-export-html-date-format-string "%Y-%m-%dT%R%z"
"Format string to format the date and time.
The default is an extended format of the ISO 8601 specification."
:group 'org-export-html
:version "24.1"
:type 'string)
;;; Hooks
(defvar org-export-html-after-blockquotes-hook nil
@ -1285,7 +1305,7 @@ PUB-DIR is set, use this as the publishing directory."
((and date (string-match "%" date))
(setq date (format-time-string date)))
(date)
(t (setq date (format-time-string "%Y-%m-%d %T %Z"))))
(t (setq date (format-time-string org-export-html-date-format-string))))
;; Get the language-dependent settings
(setq lang-words (or (assoc language org-export-language-setup)
@ -1394,7 +1414,7 @@ PUB-DIR is set, use this as the publishing directory."
"\n<h1 class=\"title\">" title "</h1>\n"))
;; insert body
(if (and org-export-with-toc (not body-only))
(if org-export-with-toc
(progn
(push (format "<h%d>%s</h%d>\n"
org-export-html-toplevel-hlevel

View File

@ -194,7 +194,7 @@ or if they are only using it locally."
(defcustom org-icalendar-timezone (getenv "TZ")
"The time zone string for iCalendar export.
When nil of the empty string, use the abbreviation retrieved from Emacs."
When nil or the empty string, use output from \(current-time-zone\)."
:group 'org-export-icalendar
:type '(choice
(const :tag "Unspecified" nil)

View File

@ -671,6 +671,18 @@ This function should accept the file name as its single argument."
"bibtex %b"
"pdflatex -interaction nonstopmode -output-directory %o %f"
"pdflatex -interaction nonstopmode -output-directory %o %f"))
(const :tag "2 runs of xelatex"
("xelatex -interaction nonstopmode -output-directory %o %f"
"xelatex -interaction nonstopmode -output-directory %o %f"))
(const :tag "3 runs of xelatex"
("xelatex -interaction nonstopmode -output-directory %o %f"
"xelatex -interaction nonstopmode -output-directory %o %f"
"xelatex -interaction nonstopmode -output-directory %o %f"))
(const :tag "xelatex,bibtex,xelatex,xelatex"
("xelatex -interaction nonstopmode -output-directory %o %f"
"bibtex %b"
"xelatex -interaction nonstopmode -output-directory %o %f"
"xelatex -interaction nonstopmode -output-directory %o %f"))
(const :tag "texi2dvi"
("texi2dvi -p -b -c -V %f"))
(const :tag "rubber"
@ -870,7 +882,7 @@ when PUB-DIR is set, use this as the publishing directory."
(concat
(file-name-as-directory
(or pub-dir
(org-export-directory :LaTeX ext-plist)))
(org-export-directory :LaTeX org-export-latex-options-plist)))
(file-name-sans-extension
(or (and subtree-p
(org-entry-get rbeg "EXPORT_FILE_NAME" t))
@ -885,7 +897,7 @@ when PUB-DIR is set, use this as the publishing directory."
(concat filename ".tex")
filename)))
(auto-insert nil); Avoid any auto-insert stuff for the new file
(TeX-master t) ; Avoid the Query for TeX master from AUCTeX
(TeX-master (boundp 'TeX-master))
(buffer (if to-buffer
(cond
((eq to-buffer 'string) (get-buffer-create
@ -1239,7 +1251,7 @@ numbered sections and lower levels as unnumbered sections."
org-export-target-aliases))))
(sectioning org-export-latex-sectioning)
(depth org-export-latex-sectioning-depth)
main-heading sub-heading)
main-heading sub-heading ctnt)
(when (symbolp (car sectioning))
(setq sectioning (funcall (car sectioning) level heading))
(when sectioning
@ -1306,16 +1318,20 @@ numbered sections and lower levels as unnumbered sections."
(delete-region (point-at-bol 0) (point))
(insert (format "\\begin{%s}\n"
(symbol-name org-export-latex-low-levels))))
(insert (format "\n\\item %s\\\\\n%s%%"
heading
(if label (format "\\label{%s}" label) "")))
(insert (org-export-latex-content content))
(let ((ctnt (org-export-latex-content content)))
(insert (format (if (not (equal (replace-regexp-in-string "\n" "" ctnt) ""))
"\n\\item %s\\\\\n%s%%"
"\n\\item %s\n%s%%")
heading
(if label (format "\\label{%s}" label) "")))
(insert ctnt))
(cond ((stringp subcontent) (insert subcontent))
((listp subcontent) (org-export-latex-sub subcontent)))
(insert (format "\\end{%s} %% ends low level\n"
(symbol-name org-export-latex-low-levels))))
((listp org-export-latex-low-levels)
((and (listp org-export-latex-low-levels)
org-export-latex-low-levels)
(if (string-match "% ends low level$"
(buffer-substring (point-at-bol 0) (point)))
(delete-region (point-at-bol 0) (point))
@ -1917,10 +1933,14 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
'org-label raw-table)
longtblp (and attr (stringp attr)
(string-match "\\<longtable\\>" attr))
tblenv (if (and attr (stringp attr)
(or (string-match (regexp-quote "table*") attr)
(string-match "\\<multicolumn\\>" attr)))
"table*" "table")
tblenv (if (and attr (stringp attr))
(cond ((string-match "\\<sidewaystable\\>" attr)
"sidewaystable")
((or (string-match (regexp-quote "table*") attr)
(string-match "\\<multicolumn\\>" attr))
"table*")
(t "table"))
"table")
tabular-env
(if (and attr (stringp attr)
(string-match "\\(tabular.\\)" attr))

View File

@ -809,6 +809,8 @@ version."
(setq umax-toc (if (integerp org-export-with-toc)
(min org-export-with-toc umax)
umax))
(setq org-lparse-opt-plist
(plist-put org-lparse-opt-plist :headline-levels umax))
(when (and org-export-with-toc (not body-only))
(setq lines (org-lparse-prepare-toc
@ -845,48 +847,6 @@ version."
(org-lparse-end-environment 'fixedwidth))
(throw 'nextline nil))
;; Notes: The baseline version of org-html.el (git commit
;; 3d802e), while encountering a *line-long* protected text,
;; does one of the following two things based on the state
;; of the export buffer.
;; 1. If a paragraph element has just been opened and
;; contains only whitespace as content, insert the
;; protected text as part of the previous paragraph.
;; 2. If the paragraph element has already been opened and
;; contains some valid content insert the protected text
;; as part of the current paragraph.
;; I think --->
;; Scenario 1 mentioned above kicks in when a block of
;; protected text has to be inserted en bloc. For example,
;; this happens, when inserting an source or example block
;; or preformatted content enclosed in #+backend,
;; #+begin_backend ... #+end_backend)
;; Scenario 2 mentioned above kicks in when the protected
;; text is part of a running sentence. For example this
;; happens in the case of an *multiline* LaTeX equation that
;; needs to be inserted verbatim.
;; org-html.el in the master branch seems to do some
;; jugglery by moving paragraphs around. Inorder to make
;; these changes backend-agnostic introduce a new text
;; property org-native-text and impose the added semantics
;; that these protected blocks appear outside of a
;; conventional paragraph element.
;;
;; Extra Note: Check whether org-example and org-native-text
;; are entirely equivalent.
;; Fixes bug reported by Christian Moe concerning verbatim
;; LaTeX fragments.
;; on git commit 533ba3f90250a1f25f494c390d639ea6274f235c
;; http://repo.or.cz/w/org-mode/org-jambu.git/shortlog/refs/heads/staging
;; See http://lists.gnu.org/archive/html/emacs-orgmode/2011-03/msg01379.html
;; Native Text
(when (and (get-text-property 0 'org-native-text line)
;; Make sure it is the entire line that is protected
@ -1261,7 +1221,11 @@ for formatting. This is required for the DocBook exporter."
;; column and the special lines
(setq lines (org-table-clean-before-export lines)))
(let* ((caption (org-find-text-property-in-string 'org-caption (car lines)))
(short-caption (or (org-find-text-property-in-string
'org-caption-shortn (car lines)) caption))
(caption (and caption (org-xml-encode-org-text caption)))
(short-caption (and short-caption
(org-xml-encode-plain-text short-caption)))
(label (org-find-text-property-in-string 'org-label (car lines)))
(org-lparse-table-colalign-info (org-lparse-table-get-colalign-info lines))
(attributes (org-find-text-property-in-string 'org-attributes
@ -1272,11 +1236,13 @@ for formatting. This is required for the DocBook exporter."
(cdr lines))))))
(setq lines (org-lparse-org-table-to-list-table lines splice))
(org-lparse-insert-list-table
lines splice caption label attributes head org-lparse-table-colalign-info)))
lines splice caption label attributes head org-lparse-table-colalign-info
short-caption)))
(defun org-lparse-insert-list-table (lines &optional splice
caption label attributes head
org-lparse-table-colalign-info)
org-lparse-table-colalign-info
short-caption)
(or (featurep 'org-table) ; required for
(require 'org-table)) ; `org-table-number-regexp'
(let* ((org-lparse-table-rownum -1) org-lparse-table-ncols i (cnt 0)
@ -1296,7 +1262,7 @@ for formatting. This is required for the DocBook exporter."
(insert (org-lparse-format-table-row line) "\n")))
(t
(setq org-lparse-table-is-styled t)
(org-lparse-begin 'TABLE caption label attributes)
(org-lparse-begin 'TABLE caption label attributes short-caption)
(setq org-lparse-table-begin-marker (point))
(org-lparse-begin-table-rowgroup head)
(while (setq line (pop lines))
@ -1327,13 +1293,14 @@ But it has the disadvantage, that no cell- or row-spanning is allowed."
(org-lparse-table-cur-rowgrp-is-hdr
org-export-highlight-first-table-line)
(caption nil)
(short-caption nil)
(attributes nil)
(label nil)
(org-lparse-table-style 'table-table)
(org-lparse-table-is-styled nil)
fields org-lparse-table-ncols i (org-lparse-table-rownum -1)
(empty (org-lparse-format 'SPACES 1)))
(org-lparse-begin 'TABLE caption label attributes)
(org-lparse-begin 'TABLE caption label attributes short-caption)
(while (setq line (pop lines))
(cond
((string-match "^[ \t]*\\+-" line)

View File

@ -1,9 +1,9 @@
;;; org-mac-message.el --- Links to Apple Mail.app messages from within Org-mode
;; Copyright (C) 2008-2012 Free Software Foundation, Inc.
;; Copyright (C) 2008-2012 Free Software Foundation, Inc.
;; Author: John Wiegley <johnw@gnu.org>
;; Christopher Suckling <suckling at gmail dot com>
;; Authors: John Wiegley <johnw@gnu.org>
;; Christopher Suckling <suckling at gmail dot com>
;; Keywords: outlines, hypermedia, calendar, wp

View File

@ -300,6 +300,8 @@ Also exclude files matching `org-mobile-files-exclude-regexp'."
(push (cons file link-name) rtn)))
(nreverse rtn)))
(defvar org-agenda-filter)
;;;###autoload
(defun org-mobile-push ()
"Push the current state of Org affairs to the WebDAV directory.
@ -579,7 +581,7 @@ The table of checksums is written to the file mobile-checksums."
(concat "<after>KEYS=" key " TITLE: "
(if (and (stringp desc) (> (length desc) 0))
desc (symbol-name type))
" " match "</after>"))
"</after>"))
settings))
(push (list type match settings) new))
((or (functionp (nth 2 e)) (symbolp (nth 2 e)))

View File

@ -315,11 +315,11 @@ nor a function, elements of KEYWORDS are used directly."
(replace-match "")
(just-one-space))
(defvar rest)
(defvar org-mouse-rest)
(defun org-mouse-replace-match-and-surround (newtext &optional fixedcase
literal string subexp)
"The same as `replace-match', but surrounds the replacement with spaces."
(apply 'replace-match rest)
(apply 'replace-match org-mouse-rest)
(save-excursion
(goto-char (match-beginning (or subexp 0)))
(just-one-space)
@ -990,7 +990,7 @@ This means, between the beginning of line and the point."
(replace-match replace-text))
(forward-line))))
(defvar _cmd) ;dynamically scoped from `org-with-remote-undo'.
(defvar org-mouse-cmd) ;dynamically scoped from `org-with-remote-undo'.
(defun org-mouse-do-remotely (command)
; (org-agenda-check-no-diary)
@ -1021,7 +1021,7 @@ This means, between the beginning of line and the point."
(setq marker (copy-marker (point)))
(goto-char (max (point-at-bol) (- (point-at-eol) anticol)))
(funcall command)
(message "_cmd: %S" _cmd)
(message "_cmd: %S" org-mouse-cmd)
(message "this-command: %S" this-command)
(unless (eq (marker-position marker) (marker-position endmarker))
(setq newhead (org-get-heading))))

View File

@ -987,7 +987,7 @@ new entry in `org-odt-automatic-styles'. Return (OBJECT-NAME
(cons object-name style-name)))
(defvar org-odt-table-indentedp nil)
(defun org-odt-begin-table (caption label attributes)
(defun org-odt-begin-table (caption label attributes short-caption)
(setq org-odt-table-indentedp (not (null org-lparse-list-stack)))
(when org-odt-table-indentedp
;; Within the Org file, the table is appearing within a list item.
@ -1006,11 +1006,12 @@ new entry in `org-odt-automatic-styles'. Return (OBJECT-NAME
(insert
(org-odt-format-stylized-paragraph
'table (org-odt-format-entity-caption label caption "__Table__"))))
(let ((name-and-style (org-odt-add-automatic-style "Table" attributes)))
(let ((automatic-name (org-odt-add-automatic-style "Table" attributes)))
(org-lparse-insert-tag
"<table:table table:name=\"%s\" table:style-name=\"%s\">"
(car name-and-style) (or (nth 1 org-odt-table-style-spec)
(cdr name-and-style) "OrgTable")))
(or short-caption (car automatic-name))
(or (nth 1 org-odt-table-style-spec)
(cdr automatic-name) "OrgTable")))
(setq org-lparse-table-begin-marker (point)))
(defvar org-lparse-table-colalign-info)
@ -1184,6 +1185,16 @@ styles congruent with the ODF-1.2 specification."
(org-lparse-end-paragraph))
(defun org-odt-begin-toc (lang-specific-heading max-level)
;; Strings in `org-export-language-setup' can contain named html
;; entities. Replace those with utf-8 equivalents.
(let ((i 0) entity rpl)
(while (string-match "&\\([^#].*?\\);" lang-specific-heading i)
(setq entity (match-string 1 lang-specific-heading))
(if (not (setq rpl (org-entity-get-representation entity 'utf8)))
(setq i (match-end 0))
(setq i (+ (match-beginning 0) (length rpl)))
(setq lang-specific-heading
(replace-match rpl t t lang-specific-heading)))))
(insert
(format "
<text:table-of-content text:style-name=\"Sect2\" text:protected=\"true\" text:name=\"Table of Contents1\">
@ -1243,10 +1254,13 @@ styles congruent with the ODF-1.2 specification."
(defun org-odt-format-link (desc href &optional attr)
(cond
((and (= (string-to-char href) ?#) (not org-odt-suppress-xref))
(setq href (concat org-export-odt-bookmark-prefix (substring href 1)))
(setq href (substring href 1))
(let ((xref-format "text"))
(when (numberp desc)
(setq desc (format "%d" desc) xref-format "number"))
(when (listp desc)
(setq desc (mapconcat 'identity desc ".") xref-format "chapter"))
(setq href (concat org-export-odt-bookmark-prefix href))
(org-odt-format-tags
'("<text:bookmark-ref text:reference-format=\"%s\" text:ref-name=\"%s\">" .
"</text:bookmark-ref>")
@ -1522,10 +1536,29 @@ value of `org-export-odt-fontify-srcblocks."
(org-odt-copy-image-file thefile) thelink))))
(org-export-odt-format-image thefile href)))
(defvar org-odt-entity-labels-alist nil
"Associate Labels with the Labeled entities.
Each element of the alist is of the form (LABEL-NAME
CATEGORY-NAME SEQNO LABEL-STYLE-NAME). LABEL-NAME is same as
that specified by \"#+LABEL: ...\" line. CATEGORY-NAME is the
type of the entity that LABEL-NAME is attached to. CATEGORY-NAME
can be one of \"Table\", \"Figure\" or \"Equation\". SEQNO is
the unique number assigned to the referenced entity on a
per-CATEGORY basis. It is generated sequentially and is 1-based.
LABEL-STYLE-NAME is a key `org-odt-label-styles'.
See `org-odt-add-label-definition' and
`org-odt-fixup-label-references'.")
(defun org-export-odt-format-formula (src href)
(save-match-data
(let* ((caption (org-find-text-property-in-string 'org-caption src))
(short-caption
(or (org-find-text-property-in-string 'org-caption-shortn src)
caption))
(caption (and caption (org-xml-format-desc caption)))
(short-caption (and short-caption
(org-xml-encode-plain-text short-caption)))
(label (org-find-text-property-in-string 'org-label src))
(latex-frag (org-find-text-property-in-string 'org-latex-src src))
(embed-as (or (and latex-frag
@ -1543,10 +1576,15 @@ value of `org-export-odt-fontify-srcblocks."
(org-lparse-end-paragraph)
(org-lparse-insert-list-table
`((,(org-odt-format-entity
(if caption "CaptionedDisplayFormula" "DisplayFormula")
href width height :caption caption :label nil)
,(if (not label) ""
(org-odt-format-entity-caption label nil "__MathFormula__"))))
(if (not (or caption label)) "DisplayFormula"
"CaptionedDisplayFormula")
href width height :caption caption :label label
:short-caption short-caption)
,(if (not (or caption label)) ""
(let* ((label-props (car org-odt-entity-labels-alist)))
(setcar (last label-props) "math-label")
(apply 'org-odt-format-label-definition
caption label-props)))))
nil nil nil ":style \"OrgEquation\"" nil '((1 "c" 8) (2 "c" 1)))
(throw 'nextline nil))))))
@ -1613,7 +1651,8 @@ ATTR is a string of other attributes of the a element."
(not fragment)))
(type (if (equal type-1 "id") "file" type-1))
(filename path)
(thefile path))
(thefile path)
sec-frag sec-nos)
(cond
;; check for inlined images
((and (member type '("file"))
@ -1629,6 +1668,7 @@ ATTR is a string of other attributes of the a element."
(org-odt-is-formula-link-p filename)
(or (not descp)))
(org-odt-format-inline-formula thefile))
;; code references
((string= type "coderef")
(let* ((ref fragment)
(lineno-or-ref (cdr (assoc ref org-export-code-refs)))
@ -1651,6 +1691,23 @@ ATTR is a string of other attributes of the a element."
(or desc "%s"))
lineno-or-ref))
(org-odt-format-link (org-xml-format-desc desc) href)))))
;; links to headlines
((and (string= type "")
(or (not thefile) (string= thefile ""))
(plist-get org-lparse-opt-plist :section-numbers)
(setq sec-frag fragment)
(org-find-text-property-in-string 'org-no-description fragment)
(or (string-match "\\`sec\\(\\(-[0-9]+\\)+\\)" sec-frag)
(and (setq sec-frag
(loop for alias in org-export-target-aliases do
(when (member fragment (cdr alias))
(return (car alias)))))
(string-match "\\`sec\\(\\(-[0-9]+\\)+\\)" sec-frag)))
(setq sec-nos (org-split-string (match-string 1 sec-frag) "-"))
(<= (length sec-nos) (plist-get org-lparse-opt-plist
:headline-levels)))
(let ((org-odt-suppress-xref nil))
(org-odt-format-link sec-nos (concat "#" sec-frag) attr)))
(t
(when (string= type "file")
(setq thefile
@ -1750,7 +1807,12 @@ ATTR is a string of other attributes of the a element."
"Create image tag with source and attributes."
(save-match-data
(let* ((caption (org-find-text-property-in-string 'org-caption src))
(short-caption
(or (org-find-text-property-in-string 'org-caption-shortn src)
caption))
(caption (and caption (org-xml-format-desc caption)))
(short-caption (and short-caption
(org-xml-encode-plain-text short-caption)))
(attr (org-find-text-property-in-string 'org-attributes src))
(label (org-find-text-property-in-string 'org-label src))
(latex-frag (org-find-text-property-in-string
@ -1788,6 +1850,7 @@ ATTR is a string of other attributes of the a element."
(org-odt-format-entity
frame-style-handle href width height
:caption caption :label label :category category
:short-caption short-caption
:user-frame-params user-frame-params)))))
(defun org-odt-format-object-description (title description)
@ -1866,7 +1929,7 @@ ATTR is a string of other attributes of the a element."
(defun* org-odt-format-entity (entity href width height
&key caption label category
user-frame-params)
user-frame-params short-caption)
(let* ((entity-style (assoc-string entity org-odt-entity-frame-styles t))
default-frame-params frame-params)
(cond
@ -1884,7 +1947,16 @@ ATTR is a string of other attributes of the a element."
'illustration
(concat
(apply 'org-odt-format-frame href width height
(nth 2 entity-style))
(let ((entity-style-1 (copy-sequence
(nth 2 entity-style))))
(setcar (cdr entity-style-1)
(concat
(cadr entity-style-1)
(and short-caption
(format " draw:name=\"%s\" "
short-caption))))
entity-style-1))
(org-odt-format-entity-caption
label caption (or category (nth 1 entity-style)))))
width height frame-params)))))
@ -1989,28 +2061,15 @@ ATTR is a string of other attributes of the a element."
(setq width (* scale width) height (* scale height)))))
(cons width height)))
(defvar org-odt-entity-labels-alist nil
"Associate Labels with the Labeled entities.
Each element of the alist is of the form (LABEL-NAME
CATEGORY-NAME SEQNO LABEL-STYLE-NAME). LABEL-NAME is same as
that specified by \"#+LABEL: ...\" line. CATEGORY-NAME is the
type of the entity that LABEL-NAME is attached to. CATEGORY-NAME
can be one of \"Table\", \"Figure\" or \"Equation\". SEQNO is
the unique number assigned to the referenced entity on a
per-CATEGORY basis. It is generated sequentially and is 1-based.
LABEL-STYLE-NAME is a key `org-odt-label-styles'.
See `org-odt-add-label-definition' and
`org-odt-fixup-label-references'.")
(defvar org-odt-entity-counts-plist nil
"Plist of running counters of SEQNOs for each of the CATEGORY-NAMEs.
See `org-odt-entity-labels-alist' for known CATEGORY-NAMEs.")
(defvar org-odt-label-styles
'(("text" "(%n)" "text" "(%n)")
("category-and-value" "%e %n%c" "category-and-value" "%e %n")
("value" "%e %n%c" "value" "%n"))
'(("math-formula" "%c" "text" "(%n)")
("math-label" "(%n)" "text" "(%n)")
("category-and-value" "%e %n: %c" "category-and-value" "%e %n")
("value" "%e %n: %c" "value" "%n"))
"Specify how labels are applied and referenced.
This is an alist where each element is of the
form (LABEL-STYLE-NAME LABEL-ATTACH-FMT LABEL-REF-MODE
@ -2031,93 +2090,105 @@ specifiers - %e and %n. %e is replaced with the CATEGORY-NAME.
%n is replaced with SEQNO. See
`org-odt-format-label-reference'.")
(defcustom org-export-odt-category-strings
'(("en" "Table" "Figure" "Equation" "Equation"))
"Specify category strings for various captionable entities.
Captionable entity can be one of a Table, an Embedded Image, a
LaTeX fragment (generated with dvipng) or a Math Formula.
For example, when `org-export-default-language' is \"en\", an
embedded image will be captioned as \"Figure 1: Orgmode Logo\".
If you want the images to be captioned instead as \"Illustration
1: Orgmode Logo\", then modify the entry for \"en\" as shown
below.
\(setq org-export-odt-category-strings
'\(\(\"en\" \"Table\" \"Illustration\"
\"Equation\" \"Equation\"\)\)\)"
:group 'org-export-odt
:version "24.1"
:type '(repeat (list (string :tag "Language tag")
(choice :tag "Table"
(const :tag "Use Default" nil)
(string :tag "Category string"))
(choice :tag "Figure"
(const :tag "Use Default" nil)
(string :tag "Category string"))
(choice :tag "Math Formula"
(const :tag "Use Default" nil)
(string :tag "Category string"))
(choice :tag "Dvipng Image"
(const :tag "Use Default" nil)
(string :tag "Category string")))))
(defvar org-odt-category-map-alist
'(("__Table__" "Table" "value")
("__Figure__" "Figure" "value")
("__MathFormula__" "Equation" "text")
("__Figure__" "Illustration" "value")
("__MathFormula__" "Text" "math-formula")
("__DvipngImage__" "Equation" "value")
;; ("__Table__" "Table" "category-and-value")
;; ("__Figure__" "Figure" "category-and-value")
;; ("__DvipngImage__" "Equation" "category-and-value")
)
"Map a CATEGORY-HANDLE to CATEGORY-NAME and LABEL-STYLE.
This is an alist where each element is of the form
\\(CATEGORY-HANDLE CATEGORY-NAME LABEL-STYLE\\). CATEGORY_HANDLE
could either be one of the internal handles (as seen above) or be
derived from the \"#+LABEL:<label-name>\" specification. See
`org-export-odt-get-category-from-label'. CATEGORY-NAME and
LABEL-STYLE are used for generating ODT labels. See
`org-odt-label-styles'.")
"Map a CATEGORY-HANDLE to OD-VARIABLE and LABEL-STYLE.
This is a list where each entry is of the form \\(CATEGORY-HANDLE
OD-VARIABLE LABEL-STYLE\\). CATEGORY_HANDLE identifies the
captionable entity in question. OD-VARIABLE is the OpenDocument
sequence counter associated with the entity. These counters are
declared within
\"<text:sequence-decls>...</text:sequence-decls>\" block of
`org-export-odt-content-template-file'. LABEL-STYLE is a key
into `org-odt-label-styles' and specifies how a given entity
should be captioned and referenced.
(defvar org-export-odt-user-categories
'("Illustration" "Table" "Text" "Drawing" "Equation" "Figure"))
(defvar org-export-odt-get-category-from-label nil
"Should category of label be inferred from label itself.
When this option is non-nil, a label is parsed in to two
component parts delimited by a \":\" (colon) as shown here -
#+LABEL:[CATEGORY-HANDLE:]EXTRA. The CATEGORY-HANDLE is mapped
to a CATEGORY-NAME and LABEL-STYLE using
`org-odt-category-map-alist'. (If no such map is provided and
CATEGORY-NAME is set to CATEGORY-HANDLE and LABEL-STYLE is set to
\"category-and-value\"). If CATEGORY-NAME so obtained is listed
under `org-export-odt-user-categories' then the user specified
styles are used. Otherwise styles as determined by the internal
CATEGORY-HANDLE is used. See
`org-odt-get-label-category-and-style' for details.")
(defun org-odt-get-label-category-and-style (label default-category)
"See `org-export-odt-get-category-from-label'."
(let ((default-category-map
(assoc default-category org-odt-category-map-alist))
user-category user-category-map category)
(cond
((not org-export-odt-get-category-from-label)
default-category-map)
((not (setq user-category
(save-match-data
(and (string-match "\\`\\(.*\\):.+" label)
(match-string 1 label)))))
default-category-map)
(t
(setq user-category-map
(or (assoc user-category org-odt-category-map-alist)
(list nil user-category "category-and-value"))
category (nth 1 user-category-map))
(if (member category org-export-odt-user-categories)
user-category-map
default-category-map)))))
The position of a CATEGORY-HANDLE in this list is used as an
index in to per-language entry for
`org-export-odt-category-strings' to retrieve a CATEGORY-NAME.
This CATEGORY-NAME is then used for qualifying the user-specified
captions on export.")
(defun org-odt-add-label-definition (label default-category)
"Create an entry in `org-odt-entity-labels-alist' and return it."
(setq label (substring-no-properties label))
(let* ((label-props (org-odt-get-label-category-and-style
label default-category))
(category (nth 1 label-props))
(counter category)
(label-style (nth 2 label-props))
(sequence-var (intern (mapconcat
'downcase
(org-split-string counter) "-")))
(let* ((label-props (assoc default-category org-odt-category-map-alist))
;; identify the sequence number
(counter (nth 1 label-props))
(sequence-var (intern counter))
(seqno (1+ (or (plist-get org-odt-entity-counts-plist sequence-var)
0)))
(label-props (list label category seqno label-style)))
;; assign an internal label, if user has not provided one
(label (if label (substring-no-properties label)
(format "%s-%s" default-category seqno)))
;; identify label style
(label-style (nth 2 label-props))
;; grok language setting
(en-strings (assoc-default "en" org-export-odt-category-strings))
(lang (plist-get org-lparse-opt-plist :language))
(lang-strings (assoc-default lang org-export-odt-category-strings))
;; retrieve localized category sting
(pos (- (length org-odt-category-map-alist)
(length (memq label-props org-odt-category-map-alist))))
(category (or (nth pos lang-strings) (nth pos en-strings)))
(label-props (list label category counter seqno label-style)))
;; synchronize internal counters
(setq org-odt-entity-counts-plist
(plist-put org-odt-entity-counts-plist sequence-var seqno))
;; stash label properties for later retrieval
(push label-props org-odt-entity-labels-alist)
label-props))
(defun org-odt-format-label-definition (caption label category seqno label-style)
(defun org-odt-format-label-definition (caption label category counter
seqno label-style)
(assert label)
(format-spec
(cadr (assoc-string label-style org-odt-label-styles t))
`((?e . ,category)
(?n . ,(org-odt-format-tags
'("<text:sequence text:ref-name=\"%s\" text:name=\"%s\" text:formula=\"ooow:%s+1\" style:num-format=\"1\">" . "</text:sequence>")
(format "%d" seqno) label category category))
(?c . ,(or (and caption (concat ": " caption)) "")))))
(format "%d" seqno) label counter counter))
(?c . ,(or caption "")))))
(defun org-odt-format-label-reference (label category seqno label-style)
(defun org-odt-format-label-reference (label category counter
seqno label-style)
(assert label)
(save-match-data
(let* ((fmt (cddr (assoc-string label-style org-odt-label-styles t)))
@ -2143,10 +2214,9 @@ CATEGORY-HANDLE is used. See
(format "Unable to resolve reference to label \"%s\"" label))))))
(defun org-odt-format-entity-caption (label caption category)
(or (and label
(apply 'org-odt-format-label-definition
caption (org-odt-add-label-definition label category)))
caption ""))
(if (not (or label caption)) ""
(apply 'org-odt-format-label-definition caption
(org-odt-add-label-definition label category))))
(defun org-odt-format-tags (tag text &rest args)
(let ((prefix (when org-lparse-encode-pending "@"))

View File

@ -50,6 +50,9 @@
:tag "Org"
:group 'org)
(defvar org-drawer-regexp)
(defvar org-property-re)
(defun org-thing-at-point ()
"Examine the thing at point and let the caller know what it is.
The return value is a string naming the thing at point."
@ -69,7 +72,7 @@ The return value is a string naming the thing at point."
(re-search-backward "^[ \t]*#\\+\\([A-Z_]+\\):.*"
(line-beginning-position) t))
(cons "file-option" (match-string-no-properties 1)))
((string-match "\\`[ \t]*#\\+[a-zA-Z]*\\'" line-to-here)
((string-match "\\`[ \t]*#\\+[a-zA-Z_]*\\'" line-to-here)
(cons "file-option" nil))
((equal (char-before beg) ?\[)
(cons "link" nil))
@ -152,7 +155,7 @@ When completing for #+STARTUP, for example, this function returns
(if (string-match "^#\\+\\([A-Z_]+:?\\)" x)
(match-string 1 x)))
(org-split-string (org-get-current-options) "\n"))
org-additional-option-like-keywords)))))
(copy-sequence org-additional-option-like-keywords))))))
(substring pcomplete-stub 2)))
(defvar org-startup-options)
@ -247,6 +250,8 @@ This needs more work, to handle headings with lots of spaces in them."
lst))
(substring pcomplete-stub 1)))
(defvar org-drawers)
(defun pcomplete/org-mode/drawer ()
"Complete a drawer name."
(let ((spc (save-excursion

View File

@ -1,12 +1,11 @@
;;; org-protocol.el --- Intercept calls from emacsclient to trigger custom actions.
;;
;; Copyright (C) 2008-2012
;; Free Software Foundation, Inc.
;; Copyright (C) 2008-2012 Free Software Foundation, Inc.
;;
;; Author: Bastien Guerry <bzg AT gnu DOT org>
;; Author: Daniel M German <dmg AT uvic DOT org>
;; Author: Sebastian Rose <sebastian_rose AT gmx DOT de>
;; Author: Ross Patterson <me AT rpatterson DOT net>
;; Authors: Bastien Guerry <bzg AT gnu DOT org>
;; Daniel M German <dmg AT uvic DOT org>
;; Sebastian Rose <sebastian_rose AT gmx DOT de>
;; Ross Patterson <me AT rpatterson DOT net>
;; Maintainer: Sebastian Rose <sebastian_rose AT gmx DOT de>
;; Keywords: org, emacsclient, wp

View File

@ -1,3 +1,4 @@
;;; org-special-blocks.el --- handle Org special blocks
;; Copyright (C) 2009-2012 Free Software Foundation, Inc.
;; Author: Chris Gray <chrismgray@gmail.com>

View File

@ -41,8 +41,11 @@
(declare-function org-at-table.el-p "org" ())
(declare-function org-get-indentation "org" (&optional line))
(declare-function org-switch-to-buffer-other-window "org" (&rest args))
(declare-function org-strip-protective-commas "org" (beg end))
(declare-function org-pop-to-buffer-same-window
"org-compat" (&optional buffer-or-name norecord label))
(declare-function org-strip-protective-commas "org" (beg end))
(declare-function org-base-buffer "org" (buffer))
(defcustom org-edit-src-region-extra nil
"Additional regexps to identify regions for editing with `org-edit-src-code'.
@ -213,16 +216,16 @@ buffer."
(interactive)
(unless (eq context 'save)
(setq org-edit-src-saved-temp-window-config (current-window-configuration)))
(let ((mark (and (org-region-active-p) (mark)))
(case-fold-search t)
(info (org-edit-src-find-region-and-lang))
(full-info (org-babel-get-src-block-info 'light))
(org-mode-p (derived-mode-p 'org-mode)) ;; derived-mode-p is reflexive
(beg (make-marker))
(end (make-marker))
(allow-write-back-p (null code))
block-nindent total-nindent ovl lang lang-f single lfmt buffer msg
begline markline markcol line col transmitted-variables)
(let* ((mark (and (org-region-active-p) (mark)))
(case-fold-search t)
(info (org-edit-src-find-region-and-lang))
(full-info (org-babel-get-src-block-info 'light))
(org-mode-p (derived-mode-p 'org-mode)) ;; derived-mode-p is reflexive
(beg (make-marker))
(end (make-marker))
(allow-write-back-p (null code))
block-nindent total-nindent ovl lang lang-f single lfmt buffer msg
begline markline markcol line col transmitted-variables)
(if (not info)
nil
(setq beg (move-marker beg (nth 0 info))
@ -374,6 +377,15 @@ buffer."
"Construct the buffer name for a source editing buffer."
(concat "*Org Src " org-buffer-name "[ " lang " ]*"))
(defun org-src-edit-buffer-p (&optional buffer)
"Test whether BUFFER (or the current buffer if BUFFER is nil)
is a source block editing buffer."
(let ((buffer (org-base-buffer (or buffer (current-buffer)))))
(and (buffer-name buffer)
(string-match "\\`*Org Src " (buffer-name buffer))
(local-variable-p 'org-edit-src-beg-marker buffer)
(local-variable-p 'org-edit-src-end-marker buffer))))
(defun org-edit-src-find-buffer (beg end)
"Find a source editing buffer that is already editing the region BEG to END."
(catch 'exit
@ -685,6 +697,8 @@ the language, a switch telling if the content should be in a single line."
(interactive)
(org-src-in-org-buffer (save-buffer)))
(declare-function org-babel-tangle "ob-tangle" (&optional only-this-block target-file lang))
(defun org-src-tangle (arg)
"Tangle the parent buffer."
(interactive)

View File

@ -2368,7 +2368,7 @@ of the new mark."
(looking-at org-table-auto-recalculate-regexp))
(org-table-recalculate) t))
(defvar modes)
(defvar org-table-modes)
(defsubst org-set-calc-mode (var &optional value)
(if (stringp var)
(setq var (assoc var '(("D" calc-angle-mode deg)
@ -2376,10 +2376,10 @@ of the new mark."
("F" calc-prefer-frac t)
("S" calc-symbolic-mode t)))
value (nth 2 var) var (nth 1 var)))
(if (memq var modes)
(setcar (cdr (memq var modes)) value)
(cons var (cons value modes)))
modes)
(if (memq var org-table-modes)
(setcar (cdr (memq var org-table-modes)) value)
(cons var (cons value org-table-modes)))
org-table-modes)
(defun org-table-eval-formula (&optional arg equation
suppress-align suppress-const
@ -2526,8 +2526,13 @@ not overwrite the stored one."
(replace-match
(save-match-data
(org-table-make-reference
(org-table-get-remote-range
(match-string 1 form) (match-string 2 form))
(let ((rmtrng (org-table-get-remote-range
(match-string 1 form) (match-string 2 form))))
(if duration
(if (listp rmtrng)
(mapcar (lambda(x) (org-table-time-string-to-seconds x)) rmtrng)
(org-table-time-string-to-seconds rmtrng))
rmtrng))
keep-empty numbers lispp))
t t form)))
;; Insert complex ranges
@ -2663,8 +2668,8 @@ in the buffer and column1 and column2 are table column numbers."
; (setq r2 (or r2 r1) c2 (or c2 c1))
(if (not r1) (setq r1 thisline))
(if (not r2) (setq r2 thisline))
(if (not c1) (setq c1 col))
(if (not c2) (setq c2 col))
(if (or (not c1) (= 0 c1)) (setq c1 col))
(if (or (not c2) (= 0 c2)) (setq c2 col))
(if (and (not corners-only)
(or (not rangep) (and (= r1 r2) (= c1 c2))))
;; just one field
@ -2935,7 +2940,7 @@ known that the table will be realigned a little later anyway."
(defun org-table-iterate (&optional arg)
"Recalculate the table until it does not change anymore.
The maximun number of iterations is 10, but you can choose a different value
The maximum number of iterations is 10, but you can choose a different value
with the prefix ARG."
(interactive "P")
(let ((imax (if arg (prefix-numeric-value arg) 10))
@ -2955,6 +2960,7 @@ with the prefix ARG."
(throw 'exit t)))
(error "No convergence after %d iterations" i))))
;;;###autoload
(defun org-table-recalculate-buffer-tables ()
"Recalculate all tables in the current buffer."
(interactive)
@ -2963,6 +2969,7 @@ with the prefix ARG."
(widen)
(org-table-map-tables (lambda () (org-table-recalculate t)) t))))
;;;###autoload
(defun org-table-iterate-buffer-tables ()
"Iterate all tables in the buffer, to converge inter-table dependencies."
(interactive)
@ -4158,7 +4165,7 @@ overwritten, and the table is not marked as requiring realignment."
(looking-at "[^|\n]* +|"))
(let (org-table-may-need-update)
(goto-char (1- (match-end 0)))
(delete-char -1)
(backward-delete-char 1)
(goto-char (match-beginning 0))
(self-insert-command N))
(setq org-table-may-need-update t)

View File

@ -1,6 +1,6 @@
;;; org-xoxo.el --- XOXO export for Org-mode
;; Copyright (C) 2004-2012 Free Software Foundation, Inc.
;; Copyright (C) 2004-2012 Free Software Foundation, Inc.
;; Author: Carsten Dominik <carsten at orgmode dot org>
;; Keywords: outlines, hypermedia, calendar, wp

View File

@ -1,13 +1,13 @@
;;; org.el --- Outline-based notes management and organizer
;; Carstens outline-mode for keeping track of everything.
;; Copyright (C) 2004-2012 Free Software Foundation, Inc.
;; Copyright (C) 2004-2012 Free Software Foundation, Inc.
;;
;; Author: Carsten Dominik <carsten at orgmode dot org>
;; Maintainer: Bastien Guerry <bzg at gnu dot org>
;; Keywords: outlines, hypermedia, calendar, wp
;; Homepage: http://orgmode.org
;; Version: 7.8.03
;; Version: 7.8.09
;;
;; This file is part of GNU Emacs.
;;
@ -76,6 +76,7 @@
(require 'gnus-sum))
(require 'calendar)
(require 'format-spec)
;; Emacs 22 calendar compatibility: Make sure the new variables are available
(when (fboundp 'defvaralias)
@ -208,7 +209,7 @@ identifier."
;;; Version
(defconst org-version "7.8.03"
(defconst org-version "7.8.09"
"The version number of the file org.el.")
;;;###autoload
@ -2230,7 +2231,7 @@ property and include the word \"recursive\" into the value."
(defcustom org-after-todo-state-change-hook nil
"Hook which is run after the state of a TODO item was changed.
The new state (a string with a TODO keyword, or nil) is available in the
Lisp variable `state'."
Lisp variable `org-state'."
:group 'org-todo
:type 'hook)
@ -2268,10 +2269,7 @@ TODO state changes
Also, if a parent has an :ORDERED: property, switching an entry to DONE will
be blocked if any prior sibling is not yet done.
Finally, if the parent is blocked because of ordered siblings of its own,
the child will also be blocked.
This variable needs to be set before org.el is loaded, and you need to
restart Emacs after a change to make the change effective. The only way
to change is while Emacs is running is through the customize interface."
the child will also be blocked."
:set (lambda (var val)
(set var val)
(if val
@ -2843,9 +2841,9 @@ be the favorite working time of John Wiegley :-)"
For example, if `org-extend-today-until' is 8, and it's 4am, then the
\"effective time\" of any timestamps between midnight and 8am will be
23:59 of the previous day."
:group 'boolean
:group 'org-time
:version "24.1"
:type 'integer)
:type 'boolean)
(defcustom org-edit-timestamp-down-means-later nil
"Non-nil means S-down will increase the time in a time stamp.
@ -3947,7 +3945,9 @@ If TABLE-TYPE is non-nil, also check for table.el-type tables."
(unless quietly
(message "Mapping tables: %d%%" (/ (* 100.0 (point)) (buffer-size))))
(beginning-of-line 1)
(when (looking-at org-table-line-regexp)
(when (and (looking-at org-table-line-regexp)
;; Exclude tables in src/example/verbatim/clocktable blocks
(not (org-in-block-p '("src" "example"))))
(save-excursion (funcall function))
(or (looking-at org-table-line-regexp)
(forward-char 1)))
@ -4880,7 +4880,7 @@ This is for getting out of special buffers like remember.")
;; FIXME: Occasionally check by commenting these, to make sure
;; no other functions uses these, forgetting to let-bind them.
(defvar entry)
(defvar last-state)
(defvar org-last-state)
(defvar date)
;; Defined somewhere in this file, but used before definition.
@ -4930,6 +4930,9 @@ sure that we are at the beginning of the line.")
"Matches an headline, putting stars and text into groups.
Stars are put in group 1 and the trimmed body in group 2.")
(defvar bidi-paragraph-direction)
(defvar buffer-face-mode-face)
;;;###autoload
(define-derived-mode org-mode outline-mode "Org"
"Outline-based notes management and organizer, alias
@ -5063,8 +5066,9 @@ The following commands are available:
(set (make-local-variable 'pcomplete-parse-arguments-function)
'org-parse-arguments)
(set (make-local-variable 'pcomplete-termination-string) "")
(set (make-local-variable 'face-remapping-alist)
'((default org-default)))
(when (>= emacs-major-version 23)
(set (make-local-variable 'buffer-face-mode-face) 'org-default)
(buffer-face-mode))
;; If empty file that did not turn on org-mode automatically, make it to.
(if (and org-insert-mode-line-in-empty-file
@ -5253,7 +5257,8 @@ This should be called after the variable `org-link-types' has changed."
"Regular expression for fast time stamp matching.")
(defconst org-ts-regexp-both "[[<]\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} ?[^]\r\n>]*?\\)[]>]"
"Regular expression for fast time stamp matching.")
(defconst org-ts-regexp0 "\\(\\([0-9]\\{4\\}\\)-\\([0-9]\\{2\\}\\)-\\([0-9]\\{2\\}\\) *\\([^]+0-9>\r\n -]*\\)\\( \\([0-9]\\{1,2\\}\\):\\([0-9]\\{2\\}\\)\\)?\\)"
(defconst org-ts-regexp0
"\\(\\([0-9]\\{4\\}\\)-\\([0-9]\\{2\\}\\)-\\([0-9]\\{2\\}\\)\\( +[^]+0-9>\r\n -]+\\)?\\( +\\([0-9]\\{1,2\\}\\):\\([0-9]\\{2\\}\\)\\)?\\)"
"Regular expression matching time strings for analysis.
This one does not require the space after the date, so it can be used
on a string that terminates immediately after the date.")
@ -5433,7 +5438,8 @@ will be prompted for."
(when (re-search-forward
(concat "^[ \t]*#\\+end" (match-string 4) "\\>.*")
nil t) ;; on purpose, we look further than LIMIT
(setq end (match-end 0) end1 (1- (match-beginning 0)))
(setq end (min (point-max) (match-end 0))
end1 (min (point-max) (1- (match-beginning 0))))
(setq block-end (match-beginning 0))
(when quoting
(remove-text-properties beg end
@ -5461,11 +5467,12 @@ will be prompted for."
'(face org-block))) ; end of source block
((not org-fontify-quote-and-verse-blocks))
((string= block-type "quote")
(add-text-properties beg1 (1+ end1) '(face org-quote)))
(add-text-properties beg1 (min (point-max) (1+ end1)) '(face org-quote)))
((string= block-type "verse")
(add-text-properties beg1 (1+ end1) '(face org-verse))))
(add-text-properties beg1 (min (point-max) (1+ end1)) '(face org-verse))))
(add-text-properties beg beg1 '(face org-block-begin-line))
(add-text-properties (1+ end) (1+ end1) '(face org-block-end-line))
(add-text-properties (min (point-max) (1+ end)) (min (point-max) (1+ end1))
'(face org-block-end-line))
t))
((member dc1 '("title:" "author:" "email:" "date:"))
(add-text-properties
@ -5481,7 +5488,7 @@ will be prompted for."
((not (member (char-after beg) '(?\ ?\t)))
;; just any other in-buffer setting, but not indented
(add-text-properties
beg (1+ (match-end 0))
beg (match-end 0)
'(font-lock-fontified t face org-meta-line))
t)
((or (member dc1 '("begin:" "end:" "caption:" "label:"
@ -6353,8 +6360,11 @@ in special contexts.
(org-list-set-item-visibility (point-at-bol) struct 'children)
(org-show-entry)
(org-with-limited-levels (show-children))
(when (memq 'org-cycle-hide-drawers org-cycle-hook)
(org-cycle-hide-drawers 'subtree))
;; FIXME: This slows down the func way too much.
;; How keep drawers hidden in subtree anyway?
;; (when (memq 'org-cycle-hide-drawers org-cycle-hook)
;; (org-cycle-hide-drawers 'subtree))
;; Fold every list in subtree to top-level items.
(when (eq org-cycle-include-plain-lists 'integrate)
(save-excursion
@ -8684,7 +8694,7 @@ For file links, arg negates `org-context-in-file-links'."
(setq link (plist-get org-store-link-plist :link)
desc (or (plist-get org-store-link-plist :description) link)))
((equal (buffer-name) "*Org Edit Src Example*")
((org-src-edit-buffer-p)
(let (label gc)
(while (or (not label)
(save-excursion
@ -10696,7 +10706,8 @@ prefix argument (`C-u C-u C-u C-c C-w')."
(t (concat "Refile subtree \""
heading-text "\" to")))
default-buffer
org-refile-allow-creating-parent-nodes
(and (not (equal '(4) goto))
org-refile-allow-creating-parent-nodes)
goto))))))
(setq file (nth 1 it)
re (nth 2 it)
@ -10854,6 +10865,7 @@ this is used for the GOTO interface."
(org-refile-new-child parent-target child)))
(error "Invalid target location")))))
(declare-function org-string-nw-p "org-macs.el" (s))
(defun org-refile-check-position (refile-pointer)
"Check if the refile pointer matches the readline to which it points."
(let* ((file (nth 1 refile-pointer))
@ -11305,22 +11317,22 @@ For calling through lisp, arg is also interpreted in the following way:
(interpret (nth 1 ass))
(done-word (nth 3 ass))
(final-done-word (nth 4 ass))
(last-state (or this ""))
(org-last-state (or this ""))
(completion-ignore-case t)
(member (member this org-todo-keywords-1))
(tail (cdr member))
(state (cond
((and org-todo-key-trigger
(or (and (equal arg '(4))
(eq org-use-fast-todo-selection 'prefix))
(and (not arg) org-use-fast-todo-selection
(not (eq org-use-fast-todo-selection
'prefix)))))
;; Use fast selection
(org-fast-todo-selection))
((and (equal arg '(4))
(or (not org-use-fast-todo-selection)
(not org-todo-key-trigger)))
(org-state (cond
((and org-todo-key-trigger
(or (and (equal arg '(4))
(eq org-use-fast-todo-selection 'prefix))
(and (not arg) org-use-fast-todo-selection
(not (eq org-use-fast-todo-selection
'prefix)))))
;; Use fast selection
(org-fast-todo-selection))
((and (equal arg '(4))
(or (not org-use-fast-todo-selection)
(not org-todo-key-trigger)))
;; Read a state with completion
(org-icompleting-read
"State: " (mapcar (lambda(x) (list x))
@ -11369,12 +11381,12 @@ For calling through lisp, arg is also interpreted in the following way:
nil)))
(t
(car tail))))
(state (or
(run-hook-with-args-until-success
'org-todo-get-default-hook state last-state)
state))
(next (if state (concat " " state " ") " "))
(change-plist (list :type 'todo-state-change :from this :to state
(org-state (or
(run-hook-with-args-until-success
'org-todo-get-default-hook org-state org-last-state)
org-state))
(next (if org-state (concat " " org-state " ") " "))
(change-plist (list :type 'todo-state-change :from this :to org-state
:position startpos))
dolog now-done-p)
(when org-blocker-hook
@ -11386,16 +11398,16 @@ For calling through lisp, arg is also interpreted in the following way:
(run-hook-with-args-until-failure
'org-blocker-hook change-plist))))
(if (org-called-interactively-p 'interactive)
(error "TODO state change from %s to %s blocked" this state)
(error "TODO state change from %s to %s blocked" this org-state)
;; fail silently
(message "TODO state change from %s to %s blocked" this state)
(message "TODO state change from %s to %s blocked" this org-state)
(throw 'exit nil))))
(store-match-data match-data)
(replace-match next t t)
(unless (pos-visible-in-window-p hl-pos)
(message "TODO state changed to %s" (org-trim next)))
(unless head
(setq head (org-get-todo-sequence-head state)
(setq head (org-get-todo-sequence-head org-state)
ass (assoc head org-todo-kwd-alist)
interpret (nth 1 ass)
done-word (nth 3 ass)
@ -11403,24 +11415,24 @@ For calling through lisp, arg is also interpreted in the following way:
(when (memq arg '(nextset previousset))
(message "Keyword-Set %d/%d: %s"
(- (length org-todo-sets) -1
(length (memq (assoc state org-todo-sets) org-todo-sets)))
(length (memq (assoc org-state org-todo-sets) org-todo-sets)))
(length org-todo-sets)
(mapconcat 'identity (assoc state org-todo-sets) " ")))
(mapconcat 'identity (assoc org-state org-todo-sets) " ")))
(setq org-last-todo-state-is-todo
(not (member state org-done-keywords)))
(setq now-done-p (and (member state org-done-keywords)
(not (member org-state org-done-keywords)))
(setq now-done-p (and (member org-state org-done-keywords)
(not (member this org-done-keywords))))
(and logging (org-local-logging logging))
(when (and (or org-todo-log-states org-log-done)
(not (eq org-inhibit-logging t))
(not (memq arg '(nextset previousset))))
;; we need to look at recording a time and note
(setq dolog (or (nth 1 (assoc state org-todo-log-states))
(setq dolog (or (nth 1 (assoc org-state org-todo-log-states))
(nth 2 (assoc this org-todo-log-states))))
(if (and (eq dolog 'note) (eq org-inhibit-logging 'note))
(setq dolog 'time))
(when (and state
(member state org-not-done-keywords)
(when (and org-state
(member org-state org-not-done-keywords)
(not (member this org-not-done-keywords)))
;; This is now a todo state and was not one before
;; If there was a CLOSED time stamp, get rid of it.
@ -11429,18 +11441,18 @@ For calling through lisp, arg is also interpreted in the following way:
;; It is now done, and it was not done before
(org-add-planning-info 'closed (org-current-effective-time))
(if (and (not dolog) (eq 'note org-log-done))
(org-add-log-setup 'done state this 'findpos 'note)))
(when (and state dolog)
(org-add-log-setup 'done org-state this 'findpos 'note)))
(when (and org-state dolog)
;; This is a non-nil state, and we need to log it
(org-add-log-setup 'state state this 'findpos dolog)))
(org-add-log-setup 'state org-state this 'findpos dolog)))
;; Fixup tag positioning
(org-todo-trigger-tag-changes state)
(org-todo-trigger-tag-changes org-state)
(and org-auto-align-tags (not org-setting-tags) (org-set-tags nil t))
(when org-provide-todo-statistics
(org-update-parent-todo-statistics))
(run-hooks 'org-after-todo-state-change-hook)
(if (and arg (not (member state org-done-keywords)))
(setq head (org-get-todo-sequence-head state)))
(if (and arg (not (member org-state org-done-keywords)))
(setq head (org-get-todo-sequence-head org-state)))
(put-text-property (point-at-bol) (point-at-eol) 'org-todo-head head)
;; Do we need to trigger a repeat?
(when now-done-p
@ -11449,7 +11461,7 @@ For calling through lisp, arg is also interpreted in the following way:
(save-match-data
(setq org-agenda-headline-snapshot-before-repeat
(org-get-heading))))
(org-auto-repeat-maybe state))
(org-auto-repeat-maybe org-state))
;; Fixup cursor location if close to the keyword
(if (and (outline-on-heading-p)
(not (bolp))
@ -11921,7 +11933,7 @@ of repeating deadline/scheduled time stamps to new date.
This function is run automatically after each state change to a DONE state."
;; last-state is dynamically scoped into this function
(let* ((repeat (org-get-repeat))
(aa (assoc last-state org-todo-kwd-alist))
(aa (assoc org-last-state org-todo-kwd-alist))
(interpret (nth 1 aa))
(head (nth 2 aa))
(whata '(("d" . day) ("m" . month) ("y" . year)))
@ -11934,7 +11946,7 @@ This function is run automatically after each state change to a DONE state."
(setq to-state (or (org-entry-get nil "REPEAT_TO_STATE")
org-todo-repeat-to-state))
(unless (and to-state (member to-state org-todo-keywords-1))
(setq to-state (if (eq interpret 'type) last-state head)))
(setq to-state (if (eq interpret 'type) org-last-state head)))
(org-todo to-state)
(when (or org-log-repeat (org-entry-get nil "CLOCK"))
(org-entry-put nil "LAST_REPEAT" (format-time-string
@ -11948,7 +11960,7 @@ This function is run automatically after each state change to a DONE state."
(setq org-log-note-how 'note))
;; Set up for taking a record
(org-add-log-setup 'state (or done-word (car org-done-keywords))
last-state
org-last-state
'findpos org-log-repeat)))
(org-back-to-heading t)
(org-add-planning-info nil nil 'closed)
@ -12816,7 +12828,7 @@ obtain a list of properties. Building the tags list for each entry in such
a file becomes an N^2 operation - but with this variable set, it scales
as N.")
(defun org-scan-tags (action matcher &optional todo-only start-level)
(defun org-scan-tags (action matcher todo-only &optional start-level)
"Scan headline tags with inheritance and produce output ACTION.
ACTION can be `sparse-tree' to produce a sparse tree in the current buffer,
@ -12826,7 +12838,9 @@ this case the return value is a list of all return values from these calls.
MATCHER is a Lisp form to be evaluated, testing if a given set of tags
qualifies a headline for inclusion. When TODO-ONLY is non-nil,
only lines with a TODO keyword are included in the output.
only lines with a not-done TODO keyword are included in the output.
This should be the same variable that was scoped into
and set by `org-make-tags-matcher' when it constructed MATCHER.
START-LEVEL can be a string with asterisks, reducing the scope to
headlines matching this string."
@ -12854,7 +12868,7 @@ headlines matching this string."
(buffer-name (buffer-base-buffer)))))))
(case-fold-search nil)
(org-map-continue-from nil)
lspos tags
lspos tags tags-list
(tags-alist (list (cons 0 org-file-tags)))
(llast 0) rtn rtn1 level category i txt
todo marker entry priority)
@ -12906,7 +12920,8 @@ headlines matching this string."
;; eval matcher only when the todo condition is OK
(and (or (not todo-only) (member todo org-not-done-keywords))
(let ((case-fold-search t)) (eval matcher)))
(let ((case-fold-search t) (org-trust-scanner-tags t))
(eval matcher)))
;; Call the skipper, but return t if it does not skip,
;; so that the `and' form continues evaluating
@ -12995,8 +13010,6 @@ headlines matching this string."
(if (member x org-use-tag-inheritance) x nil))
tags)))))
(defvar todo-only) ;; dynamically scoped
(defun org-match-sparse-tree (&optional todo-only match)
"Create a sparse tree according to tags string MATCH.
MATCH can contain positive and negative selection of tags, like
@ -13043,9 +13056,29 @@ instead of the agenda files."
(org-agenda-files))))))))
(defun org-make-tags-matcher (match)
"Create the TAGS/TODO matcher form for the selection string MATCH."
;; todo-only is scoped dynamically into this function, and the function
;; may change it if the matcher asks for it.
"Create the TAGS/TODO matcher form for the selection string MATCH.
The variable `todo-only' is scoped dynamically into this function; it will be
set to t if the matcher restricts matching to TODO entries,
otherwise will not be touched.
Returns a cons of the selection string MATCH and the constructed
lisp form implementing the matcher. The matcher is to be
evaluated at an Org entry, with point on the headline,
and returns t if the entry matches the
selection string MATCH. The returned lisp form references
two variables with information about the entry, which must be
bound around the form's evaluation: todo, the TODO keyword at the
entry (or nil of none); and tags-list, the list of all tags at the
entry including inherited ones. Additionally, the category
of the entry (if any) must be specified as the text property
'org-category on the headline.
See also `org-scan-tags'.
"
(declare (special todo-only))
(unless (boundp 'todo-only)
(error "org-make-tags-matcher expects todo-only to be scoped in"))
(unless match
;; Get a new match request, with completion
(let ((org-last-tags-completion-table
@ -13162,6 +13195,9 @@ instead of the agenda files."
(setq matcher (if todomatcher
(list 'and tagsmatcher todomatcher)
tagsmatcher))
(when todo-only
(setq matcher (list 'and '(member todo org-not-done-keywords)
matcher)))
(cons match0 matcher)))
(defun org-op-to-function (op &optional stringp)
@ -13435,7 +13471,7 @@ With prefix ARG, realign all tags in headings in the current buffer."
current-tags inherited-tags table
(if org-fast-tag-selection-include-todo
org-todo-key-alist))
(let ((org-add-colon-after-tag-completion t))
(let ((org-add-colon-after-tag-completion (< 1 (length table))))
(org-trim
(org-icompleting-read "Tags: "
'org-tags-completion-function
@ -13875,7 +13911,8 @@ a *different* entry, you cannot use these techniques."
org-done-keywords-for-agenda
org-todo-keyword-alist-for-agenda
org-drawers-for-agenda
org-tag-alist-for-agenda)
org-tag-alist-for-agenda
todo-only)
(cond
((eq match t) (setq matcher t))
@ -13908,7 +13945,7 @@ a *different* entry, you cannot use these techniques."
(progn
(org-prepare-agenda-buffers
(list (buffer-file-name (current-buffer))))
(setq res (org-scan-tags func matcher nil start-level)))
(setq res (org-scan-tags func matcher todo-only start-level)))
;; Get the right scope
(cond
((and scope (listp scope) (symbolp (car scope)))
@ -13929,7 +13966,7 @@ a *different* entry, you cannot use these techniques."
(save-restriction
(widen)
(goto-char (point-min))
(setq res (append res (org-scan-tags func matcher))))))))))
(setq res (append res (org-scan-tags func matcher todo-only))))))))))
res)))
;;;; Properties
@ -14681,7 +14718,7 @@ in the current file."
(org-re-property property)
nil t)
(setq cnt (1+ cnt))
(replace-match ""))
(delete-region (match-beginning 0) (1+ (point-at-eol))))
(message "Property \"%s\" removed from %d entries" property cnt)))))
(defvar org-columns-current-fmt-compiled) ; defined in org-colview.el
@ -14985,8 +15022,9 @@ So these are more for recording a certain time/date."
(defvar org-read-date-final-answer nil)
(defvar org-read-date-analyze-futurep nil)
(defvar org-read-date-analyze-forced-year nil)
(defvar org-read-date-inactive)
(defun org-read-date (&optional with-time to-time from-string prompt
(defun org-read-date (&optional org-with-time to-time from-string prompt
default-time default-input inactive)
"Read a date, possibly a time, and make things smooth for the user.
The prompt will suggest to enter an ISO date, but you can also enter anything
@ -15019,9 +15057,7 @@ plus or minus, it is relative to the date in DEFAULT-TIME. E.g.
+2w --> two weeks from today
++5 --> five days from default date
The function understands only English month and weekday abbreviations,
but this can be configured with the variables `parse-time-months' and
`parse-time-weekdays'.
The function understands only English month and weekday abbreviations.
While prompting, a calendar is popped up - you can also select the
date with the mouse (button 1). The calendar shows a period of three
@ -15042,24 +15078,24 @@ the time/date that is used for everything that is not specified by the
user."
(require 'parse-time)
(let* ((org-time-stamp-rounding-minutes
(if (equal with-time '(16)) '(0 0) org-time-stamp-rounding-minutes))
(if (equal org-with-time '(16)) '(0 0) org-time-stamp-rounding-minutes))
(org-dcst org-display-custom-times)
(ct (org-current-time))
(def (or org-overriding-default-time default-time ct))
(defdecode (decode-time def))
(org-def (or org-overriding-default-time default-time ct))
(org-defdecode (decode-time org-def))
(dummy (progn
(when (< (nth 2 defdecode) org-extend-today-until)
(setcar (nthcdr 2 defdecode) -1)
(setcar (nthcdr 1 defdecode) 59)
(setq def (apply 'encode-time defdecode)
defdecode (decode-time def)))))
(when (< (nth 2 org-defdecode) org-extend-today-until)
(setcar (nthcdr 2 org-defdecode) -1)
(setcar (nthcdr 1 org-defdecode) 59)
(setq org-def (apply 'encode-time org-defdecode)
org-defdecode (decode-time org-def)))))
(calendar-frame-setup nil)
(calendar-setup nil)
(calendar-move-hook nil)
(calendar-view-diary-initially-flag nil)
(calendar-view-holidays-initially-flag nil)
(timestr (format-time-string
(if with-time "%Y-%m-%d %H:%M" "%Y-%m-%d") def))
(if org-with-time "%Y-%m-%d %H:%M" "%Y-%m-%d") org-def))
(prompt (concat (if prompt (concat prompt " ") "")
(format "Date+time [%s]: " timestr)))
ans (org-ans0 "") org-ans1 org-ans2 final)
@ -15072,7 +15108,7 @@ user."
(calendar)
(unwind-protect
(progn
(calendar-forward-day (- (time-to-days def)
(calendar-forward-day (- (time-to-days org-def)
(calendar-absolute-from-gregorian
(calendar-current-date))))
(org-eval-in-calendar nil t)
@ -15159,7 +15195,7 @@ user."
(delete-overlay org-read-date-overlay)
(setq org-read-date-overlay nil)))))
(setq final (org-read-date-analyze ans def defdecode))
(setq final (org-read-date-analyze ans org-def org-defdecode))
(when org-read-date-analyze-forced-year
(message "Year was forced into %s"
@ -15181,10 +15217,9 @@ user."
(nth 2 final) (nth 1 final))
(format "%04d-%02d-%02d" (nth 5 final) (nth 4 final) (nth 3 final))))))
(defvar def)
(defvar defdecode)
(defvar with-time)
(defvar org-read-date-inactive)
(defvar org-def)
(defvar org-defdecode)
(defvar org-with-time)
(defun org-read-date-display ()
"Display the current date prompt interpretation in the minibuffer."
(when org-read-date-display-live
@ -15200,11 +15235,11 @@ user."
(let* ((ans (concat (buffer-substring (point-at-bol) (point-max))
" " (or org-ans1 org-ans2)))
(org-end-time-was-given nil)
(f (org-read-date-analyze ans def defdecode))
(f (org-read-date-analyze ans org-def org-defdecode))
(fmts (if org-dcst
org-time-stamp-custom-formats
org-time-stamp-formats))
(fmt (if (or with-time
(fmt (if (or org-with-time
(and (boundp 'org-time-was-given) org-time-was-given))
(cdr fmts)
(car fmts)))
@ -15222,7 +15257,7 @@ user."
(make-overlay (1- (point-at-eol)) (point-at-eol)))
(org-overlay-display org-read-date-overlay txt 'secondary-selection))))
(defun org-read-date-analyze (ans def defdecode)
(defun org-read-date-analyze (ans org-def org-defdecode)
"Analyze the combined answer of the date prompt."
;; FIXME: cleanup and comment
(let ((nowdecode (decode-time (current-time)))
@ -15234,7 +15269,7 @@ user."
(when (string-match "\\`[ \t]*\\.[ \t]*\\'" ans)
(setq ans "+0"))
(when (setq delta (org-read-date-get-relative ans (current-time) def))
(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)
@ -15328,19 +15363,19 @@ user."
(substring ans (match-end 7))))))
(setq tl (parse-time-string ans)
day (or (nth 3 tl) (nth 3 defdecode))
day (or (nth 3 tl) (nth 3 org-defdecode))
month (or (nth 4 tl)
(if (and org-read-date-prefer-future
(nth 3 tl) (< (nth 3 tl) (nth 3 nowdecode)))
(prog1 (1+ (nth 4 nowdecode)) (setq futurep t))
(nth 4 defdecode)))
(nth 4 org-defdecode)))
year (or (and (not kill-year) (nth 5 tl))
(if (and org-read-date-prefer-future
(nth 4 tl) (< (nth 4 tl) (nth 4 nowdecode)))
(prog1 (1+ (nth 5 nowdecode)) (setq futurep t))
(nth 5 defdecode)))
hour (or (nth 2 tl) (nth 2 defdecode))
minute (or (nth 1 tl) (nth 1 defdecode))
(nth 5 org-defdecode)))
hour (or (nth 2 tl) (nth 2 org-defdecode))
minute (or (nth 1 tl) (nth 1 org-defdecode))
second (or (nth 0 tl) 0)
wday (nth 6 tl))
@ -15411,13 +15446,12 @@ user."
(condition-case nil
(ignore (encode-time second minute hour day month year))
(error
(setq year (nth 5 defdecode))
(setq year (nth 5 org-defdecode))
(setq org-read-date-analyze-forced-year t))))
(setq org-read-date-analyze-futurep futurep)
(list second minute hour day month year)))
(defvar parse-time-weekdays)
(defun org-read-date-get-relative (s today default)
"Check string S for special relative date string.
TODAY and DEFAULT are internal times, for today and for a default.
@ -17109,7 +17143,7 @@ inspection."
(dvifile (concat texfilebase ".dvi"))
(pngfile (concat texfilebase ".png"))
(fnh (if (featurep 'xemacs)
(font-height (get-face-font 'default))
(font-height (face-font 'default))
(face-attribute 'default :height nil)))
(scale (or (plist-get options (if buffer :scale :html-scale)) 1.0))
(dpi (number-to-string (* scale (floor (* 0.9 (if buffer fnh 140.))))))
@ -17138,13 +17172,19 @@ inspection."
(if (not (file-exists-p dvifile))
(progn (message "Failed to create dvi file from %s" texfile) nil)
(condition-case nil
(call-process "dvipng" nil nil nil
(if (featurep 'xemacs)
(call-process "dvipng" nil nil nil
"-fg" fg "-bg" bg
"-D" dpi
;;"-x" scale "-y" scale
"-T" "tight"
"-o" pngfile
dvifile)
(call-process "dvipng" nil nil nil
"-fg" fg "-bg" bg
"-D" dpi
;;"-x" scale "-y" scale
"-T" "tight"
"-o" pngfile
dvifile))
(error nil))
(if (not (file-exists-p pngfile))
(if org-format-latex-signal-error
@ -17220,7 +17260,12 @@ SNIPPETS-P indicates if this is run to create snippet images for HTML."
"Return an rgb color specification for dvipng."
(apply 'format "rgb %s %s %s"
(mapcar 'org-normalize-color
(color-values (face-attribute 'default attr nil)))))
(if (featurep 'xemacs)
(color-rgb-components
(face-property 'default
(cond ((eq attr :foreground) 'foreground)
((eq attr :background) 'background))))
(color-values (face-attribute 'default attr nil))))))
(defun org-normalize-color (value)
"Return string to be used as color value for an RGB component."
@ -17264,7 +17309,7 @@ BEG and END default to the buffer boundaries."
(save-restriction
(widen)
(setq beg (or beg (point-min)) end (or end (point-max)))
(goto-char (point-min))
(goto-char beg)
(let ((re (concat "\\[\\[\\(\\(file:\\)\\|\\([./~]\\)\\)\\([^]\n]+?"
(substring (org-image-file-name-regexp) 0 -2)
"\\)\\]" (if include-linked "" "\\]")))
@ -17347,9 +17392,7 @@ BEG and END default to the buffer boundaries."
(org-defkey org-mode-map "\C-i" 'org-cycle)
(org-defkey org-mode-map [(tab)] 'org-cycle)
(org-defkey org-mode-map [(control tab)] 'org-force-cycle-archived)
(org-defkey org-mode-map [(meta tab)] 'pcomplete)
(org-defkey org-mode-map "\M-\t" 'pcomplete)
(org-defkey org-mode-map "\M-\C-i" 'pcomplete)
;; The following line is necessary under Suse GNU/Linux
(unless (featurep 'xemacs)
(org-defkey org-mode-map [S-iso-lefttab] 'org-shifttab))
@ -17716,7 +17759,7 @@ overwritten, and the table is not marked as requiring realignment."
(looking-at "[^|\n]* |"))
(let (org-table-may-need-update)
(goto-char (1- (match-end 0)))
(delete-char -1)
(backward-delete-char 1)
(goto-char (match-beginning 0))
(self-insert-command N)))
(t
@ -19177,7 +19220,8 @@ See the individual commands for more information."
(org-inside-LaTeX-fragment-p)]
["Insert citation" org-reftex-citation t]
"--"
["Template for BEAMER" org-insert-beamer-options-template t])
["Template for BEAMER" (progn (require 'org-beamer)
(org-insert-beamer-options-template)) t])
"--"
("MobileOrg"
["Push Files and Views" org-mobile-push t]
@ -20475,6 +20519,14 @@ the functionality can be provided as a fall-back.")
(save-excursion (forward-paragraph 1)
(point)))
(fill-paragraph justify) t)))
;; Don't fill schedule/deadline line before a paragraph
((save-excursion (forward-paragraph -1)
(or (looking-at (concat "^[^\n]*" org-scheduled-regexp ".*$"))
(looking-at (concat "^[^\n]*" org-deadline-regexp ".*$"))))
(save-restriction
(narrow-to-region (1+ (match-end 0))
(save-excursion (forward-paragraph 1) (point)))
(fill-paragraph justify) t))
;; Else simply call `fill-paragraph'.
(t nil))))
@ -20644,7 +20696,7 @@ beyond the end of the headline."
(t refpos)))))
((org-at-item-p)
;; Being at an item and not looking at an the item means point
;; was previously moved to beginning of a visual line, whiche
;; was previously moved to beginning of a visual line, which
;; doesn't contain the item. Therefore, do nothing special,
;; just stay here.
(when (looking-at org-list-full-item-re)
@ -20747,7 +20799,7 @@ depending on context."
(not (y-or-n-p "Kill hidden subtree along with headline? ")))
(error "C-k aborted - would kill hidden subtree")))
(call-interactively
(if visual-line-mode 'kill-visual-line 'kill-line)))
(if (and (boundp 'visual-line-mode) visual-line-mode) 'kill-visual-line 'kill-line)))
((looking-at (org-re ".*?\\S-\\([ \t]+\\(:[[:alnum:]_@#%:]+:\\)\\)[ \t]*$"))
(kill-region (point) (match-beginning 1))
(org-set-tags nil t))
@ -20918,11 +20970,12 @@ This version does not only check the character property, but also
If the heading only contains a TODO keyword, it is still still considered
empty."
(and (looking-at "[ \t]*$")
(save-excursion
(beginning-of-line 1)
(let ((case-fold-search nil))
(looking-at org-todo-line-regexp)))
(string= (match-string 3) "")))
(when org-todo-line-regexp
(save-excursion
(beginning-of-line 1)
(let ((case-fold-search nil))
(looking-at org-todo-line-regexp)
(string= (match-string 3) ""))))))
(defun org-at-heading-or-item-p ()
(or (org-at-heading-p) (org-at-item-p)))
@ -21162,6 +21215,7 @@ Stop at the first and last subheadings of a superior heading."
(defun org-show-subtree ()
"Show everything after this heading at deeper levels."
(interactive)
(outline-flag-region
(point)
(save-excursion
@ -21250,8 +21304,8 @@ Show the heading too, if it is currently invisible."
(goto-char (point-max))
(while (re-search-backward re nil t)
(setq level (org-reduced-level (funcall outline-level)))
(when (<= level n)
(looking-at org-complex-heading-regexp)
(when (and (<= level n)
(looking-at org-complex-heading-regexp))
(setq head (org-link-display-format
(org-match-string-no-properties 4))
m (org-imenu-new-marker))

View File

@ -12,10 +12,13 @@ repository]].
The simplest way to run the Org-mode test suite is from the command
line with the following invocation. Note that the paths below are
relative to the base of the Org-mode directory.
#+BEGIN_SRC sh
emacs -Q --batch -l lisp/org.el -l testing/org-test.el \
--eval "(progn (org-reload) (setq org-confirm-babel-evaluate nil))" \
-f org-test-run-batch-tests
#+BEGIN_SRC sh :dir (expand-file-name "..")
# For Emacs earlier than 24, add -L /path/to/ert
emacs -Q --batch \
-L lisp/ -L testing/ -L testing/lisp -l lisp/org.el \
-l lisp/org-id.el -l testing/org-test.el \
--eval "(progn (org-reload) (setq org-confirm-babel-evaluate nil))" \
-f org-test-run-batch-tests
#+END_SRC
The options in the above command are explained below.

View File

@ -18,10 +18,10 @@
(ert-deftest ob-lilypond/assert ()
(should t))
(ert-deftest ob-lilypond/feature-provision ()
(should (featurep 'ob-lilypond)))
(ert-deftest ob-lilypond/check-lilypond-alias ()
(should (fboundp 'lilypond-mode)))
@ -33,21 +33,11 @@
(setq found t))
(setq list (cdr list)))
(should found)))
(ert-deftest ob-lilypond/org-babel-prep-session:lilypond ()
(should-error (org-babel-prep-session:lilypond nil nil))
:type 'error)
(ert-deftest ob-lilypond/ly-version-const ()
(should (boundp 'ly-version)))
(ert-deftest ob-lilypond/ly-version-command ()
(should (equal "ob-lilypond version 0.3" (ly-version)))
(with-temp-buffer
(ly-version t)
(should (equal "ob-lilypond version 0.3"
(buffer-substring (point-min) (point-max))))))
(ert-deftest ob-lilypond/ly-compile-lilyfile ()
(should (equal
`(,(ly-determine-ly-path) ;program
@ -55,7 +45,8 @@
"*lilypond*" ;buffer
t ;display
,(if ly-gen-png "--png" "") ;&rest...
,(if ly-gen-html "--html" "")
,(if ly-gen-html "--html" "")
,(if ly-gen-pdf "--pdf" "")
,(if ly-use-eps "-dbackend=eps" "")
,(if ly-gen-svg "-dbackend=svg" "")
"--output=test-file"
@ -116,6 +107,9 @@
(ert-deftest ob-lilypond/ly-gen-html ()
(should (boundp 'ly-gen-html)))
(ert-deftest ob-lilypond/ly-gen-html ()
(should (boundp 'ly-gen-pdf)))
(ert-deftest ob-lilypond/use-eps ()
(should (boundp 'ly-use-eps)))
@ -168,7 +162,7 @@
(should (equal (+ 238 (length "line 25")) (point)))
(kill-buffer "*lilypond*")
(kill-buffer "ob-lilypond-broken.org"))
(ert-deftest ob-lilypond/ly-mark-error-line ()
(let ((file-name (concat
ly-here
@ -179,7 +173,7 @@
(find-file-other-window file-name)
(ly-mark-error-line file-name line)
(should (equal expected-point-min (point)))
(exchange-point-and-mark)
(should (= expected-point-max (point)))
(kill-buffer (file-name-nondirectory file-name))))
@ -193,7 +187,7 @@
(goto-char (point-min))
(search-forward "error:")
(should (equal 25 (ly-parse-line-num (current-buffer))))))
(ert-deftest ob-lilypond/ly-parse-error-line ()
(let ((ly-file (concat
ly-here
@ -201,7 +195,7 @@
(should (equal "line 20"
(ly-parse-error-line ly-file 20)))
(should (not (ly-parse-error-line ly-file 0)))))
(ert-deftest ob-lilypond/ly-attempt-to-open-pdf ()
(let ((post-tangle ly-display-pdf-post-tangle)
(ly-file (concat
@ -214,7 +208,7 @@
(when (not (file-exists-p pdf-file))
(set-buffer (get-buffer-create (file-name-nondirectory pdf-file)))
(write-file pdf-file))
(should (equal
(should (equal
(concat
(ly-determine-pdf-path) " " pdf-file)
(ly-attempt-to-open-pdf ly-file t)))
@ -296,6 +290,18 @@
(ly-toggle-pdf-display)
(should (not ly-display-pdf-post-tangle))))
(ert-deftest ob-lilypond/ly-toggle-pdf-generation-toggles-flag ()
(if ly-gen-pdf
(progn
(ly-toggle-pdf-generation)
(should (not ly-gen-pdf))
(ly-toggle-pdf-generation)
(should ly-gen-pdf))
(ly-toggle-pdf-generation)
(should ly-gen-pdf)
(ly-toggle-pdf-generation)
(should (not ly-gen-pdf))))
(ert-deftest ob-lilypond/ly-toggle-arrange-mode ()
(if ly-arrange-mode
(progn
@ -319,7 +325,7 @@
(should ly-gen-png)
(ly-toggle-png-generation)
(should (not ly-gen-png))))
(ert-deftest ob-lilypond/ly-toggle-html-generation-toggles-flag ()
(if ly-gen-html
(progn
@ -348,6 +354,7 @@
(should (equal '((:tangle . "yes")
(:noweb . "yes")
(:results . "silent")
(:cache . "yes")
(:comments . "yes"))
(ly-set-header-args t)))
(should (equal '((:results . "file")
@ -359,14 +366,14 @@
(should (equal '((:tangle . "yes")
(:noweb . "yes")
(:results . "silent")
(:cache . "yes")
(:comments . "yes"))
org-babel-default-header-args:lilypond))
(ly-set-header-args nil)
(should (equal '((:results . "file")
(:exports . "results"))
org-babel-default-header-args:lilypond)))
(provide 'test-ob-lilypond)
;;; test-ob-lilypond.el ends here

View File

@ -87,6 +87,24 @@
'((:session . "none") (:results . "replace") (:exports . "results"))
org-babel-default-inline-header-args)))
(ert-deftest ob-test/org-babel-combine-header-arg-lists ()
(let ((results (org-babel-combine-header-arg-lists
'((foo . :any)
(bar)
(baz . ((foo bar) (baz)))
(qux . ((foo bar baz qux)))
(quux . ((foo bar))))
'((bar)
(baz . ((baz)))
(quux . :any)))))
(dolist (pair '((foo . :any)
(bar)
(baz . ((baz)))
(quux . :any)
(qux . ((foo bar baz qux)))))
(should (equal (cdr pair)
(cdr (assoc (car pair) results)))))))
;;; ob-get-src-block-info
(ert-deftest test-org-babel/get-src-block-info-language ()
(org-test-at-marker nil org-test-file-ob-anchor
@ -763,6 +781,35 @@ replacement happens correctly."
* next heading"))
(ert-deftest test-ob/org-babel-results-indented-wrap ()
"Ensure that wrapped results are inserted correction when indented.
If not inserted correctly then the second evaluation will fail
trying to find the :END: marker."
(org-test-with-temp-text
"- indented
#+begin_src sh :results file wrap
echo test.txt
#+end_src"
(org-babel-next-src-block 1)
(org-babel-execute-src-block)
(org-babel-execute-src-block)))
(ert-deftest test-ob/file-desc-header-argument ()
"Test that the :file-desc header argument is used."
(org-test-with-temp-text "#+begin_src emacs-lisp :results file :file-desc bar
\"foo\"
#+end_src
#+begin_src emacs-lisp :results file :file-desc
\"foo\"
#+end_src"
(org-babel-execute-src-block)
(org-babel-next-src-block 1)
(org-babel-execute-src-block)
(goto-char (point-min))
(should (search-forward "[[file:foo][bar]]" nil t))
(should (search-forward "[[file:foo][foo]]" nil t))))
(ert-deftest test-ob/org-babel-remove-result--results-wrap ()
"Test `org-babel-remove-result' with :results wrap."
(test-ob-verify-result-and-removed-result

View File

@ -29,6 +29,7 @@
;;; Tests:
;;;; Headlines
(ert-deftest test-org-element/headline-quote-keyword ()
@ -100,7 +101,283 @@
;;; Navigation tools.
;;;; Example-blocks and Src-blocks
(ert-deftest test-org-element/block-switches ()
"Test `example-block' and `src-block' switches parsing."
(let ((org-coderef-label-format "(ref:%s)"))
;; 1. Test "-i" switch.
(org-test-with-temp-text "#+BEGIN_SRC emacs-lisp\n(+ 1 1)\n#+END_SRC"
(let ((element (org-element-current-element)))
(should-not (org-element-property :preserve-indent element))))
(org-test-with-temp-text "#+BEGIN_SRC emacs-lisp -i\n(+ 1 1)\n#+END_SRC"
(let ((element (org-element-current-element)))
(should (org-element-property :preserve-indent element))))
(org-test-with-temp-text "#+BEGIN_EXAMPLE\nText.\n#+END_EXAMPLE"
(let ((element (org-element-current-element)))
(should-not (org-element-property :preserve-indent element))))
(org-test-with-temp-text "#+BEGIN_EXAMPLE -i\nText.\n#+END_EXAMPLE"
(let ((element (org-element-current-element)))
(should (org-element-property :preserve-indent element))))
;; 2. "-n -r -k" combination should number lines, retain labels but
;; not use them in coderefs.
(org-test-with-temp-text "#+BEGIN_EXAMPLE -n -r -k\nText.\N#+END_EXAMPLE"
(let ((element (org-element-current-element)))
(should (and (org-element-property :number-lines element)
(org-element-property :retain-labels element)
(not (org-element-property :use-labels element))))))
(org-test-with-temp-text
"#+BEGIN_SRC emacs-lisp -n -r -k\n(+ 1 1)\n#+END_SRC"
(let ((element (org-element-current-element)))
(should (and (org-element-property :number-lines element)
(org-element-property :retain-labels element)
(not (org-element-property :use-labels element))))))
;; 3. "-n -r" combination should number-lines remove labels and not
;; use them in coderefs.
(org-test-with-temp-text "#+BEGIN_EXAMPLE -n -r\nText.\n#+END_EXAMPLE"
(let ((element (org-element-current-element)))
(should (and (org-element-property :number-lines element)
(not (org-element-property :retain-labels element))
(not (org-element-property :use-labels element))))))
(org-test-with-temp-text "#+BEGIN_SRC emacs-lisp -n -r\n(+ 1 1)\n#+END_SRC"
(let ((element (org-element-current-element)))
(should (and (org-element-property :number-lines element)
(not (org-element-property :retain-labels element))
(not (org-element-property :use-labels element))))))
;; 4. "-n" or "+n" should number lines, retain labels and use them
;; in coderefs.
(org-test-with-temp-text "#+BEGIN_EXAMPLE -n\nText.\n#+END_EXAMPLE"
(let ((element (org-element-current-element)))
(should (and (org-element-property :number-lines element)
(org-element-property :retain-labels element)
(org-element-property :use-labels element)))))
(org-test-with-temp-text "#+BEGIN_SRC emacs-lisp -n\n(+ 1 1)\n#+END_SRC"
(let ((element (org-element-current-element)))
(should (and (org-element-property :number-lines element)
(org-element-property :retain-labels element)
(org-element-property :use-labels element)))))
(org-test-with-temp-text "#+BEGIN_EXAMPLE +n\nText.\n#+END_EXAMPLE"
(let ((element (org-element-current-element)))
(should (and (org-element-property :number-lines element)
(org-element-property :retain-labels element)
(org-element-property :use-labels element)))))
(org-test-with-temp-text "#+BEGIN_SRC emacs-lisp +n\n(+ 1 1)\n#+END_SRC"
(let ((element (org-element-current-element)))
(should (and (org-element-property :number-lines element)
(org-element-property :retain-labels element)
(org-element-property :use-labels element)))))
;; 5. No switch should not number lines, but retain labels and use
;; them in coderefs.
(org-test-with-temp-text "#+BEGIN_EXAMPLE\nText.\n#+END_EXAMPLE"
(let ((element (org-element-current-element)))
(should (and (not (org-element-property :number-lines element))
(org-element-property :retain-labels element)
(org-element-property :use-labels element)))))
(org-test-with-temp-text "#+BEGIN_SRC emacs-lisp\n(+ 1 1)\n#+END_SRC"
(let ((element (org-element-current-element)))
(should (and (not (org-element-property :number-lines element))
(org-element-property :retain-labels element)
(org-element-property :use-labels element)))))
;; 6. "-r" switch only: do not number lines, remove labels, and
;; don't use labels in coderefs.
(org-test-with-temp-text "#+BEGIN_EXAMPLE -r\nText.\n#+END_EXAMPLE"
(let ((element (org-element-current-element)))
(should (and (not (org-element-property :number-lines element))
(not (org-element-property :retain-labels element))
(not (org-element-property :use-labels element))))))
(org-test-with-temp-text "#+BEGIN_SRC emacs-lisp -r\n(+ 1 1)\n#+END_SRC"
(let ((element (org-element-current-element)))
(should (and (not (org-element-property :number-lines element))
(not (org-element-property :retain-labels element))
(not (org-element-property :use-labels element))))))
;; 7. Recognize coderefs with user-defined syntax.
(org-test-with-temp-text
"#+BEGIN_EXAMPLE -l \"[ref:%s]\"\nText [ref:text]\n#+END_EXAMPLE"
(let ((element (org-element-current-element)))
(should
(equal (org-element-property :label-fmt element) "[ref:%s]"))))
(org-test-with-temp-text
"#+BEGIN_SRC emacs-lisp -l \"[ref:%s]\"\n(+ 1 1) [ref:text]\n#+END_SRC"
(let ((element (org-element-current-element)))
(should
(equal (org-element-property :label-fmt element) "[ref:%s]"))))))
;;;; Footnotes references and definitions
(ert-deftest test-org-element/footnote-reference ()
"Test footnote-reference parsing."
;; 1. Parse a standard reference.
(org-test-with-temp-text "[fn:label]"
(should (equal (org-element-footnote-reference-parser)
'(footnote-reference
(:label "fn:label" :type standard :inline-definition nil
:begin 1 :end 11 :post-blank 0)))))
;; 2. Parse a normalized reference.
(org-test-with-temp-text "[1]"
(should (equal (org-element-footnote-reference-parser)
'(footnote-reference
(:label "1" :type standard :inline-definition nil
:begin 1 :end 4 :post-blank 0)))))
;; 3. Parse an inline reference.
(org-test-with-temp-text "[fn:test:def]"
(should (equal (org-element-footnote-reference-parser)
'(footnote-reference
(:label "fn:test" :type inline :inline-definition ("def")
:begin 1 :end 14 :post-blank 0)))))
;; 4. Parse an anonymous reference.
(org-test-with-temp-text "[fn::def]"
(should (equal (org-element-footnote-reference-parser)
'(footnote-reference
(:label nil :type inline :inline-definition ("def")
:begin 1 :end 10 :post-blank 0)))))
;; 5. Parse nested footnotes.
(org-test-with-temp-text "[fn::def [fn:label]]"
(should
(equal
(org-element-footnote-reference-parser)
'(footnote-reference
(:label nil :type inline
:inline-definition
("def "
(footnote-reference
(:label "fn:label" :type standard :inline-definition nil
:begin 5 :end 15 :post-blank 0)))
:begin 1 :end 21 :post-blank 0)))))
;; 6. Parse adjacent footnotes.
(org-test-with-temp-text "[fn:label1][fn:label2]"
(should
(equal
(org-element-footnote-reference-parser)
'(footnote-reference
(:label "fn:label1" :type standard :inline-definition nil :begin 1
:end 12 :post-blank 0)))))
;; 7. Only properly closed footnotes are recognized as such.
(org-test-with-temp-text "Text [fn:label"
(should-not
(org-element-map
(org-element-parse-buffer) 'footnote-reference 'identity))))
;;;; Granularity
(ert-deftest test-org-element/granularity ()
"Test granularity impact on buffer parsing."
(org-test-with-temp-text "
* Head 1
** Head 2
#+BEGIN_CENTER
Centered paragraph.
#+END_CENTER
Paragraph \\alpha."
;; 1.1. Granularity set to `headline' should parse every headline
;; in buffer, and only them.
(let ((tree (org-element-parse-buffer 'headline)))
(should (= 2 (length (org-element-map tree 'headline 'identity))))
(should-not (org-element-map tree 'paragraph 'identity)))
;; 1.2. Granularity set to `greater-element' should not enter
;; greater elements excepted headlines and sections.
(let ((tree (org-element-parse-buffer 'greater-element)))
(should (= 1 (length (org-element-map tree 'center-block 'identity))))
(should (= 1 (length (org-element-map tree 'paragraph 'identity))))
(should-not (org-element-map tree 'entity 'identity)))
;; 1.3. Granularity set to `element' should enter every
;; greater-element.
(let ((tree (org-element-parse-buffer 'element)))
(should (= 2 (length (org-element-map tree 'paragraph 'identity))))
(should-not (org-element-map tree 'entity 'identity)))
;; 1.4. Granularity set to `object' can see everything.
(let ((tree (org-element-parse-buffer 'object)))
(should (= 1 (length (org-element-map tree 'entity 'identity)))))))
(ert-deftest test-org-element/secondary-string-parsing ()
"Test if granularity correctly toggles secondary strings parsing."
;; 1. With a granularity bigger than `object', no secondary string
;; should be parsed.
;;
;; 1.1. Test with `headline' type.
(org-test-with-temp-text "* Headline"
(let ((headline
(org-element-map (org-element-parse-buffer 'headline) 'headline
'identity
nil
'first-match)))
(should (stringp (org-element-property :title headline)))))
;; 1.2. Test with `item' type.
(org-test-with-temp-text "* Headline\n- tag :: item"
(let ((item (org-element-map (org-element-parse-buffer 'element)
'item
'identity
nil
'first-match)))
(should (stringp (org-element-property :tag item)))))
;; 1.3. Test with `verse-block' type.
(org-test-with-temp-text "#+BEGIN_VERSE\nTest\n#+END_VERSE"
(let ((verse-block (org-element-map (org-element-parse-buffer 'element)
'verse-block
'identity
nil
'first-match)))
(should (stringp (org-element-property :value verse-block)))))
;; 1.4. Test with `inlinetask' type, if avalaible.
(when (featurep 'org-inlinetask)
(let ((org-inlinetask-min-level 15))
(org-test-with-temp-text "*************** Inlinetask"
(let ((inlinetask (org-element-map (org-element-parse-buffer 'element)
'inlinetask
'identity
nil
'first-match)))
(should (stringp (org-element-property :title inlinetask)))))))
;; 2. With a default granularity, secondary strings should be
;; parsed.
(org-test-with-temp-text "* Headline"
(let ((headline
(org-element-map (org-element-parse-buffer) 'headline
'identity
nil
'first-match)))
(should (listp (org-element-property :title headline)))))
;; 3. `org-element-at-point' should never parse a secondary string.
(org-test-with-temp-text "* Headline"
(should (stringp (org-element-property :title (org-element-at-point))))))
;;;; Interpretation.
(ert-deftest test-org-element/interpret-affiliated-keywords ()
"Test if affiliated keywords are correctly interpreted."
;; Interpret simple keywords.
(should
(equal
(org-element-interpret-data
'(org-data nil (paragraph (:name "para") "Paragraph")))
"#+NAME: para\nParagraph\n"))
;; Interpret multiple keywords.
(should
(equal
(org-element-interpret-data
'(org-data nil (paragraph (:attr_ascii ("line1" "line2")) "Paragraph")))
"#+ATTR_ASCII: line1\n#+ATTR_ASCII: line2\nParagraph\n"))
;; Interpret parsed keywords.
(should
(equal
(org-element-interpret-data
'(org-data nil (paragraph (:caption ("caption")) "Paragraph")))
"#+CAPTION: caption\nParagraph\n"))
;; Interpret dual keywords.
(should
(equal
(org-element-interpret-data
'(org-data nil (paragraph (:caption (("long") "short")) "Paragraph")))
"#+CAPTION[short]: long\nParagraph\n")))
;;;; Navigation tools.
(ert-deftest test-org-element/forward-element ()
"Test `org-element-forward' specifications."
@ -312,7 +589,7 @@ Outside."
(org-element-up)
(should (looking-at "\\* Top"))))
(ert-deftest test-org-elemnet/down-element ()
(ert-deftest test-org-element/down-element ()
"Test `org-element-down' specifications."
;; 1. Error when the element hasn't got a recursive type.
(org-test-with-temp-text "Paragraph."
@ -327,6 +604,50 @@ Outside."
(org-element-down)
(should (looking-at "Paragraph"))))
(ert-deftest test-org-element/drag-backward ()
"Test `org-element-drag-backward' specifications."
;; 1. Error when trying to move first element of buffer.
(org-test-with-temp-text "Paragraph 1.\n\nParagraph 2."
(should-error (org-element-drag-backward)))
;; 2. Error when trying to swap nested elements.
(org-test-with-temp-text "#+BEGIN_CENTER\nTest.\n#+END_CENTER"
(forward-line)
(should-error (org-element-drag-backward)))
;; 3. Error when trying to swap an headline element and
;; a non-headline element.
(org-test-with-temp-text "Test.\n* Head 1"
(forward-line)
(should-error (org-element-drag-backward)))
;; 4. Otherwise, swap elements, preserving column and blank lines
;; between elements.
(org-test-with-temp-text "Para1\n\n\nParagraph 2\n\nPara3"
(search-forward "graph")
(org-element-drag-backward)
(should (equal (buffer-string) "Paragraph 2\n\n\nPara1\n\nPara3"))
(should (looking-at " 2"))))
(ert-deftest test-org-element/drag-forward ()
"Test `org-element-drag-forward' specifications."
;; 1. Error when trying to move first element of buffer.
(org-test-with-temp-text "Paragraph 1.\n\nParagraph 2."
(goto-line 3)
(should-error (org-element-drag-forward)))
;; 2. Error when trying to swap nested elements.
(org-test-with-temp-text "#+BEGIN_CENTER\nTest.\n#+END_CENTER"
(forward-line)
(should-error (org-element-drag-forward)))
;; 3. Error when trying to swap a non-headline element and an
;; headline.
(org-test-with-temp-text "Test.\n* Head 1"
(should-error (org-element-drag-forward)))
;; 4. Otherwise, swap elements, preserving column and blank lines
;; between elements.
(org-test-with-temp-text "Paragraph 1\n\n\nPara2\n\nPara3"
(search-forward "graph")
(org-element-drag-forward)
(should (equal (buffer-string) "Para2\n\n\nParagraph 1\n\nPara3"))
(should (looking-at " 1"))))
(provide 'test-org-element)
;;; test-org-element.el ends here

View File

@ -82,10 +82,10 @@ as Org syntax."
#+TITLE: with spaces"
(org-export-get-inbuffer-options))
'(:author
"Me, Myself and I" :creator "Idem" :date "Today"
("Me, Myself and I") :creator "Idem" :date "Today"
:description "Testing\nwith two lines" :email "some@email.org"
:exclude-tags ("noexport" "invisible") :keywords "test" :language "en"
:select-tags ("export") :title "Some title with spaces"))))
:select-tags ("export") :title ("Some title with spaces")))))
(ert-deftest test-org-export/define-macro ()
"Try defining various Org macro using in-buffer #+MACRO: keyword."
@ -232,7 +232,21 @@ text
(transient-mark-mode 1)
(push-mark (point) t t)
(goto-char (point-at-eol))
(should (equal (org-export-as 'test) "text\n")))))
(should (equal (org-export-as 'test) "text\n"))))
;; Subtree with a code block calling another block outside.
(org-test-with-temp-text "
* Head1
#+BEGIN_SRC emacs-lisp :noweb yes :exports results
<<test>>
#+END_SRC
* Head2
#+NAME: test
#+BEGIN_SRC emacs-lisp
\(+ 1 2)
#+END_SRC"
(org-test-with-backend "test"
(forward-line 1)
(should (equal (org-export-as 'test 'subtree) ": 3\n")))))
(ert-deftest test-org-export/export-snippet ()
"Test export snippets transcoding."
@ -313,6 +327,10 @@ body\n")))
(org-test-with-temp-text "* Head1\n* Head2 (note)\n"
(should (equal (org-export-as 'test) "* Head1\n")))))))
;; Footnotes
(ert-deftest test-org-export/footnotes ()
"Test footnotes specifications."
(let ((org-footnote-section nil))
@ -320,10 +338,8 @@ body\n")))
(org-test-with-temp-text
"Text[fn:1] [1] [fn:label:C] [fn::D]\n\n[fn:1] A\n\n[1] B"
(let* ((tree (org-element-parse-buffer))
(info (org-combine-plists
(org-export-initial-options) '(:with-footnotes t))))
(setq info (org-combine-plists
info (org-export-collect-tree-properties tree info 'test)))
(info (org-export-store-footnote-definitions
`(:parse-tree ,tree :with-footnotes t))))
(should
(equal
'((1 . "A") (2 . "B") (3 . "C") (4 . "D"))
@ -340,10 +356,8 @@ body\n")))
(org-test-with-temp-text
"Text[fn:1:A[fn:2]] [fn:3].\n\n[fn:2] B [fn:3] [fn::D].\n\n[fn:3] C."
(let* ((tree (org-element-parse-buffer))
(info (org-combine-plists
(org-export-initial-options) '(:with-footnotes t))))
(setq info (org-combine-plists
info (org-export-collect-tree-properties tree info 'test)))
(info (org-export-store-footnote-definitions
`(:parse-tree ,tree :with-footnotes t))))
(should
(equal
'((1 . "fn:1") (2 . "fn:2") (3 . "fn:3") (4))
@ -359,10 +373,8 @@ body\n")))
;; Hide definitions.
(narrow-to-region (point) (point-at-eol))
(let* ((tree (org-element-parse-buffer))
(info (org-combine-plists
(org-export-initial-options) '(:with-footnotes t))))
(setq info (org-combine-plists
info (org-export-collect-tree-properties tree info 'test)))
(info (org-export-store-footnote-definitions
`(:parse-tree ,tree :with-footnotes t))))
;; Both footnotes should be seen.
(should
(= (length (org-export-collect-footnote-definitions tree info)) 2))))
@ -372,23 +384,35 @@ body\n")))
\[fn:2] B [fn:3] [fn::D].
\[fn:3] C."
(let ((tree (org-element-parse-buffer))
(info (org-combine-plists
(org-export-initial-options) '(:with-footnotes t))))
(setq info (org-combine-plists
info (org-export-collect-tree-properties tree info 'test)))
(let* ((tree (org-element-parse-buffer))
(info (org-export-store-footnote-definitions
`(:parse-tree ,tree :with-footnotes t))))
(should (= (length (org-export-collect-footnote-definitions tree info))
4))))))
4))))
;; 5. Test export of footnotes defined outside parsing scope.
(org-test-with-temp-text "[fn:1] Out of scope
* Title
Paragraph[fn:1]"
(org-test-with-backend "test"
(flet ((org-test-footnote-reference
(fn-ref contents info)
(org-element-interpret-data
(org-export-get-footnote-definition fn-ref info))))
(forward-line)
(should (equal "ParagraphOut of scope\n"
(org-export-as 'test 'subtree))))))))
;;; Links
(ert-deftest test-org-export/fuzzy-links ()
"Test fuzz link export specifications."
"Test fuzzy link export specifications."
;; 1. Links to invisible (keyword) targets should be ignored.
(org-test-with-temp-text
"Paragraph.\n#+TARGET: Test\n[[Test]]"
(let* ((tree (org-element-parse-buffer))
(info (org-combine-plists (org-export-initial-options))))
(setq info (org-combine-plists
info (org-export-collect-tree-properties tree info 'test)))
(info (org-export-collect-tree-properties tree nil 'test)))
(should-not
(org-element-map
tree 'link
@ -399,9 +423,7 @@ body\n")))
(org-test-with-temp-text
"Paragraph.\n* Head1\n* Head2\n* Head3\n[[Head2]]"
(let* ((tree (org-element-parse-buffer))
(info (org-combine-plists (org-export-initial-options))))
(setq info (org-combine-plists
info (org-export-collect-tree-properties tree info 'test)))
(info (org-export-collect-tree-properties tree nil 'test)))
(should
;; Note: Headline's number is in fact a list of numbers.
(equal '(2)
@ -414,9 +436,7 @@ body\n")))
(org-test-with-temp-text
"- Item1\n - Item11\n - <<test>>Item12\n- Item2\n\n\n[[test]]"
(let* ((tree (org-element-parse-buffer))
(info (org-combine-plists (org-export-initial-options))))
(setq info (org-combine-plists
info (org-export-collect-tree-properties tree info 'test)))
(info (org-export-collect-tree-properties tree nil 'test)))
(should
;; Note: Item's number is in fact a list of numbers.
(equal '(1 2)
@ -430,9 +450,7 @@ body\n")))
(org-test-with-temp-text
"Paragraph[1][2][fn:lbl3:C<<target>>][[test]][[target]]\n[1] A\n\n[2] <<test>>B"
(let* ((tree (org-element-parse-buffer))
(info (org-combine-plists (org-export-initial-options))))
(setq info (org-combine-plists
info (org-export-collect-tree-properties tree info 'test)))
(info (org-export-collect-tree-properties tree nil 'test)))
(should
(equal '(2 3)
(org-element-map
@ -445,9 +463,7 @@ body\n")))
(org-test-with-temp-text
"#+NAME: tbl1\n|1|2|\n#+NAME: tbl2\n|3|4|\n#+NAME: tbl3\n|5|6|\n[[tbl2]]"
(let* ((tree (org-element-parse-buffer))
(info (org-combine-plists (org-export-initial-options))))
(setq info (org-combine-plists
info (org-export-collect-tree-properties tree info 'test)))
(info (org-export-collect-tree-properties tree nil 'test)))
(should
(= 2
(org-element-map
@ -460,9 +476,7 @@ body\n")))
(org-test-with-temp-text
"* Head1\n* Head2\nParagraph<<target>>\n* Head3\n[[target]]"
(let* ((tree (org-element-parse-buffer))
(info (org-combine-plists (org-export-initial-options))))
(setq info (org-combine-plists
info (org-export-collect-tree-properties tree info 'test)))
(info (org-export-collect-tree-properties tree nil 'test)))
(should
(equal '(2)
(org-element-map
@ -470,3 +484,148 @@ body\n")))
(lambda (link)
(org-export-get-ordinal
(org-export-resolve-fuzzy-link link info) info)) info t))))))
(defun test-org-export/resolve-coderef ()
"Test `org-export-resolve-coderef' specifications."
(let ((org-coderef-label-format "(ref:%s)"))
;; 1. A link to a "-n -k -r" block returns line number.
(org-test-with-temp-text
"#+BEGIN_EXAMPLE -n -k -r\nText (ref:coderef)\n#+END_EXAMPLE"
(let ((tree (org-element-parse-buffer)))
(should
(= (org-export-resolve-coderef "coderef" `(:parse-tree ,tree)) 1))))
(org-test-with-temp-text
"#+BEGIN_SRC emacs-lisp -n -k -r\n(+ 1 1) (ref:coderef)\n#+END_SRC"
(let ((tree (org-element-parse-buffer)))
(should
(= (org-export-resolve-coderef "coderef" `(:parse-tree ,tree)) 1))))
;; 2. A link to a "-n -r" block returns line number.
(org-test-with-temp-text
"#+BEGIN_EXAMPLE -n -r\nText (ref:coderef)\n#+END_EXAMPLE"
(let ((tree (org-element-parse-buffer)))
(should
(= (org-export-resolve-coderef "coderef" `(:parse-tree ,tree)) 1))))
(org-test-with-temp-text
"#+BEGIN_SRC emacs-lisp -n -r\n(+ 1 1) (ref:coderef)\n#+END_SRC"
(let ((tree (org-element-parse-buffer)))
(should
(= (org-export-resolve-coderef "coderef" `(:parse-tree ,tree)) 1))))
;; 3. A link to a "-n" block returns coderef.
(org-test-with-temp-text
"#+BEGIN_SRC emacs-lisp -n\n(+ 1 1) (ref:coderef)\n#+END_SRC"
(let ((tree (org-element-parse-buffer)))
(should
(equal (org-export-resolve-coderef "coderef" `(:parse-tree ,tree))
"coderef"))))
(org-test-with-temp-text
"#+BEGIN_EXAMPLE -n\nText (ref:coderef)\n#+END_EXAMPLE"
(let ((tree (org-element-parse-buffer)))
(should
(equal (org-export-resolve-coderef "coderef" `(:parse-tree ,tree))
"coderef"))))
;; 4. A link to a "-r" block returns line number.
(org-test-with-temp-text
"#+BEGIN_SRC emacs-lisp -r\n(+ 1 1) (ref:coderef)\n#+END_SRC"
(let ((tree (org-element-parse-buffer)))
(should
(= (org-export-resolve-coderef "coderef" `(:parse-tree ,tree)) 1))))
(org-test-with-temp-text
"#+BEGIN_EXAMPLE -r\nText (ref:coderef)\n#+END_EXAMPLE"
(let ((tree (org-element-parse-buffer)))
(should
(= (org-export-resolve-coderef "coderef" `(:parse-tree ,tree)) 1))))
;; 5. A link to a block without a switch returns coderef.
(org-test-with-temp-text
"#+BEGIN_SRC emacs-lisp\n(+ 1 1) (ref:coderef)\n#+END_SRC"
(let ((tree (org-element-parse-buffer)))
(should
(equal (org-export-resolve-coderef "coderef" `(:parse-tree ,tree))
"coderef"))))
(org-test-with-temp-text
"#+BEGIN_EXAMPLE\nText (ref:coderef)\n#+END_EXAMPLE"
(let ((tree (org-element-parse-buffer)))
(should
(equal (org-export-resolve-coderef "coderef" `(:parse-tree ,tree))
"coderef"))))
;; 6. Correctly handle continued line numbers. A "+n" switch
;; should resume numbering from previous block with numbered
;; lines, ignoring blocks not numbering lines in the process.
;; A "-n" switch resets count.
(org-test-with-temp-text "
#+BEGIN_EXAMPLE -n
Text.
#+END_EXAMPLE
#+BEGIN_SRC emacs-lisp
\(- 1 1)
#+END_SRC
#+BEGIN_SRC emacs-lisp +n -r
\(+ 1 1) (ref:addition)
#+END_SRC
#+BEGIN_EXAMPLE -n -r
Another text. (ref:text)
#+END_EXAMPLE"
(let* ((tree (org-element-parse-buffer))
(info `(:parse-tree ,tree)))
(should (= (org-export-resolve-coderef "addition" info) 2))
(should (= (org-export-resolve-coderef "text" info) 1))))
;; 7. Recognize coderef with user-specified syntax.
(org-test-with-temp-text
"#+BEGIN_EXAMPLE -l \"[ref:%s]\"\nText. [ref:text]\n#+END_EXAMPLE"
(let ((tree (org-element-parse-buffer)))
(should (equal (org-export-resolve-coderef "text" `(:parse-tree ,tree))
"text"))))))
;;; Src-block and example-block
(ert-deftest test-org-export/unravel-code ()
"Test `org-export-unravel-code' function."
(let ((org-coderef-label-format "(ref:%s)"))
;; 1. Code without reference.
(org-test-with-temp-text "#+BEGIN_EXAMPLE\n(+ 1 1)\n#+END_EXAMPLE"
(should (equal (org-export-unravel-code (org-element-current-element))
'("(+ 1 1)\n"))))
;; 2. Code with reference.
(org-test-with-temp-text
"#+BEGIN_EXAMPLE\n(+ 1 1) (ref:test)\n#+END_EXAMPLE"
(should (equal (org-export-unravel-code (org-element-current-element))
'("(+ 1 1)\n" (1 . "test")))))
;; 3. Code with user-defined reference.
(org-test-with-temp-text
"#+BEGIN_EXAMPLE -l \"[ref:%s]\"\n(+ 1 1) [ref:test]\n#+END_EXAMPLE"
(should (equal (org-export-unravel-code (org-element-current-element))
'("(+ 1 1)\n" (1 . "test")))))
;; 4. Code references keys are relative to the current block.
(org-test-with-temp-text "
#+BEGIN_EXAMPLE -n
\(+ 1 1)
#+END_EXAMPLE
#+BEGIN_EXAMPLE +n
\(+ 2 2)
\(+ 3 3) (ref:one)
#+END_EXAMPLE"
(goto-line 5)
(should (equal (org-export-unravel-code (org-element-current-element))
'("(+ 2 2)\n(+ 3 3)\n" (2 . "one")))))
;; 5. Free up comma-protected lines.
;;
;; 5.1. In an Org source block, every line is protected.
(org-test-with-temp-text
"#+BEGIN_SRC org\n,* Test\n,# comment\n,Text\n#+END_SRC"
(should (equal (org-export-unravel-code (org-element-current-element))
'("* Test\n# comment\nText\n"))))
;; 5.2. In other blocks, only headlines, comments and keywords are
;; protected.
(org-test-with-temp-text
"#+BEGIN_EXAMPLE\n,* Headline\n, * Not headline\n,Keep\n#+END_EXAMPLE"
(should (equal (org-export-unravel-code (org-element-current-element))
'("* Headline\n, * Not headline\n,Keep\n"))))))
(provide 'test-org-export)
;;; test-org-export.el end here

View File

@ -109,7 +109,6 @@ Body[1]
\[4] Inline
\[5] Anonymous
")))
;; 2.2. Put each footnote definition at the end of the section
;; containing its first reference.
@ -256,7 +255,6 @@ Signature")))))
\[fn:2] B
\[fn:label] C
")))))