Commit Graph

193 Commits

Author SHA1 Message Date
Nicolas Goaziou ede82ccf93 org-element: Fix infloops
* lisp/org-element.el (org-element-center-block-parser)
  (org-element-drawer-parser, org-element-dynamic-block-parser)
  (org-element-footnote-definition-parser)
  (org-element-inlinetask-parser, org-element-property-drawer-parser)
  (org-element-quote-block-parser, org-element-comment-block-parser)
  (org-element-diary-sexp-parser, org-element-example-block-parser)
  (org-element-keyword-parser, org-element-latex-environment-parser)
  (org-element-paragraph-parser, org-element-src-block-parser)
  (org-element-table-parser, org-element-verse-block-parser): Fix
  infloop when buffer ends with a non-empty blank line after the
  element.
* testing/lisp/test-org-element.el: Add tests.
2013-11-10 11:28:14 +01:00
Nicolas Goaziou 84818415e8 org-element: Fix infloop
* lisp/org-element.el (org-element-comment-parser): Fix infloop when
  a non-empty blank line follows a comment at the end of the buffer.
* testing/lisp/test-org-element.el: Add test.
2013-11-10 10:23:18 +01:00
Nicolas Goaziou 92f89eedba ox-org: Fix headline level during subtree export
* lisp/org-element.el (org-element-headline-interpreter): Take into
  consideration `org-odd-levels-only' when building a headline.
* lisp/ox-org.el (org-org-headline): Correctly set transcoded headline
  level during subtree export.
2013-11-06 19:14:14 +01:00
Nicolas Goaziou 757f00811d org-element: Fix error when parsing lowercase keywords
* lisp/org-element.el (org-element-context): Fix error when parsing
  affiliated keywords, e.g. "caption".
* testing/lisp/test-org-element.el: Add test.
2013-11-03 17:51:12 +01:00
Nicolas Goaziou ff172be293 org-element: Use `org-latex-regexps', not `org-format-latex-options'
* lisp/org-element.el (org-element-latex-or-entity-successor,
  org-element-latex-fragment-parser): Use `org-latex-regexps' instead
  of `org-format-latex-options'.
* testing/lisp/test-org-element.el: Fix tests.

`org-latex-regexps' defines the correct syntax for LaTeX code within
an Org buffer.  On the other hand, `org-format-latex-options'
determines which syntax can be previewed within the buffer.
2013-10-24 17:15:23 +02:00
Nicolas Goaziou 5394f15e51 org-element: Use `org-match-string-no-properties'.
* lisp/org-element.el (org-element--list-struct): Use
  `org-match-string-no-properties'.
2013-10-16 21:26:19 +02:00
Nicolas Goaziou b1e7b86fda org-element: Fix block parsing in lists
* lisp/org-element.el (org-element--list-struct): Fix block parsing in
  lists.
* testing/lisp/test-org-element.el: Add test.

Reported-by: Omid <omidlink@gmail.com>
2013-10-16 13:21:42 +02:00
Nicolas Goaziou 92c2ccb1fb org-element: Fix interpreter for timestamp with delay
* lisp/org-element.el (org-element-timestamp-interpreter): Correctly
  interpret timestamps with delays.
* testing/lisp/test-org-element.el: Add test.
2013-10-13 18:13:35 +02:00
Nicolas Goaziou 11514badc1 org-element: Parse warning delays in timestamps
* lisp/org-element.el (org-element-timestamp-parser,
  org-element-timestamp-interpreter): Parse warning delays.
* testing/lisp/test-org-element.el (test-org-element/timestamp): Add
  tests.
2013-10-13 10:17:16 +02:00
Nicolas Goaziou 41cf6f2a36 org-element: Fix `org-element-at-point' at end of buffer
* lisp/org-element.el (org-element-at-point): If point is at the end
  of the buffer, and that buffer ends with a list, and there's no
  final newline, return last element in last item instead of plain
  list.
* testing/lisp/test-org-element.el: Add test.

This fix allows to fill correctly the following construct:

 - Item with a very long line ending at the end of buffer.
2013-09-18 21:15:04 +02:00
Nicolas Goaziou 072f2abe4c org-element: Fix infloop in `org-element-at-point'
* lisp/org-element.el (org-element-at-point): Fix infloop when called
  on a blank line at the end of the buffer after a headline.
