Export: Make switches for literal examples work in include files.

When including s file in example or src markup, you can now also
specify the switches for code references and line numbering that work
also when directly adding SRC or EXAMPLE blocks.

Reported by Manish.
This commit is contained in:
Carsten Dominik 2009-01-08 12:10:47 +01:00
parent bb5567cb8f
commit c170516b5f
4 changed files with 26 additions and 7 deletions

View File

@ -26,6 +26,13 @@
Thanks to Alan Davis for driving this change.
*** Include files can now also process switches
The example and src switches like =-n= can now also be added
to inlcude file statements:
: #+INCLUDE "~/.emacs" erc emacs-lisp -n -r
* Version 6.17
** Overview

View File

@ -72,7 +72,8 @@
;; Needs to be on a line by itself, similarly the </src> tag.
;; Will be translated into Org's BEGIN_SRC construct.
;;
;; <include file="FILE" markup="MARKUP" lang="LANG" prefix="str" prefix1="str">
;; <include file="FILE" markup="MARKUP" lang="LANG"
;; prefix="str" prefix1="str" switches="-n -r">
;; Needs to be on a line by itself.
;; Will be translated into Org's #+INCLUDE construct.
;;
@ -187,8 +188,10 @@ The is done in the entire buffer."
markup (downcase (plist-get info :markup))
lang (plist-get info :lang)
prefix (plist-get info :prefix)
prefix1 (plist-get info :prefix1))
prefix1 (plist-get info :prefix1)
switches (plist-get info :switches))
(setq rpl "#+INCLUDE")
(setq rpl (concat rpl " " (prin1-to-string file)))
(when markup
(setq rpl (concat rpl " " markup))
(when (and (equal markup "src") lang)
@ -196,7 +199,9 @@ The is done in the entire buffer."
(when prefix
(setq rpl (concat rpl " :prefix " (prin1-to-string prefix))))
(when prefix1
(setq rpl (concat rpl " :prefix1 " (prin1-to-string prefix1))))))
(setq rpl (concat rpl " :prefix1 " (prin1-to-string prefix1))))
(when switches
(setq rpl (concat rpl " " switches)))))
(when rpl
(goto-char (plist-get info :match-beginning))
(delete-region (point-at-bol) (plist-get info :match-end))

View File

@ -1,5 +1,8 @@
2009-01-08 Carsten Dominik <carsten.dominik@gmail.com>
* org-exp.el (org-export-handle-include-files): Fetch switches and
put them into the BEGIN statement.
* org-timer.el (org-timer-mode-line-string): New variable.
* org-clock.el (org-clock-mode-line-map): Renamed from

View File

@ -2234,7 +2234,7 @@ TYPE must be a string, any of:
(defun org-export-handle-include-files ()
"Include the contents of include files, with proper formatting."
(let ((case-fold-search t)
params file markup lang start end prefix prefix1)
params file markup lang start end prefix prefix1 switches)
(goto-char (point-min))
(while (re-search-forward "^#\\+INCLUDE:?[ \t]+\\(.*\\)" nil t)
(setq params (read (concat "(" (match-string 1) ")"))
@ -2242,7 +2242,9 @@ TYPE must be a string, any of:
prefix1 (org-get-and-remove-property 'params :prefix1)
file (org-symname-or-string (pop params))
markup (org-symname-or-string (pop params))
lang (org-symname-or-string (pop params)))
lang (and (member markup '("src" "SRC"))
(org-symname-or-string (pop params)))
switches (mapconcat '(lambda (x) (format "%s" x)) params " "))
(delete-region (match-beginning 0) (match-end 0))
(if (or (not file)
(not (file-exists-p file))
@ -2250,9 +2252,11 @@ TYPE must be a string, any of:
(insert (format "CANNOT INCLUDE FILE %s" file))
(when markup
(if (equal (downcase markup) "src")
(setq start (format "#+begin_src %s\n" (or lang "fundamental"))
(setq start (format "#+begin_src %s %s\n"
(or lang "fundamental")
(or switches ""))
end "#+end_src")
(setq start (format "#+begin_%s\n" markup)
(setq start (format "#+begin_%s %s\n" markup switches)
end (format "#+end_%s" markup))))
(insert (or start ""))
(insert (org-get-file-contents (expand-file-name file) prefix prefix1))