Commit Graph

584 Commits

Author SHA1 Message Date
Nicolas Goaziou 476ea10a70 org-element: Fix "wrong-type-argument" error in cache
* lisp/org-element.el (org-element--cache-sync): Do not copy phase
  number into next request.  This is a special case that deserves to
  be handled locally.  See below.
(org-element--cache-process-request): Properly transfer phase in
a special case, which is now commented.  Also fix phase numbers in
comments.  Small refactoring.

Thanks to Alan Schmitt for reporting it.
http://permalink.gmane.org/gmane.emacs.orgmode/88406
2014-07-17 16:34:06 +02:00
Nicolas Goaziou baa2c5943a org-element: Avoid using a slow regexp
* lisp/org-element.el (org-element-latex-fragment-parser): Avoid using
  a slow regexp.
2014-07-06 23:55:48 +02:00
Nicolas Goaziou 4235718d79 org-element: Small optimizations
* lisp/org-element.el (org-element-latex-fragment-parser): Avoid
  matching twice regexps in some cases.
(org-element--object-lex): Avoid making a funcall if a line break
isn't possible.

This patch also removes the limit on the number of lines a latex
fragment with a single dollar can span over.
2014-07-06 23:15:44 +02:00
Nicolas Goaziou 0ce82e53a1 org-element: Fix docstring
* lisp/org-element.el (org-element-footnote-reference-interpreter):
  Fix docstring.
2014-07-06 19:06:54 +02:00
Nicolas Goaziou ca6ecf9e49 org-element: Remove :inline-definition from inline footnotes
* lisp/org-element.el (org-element-recursive-objects): Add
  `footnote-reference'.
(org-element-secondary-value-alist): Remove reference to
`footnote-reference'.
(org-element-footnote-reference-parser): Definition for inline
references is stored as the contents of the reference, not in
a secondary string.
(org-element-footnote-reference-interpreter): Apply changes from
parser.

* lisp/ox.el (org-export-get-footnote-definition,
  org-export-get-environment): Apply changes from parser.

* testing/lisp/test-org-element.el (test-org-element/footnote-reference-parser):
  Update test.
(test-org-element/context): Add test.

Storing definition in a secondary string was a poor design choice as
there is no "primary" string anyway.  This also prevents
`org-element-context' from finding objects within the inline
definition.
2014-07-06 11:24:12 +02:00
Nicolas Goaziou df9ccbd119 org-element: Reach orphaned elements during cache sync
* lisp/org-element.el (org-element--cache-sync-requests): Change
  pattern.
(org-element--cache-sync, org-element--cache-submit-request): Update
request pattern.
(org-element--cache-process-request): Remove orphaned elements during
first phase.

An orphaned element is an element not directly altered by changes to
buffer but with one of its parent removed.
2014-07-05 10:54:09 +02:00
Nicolas Goaziou f1433d82ae org-element: Fix buffer positions when merging requests
* lisp/org-element.el (org-element--cache-submit-request): Correctly
  compute buffer positions where cache is missing, taking into account
  the request not yet applied.
2014-07-05 10:54:09 +02:00
Nicolas Goaziou 126e2bcebd org-element: Fix corner case
* lisp/org-element.el (org-element--cache-for-removal): Fix corner
  case when changes happen in a robust element (e.g., a center block)
  within a fragile element (e.g., a plain list).  Do not assume that
  all parents from a robust element are also robust.
2014-06-30 23:47:37 +02:00
Nicolas Goaziou ef8e9cf045 org-element: Fix bug in sync request submission
* lisp/org-element.el (org-element--cache-submit-request): Do not
  modify ending position twice.
2014-06-30 23:47:37 +02:00
Nicolas Goaziou d1f2d73b08 org-element: Improve sychronization request submission
* lisp/org-element.el (org-element--cache-submit-request): Store
  parent of first element to delete, if any.  This saves a call to
  `org-element--cache-find' in a very common use case.
(org-element--cache-sync-requests): Update docstring accordingly.
2014-06-30 23:47:36 +02:00
Nicolas Goaziou 67c1e54a5b org-element: Tiny refactoring
* lisp/org-element.el (org-element--cache-submit-request): Tiny
  refactoring.
2014-06-30 23:47:36 +02:00
Nicolas Goaziou 093d455f7f org-element: Better threshold computation during synchronization
* lisp/org-element.el (org-element--cache-process-request): Threshold
  is based off beginning of the first element to shift instead of the
  end of the changes.
2014-06-30 23:47:36 +02:00
Nicolas Goaziou 1a9b074d9f org-element: Simplify request processing
* lisp/org-element.el (org-element--cache-process-request): Do not try
  to find orphans for now.  Remove useless comments.  Refactor code.
2014-06-30 23:45:20 +02:00
Nicolas Goaziou ba9c43fc81 org-element: Do not trust a stored request after cache sync
* lisp/org-element.el (org-element--cache-submit-request): Do not
  trust a stored request after calling `org-element--cache-sync' since
  it may as well not exist anymore (i.e., the synchronization was
  complete).
2014-06-30 23:44:51 +02:00
Nicolas Goaziou 815c218f22 org-element: Small fix
* lisp/org-element.el (org-element--cache-submit-request): Fix off by
  one error when updating cache.  Changes happening at the beginning
  to the previous ones, which are always located at the beginning of
  an element, imply to delete previous element.  Also do not call
  `org-element--cache-sync' if there's nothing to synchronize.
2014-06-29 17:17:23 +02:00
Nicolas Goaziou f12f9543fc org-element: Tiny fix
* lisp/org-element.el (org-element-headline-parser): Do not assume
  property drawers are correctly formed.
2014-06-29 15:25:54 +02:00
Nicolas Goaziou 49f3c6e558 org-element: Fix inlinetask parsing
* lisp/org-element.el (org-element-inlinetask-parser): Do not infloop
  when parsing property drawer in an inlinetask.

* testing/lisp/test-org-element.el (test-org-element/headline-properties):
  Add test.

Thanks to Aaron Ecay for reporting it.
http://permalink.gmane.org/gmane.emacs.orgmode/88133
2014-06-29 15:23:22 +02:00
Nicolas Goaziou 2824502e2e org-element: Fix cache corruption when altering a drawer
* lisp/org-element.el (org-element--cache-submit-request): Correctly
  update cache when changes alter the contents of a greater
  element (e.g. a property drawer).

Thanks to Alan Schmitt for reporting it.
http://permalink.gmane.org/gmane.emacs.orgmode/88086
2014-06-28 00:28:45 +02:00
Nicolas Goaziou 2ae77c5e50 org-element: Fix parsing path starting with ~
* lisp/org-element.el (org-element-link-parser): Do not prepend "//"
  to paths starting with "~".

Since b1dcd0fb0b, link parser doesn't
expand file names anymore. We need to prevent it from "fixing" paths
starting with "~", as it can cause trouble to some
exporters (e.g. latex).
2014-06-27 17:28:56 +02:00
Nicolas Goaziou 16c71d6b78 org-element: Small refactoring
* lisp/org-element.el (org-element--cache-generate-key): Small
  refactoring.
2014-06-26 22:00:27 +02:00
Nicolas Goaziou db995f2b9d org-element: Use full range of integers for cache keys
* lisp/org-element.el (org-element--cache-generate-key): Allow
  negative numbers in keys.  Small refactoring.
2014-06-26 21:13:43 +02:00
Nicolas Goaziou d5bc5859af org-element: Fix typo
* lisp/org-element.el (org-element--cache-generate-key): Fix typo in
  docstring.
2014-06-26 01:11:26 +02:00
Nicolas Goaziou d40dbc6ca2 org-element: More refactoring
* lisp/org-element.el (org-element--cache-generate-key): Refactor key
  computation.
(org-element--cache-default-key): Remove variable.
2014-06-26 01:08:15 +02:00
Nicolas Goaziou 03040f109f org-element: Refactoring
* lisp/org-element.el (org-element--cache-sensitive-re): New variable
(org-element--cache-opening-line, org-element--cache-closing-line):
Removed variables.
(org-element--cache-before-change, org-element--cache-after-change):
Refactoring.  Also simplify process.
2014-06-25 23:53:23 +02:00
Nicolas Goaziou e46c62d96f org-element: Small cache fix
* lisp/org-element.el (org-element--cache-before-change): Ignore case
  sensitivity when looking for a modified sensitive line.
2014-06-25 23:51:04 +02:00
Nicolas Goaziou 77e234e578 org-element: Fix thinko
* lisp/org-element.el (org-element--cache-key-less-p): Fix thinko.
2014-06-23 23:45:00 +02:00
Nicolas Goaziou 69773248c5 org-element: Fix cache
* lisp/org-element.el (org-element--cache-after-change): Preserve
  match data.

Thanks to Matt Lundin for reporting it.
http://permalink.gmane.org/gmane.emacs.orgmode/87871
2014-06-23 12:28:11 +02:00
Nicolas Goaziou f336de2f82 org-element: Tweak cache parameters
* lisp/org-element.el (org-element-cache-sync-idle-time,
  org-element-cache-sync-break): Increase values as synchronizing
  cache too makes editing somewhat sluggish without any benefit.
2014-06-19 22:32:23 +02:00
Nicolas Goaziou 8e49c823fd org-element: Optimize cache
* lisp/org-element.el (org-element--cache-for-removal): New function.
(org-element--cache-submit-request): Do not synchronize cache when
changes can be merged with next request.

This shortcut is particularly useful when many changes happen in the
same area, which is expensive to parse (e.g., a large list).
2014-06-19 22:32:23 +02:00
Nicolas Goaziou b2f200f0a1 org-element: Sync cache after changes instead of before them
* lisp/org-element.el (org-element--cache-sync,
  org-element--cache-process-request): Change signature.
