Commit Graph

282 Commits

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