Commit Graph

299 Commits

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