(org-element--cache-before-change): Do not synchronize cache
preemptively.
(org-element--cache-submit-request): Synchronize cache preemptively.

This change makes possible to skip cache preemptive synchronization
under some circumstances.
2014-06-19 22:32:22 +02:00
Nicolas Goaziou 87dbce239d org-element: Extend format for cache sync requests
* lisp/org-element.el (org-element--cache-sync-requests): Also store
  beginning position for buffer modifications.
(org-element--cache-sync, org-element--cache-process-request)
(org-element--cache-submit-request): Adapt to new request template.

This change is required for a future cache optimization.
2014-06-19 22:32:22 +02:00
Nicolas Goaziou 2084ff06d8 org-element: Tiny refactoring
* lisp/org-element.el (org-element--cache-sync): Do not check return
  value from `org-element--cache-process-request'.
(org-element--cache-process-request): Throw `interrupt' when the
request cannot be processed.
(org-element--cache-process-request): Do not catch interruption from
  `org-element--parse-to'.
(org-element--parse-to): Throw `interrupt' when the process stops
before finding the result.
2014-06-19 22:32:22 +02:00
Nicolas Goaziou ab145f0df5 org-element: Properly parse headline properties
* lisp/org-element.el (org-element-headline-parser,
  org-element-inlinetask-parser): First find appropriate property
  drawer in order to read properties.

* testing/lisp/test-org-element.el (test-org-element/headline-properties):
  Add tests.

Thanks to Sébastien Vauban for reporting it.
http://permalink.gmane.org/gmane.emacs.orgmode/87701
2014-06-18 23:28:19 +02:00
Nicolas Goaziou b1dcd0fb0b org-element: Do not expand file name when parsing links
* lisp/org-element.el (org-element-link-parser): Do not expand file
  name when parsing links so that Tramp doesn't kick in.

Thanks to Sébastien Vauban for reporting it.
http://permalink.gmane.org/gmane.emacs.orgmode/87696
2014-06-18 19:22:21 +02:00
Nicolas Goaziou 4357dde362 org-element: Small fix
* lisp/org-element.el (org-element--cache-generate-key): Small fix.
  Check if UPPER is non nil before comparing its car with 1.  This is
  a safety feature, though, as a key shouldn't end on 0 anyway.
2014-06-07 15:32:47 +02:00
Nicolas Goaziou 36b497720d Merge branch 'maint'
Conflicts:
	lisp/org-element.el
2014-04-23 22:04:20 +02:00
Nicolas Goaziou 94ae862515 org-element: Fix docstring
* lisp/org-element.el (org-element-timestamp-parser): Fix docstring.
2014-04-23 22:02:10 +02:00
Nicolas Goaziou 57039a54aa org-element: Fix code typo
* lisp/org-element.el (org-element--cache-remove): Fix code typo.
2014-04-19 21:59:35 +02:00
Nicolas Goaziou ec65bacc14 org-element: Fix leakage in objects cache
* lisp/org-element.el (org-element--cache-remove): New function.
(org-element--cache-process-request): Use new function.
(org-element-cache-reset): Do not rely on a weak hash table to handle
objects cache.

Elements used as keys in object cache cannot be garbage collected
since they appear in the :parent hierarchy in objects.  Instead we
remove entries from the objects cache whenever an element is removed
from the element cache.
2014-04-19 21:51:56 +02:00
Nicolas Goaziou 6eb940a8dc Fix cache update when radio targets are being refreshed
* lisp/org-element.el (org-element-cache-refresh): New function.
* lisp/org.el (org-update-radio-target-regexp): Make it standalone.
  Also refresh fontification only when necessary.
(org-all-targets, org-make-target-link-regexp): Remove functions.

* testing/lisp/test-org.el (test-org/update-radio-target-regexp): New
  test
(test-org/all-targets): Remove test.

We need to manually reset cache on radio links as re-fontification
doesn't trigger a buffer change, and, as a consequence, a cache reset.
2014-04-19 18:36:58 +02:00
Nicolas Goaziou 2b2b2c5c99 org-element: Fix infloop at the end of an incomplete table row
* lisp/org-element.el (org-element-context): Fix infloop.  Be more
  cautious when point is at the end of buffer.

* testing/lisp/test-org-element.el (test-org-element/context): Add
  test.
2014-04-17 21:37:07 +02:00
Nicolas Goaziou fffd055ac5 Merge branch 'maint'
Conflicts:
	lisp/org-element.el
	lisp/ox-html.el
2014-04-17 11:34:54 +02:00
Nicolas Goaziou b49cbf1338 org-element: Fix ill-defined "file" type links
* lisp/org-element.el (org-element-link-parser): Fix ill-defined
  "file" type links.  Expand absolute file names in the process.

Org accepts invalid URI syntax for absolute "file" links, e.g.,
file:/home/user/file.txt.  This patch normalizes them.
2014-04-17 11:30:15 +02:00
Nicolas Goaziou 7c82e6ac19 No alphanumeric characters around radio links
* lisp/org.el (org-make-target-link-regexp): Change regexp so
  alphanumeric characters cannot be found next to a radio link.
(org-activate-target-links): Apply changes to radio link regexp.

* lisp/org-element.el (org-element--object-lex,
  org-element-link-parser): Apply changes to radio link regexp.

* testing/lisp/test-org-element.el (test-org-element/link-parser):
  Update test.

Patch suggested by Daniel Clemente.
http://permalink.gmane.org/gmane.emacs.orgmode/84461
2014-04-11 21:30:15 +02:00
Nicolas Goaziou ce72d251f7 Merge branch 'maint' 2014-04-09 23:49:49 +02:00
Nicolas Goaziou a768cf045d org-element: Tiny refactoring
* lisp/org-element.el (org-element-headline-parser): Tiny refactoring.
2014-04-09 23:49:04 +02:00
Nicolas Goaziou 1b7d3ffcbf org-element: Tiny fix to headline parsing
* lisp/org-element.el (org-element-headline-parser): Correctly parse
  blank lines after a headline.

Thanks to Thorsten Jolitz for reporting it.
http://permalink.gmane.org/gmane.emacs.orgmode/84753
2014-04-09 23:44:15 +02:00
Nicolas Goaziou dfcfca8219 Merge branch 'maint'
Conflicts:
	lisp/org-element.el
2014-04-08 18:59:06 +02:00
Nicolas Goaziou 728661309e org-element: Fix table parsing with missing final bar
* lisp/org-element.el (org-element-table-cell-parser,
  org-element-table-cell-successor): Recognize cell even when last
  vertical bar is missing.

* testing/lisp/test-org-element.el (test-org-element/table-cell-parser):
  Add test.

Thanks to Thorsten Jolitz for reporting it.
http://permalink.gmane.org/gmane.emacs.orgmode/84713
2014-04-08 18:56:51 +02:00
Nicolas Goaziou 8a43270e8e org-element: Small fix
* lisp/org-element.el (org-element--cache-process-request): Small fix.

This fixes 7fca554f43.
2014-04-01 08:10:41 +02:00
Nicolas Goaziou 7fca554f43 org-element: Slightly change object cache
* lisp/org-element.el (org-element--cache-objects):
(org-element-context): Simplify structure of object cache.

This change avoids relying on buffer positions and artificial keys.
2014-03-31 22:56:25 +02:00
Nicolas Goaziou 10cd4ed4d0 org-element: Fix regression
* lisp/org-element.el (org-element--object-regexp): Take into
  consideration `org-emphasis-regexp-components' when building regexp.

http://permalink.gmane.org/gmane.emacs.orgmode/84349
2014-03-28 17:25:25 +01:00
Nicolas Goaziou 3e5fc4540b org-element: Fix docstring
* lisp/org-element.el (org-element--cache-objects): Fix docstring.
2014-03-27 10:47:36 +01:00
Nicolas Goaziou b5dd32c7e4 org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
  org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(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-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,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.

This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.

http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-27 01:25:52 +01:00
Nicolas Goaziou 230d09aeb0 Merge branch 'maint' 2014-03-24 14:20:23 +01:00
Nicolas Goaziou 8212776cfc Fix radio target parsing
* lisp/org-element.el (org-element-all-successors,
  org-element-object-restrictions): Prioritize `link' over other
  successors in order to find radio links starting with another syntax
  object (e.g., an entity).  Also allow text markup within radio
  targets.
(org-element-link-parser): Add contents to radio targets.

* lisp/org.el (org-make-target-link-regexp): Fix regexp so it can
  match targets starting with an Org object (e.g., an entity).
(org-ctrl-c-ctrl-c): Fix function when applied on an object contained
within a radio target.

* testing/lisp/test-org-element.el (test-org-element/radio-target-parser): Add test.
* testing/lisp/test-ox.el (test-org-export/resolve-radio-link): Add test.
2014-03-24 14:13:24 +01:00
Nicolas Goaziou 7e689ae961 org-element: Fix infloop in `org-element-context'
* lisp/org-element.el (org-element-context): Fix infloop.
2014-03-22 09:16:36 +01:00
Nicolas Goaziou 625397177d Merge branch 'maint' 2014-03-20 18:22:39 +01:00
Nicolas Goaziou 0c4ab29d0a Revert "org-element: Fix radio-target and radio link parsing"
This reverts commit 5174495ee6.

Conflicts:
	lisp/org-element.el
2014-03-20 18:21:04 +01:00
Nicolas Goaziou 5d8cc35e4a org-element: Re-enable cache
* lisp/org-element.el (org-element--cache-put): Effectively store
  elements in cache.

This fixes a bug introduced in 0a5f5117a3.
2014-03-17 21:31:33 +01:00
Nicolas Goaziou 17ecfd4130 Merge branch 'maint' 2014-03-17 10:33:21 +01:00
Nicolas Goaziou 39cfc39ccb org-element: Fix docstring and code typos 2014-03-17 10:31:37 +01:00
Nicolas Goaziou 5174495ee6 org-element: Fix radio-target and radio link parsing
* lisp/org-element.el (org-element-link-parser): "radio" links have
  their path downcased to avoid introducing case mismatch with their
  relative radio target.  With this change it is also necessary to add
  contents to them, since `:path' property no longer matches real
  value of the link.
