From 3d2b7841e64c2d88bea760dad0a4c5a493272943 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Thu, 16 Aug 2012 00:00:51 +0200 Subject: [PATCH 01/32] org-e-texinfo.el: Clean up code. --- contrib/lisp/org-e-texinfo.el | 252 +++++++++++++--------------------- 1 file changed, 96 insertions(+), 156 deletions(-) diff --git a/contrib/lisp/org-e-texinfo.el b/contrib/lisp/org-e-texinfo.el index dcef6ad11..da407584f 100644 --- a/contrib/lisp/org-e-texinfo.el +++ b/contrib/lisp/org-e-texinfo.el @@ -1,8 +1,11 @@ ;;; org-e-texinfo.el --- Texinfo Back-End For Org Export Engine +;; Copyright (C) 2012 Jonathan Leech-Pepin ;; Author: Jonathan Leech-Pepin ;; Keywords: outlines, hypermedia, calendar, wp - +;; +;; This file is not part of GNU Emacs. +;; ;; 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 @@ -36,7 +39,7 @@ ;; To include inline code snippets (for example for generating @kbd{} ;; and @key{} commands), the following export-snippet keys are ;; accepted: -;; +;; ;; info ;; e-info ;; e-texinfo @@ -49,8 +52,7 @@ ;; '("e-texinfo" . "e-texinfo")) ;; (add-to-list 'org-export-snippet-translation-alist ;; '("info" . "e-texinfo")) -;; - +;; ;;; Code: @@ -140,7 +142,6 @@ and title information beyond the initial variable.") "Alist between filters keywords and back-end specific filters. See `org-export-filters-alist' for more information") - ;;; Internal Variables @@ -155,8 +156,7 @@ and title information beyond the initial variable.") :tag "Org Export Texinfo" :group 'org-export) - -;;;; Preamble +;;; Preamble (defcustom org-e-texinfo-filename nil "Default filename for texinfo output." @@ -208,8 +208,7 @@ a format string in which the section title will be added." (string :tag "unnumbered")) (function :tag "Hook computing sectioning")))))) - -;;;; Headline +;;; Headline (defcustom org-e-texinfo-format-headline-function nil "Function to format headline text. @@ -240,11 +239,11 @@ order to reproduce the default set-up: :type 'function) -;;;; Footnotes +;;; Footnotes ;; ;; Footnotes are inserted directly -;;;; Timestamps +;;; Timestamps (defcustom org-e-texinfo-active-timestamp-format "@emph{%s}" "A printf format string to be applied to active timestamps." @@ -261,15 +260,14 @@ order to reproduce the default set-up: :group 'org-export-e-texinfo :type 'string) -;;;; Links +;;; Links (defcustom org-e-texinfo-link-with-unknown-path-format "@indicateurl{%s}" "Format string for links with unknown path type." :group 'org-export-e-texinfo :type 'string) - -;;;; Tables +;;; Tables (defcustom org-e-texinfo-tables-verbatim nil "When non-nil, tables are exported verbatim." @@ -290,13 +288,13 @@ When nil, no transformation is made." (defcustom org-e-texinfo-def-table-markup "@samp" "Default setting for @table environments.") -;;;; Text markup +;;; Text markup (defcustom org-e-texinfo-text-markup-alist '((bold . "@strong{%s}") - (code . code) - (italic . "@emph{%s}") - (verbatim . verb) - (comment . "@c %s")) + (code . code) + (italic . "@emph{%s}") + (verbatim . verb) + (comment . "@c %s")) "Alist of Texinfo expressions to convert text markup. The key must be a symbol among `bold', `italic' and `comment'. @@ -314,8 +312,7 @@ returned as-is." :type 'alist :options '(bold code italic verbatim comment)) - -;;;; Drawers +;;; Drawers (defcustom org-e-texinfo-format-drawer-function nil "Function called to format a drawer in Texinfo code. @@ -335,8 +332,7 @@ in order to mimic default behaviour: :group 'org-export-e-texinfo :type 'function) - -;;;; Inlinetasks +;;; Inlinetasks (defcustom org-e-texinfo-format-inlinetask-function nil "Function called to format an inlinetask in Texinfo code. @@ -372,12 +368,11 @@ in order to mimic default behaviour: :group 'org-export-e-texinfo :type 'function) - -;;;; Src blocks +;;; Src blocks ;; ;; Src Blocks are example blocks, except for LISP -;;;; Plain text +;;; Plain text (defcustom org-e-texinfo-quotes '(("quotes" @@ -407,8 +402,7 @@ string defines the replacement string for this quote." (string :tag "Regexp for char before") (string :tag "Replacement quote ")))) - -;;;; Compilation +;;; Compilation (defcustom org-e-texinfo-info-process '("makeinfo %f") @@ -504,7 +498,7 @@ See `org-e-texinfo-text-markup-alist' for details." ;; Else use format string. (t (format fmt text))))) -;;;; Menu creation +;;; Menu creation (defun org-e-texinfo--build-menu (tree level info &optional detailed) "Create the @menu/@end menu information from TREE at headline @@ -633,15 +627,13 @@ of the longest menu entry." (concat "* " title ":: " (make-string (- (+ 3 max-length) length) - ?\s) + ?\s) (if desc (concat desc))) (concat "\n" title "\n")))) text-menu)) output)) - - ;;; Template (defun org-e-texinfo-template (contents info) @@ -681,7 +673,7 @@ holding export options." (concat "\n" texinfo-header "\n")) - + "@c %**end of header\n" "@finalout\n" "\n\n" @@ -728,7 +720,7 @@ holding export options." "@top " title " Manual\n" "@insertcopying\n" "@end ifnottex\n\n" - + ;; Menu "@menu\n" (org-e-texinfo-make-menu info 'main) @@ -741,7 +733,7 @@ holding export options." "@end detailmenu\n" "@end menu\n" "\n\n" - + ;; Document's body. contents "\n" @@ -759,12 +751,11 @@ holding export options." ;;; Transcode Functions -;;;; Babel Call +;;; Babel Call ;; ;; Babel Calls are ignored. - -;;;; Bold +;;; Bold (defun org-e-texinfo-bold (bold contents info) "Transcode BOLD from Org to Texinfo. @@ -772,13 +763,11 @@ CONTENTS is the text with bold markup. INFO is a plist holding contextual information." (org-e-texinfo--text-markup contents 'bold)) - -;;;; Center Block +;;; Center Block ;; ;; Center blocks are ignored - -;;;; Clock +;;; Clock (defun org-e-texinfo-clock (clock contents info) "Transcode a CLOCK element from Org to Texinfo. @@ -793,8 +782,7 @@ information." (and time (format " (%s)" time))))) "@*")) - -;;;; Code +;;; Code (defun org-e-texinfo-code (code contents info) "Transcode a CODE object from Org to Texinfo. @@ -802,7 +790,7 @@ CONTENTS is nil. INFO is a plist used as a communication channel." (org-e-texinfo--text-markup (org-element-property :value code) 'code)) -;;;; Comment +;;; Comment (defun org-e-texinfo-comment (comment contents info) "Transcode a COMMENT object from Org to Texinfo. @@ -810,7 +798,7 @@ CONTENTS is the text in the comment. INFO is a plist holding contextual information." (org-e-texinfo--text-markup (org-element-property :value comment) 'comment)) -;;;; Comment Block +;;; Comment Block (defun org-e-texinfo-comment-block (comment-block contents info) "Transcode a COMMENT-BLOCK object from Org to Texinfo. @@ -818,7 +806,7 @@ CONTENTS is the text within the block. INFO is a plist holding contextual information." (format "@ignore\n%s@end ignore" (org-element-property :value comment-block))) -;;;; Drawer +;;; Drawer (defun org-e-texinfo-drawer (drawer contents info) "Transcode a DRAWER element from Org to Texinfo. @@ -833,8 +821,7 @@ holding contextual information." contents))) output)) - -;;;; Dynamic Block +;;; Dynamic Block (defun org-e-texinfo-dynamic-block (dynamic-block contents info) "Transcode a DYNAMIC-BLOCK element from Org to Texinfo. @@ -842,8 +829,7 @@ CONTENTS holds the contents of the block. INFO is a plist holding contextual information. See `org-export-data'." contents) - -;;;; Entity +;;; Entity (defun org-e-texinfo-entity (entity contents info) "Transcode an ENTITY object from Org to Texinfo. @@ -852,8 +838,7 @@ contextual information." (let ((ent (org-element-property :latex entity))) (if (org-element-property :latex-math-p entity) (format "@math{%s}" ent) ent))) - -;;;; Example Block +;;; Example Block (defun org-e-texinfo-example-block (example-block contents info) "Transcode an EXAMPLE-BLOCK element from Org to Texinfo. @@ -862,8 +847,7 @@ information." (format "@verbatim\n%s@end verbatim" (org-export-format-code-default example-block info))) - -;;;; Export Block +;;; Export Block (defun org-e-texinfo-export-block (export-block contents info) "Transcode a EXPORT-BLOCK element from Org to Texinfo. @@ -871,8 +855,7 @@ CONTENTS is nil. INFO is a plist holding contextual information." (when (string= (org-element-property :type export-block) "TEXINFO") (org-remove-indentation (org-element-property :value export-block)))) - -;;;; Export Snippet +;;; Export Snippet (defun org-e-texinfo-export-snippet (export-snippet contents info) "Transcode a EXPORT-SNIPPET object from Org to Texinfo. @@ -880,8 +863,7 @@ CONTENTS is nil. INFO is a plist holding contextual information." (when (eq (org-export-snippet-backend export-snippet) 'e-texinfo) (org-element-property :value export-snippet))) - -;;;; Fixed Width +;;; Fixed Width (defun org-e-texinfo-fixed-width (fixed-width contents info) "Transcode a FIXED-WIDTH element from Org to Texinfo. @@ -890,13 +872,11 @@ CONTENTS is nil. INFO is a plist holding contextual information." (org-remove-indentation (org-element-property :value fixed-width)))) - -;;;; Footnote Definition +;;; Footnote Definition ;; ;; Footnote Definitions are ignored. - -;;;; Footnote Reference +;;; Footnote Reference ;; (defun org-e-texinfo-footnote-reference (footnote contents info) @@ -908,7 +888,7 @@ plist holding contextual information." (format "@footnote{%s}" (org-trim (org-export-data def info))))) -;;;; Headline +;;; Headline (defun org-e-texinfo-headline (headline contents info) "Transcode an HEADLINE element from Org to Texinfo. @@ -1016,7 +996,7 @@ holding contextual information." (index (format section-fmt full-text - (concat pre-blanks contents "\n" + (concat pre-blanks contents "\n" (if (member index '("cp" "fn" "ky" "pg" "tp" "vr")) (concat "@printindex " index))))) ;; Case 4: This is a deep sub-tree: export it as a list item. @@ -1068,17 +1048,15 @@ holding contextual information." (format (replace-regexp-in-string "%]" "%%]" section-fmt) full-text (concat pre-blanks contents)))))))) - -;;;; Horizontal Rule +;;; Horizontal Rule ;; ;; Horizontal rules are ignored -;;;; Inline Babel Call +;;; Inline Babel Call ;; ;; Inline Babel Calls are ignored. - -;;;; Inline Src Block +;;; Inline Src Block (defun org-e-texinfo-inline-src-block (inline-src-block contents info) "Transcode an INLINE-SRC-BLOCK element from Org to Texinfo. @@ -1088,8 +1066,7 @@ contextual information." (separator (org-e-texinfo--find-verb-separator code))) (concat "@verb{" separator code separator "}"))) - -;;;; Inlinetask +;;; Inlinetask (defun org-e-texinfo-inlinetask (inlinetask contents info) "Transcode an INLINETASK element from Org to Texinfo. @@ -1122,8 +1099,7 @@ holding contextual information." "\n") full-title contents))))) - -;;;; Italic +;;; Italic (defun org-e-texinfo-italic (italic contents info) "Transcode ITALIC from Org to Texinfo. @@ -1131,7 +1107,7 @@ CONTENTS is the text with italic markup. INFO is a plist holding contextual information." (org-e-texinfo--text-markup contents 'italic)) -;;;; Item +;;; Item (defun org-e-texinfo-item (item contents info) "Transcode an ITEM element from Org to Texinfo. @@ -1139,11 +1115,10 @@ CONTENTS holds the contents of the item. INFO is a plist holding contextual information." (let* ((tag (org-element-property :tag item)) (desc (org-export-data tag info))) - (concat "\n@item " (if tag desc) "\n" - (org-trim contents) "\n"))) + (concat "\n@item " (if tag desc) "\n" + (org-trim contents) "\n"))) - -;;;; Keyword +;;; Keyword (defun org-e-texinfo-keyword (keyword contents info) "Transcode a KEYWORD element from Org to Texinfo. @@ -1157,29 +1132,24 @@ CONTENTS is nil. INFO is a plist holding contextual information." ((string= key "KINDEX") (format "@kindex %s" value)) ((string= key "PINDEX") (format "@pindex %s" value)) ((string= key "TINDEX") (format "@tindex %s" value)) - ((string= key "VINDEX") (format "@vindex %s" value)) - ))) + ((string= key "VINDEX") (format "@vindex %s" value))))) - -;;;; Latex Environment +;;; Latex Environment ;; ;; Latex environments are ignored - -;;;; Latex Fragment +;;; Latex Fragment ;; ;; Latex fragments are ignored. - -;;;; Line Break +;;; Line Break (defun org-e-texinfo-line-break (line-break contents info) "Transcode a LINE-BREAK object from Org to Texinfo. CONTENTS is nil. INFO is a plist holding contextual information." "@*") - -;;;; Link +;;; Link (defun org-e-texinfo-link (link desc info) "Transcode a LINK object from Org to Texinfo. @@ -1204,7 +1174,7 @@ INFO is a plist holding contextual information. See (email (if (string= type "mailto") (let ((text (replace-regexp-in-string "@" "@@" raw-path))) - (concat text (if desc (concat "," desc)))))) + (concat text (if desc (concat "," desc)))))) protocol) (cond ;; Links pointing to an headline: Find destination and build @@ -1251,8 +1221,7 @@ INFO is a plist holding contextual information. See ;; No path, only description. Try to do something useful. (t (format org-e-texinfo-link-with-unknown-path-format desc))))) - -;;;; Macro +;;; Macro (defun org-e-texinfo-macro (macro contents info) "Transcode a MACRO element from Org to Texinfo. @@ -1260,8 +1229,7 @@ CONTENTS is nil. INFO is a plist holding contextual information." ;; Use available tools. (org-export-expand-macro macro info)) - -;;;; Menu +;;; Menu (defun org-e-texinfo-make-menu (info level) "Create the menu for inclusion in the texifo document. @@ -1291,8 +1259,7 @@ are generated directly." ;; Otherwise do nothing (t)))) - -;;;; Paragraph +;;; Paragraph (defun org-e-texinfo-paragraph (paragraph contents info) "Transcode a PARAGRAPH element from Org to Texinfo. @@ -1300,8 +1267,7 @@ CONTENTS is the contents of the paragraph, as a string. INFO is the plist used as a communication channel." contents) - -;;;; Plain List +;;; Plain List (defun org-e-texinfo-plain-list (plain-list contents info) "Transcode a PLAIN-LIST element from Org to Texinfo. @@ -1324,12 +1290,11 @@ contextual information." (format "@%s%s\n@end %s" (if (eq type 'descriptive) (concat list-type " " indic) - list-type) + list-type) contents list-type))) - -;;;; Plain Text +;;; Plain Text (defun org-e-texinfo-plain-text (text info) "Transcode a TEXT string from Org to Texinfo. @@ -1359,8 +1324,7 @@ contextual information." ;; Return value. text) - -;;;; Planning +;;; Planning (defun org-e-texinfo-planning (planning contents info) "Transcode a PLANNING element from Org to Texinfo. @@ -1393,8 +1357,7 @@ information." " ") "@*")) - -;;;; Property Drawer +;;; Property Drawer (defun org-e-texinfo-property-drawer (property-drawer contents info) "Transcode a PROPERTY-DRAWER element from Org to Texinfo. @@ -1404,24 +1367,19 @@ information." ;; lines nonetheless. "") - -;;;; Quote Block +;;; Quote Block (defun org-e-texinfo-quote-block (quote-block contents info) "Transcode a QUOTE-BLOCK element from Org to Texinfo. CONTENTS holds the contents of the block. INFO is a plist holding contextual information." - (let* ((title (org-element-property :name quote-block)) (start-quote (concat "@quotation" - (if title - (format " %s" title))))) - + (format " %s" title))))) (format "%s\n%s@end quotation" start-quote contents))) - -;;;; Quote Section +;;; Quote Section (defun org-e-texinfo-quote-section (quote-section contents info) "Transcode a QUOTE-SECTION element from Org to Texinfo. @@ -1430,8 +1388,7 @@ CONTENTS is nil. INFO is a plist holding contextual information." (org-element-property :value quote-section)))) (when value (format "@verbatim\n%s@end verbatim" value)))) - -;;;; Radio Target +;;; Radio Target (defun org-e-texinfo-radio-target (radio-target text info) "Transcode a RADIO-TARGET object from Org to Texinfo. @@ -1442,8 +1399,7 @@ contextual information." (org-element-property :value radio-target)) text)) - -;;;; Section +;;; Section (defun org-e-texinfo-section (section contents info) "Transcode a SECTION element from Org to Texinfo. @@ -1451,12 +1407,11 @@ CONTENTS holds the contents of the section. INFO is a plist holding contextual information." contents) - -;;;; Special Block +;;; Special Block ;; ;; Are ignored at the moment -;;;; Src Block +;;; Src Block (defun org-e-texinfo-src-block (src-block contents info) "Transcode a SRC-BLOCK element from Org to Texinfo. @@ -1474,21 +1429,18 @@ contextual information." (format "@example\n%s\n@end example" (org-export-format-code-default src-block info)))))) - -;;;; Statistics Cookie +;;; Statistics Cookie (defun org-e-texinfo-statistics-cookie (statistics-cookie contents info) "Transcode a STATISTICS-COOKIE object from Org to Texinfo. CONTENTS is nil. INFO is a plist holding contextual information." (org-element-property :value statistics-cookie)) - -;;;; Strike-Through +;;; Strike-Through ;; ;; Strikethrough is ignored - -;;;; Subscript +;;; Subscript (defun org-e-texinfo-subscript (subscript contents info) "Transcode a SUBSCRIPT object from Org to Texinfo. @@ -1496,8 +1448,7 @@ CONTENTS is the contents of the object. INFO is a plist holding contextual information." (format "@math{_%s}" contents)) - -;;;; Superscript +;;; Superscript (defun org-e-texinfo-superscript (superscript contents info) "Transcode a SUPERSCRIPT object from Org to Texinfo. @@ -1505,8 +1456,7 @@ CONTENTS is the contents of the object. INFO is a plist holding contextual information." (format "@math{^%s}" contents)) - -;;;; Table +;;; Table ;; ;; `org-e-texinfo-table' is the entry point for table transcoding. It ;; takes care of tables with a "verbatim" attribute. Otherwise, it @@ -1552,19 +1502,18 @@ a communication channel." cells counts) (loop for row in collected do (push (mapcar (lambda (ref) - (let* ((start (org-element-property :contents-begin ref)) - (end (org-element-property :contents-end ref)) - (length (- end start))) - length)) row) cells)) + (let* ((start (org-element-property :contents-begin ref)) + (end (org-element-property :contents-end ref)) + (length (- end start))) + length)) row) cells)) (setq cells (remove-if #'null cells)) (push (loop for count from 0 to (- number-cells 1) collect - (loop for item in cells collect - (nth count item))) counts) + (loop for item in cells collect + (nth count item))) counts) (mapconcat '(lambda (size) (make-string size ?a)) (mapcar (lambda (ref) - (apply 'max `,@ref)) (car counts)) - "} {") - )) + (apply 'max `,@ref)) (car counts)) + "} {"))) (defun org-e-texinfo-table--org-table (table contents info) "Return appropriate Texinfo code for an Org table. @@ -1597,8 +1546,7 @@ This function assumes TABLE has `org' as its `:type' attribute." Rather than return an invalid table, nothing is returned." 'nil) - -;;;; Table Cell +;;; Table Cell (defun org-e-texinfo-table-cell (table-cell contents info) "Transcode a TABLE-CELL element from Org to Texinfo. @@ -1615,8 +1563,7 @@ a communication channel." contents) (when (org-export-get-next-element table-cell info) "\n@tab "))) - -;;;; Table Row +;;; Table Row (defun org-e-texinfo-table-row (table-row contents info) "Transcode a TABLE-ROW element from Org to Texinfo. @@ -1624,11 +1571,10 @@ CONTENTS is the contents of the row. INFO is a plist used as a communication channel." ;; Rules are ignored since table separators are deduced from ;; borders of the current row. - (when (eq (org-element-property :type table-row) 'standard) + (when (eq (org-element-property :type table-row) 'standard) (concat "@item " contents "\n"))) - -;;;; Target +;;; Target (defun org-e-texinfo-target (target contents info) "Transcode a TARGET object from Org to Texinfo. @@ -1637,8 +1583,7 @@ information." (format "@anchor{%s}" (org-export-solidify-link-text (org-element-property :value target)))) - -;;;; Timestamp +;;; Timestamp (defun org-e-texinfo-timestamp (timestamp contents info) "Transcode a TIMESTAMP object from Org to Texinfo. @@ -1652,13 +1597,11 @@ information." (format org-e-texinfo-inactive-timestamp-format value)) (t (format org-e-texinfo-diary-timestamp-format value))))) - -;;;; Underline +;;; Underline ;; ;; Underline is ignored - -;;;; Verbatim +;;; Verbatim (defun org-e-texinfo-verbatim (verbatim contents info) "Transcode a VERBATIM object from Org to Texinfo. @@ -1666,8 +1609,7 @@ CONTENTS is nil. INFO is a plist used as a communication channel." (org-e-texinfo--text-markup (org-element-property :value verbatim) 'verbatim)) - -;;;; Verse Block +;;; Verse Block (defun org-e-texinfo-verse-block (verse-block contents info) "Transcode a VERSE-BLOCK element from Org to Texinfo. @@ -1688,7 +1630,6 @@ contextual information." (setq contents (replace-match new-str nil t contents)))) (format "\\begin{verse}\n%s\\end{verse}" contents))) - ;;; Interactive functions @@ -1843,6 +1784,5 @@ none." (setq errors (concat errors " [unexpected error]"))) (and (org-string-nw-p errors) (org-trim errors))))))) - (provide 'org-e-texinfo) ;;; org-e-texinfo.el ends here From a4bef9a73d3df8629bb3698738e0eb5e34744a60 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Thu, 16 Aug 2012 00:01:59 +0200 Subject: [PATCH 02/32] contrib: Do not tell files are part of Emacs if they are not (yet) --- contrib/lisp/org-e-odt.el | 2 +- contrib/lisp/org-e-publish.el | 2 +- contrib/lisp/org-learn.el | 2 +- contrib/lisp/org-track.el | 2 +- contrib/lisp/org-wikinodes.el | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/contrib/lisp/org-e-odt.el b/contrib/lisp/org-e-odt.el index d4c38ed98..0f9e2d487 100644 --- a/contrib/lisp/org-e-odt.el +++ b/contrib/lisp/org-e-odt.el @@ -6,7 +6,7 @@ ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; This file is part of GNU Emacs. +;; This file is not part of GNU Emacs. ;; GNU Emacs is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by diff --git a/contrib/lisp/org-e-publish.el b/contrib/lisp/org-e-publish.el index 8eb8a7e44..c4c0f178c 100644 --- a/contrib/lisp/org-e-publish.el +++ b/contrib/lisp/org-e-publish.el @@ -5,7 +5,7 @@ ;; Maintainer: Carsten Dominik ;; Keywords: hypermedia, outlines, wp -;; This file is part of GNU Emacs. +;; This file is not part of GNU Emacs. ;; ;; GNU Emacs is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by diff --git a/contrib/lisp/org-learn.el b/contrib/lisp/org-learn.el index 1e08ea34c..0d5752b19 100644 --- a/contrib/lisp/org-learn.el +++ b/contrib/lisp/org-learn.el @@ -7,7 +7,7 @@ ;; Homepage: http://orgmode.org ;; Version: 6.32trans ;; -;; This file is part of GNU Emacs. +;; This file is not part of GNU Emacs. ;; ;; GNU Emacs is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by diff --git a/contrib/lisp/org-track.el b/contrib/lisp/org-track.el index 516868045..1d12862dd 100644 --- a/contrib/lisp/org-track.el +++ b/contrib/lisp/org-track.el @@ -14,7 +14,7 @@ ;; Released under the GNU General Public License version 3 ;; see: http://www.gnu.org/licenses/gpl-3.0.html ;; -;; This file is part of GNU Emacs. +;; This file is not part of GNU Emacs. ;; ;; GNU Emacs is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by diff --git a/contrib/lisp/org-wikinodes.el b/contrib/lisp/org-wikinodes.el index 87cc174da..72af6eb6f 100644 --- a/contrib/lisp/org-wikinodes.el +++ b/contrib/lisp/org-wikinodes.el @@ -7,7 +7,7 @@ ;; Homepage: http://orgmode.org ;; Version: 7.01trans ;; -;; This file is part of GNU Emacs. +;; This file is not part of GNU Emacs. ;; ;; GNU Emacs is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by From e4c4d85e594c98c1a0acc7555c216e5539c78a57 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Thu, 16 Aug 2012 00:27:35 +0200 Subject: [PATCH 03/32] ob-ref.el (org-babel-ref-index-list): Fix bug introduced by commit e85479 * ob-ref.el (org-babel-ref-index-list): Fix bug introduced by commit e85479. Thanks to Ivars Finvers who reported it and gave the correct patch. --- lisp/ob-ref.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/ob-ref.el b/lisp/ob-ref.el index d2235898e..79861f1b7 100644 --- a/lisp/ob-ref.el +++ b/lisp/ob-ref.el @@ -240,8 +240,8 @@ to \"0:-1\"." (funcall wrap (string-to-number (match-string 2 portion))) (funcall wrap (string-to-number (match-string 3 portion)))) (list (funcall wrap 0) (funcall wrap -1))))) - (list (nth (funcall wrap (string-to-number portion)) lis))))))) - lis) + (list (nth (funcall wrap (string-to-number portion)) lis)))))) + lis)) (defun org-babel-ref-split-args (arg-string) "Split ARG-STRING into top-level arguments of balanced parenthesis." From 009c530e83cedd3d8966b6111c1129ab1220181f Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Thu, 16 Aug 2012 09:22:22 +0200 Subject: [PATCH 04/32] org-icalendar.el: Code clean up. * org-icalendar.el (org-icalendar-print-entries): Rename from `org-print-icalendar-entries'. (org-icalendar-start-file): Rename from `org-start-icalendar-file'. (org-icalendar-finish-file): Rename from `org-finish-icalendar-file'. (org-icalendar-ts-to-string): Rename from `org-ical-ts-to-string'. (org-export-icalendar): Use the correct functions. --- lisp/org-icalendar.el | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/lisp/org-icalendar.el b/lisp/org-icalendar.el index 3cac791e7..bab366fcf 100644 --- a/lisp/org-icalendar.el +++ b/lisp/org-icalendar.el @@ -28,8 +28,7 @@ (require 'org-exp) -(eval-when-compile - (require 'cl)) +(eval-when-compile (require 'cl)) (declare-function org-bbdb-anniv-export-ical "org-bbdb" nil) @@ -288,20 +287,19 @@ file and store it under the name `org-combined-agenda-icalendar-file'." (let ((standard-output ical-buffer)) (if combine (and (not started) (setq started t) - (org-start-icalendar-file org-icalendar-combined-name)) - (org-start-icalendar-file category)) - (org-print-icalendar-entries combine) + (org-icalendar-start-file org-icalendar-combined-name)) + (org-icalendar-start-file category)) + (org-icalendar-print-entries combine) (when (or (and combine (not files)) (not combine)) (when (and combine org-icalendar-include-bbdb-anniversaries) (require 'org-bbdb) (org-bbdb-anniv-export-ical)) - (org-finish-icalendar-file) + (org-icalendar-finish-file) (set-buffer ical-buffer) (run-hooks 'org-before-save-iCalendar-file-hook) (save-buffer) (run-hooks 'org-after-save-iCalendar-file-hook) - (and (boundp 'org-wait) (numberp org-wait) (sit-for org-wait)) - )))) + (and (boundp 'org-wait) (numberp org-wait) (sit-for org-wait)))))) (org-release-buffers org-agenda-new-buffers)))) (defvar org-before-save-iCalendar-file-hook nil @@ -315,13 +313,13 @@ A good way to use this is to tell a desktop calendar application to re-read the iCalendar file.") (defvar org-agenda-default-appointment-duration) ; defined in org-agenda.el -(defun org-print-icalendar-entries (&optional combine) +(defun org-icalendar-print-entries (&optional combine) "Print iCalendar entries for the current Org-mode file to `standard-output'. When COMBINE is non nil, add the category to each line." (require 'org-agenda) (let ((re1 (concat org-ts-regexp "\\|<%%([^>\n]+>")) (re2 (concat "--?-?\\(" org-ts-regexp "\\)")) - (dts (org-ical-ts-to-string + (dts (org-icalendar-ts-to-string (format-time-string (cdr org-time-stamp-formats) (current-time)) "DTSTART")) hd ts ts2 state status (inc t) pos b sexp rrule @@ -448,8 +446,8 @@ SUMMARY:%s%s%s CATEGORIES:%s%s END:VEVENT\n" (concat prefix uid) - (org-ical-ts-to-string ts "DTSTART") - (org-ical-ts-to-string ts2 "DTEND" inc) + (org-icalendar-ts-to-string ts "DTSTART") + (org-icalendar-ts-to-string ts2 "DTEND" inc) rrule summary (if (and desc (string-match "\\S-" desc)) (concat "\nDESCRIPTION: " desc) "") @@ -532,8 +530,8 @@ END:VEVENT\n" uid (if org-icalendar-store-UID (org-id-get-create) (or (org-id-get) (org-id-new)))) - (and due (setq due (org-ical-ts-to-string due "DUE"))) - (and start (setq start (org-ical-ts-to-string start "DTSTART"))) + (and due (setq due (org-icalendar-ts-to-string due "DUE"))) + (and start (setq start (org-icalendar-ts-to-string start "DTSTART"))) (if (string-match org-bracket-link-regexp hd) (setq hd (replace-match (if (match-end 3) (match-string 3 hd) @@ -636,7 +634,7 @@ not used right now." (when (string-match "[;,:]" s) (setq s (concat "\"" s "\""))) s)) -(defun org-start-icalendar-file (name) +(defun org-icalendar-start-file (name) "Start an iCalendar file by inserting the header." (let ((user user-full-name) (name (or name "unknown")) @@ -653,11 +651,11 @@ X-WR-TIMEZONE:%s X-WR-CALDESC:%s CALSCALE:GREGORIAN\n" name user timezone description)))) -(defun org-finish-icalendar-file () +(defun org-icalendar-finish-file () "Finish an iCalendar file by inserting the END statement." (princ "END:VCALENDAR\n")) -(defun org-ical-ts-to-string (s keyword &optional inc) +(defun org-icalendar-ts-to-string (s keyword &optional inc) "Take a time string S and convert it to iCalendar format. KEYWORD is added in front, to make a complete line like DTSTART.... When INC is non-nil, increase the hour by two (if time string contains From 76b0d582b8733f63685b441ec8124d6b33e267e1 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Thu, 16 Aug 2012 09:24:58 +0200 Subject: [PATCH 05/32] Replace Emacs version to "24.2" by "24.3" This is needed because the current HEAD of the git repository will not be synced with Emacs 24.2 but more likely with Emacs 24.3. --- lisp/org-agenda.el | 2 +- lisp/org-capture.el | 2 +- lisp/org-datetree.el | 2 +- lisp/org-latex.el | 4 ++-- lisp/org.el | 10 +++++----- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 7db4e9dd2..2587341bd 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -886,7 +886,7 @@ you want to use two-columns display (see `org-agenda-menu-two-columns')." :version "24.1" :type 'boolean) -(make-obsolete-variable 'org-agenda-menu-two-column 'org-agenda-menu-two-columns "24.2") +(make-obsolete-variable 'org-agenda-menu-two-column 'org-agenda-menu-two-columns "24.3") (defcustom org-agenda-menu-two-columns nil "Non-nil means, use two columns to show custom commands in the dispatcher. diff --git a/lisp/org-capture.el b/lisp/org-capture.el index a59d9ee5b..8beb9c2a6 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -368,7 +368,7 @@ The capture buffer is current and still narrowed." "When non-nil, add a bookmark pointing at the last stored position when capturing." :group 'org-capture - :version "24.2" + :version "24.3" :type 'boolean) ;;; The property list for keeping information about the capture process diff --git a/lisp/org-datetree.el b/lisp/org-datetree.el index b39dc4448..4ff8e7d00 100644 --- a/lisp/org-datetree.el +++ b/lisp/org-datetree.el @@ -41,7 +41,7 @@ so the base level will be properly adjusted.") (defcustom org-datetree-add-timestamp nil "When non-nil, add a time stamp when create a datetree entry." :group 'org-capture - :version "24.2" + :version "24.3" :type '(choice (const :tag "Do not add a time stamp" nil) (const :tag "Add an inactive time stamp" inactive) diff --git a/lisp/org-latex.el b/lisp/org-latex.el index 1ec5d3695..933fa56b8 100644 --- a/lisp/org-latex.el +++ b/lisp/org-latex.el @@ -330,7 +330,7 @@ its description and the Org's version number, as a string. Set this option to the empty string if you don't want to include hyperref options altogether." :type 'string - :version "24.2" + :version "24.3" :group 'org-export-latex) (defcustom org-export-latex-footnote-separator "\\textsuperscript{,}\\," @@ -649,7 +649,7 @@ and `org-export-with-tags' instead." (defcustom org-export-latex-link-with-unknown-path-format "\\texttt{%s}" "Format string for links with unknown path type." :group 'org-export-latex - :version "24.2" + :version "24.3" :type 'string) (defcustom org-export-latex-inline-image-extensions diff --git a/lisp/org.el b/lisp/org.el index 86ec7472d..6f9aa6520 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -1409,7 +1409,7 @@ description to use." (defcustom org-url-hexify-p t "When non-nil, hexify URL when creating a link." :type 'boolean - :version "24.2" + :version "24.3" :group 'org-link-store) (defcustom org-email-link-description-format "Email %c: %.30s" @@ -1853,7 +1853,7 @@ For more examples, see the system specific constants (defcustom org-doi-server-url "http://dx.doi.org/" "The URL of the DOI server." :type 'string - :version "24.2" + :version "24.3" :group 'org-link-follow) (defgroup org-refile nil @@ -3425,7 +3425,7 @@ imagemagick Convert the LaTeX fragments to pdf files and use imagemagick directories relative to the processed org files paths. An absolute path puts all preview images at the same place." :group 'org-latex - :version "24.2" + :version "24.3" :type 'string) (defun org-format-latex-mathml-available-p () @@ -3611,7 +3611,7 @@ The default use of these custom properties is to let the user hide them with `org-toggle-custom-properties-visibility'." :group 'org-properties :group 'org-appearance - :version "24.2" + :version "24.3" :type '(repeat (string :tag "Property Name"))) (defcustom org-fontify-done-headline nil @@ -4307,7 +4307,7 @@ Otherwise, these types are allowed: (const :tag "Only scheduled timestamps" scheduled) (const :tag "Only deadline timestamps" deadline)) :group 'org-sparse-trees - :version "24.2") + :version "24.3") (defun org-cycle-hide-archived-subtrees (state) "Re-hide all archived subtrees after a visibility state change." From d2200b2bede8d596119c97961aefc6e81319234c Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Thu, 16 Aug 2012 09:42:55 +0200 Subject: [PATCH 06/32] org.el: Allow both "8am Wed" and "Wed 8am" to be parsed correctly * org.el (org-read-date-analyze): Allow both "8am Wed" and "Wed 8am" to be parsed correctly with respect to possible values of `org-read-date-prefer-future'. (org-read-date-prefer-future): Update docstring to remove the restriction about inserting only the time. The user can now insert the time and the day. --- lisp/org.el | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 6f9aa6520..cc5f9f90b 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -2752,8 +2752,8 @@ This affects the following situations: If you set this variable to the symbol `time', then also the following will work: -3. If the user gives a time, but no day. If the time is before now, - to will be interpreted as tomorrow. +3. If the user gives a time. + If the time is before now, it will be interpreted as tomorrow. Currently none of this works for ISO week specifications. @@ -15557,10 +15557,11 @@ user." (setq ans "+0")) (when (setq delta (org-read-date-get-relative ans (current-time) org-def)) - (setq ans (replace-match "" t t ans) - deltan (car delta) - deltaw (nth 1 delta) - deltadef (nth 2 delta))) + (unless (save-match-data (string-match org-plain-time-of-day-regexp ans)) + (setq ans (replace-match "" t t ans) + deltan (car delta) + deltaw (nth 1 delta) + deltadef (nth 2 delta)))) ;; Check if there is an iso week date in there ;; If yes, store the info and postpone interpreting it until the rest @@ -15713,7 +15714,6 @@ user." ((equal deltaw "m") (setq month (+ month deltan))) ((equal deltaw "y") (setq year (+ year deltan))))) ((and wday (not (nth 3 tl))) - (setq futurep nil) ;; Weekday was given, but no day, so pick that day in the week ;; on or after the derived date. (setq wday1 (nth 6 (decode-time (encode-time 0 0 0 day month year)))) From 952d722dcddb275d84ad6dd356bee2fd5c8027c8 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Thu, 16 Aug 2012 12:46:49 +0200 Subject: [PATCH 07/32] org-export: Allow to toggle inlinetasks inclusion in export output * contrib/lisp/org-export.el (org-export-options-alist, org-export--skip-p): Allow to toggle inlinetask inclusion in export. (org-export-headline-levels, org-export-with-priority): Fix docstring. (org-export-with-inlinetasks): New variable. * testing/lisp/test-org-export.el: Add tests. --- contrib/lisp/org-export.el | 17 +++++++++++------ testing/lisp/test-org-export.el | 27 ++++++++++++++++++++++----- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/contrib/lisp/org-export.el b/contrib/lisp/org-export.el index c5cbaaaea..24dc35bf5 100644 --- a/contrib/lisp/org-export.el +++ b/contrib/lisp/org-export.el @@ -138,6 +138,7 @@ (:with-entities nil "e" org-export-with-entities) (:with-fixed-width nil ":" org-export-with-fixed-width) (:with-footnotes nil "f" org-export-with-footnotes) + (:with-inlinetasks nil "inline" org-export-with-inlinetasks) (:with-plannings nil "p" org-export-with-planning) (:with-priority nil "pri" org-export-with-priority) (:with-special-strings nil "-" org-export-with-special-strings) @@ -405,9 +406,7 @@ e.g. \"f:nil\"." (defcustom org-export-headline-levels 3 "The last level which is still exported as a headline. -Inferior levels will produce itemize lists when exported. Note -that a numeric prefix argument to an exporter function overrides -this setting. +Inferior levels will produce itemize lists when exported. This option can also be set with the #+OPTIONS line, e.g. \"H:2\"." :group 'org-export-general @@ -444,6 +443,13 @@ e.g. \"e:nil\"." :group 'org-export-general :type 'boolean) +(defcustom org-export-with-inlinetasks t + "Non-nil means inlinetasks should be exported. +This option can also be set with the #+OPTIONS line, +e.g. \"inline:nil\"." + :group 'org-export-general + :type 'boolean) + (defcustom org-export-with-planning nil "Non-nil means include planning info in export. This option can also be set with the #+OPTIONS: line, @@ -453,9 +459,6 @@ e.g. \"p:t\"." (defcustom org-export-with-priority nil "Non-nil means include priority cookies in export. - -When nil, remove priority cookies for export. - This option can also be set with the #+OPTIONS line, e.g. \"pri:t\"." :group 'org-export-general @@ -1814,6 +1817,8 @@ tag." (and (memq with-tasks '(todo done)) (not (eq todo-type with-tasks))) (and (consp with-tasks) (not (member todo with-tasks)))))))) + ;; Check inlinetask. + (inlinetask (not (plist-get options :with-inlinetasks))) ;; Check timestamp. (timestamp (case (plist-get options :with-timestamps) diff --git a/testing/lisp/test-org-export.el b/testing/lisp/test-org-export.el index 3b372f964..56b351e06 100644 --- a/testing/lisp/test-org-export.el +++ b/testing/lisp/test-org-export.el @@ -65,14 +65,14 @@ already filled in `info'." (equal (org-export--parse-option-keyword "H:1 num:t \\n:t timestamp:t arch:t author:t creator:t d:t email:t - *:t e:t ::t f:t pri:t -:t ^:t toc:t |:t tags:t tasks:t <:t todo:t") + *:t e:t ::t f:t pri:t -:t ^:t toc:t |:t tags:t tasks:t <:t todo:t inline:nil") '(:headline-levels 1 :preserve-breaks t :section-numbers t :time-stamp-file t :with-archived-trees t :with-author t :with-creator t :with-drawers t :with-email t :with-emphasize t :with-entities t :with-fixed-width t - :with-footnotes t :with-priority t :with-special-strings t - :with-sub-superscript t :with-toc t :with-tables t :with-tags t - :with-tasks t :with-timestamps t :with-todo-keywords t))) + :with-footnotes t :with-inlinetasks nil :with-priority t + :with-special-strings t :with-sub-superscript t :with-toc t :with-tables t + :with-tags t :with-tasks t :with-timestamps t :with-todo-keywords t))) ;; Test some special values. (should (equal @@ -265,7 +265,24 @@ Paragraph" "CLOSED: [2012-04-29 sun. 10:45]\n")) (should (equal (org-export-as 'test nil nil nil '(:with-plannings nil)) - "")))))) + ""))))) + ;; Inlinetasks. + (when (featurep 'org-inlinetask) + (should + (equal + (let ((org-inlinetask-min-level 15)) + (org-test-with-temp-text "*************** Task" + (org-test-with-backend test + (org-export-as 'test nil nil nil '(:with-inlinetasks nil))))) + "")) + (should + (equal + (let ((org-inlinetask-min-level 15)) + (org-test-with-temp-text + "*************** Task\nContents\n*************** END" + (org-test-with-backend test + (org-export-as 'test nil nil nil '(:with-inlinetasks nil))))) + "")))) (ert-deftest test-org-export/comment-tree () "Test if export process ignores commented trees." From b1ed817e38e92bc564c14e7f4689135665ff7abd Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Fri, 17 Aug 2012 15:22:36 +0200 Subject: [PATCH 08/32] org-element: Use strict comment syntax (no "#+" allowed) * lisp/org.el (org-fill-paragraph): No need to use `org-element-paragraph-separate' in a verse block since blank lines only can end a "paragraph". * lisp/org-element.el (org-element-paragraph-separate): Apply changes to comments. (org-element-paragraph-parser): Correctly find end of paragraphs. (org-element--current-element): Require colons for Babel calls. (org-element-center-block-parser, org-element-dynamic-block-parser, org-element-quote-block-parser, org-element-special-block-parser, org-element-comment-block-parser, org-element-example-block-parser, org-element-export-block-parser, org-element-src-block-parser, org-element-verse-block-parser): Fall-back to paragraph parsing when incomplete or ill-formed. * testing/lisp/test-org-element.el: Update tests. --- lisp/org-element.el | 72 ++++++++++++++++++++------------ lisp/org.el | 4 +- testing/lisp/test-org-element.el | 12 +++--- 3 files changed, 53 insertions(+), 35 deletions(-) diff --git a/lisp/org-element.el b/lisp/org-element.el index e5e692afb..dea1ff750 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -131,11 +131,12 @@ "[ \t]*\\(?:" ;; Empty lines. "$" "\\|" - ;; Comments, blocks (any type), keywords, Babel calls, - ;; drawers (any type) and tables. - "[|#]" "\\|" - ;; Fixed width areas. - ":\\(?:[ \t]\\|$\\)" "\\|" + ;; Tables (any type). + "\\(?:|\\|\\+-[-+]\\)" "\\|" + ;; Blocks (any type), Babel calls, drawers (any type), + ;; fixed-width areas and keywords. Note: this is only an + ;; indication and need some thorough check. + "[#:]" "\\|" ;; Horizontal rules. "-\\{5,\\}[ \t]*$" "\\|" ;; LaTeX environments. @@ -153,7 +154,10 @@ (concat "\\(?:[-+*]\\|\\(?:[0-9]+" alpha "\\)" term "\\)" "\\(?:[ \t]\\|$\\)")) "\\)\\)") - "Regexp to separate paragraphs in an Org buffer.") + "Regexp to separate paragraphs in an Org buffer. +In the case of lines starting with \"#\" and \":\", this regexp +is not sufficient to know if point is at a paragraph ending. See +`org-element-paragraph-parser' for more information.") (defconst org-element-all-elements '(center-block clock comment comment-block drawer dynamic-block example-block @@ -475,7 +479,7 @@ Assume point is at the beginning of the block." (if (not (save-excursion (re-search-forward "^[ \t]*#\\+END_CENTER" limit t))) ;; Incomplete block: parse it as a comment. - (org-element-comment-parser limit) + (org-element-paragraph-parser limit) (let ((block-end-line (match-beginning 0))) (let* ((keywords (org-element--collect-affiliated-keywords)) (begin (car keywords)) @@ -575,7 +579,7 @@ Assume point is at beginning of dynamic block." (let ((case-fold-search t)) (if (not (save-excursion (re-search-forward org-dblock-end-re limit t))) ;; Incomplete block: parse it as a comment. - (org-element-comment-parser limit) + (org-element-paragraph-parser limit) (let ((block-end-line (match-beginning 0))) (save-excursion (let* ((name (progn (looking-at org-dblock-start-re) @@ -1129,7 +1133,7 @@ Assume point is at the beginning of the block." (if (not (save-excursion (re-search-forward "^[ \t]*#\\+END_QUOTE" limit t))) ;; Incomplete block: parse it as a comment. - (org-element-comment-parser limit) + (org-element-paragraph-parser limit) (let ((block-end-line (match-beginning 0))) (save-excursion (let* ((keywords (org-element--collect-affiliated-keywords)) @@ -1211,7 +1215,7 @@ Assume point is at the beginning of the block." (if (not (save-excursion (re-search-forward (concat "^[ \t]*#\\+END_" type) limit t))) ;; Incomplete block: parse it as a comment. - (org-element-comment-parser limit) + (org-element-paragraph-parser limit) (let ((block-end-line (match-beginning 0))) (save-excursion (let* ((keywords (org-element--collect-affiliated-keywords)) @@ -1359,8 +1363,6 @@ Assume point is at comment beginning." (save-excursion (let* ((keywords (org-element--collect-affiliated-keywords)) (begin (car keywords)) - ;; Match first line with a loose regexp since it might as - ;; well be an ill-defined keyword. (value (prog2 (looking-at "[ \t]*# ?") (buffer-substring-no-properties (match-end 0) (line-end-position)) @@ -1411,7 +1413,7 @@ Assume point is at comment block beginning." (if (not (save-excursion (re-search-forward "^[ \t]*#\\+END_COMMENT" limit t))) ;; Incomplete block: parse it as a comment. - (org-element-comment-parser limit) + (org-element-paragraph-parser limit) (let ((contents-end (match-beginning 0))) (save-excursion (let* ((keywords (org-element--collect-affiliated-keywords)) @@ -1456,7 +1458,7 @@ containing `:begin', `:end', `:number-lines', `:preserve-indent', (if (not (save-excursion (re-search-forward "^[ \t]*#\\+END_EXAMPLE" limit t))) ;; Incomplete block: parse it as a comment. - (org-element-comment-parser limit) + (org-element-paragraph-parser limit) (let ((contents-end (match-beginning 0))) (save-excursion (let* ((switches @@ -1535,7 +1537,7 @@ Assume point is at export-block beginning." (if (not (save-excursion (re-search-forward (concat "^[ \t]*#\\+END_" type) limit t))) ;; Incomplete block: parse it as a comment. - (org-element-comment-parser limit) + (org-element-paragraph-parser limit) (let ((contents-end (match-beginning 0))) (save-excursion (let* ((keywords (org-element--collect-affiliated-keywords)) @@ -1732,12 +1734,27 @@ Assume point is at the beginning of the paragraph." (keywords (org-element--collect-affiliated-keywords)) (begin (car keywords)) (before-blank - (progn (end-of-line) - (if (re-search-forward org-element-paragraph-separate - limit - 'm) - (goto-char (match-beginning 0)) - (point)))) + (let ((case-fold-search t)) + (end-of-line) + (re-search-forward org-element-paragraph-separate limit 'm) + (while (and (/= (point) limit) + (cond ((and (looking-at "[ \t]*:\\S-") + (not (looking-at org-drawer-regexp)))) + ((not (looking-at "[ \t]*#\\S-")) nil) + ((looking-at "[ \t]*\\+BEGIN:? ") + (not (save-excursion + (re-search-forward + "^[ \t]*\\+END:" limit t)))) + ((looking-at "[ \t]*\\+BEGIN_\\(\\S-+\\)") + (not (save-excursion + (re-search-forward + (concat "^[ \t]*\\+END_" + (match-string 1)) + limit t)))) + ((not (looking-at "[ \t]*#\\+\\S-+:"))))) + (when (re-search-forward org-element-paragraph-separate limit 'm) + (goto-char (match-beginning 0)))) + (if (eobp) (point) (goto-char (line-beginning-position))))) (contents-end (progn (skip-chars-backward " \r\t\n" contents-begin) (forward-line) (point))) @@ -1914,7 +1931,7 @@ Assume point is at the beginning of the block." (let ((case-fold-search t)) (if (not (save-excursion (re-search-forward "^[ \t]*#\\+END_SRC" limit t))) ;; Incomplete block: parse it as a comment. - (org-element-comment-parser limit) + (org-element-paragraph-parser limit) (let ((contents-end (match-beginning 0))) (save-excursion (let* ((keywords (org-element--collect-affiliated-keywords)) @@ -2119,7 +2136,7 @@ Assume point is at beginning of the block." (if (not (save-excursion (re-search-forward "^[ \t]*#\\+END_VERSE" limit t))) ;; Incomplete block: parse it as a comment. - (org-element-comment-parser limit) + (org-element-paragraph-parser limit) (let ((contents-end (match-beginning 0))) (save-excursion (let* ((keywords (org-element--collect-affiliated-keywords)) @@ -3325,13 +3342,16 @@ element it has to parse." ;; Keywords. ((looking-at "[ \t]*#") (goto-char (match-end 0)) - (cond ((looking-at "\\+BEGIN_\\(\\S-+\\)") + (cond ((looking-at "\\(?: \\|$\\)") + (beginning-of-line) + (org-element-comment-parser limit)) + ((looking-at "\\+BEGIN_\\(\\S-+\\)") (beginning-of-line) (let ((parser (assoc (upcase (match-string 1)) org-element-block-name-alist))) (if parser (funcall (cdr parser) limit) (org-element-special-block-parser limit)))) - ((looking-at "\\+CALL") + ((looking-at "\\+CALL:") (beginning-of-line) (org-element-babel-call-parser limit)) ((looking-at "\\+BEGIN:? ") @@ -3342,7 +3362,7 @@ element it has to parse." (org-element-keyword-parser limit)) (t (beginning-of-line) - (org-element-comment-parser limit)))) + (org-element-paragraph-parser limit)))) ;; Footnote Definition. ((looking-at org-footnote-definition-re) (org-element-footnote-definition-parser limit)) diff --git a/lisp/org.el b/lisp/org.el index cc5f9f90b..2ddc9a03c 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -21005,7 +21005,6 @@ meant to be filled." (when (and (>= p cbeg) (< p cend)) (if (looking-at "\\s-+") (match-string 0) "")))))))))) -(defvar org-element-paragraph-separate) ; From org-element.el (defvar org-element-all-objects) ; From org-element.el (defun org-fill-paragraph (&optional justify) "Fill element at point, when applicable. @@ -21065,8 +21064,7 @@ a footnote definition, try to fill the first paragraph within." (narrow-to-region beg end) (save-excursion (let ((bol-pos (point-at-bol))) - (re-search-backward - org-element-paragraph-separate nil 'm) + (re-search-backward "^[ \t]*$" nil 'm) (unless (or (bobp) (= (point-at-bol) bol-pos)) (forward-line)) (setq element (org-element-paragraph-parser end) diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el index 6c2b39f59..ae9043fe8 100644 --- a/testing/lisp/test-org-element.el +++ b/testing/lisp/test-org-element.el @@ -297,10 +297,6 @@ CLOCK: [2012-01-01 sun. 00:01]--[2012-01-01 sun. 00:02] => 0:01" (org-test-with-temp-text "# First part\n# \n#\n# Second part" (org-element-map (org-element-parse-buffer) 'comment 'identity nil t))) "First part\n\n\nSecond part")) - ;; Keywords without colons are treated as comments. - (should - (org-test-with-temp-text "#+wrong_keyword something" - (org-element-map (org-element-parse-buffer) 'comment 'identity))) ;; Do not mix comments and keywords. (should (eq 1 @@ -1147,7 +1143,11 @@ e^{i\\pi}+1=0 (org-element-map (org-element-parse-buffer) 'paragraph (lambda (p) (char-after (org-element-property :end p))) - nil t))))) + nil t)))) + ;; Keywords without colons are treated as plain text. + (should + (org-test-with-temp-text "#+wrong_keyword something" + (org-element-map (org-element-parse-buffer) 'paragraph 'identity)))) ;;;; Plain List @@ -1776,7 +1776,7 @@ CLOCK: [2012-01-01 sun. 00:01]--[2012-01-01 sun. 00:02] => 0:01")) (ert-deftest test-org-element/comment-interpreter () "Test comment interpreter." ;; Regular comment. - (should (equal (org-test-parse-and-interpret "#Comment") "# Comment\n")) + (should (equal (org-test-parse-and-interpret "# Comment") "# Comment\n")) ;; Inline comment. (should (equal (org-test-parse-and-interpret " # Comment") "# Comment\n")) From 8ab1d76529093085c6f8a96870527ed0cf0f6231 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Fri, 17 Aug 2012 17:24:33 +0200 Subject: [PATCH 09/32] org-element: Fix previous patch * lisp/org-element.el (org-element-paragraph-parser): Fix previous patch. * testing/lisp/test-org-element.el: Add tests. --- lisp/org-element.el | 50 ++++++++++++++++++++++---------- testing/lisp/test-org-element.el | 28 ++++++++++++++++-- 2 files changed, 60 insertions(+), 18 deletions(-) diff --git a/lisp/org-element.el b/lisp/org-element.el index dea1ff750..b7cdc4428 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -1738,22 +1738,40 @@ Assume point is at the beginning of the paragraph." (end-of-line) (re-search-forward org-element-paragraph-separate limit 'm) (while (and (/= (point) limit) - (cond ((and (looking-at "[ \t]*:\\S-") - (not (looking-at org-drawer-regexp)))) - ((not (looking-at "[ \t]*#\\S-")) nil) - ((looking-at "[ \t]*\\+BEGIN:? ") - (not (save-excursion - (re-search-forward - "^[ \t]*\\+END:" limit t)))) - ((looking-at "[ \t]*\\+BEGIN_\\(\\S-+\\)") - (not (save-excursion - (re-search-forward - (concat "^[ \t]*\\+END_" - (match-string 1)) - limit t)))) - ((not (looking-at "[ \t]*#\\+\\S-+:"))))) - (when (re-search-forward org-element-paragraph-separate limit 'm) - (goto-char (match-beginning 0)))) + (cond + ;; Skip non-existent or incomplete drawer. + ((save-excursion + (beginning-of-line) + (and (looking-at "[ \t]*:\\S-") + (or (not (looking-at org-drawer-regexp)) + (not (save-excursion + (re-search-forward + "^[ \t]*:END:" limit t))))))) + ;; Stop at comments. + ((save-excursion + (beginning-of-line) + (not (looking-at "[ \t]*#\\S-"))) nil) + ;; Skip incomplete dynamic blocks. + ((save-excursion + (beginning-of-line) + (looking-at "[ \t]*#\\+BEGIN: ")) + (not (save-excursion + (re-search-forward + "^[ \t]*\\+END:" limit t)))) + ;; Skip incomplete blocks. + ((save-excursion + (beginning-of-line) + (looking-at "[ \t]*#\\+BEGIN_\\(\\S-+\\)")) + (not (save-excursion + (re-search-forward + (concat "^[ \t]*#\\+END_" + (match-string 1)) + limit t)))) + ;; Skip ill-formed keywords. + ((not (save-excursion + (beginning-of-line) + (looking-at "[ \t]*#\\+\\S-+:")))))) + (re-search-forward org-element-paragraph-separate limit 'm)) (if (eobp) (point) (goto-char (line-beginning-position))))) (contents-end (progn (skip-chars-backward " \r\t\n" contents-begin) (forward-line) diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el index ae9043fe8..df719b78c 100644 --- a/testing/lisp/test-org-element.el +++ b/testing/lisp/test-org-element.el @@ -1144,10 +1144,34 @@ e^{i\\pi}+1=0 (org-element-parse-buffer) 'paragraph (lambda (p) (char-after (org-element-property :end p))) nil t)))) - ;; Keywords without colons are treated as plain text. + ;; Include ill-formed Keywords. (should (org-test-with-temp-text "#+wrong_keyword something" - (org-element-map (org-element-parse-buffer) 'paragraph 'identity)))) + (org-element-map (org-element-parse-buffer) 'paragraph 'identity))) + ;; Include incomplete-drawers. + (should + (let ((org-drawers '("TEST"))) + (org-test-with-temp-text ":TEST:\nParagraph" + (let ((elem (org-element-at-point))) + (and (eq (org-element-type elem) 'paragraph) + (= (point-max) (org-element-property :end elem))))))) + ;; Include non-existent drawers. + (should + (let ((org-drawers '("TEST"))) + (org-test-with-temp-text ":NONAME:" + (org-element-map (org-element-parse-buffer) 'paragraph 'identity)))) + ;; Include incomplete blocks. + (should + (org-test-with-temp-text "#+BEGIN_CENTER\nParagraph" + (let ((elem (org-element-at-point))) + (and (eq (org-element-type elem) 'paragraph) + (= (point-max) (org-element-property :end elem)))))) + ;; Include incomplete dynamic blocks. + (should + (org-test-with-temp-text "#+BEGIN: \nParagraph" + (let ((elem (org-element-at-point))) + (and (eq (org-element-type elem) 'paragraph) + (= (point-max) (org-element-property :end elem))))))) ;;;; Plain List From 50a434bb9faa23396c2619031bd07a2fa2d30d0b Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sat, 18 Aug 2012 09:28:27 +0200 Subject: [PATCH 10/32] org-list: Fix list type with mixed constructs * lisp/org-list.el (org-list-automatic-rules): Remove `bullet' rule, which is now hard-coded. (org-cycle-list-bullet): Hard code `bullet' rule. (org-list-get-list-type): Make sure a list with numbered bullets cannot have `descriptive' type. * testing/lisp/test-org-list.el: Add tests. --- lisp/org-list.el | 21 +++---- testing/lisp/test-org-list.el | 105 ++++++++++++++++++++++++++++++++++ 2 files changed, 112 insertions(+), 14 deletions(-) diff --git a/lisp/org-list.el b/lisp/org-list.el index a3ea49f5f..9b254b246 100644 --- a/lisp/org-list.el +++ b/lisp/org-list.el @@ -236,8 +236,7 @@ Otherwise, two of them will be necessary." :group 'org-plain-lists :type 'boolean) -(defcustom org-list-automatic-rules '((bullet . t) - (checkbox . t) +(defcustom org-list-automatic-rules '((checkbox . t) (indent . t)) "Non-nil means apply set of rules when acting on lists. By default, automatic actions are taken when using @@ -247,9 +246,6 @@ By default, automatic actions are taken when using \\[org-insert-todo-heading]. You can disable individually these rules by setting them to nil. Valid rules are: -bullet when non-nil, cycling bullet do not allow lists at - column 0 to have * as a bullet and descriptions lists - to be numbered. checkbox when non-nil, checkbox statistics is updated each time you either insert a new checkbox or toggle a checkbox. indent when non-nil, indenting or outdenting list top-item @@ -261,7 +257,6 @@ indent when non-nil, indenting or outdenting list top-item :type '(alist :tag "Sets of rules" :key-type (choice - (const :tag "Bullet" bullet) (const :tag "Checkbox" checkbox) (const :tag "Indent" indent)) :value-type @@ -1013,8 +1008,8 @@ Possible types are `descriptive', `ordered' and `unordered'. The type is determined by the first item of the list." (let ((first (org-list-get-list-begin item struct prevs))) (cond - ((org-list-get-tag first struct) 'descriptive) ((string-match "[[:alnum:]]" (org-list-get-bullet first struct)) 'ordered) + ((org-list-get-tag first struct) 'descriptive) (t 'unordered)))) (defun org-list-get-item-number (item struct prevs parents) @@ -2228,7 +2223,6 @@ is an integer, 0 means `-', 1 means `+' etc. If WHICH is (prevs (org-list-prevs-alist struct)) (list-beg (org-list-get-first-item (point) struct prevs)) (bullet (org-list-get-bullet list-beg struct)) - (bullet-rule-p (cdr (assq 'bullet org-list-automatic-rules))) (alpha-p (org-list-use-alpha-bul-p list-beg struct prevs)) (case-fold-search nil) (current (cond @@ -2243,22 +2237,21 @@ is an integer, 0 means `-', 1 means `+' etc. If WHICH is (bullet-list (append '("-" "+" ) ;; *-bullets are not allowed at column 0. - (unless (and bullet-rule-p - (looking-at "\\S-")) '("*")) + (unless (looking-at "\\S-") '("*")) ;; Description items cannot be numbered. (unless (or (eq org-plain-list-ordered-item-terminator ?\)) - (and bullet-rule-p (org-at-item-description-p))) + (org-at-item-description-p)) '("1.")) (unless (or (eq org-plain-list-ordered-item-terminator ?.) - (and bullet-rule-p (org-at-item-description-p))) + (org-at-item-description-p)) '("1)")) (unless (or (not alpha-p) (eq org-plain-list-ordered-item-terminator ?\)) - (and bullet-rule-p (org-at-item-description-p))) + (org-at-item-description-p)) '("a." "A.")) (unless (or (not alpha-p) (eq org-plain-list-ordered-item-terminator ?.) - (and bullet-rule-p (org-at-item-description-p))) + (org-at-item-description-p)) '("a)" "A)")))) (len (length bullet-list)) (item-index (- len (length (member current bullet-list)))) diff --git a/testing/lisp/test-org-list.el b/testing/lisp/test-org-list.el index 41721a563..d57ebc94e 100644 --- a/testing/lisp/test-org-list.el +++ b/testing/lisp/test-org-list.el @@ -113,6 +113,111 @@ (org-previous-item) (should (looking-at " - item 1.3")))))) +(ert-deftest test-org-list/cycle-bullet () + "Test `org-cycle-list-bullet' specifications." + ;; Error when not at an item. + (should-error + (org-test-with-temp-text "Paragraph" + (org-cycle-list-bullet))) + ;; Cycle through "-", "+", "*", "1.", "1)". + (org-test-with-temp-text " - item" + (org-cycle-list-bullet) + (should (looking-at "[ \t]+\\+")) + (org-cycle-list-bullet) + (should (looking-at "[ \t]+\\*")) + (let ((org-plain-list-ordered-item-terminator t)) + (org-cycle-list-bullet)) + (should (looking-at "[ \t]+1\\.")) + (let ((org-plain-list-ordered-item-terminator t)) + (org-cycle-list-bullet)) + (should (looking-at "[ \t]+1)"))) + ;; Argument is a valid bullet: cycle to that bullet directly. + (should + (equal "1. item" + (org-test-with-temp-text "- item" + (let ((org-plain-list-ordered-item-terminator t)) + (org-cycle-list-bullet "1.") + (buffer-string))))) + ;; Argument is an integer N: cycle to the Nth allowed bullet. + (should + (equal "+ item" + (org-test-with-temp-text "1. item" + (let ((org-plain-list-ordered-item-terminator t)) + (org-cycle-list-bullet 1) + (buffer-string))))) + ;; Argument is `previous': cycle backwards. + (should + (equal "- item" + (org-test-with-temp-text "+ item" + (let ((org-plain-list-ordered-item-terminator t)) + (org-cycle-list-bullet 'previous) + (buffer-string))))) + ;; Do not cycle to "*" bullets when item is at column 0. + (should + (equal "1. item" + (org-test-with-temp-text "+ item" + (let ((org-plain-list-ordered-item-terminator t)) + (org-cycle-list-bullet) + (buffer-string))))) + ;; Do not cycle to numbered bullets in a description list. + (should-not + (equal "1. tag :: item" + (org-test-with-temp-text "+ tag :: item" + (let ((org-plain-list-ordered-item-terminator t)) + (org-cycle-list-bullet) + (buffer-string))))) + ;; Do not cycle to ordered item terminators if they are not allowed + ;; in `org-plain-list-ordered-item-terminator'. + (should + (equal " 1) item" + (org-test-with-temp-text " * item" + (let ((org-plain-list-ordered-item-terminator 41)) + (org-cycle-list-bullet) + (buffer-string))))) + ;; When `org-alphabetical-lists' is non-nil, cycle to alpha bullets. + (should + (equal "a. item" + (org-test-with-temp-text "1) item" + (let ((org-plain-list-ordered-item-terminator t) + (org-alphabetical-lists t)) + (org-cycle-list-bullet) + (buffer-string))))) + ;; Do not cycle to alpha bullets when list has more than 26 + ;; elements. + (should-not + (equal "a. item 1" + (org-test-with-temp-text "1) item 1 +2) item 2 +3) item 3 +4) item 4 +5) item 5 +6) item 6 +7) item 7 +8) item 8 +9) item 9 +10) item 10 +11) item 11 +12) item 12 +13) item 13 +14) item 14 +15) item 15 +16) item 16 +17) item 17 +18) item 18 +19) item 19 +20) item 20 +21) item 21 +22) item 22 +23) item 23 +24) item 24 +25) item 25 +26) item 26 +27) item 27" + (let ((org-plain-list-ordered-item-terminator t) + (org-alphabetical-lists t)) + (org-cycle-list-bullet) + (buffer-substring (point) (line-end-position))))))) + (ert-deftest test-org-list/indent-item () "Test `org-indent-item' specifications." ;; 1. Error when not at an item. From 445a90ceeb30b0edf57dc79564cd3fa5fb4e0087 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sat, 18 Aug 2012 10:00:58 +0200 Subject: [PATCH 11/32] Update documentation with regards to lists * doc/org.texi (Plain lists): Remove reference to now hard-coded `bullet' automatic rule. --- doc/org.texi | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/doc/org.texi b/doc/org.texi index 3fdb4ac6b..1d30a0614 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -1775,19 +1775,16 @@ state of the checkbox. In any case, verify bullets and indentation consistency in the whole list. @kindex C-c - @vindex org-plain-list-ordered-item-terminator -@vindex org-list-automatic-rules @item C-c - Cycle the entire list level through the different itemize/enumerate bullets (@samp{-}, @samp{+}, @samp{*}, @samp{1.}, @samp{1)}) or a subset of them, depending on @code{org-plain-list-ordered-item-terminator}, the type of list, -and its position@footnote{See @code{bullet} rule in -@code{org-list-automatic-rules} for more information.}. With a numeric -prefix argument N, select the Nth bullet from this list. If there is an -active region when calling this, selected text will be changed into an item. -With a prefix argument, all lines will be converted to list items. If the -first line already was a list item, any item marker will be removed from the -list. Finally, even without an active region, a normal line will be -converted into a list item. +and its indentation. With a numeric prefix argument N, select the Nth bullet +from this list. If there is an active region when calling this, selected +text will be changed into an item. With a prefix argument, all lines will be +converted to list items. If the first line already was a list item, any item +marker will be removed from the list. Finally, even without an active +region, a normal line will be converted into a list item. @kindex C-c * @item C-c * Turn a plain list item into a headline (so that it becomes a subheading at From 3f57803fb4cbbcc5b7f1c38d6c6c7a287f847753 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sat, 18 Aug 2012 10:13:35 +0200 Subject: [PATCH 12/32] org-element: Generalize `org-element-adopt-element' into `org-element-adopt-elements' * lisp/org-element.el (org-element-set-element): Rewrite function. (org-element-adopt-elements): New function. (org-element-adopt-element): Removed function. (org-element--parse-elements, org-element--parse-objects): Use new function. * testing/lisp/test-org-element.el: Update tests. --- lisp/org-element.el | 69 ++++++++++++++++---------------- testing/lisp/test-org-element.el | 21 +++------- 2 files changed, 41 insertions(+), 49 deletions(-) diff --git a/lisp/org-element.el b/lisp/org-element.el index b7cdc4428..3109186c0 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -346,7 +346,7 @@ still has an entry since one of its properties (`:title') does.") ;; Setter functions allow to modify elements by side effect. There is ;; `org-element-put-property', `org-element-set-contents', ;; `org-element-set-element' and `org-element-adopt-element'. Note -;; that `org-element-set-element' and `org-element-adopt-element' are +;; that `org-element-set-element' and `org-element-adopt-elements' are ;; higher level functions since also update `:parent' property. (defsubst org-element-type (element) @@ -393,38 +393,39 @@ Return modified element." (defsubst org-element-set-element (old new) "Replace element or object OLD with element or object NEW. The function takes care of setting `:parent' property for NEW." - ;; OLD can belong to the contents of PARENT or to its secondary - ;; string. - (let* ((parent (org-element-property :parent old)) - (sec-loc (cdr (assq (org-element-type parent) - org-element-secondary-value-alist))) - (sec-value (and sec-loc (org-element-property sec-loc parent))) - (place (or (memq old sec-value) (memq old parent)))) - ;; Make sure NEW has correct `:parent' property. - (org-element-put-property new :parent parent) - ;; Replace OLD with NEW in PARENT. - (setcar place new))) + ;; Since OLD is going to be changed into NEW by side-effect, first + ;; make sure that every element or object within NEW has OLD as + ;; parent. + (mapc (lambda (blob) (org-element-put-property blob :parent old)) + (org-element-contents new)) + ;; Transfer contents. + (apply 'org-element-set-contents old (org-element-contents new)) + ;; Ensure NEW has same parent as OLD, then overwrite OLD properties + ;; with NEW's. + (org-element-put-property new :parent (org-element-property :parent old)) + (setcar (cdr old) (nth 1 new)) + ;; Transfer type. + (setcar old (car new))) -(defsubst org-element-adopt-element (parent child &optional append) - "Add an element to the contents of another element. +(defsubst org-element-adopt-elements (parent &rest children) + "Append elements to the contents of another element. -PARENT is an element or object. CHILD is an element, an object, -or a string. - -CHILD is added at the beginning of PARENT contents, unless the -optional argument APPEND is non-nil, in which case CHILD is added -at the end. +PARENT is an element or object. CHILDREN can be elements, +objects, or a strings. The function takes care of setting `:parent' property for CHILD. Return parent element." - (if (not parent) (list child) - (let ((contents (org-element-contents parent))) - (apply 'org-element-set-contents - parent - (if append (append contents (list child)) (cons child contents)))) - ;; Link the CHILD element with PARENT. - (when (consp child) (org-element-put-property child :parent parent)) - ;; Return the parent element. + (if (not parent) children + ;; Link every child to PARENT. + (mapc (lambda (child) + (unless (stringp child) + (org-element-put-property child :parent parent))) + children) + ;; Add CHILDREN at the end of PARENT contents. + (apply 'org-element-set-contents + parent + (nconc (org-element-contents parent) children)) + ;; Return modified PARENT element. parent)) @@ -3738,7 +3739,7 @@ Elements are accumulated into ACC." (org-element--parse-objects cbeg (org-element-property :contents-end element) element (org-element-restriction type)))) - (org-element-adopt-element acc element t))) + (org-element-adopt-elements acc element))) ;; Return result. acc)) @@ -3765,11 +3766,11 @@ current object." (let ((obj-beg (org-element-property :begin next-object))) (unless (= (point) obj-beg) (setq acc - (org-element-adopt-element + (org-element-adopt-elements acc (replace-regexp-in-string "\t" (make-string tab-width ? ) - (buffer-substring-no-properties (point) obj-beg)) t)))) + (buffer-substring-no-properties (point) obj-beg)))))) ;; 2. Object... (let ((obj-end (org-element-property :end next-object)) (cont-beg (org-element-property :contents-begin next-object))) @@ -3784,16 +3785,16 @@ current object." (org-element--parse-objects (point-min) (point-max) next-object (org-element-restriction next-object)))) - (setq acc (org-element-adopt-element acc next-object t)) + (setq acc (org-element-adopt-elements acc next-object)) (goto-char obj-end)))) ;; 3. Text after last object. Untabify it. (unless (= (point) end) (setq acc - (org-element-adopt-element + (org-element-adopt-elements acc (replace-regexp-in-string "\t" (make-string tab-width ? ) - (buffer-substring-no-properties (point) end)) t))) + (buffer-substring-no-properties (point) end))))) ;; Result. acc))) diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el index df719b78c..feeee6b6f 100644 --- a/testing/lisp/test-org-element.el +++ b/testing/lisp/test-org-element.el @@ -128,34 +128,25 @@ Some other text (org-element-map tree 'italic 'identity nil t)) (org-element-map tree 'paragraph 'identity nil t)))))) -(ert-deftest test-org-element/adopt-element () - "Test `org-element-adopt-element' specifications." +(ert-deftest test-org-element/adopt-elements () + "Test `org-element-adopt-elements' specifications." ;; Adopt an element. (should - (equal '(italic plain-text) + (equal '(plain-text italic) (org-test-with-temp-text "* Headline\n *a*" (let ((tree (org-element-parse-buffer))) - (org-element-adopt-element + (org-element-adopt-elements (org-element-map tree 'bold 'identity nil t) '(italic nil "a")) (mapcar (lambda (blob) (org-element-type blob)) (org-element-contents (org-element-map tree 'bold 'identity nil t))))))) ;; Adopt a string. - (should - (equal '("b" "a") - (org-test-with-temp-text "* Headline\n *a*" - (let ((tree (org-element-parse-buffer))) - (org-element-adopt-element - (org-element-map tree 'bold 'identity nil t) "b") - (org-element-contents - (org-element-map tree 'bold 'identity nil t)))))) - ;; Test APPEND optional argument. (should (equal '("a" "b") (org-test-with-temp-text "* Headline\n *a*" (let ((tree (org-element-parse-buffer))) - (org-element-adopt-element - (org-element-map tree 'bold 'identity nil t) "b" t) + (org-element-adopt-elements + (org-element-map tree 'bold 'identity nil t) "b") (org-element-contents (org-element-map tree 'bold 'identity nil t))))))) From ad94a9433b397f11b1041ae60cc0949a6a56f157 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sat, 18 Aug 2012 12:37:39 +0200 Subject: [PATCH 13/32] Addendum to 50a434bb9faa23396c2619031bd07a2fa2d30d0b * lisp/org-element.el (org-element-item-parser): Do not remove tag from body if list isn't descriptive. * lisp/org-list.el (org-insert-item): Only ask about a term for descriptive lists. (org-list-struct, org-list-insert-item): Do not recognize a tag in an ordered list. * testing/lisp/test-org-element.el: Add test. --- lisp/org-element.el | 45 ++++++++++++++++++-------------- lisp/org-list.el | 35 ++++++++++++++++++------- testing/lisp/test-org-element.el | 6 +++++ 3 files changed, 56 insertions(+), 30 deletions(-) diff --git a/lisp/org-element.el b/lisp/org-element.el index 3109186c0..c3cef453f 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -984,34 +984,39 @@ string instead. Assume point is at the beginning of the item." (save-excursion (beginning-of-line) + (looking-at org-list-full-item-re) (let* ((begin (point)) - (bullet (org-list-get-bullet (point) struct)) - (checkbox (let ((box (org-list-get-checkbox begin struct))) + (bullet (org-match-string-no-properties 1)) + (checkbox (let ((box (org-match-string-no-properties 3))) (cond ((equal "[ ]" box) 'off) ((equal "[X]" box) 'on) ((equal "[-]" box) 'trans)))) - (counter (let ((c (org-list-get-counter begin struct))) - (cond - ((not c) nil) - ((string-match "[A-Za-z]" c) - (- (string-to-char (upcase (match-string 0 c))) - 64)) - ((string-match "[0-9]+" c) - (string-to-number (match-string 0 c)))))) + (counter (let ((c (org-match-string-no-properties 2))) + (save-match-data + (cond + ((not c) nil) + ((string-match "[A-Za-z]" c) + (- (string-to-char (upcase (match-string 0 c))) + 64)) + ((string-match "[0-9]+" c) + (string-to-number (match-string 0 c))))))) (end (save-excursion (goto-char (org-list-get-item-end begin struct)) (unless (bolp) (forward-line)) (point))) - (contents-begin (progn (looking-at org-list-full-item-re) - (goto-char (match-end 0)) - (skip-chars-forward " \r\t\n" limit) - ;; If first line isn't empty, - ;; contents really start at the text - ;; after item's meta-data. - (if (= (point-at-bol) begin) (point) - (point-at-bol)))) + (contents-begin + (progn (goto-char + ;; Ignore tags in un-ordered lists: they are just + ;; a part of item's body. + (if (and (match-beginning 4) + (save-match-data (string-match "[.)]" bullet))) + (match-beginning 4) + (match-end 0))) + (skip-chars-forward " \r\t\n" limit) + ;; If first line isn't empty, contents really start + ;; at the text after item's meta-data. + (if (= (point-at-bol) begin) (point) (point-at-bol)))) (hidden (progn (forward-line) - (and (not (= (point) end)) - (org-invisible-p2)))) + (and (not (= (point) end)) (org-invisible-p2)))) (contents-end (progn (goto-char end) (skip-chars-backward " \r\t\n") (forward-line) diff --git a/lisp/org-list.el b/lisp/org-list.el index 9b254b246..043564130 100644 --- a/lisp/org-list.el +++ b/lisp/org-list.el @@ -621,12 +621,15 @@ Assume point is at an item." ;; Return association at point. (lambda (ind) (looking-at org-list-full-item-re) - (list (point) - ind - (match-string-no-properties 1) ; bullet - (match-string-no-properties 2) ; counter - (match-string-no-properties 3) ; checkbox - (match-string-no-properties 4))))) ; description tag + (let ((bullet (match-string-no-properties 1))) + (list (point) + ind + bullet + (match-string-no-properties 2) ; counter + (match-string-no-properties 3) ; checkbox + ;; Description tag. + (and (save-match-data (string-match "[-+*]" bullet)) + (match-string-no-properties 4))))))) (end-before-blank (function ;; Ensure list ends at the first blank line. @@ -1253,8 +1256,15 @@ This function modifies STRUCT." (let* ((item (progn (goto-char pos) (goto-char (org-list-get-item-begin)))) (item-end (org-list-get-item-end item struct)) (item-end-no-blank (org-list-get-item-end-before-blank item struct)) - (beforep (and (looking-at org-list-full-item-re) - (<= pos (match-end 0)))) + (beforep + (progn + (looking-at org-list-full-item-re) + ;; Do not count tag in a non-descriptive list. + (<= pos (if (and (match-beginning 4) + (save-match-data + (string-match "[.)]" (match-string 1)))) + (match-beginning 4) + (match-end 0))))) (split-line-p (org-get-alist-option org-M-RET-may-split-line 'item)) (blank-nb (org-list-separating-blank-lines-number pos struct prevs)) @@ -2187,14 +2197,19 @@ item is invisible." (org-list-struct))) (prevs (org-list-prevs-alist struct)) ;; If we're in a description list, ask for the new term. - (desc (when (org-list-get-tag itemp struct) + (desc (when (eq (org-list-get-list-type itemp struct prevs) + 'descriptive) (concat (read-string "Term: ") " :: ")))) (setq struct (org-list-insert-item pos struct prevs checkbox desc)) (org-list-write-struct struct (org-list-parents-alist struct)) (when checkbox (org-update-checkbox-count-maybe)) (looking-at org-list-full-item-re) - (goto-char (match-end 0)) + (goto-char (if (and (match-beginning 4) + (save-match-data + (string-match "[.)]" (match-string 1)))) + (match-beginning 4) + (match-end 0))) t))))) (defun org-list-repair () diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el index feeee6b6f..63faca1b1 100644 --- a/testing/lisp/test-org-element.el +++ b/testing/lisp/test-org-element.el @@ -890,6 +890,12 @@ DEADLINE: <2012-03-29 thu.>" :tag (org-test-with-temp-text "- tag :: description" (org-element-map (org-element-parse-buffer) 'item 'identity nil t))))) + ;; No tags in ordered lists. + (should-not + (org-element-property + :tag + (org-test-with-temp-text "1. tag :: description" + (org-element-map (org-element-parse-buffer) 'item 'identity nil t)))) ;; Check-boxes (should (equal From 7a1bd94df1b078b432b072dafa515ba1cf9a97c8 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sat, 18 Aug 2012 13:34:27 +0200 Subject: [PATCH 14/32] org-element: Fix some code comments --- lisp/org-element.el | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lisp/org-element.el b/lisp/org-element.el index c3cef453f..5efa6661b 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -479,7 +479,7 @@ Assume point is at the beginning of the block." (let ((case-fold-search t)) (if (not (save-excursion (re-search-forward "^[ \t]*#\\+END_CENTER" limit t))) - ;; Incomplete block: parse it as a comment. + ;; Incomplete block: parse it as a paragraph. (org-element-paragraph-parser limit) (let ((block-end-line (match-beginning 0))) (let* ((keywords (org-element--collect-affiliated-keywords)) @@ -579,7 +579,7 @@ containing `:block-name', `:begin', `:end', `:hiddenp', Assume point is at beginning of dynamic block." (let ((case-fold-search t)) (if (not (save-excursion (re-search-forward org-dblock-end-re limit t))) - ;; Incomplete block: parse it as a comment. + ;; Incomplete block: parse it as a paragraph. (org-element-paragraph-parser limit) (let ((block-end-line (match-beginning 0))) (save-excursion @@ -1138,7 +1138,7 @@ Assume point is at the beginning of the block." (let ((case-fold-search t)) (if (not (save-excursion (re-search-forward "^[ \t]*#\\+END_QUOTE" limit t))) - ;; Incomplete block: parse it as a comment. + ;; Incomplete block: parse it as a paragraph. (org-element-paragraph-parser limit) (let ((block-end-line (match-beginning 0))) (save-excursion @@ -1220,7 +1220,7 @@ Assume point is at the beginning of the block." (upcase (match-string-no-properties 1))))) (if (not (save-excursion (re-search-forward (concat "^[ \t]*#\\+END_" type) limit t))) - ;; Incomplete block: parse it as a comment. + ;; Incomplete block: parse it as a paragraph. (org-element-paragraph-parser limit) (let ((block-end-line (match-beginning 0))) (save-excursion @@ -1418,7 +1418,7 @@ Assume point is at comment block beginning." (let ((case-fold-search t)) (if (not (save-excursion (re-search-forward "^[ \t]*#\\+END_COMMENT" limit t))) - ;; Incomplete block: parse it as a comment. + ;; Incomplete block: parse it as a paragraph. (org-element-paragraph-parser limit) (let ((contents-end (match-beginning 0))) (save-excursion @@ -1463,7 +1463,7 @@ containing `:begin', `:end', `:number-lines', `:preserve-indent', (let ((case-fold-search t)) (if (not (save-excursion (re-search-forward "^[ \t]*#\\+END_EXAMPLE" limit t))) - ;; Incomplete block: parse it as a comment. + ;; Incomplete block: parse it as a paragraph. (org-element-paragraph-parser limit) (let ((contents-end (match-beginning 0))) (save-excursion @@ -1542,7 +1542,7 @@ Assume point is at export-block beginning." (upcase (org-match-string-no-properties 1))))) (if (not (save-excursion (re-search-forward (concat "^[ \t]*#\\+END_" type) limit t))) - ;; Incomplete block: parse it as a comment. + ;; Incomplete block: parse it as a paragraph. (org-element-paragraph-parser limit) (let ((contents-end (match-beginning 0))) (save-excursion @@ -1954,7 +1954,7 @@ containing `:language', `:switches', `:parameters', `:begin', Assume point is at the beginning of the block." (let ((case-fold-search t)) (if (not (save-excursion (re-search-forward "^[ \t]*#\\+END_SRC" limit t))) - ;; Incomplete block: parse it as a comment. + ;; Incomplete block: parse it as a paragraph. (org-element-paragraph-parser limit) (let ((contents-end (match-beginning 0))) (save-excursion @@ -2159,7 +2159,7 @@ Assume point is at beginning of the block." (let ((case-fold-search t)) (if (not (save-excursion (re-search-forward "^[ \t]*#\\+END_VERSE" limit t))) - ;; Incomplete block: parse it as a comment. + ;; Incomplete block: parse it as a paragraph. (org-element-paragraph-parser limit) (let ((contents-end (match-beginning 0))) (save-excursion From 8d382158e751722fc93ef234a9af884054a0c9de Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Sat, 18 Aug 2012 16:58:28 +0200 Subject: [PATCH 15/32] 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 3a8969edbcea3f053c0bd936fafadf1a01a2aa16 Mon Sep 17 00:00:00 2001 From: Jambunathan K Date: Sat, 18 Aug 2012 21:03:49 +0530 Subject: [PATCH 16/32] org-e-html-table: Emit `caption' elements only when required --- contrib/lisp/org-e-html.el | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/contrib/lisp/org-e-html.el b/contrib/lisp/org-e-html.el index 1c06005f9..4e9d39828 100644 --- a/contrib/lisp/org-e-html.el +++ b/contrib/lisp/org-e-html.el @@ -2835,10 +2835,9 @@ contextual information." (org-export-solidify-link-text label))))))) ;; Remove last blank line. (setq contents (substring contents 0 -1)) - ;; FIXME: splice - (format "\n%s\n%s\n%s\n" + (format "\n%s\n%s\n%s\n" table-attributes - (or caption "") + (if (not caption) "" (format "%s" caption)) (funcall table-column-specs table info) contents))))) From f25baf9e1ea22e7c088941ecead10d53dbe4d897 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Sat, 18 Aug 2012 17:49:01 +0200 Subject: [PATCH 17/32] 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 18/32] =?UTF-8?q?org.el:=20Fix=20bug=20in=20=CC=80org-font?= =?UTF-8?q?ify-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 19/32] 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 20/32] 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 21/32] 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 22/32] 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 23/32] 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 () From e8046d2f6330895e36d2f79a20b740f28df092a4 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sun, 19 Aug 2012 10:25:39 +0200 Subject: [PATCH 24/32] Fix comment fontification * lisp/org.el (org-set-font-lock-defaults): Fix comment fontification. --- lisp/org.el | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index fdaa16881..cf69b83af 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -5090,7 +5090,7 @@ The following commands are available: (org-update-radio-target-regexp) ;; Comments (org-set-local 'comment-use-syntax nil) - (org-set-local 'comment-start "#") + (org-set-local 'comment-start "# ") (org-set-local 'comment-start-skip "# ?") (org-set-local 'comment-insert-comment-function 'org-insert-comment) (org-set-local 'comment-region-function 'org-comment-or-uncomment-region) @@ -5993,7 +5993,6 @@ needs to be inserted at a specific position in the font-lock sequence.") org-comment-string "\\|" org-quote-string "\\)")) '(2 'org-special-keyword t)) - '("^[ \t]*#.*" (0 'font-lock-comment-face t)) ;; Blocks and meta lines '(org-fontify-meta-lines-and-blocks) ))) From ecb8fbd7d58d690f17c24c3ae6ab88e7685db26a Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sun, 19 Aug 2012 11:07:50 +0200 Subject: [PATCH 25/32] Line with a single hash sign on it is a comment * lisp/org.el (org-mode): Line with a single hash sign on it is a comment. --- lisp/org.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/org.el b/lisp/org.el index cf69b83af..3bf338d69 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -5091,7 +5091,7 @@ The following commands are available: ;; Comments (org-set-local 'comment-use-syntax nil) (org-set-local 'comment-start "# ") - (org-set-local 'comment-start-skip "# ?") + (org-set-local 'comment-start-skip "#\\(?:[ \t]\\|$\\)") (org-set-local 'comment-insert-comment-function 'org-insert-comment) (org-set-local 'comment-region-function 'org-comment-or-uncomment-region) (org-set-local 'uncomment-region-function 'org-comment-or-uncomment-region) From a3c4e10ac1e85277d2bd70371b9be3117c59950b Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sun, 19 Aug 2012 12:56:57 +0200 Subject: [PATCH 26/32] Fix filling in in a narrowed buffer * lisp/org.el (org-fill-paragraph): Fix filling in a narrowed buffer. (org-fill-context-prefix): Fill prefix doesn't depend on current narrowing. * testing/lisp/test-org.el: Add test. --- lisp/org.el | 124 +++++++++++++++++++++------------------ testing/lisp/test-org.el | 8 +++ 2 files changed, 74 insertions(+), 58 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 3bf338d69..168d4701e 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -20962,50 +20962,50 @@ hierarchy of headlines by UP levels before marking the subtree." "Compute a fill prefix for the line at point P. Return fill prefix, as a string, or nil if current line isn't meant to be filled." - (unless (and (derived-mode-p 'message-mode) (not (message-in-body-p))) - ;; FIXME: Prevent an error for users who forgot to make autoloads? - ;; See also `org-fill-paragraph', which has the same. - (require 'org-element) - ;; FIXME: This is really the job of orgstruct++-mode - (save-excursion - (goto-char p) - (beginning-of-line) - (let* ((element (org-element-at-point)) - (type (org-element-type element)) - (post-affiliated - (progn - (goto-char (org-element-property :begin element)) - (while (looking-at org-element--affiliated-re) (forward-line)) - (point)))) - (unless (< p post-affiliated) - (case type - (comment (looking-at "[ \t]*# ?") (match-string 0)) - (footnote-definition "") - ((item plain-list) - (make-string (org-list-item-body-column - (org-element-property :begin element)) - ? )) - (paragraph - ;; Fill prefix is usually the same as the current line, - ;; except if the paragraph is at the beginning of an item. - (let ((parent (org-element-property :parent element))) - (cond ((eq (org-element-type parent) 'item) - (make-string (org-list-item-body-column - (org-element-property :begin parent)) - ? )) - ((looking-at "\\s-+") (match-string 0)) - (t "")))) - ((comment-block verse-block) - ;; Only fill contents if P is within block boundaries. - (let* ((cbeg (save-excursion (goto-char post-affiliated) - (forward-line) - (point))) - (cend (save-excursion - (goto-char (org-element-property :end element)) - (skip-chars-backward " \r\t\n") - (line-beginning-position)))) - (when (and (>= p cbeg) (< p cend)) - (if (looking-at "\\s-+") (match-string 0) "")))))))))) + (org-with-wide-buffer + (unless (and (derived-mode-p 'message-mode) (not (message-in-body-p))) + ;; FIXME: Prevent an error for users who forgot to make autoloads? + ;; See also `org-fill-paragraph', which has the same. + (require 'org-element) + ;; FIXME: This is really the job of orgstruct++-mode + (goto-char p) + (beginning-of-line) + (let* ((element (org-element-at-point)) + (type (org-element-type element)) + (post-affiliated + (progn + (goto-char (org-element-property :begin element)) + (while (looking-at org-element--affiliated-re) (forward-line)) + (point)))) + (unless (< p post-affiliated) + (case type + (comment (looking-at "[ \t]*# ?") (match-string 0)) + (footnote-definition "") + ((item plain-list) + (make-string (org-list-item-body-column + (org-element-property :begin element)) + ? )) + (paragraph + ;; Fill prefix is usually the same as the current line, + ;; except if the paragraph is at the beginning of an item. + (let ((parent (org-element-property :parent element))) + (cond ((eq (org-element-type parent) 'item) + (make-string (org-list-item-body-column + (org-element-property :begin parent)) + ? )) + ((looking-at "\\s-+") (match-string 0)) + (t "")))) + ((comment-block verse-block) + ;; Only fill contents if P is within block boundaries. + (let* ((cbeg (save-excursion (goto-char post-affiliated) + (forward-line) + (point))) + (cend (save-excursion + (goto-char (org-element-property :end element)) + (skip-chars-backward " \r\t\n") + (line-beginning-position)))) + (when (and (>= p cbeg) (< p cend)) + (if (looking-at "\\s-+") (match-string 0) "")))))))))) (defvar org-element-all-objects) ; From org-element.el (defun org-fill-paragraph (&optional justify) @@ -21029,10 +21029,12 @@ a footnote definition, try to fill the first paragraph within." (or (not (message-in-body-p)) (save-excursion (move-beginning-of-line 1) (looking-at "^>+ ")))) - (let ((fill-paragraph-function (cadadr (assoc 'fill-paragraph-function org-fb-vars))) + (let ((fill-paragraph-function + (cadadr (assoc 'fill-paragraph-function org-fb-vars))) (fill-prefix (cadadr (assoc 'fill-prefix org-fb-vars))) (paragraph-start (cadadr (assoc 'paragraph-start org-fb-vars))) - (paragraph-separate (cadadr (assoc 'paragraph-separate org-fb-vars)))) + (paragraph-separate + (cadadr (assoc 'paragraph-separate org-fb-vars)))) (fill-paragraph)) (save-excursion ;; Move to end of line in order to get the first paragraph within @@ -21051,8 +21053,10 @@ a footnote definition, try to fill the first paragraph within." t) ;; Elements that may contain `line-break' type objects. ((paragraph verse-block) - (let ((beg (org-element-property :contents-begin element)) - (end (org-element-property :contents-end element)) + (let ((beg (max (point-min) + (org-element-property :contents-begin element))) + (end (min (point-max) + (org-element-property :contents-end element))) (type (org-element-type element))) ;; Do nothing if point is at an affiliated keyword or at ;; verse block markers. @@ -21062,15 +21066,16 @@ a footnote definition, try to fill the first paragraph within." ;; At a verse block, first narrow to current "paragraph" ;; and set current element to that paragraph. (save-restriction + (narrow-to-region beg end) (when (eq type 'verse-block) - (narrow-to-region beg end) (save-excursion (let ((bol-pos (point-at-bol))) (re-search-backward "^[ \t]*$" nil 'm) (unless (or (bobp) (= (point-at-bol) bol-pos)) (forward-line)) (setq element (org-element-paragraph-parser end) - beg (org-element-property :contents-begin element) + beg (org-element-property + :contents-begin element) end (org-element-property :contents-end element))))) ;; Fill paragraph, taking line breaks into consideration. @@ -21088,12 +21093,13 @@ a footnote definition, try to fill the first paragraph within." ;; in the current paragraph. Add paragraph beginning ;; to include first slice. (nreverse - (cons beg - (org-element-map - (org-element--parse-objects - beg end nil org-element-all-objects) - 'line-break - (lambda (lb) (org-element-property :end lb)))))))) + (cons + beg + (org-element-map + (org-element--parse-objects + beg end nil org-element-all-objects) + 'line-break + (lambda (lb) (org-element-property :end lb)))))))) t))) ;; Contents of `comment-block' type elements should be filled as ;; plain text. @@ -21103,7 +21109,8 @@ a footnote definition, try to fill the first paragraph within." (fill-region-as-paragraph (progn (goto-char (org-element-property :begin element)) - (while (looking-at org-element--affiliated-re) (forward-line)) + (while (looking-at org-element--affiliated-re) + (forward-line)) (forward-line) (point)) (progn @@ -21118,7 +21125,8 @@ a footnote definition, try to fill the first paragraph within." (fill-region-as-paragraph (progn (goto-char (org-element-property :begin element)) - (while (looking-at org-element--affiliated-re) (forward-line)) + (while (looking-at org-element--affiliated-re) + (forward-line)) (point)) (progn (goto-char (org-element-property :end element)) diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index 9f59a7cdd..09bf3283e 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -160,6 +160,14 @@ http://article.gmane.org/gmane.emacs.orgmode/21459/" (end-of-line) (org-fill-paragraph) (buffer-string))))) + ;; Correctly fill an element in a narrowed buffer. + (should + (equal "01234\n6" + (org-test-with-temp-text "01234 6789" + (let ((fill-column 5)) + (narrow-to-region 1 8) + (org-fill-paragraph) + (buffer-string))))) ;; Special case: Fill first paragraph when point is at an item or ;; a plain-list or a footnote reference. (should From 655da8d1d316ccad783c0072aabf15e63fb9a2ce Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Sun, 19 Aug 2012 14:42:54 +0200 Subject: [PATCH 27/32] Remove useless (t nil) sexps at the end of some (cond ...) constructs * org.el (org-compute-latex-and-specials-regexp) (org-paste-subtree, org-sort-entries, org-store-link) (org-open-at-point, org-file-remote-p, org-add-log-setup) (org-set-tags-to, org-fast-tag-selection) (org-diary-sexp-entry): Ditto. * org-agenda.el (org-agenda-get-blocks, org-cmp-priority) (org-cmp-effort, org-cmp-todo-state, org-cmp-alpha) (org-cmp-tag, org-cmp-time): Remove useless (t nil) sexps at the end of (cond ...) constructs. * org-mobile.el (org-mobile-create-index-file): Ditto. * org-lparse.el (org-lparse-format-table-row): Ditto. * org-list.el (org-sort-list): Ditto. * org-id.el (org-id-get): Ditto. * org-html.el (org-export-html-preprocess): Ditto. * org-exp.el (org-default-export-plist) (org-table-clean-before-export): Ditto. (t nil) in (cond (...) (...) (t nil)) has no other meaning that to remind the developer that the cond sexp returns nil in case no condition is matched. For several (cond ...) constructs this is obvious from reading the code. For others, the reminder might be useful and we leave it. See the discussion about this on emacs-devel: http://thread.gmane.org/gmane.emacs.devel/152664 --- lisp/org-agenda.el | 27 +++++++++------------------ lisp/org-exp.el | 9 +++------ lisp/org-html.el | 3 +-- lisp/org-id.el | 3 +-- lisp/org-list.el | 3 +-- lisp/org-lparse.el | 3 +-- lisp/org-mobile.el | 3 +-- lisp/org.el | 33 +++++++++++---------------------- 8 files changed, 28 insertions(+), 56 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 2587341bd..b4d6d655d 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -5718,8 +5718,7 @@ FRACTION is what fraction of the head-warning time has passed." ((= d1 d0) (concat "<" start-time ">")) ((= d2 d0) - (concat "<" end-time ">")) - (t nil)) + (concat "<" end-time ">"))) remove-re)))) (org-add-props txt props 'org-marker marker 'org-hd-marker hdmarker @@ -6178,8 +6177,7 @@ could bind the variable in the options section of a custom command.") (let ((pa (or (get-text-property 1 'priority a) 0)) (pb (or (get-text-property 1 'priority b) 0))) (cond ((> pa pb) +1) - ((< pa pb) -1) - (t nil)))) + ((< pa pb) -1)))) (defsubst org-cmp-effort (a b) "Compare the effort values of string A and B." @@ -6187,16 +6185,14 @@ could bind the variable in the options section of a custom command.") (ea (or (get-text-property 1 'effort-minutes a) def)) (eb (or (get-text-property 1 'effort-minutes b) def))) (cond ((> ea eb) +1) - ((< ea eb) -1) - (t nil)))) + ((< ea eb) -1)))) (defsubst org-cmp-category (a b) "Compare the string values of categories of strings A and B." (let ((ca (or (get-text-property 1 'org-category a) "")) (cb (or (get-text-property 1 'org-category b) ""))) (cond ((string-lessp ca cb) -1) - ((string-lessp cb ca) +1) - (t nil)))) + ((string-lessp cb ca) +1)))) (defsubst org-cmp-todo-state (a b) "Compare the todo states of strings A and B." @@ -6218,8 +6214,7 @@ could bind the variable in the options section of a custom command.") (cond ((and donepa (not donepb)) -1) ((and (not donepa) donepb) +1) ((< la lb) -1) - ((< lb la) +1) - (t nil)))) + ((< lb la) +1)))) (defsubst org-cmp-alpha (a b) "Compare the headlines, alphabetically." @@ -6240,8 +6235,7 @@ could bind the variable in the options section of a custom command.") (cond ((not ta) +1) ((not tb) -1) ((string-lessp ta tb) -1) - ((string-lessp tb ta) +1) - (t nil)))) + ((string-lessp tb ta) +1)))) (defsubst org-cmp-tag (a b) "Compare the string values of the first tags of A and B." @@ -6250,8 +6244,7 @@ could bind the variable in the options section of a custom command.") (cond ((not ta) +1) ((not tb) -1) ((string-lessp ta tb) -1) - ((string-lessp tb ta) +1) - (t nil)))) + ((string-lessp tb ta) +1)))) (defsubst org-cmp-time (a b) "Compare the time-of-day values of strings A and B." @@ -6259,16 +6252,14 @@ could bind the variable in the options section of a custom command.") (ta (or (get-text-property 1 'time-of-day a) def)) (tb (or (get-text-property 1 'time-of-day b) def))) (cond ((< ta tb) -1) - ((< tb ta) +1) - (t nil)))) + ((< tb ta) +1)))) (defsubst org-cmp-habit-p (a b) "Compare the todo states of strings A and B." (let ((ha (get-text-property 1 'org-habit-p a)) (hb (get-text-property 1 'org-habit-p b))) (cond ((and ha (not hb)) -1) - ((and (not ha) hb) +1) - (t nil)))) + ((and (not ha) hb) +1)))) (defsubst org-em (x y list) (or (memq x list) (memq y list))) diff --git a/lisp/org-exp.el b/lisp/org-exp.el index d4c45608b..43652fe83 100644 --- a/lisp/org-exp.el +++ b/lisp/org-exp.el @@ -731,8 +731,7 @@ Each element is a list of 3 items: (setq s (nth 2 e) v (cond ((assq s letbind) (nth 1 (assq s letbind))) - ((boundp s) (symbol-value s)) - (t nil)) + ((boundp s) (symbol-value s))) rtn (cons (car e) (cons v rtn)))) rtn)) @@ -3260,8 +3259,7 @@ If yes remove the column and the special lines." (mapcar (lambda (x) (cond ((member x '("<" "<")) :start) ((member x '(">" ">")) :end) - ((member x '("<>" "<>")) :startend) - (t nil))) + ((member x '("<>" "<>")) :startend))) (org-split-string x "[ \t]*|[ \t]*"))) nil) ((org-table-cookie-line-p x) @@ -3282,8 +3280,7 @@ If yes remove the column and the special lines." (mapcar (lambda (x) (cond ((member x '("<" "<")) :start) ((member x '(">" ">")) :end) - ((member x '("<>" "<>")) :startend) - (t nil))) + ((member x '("<>" "<>")) :startend))) (cdr (org-split-string x "[ \t]*|[ \t]*")))) nil) ((org-table-cookie-line-p x) diff --git a/lisp/org-html.el b/lisp/org-html.el index b8e7557c8..2466b5c1b 100644 --- a/lisp/org-html.el +++ b/lisp/org-html.el @@ -698,8 +698,7 @@ The default is an extended format of the ISO 8601 specification." ((eq (plist-get parameters :LaTeX-fragments) 'mathjax ) 'mathjax) ((eq (plist-get parameters :LaTeX-fragments) t ) 'mathjax) ((eq (plist-get parameters :LaTeX-fragments) 'imagemagick) 'imagemagick) - ((eq (plist-get parameters :LaTeX-fragments) 'dvipng ) 'dvipng) - (t nil)))) + ((eq (plist-get parameters :LaTeX-fragments) 'dvipng ) 'dvipng)))) (goto-char (point-min)) (let (label l1) (while (re-search-forward "\\\\ref{\\([^{}\n]+\\)}" nil t) diff --git a/lisp/org-id.el b/lisp/org-id.el index ae112c3f7..0c7a1b52d 100644 --- a/lisp/org-id.el +++ b/lisp/org-id.el @@ -216,8 +216,7 @@ In any case, the ID of the entry is returned." (setq id (org-id-new prefix)) (org-entry-put pom "ID" id) (org-id-add-location id (buffer-file-name (buffer-base-buffer))) - id) - (t nil))))) + id))))) ;;;###autoload (defun org-id-get-with-outline-path-completion (&optional targets) diff --git a/lisp/org-list.el b/lisp/org-list.el index 043564130..10f5e6ec6 100644 --- a/lisp/org-list.el +++ b/lisp/org-list.el @@ -2822,8 +2822,7 @@ COMPARE-FUNC to compare entries." (sort-func (cond ((= dcst ?a) 'string<) ((= dcst ?f) compare-func) - ((= dcst ?t) '<) - (t nil))) + ((= dcst ?t) '<))) (next-record (lambda () (skip-chars-forward " \r\t\n") (beginning-of-line))) diff --git a/lisp/org-lparse.el b/lisp/org-lparse.el index 797e6901d..52518b357 100644 --- a/lisp/org-lparse.el +++ b/lisp/org-lparse.el @@ -1929,8 +1929,7 @@ See `org-xhtml-entity-format-callbacks-alist' for more information." (cond ((string= align "l") "left") ((string= align "r") "right") - ((string= align "c") "center") - (t nil)))))))) + ((string= align "c") "center")))))))) (incf org-lparse-table-rownum) (let ((i -1)) (org-lparse-format diff --git a/lisp/org-mobile.el b/lisp/org-mobile.el index e899bfd51..93ba7e418 100644 --- a/lisp/org-mobile.el +++ b/lisp/org-mobile.el @@ -451,8 +451,7 @@ agenda view showing the flagged items." ((eq (car x) :startgroup) "{") ((eq (car x) :endgroup) "}") ((eq (car x) :newline) nil) - ((listp x) (car x)) - (t nil))) + ((listp x) (car x)))) def-tags)) (setq def-tags (delq nil def-tags)) (setq tags (org-delete-all def-tags tags)) diff --git a/lisp/org.el b/lisp/org.el index 168d4701e..3b383a54b 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -5773,8 +5773,7 @@ by a #." ((equal org-export-with-sub-superscripts '{}) (list org-match-substring-with-braces-regexp)) (org-export-with-sub-superscripts - (list org-match-substring-regexp)) - (t nil))) + (list org-match-substring-regexp)))) (re-latex (if org-export-with-LaTeX-fragments (mapcar (lambda (x) (nth 1 x)) latexs))) @@ -7920,8 +7919,7 @@ the inserted text when done." (- (match-end 1) (match-beginning 1))) ((and (bolp) (looking-at org-outline-regexp)) - (- (match-end 0) (point) 1)) - (t nil))) + (- (match-end 0) (point) 1)))) (previous-level (save-excursion (condition-case nil (progn @@ -8373,8 +8371,7 @@ WITH-CASE, the sorting considers case as well." (cond ((= dcst ?a) 'string<) ((= dcst ?f) compare-func) - ((member dcst '(?p ?t ?s ?d ?c)) '<) - (t nil))))) + ((member dcst '(?p ?t ?s ?d ?c)) '<))))) (run-hooks 'org-after-sorting-entries-or-items-hook) (message "Sorting entries...done"))) @@ -8961,8 +8958,7 @@ For file links, arg negates `org-context-in-file-links'." (setq txt (cond ((org-at-heading-p) nil) ((org-region-active-p) - (buffer-substring (region-beginning) (region-end))) - (t nil))) + (buffer-substring (region-beginning) (region-end))))) (when (or (null txt) (string-match "\\S-" txt)) (setq cpltxt (concat cpltxt "::" @@ -9924,15 +9920,13 @@ application the system uses for this file type." (let ((cmd `(org-link-search ,path ,(cond ((equal arg '(4)) ''occur) - ((equal arg '(16)) ''org-occur) - (t nil)) + ((equal arg '(16)) ''org-occur)) ,pos))) (condition-case nil (let ((org-link-search-inhibit-query t)) (eval cmd)) (error (progn (widen) (eval cmd)))))) - (t - (browse-url-at-point))))))) + (t (browse-url-at-point))))))) (move-marker org-open-link-marker nil) (run-hook-with-args 'org-follow-link-hook))) @@ -10559,8 +10553,7 @@ on the system \"/user@host:\"." (tramp-handle-file-remote-p file)) ((and (boundp 'ange-ftp-name-format) (string-match (car ange-ftp-name-format) file)) - t) - (t nil))) + t))) ;;;; Refiling @@ -12538,8 +12531,7 @@ EXTRA is additional text that will be inserted into the notes buffer." (let* ((org-log-into-drawer (org-log-into-drawer)) (drawer (cond ((stringp org-log-into-drawer) org-log-into-drawer) - (org-log-into-drawer "LOGBOOK") - (t nil)))) + (org-log-into-drawer "LOGBOOK")))) (save-restriction (save-excursion (when findpos @@ -13646,8 +13638,7 @@ If DATA is nil or the empty string, any tags will be removed." (concat ":" (mapconcat 'identity (org-split-string data ":+") ":") ":")) ((listp data) - (concat ":" (mapconcat 'identity data ":") ":")) - (t nil))) + (concat ":" (mapconcat 'identity data ":") ":")))) (when data (save-excursion (org-back-to-heading t) @@ -13963,8 +13954,7 @@ Returns the new tags string, or nil to not change the current settings." ((not (assoc tg table)) (org-get-todo-face tg)) ((member tg current) c-face) - ((member tg inherited) i-face) - (t nil)))) + ((member tg inherited) i-face)))) (if (and (= cnt 0) (not ingroup)) (insert " ")) (insert "[" c "] " tg (make-string (- fwidth 4 (length tg)) ?\ )) @@ -16211,8 +16201,7 @@ D may be an absolute day number, or a calendar-type list (month day year)." (stringp (cdr result))) (cdr result)) ((and (consp result) (stringp (car result))) result) - (result entry) - (t nil)))) + (result entry)))) (defun org-diary-to-ical-string (frombuf) "Get iCalendar entries from diary entries in buffer FROMBUF. From bb895827c2009028a000f6c04afce390f082a38c Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sun, 19 Aug 2012 14:45:31 +0200 Subject: [PATCH 28/32] Try to be smarter when filling paragraphs in message-mode * lisp/org.el (org-fill-paragraph): Try not to include message header and citation lines in a paragraph when filling it. --- lisp/org.el | 87 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 49 insertions(+), 38 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 3b383a54b..5e7807d43 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -20996,7 +20996,9 @@ meant to be filled." (when (and (>= p cbeg) (< p cend)) (if (looking-at "\\s-+") (match-string 0) "")))))))))) -(defvar org-element-all-objects) ; From org-element.el +(declare-function message-goto-body "message" ()) +(defvar message-cite-prefix-regexp) ; From message.el +(defvar org-element-all-objects) ; From org-element.el (defun org-fill-paragraph (&optional justify) "Fill element at point, when applicable. @@ -21017,7 +21019,7 @@ a footnote definition, try to fill the first paragraph within." (if (and (derived-mode-p 'message-mode) (or (not (message-in-body-p)) (save-excursion (move-beginning-of-line 1) - (looking-at "^>+ ")))) + (looking-at message-cite-prefix-regexp)))) (let ((fill-paragraph-function (cadadr (assoc 'fill-paragraph-function org-fb-vars))) (fill-prefix (cadadr (assoc 'fill-prefix org-fb-vars))) @@ -21052,43 +21054,52 @@ a footnote definition, try to fill the first paragraph within." (if (or (< (point) beg) (and (eq type 'verse-block) (>= (point) end))) t - ;; At a verse block, first narrow to current "paragraph" - ;; and set current element to that paragraph. - (save-restriction - (narrow-to-region beg end) - (when (eq type 'verse-block) - (save-excursion - (let ((bol-pos (point-at-bol))) - (re-search-backward "^[ \t]*$" nil 'm) - (unless (or (bobp) (= (point-at-bol) bol-pos)) - (forward-line)) - (setq element (org-element-paragraph-parser end) - beg (org-element-property - :contents-begin element) - end (org-element-property - :contents-end element))))) - ;; Fill paragraph, taking line breaks into consideration. - ;; For that, slice the paragraph using line breaks as - ;; separators, and fill the parts in reverse order to - ;; avoid messing with markers. + ;; In verse blocks and `message-mode', boundaries of + ;; region to fill have to be tweaked. + (cond + ;; At a verse block, fill current "paragraph", that + ;; is part of text separated by blank lines. + ((eq type 'verse-block) (save-excursion - (goto-char end) - (mapc - (lambda (pos) - (let ((fill-prefix (org-fill-context-prefix pos))) - (fill-region-as-paragraph pos (point) justify)) - (goto-char pos)) - ;; Find the list of ending positions for line breaks - ;; in the current paragraph. Add paragraph beginning - ;; to include first slice. - (nreverse - (cons - beg - (org-element-map - (org-element--parse-objects - beg end nil org-element-all-objects) - 'line-break - (lambda (lb) (org-element-property :end lb)))))))) + (when (looking-at "[ \t]*$") + (skip-chars-backward " \r\t\n" beg)) + (when (re-search-backward "^[ \t]*$" beg t) + (forward-line) + (setq beg (point)))) + (when (save-excursion (re-search-forward "^[ \t]*$" end t)) + (setq end (match-beginning 0)))) + ;; In `message-mode', do not fill following citation + ;; in current paragraph nor text before message + ;; body. + ((derived-mode-p 'message-mode) + (let ((body-start (message-goto-body))) + (when body-start (setq beg (max body-start beg)))) + (when (save-excursion + (re-search-forward + (concat "^" message-cite-prefix-regexp) end t)) + (setq end (match-beginning 0))))) + ;; Fill paragraph, taking line breaks into consideration. + ;; For that, slice the paragraph using line breaks as + ;; separators, and fill the parts in reverse order to + ;; avoid messing with markers. + (save-excursion + (goto-char end) + (mapc + (lambda (pos) + (let ((fill-prefix (org-fill-context-prefix pos))) + (fill-region-as-paragraph pos (point) justify)) + (goto-char pos)) + ;; Find the list of ending positions for line breaks + ;; in the current paragraph. Add paragraph beginning + ;; to include first slice. + (nreverse + (cons + beg + (org-element-map + (org-element--parse-objects + beg end nil org-element-all-objects) + 'line-break + (lambda (lb) (org-element-property :end lb))))))) t))) ;; Contents of `comment-block' type elements should be filled as ;; plain text. From 2fd696716a9411793dbd2e4916d7d05695111945 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sun, 19 Aug 2012 15:51:55 +0200 Subject: [PATCH 29/32] Forgot a `save-excursion' * lisp/org.el (org-fill-paragraph): Add a `save-excursion' to avoid returning funny results. --- lisp/org.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/org.el b/lisp/org.el index 5e7807d43..163fe703d 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -21072,7 +21072,7 @@ a footnote definition, try to fill the first paragraph within." ;; in current paragraph nor text before message ;; body. ((derived-mode-p 'message-mode) - (let ((body-start (message-goto-body))) + (let ((body-start (save-excursion (message-goto-body)))) (when body-start (setq beg (max body-start beg)))) (when (save-excursion (re-search-forward From c81bcccbf324647d9f35552b2b45e8cd7a534a11 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sun, 19 Aug 2012 15:59:24 +0200 Subject: [PATCH 30/32] org-md: Fix export of paragraph starting with an hash sign * contrib/lisp/org-md.el (org-md-paragraph): Fix export of paragraph starting with an hash sign. --- contrib/lisp/org-md.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/lisp/org-md.el b/contrib/lisp/org-md.el index 2fb417288..4579ca31e 100644 --- a/contrib/lisp/org-md.el +++ b/contrib/lisp/org-md.el @@ -334,7 +334,7 @@ a communication channel." (let ((first-object (car (org-element-contents paragraph)))) ;; If paragraph starts with a #, protect it. (if (and (stringp first-object) (string-match "\\`#" first-object)) - (replace-match "\\#" nil t first-object) + (replace-regexp-in-string "\\`#" "\\#" contents nil t) contents))) From ad35e2ac6c6decae55dd987be738e07e7c87bd7d Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Sun, 19 Aug 2012 16:56:52 +0200 Subject: [PATCH 31/32] org.el: Don't activate a plain link when it is part of a bracketed link * org.el (org-activate-plain-links): Don't activate a plain link when it is part of a bracketed link, unless bracketed links are not enlisted in `org-activate-links'. (org-open-at-point): Don't consider the text immediately after a bracketed link is part of a plain link. This fixes a bug when fontifying [[http://orgmode.org][Org]]Mode -- where "Mode" should not be fontified, because it is not part of the bracketed link. Note that there was another related bug: C-c C-o on "Mode" used to try opening a plain link. Also fixed in this commit. --- lisp/org.el | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 5e7807d43..e7c6223e7 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -5450,7 +5450,12 @@ will be prompted for." "Run through the buffer and add overlays to links." (catch 'exit (let (f) - (if (re-search-forward org-plain-link-re limit t) + (if (and (re-search-forward (concat org-plain-link-re) limit t) + (or (not (member 'bracket org-activate-links)) + (save-excursion + (save-match-data + (goto-char (match-beginning 0)) + (not (looking-back "\\[\\[")))))) (progn (org-remove-flyspell-overlays-in (match-beginning 0) (match-end 0)) (setq f (get-text-property (match-beginning 0) 'face)) @@ -9780,7 +9785,8 @@ application the system uses for this file type." (save-excursion (when (or (org-in-regexp org-angle-link-re) - (org-in-regexp org-plain-link-re)) + (and (goto-char (car (org-in-regexp org-plain-link-re))) + (save-match-data (not (looking-back "\\[\\["))))) (setq type (match-string 1) path (org-link-unescape (match-string 2))) (throw 'match t))) From 92271aecea5de800538fed427a3620dcc3859d9b Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Sun, 19 Aug 2012 17:41:01 +0200 Subject: [PATCH 32/32] org-capture.el (org-capture-place-table-line): Fix bug * org-capture.el (org-capture-place-table-line): Fix bug. Thanks to Ian Barton for reporting this. --- lisp/org-capture.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/org-capture.el b/lisp/org-capture.el index 8beb9c2a6..0c5d04072 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -1081,8 +1081,8 @@ it. When it is a variable, retrieve the value. Return whatever we get." (setq end (point)))) (goto-char beg) (org-capture-position-for-last-stored 'table-line) - (if (or (re-search-backward "%\\?" end t) - (re-search-forward "%\\?" beg t)) + (if (or (re-search-backward "%\\?" beg t) + (re-search-forward "%\\?" end t)) (replace-match "")) (org-table-align)))