From b335a4fa34dd33850c9c077943f3bd88eb6894b7 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Wed, 17 Apr 2013 18:43:01 +0200 Subject: [PATCH 01/16] ox-latex: Improve subscript/superscript export * lisp/ox-latex.el (org-latex--script-size): New function. (org-latex-subscript, org-latex-superscript): Use new function. --- lisp/ox-latex.el | 91 ++++++++++++++++++++++-------------------------- 1 file changed, 41 insertions(+), 50 deletions(-) diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index 4d095795c..dafb991b1 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -2201,35 +2201,50 @@ holding contextual information." ;;;; Subscript +(defun org-latex--script-size (object info) + "Transcode a subscript or superscript object. +OBJECT is an Org object. INFO is a plist used as a communication +channel." + (let ((output "")) + (org-element-map (org-element-contents object) + (cons 'plain-text org-element-all-objects) + (lambda (obj) + (case (org-element-type obj) + ((entity latex-fragment) + (let ((data (org-trim (org-export-data obj info)))) + (string-match + "\\`\\(?:\\\\[([]\\|\\$+\\)?\\(.*?\\)\\(?:\\\\[])]\\|\\$+\\)?\\'" + data) + (setq output + (concat output + (match-string 1 data) + (let ((blank (org-element-property :post-blank obj))) + (and blank (> blank 0) "\\ ")))))) + (plain-text + (setq output + (format "%s\\mathrm{%s}" + output + ;; \mathrm command doesn't handle spaces, so + ;; we have to enforce them. + (replace-regexp-in-string + " " "\\\\ " (org-export-data obj info))))) + (otherwise + (setq output + (concat output + (org-export-data obj info) + (let ((blank (org-element-property :post-blank obj))) + (and blank (> blank 0) "\\ "))))))) + info nil org-element-recursive-objects) + ;; Result. + (format (if (= (length output) 1) "$%s%s$" "$%s{%s}$") + (if (eq (org-element-type object) 'subscript) "_" "^") + output))) + (defun org-latex-subscript (subscript contents info) "Transcode a SUBSCRIPT object from Org to LaTeX. CONTENTS is the contents of the object. INFO is a plist holding contextual information." - (if (= (length contents) 1) (format "$_%s$" contents) - ;; Handle multiple objects in SUBSCRIPT by creating a subscript - ;; command for each of them. - (let ((prev-blanks 0)) - (mapconcat - (lambda (obj) - (case (org-element-type obj) - ((entity latex-fragment) - (setq prev-blanks (org-element-property :post-blank obj)) - (let ((data (org-trim (org-export-data obj info)))) - (string-match - "\\`\\(?:\\\\[([]\\|\\$+\\)?\\(.*?\\)\\(?:\\\\[])]\\|\\$+\\)?\\'" - data) - (format "$_{%s}$" (match-string 1 data)))) - (plain-text - (format "$_\\mathrm{%s}$" - (concat (make-string prev-blanks ? ) - ;; mathrm command doesn't handle spaces, - ;; so we have to enforce them. - (replace-regexp-in-string - " " "\\\\ " (org-export-data obj info))))) - (otherwise - (setq prev-blanks (org-element-property :post-blank obj)) - (format "$_{%s}$" (org-export-data obj info))))) - (org-element-contents subscript) "")))) + (org-latex--script-size subscript info)) ;;;; Superscript @@ -2238,31 +2253,7 @@ contextual information." "Transcode a SUPERSCRIPT object from Org to LaTeX. CONTENTS is the contents of the object. INFO is a plist holding contextual information." - (if (= (length contents) 1) (format "$^%s$" contents) - ;; Handle multiple objects in SUPERSCRIPT by creating - ;; a superscript command for each of them. - (let ((prev-blanks 0)) - (mapconcat - (lambda (obj) - (case (org-element-type obj) - ((entity latex-fragment) - (setq prev-blanks (org-element-property :post-blank obj)) - (let ((data (org-trim (org-export-data obj info)))) - (string-match - "\\`\\(?:\\\\[([]\\|\\$+\\)?\\(.*?\\)\\(?:\\\\[])]\\|\\$+\\)?\\'" - data) - (format "$^{%s}$" (match-string 1 data)))) - (plain-text - (format "$^\\mathrm{%s}$" - (concat (make-string prev-blanks ? ) - ;; mathrm command doesn't handle spaces, - ;; so we have to enforce them. - (replace-regexp-in-string - " " "\\\\ " (org-export-data obj info))))) - (otherwise - (setq prev-blanks (org-element-property :post-blank obj)) - (format "$^{%s}$" (org-export-data obj info))))) - (org-element-contents superscript) "")))) + (org-latex--script-size superscript info)) ;;;; Table From 937b4484c6a825b42529b774b8a98206119e5cd8 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Wed, 17 Apr 2013 20:25:02 +0200 Subject: [PATCH 02/16] org-agenda.el: New commands for dragging a line forward/backward * org-agenda.el (org-agenda-drag-line-forward) (org-agenda-drag-line-backward): New commands. (org-agenda-mode-map): Bind the new commands to M- and M- respectively. * org.texi (Agenda commands): Add a table heading for dragging agenda lines forward/backward. --- doc/org.texi | 11 +++++++++++ lisp/org-agenda.el | 28 ++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/doc/org.texi b/doc/org.texi index 4e6c2db62..69d70bdf1 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -8913,6 +8913,17 @@ the default behavior of @code{org-capture}. @cindex capturing, from agenda @vindex org-capture-use-agenda-date +@tsubheading{Dragging agenda lines forward/backward} +@cindex dragging, agenda lines + +@orgcmd{M-,org-agenda-drag-line-backward} +Drag the line at point backward one line. With a numeric prefix argument, +drag backward by that many lines. + +@orgcmd{M-,org-agenda-drag-line-forward} +Drag the line at point forward one line. With a numeric prefix argument, +drag forward by that many lines. + @tsubheading{Bulk remote editing selected entries} @cindex remote editing, bulk, from agenda @vindex org-agenda-bulk-custom-functions diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index f13e6ede1..607269d39 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -2182,6 +2182,8 @@ The following commands are available: (org-defkey org-agenda-mode-map "\C-m" 'org-agenda-switch-to) (org-defkey org-agenda-mode-map "\C-k" 'org-agenda-kill) (org-defkey org-agenda-mode-map "\C-c\C-w" 'org-agenda-refile) +(org-defkey org-agenda-mode-map [(meta down)] 'org-agenda-drag-line-forward) +(org-defkey org-agenda-mode-map [(meta up)] 'org-agenda-drag-line-backward) (org-defkey org-agenda-mode-map "m" 'org-agenda-bulk-mark) (org-defkey org-agenda-mode-map "\M-m" 'org-agenda-bulk-toggle) (org-defkey org-agenda-mode-map "*" 'org-agenda-bulk-mark-all) @@ -9880,6 +9882,32 @@ current HH:MM time." (org-get-cursor-date (equal with-time 1)))) (call-interactively 'org-capture)))) +;;; Dragging agenda lines forward/backward + +(defun org-agenda-drag-line-forward (arg) + "Drag an agenda line forward by ARG lines." + (interactive "p") + (let ((inhibit-read-only t) lst) + (if (save-excursion + (dotimes (n arg) + (beginning-of-line 2) + (push (not (get-text-property (point) 'txt)) lst)) + (delq nil lst)) + (message "Cannot move line forward") + (org-drag-line-forward arg)))) + +(defun org-agenda-drag-line-backward (arg) + "Drag an agenda line backward by ARG lines." + (interactive "p") + (let ((inhibit-read-only t) lst) + (if (save-excursion + (dotimes (n arg) + (beginning-of-line 0) + (push (not (get-text-property (point) 'txt)) lst)) + (delq nil lst)) + (message "Cannot move line backward") + (org-drag-line-backward arg)))) + ;;; Flagging notes (defun org-agenda-show-the-flagging-note () From 79ecb6570b7dabe2321f4bc36450473e89f8d732 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Wed, 17 Apr 2013 20:34:28 +0200 Subject: [PATCH 03/16] org.texi (Agenda commands): Add a footnote * org.texi (Agenda commands): Add a footnote about dragging agenda lines: it does not persist and it does not change the .org files. --- doc/org.texi | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/org.texi b/doc/org.texi index 69d70bdf1..f697284ba 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -8917,8 +8917,10 @@ the default behavior of @code{org-capture}. @cindex dragging, agenda lines @orgcmd{M-,org-agenda-drag-line-backward} -Drag the line at point backward one line. With a numeric prefix argument, -drag backward by that many lines. +Drag the line at point backward one line@footnote{Moving agenda lines does +not persist after an agenda refresh and does not modify the contributing +@file{.org} files}. With a numeric prefix argument, drag backward by that +many lines. @orgcmd{M-,org-agenda-drag-line-forward} Drag the line at point forward one line. With a numeric prefix argument, From d57b9e84e16b7a9434c5ef0f0728f82c8cb6a9d8 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Wed, 17 Apr 2013 20:57:21 +0200 Subject: [PATCH 04/16] ox-latex: Better handling of sub/superscript within sub/superscript * lisp/ox-latex.el (org-latex--script-size): Fix error when using sub/superscript within sub/superscript. --- lisp/ox-latex.el | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index dafb991b1..dd8f77421 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -2205,7 +2205,17 @@ holding contextual information." "Transcode a subscript or superscript object. OBJECT is an Org object. INFO is a plist used as a communication channel." - (let ((output "")) + (let ((in-script-p + ;; Non-nil if object is already in a sub/superscript. + (let ((parent object)) + (catch 'exit + (while (setq parent (org-export-get-parent parent)) + (let ((type (org-element-type parent))) + (cond ((memq type '(subscript superscript)) + (throw 'exit t)) + ((memq type org-element-all-elements) + (throw 'exit nil)))))))) + (output "")) (org-element-map (org-element-contents object) (cons 'plain-text org-element-all-objects) (lambda (obj) @@ -2235,10 +2245,15 @@ channel." (let ((blank (org-element-property :post-blank obj))) (and blank (> blank 0) "\\ "))))))) info nil org-element-recursive-objects) - ;; Result. - (format (if (= (length output) 1) "$%s%s$" "$%s{%s}$") + ;; Result. Do not wrap into math mode if already in a subscript + ;; or superscript. Do not wrap into curly brackets if OUTPUT is + ;; a single character. + (concat (and (not in-script-p) "$") (if (eq (org-element-type object) 'subscript) "_" "^") - output))) + (and (> (length output) 1) "{") + output + (and (> (length output) 1) "}") + (and (not in-script-p) "$")))) (defun org-latex-subscript (subscript contents info) "Transcode a SUBSCRIPT object from Org to LaTeX. From 99f88219951ca73bfea95e433211f566b354fedc Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Wed, 17 Apr 2013 20:56:32 +0200 Subject: [PATCH 05/16] ox-latex: Use \text command for subscript and superscript * lisp/ox-latex.el (org-latex--script-size): Use \text command for subscript and superscript. This is far superior to \mathrm, but it requires "amstext" package. In particular, accented characters are now allowed within sub/superscript. * lisp/org.el (org-latex-default-packages-alist): Add "amstext" package. --- lisp/org.el | 2 ++ lisp/ox-latex.el | 7 +------ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index a7570dd4f..1ceeda21c 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -3810,6 +3810,7 @@ header, or they will be appended." ("" "wasysym" t) ("" "latexsym" t) ("" "amssymb" t) + ("" "amstext" nil) ("" "hyperref" nil) "\\tolerance=1000") "Alist of default packages to be inserted in the header. @@ -3821,6 +3822,7 @@ The packages in this list are needed by one part or another of Org mode to function properly: - inputenc, fontenc: for basic font and character selection +- amstext: for subscript and superscript - textcomp, marvosymb, wasysym, latexsym, amssym: for various symbols used for interpreting the entities in `org-entities'. You can skip some of these packages if you don't use any of the diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index dd8f77421..c6fb9a0fe 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -2232,12 +2232,7 @@ channel." (and blank (> blank 0) "\\ ")))))) (plain-text (setq output - (format "%s\\mathrm{%s}" - output - ;; \mathrm command doesn't handle spaces, so - ;; we have to enforce them. - (replace-regexp-in-string - " " "\\\\ " (org-export-data obj info))))) + (format "%s\\text{%s}" output (org-export-data obj info)))) (otherwise (setq output (concat output From f6bf19f898b1e89728db4e3be2b3c176a4067e53 Mon Sep 17 00:00:00 2001 From: Achim Gratz Date: Wed, 17 Apr 2013 21:38:21 +0200 Subject: [PATCH 06/16] ob-perl: fix result handling * lisp/ob-perl.el (org-babel-perl-wrapper-method): Select output handle only after evaluation so that output is not mixed into results eavaluation. (org-babel-perl-evaluate): Fix the handling of results for ":results output" to also parse tables. Use the same lambda construction as in ob-sh.el to avoid code duplication. --- lisp/ob-perl.el | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/lisp/ob-perl.el b/lisp/ob-perl.el index d90ca181d..43ab9467c 100644 --- a/lisp/ob-perl.el +++ b/lisp/ob-perl.el @@ -101,9 +101,9 @@ specifying a var of the same value." %s }; open my $BOH, qq(>%s) or die qq(Perl: Could not open output file.$/); - select $BOH; my $rv = &$babel_sub(); my $rt = ref $rv; + select $BOH; if (qq(ARRAY) eq $rt) { local $\\=$/; local $,=qq(\t); @@ -131,19 +131,25 @@ 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, as elisp." (when session (error "Sessions are not supported for Perl")) - (let ((body (concat org-babel-perl-preface ibody))) - (case result-type - (output (org-babel-eval org-babel-perl-command body)) - (value (let ((tmp-file (org-babel-temp-file "perl-"))) - (org-babel-eval - org-babel-perl-command - (format org-babel-perl-wrapper-method body - (org-babel-process-file-name tmp-file 'noquote))) - (org-babel-result-cond result-params - (with-temp-buffer - (insert-file-contents tmp-file) - (buffer-string)) - (org-babel-import-elisp-from-file tmp-file '(16)))))))) + (let* ((body (concat org-babel-perl-preface ibody)) + (tmp-file (org-babel-temp-file "perl-")) + (tmp-babel-file (org-babel-process-file-name + tmp-file 'noquote))) + ((lambda (results) + (when results + (org-babel-result-cond result-params + (org-babel-eval-read-file tmp-file) + (org-babel-import-elisp-from-file tmp-file '(16))))) + (case result-type + (output + (with-temp-file tmp-file + (insert + (org-babel-eval org-babel-perl-command body)) + (buffer-string))) + (value + (org-babel-eval org-babel-perl-command + (format org-babel-perl-wrapper-method + body tmp-babel-file))))))) (provide 'ob-perl) From 718e7e8b80c47205c36559dcce482f63e302fdf0 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Wed, 17 Apr 2013 21:33:34 +0200 Subject: [PATCH 07/16] org.texi: Small fixes to HTML documentation * doc/org.texi (Math formatting in HTML export): Fix OPTIONS item's name. (Text areas in HTML export): Update text areas. (HTML Export commands): Update export commands. --- doc/org.texi | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/doc/org.texi b/doc/org.texi index f697284ba..3ec4948c6 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -10961,26 +10961,15 @@ language, but with additional support for tables. @node HTML Export commands, HTML preamble and postamble, HTML export, HTML export @subsection HTML export commands -@cindex region, active -@cindex active region -@cindex transient-mark-mode @table @kbd @orgcmd{C-c C-e h h,org-html-export-to-html} -@cindex property, EXPORT_FILE_NAME Export as a HTML file. For an Org file @file{myfile.org}, the HTML file will be @file{myfile.html}. The file will be overwritten -without warning. If there is an active region@footnote{This requires -@var{transient-mark-mode} be turned on.}, only the region will be -exported. If the selected region is a single tree@footnote{To select the -current subtree, use @kbd{C-c @@}.}, the tree head will become the document -title. If the tree head entry has, or inherits, an @code{EXPORT_FILE_NAME} -property, that name will be used for the export. +without warning. @kbd{C-c C-e h o} Export as a HTML file and immediately open it with a browser. @orgcmd{C-c C-e h H,org-html-export-as-html} Export to a temporary buffer. Do not create a file. -@item C-c C-e C-v h H/h h/h o -Export only the visible part of the document. @end table @c FIXME Exporting sublevels @@ -11170,7 +11159,7 @@ method requires that the @file{dvipng} program is available on your system. You can still get this processing with @example -#+OPTIONS: LaTeX:dvipng +#+OPTIONS: tex:dvipng @end example @node Text areas in HTML export, CSS support, Math formatting in HTML export, HTML export @@ -11179,15 +11168,16 @@ You can still get this processing with @cindex text areas, in HTML An alternative way to publish literal code examples in HTML is to use text areas, where the example can even be edited before pasting it into an -application. It is triggered by a @code{-t} switch at an @code{example} or -@code{src} block. Using this switch disables any options for syntax and -label highlighting, and line numbering, which may be present. You may also -use @code{-h} and @code{-w} switches to specify the height and width of the -text area, which default to the number of lines in the example, and 80, -respectively. For example +application. It is triggered by @code{:textarea} attribute at an +@code{example} or @code{src} block. + +You may also use @code{:height} and @code{:width} attributes to specify the +height and width of the text area, which default to the number of lines in +the example, and 80, respectively. For example @example -#+BEGIN_EXAMPLE -t -w 40 +#+ATTR_HTML: :textarea t :width 40 +#+BEGIN_EXAMPLE (defun org-xor (a b) "Exclusive or." (if a (not b) b)) From bdde7db20cf5e267e10a97f7e8daccc056b9556b Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Wed, 17 Apr 2013 21:53:22 +0200 Subject: [PATCH 08/16] org.texi: Improve documentation for export settings * doc/org.texi (Export settings): Improve documentation. --- doc/org.texi | 49 +++++++++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/doc/org.texi b/doc/org.texi index 3ec4948c6..8d54d1ba5 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -10470,14 +10470,18 @@ A date or a time-stamp@footnote{The variable exported.}. @item DESCRIPTION -The page description, e.g., for the XHTML meta tag. +The document description. Back-ends handle it as they see fit (e.g., for the +XHTML meta tag), if at all. You can use several such keywords for long +descriptions. @item EMAIL @vindex user-mail-address The email address (@var{user-mail-address}). @item KEYWORDS -The keywords defining the contents, e.g., for the XHTML meta tag. +The keywords defining the contents of the document. Back-ends handle it as +they see fit (e.g., for the XHTML meta tag), if at all. You can use several +such keywords if the list is long. @item LANGUAGE @vindex org-export-default-language @@ -10500,7 +10504,8 @@ tag will be unconditionally excluded from the export, even if they have an @code{:export:} tag. @item TITLE -The title to be shown (otherwise derived from buffer's name). +The title to be shown (otherwise derived from buffer's name). You can use +several such keywords for long titles. @end table The @code{#+OPTIONS} keyword is a compact@footnote{If you want to configure @@ -10581,7 +10586,8 @@ Toggle the inclusion of footnotes (@var{org-export-with-footnotes}). @item H: @vindex org-export-headline-levels Set the number of headline levels for export -(@var{org-export-headline-levels}). +(@var{org-export-headline-levels}). Below that level, headlines are treated +differently. In most back-ends, they become list items. @item inline: @vindex org-export-with-inlinetasks @@ -10589,7 +10595,9 @@ Toggle inclusion of inlinetasks (@var{org-export-with-inlinetasks}). @item num: @vindex org-export-with-section-numbers -Toggle section-numbers (@var{org-export-with-section-numbers}). +Toggle section-numbers (@var{org-export-with-section-numbers}). It can also +be set to a number @samp{n}, so only headlines at that level or above will be +numbered. @item p: @vindex org-export-with-planning @@ -10599,7 +10607,7 @@ Toggle export of planning information (@var{org-export-with-planning}). @item pri: @vindex org-export-with-priority -Toggle priority cookies (@var{org-export-with-priority}). +Toggle inclusion of priority cookies (@var{org-export-with-priority}). @item stat: @vindex org-export-with-statistics-cookies @@ -10642,21 +10650,22 @@ Toggle inclusion of TODO keywords into exported text Toggle inclusion of tables (@var{org-export-with-tables}). @end table -@cindex #+BIND -A more general mechanism is also provided. Indeed, Emacs variables can -become buffer-local during export by using the BIND keyword. Its syntax is -@samp{#+BIND: variable value}. This is particularly useful for in-buffer -settings that cannot be changed using specific keywords. +@cindex property, EXPORT_FILE_NAME +When exporting only a subtree, each of the previous keywords@footnote{With +the exception of @samp{SETUPFILE}.} can be overriden locally by special node +properties. These begin with @samp{EXPORT_}, followed by the name of the +keyword they supplant. For example, @samp{DATE} and @samp{OPTIONS} keywords +become, respectively, @samp{EXPORT_DATE} and @samp{EXPORT_OPTIONS} +properties. Subtree export also supports the self-explicit +@samp{EXPORT_FILE_NAME} property@footnote{There is no buffer-wide equivalent +for this property. The file name in this case is derived from the file +associated to the buffer, if possible, or asked to the user otherwise.}. -These settings affect all buffer's export processes. Though, it is possible -to override them locally when exporting only a subtree. This is done by -adding a headline property named after the keyword with the @samp{EXPORT_} -prefix. For example, @samp{DATE} and @samp{OPTIONS} keywords become, -respectively @samp{EXPORT_DATE} and @samp{EXPORT_OPTIONS} properties. -Subtree export also supports the self-explicit @samp{EXPORT_FILE_NAME} -property@footnote{There is no buffer-wide equivalent for this property. The -file name in this case is derived from the file associated to the buffer, if -possible, or asked to the user otherwise.}. +@cindex #+BIND +Eventually, Emacs variables can become buffer-local during export by using +the BIND keyword. Its syntax is @samp{#+BIND: variable value}. This is +particularly useful for in-buffer settings that cannot be changed using +specific keywords. @node ASCII/Latin-1/UTF-8 export, Beamer export, Export settings, Exporting @section ASCII/Latin-1/UTF-8 export From 58f7e4382101b555fe7d6af460bfa2fb6208adb5 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Wed, 17 Apr 2013 22:44:28 +0200 Subject: [PATCH 09/16] ox-org.el: Fix some docstrings * lisp/ox-org.el (org-org-identity): Fix docstring. Tiny refactoring. (org-org-headline, org-org-keyword): Fix docstring. --- lisp/ox-org.el | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lisp/ox-org.el b/lisp/ox-org.el index 18925c556..f55b5dc67 100644 --- a/lisp/ox-org.el +++ b/lisp/ox-org.el @@ -117,13 +117,13 @@ setting of `org-html-htmlize-output-type' is 'css." (org-open-file (org-org-export-to-org nil s v b)))))))) (defun org-org-identity (blob contents info) - "Transcode BLOB element or object back into Org syntax." - (funcall - (intern (format "org-element-%s-interpreter" (org-element-type blob))) - blob contents)) + "Transcode BLOB element or object back into Org syntax. +CONTENTS is its contents, as a string or nil. INFO is ignored." + (org-export-expand blob contents)) (defun org-org-headline (headline contents info) - "Transcode HEADLINE element back into Org syntax." + "Transcode HEADLINE element back into Org syntax. +CONTENTS is its contents, as a string or nil. INFO is ignored." (unless (plist-get info :with-todo-keywords) (org-element-put-property headline :todo-keyword nil)) (unless (plist-get info :with-tags) @@ -134,7 +134,8 @@ setting of `org-html-htmlize-output-type' is 'css." (defun org-org-keyword (keyword contents info) "Transcode KEYWORD element back into Org syntax. -Ignore keywords targeted at other export back-ends." +CONTENTS is nil. INFO is ignored. This function ignores +keywords targeted at other export back-ends." (unless (member (org-element-property :key keyword) (mapcar (lambda (block-cons) From 77c5710de2256dd19a1b05ea8411e787f611a515 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Thu, 18 Apr 2013 00:06:06 +0200 Subject: [PATCH 10/16] ox-latex: Handle consecutive alterning sub and superscript * lisp/ox-latex.el (org-latex--script-size): Handle consecutive alterning sub and superscript. This patch fixes export of "a^b_c" constructs. --- lisp/ox-latex.el | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index c6fb9a0fe..2a315ef70 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -2215,6 +2215,7 @@ channel." (throw 'exit t)) ((memq type org-element-all-elements) (throw 'exit nil)))))))) + (type (org-element-type object)) (output "")) (org-element-map (org-element-contents object) (cons 'plain-text org-element-all-objects) @@ -2242,13 +2243,29 @@ channel." info nil org-element-recursive-objects) ;; Result. Do not wrap into math mode if already in a subscript ;; or superscript. Do not wrap into curly brackets if OUTPUT is - ;; a single character. - (concat (and (not in-script-p) "$") + ;; a single character. Also merge consecutive subscript and + ;; superscript into the same math snippet. + (concat (and (not in-script-p) + (let ((prev (org-export-get-previous-element object info))) + (or (not prev) + (not (eq (org-element-type prev) + (if (eq type 'subscript) 'superscript + 'subscript))) + (let ((blank (org-element-property :post-blank prev))) + (and blank (> blank 0))))) + "$") (if (eq (org-element-type object) 'subscript) "_" "^") (and (> (length output) 1) "{") output (and (> (length output) 1) "}") - (and (not in-script-p) "$")))) + (and (not in-script-p) + (or (let ((blank (org-element-property :post-blank object))) + (and blank (> blank 0))) + (not (eq (org-element-type + (org-export-get-next-element object info)) + (if (eq type 'subscript) 'superscript + 'subscript)))) + "$")))) (defun org-latex-subscript (subscript contents info) "Transcode a SUBSCRIPT object from Org to LaTeX. From 217d14ecc28a7e2d6e71193b253d8336625942a6 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Thu, 18 Apr 2013 10:22:34 +0200 Subject: [PATCH 11/16] ob-core.el (org-babel-pop-to-session-maybe): Fix docstring * ob-core.el (org-babel-pop-to-session-maybe): Fix docstring. (org-babel-pop-to-session-maybe): Use true function's name, not its alias. --- lisp/ob-core.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/ob-core.el b/lisp/ob-core.el index b8d93f237..97d0100f4 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -417,10 +417,10 @@ then run `org-babel-load-in-session'." (defun org-babel-pop-to-session-maybe () "Conditionally pop to a session. Detect if this is context for a org-babel src-block and if so -then run `org-babel-pop-to-session'." +then run `org-babel-switch-to-session'." (interactive) (let ((info (org-babel-get-src-block-info))) - (if info (progn (org-babel-pop-to-session current-prefix-arg info) t) nil))) + (if info (progn (org-babel-switch-to-session current-prefix-arg info) t) nil))) (add-hook 'org-metadown-hook 'org-babel-pop-to-session-maybe) From 4231cb4b129ece52526d415e0c900c7d16bf4181 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Thu, 18 Apr 2013 10:29:00 +0200 Subject: [PATCH 12/16] Use `org-add-hook' in some places and merge Emacs revno r112320 * ox.el (org-export-stack-mode) * org-crypt.el (org-crypt-check-auto-save) (org-crypt-use-before-save-magic): Use `org-add-hook' when the hooks are local hooks. * org-indent.el (org-indent-mode) * org-agenda.el (org-agenda-mode): Use `org-add-hook' and merge upstream change from Emacs revno r112320. --- lisp/org-agenda.el | 8 ++++---- lisp/org-crypt.el | 12 ++++++------ lisp/org-indent.el | 10 +++++----- lisp/ox.el | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 607269d39..631c6d03c 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -2148,10 +2148,10 @@ The following commands are available: (org-add-hook 'post-command-hook 'org-agenda-update-agenda-type nil 'local) (org-add-hook 'pre-command-hook 'org-unhighlight nil 'local) ;; Make sure properties are removed when copying text - (make-local-variable 'filter-buffer-substring-functions) - (add-hook 'filter-buffer-substring-functions - (lambda (fun start end delete) - (substring-no-properties (funcall fun start end delete)))) + (org-add-hook 'filter-buffer-substring-functions + (lambda (fun start end delete) + (substring-no-properties (funcall fun start end delete))) + nil t) (unless org-agenda-keep-modes (setq org-agenda-follow-mode org-agenda-start-with-follow-mode org-agenda-entry-text-mode org-agenda-start-with-entry-text-mode diff --git a/lisp/org-crypt.el b/lisp/org-crypt.el index 2dfc4addc..b02a7ceff 100644 --- a/lisp/org-crypt.el +++ b/lisp/org-crypt.el @@ -139,11 +139,11 @@ See `org-crypt-disable-auto-save'." (message "org-decrypt: Decrypting entry with auto-save-mode enabled. This may cause leakage.")) ((eq org-crypt-disable-auto-save 'encrypt) (message "org-decrypt: Enabling re-encryption on auto-save.") - (add-hook 'auto-save-hook - (lambda () - (message "org-crypt: Re-encrypting all decrypted entries due to auto-save.") - (org-encrypt-entries)) - nil t)) + (org-add-hook 'auto-save-hook + (lambda () + (message "org-crypt: Re-encrypting all decrypted entries due to auto-save.") + (org-encrypt-entries)) + nil t)) (t nil)))) (defun org-crypt-key-for-heading () @@ -264,7 +264,7 @@ See `org-crypt-disable-auto-save'." "Add a hook to automatically encrypt entries before a file is saved to disk." (add-hook 'org-mode-hook - (lambda () (add-hook 'before-save-hook 'org-encrypt-entries nil t)))) + (lambda () (org-add-hook 'before-save-hook 'org-encrypt-entries nil t)))) (add-hook 'org-reveal-start-hook 'org-decrypt-entry) diff --git a/lisp/org-indent.el b/lisp/org-indent.el index 5221e4458..44311e388 100644 --- a/lisp/org-indent.el +++ b/lisp/org-indent.el @@ -182,11 +182,11 @@ during idle time." (org-set-local 'org-hide-leading-stars-before-indent-mode org-hide-leading-stars) (org-set-local 'org-hide-leading-stars t)) - (make-local-variable 'filter-buffer-substring-functions) - (add-hook 'filter-buffer-substring-functions - (lambda (fun start end delete) - (org-indent-remove-properties-from-string - (funcall fun start end delete)))) + (org-add-hook 'filter-buffer-substring-functions + (lambda (fun start end delete) + (org-indent-remove-properties-from-string + (funcall fun start end delete))) + nil t) (org-add-hook 'after-change-functions 'org-indent-refresh-maybe nil 'local) (org-add-hook 'before-change-functions 'org-indent-notify-modified-headline nil 'local) diff --git a/lisp/ox.el b/lisp/ox.el index d35f0a9a1..1b7ec2e1d 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -5557,7 +5557,7 @@ files or buffers, only the display. header-line-format '(:eval (format " %-12s | %6s | %s" "Back-End" "Age" "Source"))) - (add-hook 'post-command-hook 'org-export-stack-refresh nil t) + (org-add-hook 'post-command-hook 'org-export-stack-refresh nil t) (set (make-local-variable 'revert-buffer-function) 'org-export-stack-refresh)) From 25869e5670942f069cd3b4c3612610711fd28cca Mon Sep 17 00:00:00 2001 From: Aaron Ecay Date: Sun, 31 Mar 2013 18:47:44 -0400 Subject: [PATCH 13/16] Add 'inline-only option to org-export-babel-evaluate * lisp/ob-exp.el (org-export-babel-evaluate): Add a 'inline-only option. (org-babel-exp-results): Implement 'inline-only for `org-export-babel-evaluate'. * doc/org.texi (Exporting code blocks): Document the 'inline-only setting for `org-export-babel-evaluate'. This is useful because there is no way for inline results to be stored. The imagined usecase is that all non-inline source blocks will be evaluated manually by the user. Inline blocks, however, must be evaluated during export, or they will be simply deleted by the exporter. --- doc/org.texi | 7 ++++++- lisp/ob-exp.el | 11 ++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/doc/org.texi b/doc/org.texi index 8d54d1ba5..07c671fd6 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -13582,7 +13582,12 @@ Setting the @var{org-export-babel-evaluate} variable to @code{nil} will ensure that no code blocks are evaluated as part of the export process. This can be useful in situations where potentially untrusted Org mode files are exported in an automated fashion, for example when Org mode is used as the -markup language for a wiki. +markup language for a wiki. It is also possible to set this variable to +@code{‘inline-only}. In that case, only inline code blocks will be +evaluated, in order to insert their results. Non-inline code blocks are +assumed to have their results already inserted in the buffer by manual +evaluation. This setting is useful to avoid expensive recalculations during +export, not to provide security. @comment node-name, next, previous, up @comment Extracting source code, Evaluating code blocks, Exporting code blocks, Working With Source Code diff --git a/lisp/ob-exp.el b/lisp/ob-exp.el index 664a52b0c..d9fb294b2 100644 --- a/lisp/ob-exp.el +++ b/lisp/ob-exp.el @@ -52,10 +52,13 @@ (defcustom org-export-babel-evaluate t "Switch controlling code evaluation during export. When set to nil no code will be evaluated as part of the export -process." +process. When set to 'inline-only, only inline code blocks will +be executed." :group 'org-babel :version "24.1" - :type 'boolean) + :type '(choice (const :tag "Never" nil) + (const :tag "Only inline code" inline-only) + (const :tag "Always" t))) (put 'org-export-babel-evaluate 'safe-local-variable (lambda (x) (eq x nil))) (defun org-babel-exp-get-export-buffer () @@ -378,7 +381,9 @@ Results are prepared in a manner suitable for export by org-mode. This function is called by `org-babel-exp-do-export'. The code block will be evaluated. Optional argument SILENT can be used to inhibit insertion of results into the buffer." - (when (and org-export-babel-evaluate + (when (and (or (eq org-export-babel-evaluate t) + (and (eq type 'inline) + (eq org-export-babel-evaluate 'inline-only))) (not (and hash (equal hash (org-babel-current-result-hash))))) (let ((lang (nth 0 info)) (body (if (org-babel-noweb-p (nth 2 info) :eval) From 4d763f35f5ff061e717fad1c8702557a0089e0d9 Mon Sep 17 00:00:00 2001 From: Aaron Ecay Date: Thu, 18 Apr 2013 04:02:47 -0400 Subject: [PATCH 14/16] Fix bug in org-babel-execute-src-block * lisp/ob-core.el (org-babel-execute-src-block): Use `copy-tree' to prevent setf from modifying users variables withing let-bound `info' variable. Otherwise, the setf calls in this function can reach into and change other configuration variables, such as the library of babel. --- lisp/ob-core.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lisp/ob-core.el b/lisp/ob-core.el index 97d0100f4..7b00cb842 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -541,7 +541,9 @@ Optionally supply a value for PARAMS which will be merged with the header arguments specified at the front of the source code block." (interactive) - (let* ((info (or info (org-babel-get-src-block-info))) + (let* ((info (if info + (copy-tree info) + (org-babel-get-src-block-info))) (merged-params (org-babel-merge-params (nth 2 info) params))) (when (org-babel-check-evaluate (let ((i info)) (setf (nth 2 i) merged-params) i)) From b432d2eb93a7277de765434d87eda9237e540826 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Thu, 18 Apr 2013 12:04:48 +0200 Subject: [PATCH 15/16] org.texi: Enhance style. * org.texi (Beamer export, @LaTeX{} and PDF export) (Header and sectioning, @LaTeX{} specific attributes): Enhance style. Thanks to Thomas Dye for these suggestions. --- doc/org.texi | 94 ++++++++++++++++++++++++++++------------------------ 1 file changed, 50 insertions(+), 44 deletions(-) diff --git a/doc/org.texi b/doc/org.texi index 07c671fd6..e43e4789d 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -608,7 +608,7 @@ HTML export @LaTeX{} and PDF export -* @LaTeX{}/PDF export commands:: +* @LaTeX{} export commands:: How to export to LaTeX and PDF * Header and sectioning:: Setting up the export file structure * Quoting @LaTeX{} code:: Incorporating literal @LaTeX{} code * @LaTeX{} specific attributes:: Controlling @LaTeX{} output @@ -10834,9 +10834,9 @@ Beamer export introduces a number of keywords to insert code in the document's header. Four control appearance of the presentantion: @code{#+BEAMER_THEME}, @code{#+BEAMER_COLOR_THEME}, @code{#+BEAMER_FONT_THEME}, @code{#+BEAMER_INNER_THEME} and -@code{#+BEAMER_OUTER_THEME}. All of them accept optional arguments within -square brackets. The last one, @code{#+BEAMER_HEADER}, is more generic and -allows to append any line of code in the header. +@code{#+BEAMER_OUTER_THEME}. All of them accept optional arguments +within square brackets. The last one, @code{#+BEAMER_HEADER}, is more +generic and allows you to append any line of code in the header. @example #+BEAMER_THEME: Rochester [height=20pt] @@ -10877,10 +10877,10 @@ A *@@@@beamer:<2->@@@@useful* feature @cindex #+ATTR_BEAMER Eventually, every plain list has support for @code{:environment}, -@code{:overlay} and @code{:options} attributes through @code{ATTR_BEAMER} -affiliated keyword. The first one allows to use a different environment, the -second sets overlay specifications and the last one inserts optional -arguments in current list environment. +@code{:overlay} and @code{:options} attributes through +@code{ATTR_BEAMER} affiliated keyword. The first one allows the use +of a different environment, the second sets overlay specifications and +the last one inserts optional arguments in current list environment. @example #+ATTR_BEAMER: :overlay +- @@ -11341,30 +11341,34 @@ pages, configure the variable @var{org-html-use-infojs}. @cindex @LaTeX{} export @cindex PDF export -Org mode contains a @LaTeX{} exporter. With further processing@footnote{The +@LaTeX{} export can produce an arbitrarily complex LaTeX document of any +standard or custom document class. With further processing@footnote{The default @LaTeX{} output is designed for processing with @code{pdftex} or @LaTeX{}. It includes packages that are not compatible with @code{xetex} and -possibly @code{luatex}. See the variables -@var{org-latex-default-packages-alist} and -@var{org-latex-packages-alist}.}, this back-end is also used to produce PDF -output. Since the @LaTeX{} output uses @file{hyperref} to implement links -and cross references, the PDF output file will be fully linked. +possibly @code{luatex}. The @LaTeX{} exporter can be configured to support +alternative TeX engines, see the options +@var{org-latex-default-packages-alist} and @var{org-latex-packages-alist}.}, +which the @LaTeX{} exporter is able to control, this back-end is able to +produce PDF output. Because the @LaTeX{} exporter can be configured to use +the @code{hyperref} package, the default setup produces fully-linked PDF +output. -As is @LaTeX{}, blank lines are meaningful for this back-end: a paragraph +As in @LaTeX{}, blank lines are meaningful for this back-end: a paragraph will not be started if two contiguous syntactical elements are not separated by an empty line. This back-end also offers enhanced support for footnotes. Thus, it handles -nested footnotes, footnotes in tables and footnotes in items' description. +nested footnotes, footnotes in tables and footnotes in a list item's +description. @menu -* @LaTeX{}/PDF export commands:: +* @LaTeX{} export commands:: How to export to LaTeX and PDF * Header and sectioning:: Setting up the export file structure * Quoting @LaTeX{} code:: Incorporating literal @LaTeX{} code * @LaTeX{} specific attributes:: Controlling @LaTeX{} output @end menu -@node @LaTeX{}/PDF export commands, Header and sectioning, @LaTeX{} and PDF export, @LaTeX{} and PDF export +@node @LaTeX{} export commands, Header and sectioning, @LaTeX{} and PDF export, @LaTeX{} and PDF export @subsection @LaTeX{} export commands @table @kbd @@ -11380,7 +11384,7 @@ Export as @LaTeX{} and then process to PDF. Export as @LaTeX{} and then process to PDF, then open the resulting PDF file. @end table -@node Header and sectioning, Quoting @LaTeX{} code, @LaTeX{}/PDF export commands, @LaTeX{} and PDF export +@node Header and sectioning, Quoting @LaTeX{} code, @LaTeX{} export commands, @LaTeX{} and PDF export @subsection Header and sectioning structure @cindex @LaTeX{} class @cindex @LaTeX{} sectioning structure @@ -11388,10 +11392,10 @@ Export as @LaTeX{} and then process to PDF, then open the resulting PDF file. @cindex header, for @LaTeX{} files @cindex sectioning structure, for @LaTeX{} export -The first three outline levels become headlines, defining a general document -structure. Additional levels are exported as @code{itemize} or -@code{enumerate} lists. The transition can also occur at a different level -(@pxref{Export settings}). +By default, the first three outline levels become headlines, defining a +general document structure. Additional levels are exported as @code{itemize} +or @code{enumerate} lists. The transition can also occur at a different +level (@pxref{Export settings}). By default, the @LaTeX{} output uses the class @code{article}. @@ -11414,14 +11418,14 @@ class. You can also define your own classes there. @cindex #+LATEX_CLASS_OPTIONS @cindex property, EXPORT_LATEX_CLASS @cindex property, EXPORT_LATEX_CLASS_OPTIONS -@code{LATEX_CLASS_OPTIONS} keyword or @code{EXPORT_LATEX_CLASS_OPTIONS} +The @code{LATEX_CLASS_OPTIONS} keyword or @code{EXPORT_LATEX_CLASS_OPTIONS} property can specify the options for the @code{\documentclass} macro. These options have to be provided, as expected by @LaTeX{}, within square brackets. @cindex #+LATEX_HEADER @cindex #+LATEX_HEADER_EXTRA -You can also use @code{LATEX_HEADER} and -@code{LATEX_HEADER_EXTRA}@footnote{Unlike to @code{LATEX_HEADER}, contents +You can also use the @code{LATEX_HEADER} and +@code{LATEX_HEADER_EXTRA}@footnote{Unlike @code{LATEX_HEADER}, contents from @code{LATEX_HEADER_EXTRA} keywords will not be loaded when previewing @LaTeX{} snippets (@pxref{Previewing @LaTeX{} fragments}).} keywords in order to add lines to the header. See the docstring of @var{org-latex-classes} for @@ -11469,7 +11473,7 @@ affect tables, images, plain lists, special blocks and source blocks. For @LaTeX{} export of a table, you can specify a label and a caption (@pxref{Images and tables}). You can also use attributes to control table -layout and contents. Valid properties are: +layout and contents. Valid @LaTeX{} attributes include: @table @code @item :mode @@ -11483,7 +11487,7 @@ environment. Default mode is determined in @var{org-latex-default-table-mode}. @item :environment @vindex org-latex-default-table-environment -Environment used for the table. It can be to any @LaTeX{} table +Environment used for the table. It can be set to any @LaTeX{} table environment, like @code{tabularx}, @code{longtable}, @code{array}, @code{tabu}, @code{bmatrix}@enddots{} It defaults to @var{org-latex-default-table-environment} value. @@ -11495,7 +11499,7 @@ can specify the positioning of the float. @item :align @itemx :font @itemx :width -set, respectively, the alignment string of the table, its font size and its +Set, respectively, the alignment string of the table, its font size and its width. They only apply on regular tables. @item :spread Boolean specific to the @code{tabu} and @code{longtabu} environments, and @@ -11510,16 +11514,16 @@ value of @code{:width}. They toggle, respectively, @code{booktabs} usage (assuming the package is properly loaded), table centering and removal of every horizontal rule but the first one (in a "table.el" table only). In particular, -@var{org-latex-tables-booktabs} (resp.@: @var{org-latex-tables-centered}) -activates the first (resp.@: second) attribute globally. +@var{org-latex-tables-booktabs} (respectively @var{org-latex-tables-centered}) +activates the first (respectively second) attribute globally. @item :math-prefix @itemx :math-suffix @itemx :math-arguments -string which will be inserted, respectively, before the table within the math -environment, after the table within the math environment, and between the -macro name and the contents of the table. The latter attribute is necessary -to matrix macros that require more than one argument (e.g., -@code{qbordermatrix}). +A string that will be inserted, respectively, before the table within the +math environment, after the table within the math environment, and between +the macro name and the contents of the table. The @code{:math-arguments} +attribute is used for matrix macros that require more than one argument +(e.g., @code{qbordermatrix}). @end table Thus, attributes can be used in a wide array of situations, like writing @@ -11582,16 +11586,17 @@ To modify the placement option of any floating environment, set the [[./img/hst.png]] @end example -Eventually, in the @code{:comment-include} attributes has a non-@code{nil} value, -the code actually including the image will be commented out. +If the @code{:comment-include} attribute is set to a non-@code{nil} value, +the @LaTeX{} @code{\includegraphics} macro will be commented out. @subsubheading Plain lists in @LaTeX{} export @cindex plain lists, in @LaTeX{} export Plain lists accept two optional attributes: @code{:environment} and -@code{:options}. The first one allows to use a non-standard environment -(e.g., @samp{inparaenum}). The second one allows to specify optional -arguments for that environment (square brackets may be omitted). +@code{:options}. The first one allows the use of a non-standard +environment (e.g., @samp{inparaenum}). The second one specifies +optional arguments for that environment (square brackets may be +omitted). @example #+ATTR_LATEX: :environment compactitem :options $\circ$ @@ -11601,9 +11606,10 @@ arguments for that environment (square brackets may be omitted). @subsubheading Source blocks in @LaTeX{} export @cindex source blocks, in @LaTeX{} export -In addition to syntax defined in @ref{Literal examples}, names and captions -(@pxref{Images and tables}), source blocks also accept @code{:long-listing} -attribute, which prevents the block to become a float when non-@code{nil}. +In addition to syntax defined in @ref{Literal examples}, names and +captions (@pxref{Images and tables}), source blocks also accept a +@code{:long-listing} attribute, which prevents the block from floating +when non-@code{nil}. @example #+ATTR_LATEX: :long-listing t From ccdfa8ddf8c1e7ae438a3f3df6927f1026baf5c0 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Thu, 18 Apr 2013 12:20:08 +0200 Subject: [PATCH 16/16] org-datetree.el: Be more restrictive when finding a year datetree * org-datetree.el (org-datetree-find-month-create) (org-datetree-find-day-create): Add a docstring. (org-datetree-find-year-create): Only match headlines with a year or a year and one or more tags. Thanks to Suvayu Ali for reporting this. --- lisp/org-datetree.el | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lisp/org-datetree.el b/lisp/org-datetree.el index e0f4d10bc..dd4b1b0e1 100644 --- a/lisp/org-datetree.el +++ b/lisp/org-datetree.el @@ -72,7 +72,8 @@ tree can be found." (goto-char (prog1 (point) (widen)))))) (defun org-datetree-find-year-create (year) - (let ((re "^\\*+[ \t]+\\([12][0-9]\\{3\\}\\)\\(.*?\\([ \t]:[[:alnum:]:_@#%]+:\\)?\\s-*$\\)") + "Find the YEAR datetree or create it." + (let ((re "^\\*+[ \t]+\\([12][0-9]\\{3\\}\\)\\(\\s-*?\\([ \t]:[[:alnum:]:_@#%]+:\\)?\\s-*$\\)") match) (goto-char (point-min)) (while (and (setq match (re-search-forward re nil t)) @@ -90,6 +91,7 @@ tree can be found." (org-datetree-insert-line year))))) (defun org-datetree-find-month-create (year month) + "Find the datetree for YEAR and MONTH or create it." (org-narrow-to-subtree) (let ((re (format "^\\*+[ \t]+%d-\\([01][0-9]\\) \\w+$" year)) match) @@ -109,6 +111,7 @@ tree can be found." (org-datetree-insert-line year month))))) (defun org-datetree-find-day-create (year month day) + "Find the datetree for YEAR, MONTH and DAY or create it." (org-narrow-to-subtree) (let ((re (format "^\\*+[ \t]+%d-%02d-\\([0123][0-9]\\) \\w+$" year month)) match)