(org-element-radio-target-parser): Downcase value as explained above.
Store the initial value in a new `:raw-value' property.
2014-03-17 10:24:43 +01:00
Nicolas Goaziou 8012443bc8 org-element: Speed up parsing
* lisp/org-element.el (org-element-inline-babel-call-successor):
  Improve speed.
2014-03-14 19:41:06 +01:00
Nicolas Goaziou e3fa9355f3 org-element: Tiny fix
* lisp/org-element.el (org-element--list-struct): Fix regexp.  Small
  refactoring.
2014-03-14 16:15:57 +01:00
Bastien Guerry 25f47777ef Complete commit 07158e
* org.el (org-refresh-category-properties)
(org-complete-expand-structure-template)
(org-buffer-property-keys, org-context):
* org-mouse.el (org-mouse-context-menu):
* org-list.el (org-list-send-list):
* org-element.el (org-element--list-struct):
* org-archive.el (org-all-archive-files): Allow spaces before
any option keyword.

* org.el (org-fontify-meta-lines-and-blocks-1): Fix
fontification of all option keywords.

Thanks to Alan Schmitt for raising the problem with fontification.
2014-03-13 11:28:07 +01:00
Nicolas Goaziou 0a5f5117a3 org-element: Fix memory leak in cache
* lisp/org-element.el (org-element--cache-put): Do not store objects
  within headlines in cache as headlines are not cached, and,
  therefore, never removed.  This prevents adding the same object in
  cache multiple times without ever garbage collecting it.
2014-03-12 15:18:47 +01:00
Nicolas Goaziou 2f60dfc1b3 Merge branch 'maint' 2014-03-12 09:08:37 +01:00
Nicolas Goaziou cb22a0355f org-element: Fix parsing of bold objects at the beginning of a headline
* lisp/org-element.el (org-element-context): Fix parsing of bold
  objects at the beginning of a headline.
* testing/lisp/test-org-element.el (test-org-element/context): Add
  test.
2014-03-12 09:05:50 +01:00
Nicolas Goaziou a8568372ad org-element: Fix wrong cache behaviour
* lisp/org-element.el (org-element--cache-before-change): Correctly
  preserve match data.
2014-03-05 16:39:29 +01:00
Nicolas Goaziou ef207f4424 org-element: Fix cache bug
* lisp/org-element.el (org-element-context): First initialize cache
  before retrieving data from it.
2014-02-26 14:55:45 +01:00
Nicolas Goaziou 3960ed07e6 Merge branch 'maint'
Conflicts:
	lisp/org-element.el
2014-02-25 20:54:48 +01:00
Nicolas Goaziou 7f8c1226e8 org-element: Fix timestamps parsing in planning lines
* lisp/org-element.el (org-element-context): Fix timestamps parsing.
* testing/lisp/test-org-element.el (test-org-element/context): Add
  test.
2014-02-25 20:51:32 +01:00
Nicolas Goaziou d55fa4b783 Merge branch 'maint' 2014-02-24 17:24:35 +01:00
Nicolas Goaziou 4298a21b82 org-element: Fix parsing of inlinetasks within lists
* lisp/org-element.el (org-element--list-struct): Fix regexp.
2014-02-24 17:22:55 +01:00
Nicolas Goaziou 2ae5cf85e6 org-element: Add checks relative to cache
* lisp/org-element.el (org-element--cache-put, org-element-context):
  Check if cache is active before trying to access it.
2014-02-24 00:05:53 +01:00
Nicolas Goaziou 13691bde32 org-element: Fix `org-element-context' at eob
* lisp/org-element.el (org-element-context): If function is called at
  the end of buffer, return any object that ends there.
* testing/lisp/test-org-element.el (test-org-element/context): Add
  test.
2014-02-23 13:49:41 +01:00
Nicolas Goaziou d0ae5616a5 org-element: Fix cache bug
* lisp/org-element.el (org-element--parse-to): Fix cache parsing when
  the next element to shift is at the contents beginning of its
  parent.  Refactor function.
2014-02-21 12:55:45 +01:00
Nicolas Goaziou eed0500913 org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
  default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function.  Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.

* lisp/ox.el (org-export--generate-copy-script): Do not copy through
  new cache-related variables.
(org-export-ignored-local-variables): New variable.

* testing/lisp/test-org-element.el (test-org-element/cache): New test.

Now only the part of the cache that needs to be accessed is updated
synchronously.  Otherwise, it happens on idle time.
2014-02-20 22:18:17 +01:00
Nicolas Goaziou 03514a6a78 Merge branch 'maint' 2014-02-17 23:01:40 +01:00
Nicolas Goaziou c5d88fb606 org-element: Fix inlinetask parsing
* lisp/org-element.el (org-element-inlinetask-parser): Fix parsing
  when regular and degenerate inlinetasks are mixed in the section.
* testing/lisp/test-org-element.el (test-org-element/inlinetask-parser):
  Add tests.

Thanks to Anders Johansson for reporting it.
2014-02-17 22:59:25 +01:00
Nicolas Goaziou def5cd8ca5 Merge branch 'maint' 2014-02-07 20:08:29 +01:00
Nicolas Goaziou 7f287d1b62 org-element: Fix indentation normalization
* lisp/org-element.el (org-element-normalize-contents): Do not ignore
  empty lines when an object follows.
* testing/lisp/test-org-element.el (test-org-element/normalize-contents):
  Add test.
2014-02-07 20:06:00 +01:00
Nicolas Goaziou dda9461fbb Merge branch 'maint'
Conflicts:
	lisp/org-element.el
2014-02-01 23:33:58 +01:00
Nicolas Goaziou 8e1386cead org-element: Fix smart quotes in TITLE
* lisp/org-element.el (org-element-interpret-data): Do not remove
  properties by side-effect when interpreting a string, as it also
  removes them from the parse tree, making the string unusable without
  its :parent property.

If text properties get in the way, it is also possible to use
`substring-no-properties' but then, a compatibility function would be
required for XEmacs.
2014-02-01 23:25:47 +01:00
Nicolas Goaziou 88c18e07db org-element: Fix a code comment
* lisp/org-element.el (org-element-headline-parser): Fix code comment.
2014-01-28 22:14:40 +01:00
Nicolas Goaziou 6a00c96541 Remove left over references to QUOTE blocks
* lisp/org.el (org-quote-string): Remove variable.
(org-enable-fixed-width-editor, org-context): Update docstring.
(org-toggle-fixed-width-section): Remove function and binding.
(org-set-font-lock-defaults): Remove reference to `org-quote-string'.

* lisp/org-element.el (org-element-headline-parser,
  org-element-headline-interpreter): Remove references to
  `org-quote-string'.

* testing/lisp/test-org-element.el (test-org-element/headline-quote-keyword):
  Remove test.
(test-org-element/headline-interpreter): Remove a test.
2014-01-28 21:36:54 +01:00
Nicolas Goaziou 8a265e2915 org-element: Remove quote sections
* lisp/org-element.el (org-element-quote-section-parser,
  org-element-quote-section-interpreter): Remove functions.
  (org-element--current-element, org-element--parse-elements): Do not
  handle quote sections at all.
* testing/lisp/test-org-element.el (test-org-element/quote-section-parser):
  Remove test.
2014-01-27 21:14:20 +01:00
Nicolas Goaziou 34edfd846f org-element: Preserve Emacs 23 compatibility
* lisp/org-element.el (org-element--cache-mapc): New function.
(org-element--cache-sync): Use new function.

`avl-tree-mapc' exists in Emacs 24's "avl-tree" but not in Emacs
23's. The new function implements it.
2014-01-21 18:17:33 +01:00
Nicolas Goaziou 5f38f7b7b0 org-element: Comply to Emacs 23 signature requirements
* lisp/org-element.el (org-element--cache-sync): Call
  `avl-tree-delete' with 2 arguments only as a 4-arguments call is
  only compatible with Emacs 24.1 and later.
2014-01-20 19:03:50 +01:00
Nicolas Goaziou fd877a7380 org-element: Small optimization
* lisp/org-element.el (org-element-at-point): Do not call
  `outline-next-heading' when an element at top level contains point.
  This is particularly important when the current section ends way
  after the point.
2014-01-19 15:06:09 +01:00
Nicolas Goaziou cad81696b8 Change no brace sub/superscript syntax
* lisp/org.el (org-match-substring-regexp): Simplify syntax when not
using braces.  Also make the variable a defconst.
(org-match-substring-with-braces-regexp): Make the variable a defconst
and remove a useless group in regexp.
* lisp/org-element.el (org-element-subscript-parser,
  org-element-superscript-parser): Adapt to group changes.
2014-01-11 23:54:22 +01:00
Nicolas Goaziou fd5edd35ae org-element: Fix cache bug
* lisp/org-element.el (org-element-cache-get): Return correct cached
  element when point is at the beginning of an item.
2014-01-11 22:31:53 +01:00
Nicolas Goaziou a4b1fa7ca1 org-element: New accessor for cache root
* lisp/org-element.el (org-element--cache-root): New function.
(org-element--cache-sync, org-element-cache-get): Use new function.