2013-09-17 22:36:09 +02:00
Nicolas Goaziou 29c33591a2 org-element: Fix af9c0fbf91
* lisp/org-element.el (org-element-at-point): Fix commit
  af9c0fbf91.
2013-09-11 18:23:16 +02:00
Nicolas Goaziou 7b4d8bb614 org-element: Fix footnote definition parsing
* lisp/org-element.el (org-element-footnote-definition-parser): Fix
  value for :contents-begin when first line of footnote definition is
  empty besides the label.
* testing/lisp/test-org-element.el (test-org-element/footnote-definition-parser):
  Add test.
2013-09-11 17:12:26 +02:00
Nicolas Goaziou af9c0fbf91 org-element: Fix bug in `org-element-at-point'
* lisp/org-element.el (org-element-at-point): Return correct element
  when point is on a blank line just below a headline.
* testing/lisp/test-org-element.el: Add test.
2013-09-11 12:22:05 +02:00
Nicolas Goaziou a031a4b75b org-element: Fix d003d56eaf
* lisp/org-element.el (org-element-paragraph-parser): Use
  `org-match-string-no-properties'.
2013-09-08 23:50:53 +02:00
Nicolas Goaziou d003d56eaf org-element: Fix paragraph parsing
* lisp/org-element.el (org-element-paragraph-parser): Small fixes to
  paragraph parsing.
2013-09-08 23:24:42 +02:00
Nicolas Goaziou 81626dcc15 Merge branch 'maint' 2013-08-30 14:38:03 +02:00
Nicolas Goaziou cb35032641 org-element: Modify misleading comment
* lisp/org-element.el (org-element-context): Modify misleading
  comment.
2013-08-30 14:37:16 +02:00
Nicolas Goaziou c33e04dcf2 Merge branch 'maint' 2013-08-30 14:22:07 +02:00
Nicolas Goaziou 026b99ecb8 org-element: Fix parsing error in `org-element-context'
* lisp/org-element.el (org-element-text-markup-successor,
  org-element-latex-or-entity-successor,
  org-element-export-snippet-successor,
  org-element-footnote-reference-successor,
  org-element-inline-babel-call-successor,
  org-element-inline-src-block-successor,
  org-element-line-break-successor, org-element-link-successor,
  org-element-plain-link-successor, org-element-macro-successor,
  org-element-radio-target-successor,
  org-element-statistics-cookie-successor,
  org-element-sub/superscript-successor,
  org-element-table-cell-successor, org-element-target-successor,
  org-element-timestamp-successor): Remove LIMIT argument.
(org-element--parse-objects, org-element--get-next-object-candidates):
Apply signature change to successors.
(org-element-context): Narrow buffer around object containers so
parsing of objects when using this function is done under the same
restrictions as in buffer parsing.
* testing/lisp/test-org-element.el: Add test.
2013-08-30 14:19:30 +02:00
Nicolas Goaziou 95dd398f6a Merge branch 'maint'
Conflicts:
	testing/lisp/test-org-element.el
2013-07-21 15:54:08 +02:00
Nicolas Goaziou b4a8ec9321 org-element: Fix infloop when parsing a list at the end of buffer
* lisp/org-element.el (org-element-plain-list-parser): Fix infloop
  when parsing a list at the end of buffer, if buffer doesn't end at
  a line beginning.
* testing/lisp/test-org-element.el: Add test.
2013-07-21 15:51:14 +02:00
Nicolas Goaziou 17b584df89 Merge branch 'maint' 2013-07-20 13:53:35 +02:00
Nicolas Goaziou 21dd83661b org-element: Do not url-decode parsed links
* lisp/org-element.el (org-element-link-parser): Do not url-decode
  parsed links.

The function now assumes link at point is correctly encoded if needed.
`org-insert-link' already automatically url-encode generated links,
and link types not handled by this function (e.g., custom-id links) do
not need such encoding.
2013-07-20 13:51:18 +02:00
Nicolas Goaziou 0bab94dedf Merge branch 'maint' 2013-07-06 00:41:04 +02:00
Nicolas Goaziou 0aa0fdd971 org-element: Fix interpretation of empty items
* lisp/org-element.el (org-element-item-interpreter): This patch fixes
  "(wrong-type-argument arrayp nil)" error when trying to interpret
  empty items.
