From d555545b48008b98999d0e5cba58474585b58b49 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Tue, 27 Apr 2010 06:58:48 +0200 Subject: [PATCH 1/5] Docbook export: Implement ordered lists with offset --- lisp/ChangeLog | 5 +++++ lisp/org-docbook.el | 21 ++++++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 3b97d17c8..49a8b4e4f 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2010-04-27 Carsten Dominik + + * org-docbook.el (org-export-as-docbook): Implement ordered + lists starting at some offset. + 2010-04-26 Carsten Dominik * org.el (org-link-types, org-open-at-point): Add doi links. diff --git a/lisp/org-docbook.el b/lisp/org-docbook.el index bb8d048bf..d7ea4b7fe 100644 --- a/lisp/org-docbook.el +++ b/lisp/org-docbook.el @@ -533,7 +533,7 @@ publishing directory." table-buffer table-orig-buffer ind item-type starter didclose rpl path attr caption label desc descp desc1 desc2 link - fnc item-tag + fnc item-tag initial-number footref-seen footnote-list id-file ) @@ -998,7 +998,11 @@ publishing directory." starter (if (match-beginning 2) (substring (match-string 2 line) 0 -1)) line (substring line (match-beginning 5)) - item-tag nil) + item-tag nil + initial-number nil) + (if (string-match "\\`\\[@start:\\([0-9]+\\)\\][ \t]?" line) + (setq initial-number (match-string 1 line) + line (replace-match "" t t line))) (if (and starter (string-match "\\(.*?\\) ::[ \t]*" line)) (setq item-type "d" item-tag (match-string 1 line) @@ -1031,7 +1035,18 @@ publishing directory." (org-export-docbook-close-para-maybe) (insert (cond ((equal item-type "u") "\n\n") - ((equal item-type "o") "\n\n") + ((equal item-type "o") + ;; Check for a specific start number. If it + ;; is specified, we use the ``override'' + ;; attribute of element to pass the + ;; info to DocBook. We could also use the + ;; ``startingnumber'' attribute of element + ;; , but the former works on both + ;; DocBook 5.0 and prior versions. + (if initial-number + (format "\n\n" + initial-number) + "\n\n")) ((equal item-type "d") (format "\n%s\n" item-tag)))) ;; For DocBook, we need to open a para right after tag From 91749e6594043762bd5a191b38fe50a2c33abfa9 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Mon, 26 Apr 2010 18:53:39 +0200 Subject: [PATCH 2/5] Make the inclusion of packages for snippet creation optional --- lisp/ChangeLog | 13 +++++++ lisp/org-latex.el | 2 +- lisp/org.el | 95 +++++++++++++++++++++++++++++++---------------- 3 files changed, 78 insertions(+), 32 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 49a8b4e4f..914fbb013 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,18 @@ 2010-04-27 Carsten Dominik + * org.el (org-set-packages-alist, org-get-packages-alist): New + function. + (org-export-latex-default-packages-alist) + (org-export-latex-packages-alist): Add extra flag to + each package, indicating if it should be used for snippets. + (org-create-formula-image): Add the snippet argument. + (org-splice-latex-header): New argument SNIPPET-P, pass it + through to `org-latex-packages-to-string'. + (org-latex-packages-to-string): New argument SNIPPET-P. + + * org-latex.el (org-export-latex-make-header): Add the snippet + argument. + * org-docbook.el (org-export-as-docbook): Implement ordered lists starting at some offset. diff --git a/lisp/org-latex.el b/lisp/org-latex.el index 9850e9bcd..2ec41ea5c 100644 --- a/lisp/org-latex.el +++ b/lisp/org-latex.el @@ -1147,7 +1147,7 @@ OPT-PLIST is the options plist for current buffer." (org-splice-latex-header (org-export-apply-macros-in-string org-export-latex-header) org-export-latex-default-packages-alist - org-export-latex-packages-alist + org-export-latex-packages-alist nil (org-export-apply-macros-in-string (plist-get opt-plist :latex-header-extra))) ;; append another special variable diff --git a/lisp/org.el b/lisp/org.el index 992050418..0f6929624 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -2302,7 +2302,7 @@ a double prefix argument to a time-stamp command like `C-c .' or `C-c !', and by using a prefix arg to `S-up/down' to specify the exact number of minutes to shift." :group 'org-time - :get '(lambda (var) ; Make sure all entries have 5 elements + :get '(lambda (var) ; Make sure both elements are there (if (integerp (default-value var)) (list (default-value var) 5) (default-value var))) @@ -2958,25 +2958,42 @@ will be appended." (defvar org-format-latex-header-extra nil) +(defun org-set-packages-alist (var val) + "Set the packages alist and make sure it has 3 elements per entry." + (set var (mapcar (lambda (x) + (if (and (consp x) (= (length x) 2)) + (list (car x) (nth 1 x) t) + x)) + val))) + +(defun org-get-packages-alist (var) + + "Get the packages alist and make sure it has 3 elements per entry." + (mapcar (lambda (x) + (if (and (consp x) (= (length x) 2)) + (list (car x) (nth 1 x) t) + x)) + (default-value var))) + ;; The following variables are defined here because is it also used ;; when formatting latex fragments. Originally it was part of the ;; LaTeX exporter, which is why the name includes "export". (defcustom org-export-latex-default-packages-alist - '(("AUTO" "inputenc") - ("T1" "fontenc") - ("" "fixltx2e") - ("" "graphicx") - ("" "longtable") - ("" "float") - ("" "wrapfig") - ("" "soul") - ("" "t1enc") - ("" "textcomp") - ("" "marvosym") - ("" "wasysym") - ("" "latexsym") - ("" "amssymb") - ("" "hyperref") + '(("AUTO" "inputenc" t) + ("T1" "fontenc" t) + ("" "fixltx2e" nil) + ("" "graphicx" t) + ("" "longtable" nil) + ("" "float" nil) + ("" "wrapfig" nil) + ("" "soul" t) + ("" "t1enc" t) + ("" "textcomp" t) + ("" "marvosym" t) + ("" "wasysym" t) + ("" "latexsym" t) + ("" "amssymb" t) + ("" "hyperref" nil) "\\tolerance=1000" ) "Alist of default packages to be inserted in the header. @@ -2997,31 +3014,42 @@ to function properly. Therefore you should not modify this variable unless you know what you are doing. The one reason to change it anyway is that you might be loading some other package that conflicts with one of the default packages. -Each cell is of the format \( \"options\" \"package\" \)." +Each cell is of the format \( \"options\" \"package\" snippet-flag\). +If SNIPPET-FLAG is t, the package also needs to be included when +compiling LaTeX snippets into images for inclusion into HTML." :group 'org-export-latex + :set 'org-set-packages-alist + :get 'org-get-packages-alist :type '(repeat (choice - (string :tag "A line of LaTeX") (list :tag "options/package pair" (string :tag "options") - (string :tag "package"))))) + (string :tag "package") + (boolean :tag "Snippet")) + (string :tag "A line of LaTeX")))) (defcustom org-export-latex-packages-alist nil "Alist of packages to be inserted in every LaTeX the header. These will be inserted after `org-export-latex-default-packages-alist'. -Each cell is of the format \( \"options\" \"package\" \). -Make sure that you only lis packages here which: +Each cell is of the format \( \"options\" \"package\" snippet-flag \). +SNIPPET-FLAG, when t, indicates that this package is also needed when +turning LaTeX snippets into images for inclusion into HTML. +Make sure that you only list packages here which: - you want in every file - do not conflict with the default packages in `org-export-latex-default-packages-alist' - do not conflict with the setup in `org-format-latex-header'." :group 'org-export-latex + :set 'org-set-packages-alist + :get 'org-get-packages-alist :type '(repeat (choice - (string :tag "A line of LaTeX") (list :tag "options/package pair" (string :tag "options") - (string :tag "package"))))) + (string :tag "package") + (boolean :tag "Snippet")) + (string :tag "A line of LaTeX")))) + (defgroup org-appearance nil "Settings for Org-mode appearance." @@ -15332,7 +15360,7 @@ Some of the options can be changed using the variable (insert (org-splice-latex-header org-format-latex-header org-export-latex-default-packages-alist - org-export-latex-packages-alist + org-export-latex-packages-alist t org-format-latex-header-extra)) (insert "\n\\begin{document}\n" string "\n\\end{document}\n") (require 'org-latex) @@ -15366,7 +15394,7 @@ Some of the options can be changed using the variable (delete-file (concat texfilebase e))) pngfile)))) -(defun org-splice-latex-header (tpl def-pkg pkg &optional extra) +(defun org-splice-latex-header (tpl def-pkg pkg snippets-p &optional extra) "Fill a LaTeX header template TPL. In the template, the following place holders will be recognized: @@ -15381,19 +15409,22 @@ For backward compatibility, if both the positive and the negative place holder is missing, the positive one (without the \"NO-\") will be assumed to be present at the end of the template. DEF-PKG and PKG are assumed to be alists of options/packagename lists. -EXTRA is a string." +EXTRA is a string. +SNIPPETS-P indicates if this is run to create snippet images for HTML." (let (rpl (end "")) (if (string-match "^[ \t]*\\[\\(NO-\\)?DEFAULT-PACKAGES\\][ \t]*\n?" tpl) (setq rpl (if (or (match-end 1) (not def-pkg)) - "" (org-latex-packages-to-string def-pkg t)) + "" (org-latex-packages-to-string def-pkg snippets-p t)) tpl (replace-match rpl t t tpl)) - (if def-pkg (setq end (org-latex-packages-to-string def-pkg)))) + (if def-pkg (setq end (org-latex-packages-to-string def-pkg snippets-p)))) (if (string-match "\\[\\(NO-\\)?PACKAGES\\][ \t]*\n?" tpl) (setq rpl (if (or (match-end 1) (not pkg)) - "" (org-latex-packages-to-string pkg t)) + "" (org-latex-packages-to-string pkg snippets-p t)) tpl (replace-match rpl t t tpl)) - (if pkg (setq end (concat end "\n" (org-latex-packages-to-string pkg))))) + (if pkg (setq end + (concat end "\n" + (org-latex-packages-to-string pkg snippets-p))))) (if (string-match "\\[\\(NO-\\)?EXTRA\\][ \t]*\n?" tpl) (setq rpl (if (or (match-end 1) (not extra)) @@ -15406,11 +15437,13 @@ EXTRA is a string." (concat tpl "\n" end) tpl))) -(defun org-latex-packages-to-string (pkg &optional newline) +(defun org-latex-packages-to-string (pkg &optional snippets-p newline) "Turn an alist of packages into a string with the \\usepackage macros." (setq pkg (mapconcat (lambda(p) (cond ((stringp p) p) + ((and snippets-p (>= (length p) 3) (not (nth 2 p))) + (format "%% Package %s omitted" (cadr p))) ((equal "" (car p)) (format "\\usepackage{%s}" (cadr p))) (t From 6cb53826696ad42e286ef7ef31e2f8c44483edb5 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Tue, 27 Apr 2010 07:57:22 +0200 Subject: [PATCH 3/5] Fix a bug with item demotion M-right did not work on the last item of a list. Report by Matti de Craene. --- lisp/ChangeLog | 3 +++ lisp/org-list.el | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 914fbb013..c7c4c0966 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,8 @@ 2010-04-27 Carsten Dominik + * org-list.el (org-end-of-item-text-before-children): Also do + the right thing at the end of a file. + * org.el (org-set-packages-alist, org-get-packages-alist): New function. (org-export-latex-default-packages-alist) diff --git a/lisp/org-list.el b/lisp/org-list.el index 34deff5ee..6f2205636 100644 --- a/lisp/org-list.el +++ b/lisp/org-list.el @@ -605,8 +605,9 @@ Assumes that the cursor is in the first ine of an item." (min (save-excursion (org-end-of-item) (point)) (save-excursion (goto-char (point-at-eol)) - (re-search-forward (concat "^" (org-item-re t)) nil t) - (match-beginning 0))))) + (if (re-search-forward (concat "^" (org-item-re t)) nil 'move) + (match-beginning 0) + (point-max)))))) (defun org-next-item () "Move to the beginning of the next item in the current plain list. From 0d4883f7dee7968e91d7c87fcab1957afec87afd Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Tue, 27 Apr 2010 08:11:03 +0200 Subject: [PATCH 4/5] Fix typos and add customization group for footnotes Patch by Michael Fornius --- lisp/ChangeLog | 4 ++++ lisp/org-footnote.el | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index c7c4c0966..181143e07 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,9 @@ 2010-04-27 Carsten Dominik + * org-footnote.el (org-footnote): New group. + (org-footnote-section) + (org-footnote-tag-for-non-org-mode-files): Fix typos. + * org-list.el (org-end-of-item-text-before-children): Also do the right thing at the end of a file. diff --git a/lisp/org-footnote.el b/lisp/org-footnote.el index 84cd7b313..0f7168b30 100644 --- a/lisp/org-footnote.el +++ b/lisp/org-footnote.el @@ -65,6 +65,11 @@ (org-re "^\\(\\[\\([0-9]+\\|fn:[-_[:word:]]+\\)\\]\\)") "Regular expression matching the definition of a footnote.") +(defgroup org-footnote nil + "Footnotes in Org-mode." + :tag "Org Footnote" + :group 'org) + (defcustom org-footnote-section "Footnotes" "Outline heading containing footnote definitions before export. This can be nil, to place footnotes locally at the end of the current @@ -75,7 +80,7 @@ automatically, i.e. when creating the footnote, and when sorting the notes. However, by hand you may place definitions *anywhere*. If this is a string, during export, all subtrees starting with this heading will be removed after extracting footnote definitions." - :group 'org-footnotes + :group 'org-footnote :type '(choice (string :tag "Collect footnotes under heading") (const :tag "Define footnotes locally" nil))) @@ -87,7 +92,7 @@ as in Org-mode. Outside Org-mode, new footnotes are always placed at the end of the file. When you normalize the notes, any line containing only this tag will be removed, a new one will be inserted at the end of the file, followed by the collected and normalized footnotes." - :group 'org-footnotes + :group 'org-footnote :type 'string) (defcustom org-footnote-define-inline nil From 9822a6799a45d8f8efa0bad624c99994b2bd41a6 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Tue, 27 Apr 2010 12:00:03 +0200 Subject: [PATCH 5/5] Push a mark before the agenda can move point in a buffer Patch by Andreas Seltenreich. --- lisp/ChangeLog | 3 +++ lisp/org-agenda.el | 1 + 2 files changed, 4 insertions(+) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 181143e07..21bbbcc69 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,8 @@ 2010-04-27 Carsten Dominik + * org-agenda.el (org-agenda-goto): Push a mark before changing + the position. + * org-footnote.el (org-footnote): New group. (org-footnote-section) (org-footnote-tag-for-non-org-mode-files): Fix typos. diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index d8039163f..279d682ba 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -6082,6 +6082,7 @@ and by additional input from the age of a schedules or deadline entry." (pos (marker-position marker))) (switch-to-buffer-other-window buffer) (widen) + (push-mark) (goto-char pos) (when (org-mode-p) (org-show-context 'agenda)