This is a workaround for `avl-tree--root' bug before Emacs 24.  Thanks
to Daniel Clemente for reporting it.
2014-01-11 10:12:45 +01:00
Nicolas Goaziou f75f3dd1c1 org-element: Fix `org-element-at-point' at eob
* lisp/org-element.el (org-element-at-point): Return appropriate value
  when point is at end of buffer and a cached element was found above.
2014-01-09 11:55:49 +01:00
Bastien Guerry f8e1745440 Merge branch 'maint'
Conflicts:
	contrib/lisp/org-favtable.el
2014-01-07 14:19:03 +01:00
Bastien Guerry 7d9a883b50 Update copyright years again.
Hint: copyright years are all updated in Emacs.
2014-01-07 14:18:17 +01:00
Nicolas Goaziou e32ebb6c1a org-element: Change data structure for cache
* lisp/org-element.el (org-element-at-point, org-element-cache-get,
  org-element-cache-put, org-element--cache-sync): Complete rewrite to
  use new data structure.
(org-element-context, org-element-cache-reset): Slight change in order
to use new tools to access cached data.
(org-element-cache-merge-changes-threshold): Renamed from
`org-element--cache-merge-changes-threshold'.
(org-element-cache-sync-idle-time): Renamed from
`org-element--cache-sync-idle-time'.
(org-element--cache-objects): New variable.

Now elements are stored in AVL tree and objects in a hash table.  Also
moved functions relative to cache into a specific section of the file.
2014-01-05 23:08:18 +01:00
Nicolas Goaziou 594b7808a1 org-element: Fix parsing orphaned affiliated keywords
* lisp/org-element.el (org-element-keyword-parser): Fix parsing
  orphaned affiliated keywords.
2014-01-05 23:08:18 +01:00
Bastien Guerry c41f5075ac Merge branch 'maint'
Conflicts:
	contrib/lisp/org-favtable.el
2014-01-05 06:36:11 +01:00
Bastien Guerry 0beda99171 Revert "Update copyright years."
This reverts commit 21105594fc.
2014-01-05 06:28:07 +01:00
Bastien Guerry 096ff7e078 Merge branch 'maint'
Conflicts:
	contrib/lisp/org-favtable.el
2014-01-04 18:58:12 +01:00
Bastien Guerry 21105594fc Update copyright years. 2014-01-04 18:56:11 +01:00
Nicolas Goaziou ae1cf04833 org-element: Fix `org-element-at-point'
* lisp/org-element.el (org-element-at-point): Fix function when buffer
  starts with a headline.
2013-12-30 17:26:13 +01:00
Nicolas Goaziou 4dbbbe5b01 org-element: Small refactoring
* lisp/org-element.el (org-element-at-point): Refactor code.  Fixing
  structure in cached plain lists is no longer required since
  4423d750a4.
2013-12-30 14:15:11 +01:00
Nicolas Goaziou fde42c5303 org-element: Fix cache when point is at eob
* lisp/org-element.el (org-element-at-point): Fix cache when point is
  at eob and shortcut found something above.
2013-12-30 14:15:11 +01:00
Nicolas Goaziou 405b505c73 org-element: Fix cache update
* lisp/org-element.el (org-element--cache-sync): Fix cache update when
  a only contents of an element are modified.
(org-element--cache-shift-positions): Add optional argument allowing
partial shifting.
2013-12-30 14:15:11 +01:00
Nicolas Goaziou 398dbd91ed org-element: Fix `org-element-at-point' shortcut
* lisp/org-element.el (org-element-at-point): Correctly move from
  blank line to blank line in order to find a known element above.
2013-12-27 15:41:41 +01:00
Nicolas Goaziou 4cb98ed1cd org-element: Fix org-element-insert-before
* lisp/org-element.el (org-element-insert-before): Handle insertion at
  the beginning of a :title property.
2013-12-26 12:26:11 +01:00
Nicolas Goaziou b44fbb920c Merge branch 'maint' 2013-12-16 21:04:57 +01:00
Nicolas Goaziou b22714a88d org-element: Keep compatibility with Babel's regexps
* lisp/org-element.el (org-element-inline-babel-call-successor): Use
  original regexp to stay up-to-date with Babel changes.
2013-12-16 21:00:57 +01:00
Nicolas Goaziou d55f0632b5 Merge branch 'maint' 2013-12-15 16:18:31 +01:00
Nicolas Goaziou f1b9339aa5 org-element: Fix affiliated keyword regexp
* lisp/org-element.el (org-element--affiliated-re): Fix affiliated
  keyword regexp.
2013-12-15 16:16:20 +01:00
Nicolas Goaziou 149eafb487 org-element: Small change to cache optimization
* lisp/org-element.el (org-element-at-point): Simplify opportunistic
  shortcut by looking only for blank lines and headlines or
  inlinetasks.  Since regexp is simpler, we can afford to make more
  searches.
2013-12-12 23:49:49 +01:00
Nicolas Goaziou 4423d750a4 org-element: Fix holes in cache
* lisp/org-element.el (org-element--cache-stable-types): New variable.
(org-element--cache-sync): Do not store elements with missing parents
in cache.

The bug was introduced in 71c8474ae9.
Parsing doesn't always start from beginning of section, which means
that missing parents aren't always repaired while moving to the
current element.  Therefore, we need to remove any element from cache
with an invalid parent property.
2013-12-12 23:04:29 +01:00
Nicolas Goaziou cd439bc513 org-element: Extend `org-element-set-element' to strings
* lisp/org-element.el (org-element-set-element): Allow to replace
  a string with an element, an element with a string, or a string with
  a string.
2013-12-01 17:05:34 +01:00
Nicolas Goaziou 798ad3a27e org-element: Implement `org-element-insert-before'
* lisp/org-element.el (org-element-insert-before): New function.
* testing/lisp/test-org-element.el (test-org-element/insert-before):
  New test.
2013-12-01 17:05:34 +01:00
Nicolas Goaziou b0216248e3 org-element: Implement `org-element-extract-element'
* lisp/org-element.el (org-element-extract-element): New function.
* testing/lisp/test-org-element.el (test-org-element/extract-element):
  New test.
2013-12-01 17:05:34 +01:00
Nicolas Goaziou 0fd4245a43 org-element: Implement `org-element-secondary-p'
* lisp/org-element.el (org-element-secondary-p): New function.
* lisp/ox.el (org-export-get-previous-element,
  org-export-get-next-element): Use new function.
* testing/lisp/test-org-element.el (test-org-element/secondary-p): New
  test.
2013-12-01 17:05:34 +01:00
Nicolas Goaziou 5a2dabc21b org-element: Optimize parser only when cache is active
* lisp/org-element.el (org-element-at-point): Try opportunistic
  shortcut only when cache is active.
2013-11-26 23:51:26 +01:00
Nicolas Goaziou 71c8474ae9 org-element: Speed-up for `org-element-at-point'
* lisp/org-element.el (org-element-at-point): Rewrite function. Remove
  optional argument.

Include an opportunistic search at the beginning of the function.  It
drastically improves speed on large sections for a small overhead on
small ones.
2013-11-26 18:18:33 +01:00
Nicolas Goaziou a9eec72ecf Merge branch 'maint' 2013-11-25 23:36:38 +01:00
Nicolas Goaziou 7bee47120b org-element: Update paragraph separate regexp
* lisp/org-element.el (org-element-paragraph-separate): More accurate
  regexp.
2013-11-25 23:19:48 +01:00
Nicolas Goaziou fc95ee2768 org-element: Change to timestamp interpreter
* lisp/org-element.el (org-element-timestamp-interpreter):
  Ignore :raw-value and build timestamp from numeric properties
  instead.
* testing/lisp/test-org-element.el: Update tests.
* testing/lisp/test-ox.el: Update tests.

This change allow to modify and update a timestamp easily without
requiring to reset :raw-value first, which was not intuitive.
2013-11-16 10:18:19 +01:00
Nicolas Goaziou 926bc85861 org-element: Rename a function
* lisp/org-element.el (org-element--cache-shift-positions): Renamed
  from `org-element--shift-positions'.
(org-element--cache-sync): Apply renaming.
2013-11-16 09:53:10 +01:00
Nicolas Goaziou 4466af5c11 org-element: Fix commit 73d60606bd
* lisp/org-element.el (org-element--cache-sync): Fix commit
  73d60606bd.
2013-11-16 00:33:30 +01:00
Nicolas Goaziou 73d60606bd org-element: Fix cache bug
* lisp/org-element.el (org-element--cache-sync): Properly remove from
  cache last element in a plain list when blank lines at the end of
  that list are modified.
2013-11-15 23:46:45 +01:00
Nicolas Goaziou 91c1718519 org-element: Fix cache corruption when moving list
* lisp/org-element.el (org-element--shift-positions): Fix cache
  corruption when moving list.
2013-11-15 23:10:41 +01:00
Nicolas Goaziou f101663489 org-element: Interpret pseudo elements and objects
* lisp/org-element.el (org-element-interpret-data): Change signature.
  One can now define pseudo elements and objects types.
(org-element--interpret-data-1): New function.
* testing/lisp/test-org-element.el: Add tests.
* testing/lisp/test-ox.el: Update tests.

A pseudo element or object is a new element or object type that is
created and treated locally within an export back-end.  The back-end
provides a translator for it and it is ignored when interpreted back
into Org syntax.
2013-11-11 13:16:43 +01:00
Nicolas Goaziou c57372d5fa Merge branch 'maint'
Conflicts:
	testing/lisp/test-org-element.el