* testing/lisp/test-org-element.el: Add test.
2013-07-06 00:39:28 +02:00
Nicolas Goaziou acb351444e Merge branch 'maint' 2013-07-05 21:14:43 +02:00
Nicolas Goaziou e5630add27 org-element: Fix "*" itemized plain lists interpretation
* lisp/org-element.el (org-element-item-interpreter): Correctly
  interpret back plain lists with "*" items.  This fixes "This is not
  a list" error returned in this case.
* testing/lisp/test-org-element.el: Add test.
2013-07-05 21:12:47 +02:00
Nicolas Goaziou acb00702d5 Merge branch 'maint' 2013-06-25 17:38:43 +02:00
Nicolas Goaziou 838e849bf7 org-element: Fix org-meta-return error at the end of buffer
* lisp/org-element.el (org-element--current-element): Fix
  org-meta-return error at the end of buffer.
* testing/lisp/test-org-element.el: Add test.

Thanks to Nicolas Richard for reporting this.
2013-06-25 17:37:48 +02:00
Nicolas Goaziou 5e3c3f93bf Merge branch 'maint' 2013-06-17 17:17:24 +02:00
Nicolas Goaziou dffdc499ea org-element: Fix special block parsing
* lisp/org-element.el (org-element-special-block-parser): Fix typo in
  regexp matching block type.  Also quote the type so it can contain
  special characters.
* testing/lisp/test-org-element.el: Add test.
2013-06-17 17:15:55 +02:00
Achim Gratz 3c933adaf6 org.el: improve org-property-re and use it throughout
* lisp/org.el (org-property-re): Improve definition so that this regex
  can be used in all situations.  Extend docstring with explanation of
  matching groups.
  (org-at-property-p): Implement using `org-element-at-point'.
  (org-entry-properties, org-buffer-property-keys, org-indent-line):
  Use `org-property-re' and adjust match group numbers accordingly.

* lisp/org-element.el (org-element-node-property-parser): Use
  `org-property-re' and adjust match group numbers accordingly.  Move
  `looking-at' out of the let clause to not rely on the unspecified
  evaluation order inside the let.
2013-06-08 21:38:24 +02:00
Nicolas Goaziou d8b983b85a org-element: Fix failing "plain-list-parser" test
* lisp/org-element.el (org-element--list-struct): Fix failing
  "plain-list-parser" test.
