From 8d382158e751722fc93ef234a9af884054a0c9de Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Sat, 18 Aug 2012 16:58:28 +0200 Subject: [PATCH 1/8] org-html.el: Don't include the caption tag for empty captions in HTML export * org-html.el (org-format-org-table-html): Don't include the caption tag for empty captions in HTML export. Keep it in the DocBook export so that it produces valid DocBook XML. --- lisp/org-html.el | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lisp/org-html.el b/lisp/org-html.el index 6c1437386..fb72e31f9 100644 --- a/lisp/org-html.el +++ b/lisp/org-html.el @@ -2141,9 +2141,10 @@ for formatting. This is required for the DocBook exporter." (if colgropen (setq html (cons (car html) (cons "" (cdr html))))) ;; Since the output of HTML table formatter can also be used in - ;; DocBook document, we want to always include the caption to make - ;; DocBook XML file valid. - (push (format "%s" (or caption "")) html) + ;; DocBook document, include empty captions for the DocBook + ;; export only so that it produces valid XML. + (when (or caption (eq org-export-current-backend 'docbook)) + (push (format "%s" (or caption "")) html)) (when label (setq html-table-tag (org-export-splice-attributes html-table-tag (format "id=\"%s\"" (org-solidify-link-text label))))) (push html-table-tag html)) From f25baf9e1ea22e7c088941ecead10d53dbe4d897 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Sat, 18 Aug 2012 17:49:01 +0200 Subject: [PATCH 2/8] org-exp.el: Merge functions for removing tables and source blocks metalines * org-exp.el (org-export-handle-metalines): Rename from `org-export-handle-table-metalines'. Now also handle source block metalines. (org-export-res/src-name-cleanup): Delete. (org-export-preprocess-string): Use `org-export-handle-metalines'. Don't use `org-export-res/src-name-cleanup' anymore. This fixes a but reported by Feiming Chen, thanks to him. --- lisp/org-exp.el | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/lisp/org-exp.el b/lisp/org-exp.el index bce73bd6b..db0febfd3 100644 --- a/lisp/org-exp.el +++ b/lisp/org-exp.el @@ -1,4 +1,4 @@ -;;; org-exp.el --- ASCII, HTML, XOXO and iCalendar export for Org-mode +;;; org-exp.el --- Export internals for Org-mode ;; Copyright (C) 2004-2012 Free Software Foundation, Inc. @@ -1318,11 +1318,8 @@ on this string to produce the exported version." ;; Remove or replace comments (org-export-handle-comments (plist-get parameters :comments)) - ;; Remove #+TBLFM and #+TBLNAME lines - (org-export-handle-table-metalines) - - ;; Remove #+results and #+name lines - (org-export-res/src-name-cleanup) + ;; Remove #+TBLFM #+TBLNAME #+NAME #+RESULTS lines + (org-export-handle-metalines) ;; Run the final hook (run-hooks 'org-export-preprocess-final-hook) @@ -2009,9 +2006,11 @@ When it is nil, all comments will be removed." (replace-match "") (goto-char (max (point-min) (1- pos)))))))) -(defun org-export-handle-table-metalines () - "Remove table specific metalines #+TBLNAME: and #+TBLFM:." - (let ((re "^[ \t]*#\\+tbl\\(name\\|fm\\):\\(.*\n?\\)") +(defun org-export-handle-metalines () + "Remove tables and source blocks metalines. +This function should only be called after all block processing +has taken place." + (let ((re "^[ \t]*#\\+\\(tbl\\(?:name\\|fm\\)\\|results\\(?:\\[[a-z0-9]+\\]\\)?\\|name\\):\\(.*\n?\\)") (case-fold-search t) pos) (goto-char (point-min)) @@ -2024,18 +2023,6 @@ When it is nil, all comments will be removed." (replace-match "") (goto-char (max (point-min) (1- pos))))))) -(defun org-export-res/src-name-cleanup () - "Clean up #+results and #+name lines for export. -This function should only be called after all block processing -has taken place." - (interactive) - (save-excursion - (goto-char (point-min)) - (let ((case-fold-search t)) - (while (org-re-search-forward-unprotected - "#\\+\\(name\\|results\\(\\[[a-z0-9]+\\]\\)?\\):" nil t) - (delete-region (match-beginning 0) (progn (forward-line) (point))))))) - (defun org-export-mark-radio-links () "Find all matches for radio targets and turn them into internal links." (let ((re-radio (and org-target-link-regexp From 90e9aeeff5e20b49af4fe5bf1550368b332a5247 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Sat, 18 Aug 2012 17:52:02 +0200 Subject: [PATCH 3/8] =?UTF-8?q?org.el:=20Fix=20bug=20in=20=CC=80org-fontif?= =?UTF-8?q?y-meta-lines-and-blocks-1'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * org.el (org-fontify-meta-lines-and-blocks-1): Correctly handle metalines with #+results[...]:. --- lisp/org.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lisp/org.el b/lisp/org.el index 2ddc9a03c..33dc8d756 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -5579,7 +5579,8 @@ by a #." (if (string-equal dc1 "+title:") '(font-lock-fontified t face org-document-title) '(font-lock-fontified t face org-document-info)))) - ((or (member dc1 '("+begin:" "+end:" "+caption:" "+label:" + ((or (equal dc1 "+results") + (member dc1 '("+begin:" "+end:" "+caption:" "+label:" "+orgtbl:" "+tblfm:" "+tblname:" "+results:" "+call:" "+header:" "+headers:" "+name:")) (and (match-end 4) (equal dc3 "+attr"))) From 56b731087ece7f52b9639da4dc1c3c8786a4cdb2 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Sat, 18 Aug 2012 18:44:56 +0200 Subject: [PATCH 4/8] Fix HTML export bug for empty headlines when `org-export-with-priority' is nil * org-html.el (org-export-as-html): Make sure we always process a string. * org-exp.el (org-export-cleanup-toc-line): Always return a string. Thanks to Friedrich Delgado for reporting this. --- lisp/org-exp.el | 24 +++++++++++++----------- lisp/org-html.el | 2 +- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/lisp/org-exp.el b/lisp/org-exp.el index db0febfd3..d4c45608b 100644 --- a/lisp/org-exp.el +++ b/lisp/org-exp.el @@ -3300,18 +3300,20 @@ If yes remove the column and the special lines." (defun org-export-cleanup-toc-line (s) "Remove tags and timestamps from lines going into the toc." - (when (memq org-export-with-tags '(not-in-toc nil)) - (if (string-match (org-re " +:[[:alnum:]_@#%:]+: *$") s) + (if (not s) + "" ; Return a string when argument is nil + (when (memq org-export-with-tags '(not-in-toc nil)) + (if (string-match (org-re " +:[[:alnum:]_@#%:]+: *$") s) + (setq s (replace-match "" t t s)))) + (when org-export-remove-timestamps-from-toc + (while (string-match org-maybe-keyword-time-regexp s) (setq s (replace-match "" t t s)))) - (when org-export-remove-timestamps-from-toc - (while (string-match org-maybe-keyword-time-regexp s) - (setq s (replace-match "" t t s)))) - (while (string-match org-bracket-link-regexp s) - (setq s (replace-match (match-string (if (match-end 3) 3 1) s) - t t s))) - (while (string-match "\\[\\([0-9]\\|fn:[^]]*\\)\\]" s) - (setq s (replace-match "" t t s))) - s) + (while (string-match org-bracket-link-regexp s) + (setq s (replace-match (match-string (if (match-end 3) 3 1) s) + t t s))) + (while (string-match "\\[\\([0-9]\\|fn:[^]]*\\)\\]" s) + (setq s (replace-match "" t t s))) + s)) (defun org-get-text-property-any (pos prop &optional object) diff --git a/lisp/org-html.el b/lisp/org-html.el index fb72e31f9..b8e7557c8 100644 --- a/lisp/org-html.el +++ b/lisp/org-html.el @@ -1704,7 +1704,7 @@ PUB-DIR is set, use this as the publishing directory." ;; This is a headline (setq level (org-tr-level (- (match-end 1) (match-beginning 1) level-offset)) - txt (match-string 2 org-line)) + txt (or (match-string 2 org-line) "")) (if (string-match quote-re0 txt) (setq txt (replace-match "" t t txt))) (if (<= level (max umax umax-toc)) From 62064c73fc135735a205b9523f0d6f78f147ca40 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Sun, 19 Aug 2012 08:01:43 +0200 Subject: [PATCH 5/8] org-clock.el: Fix clock overlays bug * org-clock.el (org-clock-put-overlay): Put the overlay on the whole headline, not only on the last character. This fixes a bug with overlays on headlines ending with a bracketed link. Thanks to Ryan Kaskel for reporting this. --- lisp/org-clock.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/org-clock.el b/lisp/org-clock.el index 9a31ef106..633fb2b34 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -1798,8 +1798,8 @@ will be easy to remove." (org-move-to-column c) (unless (eolp) (skip-chars-backward "^ \t")) (skip-chars-backward " \t") - (setq ov (make-overlay (1- (point)) (point-at-eol)) - tx (concat (buffer-substring (1- (point)) (point)) + (setq ov (make-overlay (point-at-bol) (point-at-eol)) + tx (concat (buffer-substring (point-at-bol) (point)) (make-string (+ off (max 0 (- c (current-column)))) ?.) (org-add-props (if org-time-clocksum-use-fractional (format fmt From 788f7da28527f37f55b96432db6734319c184907 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Sun, 19 Aug 2012 08:26:35 +0200 Subject: [PATCH 6/8] org.el: Use case-folding when trying to match clocktables and source blocks contexts * org.el (org-context): Use case-folding when trying to match clocktables and source blocks contexts. --- lisp/org.el | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 33dc8d756..0c71a2287 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -20352,21 +20352,22 @@ and :keyword." (push (list :table-table) clist))) (goto-char p) - ;; New the "medium" contexts: clocktables, source blocks - (cond ((org-in-clocktable-p) - (push (list :clocktable - (and (or (looking-at "#\\+BEGIN: clocktable") - (search-backward "#+BEGIN: clocktable" nil t)) - (match-beginning 0)) - (and (re-search-forward "#\\+END:?" nil t) - (match-end 0))) clist)) - ((org-in-src-block-p) - (push (list :src-block - (and (or (looking-at "#\\+BEGIN_SRC") - (search-backward "#+BEGIN_SRC" nil t)) - (match-beginning 0)) - (and (search-forward "#+END_SRC" nil t) - (match-beginning 0))) clist))) + (let ((case-fold-search t)) + ;; New the "medium" contexts: clocktables, source blocks + (cond ((org-in-clocktable-p) + (push (list :clocktable + (and (or (looking-at "#\\+BEGIN: clocktable") + (search-backward "#+BEGIN: clocktable" nil t)) + (match-beginning 0)) + (and (re-search-forward "#\\+END:?" nil t) + (match-end 0))) clist)) + ((org-in-src-block-p) + (push (list :src-block + (and (or (looking-at "#\\+BEGIN_SRC") + (search-backward "#+BEGIN_SRC" nil t)) + (match-beginning 0)) + (and (search-forward "#+END_SRC" nil t) + (match-beginning 0))) clist)))) (goto-char p) ;; Now the small context From f926d9019b1d28c6a459b869db8876b21e47e488 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Sun, 19 Aug 2012 08:48:53 +0200 Subject: [PATCH 7/8] org.el: Allow lowercase "#+category" and "#+begin:" dynamic blocks * org.el (org-refresh-category-properties) (org-find-dblock, org-dblock-start-re, org-dblock-end-re): Allow lowercase "#+category" and "#+begin:" dynamic blocks. --- lisp/org.el | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 0c71a2287..e0366f5b3 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -8698,7 +8698,8 @@ call CMD." (defun org-refresh-category-properties () "Refresh category text properties in the buffer." - (let ((inhibit-read-only t) + (let ((case-fold-search t) + (inhibit-read-only t) (def-cat (cond ((null org-category) (if buffer-file-name @@ -11158,20 +11159,20 @@ this is used for the GOTO interface." (defun org-find-dblock (name) "Find the first dynamic block with name NAME in the buffer. If not found, stay at current position and return nil." - (let (pos) + (let ((case-fold-search t) pos) (save-excursion (goto-char (point-min)) - (setq pos (and (re-search-forward (concat "^[ \t]*#\\+BEGIN:[ \t]+" name "\\>") - nil t) + (setq pos (and (re-search-forward + (concat "^[ \t]*#\\+\\(?:BEGIN\\|begin\\):[ \t]+" name "\\>") nil t) (match-beginning 0)))) (if pos (goto-char pos)) pos)) (defconst org-dblock-start-re - "^[ \t]*#\\+BEGIN:[ \t]+\\(\\S-+\\)\\([ \t]+\\(.*\\)\\)?" + "^[ \t]*#\\+\\(?:BEGIN\\|begin\\):[ \t]+\\(\\S-+\\)\\([ \t]+\\(.*\\)\\)?" "Matches the start line of a dynamic block, with parameters.") -(defconst org-dblock-end-re "^[ \t]*#\\+END\\([: \t\r\n]\\|$\\)" +(defconst org-dblock-end-re "^[ \t]*#\\+\\(?:END\\|end\\)\\([: \t\r\n]\\|$\\)" "Matches the end of a dynamic block.") (defun org-create-dblock (plist) From 6309dcae6b9fccd8e3cca13ab2c9ff21b361dac2 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Sun, 19 Aug 2012 10:15:59 +0200 Subject: [PATCH 8/8] org.el: Be more strict about matching option keywords * org.el (org-options-keywords): Add "TODO". (org-make-options-regexp): Make the hashtag mandatory for options and don't allow whitespaces between the hashtag and the plus sign. --- lisp/org.el | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index e0366f5b3..fdaa16881 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -11324,7 +11324,7 @@ This function can be used in a hook." '("TITLE:" "AUTHOR:" "EMAIL:" "DATE:" "DESCRIPTION:" "KEYWORDS:" "LANGUAGE:" "OPTIONS:" "EXPORT_SELECT_TAGS:" "EXPORT_EXCLUDE_TAGS:" - "LINK_UP:" "LINK_HOME:" "LINK:" + "LINK_UP:" "LINK_HOME:" "LINK:" "TODO:" "XSLT:" "CATEGORY:" "SEQ_TODO:" "TYP_TODO:" "PRIORITIES:" "DRAWERS:" "STARTUP:" "TAGS:" "FILETAGS:" "ARCHIVE:")) @@ -22062,12 +22062,10 @@ Show the heading too, if it is currently invisible." (defun org-make-options-regexp (kwds &optional extra) "Make a regular expression for keyword lines." (concat - "^" - "#?[ \t]*\\+\\(" + "^#\\+\\(" (mapconcat 'regexp-quote kwds "\\|") (if extra (concat "\\|" extra)) - "\\):[ \t]*" - "\\(.*\\)")) + "\\):[ \t]*\\(.*\\)")) ;; Make isearch reveal the necessary context (defun org-isearch-end ()