2013-11-10 11:47:06 +01:00
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 ca100eaa01 Merge branch 'maint' 2013-11-10 10:25:17 +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 0656278de4 Merge branch 'maint' 2013-11-06 19:17:39 +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 8403332dbc org-element: Fix bug in cache
* lisp/org-element.el (org-element--cache-sync): Modifying blank lines
  at the end of a list or a footnote definition no longer corrupt
  cache.
2013-11-04 19:28:07 +01:00
Nicolas Goaziou 8255286e22 org-element: Small refactoring
* lisp/org-element.el (org-element-item-parser,
  org-element-plain-list-parser): Remove dependencies on org-list
  library.
2013-11-04 18:16:28 +01:00
Nicolas Goaziou b96986b81c Merge branch 'maint' 2013-11-03 17:53:11 +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 0cecf32a0a org-element: Implement caching for dynamic parser
* lisp/org-element.el (org-element-use-cache, org-element--cache,
org-element--cache-sync-idle-time,
org-element--cache-merge-changes-threshold, org-element--cache-status,
org-element--cache-opening-line, org-element--cache-closing-line): New
variables.
(org-element-cache-reset, org-element--cache-pending-changes-p,
org-element--cache-push-change, org-element--cache-cancel-changes,
org-element--cache-get-key, org-element-cache-get,
org-element-cache-put, org-element--shift-positions,
org-element--cache-before-change, org-element--cache-record-change,
org-element--cache-sync): New functions.
(org-element-at-point, org-element-context): Use cache when possible.
* lisp/org.el (org-mode, org-set-modules): Reset cache.
* lisp/org-footnote.el (org-footnote-section): Reset cache.
* testing/lisp/test-org-element.el: Update tests.

This patch gives a boost to `org-element-at-point' and, to a lesser
extent, to `org-element-context'.
2013-11-03 13:09:54 +01:00
Nicolas Goaziou 6202ec7b3b Remove need to declare drawers before using them
* lisp/org-agenda.el (org-agenda-prepare): Remove reference to
  `org-drawers-for-agenda'.
(org-agenda-show-1): Remove reference to `org-drawers'.
* lisp/org-clock.el (org-clock-remove-empty-clock-drawer,
  org-clock-cancel): Apply signature change to
  `org-remove-empty-drawer-at'.
* lisp/org-element.el (org-element--list-struct): Use
  `org-drawer-regexp' instead of `org-drawers'.
* lisp/org-feed.el (org-feed-drawer): Update docstring according to
  change.
* lisp/org-list.el (org-in-item-p, org-list-context): Use
  `org-drawer-regexp' instead of `org-drawers'.
* lisp/org-mobile.el (org-mobile-create-index-file): Remove reference
  to `org-drawers-for-agenda'.
* lisp/org-pcomplete.el (pcomplete/org-mode/drawer): Remove function.
* lisp/org.el (org-drawer-regexp): Make variable global.
(org-drawers): Remove variable.
(org-set-regexps-and-options): Ignore DRAWER keyword.
(org-cycle): Use `org-drawer-regexp' instead of `org-drawers'.
(org-cycle-hide-drawers): Add an optional argument to ignore some
drawers.
(org-remove-empty-drawer-at): Remove second argument.  Rewrite
function.
(org-clone-subtree-with-time-shift): Apply signature change to
`org-remove-empty-drawer-at'.
(org-toggle-ordered-property): Apply `org-delete-property' signature
change.
(org-map-entries): Remove reference to `org-drawers-for-agenda'.
(org-entry-delete): Remove optional argument.  Small refactoring.
(org-insert-drawer): Remove reference to `org-drawers'.
(org-delete-property): Apply `org-entry-delete' signature change.
(org-in-drawer-p): Rewrite function.
* testing/lisp/test-org-element.el: Update tests.
* testing/lisp/test-org.el: Update tests.
* testing/lisp/test-ox.el: Update tests.
2013-10-31 21:19:40 +01:00
Nicolas Goaziou 73f2ef866d org-element: Small change to src block indentation
* lisp/org-element.el (org-element-remove-indentation): Renamed from
  `org-element--remove-indentation'.
(org-element-example-block-interpreter, org-element-src-block-parser):
Do not depend on `org-src-preserve-indentation'.
(org-element-src-block-interpreter, org-element-example-block-parser):
Check `org-src-preserve-indentation'.
* lisp/ox.el (org-export-unravel-code): Handle
  `org-src-preserve-indentation'.
* testing/lisp/test-org-element.el: Update tests.
2013-10-27 11:06:28 +01:00
Nicolas Goaziou 2668d9e9ce Merge branch 'maint' 2013-10-24 17:22:26 +02: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 e9647da101 org-element: Do not retrieve Babel related info
* lisp/org-element.el (org-element-babel-call-parser,
  org-element-inline-babel-call-parser): Do not call
  `org-babel-lob-get-info' since it is out of parser's scope.
(org-element-babel-call-interpreter,
org-element-inline-babel-call-interpreter): Apply changes to parsers.
2013-10-20 13:38:30 +02:00
Nicolas Goaziou fe27ca9906 org-element: Remove folding status in parsed data
* lisp/org-element.el (org-element-center-block-parser,
  org-element-drawer-parser, org-element-dynamic-block-parser,
  org-element-item-parser, org-element-quote-block-parser,
  org-element-comment-block-parser, org-element-export-block-parser,
  org-element-verse-block-parser, org-element-special-block-parser,
  org-element-example-block-parser, org-element-headline-parser,
  org-element-inlinetask-parser): Remove :hiddenp property.
* lisp/org.el (org-end-of-line, org-down-element): Use an equivalent
  of :hiddenp property.
* testing/lisp/test-org-element.el: Remove tests.

The property is removed because it is buggy (e.g., when there's a link
just after a block opening line) and not really useful.
2013-10-17 22:45:00 +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
Nicolas Goaziou 7cd6fdcd34 org-element: Only allow plain links in links
* lisp/org-element.el (org-element-all-successors): Add `plain-link'
  successor.
(org-element-object-restrictions): Remove `link' within `link'.  Allow
`plain-link' instead.
(org-element-plain-link-successor): New function.
* testing/lisp/test-org-element.el: Add test.

Plain links within links are needed for the following kind of syntax:

  [[http://orgmode.org][file:unicorn.png]]

No other link type is allowed within links.
2013-02-25 22:16:01 +01:00
Nicolas Goaziou e024beaa7e org-element: Refactor object parsing
* lisp/org-element.el (org-element--get-next-object-candidates):
  Rewrite function to simplify algorithm.
(org-element-context, (org-element--parse-elements)): Apply
changes.
* lisp/org.el (org-fill-paragraph): Apply changes.
2013-02-25 21:52:54 +01:00
Nicolas Goaziou ca060f7be7 Require 2 blank lines to separate footnote definition
* lisp/org-element.el (org-element-footnote-definition-parser):
  Require 2 blank lines to separate footnote definition.
* lisp/org-footnote.el (org-footnote-at-definition-p): Require 2 blank
  lines to separate footnote definition.
* doc/org.texi: Update documentation for footnotes.
* testing/lisp/test-org-element.el: Update tests.
* testing/lisp/test-org-footnote.el: Add tests.

Footnote definitions can still be separated with other footnote
definitions and headlines. This change allows to have multiple
paragraphs in a footnote definition without resorting to the "\par"
trick.
2013-02-24 14:44:07 +01:00
Nicolas Goaziou e5a249b327 org-element/ox: Introduce :optional-title property and an accessor
* lisp/org-element.el (org-element-headline-parser): Node
  property :OPTIONAL_TITLE: in a headline will be parsed and stored
  under :optional-title property.
* lisp/ox.el (org-export-get-optional-title): New function.
2013-02-23 22:41:30 +01:00
Bastien Guerry 8ee6c13c7f Fix typo: an headline -> a headline. 2013-02-23 13:47:44 +01:00
Nicolas Goaziou 6c565ec533 org-element: Fix latex environment parsing
* lisp/org-element.el (org-element-latex-environment-parser): Fix
  wrong value for :post-affiliated property when parsing a latex
  environment.
2013-02-22 14:31:05 +01:00
Nicolas Goaziou a385c6e0e4 org-element: Fix docstring, add tests
* lisp/org-element.el (org-element-headline-parser,
  org-element-inlinetask-parser): Fix docstring.
* testing/lisp/test-org-element.el: Add tests.

This follows ae5932282d.
2013-02-18 08:58:59 +01:00
Nicolas Goaziou ae5932282d org-element: Headlines properties from property drawer are upcased
* lisp/org-element.el (org-element-headline-parser,
  org-element-inlinetask-parser): Upcase properties.  This is done to
  avoid confusion between properties from parser (e.g. `:end') and
  properties from the property drawer (e.g. :END:).

In particular, it means that :CUSTOM_ID: property is accessed through:

  (org-element-property :CUSTOM_ID headline)
2013-02-18 00:01:52 +01:00
Nicolas Goaziou 229d08e44e org-element: Allow to map over arbitrary lists
* lisp/org-element.el (org-element-map): Allow to map over any list.
  Do not restrict mapping to object types.
2013-02-17 00:49:13 +01:00
Nicolas Goaziou 78a652716e ox: Whitespaces are not significant when matching a fuzzy link
* lisp/ox.el (org-export-resolve-fuzzy-link): Whitespaces are not
  significant when matching a fuzzy link.
* lisp/org-element.el (org-element-link-parser): Do not remove
  newlines characters in paths anymore, since this is not required.