* testing/lisp/test-org-element.el: Update test.
2013-06-01 21:38:15 +02:00
Nicolas Goaziou ca99372d83 org-element: Use internal version of `org-list-struct'
* lisp/org-element.el (org-element--list-struct): New function.
(org-element-plain-list-parser, org-element--current-element): Use new
function.

This patch removes dependency on org-list.el to parsing lists. For
now, it leads to code duplication, but, ultimately (i.e., when parsing
will be faster), org-list.el will delegate the parsing job to
org-element. The new implementation is also faster than the previous one.
2013-05-31 20:14:02 +02:00
Nicolas Goaziou 206762bd34 org-element: Small optimization
* lisp/org-element.el (org-element--remove-indentation): Small
  optimization.
2013-05-25 22:02:26 +02:00
Nicolas Goaziou 10169054eb org-element: Fix a docstring
* lisp/org-element.el (org-element--remove-indentation): Fix
  docstring.
2013-05-25 17:08:01 +02:00
Nicolas Goaziou 87ab99f563 org-element/ox: Fix src-block indentation when it should be preserved
* lisp/org-element.el (org-element--remove-indentation): New function.
(org-element-example-block-parser, org-element-src-block-parser): Use
new function.
(org-element-src-block-interpreter): Update function according to
change.
* lisp/ox.el (org-export-unravel-code): Do not remove any indentation
  since it now happens at the parser level.
* testing/lisp/test-org-element.el: Add tests.
* testing/lisp/test-ox.el: Refactor tests.
2013-05-25 14:35:24 +02:00
Nicolas Goaziou 7d37898371 org-element: Be stricter when matching arguments in LaTeX environments
* lisp/org-element.el (org-element--current-element): Be stricter when
  matching arguments in LaTeX environments.  In particular, do not
  allow anything else than options and arguments in the opening line.
* testing/lisp/test-org-element.el: Add tests.
2013-05-12 17:15:06 +02:00
Nicolas Goaziou be794a2a30 org-element: Fix visible-only parsing
* lisp/org-element.el (org-element--parse-elements): Also parse
  visible headlines within an otherwise compacted headline.
* testing/lisp/test-org-element.el: Add test.
2013-05-08 10:10:29 +02:00
Nicolas Goaziou 41bd891d48 org-element: Recognize LaTeX environments with options
* lisp/org-element.el (org-element--current-element): Allow the
  opening string of a LaTeX environment to contain additional
  arguments.
* testing/lisp/test-org-element.el: Add tests.
2013-04-28 09:38:01 +02:00
Nicolas Goaziou 5efd7311e8 org-element: Fix interpretation of empty fixed-width elements
* lisp/org-element.el (org-element-fixed-width-interpreter): Fix
  interpretation of fixed-width elements with a nil or empty string
  value.
* testing/lisp/test-org-element.el: Add tests.
2013-04-26 10:38:05 +02:00
Nicolas Goaziou 6ce2b72c9f org-element: Parse table cells with missing ending space
* lisp/org-element.el (org-element-table-cell-successor): Parse table
  cells with missing ending space.
2013-04-09 16:17:08 +02:00
Bastien Guerry 78959943e2 Merge branch 'master-group-tags2' 2013-03-25 06:59:23 +01:00
Nicolas Goaziou 42e1a6351d org-element: Allow to escape escaping character before a comma
* lisp/org-element.el (org-element-macro-parser): Allow to escape
  escaping character before a comma.  Also do not trim spaces at
  argument boundaries.
* doc/org.texi (Macro replacement): Update documentation about
  possible locations and escaping mechanism.
* testing/lisp/test-org-element.el: Add tests.

With this patch, macro's arguments are read as the following:

  "a,b"     -> '("a" "b")
  "a\,b"    -> '("a,b")
  "a\\,b"   -> '("a\" "b")
  "a\\\,b"  -> '("a\,b")
  "a\\\\,b" -> '(a"\\" "b")

Note that with the patch, you only need to escape backslashes before
a comma:

  "a\\b\,c" -> '("a\\b,c")
2013-03-23 20:42:34 +01:00
Bastien Guerry f373bca58b Rename some list variables
* org-element.el (org-element-paragraph-separate): Use
new name `org-list-allow-alphabetical'.

* org-list.el (org-list-allow-alphabetical): Rename from
`org-alphabetical-lists'.
(org-list-empty-line-terminates-plain-lists): Rename from
`org-empty-line-terminates-plain-lists'.
(org-checkbox-hierarchical-statistics): Rename from
`org-hierarchical-checkbox-statistics'.

* org.texi (Plain lists, Checkboxes): Use non-obsolete
variable names.
2013-03-23 17:45:15 +01:00
Bastien Guerry a5a676e609 org-element.el (org-element-context): Prevent an error when getting the context of a table rule
* org-element.el (org-element-context): Prevent an error when
getting the context of a table rule.

Thanks to Eric Abrahamsen for reporting this bug.
2013-03-14 12:20:33 +01:00
Bastien Guerry a68ae08422 org-element.el (org-element-map): Fix tiny typo in docstring
* org-element.el (org-element-map): Fix tiny typo in docstring.
2013-03-08 16:53:03 +01:00
Nicolas Goaziou 70cef89265 org-element: Simplify restrictions within secondary strings and objects
* lisp/org-element.el (org-element-object-restrictions): Simplify
  restrictions within secondary strings and objects.
2013-03-04 15:42:42 +01:00
Nicolas Goaziou 86563e0119 org-element: OPTIONAL_TITLE becomes ALT_TITLE property
* lisp/org-element.el (org-element-headline-parser):
  Rename :optional-title into :alt-title.
* lisp/ox.el (org-export-get-alt-title): Renamed from
  `org-export-get-optional-title'.
* lisp/ox-ascii.el (org-ascii--build-title): Apply name change.
* lisp/ox-html.el (org-html--format-toc-headline): Apply name change.
* lisp/ox-latex.el (org-latex-headline): Apply name change.
* lisp/ox-texinfo.el (org-texinfo--get-node,
  org-texinfo--generate-menu-items): Apply name change.
* testing/lisp/test-ox.el: Update tests.
* doc/org.texi (Table of contents): Update documentation.
2013-02-27 00:03:59 +01:00