1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-12-02 08:22:16 +00:00
Commit Graph

338 Commits

Author SHA1 Message Date
Nicolas Goaziou
3c14db8685 org-element: Fix infloop in cache
* lisp/org-element.el (org-element--cache-process-request): Take into
  consideration changes to come so as to avoid parsing elements with
  false beginning positions.
(org-element--cache-sync): Change signature.

Thanks to Thorsten Jolitz for reporting it.
http://permalink.gmane.org/gmane.emacs.orgmode/88673
2014-07-20 19:09:52 +02:00
Nicolas Goaziou
7bd8fafe7a org-element: Better collision handling in cache sync requests
* lisp/org-element.el (org-element--cache-process-request): Handle
  cases where procesing the first request brings us past the start of
  the next one.
2014-07-20 19:08:58 +02:00
Nicolas Goaziou
05be573e92 org-element: Fix re-parenting during cache synchronization
* lisp/org-element.el (org-element--cache-process-request): Correctly
  re-parent elements in cache in some corner cases.
* testing/lisp/test-org-element.el (test-org-element/cache): Add tests.
2014-07-17 18:12:59 +02:00
Nicolas Goaziou
33a344be33 org-element: Fix corner case in cache synchronization
* lisp/org-element.el (org-element--cache-submit-request): When
  changes happen before first know element, start from phase 1 instead
  of phase 2 in order to properly re-parent subsequent elements, if
  needed.
(org-element--cache-process-request): Do not propagate beginning
position since it is already available to the request.
2014-07-17 18:12:49 +02:00
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