* testing/lisp/test-org-element.el: Update tests.
* testing/lisp/test-ox.el: Add test.
2013-02-15 18:08:03 +01:00
Nicolas Goaziou 3bc8c9647a org-element: Fix error and infloop in `org-element-at-point'
* lisp/org-element.el (org-element-at-point): Return nil when in the
  first empty lines of the buffer.  Return headline when in empty
  lines just after the headline.
2013-02-15 16:13:53 +01:00
Nicolas Goaziou f3c79f9181 org-element: Fix 9f8f32c360
* lisp/org-element.el (org-element-link-parser): Take into
  consideration links filled and indented.
2013-02-13 13:29:07 +01:00
Bastien Guerry 5ab647af64 Merge branch 'maint'
Conflicts:
	doc/org.texi
2013-02-13 12:10:45 +01:00
Bastien Guerry 718b210009 Backport typo fixes from Emacs revno 111250 by Paul Eggert. 2013-02-13 12:09:56 +01:00
Nicolas Goaziou 9f8f32c360 org-element: Fix parsing of links with filled path
* lisp/org-element.el (org-element-link-parser): Remove all newline
  characters in path property.
* testing/lisp/test-org-element.el: Add test.
2013-02-13 08:41:43 +01:00
Nicolas Goaziou 94bcc7e282 org-element: Fix parsing of orphaned keyword at the end of an element
* lisp/org-element.el (org-element--current-element): Add a limit
  argument.
(org-element--collect-affiliated-keywords): Fix parsing of orphaned
keyword at the end of an element.
* testing/lisp/test-org-element.el: Add test.
2013-02-11 21:12:43 +01:00
Nicolas Goaziou 6b7101b910 Fix some compilation problem
* lisp/org-element.el (org-element-nested-p): Do not inline function.
* lisp/org.el: Do not autoload functions.
2013-02-10 14:47:57 +01:00
Nicolas Goaziou 787a07421c Merge branch 'maint' 2013-01-31 22:16:23 +01:00
Nicolas Goaziou 592dc2ee7e org-element: Fix macro parsing with protected commas
* lisp/org-element.el (org-element-macro-parser): Fix error when last
  argument ends with a protected comma.
* testing/lisp/test-org-element.el (test-org-element/macro-parser):
  Add tests.
2013-01-31 22:15:39 +01:00
Nicolas Goaziou 8798f15b72 org-element: Cosmetic change to `org-element-map' indentation
* lisp/org-element.el (org-element-map): Change to function
  indentation.  Also complete docstring.
2013-01-30 14:42:24 +01:00
Bastien Guerry 9d5b79104b Merge branch 'maint' 2013-01-23 12:58:15 +01:00
Bastien Guerry 340f51f723 org-element.el (org-element-at-point): Fix typo in docstring
* org-element.el (org-element-at-point): Fix typo in docstring.
2013-01-23 12:58:09 +01:00
Nicolas Goaziou 0cf7179430 Revert "org-element: Change return value for element at point in some corner cases"
This reverts commit 13e49a6385.

Conflicts:
	lisp/org-element.el
2013-01-21 21:51:39 +01:00
Nicolas Goaziou 3e699dc032 Merge branch 'maint'
Conflicts:
	lisp/org-element.el
2013-01-20 09:50:32 +01:00
Nicolas Goaziou 84d2251e57 org-element: Improve some docstrings
* lisp/org-element.el (org-element-parse-buffer, org-element-map,
  org-element-at-point, org-element-context): Be more verbose in
  docstrings.  Also fix typos.
2013-01-20 09:47:24 +01:00
Nicolas Goaziou 13e49a6385 org-element: Change return value for element at point in some corner cases
* lisp/org-element.el (org-element-at-point): When point is before any
  element, in the first blank lines of the buffer, return nil.  When
  point is within blank lines just after a headline, return that
  headline.
(org-element-context): Return nil when point is within the blank at
the beginning of the buffer.
* testing/lisp/test-org-element.el: Add tests.
2013-01-19 23:34:59 +01:00
Nicolas Goaziou b68103a344 org-element: Correctly interpret timestamps ranges with repeaters
* lisp/org-element.el (org-element-timestamp-interpreter): Interpret
  timestamps ranges with repeaters.
* testing/lisp/test-org-element.el: Add test.
2013-01-10 14:02:19 +01:00
Nicolas Goaziou 2fd88bfd56 org-element: Small optimization to `org-element-context'
* lisp/org-element.el (org-element-context): Add an optional argument
  so (org-element-context)
  and (org-element-context (org-element-at-point)) are equivalent.
* testing/lisp/test-org-element.el: Add test.
2013-01-09 15:33:29 +01:00
Bastien Guerry 679dce0fda Merge branch 'maint' 2013-01-08 15:26:17 +01:00
Bastien Guerry 31c1aeabae Various small fixes 2013-01-08 15:26:04 +01:00
Bastien Guerry 5fc740a230 Merge branch 'maint' 2013-01-08 15:04:40 +01:00
Bastien Guerry 72bc144c15 Update Copyright lines to match Emacs format. 2013-01-08 15:04:32 +01:00
Bastien Guerry 60b23bdeac Merge branch 'maint'
Conflicts:
	contrib/lisp/htmlize.el
	etc/schema/od-manifest-schema-v1.2-os.rnc
	etc/schema/od-schema-v1.2-os.rnc
	lisp/org-exp-blocks.el
2013-01-01 16:06:17 +01:00
Bastien Guerry 98cd4687a2 Update copyright years.
Happy new year!
2013-01-01 16:04:24 +01:00
Nicolas Goaziou bc4351ce0d org-element: Fix parsing of links expanded from an abbreviation
* lisp/org-element.el (org-element-object-variables): New variable.
(org-element-parse-secondary-string): Copy some buffer-local variables
to the temporary buffer created to parse the string so links can still
be properly expanded.
(org-element-link-parser): Link expansion and translation are applied
transparently for the parser.
2012-12-18 21:59:05 +01:00
Nicolas Goaziou 442b2ad15d Merge branch 'maint'
Conflicts:
	lisp/org-element.el
2012-12-16 00:49:22 +01:00
Nicolas Goaziou 20839ced71 org-element: Fix parsing of a list in a block in a list
* lisp/org-element.el (org-element--parse-elements,
  org-element-at-point): Fix parsing of a list in a block in a list.
* testing/lisp/test-org-element.el: Add test.
2012-12-16 00:45:17 +01:00
Nicolas Goaziou 6e37a4d114 org-element: Fix line break parsing
* lisp/org-element.el (org-element-line-break-parser): Line break
  includes the newline character following the backslashes.
(org-element-line-break-interpreter): Apply changes to line break
parsing.
2012-12-12 22:47:12 +01:00
Nicolas Goaziou a51b8fa308 org-element: Fix timestamp interpreter
* lisp/org-element.el (org-element-timestamp-interpreter): Fix
  timestamp interpreter when raw value isn't available.
* testing/lisp/test-org-element.el: Update test.
2012-11-25 01:16:39 +01:00
Nicolas Goaziou ce8819f18d Merge branch 'maint' 2012-11-23 23:49:19 +01:00
Nicolas Goaziou 89b8a8ca6d org-element: Fix `org-element-context'
* lisp/org-element.el (org-element-context): When point is between two
  objects, be sure to return the second one.
* testing/lisp/test-org-element.el: Add test.
2012-11-23 23:46:52 +01:00
Nicolas Goaziou cb32494e24 org-element: Timestamp with time range has active/inactive-range type
* lisp/org-element.el (org-element-timestamp-parser): Timestamp with
  time range has active/inactive-range type.
* testing/lisp/test-org-element.el: Add test.

