0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-09-22 22:10:42 +00:00

Merge branch 'master' into max-sticky-agenda

This commit is contained in:
Max Mikhanosha 2012-03-03 18:31:32 -05:00
commit f969141505
11 changed files with 424 additions and 133 deletions

View file

@ -1855,35 +1855,33 @@ contextual information."
;; (defun org-odt-format-source-code-or-example-colored
;; (lines lang caption textareap cols rows num cont rpllbl fmt))
(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)
(setq lines
(concat
"<pre class=\"example\">\n"
(cond
(textareap
(concat
(format "<p>\n<textarea cols=\"%d\" rows=\"%d\">"
cols rows)
lines "</textarea>\n</p>\n"))
(t
(with-temp-buffer
(insert lines)
(goto-char (point-min))
(while (re-search-forward "[<>&]" nil t)
(replace-match (cdr (assq (char-before)
'((?&."&amp;")(?<."&lt;")(?>."&gt;"))))
t t))
(buffer-string))))
"</pre>\n"))
(unless textareap
(setq lines (org-export-number-lines lines 1 1 num cont rpllbl fmt)))
;; (when (string-match "\\(\\`<[^>]*>\\)\n" lines)
;; (setq lines (replace-match "\\1" t nil lines)))
lines)
(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)
@ -1925,7 +1923,11 @@ contextual information."
lines "</div>")))
(unless textareap
(setq lines (org-export-number-lines lines 1 1 num cont rpllbl fmt)))
(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)))
@ -2008,7 +2010,7 @@ INDENT was the original indentation of the block."
"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)))
(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
@ -2590,8 +2592,14 @@ INFO is a plist holding contextual information. See
;; Coderef: replace link with the reference name or the
;; equivalent line number.
((string= type "coderef")
(format (org-export-get-coderef-format path (or desc ""))
(org-export-resolve-coderef path info)))
(let ((fragment (concat "coderef-" path)))
(format "<a href=#%s %s>%s</a>" fragment
(format (concat "class=\"coderef\""
" onmouseover=\"CodeHighlightOn(this, '%s');\""
" onmouseout=\"CodeHighlightOff(this, '%s');\"")
fragment fragment)
(format (org-export-get-coderef-format path (or desc "%s"))
(org-export-resolve-coderef path info)))))
;; Link type is handled by a special function.
((functionp (setq protocol (nth 2 (assoc type org-link-protocols))))
(funcall protocol (org-link-unescape path) desc 'html))
@ -2808,7 +2816,7 @@ 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))
(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

View file

@ -566,7 +566,7 @@ styles congruent with the ODF-1.2 specification."
(let ((xref-format "text"))
(when (numberp desc)
(setq desc (format "%d" desc) xref-format "number"))
(org-e-odt-format-tags
(org-e-odt-format-tags-simple
'("<text:bookmark-ref text:reference-format=\"%s\" text:ref-name=\"%s\">" .
"</text:bookmark-ref>")
desc xref-format href)))
@ -575,7 +575,7 @@ styles congruent with the ODF-1.2 specification."
'("<draw:a xlink:type=\"simple\" xlink:href=\"%s\" %s>" . "</draw:a>")
desc href (or attr "")))
(t
(org-e-odt-format-tags
(org-e-odt-format-tags-simple
'("<text:a xlink:type=\"simple\" xlink:href=\"%s\" %s>" . "</text:a>")
desc href (or attr "")))))
@ -625,17 +625,18 @@ styles congruent with the ODF-1.2 specification."
(defun org-e-odt-format-source-line-with-line-number-and-label
(line rpllbl num fontifier par-style)
(let ((keep-label (not (numberp rpllbl)))
(ref (org-find-text-property-in-string 'org-coderef line)))
(setq line (concat line (and keep-label ref (format "(%s)" ref))))
(line fontifier par-style)
(let (;; (keep-label (not (numberp rpllbl)))
(ref (org-find-text-property-in-string 'org-coderef line))
(num (org-find-text-property-in-string 'org-loc line)))
(setq line (concat line (and ref (format "(%s)" ref))))
(setq line (funcall fontifier line))
(when ref
(setq line (org-e-odt-format-target line (concat "coderef-" ref))))
(setq line (org-e-odt-format-stylized-paragraph par-style line))
(if (not num) line
(org-e-odt-format-tags '("<text:list-item>" . "</text:list-item>") line))))
(org-e-odt-format-tags
'("<text:list-item>" . "</text:list-item>") line))))
(defun org-e-odt-format-source-code-or-example-plain
(lines lang caption textareap cols rows num cont rpllbl fmt)
@ -649,7 +650,7 @@ off."
(lambda (line)
(incf i)
(org-e-odt-format-source-line-with-line-number-and-label
line rpllbl num 'org-e-odt-encode-plain-text
line 'org-e-odt-encode-plain-text
(if (= i line-count) "OrgFixedWidthBlockLastLine"
"OrgFixedWidthBlock")))
lines "\n")))
@ -701,8 +702,7 @@ Update styles.xml with styles that were collected as part of
(goto-char (match-beginning 0))
(insert "\n<!-- Org Htmlfontify Styles -->\n" styles "\n")))))
(defun org-e-odt-format-source-code-or-example-colored
(lines lang caption textareap cols rows num cont rpllbl fmt)
(defun org-e-odt-format-source-code-or-example-colored (lines lang caption)
"Format source or example blocks using `htmlfontify-string'.
Use this routine when `org-export-e-odt-fontify-srcblocks' option
is turned on."
@ -740,37 +740,37 @@ is turned on."
(lambda (line)
(incf i)
(org-e-odt-format-source-line-with-line-number-and-label
line rpllbl num 'htmlfontify-string
line 'htmlfontify-string
(if (= i line-count) "OrgSrcBlockLastLine" "OrgSrcBlock")))
lines "\n")))))
(defun org-e-odt-format-source-code-or-example (lines lang
&optional
caption textareap
cols rows num cont
rpllbl fmt)
&optional caption ; FIXME
)
"Format source or example blocks for export.
Use `org-e-odt-format-source-code-or-example-plain' or
`org-e-odt-format-source-code-or-example-colored' depending on the
value of `org-export-e-odt-fontify-srcblocks."
(setq ;; lines (org-export-number-lines
;; lines 0 0 num cont rpllbl fmt 'preprocess) FIXME
lines (funcall
(or (and org-export-e-odt-fontify-srcblocks
(or (featurep 'htmlfontify)
;; htmlfontify.el was introduced in Emacs 23.2
;; So load it with some caution
(require 'htmlfontify nil t))
(fboundp 'htmlfontify-string)
'org-e-odt-format-source-code-or-example-colored)
'org-e-odt-format-source-code-or-example-plain)
lines lang caption textareap cols rows num cont rpllbl fmt))
(if (not num) lines
(let ((extra (format " text:continue-numbering=\"%s\""
(if cont "true" "false"))))
(org-e-odt-format-tags
'("<text:list text:style-name=\"OrgSrcBlockNumberedLine\"%s>"
. "</text:list>") lines extra))))
;; lines 0 0 num cont rpllbl fmt 'preprocess) FIXME
lines (funcall
(or (and org-export-e-odt-fontify-srcblocks
(or (featurep 'htmlfontify)
;; htmlfontify.el was introduced in Emacs 23.2
;; So load it with some caution
(require 'htmlfontify nil t))
(fboundp 'htmlfontify-string)
'org-e-odt-format-source-code-or-example-colored)
'org-e-odt-format-source-code-or-example-plain)
lines lang caption))
(let ((num (org-find-text-property-in-string 'org-loc lines)))
(if (not num) lines
(let* ((cont (not (equal num 1)))
(extra (format " text:continue-numbering=\"%s\""
(if cont "true" "false"))))
(org-e-odt-format-tags
'("<text:list text:style-name=\"OrgSrcBlockNumberedLine\"%s>"
. "</text:list>") lines extra)))))
(defun org-e-odt-remap-stylenames (style-name)
(or
@ -1341,6 +1341,9 @@ ATTR is a string of other attributes of the a element."
(defun org-e-odt-format-tags (tag text &rest args)
(apply 'org-e-odt-format-tags-1 tag text "\n" "\n" args))
(defun org-e-odt-format-tags-simple (tag text &rest args)
(apply 'org-e-odt-format-tags-1 tag text nil nil args))
(defun org-e-odt-init-outfile ()
(unless (executable-find "zip")
;; Not at all OSes ship with zip by default
@ -3440,7 +3443,7 @@ contextual information."
"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)))
(value (org-export-handle-code example-block info nil nil t)))
(org-e-odt--wrap-label
example-block (org-e-odt-format-source-code-or-example value nil))))
@ -3989,8 +3992,11 @@ INFO is a plist holding contextual information. See
;; Coderef: replace link with the reference name or the
;; equivalent line number.
((string= type "coderef")
(format (org-export-get-coderef-format path (or desc ""))
(org-export-resolve-coderef path info)))
(let* ((fmt (org-export-get-coderef-format path (or desc "%s")))
(res (org-export-resolve-coderef path info))
(org-e-odt-suppress-xref nil)
(href (org-xml-format-href (concat "#coderef-" path))))
(format fmt (org-e-odt-format-link res href))))
;; Link type is handled by a special function.
((functionp (setq protocol (nth 2 (assoc type org-link-protocols))))
(funcall protocol (org-link-unescape path) desc 'html))
@ -4178,7 +4184,7 @@ 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))
(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

View file

@ -13749,8 +13749,11 @@ used.
The @code{:cache} header argument controls the use of in-buffer caching of
the results of evaluating code blocks. It can be used to avoid re-evaluating
unchanged code blocks. This header argument can have one of two
values: @code{yes} or @code{no}.
unchanged code blocks. Note that the @code{:cache} header argument will not
attempt to cache results when the @code{:session} header argument is used,
because the results of the code block execution may be stored in the session
outside of the Org-mode buffer. The @code{:cache} header argument can have
one of two values: @code{yes} or @code{no}.
@itemize @bullet
@item @code{no}

View file

@ -66,14 +66,14 @@ To add files to this list use the `org-babel-lob-ingest' command."
(defconst org-babel-block-lob-one-liner-regexp
(concat
"^\\([ \t]*\\)#\\+call:[ \t]+\\([^\(\)\n]+?\\)\\(\\[\\(.*\\)\\]\\|\\(\\)\\)"
"\(\\([^\n]*\\)\)\\(\\[.+\\]\\|\\)[ \t]*\\(\\([^\n]*\\)\\)?")
"^\\([ \t]*?\\)#\\+call:[ \t]+\\([^\(\)\n]+?\\)\\(\\[\\(.*\\)\\]\\|\\(\\)\\)"
"\(\\([^\n]*?\\)\)\\(\\[.+\\]\\|\\)[ \t]*\\(\\([^\n]*\\)\\)?")
"Regexp to match non-inline calls to predefined source block functions.")
(defconst org-babel-inline-lob-one-liner-regexp
(concat
"\\([^\n]*\\)call_\\([^\(\)\n]+?\\)\\(\\[\\(.*\\)\\]\\|\\(\\)\\)"
"\(\\([^\n]*\\)\)\\(\\[\\(.*?\\)\\]\\)?")
"\\([^\n]*?\\)call_\\([^\(\)\n]+?\\)\\(\\[\\(.*?\\)\\]\\|\\(\\)\\)"
"\(\\([^\n]*?\\)\)\\(\\[\\(.*?\\)\\]\\)?")
"Regexp to match inline calls to predefined source block functions.")
(defconst org-babel-lob-one-liner-regexp

View file

@ -1534,9 +1534,10 @@ buffer or nil if no such result exists."
(catch 'is-a-code-block
(when (re-search-forward
(concat org-babel-result-regexp
"[ \t]" (regexp-quote name) "[ \t\n\f\v\r]") nil t)
"[ \t]" (regexp-quote name) "[ \t\n\f\v\r]+") nil t)
(when (and (string= "name" (downcase (match-string 1)))
(or (looking-at org-babel-src-block-regexp)
(or (beginning-of-line 1)
(looking-at org-babel-src-block-regexp)
(looking-at org-babel-multi-line-header-regexp)))
(throw 'is-a-code-block (org-babel-find-named-result name (point))))
(beginning-of-line 0) (point)))))
@ -1996,7 +1997,8 @@ file's directory then expand relative links."
(defun org-babel-examplize-region (beg end &optional results-switches)
"Comment out region using the inline '==' or ': ' org example quote."
(interactive "*r")
(flet ((chars-between (b e) (string-match "[\\S]" (buffer-substring b e))))
(flet ((chars-between (b e)
(not (string-match "^[\\s]*$" (buffer-substring b e)))))
(if (or (chars-between (save-excursion (goto-char beg) (point-at-bol)) beg)
(chars-between end (save-excursion (goto-char end) (point-at-eol))))
(save-excursion

View file

@ -124,10 +124,6 @@
(defvar date) ;; dynamically scoped from Org
(defvar name) ;; dynamically scoped from Org
;; Support for version 2.35
(eval-after-load 'bbdb
'(defvar org-bbdb-old (fboundp 'bbdb-record-get-field-internal)))
;; Customization
(defgroup org-bbdb-anniversaries nil
@ -207,7 +203,7 @@ date year)."
;; This is BBDB, we make this link!
(let* ((rec (bbdb-current-record))
(name (bbdb-record-name rec))
(company (if org-bbdb-old
(company (if (fboundp 'bbdb-record-getprop)
(bbdb-record-getprop rec 'company)
(car (bbdb-record-get-field rec 'organization))))
(link (org-make-link "bbdb:" name)))
@ -228,10 +224,10 @@ italicized, in all other cases it is left unchanged."
(defun org-bbdb-open (name)
"Follow a BBDB link to NAME."
(require 'bbdb)
(require 'bbdb-com)
(let ((inhibit-redisplay (not debug-on-error))
(bbdb-electric-p nil))
(if org-bbdb-old
(if (fboundp 'bbdb-name)
(org-bbdb-open-old)
(org-bbdb-open-new))))

View file

@ -676,8 +676,7 @@ Additional note on `org-footnote-insert-pos-for-preprocessor':
;; If EXPORT-PROPS isn't nil, also add `org-footnote'
;; property to it, so it can be easily recognized by
;; exporters.
(if sort-only
(goto-char (nth 2 ref))
(if sort-only (goto-char (nth 2 ref))
(delete-region (nth 1 ref) (nth 2 ref))
(goto-char (nth 1 ref))
(let ((new-ref (format "[%d]" marker)))
@ -706,7 +705,10 @@ Additional note on `org-footnote-insert-pos-for-preprocessor':
'(:todo-keywords t :tags t :priority t))))
(org-export-preprocess-string def parameters))
def)
inlinep pos) ref-table)))))
;; Reference beginning position is a marker
;; to preserve it during further buffer
;; modifications.
inlinep (copy-marker pos)) ref-table)))))
;; 2. Find and remove the footnote section, if any. Also
;; determine where footnotes shall be inserted (INS-POINT).
(cond
@ -722,10 +724,9 @@ Additional note on `org-footnote-insert-pos-for-preprocessor':
(skip-chars-backward " \r\t\n")
(forward-line)
(unless (bolp) (newline)))
;; No footnote section set: Footnotes will be added before next
;; headline.
((eq major-mode 'org-mode)
(org-with-limited-levels (outline-next-heading)))
;; No footnote section set: Footnotes will be added at the end
;; of the section containing their first reference.
((eq major-mode 'org-mode))
(t
;; Remove any left-over tag in the buffer, if one is set up.
(when org-footnote-tag-for-non-org-mode-files
@ -758,18 +759,21 @@ Additional note on `org-footnote-insert-pos-for-preprocessor':
(lambda (x)
(cond
;; When only sorting, ignore inline footnotes.
((and sort-only (nth 3 x)) nil)
;; Also clear position marker.
((and sort-only (nth 3 x))
(set-marker (nth 4 x) nil) nil)
;; No definition available: provide one.
((not (nth 2 x))
(append (butlast x 2)
(list (format "DEFINITION NOT FOUND: %s" (car x))
(nth 3 x))))
(append
(list (car x) (nth 1 x)
(format "DEFINITION NOT FOUND: %s" (car x)))
(nthcdr 3 x)))
(t x)))
ref-table)))
(setq ref-table (nreverse ref-table))
;; 4. Remove left-over definitions in the buffer.
(mapc (lambda (x) (unless (nth 3 x)
(org-footnote-delete-definitions (car x))))
(mapc (lambda (x)
(unless (nth 3 x) (org-footnote-delete-definitions (car x))))
ref-table)
;; 5. Insert the footnotes again in the buffer, at the
;; appropriate spot.
@ -791,11 +795,6 @@ Additional note on `org-footnote-insert-pos-for-preprocessor':
(skip-chars-backward " \t\n\r")
(delete-region (point) ins-point)
(unless (bolp) (newline))
;; Keep one blank line between footnotes and signature.
(when (and (derived-mode-p 'message-mode)
(save-excursion
(re-search-forward message-signature-separator nil t)))
(open-line 1))
(when org-footnote-tag-for-non-org-mode-files
(insert "\n" org-footnote-tag-for-non-org-mode-files "\n")))
((and org-footnote-section (not export-props))
@ -808,6 +807,8 @@ Additional note on `org-footnote-insert-pos-for-preprocessor':
(insert
(mapconcat
(lambda (x)
;; Clean markers.
(set-marker (nth 4 x) nil)
(format "\n[%s] %s" (nth (if sort-only 0 1) x) (nth 2 x)))
ref-table "\n"))
(unless (eobp) (insert "\n\n"))
@ -816,30 +817,18 @@ Additional note on `org-footnote-insert-pos-for-preprocessor':
(when export-props (setq org-export-footnotes-seen ref-table)))
;; Each footnote definition has to be inserted at the end of
;; the section where its first reference belongs.
((not sort-only)
(t
(mapc
(lambda (x)
(goto-char (nth 4 x))
(let ((pos (nth 4 x)))
(goto-char pos)
;; Clean marker.
(set-marker pos nil))
(org-footnote-goto-local-insertion-point)
(insert (format "\n[%s] %s\n" (nth 1 x) (nth 2 x))))
ref-table))
;; Else, insert each definition at the end of the section
;; containing their first reference. Happens only in Org files
;; with no special footnote section, and only when doing
;; sorting.
(t (mapc 'org-insert-footnote-reference-near-definition
ref-table))))))
(defun org-insert-footnote-reference-near-definition (entry)
"Find first reference of footnote ENTRY and insert the definition there.
ENTRY is (fn-label num-mark definition)."
(when (car entry)
(goto-char (point-min))
(let ((ref (org-footnote-get-next-reference (car entry))))
(when ref
(goto-char (nth 2 ref))
(org-footnote-goto-local-insertion-point)
(insert (format "\n[%s] %s\n" (car entry) (nth 2 entry)))))))
(insert (format "\n[%s] %s\n"
(if sort-only (car x) (nth 1 x))
(nth 2 x))))
ref-table))))))
(defun org-footnote-goto-local-insertion-point ()
"Find insertion point for footnote, just before next outline heading."

View file

@ -1032,6 +1032,36 @@ Line 3\"
* next heading"))
(ert-deftest test-ob/results-do-not-replace-code-blocks ()
(org-test-with-temp-text "Block two has a space after the name.
#+name: foo
#+begin_src emacs-lisp
1
#+end_src emacs-lisp
#+name: foo
#+begin_src emacs-lisp
2
#+end_src
#+name: foo
#+begin_src emacs-lisp
3
#+end_src
#+RESULTS: foo
: foo
"
(dolist (num '(1 2 3))
;; execute the block
(goto-char (point-min))
(org-babel-next-src-block num) (org-babel-execute-src-block)
;; check the results
(goto-char (point-max))
(move-beginning-of-line 0)
(should (looking-at (format ": %d" num))))))
(provide 'test-ob)
;;; test-ob ends here

View file

@ -0,0 +1,260 @@
;;; test-org-footnote.el --- Tests for org-footnote.el
;; Copyright (C) 2012 Nicolas Goaziou
;; Author: Nicolas Goaziou <n.goaziou at gmail dot com>
;; 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/>.
;;; Code:
(ert-deftest test-org-footnote/normalize-in-org ()
"Test specifications for `org-footnote-normalize' in an Org buffer."
;; 1. With a non-nil `org-footnote-section'.
(let ((org-footnote-section "Footnotes")
(org-blank-before-new-entry '((heading . auto))))
;; 1.1. Normalize each type of footnote: standard, labelled,
;; numbered, inline, anonymous.
(org-test-with-temp-text
"Paragraph[fn:1][fn:label][1][fn:inline:Inline][fn::Anonymous]
* Footnotes
\[fn:1] Standard
\[fn:label] Labelled
\[1] Numbered"
(org-footnote-normalize)
(should
(equal (buffer-string)
"Paragraph[1][2][3][4][5]
* Footnotes
\[1] Standard
\[2] Labelled
\[3] Numbered
\[4] Inline
\[5] Anonymous
")))
;; 1.2. When no footnote section is present, create it. Follow
;; `org-blank-before-new-entry' specifications when doing so.
(org-test-with-temp-text "Paragraph[fn:1]\n\n[fn:1] Definition"
(org-footnote-normalize)
(should (equal (buffer-string)
"Paragraph[1]\n\n* Footnotes\n\n[1] Definition")))
(org-test-with-temp-text "Paragraph[fn:1]\n* Head1\n[fn:1] Definition"
(let ((org-blank-before-new-entry '((heading))))
(org-footnote-normalize))
(should (equal (buffer-string)
"Paragraph[1]\n* Head1\n* Footnotes\n\n[1] Definition")))
;; 1.3. When the footnote section is misplaced, move it at the end
;; of the buffer.
(org-test-with-temp-text "* Head1
Body[fn:1]
* Footnotes
\[fn:1] Definition 1
* Head2"
(org-footnote-normalize)
(should
(equal (buffer-string)
"* Head1
Body[1]
* Head2
* Footnotes
\[1] Definition 1"))))
;; 2. With a nil `org-footnote-section'.
(let ((org-footnote-section nil))
;; 2.1. Normalize each type of footnote: standard, labelled,
;; numbered, inline, anonymous.
(org-test-with-temp-text
"Paragraph[fn:1][fn:label][1][fn:inline:Inline][fn::Anonymous]
\[fn:1] Standard
\[fn:label] Labelled
\[1] Numbered"
(org-footnote-normalize)
(should
(equal (buffer-string)
"Paragraph[1][2][3][4][5]
\[1] Standard
\[2] Labelled
\[3] Numbered
\[4] Inline
\[5] Anonymous
")))
;; 2.2. Put each footnote definition at the end of the section
;; containing its first reference.
(org-test-with-temp-text
"* Head 1
Text[fn:1:Def1]
* Head 2
Text[fn:1]
* Head 3
Text[fn:2:Def2]"
(org-footnote-normalize)
(should
(equal (buffer-string)
"* Head 1
Text[1]
\[1] Def1
* Head 2
Text[1]
* Head 3
Text[2]
\[2] Def2
")))))
(ert-deftest test-org-footnote/normalize-outside-org ()
"Test `org-footnote-normalize' specifications for buffers not in Org mode."
;; 1. In a non-Org buffer, footnotes definitions are always put at
;; its end.
(let ((org-footnote-tag-for-non-org-mode-files nil))
(with-temp-buffer
(insert "Paragraph[fn:1][fn:label][1][fn:inline:Inline][fn::Anonymous]
\[fn:1] Standard
\[fn:label] Labelled
\[1] Numbered
Some additional text.")
(org-footnote-normalize)
(should
(equal (buffer-string)
"Paragraph[1][2][3][4][5]
Some additional text.
\[1] Standard
\[2] Labelled
\[3] Numbered
\[4] Inline
\[5] Anonymous"))))
;; 2. With a special tag.
(let ((org-footnote-tag-for-non-org-mode-files "Footnotes:"))
;; 2.1. The tag must be inserted before the footnotes, separated
;; from the rest of the text with a blank line.
(with-temp-buffer
(insert "Paragraph[fn:1][fn::Anonymous]
\[fn:1] Standard
Some additional text.")
(org-footnote-normalize)
(should
(equal (buffer-string)
"Paragraph[1][2]
Some additional text.
Footnotes:
\[1] Standard
\[2] Anonymous")))
;; 2.2. Any tag already inserted in the buffer should be removed
;; prior to footnotes insertion.
(with-temp-buffer
(insert "Text[fn:1]
Footnotes:
Additional text.
Footnotes:
\[fn:1] Definition")
(org-footnote-normalize)
(should
(equal (buffer-string)
"Text[1]
Additional text.
Footnotes:
\[1] Definition"))))
;; 3. As an exception, in `message-mode' buffer, if a signature is
;; present, insert footnotes before it.
(let ((org-footnote-tag-for-non-org-mode-files nil)
(message-signature-separator "^-- $"))
(with-temp-buffer
(insert "Body[fn::def]
--
Fake signature
--
Signature")
(let ((major-mode 'message-mode)) (org-footnote-normalize))
(should
(equal (buffer-string)
"Body[1]
--
Fake signature
\[1] def
--
Signature")))))
(ert-deftest test-org-footnote/sort ()
"Test footnotes definitions sorting."
(let ((org-footnote-section nil))
(org-test-with-temp-text
"Text[fn:1][fn::inline][fn:2][fn:label]
\[fn:label] C
\[fn:1] A
\[fn:2] B"
(org-footnote-normalize 'sort)
(should
(equal (buffer-string)
"Text[fn:1][fn::inline][fn:2][fn:label]
\[fn:1] A
\[fn:2] B
\[fn:label] C
")))))
(provide 'test-org-footnote)
;;; test-org-footnote.el ends here

View file

@ -103,13 +103,13 @@ http://article.gmane.org/gmane.emacs.orgmode/21459/"
;; 1. Fuzzy link goes in priority to a matching target.
(org-test-with-temp-text
"#+TARGET: Test\n#+NAME: Test\n|a|b|\n<<Test>>\n* Test\n[[Test]]"
(goto-line 4)
(goto-line 6)
(org-open-at-point)
(should (looking-at "<<Test>>")))
;; 2. Fuzzy link should then go to a matching target keyword.
(org-test-with-temp-text
"#+NAME: Test\n|a|b|\n#+TARGET: Test\n* Test\n[[Test]]"
(goto-line 4)
(goto-line 5)
(org-open-at-point)
(should (looking-at "#\\+TARGET: Test")))
;; 3. Then fuzzy link points to an element with a given name.

View file

@ -30,6 +30,8 @@
;;;; Code:
(require 'org-test-ob-consts)
(let* ((org-test-dir (expand-file-name
(file-name-directory
(or load-file-name buffer-file-name))))
@ -224,12 +226,8 @@ otherwise place the point at the beginning of the inserted text."
(defjump org-test-jump
(("lisp/\\1.el" . "testing/lisp/test-\\1.el")
("lisp/\\1.el" . "testing/lisp/\\1.el/test.*.el")
("contrib/lisp/\\1.el" . "testing/contrib/lisp/test-\\1.el")
("contrib/lisp/\\1.el" . "testing/contrib/lisp/\\1.el/test.*.el")
("testing/lisp/test-\\1.el" . "lisp/\\1.el")
("testing/lisp/\\1.el" . "lisp/\\1.el/test.*.el")
("testing/contrib/lisp/test-\\1.el" . "contrib/lisp/\\1.el")
("testing/contrib/lisp/test-\\1.el" . "contrib/lisp/\\1.el/test.*.el"))
("testing/lisp/\\1.el" . "lisp/\\1.el/test.*.el"))
(concat org-base-dir "/")
"Jump between org-mode files and their tests."
(lambda (path)
@ -313,8 +311,7 @@ otherwise place the point at the beginning of the inserted text."
:expected-result :failed (should nil))))))))
(directory-files base 'full
"^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*\\.el$"))))
(rld (expand-file-name "lisp" org-test-dir))
(rld (expand-file-name "lisp" (expand-file-name "contrib" org-test-dir)))))
(rld (expand-file-name "lisp" org-test-dir))))
(defun org-test-current-defun ()
"Test the current function."