Commit Graph

379 Commits

Author SHA1 Message Date
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