In order to know if starting date/time is really the same as ending
date/time, this patch permits to use the following:

  (memq (org-element-property :type timestamp) '(active inactive))
2012-11-22 22:32:48 +01:00
Nicolas Goaziou c3407d3c98 org-element: Do not reset `org-element-block-name-alist' at each reload
* lisp/org-element.el (org-element-block-name-alist): Do not reset
`org-element-block-name-alist' at each reload.
2012-11-19 22:57:17 +01:00
Nicolas Goaziou 807e4af09c org-element: Allow timestamps in parsed keywords (i.e. DATE)
* lisp/org-element.el (org-element-object-restrictions): Allow
  timestamps in parsed keywords (i.e. DATE).
2012-11-19 21:53:58 +01:00
Nicolas Goaziou b46b5d1c44 org-element: Return nil for unspecified time values
* lisp/org-element.el (org-element-timestamp-parser): Return nil for
  unspecified :hour-end and :minute-end properties.
* testing/lisp/test-org-element.el: Add tests.
2012-11-15 21:02:26 +01:00
Nicolas Goaziou 6d099eedc8 org-element: Allow footnote references in table cells
* lisp/org-element.el (org-element-object-restrictions): Add footnote
  references objects in table cells.
* contrib/lisp/org-e-latex.el (org-e-latex-footnote-reference,
  org-e-latex-table): Add support for footnote reference in table
  cells.
2012-11-12 21:14:43 +01:00
Nicolas Goaziou c40a0dbd38 org-element: Clear text properties when interpreting a string
* lisp/org-element.el (org-element-interpret-data): Clear text
  properties when interpreting a string .
2012-11-11 23:47:34 +01:00
Nicolas Goaziou 5e30d4fa4e org-element: Remove :clockedp property from headlines and inlinetasks
* lisp/org-element.el (org-element-headline-parser,
  org-element-inlinetask-parser): Remove :clockedp property.

This property isn't even remotely related to the structure of the
document and, as such, doesn't belong to Org element.
2012-10-30 13:13:47 +01:00
Nicolas Goaziou 1f3a2c42c6 org-element, org-export: Fix documentation typos
* contrib/lisp/org-export.el (org-export--get-subtree-options): Fix
  code comment.
* lisp/org-element.el (org-element-map): Fix docstring.
2012-10-29 21:57:46 +01:00
Nicolas Goaziou c7f4a9ebad org-element: Fix accessors and setters wrt secondary strings
* lisp/org-element.el (org-element-contents, org-element-set-contents,
  org-element-adopt-elements): Fix accessors and setters wrt secondary
  strings.
2012-10-29 19:03:54 +01:00
Nicolas Goaziou 07c8895705 org-element: Fix void-function org-clocking-buffer error
* lisp/org-element.el (org-element-headline-parser,
  org-element-inlinetask-parser): Fix void-function
  org-clocking-buffer error.
2012-10-29 16:26:34 +01:00
Nicolas Goaziou 2e8591783f org-element: Fix org-element-context on parsed keywords
* lisp/org-element.el (org-element-context): Fix org-element-context
  on parsed keywords.
* testing/lisp/test-org-element.el: Update test.
2012-10-29 14:01:49 +01:00
Nicolas Goaziou 99110c60a6 org-element: Find objects in document and parsed affiliated keywords
* lisp/org-element.el (org-element-context): Find objects in document
  and parsable affiliated keywords.
* testing/lisp/test-org-element.el: Add tests.
2012-10-29 11:09:41 +01:00
Nicolas Goaziou 89ec3f1abf org-element: Add `:post-affiliated' property to elements when applicable
* 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-plain-list-parser, org-element-property-drawer-parser,
  org-element-quote-block-parser, org-element-special-block-parser,
  org-element-babel-call-parser, org-element-comment-parser,
  org-element-comment-block-parser, org-element-diary-sexp-parser,
  org-element-example-block-parser, org-element-export-block-parser,
  org-element-fixed-width-parser, org-element-horizontal-rule-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): Add
  `:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.

This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 11:02:06 +01:00
Nicolas Goaziou 98d5666bac org-element: Allow duals keywords with only secondary value
* lisp/org-element.el (org-element--collect-affiliated-keywords):
  Allow duals keywords with only secondary value.
* testing/lisp/test-org-element.el: Add test.

This patch allows to parse correctly the following:

    #+CAPTION[short caption]:
    #+CAPTION: Very long caption
    Some paragraph.
2012-10-28 22:45:34 +01:00
Nicolas Goaziou c1e3aaece3 org-element: Improve timestamps parsing
* lisp/org-element.el (org-element-timestamp-parser): Modify timestamp
  objects properties.
(org-element-headline-parser, org-element-inlinetask-parser): Remove
`:timestamp' and `:clock' property.  Add `:clockedp' property.  Also,
set `:closed', `:deadline' and `:scheduled' values to timestamp
objects, not strings.  Small refactoring.
(org-element-clock-parser): Rename `:time' property into `:duration'.
Also, set `:value' value as a timestamp object, not a string.
(org-element-planning-parser): Set `:closed', `:deadline' and
`:scheduled' values to timestamp objects, not strings.
(org-element-clock-interpreter, org-element-planning-interpreter)
(org-element-timestamp-interpreter): Update interpreters.
(org-element--current-element): Tiny refactoring.
* testing/lisp/test-org-element.el: Add tests.
2012-10-28 16:29:55 +01:00
Nicolas Goaziou d81982ae9d org-element: Parse diary-sexp elements
* lisp/org-element.el (org-element-paragraph-separate): Diary-sexp
  elements can separate paragraphs.
(org-element-all-elements): Install new `diary-sexp' type.
(org-element--current-element): Recognize new `diary-sexp' elements.
(org-element-diary-sexp-parser, org-element-diary-sexp-interpreter):
New functions.
* testing/lisp/test-org-element.el: Add tests.
2012-10-27 14:43:30 +02:00
Nicolas Goaziou 1d58b0b2cd org-element: Small refactoring
* lisp/org-element.el (org-element-horizontal-rule-parser,
  org-element-keyword-parser, org-element--current-element): Small
  refactoring.
2012-10-27 14:37:18 +02:00
Nicolas Goaziou 95c305490e org-element: Add :parent text property to strings in parse tree
* lisp/org-element.el (org-element-property): Access to text
  properties when argument is a string.
(org-element-put-property): Correctly set property when target is
a string.
(org-element-adopt-elements): Also put :parent properties on strings.
* testing/lisp/test-org-element.el: Add test.
2012-10-27 11:42:30 +02:00
Bastien Guerry 47486f4b90 Merge branch 'maint' 2012-10-23 18:39:32 +02:00
Bastien Guerry 95ca977411 Fix typos fixed in Emacs (part 1)
Thanks to Paul Eggert for the fixes:
http://lists.gnu.org/archive/html/emacs-diffs/2012-10/msg00069.html
2012-10-23 18:39:20 +02:00
Nicolas Goaziou 23aa910259 Merge branch 'maint' 2012-10-14 21:51:59 +02:00
Nicolas Goaziou b7c5cf5d44 org-element: Fix parsing of objects of the same type in a single paragraph
* lisp/org-element.el (org-element--get-next-object-candidates): Fix
  parsing of objects of the same type in a single paragraph.
* testing/lisp/test-org-element.el: Add tests.
2012-10-14 21:49:41 +02:00
Nicolas Goaziou c65abd8577 org-element: Fix parsing of syntax at beginning of item
* lisp/org-element.el (org-element-sub/superscript-successor): Fix
  parsing of sub/superscript at beginning of item.
(org-element-latex-or-entity-successor): Fix parsing of latex
  fragments at beginning of item.
* testing/lisp/test-org-element.el: Add test.
2012-10-14 21:38:42 +02:00
Nicolas Goaziou 2c78ca4a56 Merge branch 'maint'
Conflicts:
	lisp/org-element.el
2012-10-06 01:21:27 +02:00
Nicolas Goaziou ad99ea9147 org-element: Fix parsing with trailing spaces at eob
* lisp/org-element.el (org-element-center-block-parser,
  org-element-drawer-parser, , org-element-footnote-definition-parser,
  org-element-inlinetask-parser, org-element-plain-list-parser,
  org-element-quote-block-parser, org-element-special-block-parser,
  org-element-babel-call-parser, org-element-clock-parser,
  org-element-comment-parser, org-element-comment-block-parser,
  org-element-example-block-parser, org-element-export-block-parser,
  org-element-fixed-width-parser, org-element-horizontal-rule-parser,
  org-element-keyword-parser, org-element-latex-environment-parser,
  org-element-paragraph-parser, org-element-planning-parser,
  org-element-property-drawer-parser, org-element-src-block-parser,
  org-element-table-parser,
  org-element-verse-block-parserorg-element-dynamic-block-parser):
  Make sure element never ends at the end of a blank non-empty line.
* testing/lisp/test-org-element.el: Add test.
2012-10-06 01:02:03 +02:00
Nicolas Goaziou 78d2bd7edc Merge branch 'maint' 2012-10-05 15:08:58 +02:00
Nicolas Goaziou daf8cf030c org-element: Fix `org-element-context' when in recursive objects
* lisp/org-element.el (org-element-context,
  org-element--get-next-object-candidates): Fix `org-element-context'.
  In particular, the restrictions for an object may be different from
  those of its container (i.e. table rows and table cells).
* testing/lisp/test-org-element.el: Add tests.
2012-10-05 15:02:55 +02:00
Bastien Guerry 4f0b3bfe0c Merge branch 'maint' 2012-10-02 13:07:09 +02:00
Bastien Guerry e4c31cf98b Use generated-autoload-file: "org-loaddefs.el" as a local variable. 2012-10-02 08:50:46 +02:00
Nicolas Goaziou 2a95a47c5f Merge branch 'maint' 2012-10-01 21:37:48 +02:00
Nicolas Goaziou 3bd22fb045 org-element: Store value of example-blocks and src-blocks unescaped
* lisp/org-element.el (org-element-example-block-parser,
  org-element-src-block-parser): Store value of example-blocks and
  src-blocks unescaped.
(org-element-example-block-interpreter,
org-element-src-block-interpreter): Escape value again when storing
it.
* contrib/lisp/org-export.el (org-export-unravel-code): Don't clean
  commas from code since org-element already took care of it.
* testing/lisp/test-org-export.el: Update test.
* testing/lisp/test-org-element.el: Add tests.
2012-10-01 21:35:50 +02:00
Nicolas Goaziou 934208ece1 org-element: Allow links in captions
* lisp/org-element.el (org-element-object-restrictions): Allow links
  in caption. Also allow inline-src-blocks and inline-babel-calls.
* contrib/lisp/org-e-ascii.el (org-e-ascii--unique-links): Handle
  links in captions.
(org-e-ascii--describe-links): Small refactoring.
(org-e-ascii-template--document-title): Handle links in document
properties.
2012-09-30 23:57:45 +02:00
Nicolas Goaziou 3245619445 org-element: Allow to map over affiliated keywords
* lisp/org-element.el (org-element-map): Change signature.
* testing/lisp/test-org-element.el: Add test.
2012-09-30 23:57:45 +02:00
Nicolas Goaziou e74523905b org-element: Distinguish parsed affiliated keywords from document properties
* lisp/org-element.el (org-element-parsed-keywords): Remove document
  properties from the value.
(org-element-dual-keywords): Fix docstring.
(org-element-document-properties): New variable
* contrib/lisp/org-export.el (org-export--get-subtree-options,
  org-export--get-inbuffer-options, org-export--get-global-options):
  Use new variable instead of parsed keywords.
2012-09-30 23:57:45 +02:00
Nicolas Goaziou 9f7fd9d2bb Merge branch 'maint' 2012-09-30 13:38:07 +02:00
Nicolas Goaziou 52df4aba9b org-element: Fix 1ad58a8230
* lisp/org-element.el (org-element-paragraph-parser): Fix regexp
  starting a block.
2012-09-30 13:36:44 +02:00
Nicolas Goaziou d6fb245590 Merge branch 'maint' 2012-09-30 13:13:21 +02:00
Nicolas Goaziou 1ad58a8230 org-element: Use stricter regexps for boundaries of elements
* lisp/org-element.el (org-element-center-block-parser):
(org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-latex-environment-parser, org-element-paragraph-parser,
org-element-property-drawer-parser, org-element-src-block-parser,
org-element-verse-block-parser): Use stricter regexps for boundaries
of elements.
* testing/lisp/test-org.el: Fix a test.
2012-09-30 13:09:54 +02:00
Bastien Guerry 4962980938 Merge branch 'maint' 2012-09-29 11:10:18 +02:00
Nicolas Goaziou d88344d291 org-element: Properly remove COMMENT and QUOTE keywords from title in parser
* lisp/org-element.el: Properly remove COMMENT and QUOTE keywords from
  title in parser.
* testing/lisp/test-org-element.el: Add tests.
2012-09-29 10:15:59 +02:00
Bastien Guerry 33ab30ca2a Merge branch 'maint' 2012-09-29 09:39:22 +02:00
Nicolas Goaziou 9c92312d92 org-element: Fix parsing for headlines with only a COMMENT or QUOTE keyword
* lisp/org-element.el (org-element-headline-parser): Fix parsing for
  headlines with a single COMMENT or QUOTE keyword.
* testing/lisp/test-org-element.el: Add tests.
2012-09-29 08:54:46 +02:00
Bastien Guerry bf072bd647 Merge branch 'maint' 2012-09-24 19:15:59 +02:00
Bastien Guerry 9aff6ffe8a Add COPYING and fix other related issues.
Mention COPYING in READMEs.
Fix the header of ob-fortran.el (see this fix in Emacs trunk:
http://lists.gnu.org/archive/html/emacs-diffs/2012-09/msg00365.html)
Specify that org-colview-xemacs.el is *not* part of Emacs.
Specify that org-element.el is part of Emacs (prepare the sync.)
Add COPYING in the release (mk/server.mk).
2012-09-24 19:15:42 +02:00
Nicolas Goaziou b60445cfd4 org-element: Define a new element: node-property
* lisp/org-element.el (org-element-all-elements): Add `node-property'
  as a new element type.
(org-element-greater-elements): Add property-drawer element to greater
  elements since they now contain node-property elements.
(org-element-drawer-parser): Small refactoring.
(org-element-property-drawer-parser): Move into Greater Elements file
section.
(org-element-node-property-parser,
org-element-node-property-interpreter): New functions.
(org-element--current-element, org-element-at-point,
org-element--parse-elements): Handle new element type.
* testing/lisp/test-org-element.el: Add tests.
2012-09-23 19:10:27 +02:00
Nicolas Goaziou 393acf0df8 org-element: Fix for affiliated keywords parsing
* lisp/org-element.el (org-element--collect-affiliated-keywords): Fix
  return value.
* testing/lisp/test-org-element.el: Add test.
2012-09-23 09:49:32 +02:00
Nicolas Goaziou baed7dc7db org-element: Optimize affiliated keywords parsing
* 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-plain-list-parser, org-element-quote-block-parser,
  org-element-special-block-parser, org-element-babel-call-parser,
  org-element-comment-parser, org-element-comment-block-parser,
  org-element-example-block-parser, org-element-export-block-parser,
  org-element-fixed-width-parser, org-element-horizontal-rule-parser,
  org-element-keyword-parser, org-element-latex-environment-parser,
  org-element-paragraph-parser, org-element-property-drawer-parser,
  org-element-src-block-parser, org-element-table-parser,
  org-element-verse-block-parser): Change signature. Now use an
  additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
  as an argument to parsers.  It prevents to walk through these
  keywords twice: the first time to get to the first line of the
  element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
  since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 20:08:16 +02:00
Nicolas Goaziou 7c40e0c6ba Merge branch 'maint' 2012-09-20 19:14:43 +02:00
Nicolas Goaziou fd5cc62ca5 org-element: Fix inline-src-block parsing at the beginning of an item
* lisp/org-element.el (org-element-inline-src-block-successor): Fix
  inline-src-block parsing at the beginning of an item.
* testing/lisp/test-org-element.el: Add test.
2012-09-20 19:13:40 +02:00
Nicolas Goaziou fe140488aa org-element: Allow multiple caption keywords
* lisp/org-element.el (org-element-multiple-keywords): Allow multiple
  caption keywords.
* contrib/lisp/org-export.el (org-export-get-caption): New function.
* testing/lisp/test-org-element.el: Add tests.
* testing/lisp/test-org-export.el: Add tests.
2012-09-13 17:33:46 +02:00
Nicolas Goaziou 0b13ec8c1b Merge branch 'maint' 2012-09-13 13:17:17 +02:00
Nicolas Goaziou 4a7c99134c org-element: Fix caption parsing
* lisp/org-element.el (org-element--collect-affiliated-keywords): Fix
  caption parsing.
* testing/lisp/test-org-element.el: Add tests.
2012-09-13 13:15:39 +02:00
Bastien Guerry aac2e8b93f Merge branch 'maint' 2012-09-12 15:50:25 +02:00
Nicolas Goaziou f969e24a43 org-element: Fix parsing for items/footnote definitions starting with special syntax
* lisp/org-element.el (org-element--current-element): At the very
  beginning of a footnote definition or an item, next element is
  always a paragraph.
* testing/lisp/test-org-element.el: Add tests.

This patch fixes parsing for following cases:

 - - text

or

[fn:1] # Some text
2012-09-12 15:45:10 +02:00
Nicolas Goaziou 8e44533339 Merge branch 'maint' 2012-09-09 14:14:54 +02:00
Nicolas Goaziou f29131c3d2 org-element: Handle nil titles in headlines
* lisp/org-element.el (org-element-headline-parser): Handle nil
  titles.
(org-element-inlinetask-parser): Add :raw-value property.  Also handle
nil titles.
2012-09-09 14:13:24 +02:00
Nicolas Goaziou 90aae1e2e8 Merge branch 'maint' 2012-09-01 22:57:19 +02:00
Nicolas Goaziou 8d09d1aaa9 org-element: Fix section parsing
* lisp/org-element.el (org-element-section-parser): Make sure section
  cannot contain an headline.
(org-element--current-element): Fix bug requiring to parse a quote
section even when point is at an headline.
* testing/lisp/test-org-element.el: Add test.
2012-09-01 22:55:31 +02:00
Nicolas Goaziou 3a6a5c458f org-element: Remove `macro' from recursive object types
* lisp/org-element.el (org-element-recursive-objects,
  org-element-object-restrictions): Remove `macro' from recursive
  object types.
2012-09-01 13:04:59 +02:00
Bastien Guerry e72acc0e1f Merge branch 'maint' 2012-08-30 10:25:58 +02:00
Mats Lidell 8e88bc0e0b org-element.el: Remove illegal t clause in case
* lisp/org-element.el (org-element-paragraph-separate): Remove
redundant and misplaced t clause in case.

TINYCHANGE
2012-08-30 10:25:44 +02:00
Nicolas Goaziou ab075316b0 Merge branch 'maint' 2012-08-25 23:46:18 +02:00
Nicolas Goaziou 11082518ee org-element: Tiny refactoring
* lisp/org-element.el (org-element-paragraph-parser): Tiny refactoring.
2012-08-25 23:45:14 +02:00
Nicolas Goaziou 967f20c9a9 Merge branch 'maint' 2012-08-25 23:31:10 +02:00
Nicolas Goaziou 3113c5fce9 org-element: Small code comment clean-up
* lisp/org-element.el (org-element-paragraph-parser): Remove trailing
  code comments.
2012-08-25 23:30:29 +02:00
Nicolas Goaziou 1f3d1f55fe Merge branch 'maint' 2012-08-25 15:28:40 +02:00
Nicolas Goaziou b4604d2833 org-element: Fix filling bug in a list with affiliated keyword
* lisp/org-element.el (org-element-paragraph-parser): Fix parsing of
   paragraph at the beginning of an item.
* testing/lisp/test-org-element.el: Add test.
2012-08-25 15:27:01 +02:00
Nicolas Goaziou d86f09a854 org-element: Extract search option and application in "file"-type links
* lisp/org-element.el (org-element-link-type-is-file): New variable.
(org-element-link-parser): Extract search option and application in
"file"-type links.
* contrib/lisp/org-e-html.el (org-e-html-link): Remove components
  extraction since this in now done in `org-element-link-parser'.
* contrib/lisp/org-e-odt.el: Remove components extraction since this
  in now done in `org-element-link-parser'.
* contrib/lisp/org-e-texinfo.el (org-e-texinfo-link): Remove
  components extraction since this in now done in
  `org-element-link-parser'.
* contrib/lisp/org-e-latex.el (org-e-latex-link): Remove components
  extraction since this in now done in `org-element-link-parser'.
* contrib/lisp/org-e-man.el (org-e-man-link): Remove components
  extraction since this in now done in `org-element-link-parser'.
* contrib/lisp/org-e-groff.el (org-e-groff-link): Remove components
  extraction since this in now done in `org-element-link-parser'.
* contrib/lisp/org-md.el (org-md-link): Remove components extraction
  since this in now done in `org-element-link-parser'.
* testing/lisp/test-org-element.el: Add tests.
2012-08-25 10:38:25 +02:00