* lisp/org-element.el (org-element-context): Fix 'search failed ":"'
error when point is on a blank line after a keyword.
* testing/lisp/test-org-element.el (test-org-element/context): Add
tests.
* lisp/org-element.el (org-element-paragraph-separate,
org-element--object-regexp): Turn defconst into defvar.
(org-element--set-regexps): Properly set previous variables.
(org-element-update-syntax): New function.
* lisp/org-list.el (org-plain-list-ordered-item-terminator,
org-list-allow-alphabetical): Call new function whenever these
variables are modified and Org is already loaded.
* lisp/org.el (org-add-link-type): Call new function since a new link
type triggers a rebuild of syntax regexps, possibly invalidating
cache in all Org buffers.
Reported-by: Christopher Dannheim <ch.dannheim@gmail.com>
<http://permalink.gmane.org/gmane.emacs.orgmode/92487>
* lisp/org-element.el (org-element--get-node-properties,
org-element--get-time-properties): New functions.
(org-element-headline-parser, org-element-inlinetask-parser): Use new
functions.
(org-element-property-drawer-parser): Change signature. Simplify
parsing.
drawer.
(org-element--current-element, org-element--next-mode): Property
drawers are located right after a headline or a planning element.
* testing/lisp/test-org-element.el (test-org-element/drawer-parser,
test-org-element/node-property,
test-org-element/property-drawer-interpreter): Update tests.
(test-org-element/property-drawer-parser): Add tests.
* testing/lisp/test-org.el (test-org/indent-line,
test-org/indent-region, test-org/forward-paragraph,
test-org/backward-paragraph): Update tests.
* lisp/org-element.el (org-element--cache-for-removal): Do not
consider property drawers as robusts: if contents are modified,
remove the whole drawer from cache.
* lisp/org-element.el (org-element--current-element): Only look after
planning lines right after parsing a section.
(org-element--next-mode): New function.
(org-element--parse-elements, org-element--parse-to): Use new
function.
* lisp/org.el (org-planning-line-re): New variable. Renamed from
`org-planning-or-clock-line-re'.
* lisp/org-element.el (org-element-paragraph-separate,
org-element-headline-parser, org-element-inlinetask-parser, ,
org-element--current-element): Use new variable.
(org-element-planning-parser): Check previous line before parsing
planning info. When right after a headline, fallback to paragraph
parsing.
* testing/lisp/test-org-element.el (test-org-element/planning-parser):
Add a test. Update others.
(test-org-element/timestamp): Remove a test.
* testing/lisp/test-ox.el (test-org-export/handle-options): Update
test.
* lisp/org-element.el (org-element-property-drawer-parser,
org-element-node-property-parser): Ignore lines that are not node
properties.
(org-element-node-property-interpreter): Allow nil properties.
* lisp/org.el (org-re-property): Fix regexp to match properties with
empty values.
* testing/lisp/test-org-element.el (test-org-element/node-property):
Add tests.
Thanks to Eike for reporting it.
http://permalink.gmane.org/gmane.emacs.orgmode/90293
* lisp/org-element.el (org-element-headline-interpreter): Take into
consideration `org-odd-levels-only' value. Small refactoring.
* testing/lisp/test-org-element.el (test-org-element/headline-interpreter):
Add test.
* lisp/org-element.el (org-element-headline-parser,
org-element-inlinetask-parser, org-element-item-parser,
org-element-section-parser, org-element-clock-parser,
org-element-node-property-parser, org-element-planning-parser,
org-element-table-row-parser): Add dummy :post-affiliated property.
* lisp/org.el (org--get-expected-indentation, org-indent-line,
org-indent-region, org-adaptive-fill-function,
org-toggle-fixed-width, org-forward-paragraph,
org-backward-paragraph, org-mode-flyspell-verify): Remove nullity
checks for :post-affiliated.
Even though these elements cannot have affiliated keywords, beginning
of element is a logical default value. It makes checking the nullity
of the unnecessary.
* lisp/org-element.el (org-element-normalize-contents): Fix
indentation removal when there is an empty line within a verse block.
* testing/lisp/test-org-element.el (test-org-element/normalize-contents):
Add test.
* lisp/org-element.el (org-element-comment-block-interpreter,
org-element-example-block-interpreter,
org-element-src-block-interpreter): Handle values with missing final
newline, e.g., when built by the user.
* testing/lisp/test-org-element.el (test-org-element/comment-block-interpreter,
test-org-element/example-block-interpreter,
test-org-element/src-block-interpreter): Add tests
Thanks to Thorsten Jolitz for suggesting the idea.
http://permalink.gmane.org/gmane.emacs.orgmode/89602
* lisp/org-element.el (org-element-all-elements): Remove
`export-block' type.
(org-element-block-name-alist): Make it a defconst since it is not
meant to be changed anymore.
(org-element-export-block-parser,
org-element-export-block-interpreter): Remove functions.
* lisp/ox.el (org-export-filters-alist): Remove export block filter.
(org-export-register-backend): Do not alter
`org-export-block-name-alist' anymore.
(org-export-define-backend, org-export-define-derived-backend): Update
docstring.
(org-export-filter-export-block-functions): Remove variable.
* testing/lisp/test-org-element.el (test-org-element/export-block-parser,
test-org-element/export-block-interpreter): Remove tests.
* testing/lisp/test-ox.el (test-org-export/define-backend): Update test.
* lisp/org-element.el (org-element-parse-secondary-string): Clone all
local variables from current buffer before parsing a secondary
string. Small refactoring.
(org-element-object-variables): Remove variable.
* testing/lisp/test-org-element.el (test-org-element/secondary-string-parsing):
Add test.
Thanks to Thomas S. Dye for reporting it.
http://permalink.gmane.org/gmane.emacs.orgmode/88850
* org-element.el (org-element--latex-begin-environment,
org-element--latex-end-environment): New format strings to identify
beginning and ending of LaTeX environments.
(org-element-latex-environment-parser, org-element-paragraph-parser,
org-element--current-element): Use `org-element--latex-begin-environment'
and `org-element--latex-end-environment'.
* test-org-element.el (test-org-element/latex-environment-parser):
Add tests.
* lisp/org-element.el (org-element--cache-for-removal): Do not remove
a robust element whenever only its contents are modified. Remove
inlinetasks as robust elements since modifying a node property inside
implies to parse the task again.
* 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
* 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.
* 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.
* 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
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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).
* 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.
* 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
* 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
* 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).
* 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.
* 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).
* 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.
* 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.
* 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.
* 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
* 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
* 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.
* 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.
* 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.
* 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.
* 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.
* 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
* 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
* 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.
* 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
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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")
* 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.
* 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.
* 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.
* 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.
* 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)
* 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.
* 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.
* lisp/org-element.el (org-element--current-element): Add a limit
argument.
(org-element--collect-affiliated-keywords): Fix parsing of orphaned
keyword at the end of an element.
* testing/lisp/test-org-element.el: Add test.
* lisp/org-element.el (org-element-macro-parser): Fix error when last
argument ends with a protected comma.
* testing/lisp/test-org-element.el (test-org-element/macro-parser):
Add tests.
* lisp/org-element.el (org-element-parse-buffer, org-element-map,
org-element-at-point, org-element-context): Be more verbose in
docstrings. Also fix typos.
* lisp/org-element.el (org-element-at-point): When point is before any
element, in the first blank lines of the buffer, return nil. When
point is within blank lines just after a headline, return that
headline.
(org-element-context): Return nil when point is within the blank at
the beginning of the buffer.
* testing/lisp/test-org-element.el: Add tests.
* lisp/org-element.el (org-element-context): Add an optional argument
so (org-element-context)
and (org-element-context (org-element-at-point)) are equivalent.
* testing/lisp/test-org-element.el: Add test.
* lisp/org-element.el (org-element-object-variables): New variable.
(org-element-parse-secondary-string): Copy some buffer-local variables
to the temporary buffer created to parse the string so links can still
be properly expanded.
(org-element-link-parser): Link expansion and translation are applied
transparently for the parser.
* lisp/org-element.el (org-element--parse-elements,
org-element-at-point): Fix parsing of a list in a block in a list.
* testing/lisp/test-org-element.el: Add test.
* lisp/org-element.el (org-element-line-break-parser): Line break
includes the newline character following the backslashes.
(org-element-line-break-interpreter): Apply changes to line break
parsing.
* lisp/org-element.el (org-element-timestamp-interpreter): Fix
timestamp interpreter when raw value isn't available.
* testing/lisp/test-org-element.el: Update test.
* lisp/org-element.el (org-element-context): When point is between two
objects, be sure to return the second one.
* testing/lisp/test-org-element.el: Add test.
* lisp/org-element.el (org-element-timestamp-parser): Timestamp with
time range has active/inactive-range type.
* testing/lisp/test-org-element.el: Add test.
In order to know if starting date/time is really the same as ending
date/time, this patch permits to use the following:
(memq (org-element-property :type timestamp) '(active inactive))
* lisp/org-element.el (org-element-headline-parser,
org-element-inlinetask-parser): Remove :clockedp property.
This property isn't even remotely related to the structure of the
document and, as such, doesn't belong to Org element.
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
* lisp/org-element.el (org-element--collect-affiliated-keywords):
Allow duals keywords with only secondary value.
* testing/lisp/test-org-element.el: Add test.
This patch allows to parse correctly the following:
#+CAPTION[short caption]:
#+CAPTION: Very long caption
Some paragraph.
* lisp/org-element.el (org-element-timestamp-parser): Modify timestamp
objects properties.
(org-element-headline-parser, org-element-inlinetask-parser): Remove
`:timestamp' and `:clock' property. Add `:clockedp' property. Also,
set `:closed', `:deadline' and `:scheduled' values to timestamp
objects, not strings. Small refactoring.
(org-element-clock-parser): Rename `:time' property into `:duration'.
Also, set `:value' value as a timestamp object, not a string.
(org-element-planning-parser): Set `:closed', `:deadline' and
`:scheduled' values to timestamp objects, not strings.
(org-element-clock-interpreter, org-element-planning-interpreter)
(org-element-timestamp-interpreter): Update interpreters.
(org-element--current-element): Tiny refactoring.
* testing/lisp/test-org-element.el: Add tests.
* lisp/org-element.el (org-element-paragraph-separate): Diary-sexp
elements can separate paragraphs.
(org-element-all-elements): Install new `diary-sexp' type.
(org-element--current-element): Recognize new `diary-sexp' elements.
(org-element-diary-sexp-parser, org-element-diary-sexp-interpreter):
New functions.
* testing/lisp/test-org-element.el: Add tests.
* lisp/org-element.el (org-element-property): Access to text
properties when argument is a string.
(org-element-put-property): Correctly set property when target is
a string.
(org-element-adopt-elements): Also put :parent properties on strings.
* testing/lisp/test-org-element.el: Add test.
* lisp/org-element.el (org-element--get-next-object-candidates): Fix
parsing of objects of the same type in a single paragraph.
* testing/lisp/test-org-element.el: Add tests.
* lisp/org-element.el (org-element-sub/superscript-successor): Fix
parsing of sub/superscript at beginning of item.
(org-element-latex-or-entity-successor): Fix parsing of latex
fragments at beginning of item.
* testing/lisp/test-org-element.el: Add test.
* lisp/org-element.el (org-element-context,
org-element--get-next-object-candidates): Fix `org-element-context'.
In particular, the restrictions for an object may be different from
those of its container (i.e. table rows and table cells).
* testing/lisp/test-org-element.el: Add tests.
* lisp/org-element.el (org-element-example-block-parser,
org-element-src-block-parser): Store value of example-blocks and
src-blocks unescaped.
(org-element-example-block-interpreter,
org-element-src-block-interpreter): Escape value again when storing
it.
* contrib/lisp/org-export.el (org-export-unravel-code): Don't clean
commas from code since org-element already took care of it.
* testing/lisp/test-org-export.el: Update test.
* testing/lisp/test-org-element.el: Add tests.
* lisp/org-element.el (org-element-object-restrictions): Allow links
in caption. Also allow inline-src-blocks and inline-babel-calls.
* contrib/lisp/org-e-ascii.el (org-e-ascii--unique-links): Handle
links in captions.
(org-e-ascii--describe-links): Small refactoring.
(org-e-ascii-template--document-title): Handle links in document
properties.
* lisp/org-element.el (org-element-parsed-keywords): Remove document
properties from the value.
(org-element-dual-keywords): Fix docstring.
(org-element-document-properties): New variable
* contrib/lisp/org-export.el (org-export--get-subtree-options,
org-export--get-inbuffer-options, org-export--get-global-options):
Use new variable instead of parsed keywords.
* lisp/org-element.el (org-element-headline-parser): Fix parsing for
headlines with a single COMMENT or QUOTE keyword.
* testing/lisp/test-org-element.el: Add tests.
Mention COPYING in READMEs.
Fix the header of ob-fortran.el (see this fix in Emacs trunk:
http://lists.gnu.org/archive/html/emacs-diffs/2012-09/msg00365.html)
Specify that org-colview-xemacs.el is *not* part of Emacs.
Specify that org-element.el is part of Emacs (prepare the sync.)
Add COPYING in the release (mk/server.mk).
* lisp/org-element.el (org-element-all-elements): Add `node-property'
as a new element type.
(org-element-greater-elements): Add property-drawer element to greater
elements since they now contain node-property elements.
(org-element-drawer-parser): Small refactoring.
(org-element-property-drawer-parser): Move into Greater Elements file
section.
(org-element-node-property-parser,
org-element-node-property-interpreter): New functions.
(org-element--current-element, org-element-at-point,
org-element--parse-elements): Handle new element type.
* testing/lisp/test-org-element.el: Add tests.
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
* lisp/org-element.el (org-element-inline-src-block-successor): Fix
inline-src-block parsing at the beginning of an item.
* testing/lisp/test-org-element.el: Add test.
* lisp/org-element.el (org-element--current-element): At the very
beginning of a footnote definition or an item, next element is
always a paragraph.
* testing/lisp/test-org-element.el: Add tests.
This patch fixes parsing for following cases:
- - text
or
[fn:1] # Some text
* lisp/org-element.el (org-element-section-parser): Make sure section
cannot contain an headline.
(org-element--current-element): Fix bug requiring to parse a quote
section even when point is at an headline.
* testing/lisp/test-org-element.el: Add test.
* lisp/org-element.el (org-element-paragraph-parser): Fix parsing of
paragraph at the beginning of an item.
* testing/lisp/test-org-element.el: Add test.
* lisp/org-element.el (org-element-link-type-is-file): New variable.
(org-element-link-parser): Extract search option and application in
"file"-type links.
* contrib/lisp/org-e-html.el (org-e-html-link): Remove components
extraction since this in now done in `org-element-link-parser'.
* contrib/lisp/org-e-odt.el: Remove components extraction since this
in now done in `org-element-link-parser'.
* contrib/lisp/org-e-texinfo.el (org-e-texinfo-link): Remove
components extraction since this in now done in
`org-element-link-parser'.
* contrib/lisp/org-e-latex.el (org-e-latex-link): Remove components
extraction since this in now done in `org-element-link-parser'.
* contrib/lisp/org-e-man.el (org-e-man-link): Remove components
extraction since this in now done in `org-element-link-parser'.
* contrib/lisp/org-e-groff.el (org-e-groff-link): Remove components
extraction since this in now done in `org-element-link-parser'.
* contrib/lisp/org-md.el (org-md-link): Remove components extraction
since this in now done in `org-element-link-parser'.
* testing/lisp/test-org-element.el: Add tests.
* lisp/org-element.el (org-element-paragraph-separate): Since this
variable is meant to be searched forward, \end{...} shouldn't
trigger the end of a paragraph before checking if it is the end of
a complete environment.
(org-element-latex-environment-parser): Slight change to the regexp
matching the beginning of a latex environment.
(org-element-paragraph-parser): Paragraphs don't end at incomplete
latex environments.
(org-element-latex-or-entity-successor): Remove paragraph environments
from latex fragment search.
* lisp/org-element.el (org-element-item-parser): Do not remove tag
from body if list isn't descriptive.
* lisp/org-list.el (org-insert-item): Only ask about a term for
descriptive lists.
(org-list-struct, org-list-insert-item): Do not recognize a tag in an
ordered list.
* testing/lisp/test-org-element.el: Add test.
* lisp/org.el (org-fill-paragraph): No need to use
`org-element-paragraph-separate' in a verse block since blank lines
only can end a "paragraph".
* lisp/org-element.el (org-element-paragraph-separate): Apply changes
to comments.
(org-element-paragraph-parser): Correctly find end of paragraphs.
(org-element--current-element): Require colons for Babel calls.
(org-element-center-block-parser, org-element-dynamic-block-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-comment-block-parser, org-element-example-block-parser,
org-element-export-block-parser, org-element-src-block-parser,
org-element-verse-block-parser): Fall-back to paragraph parsing when
incomplete or ill-formed.
* testing/lisp/test-org-element.el: Update tests.
* lisp/org-element.el (org-element-at-point): Return consistent value
when function is called on a blank line within a plain list.
* testing/lisp/test-org-element.el: Add test.
* org.el (org-forward-element): Rename from
`org-element-forward'.
(org-backward-element): Rename from `org-element-backward'.
(org-up-element): Rename from `org-element-up'.
(org-down-element): Rename from `org-element-down'.
(org-drag-element-backward): Rename from
`org-element-drag-backward'.
(org-drag-element-forward): Rename from
`org-element-drag-forward'.
(org-mark-element): Rename from `org-element-mark-element'.
(org-transpose-element): Rename from `org-element-transpose'.
(org-unindent-buffer): Rename from
`org-element-unindent-buffer'.
(org-mode-map): Update the names of a commands.
Remove useless declarations.
* org-element.el (org-element-forward, org-element-backward)
(org-element-up, org-element-down)
(org-element-drag-backward, org-element-drag-forward)
(org-element-mark-element, org-narrow-to-element)
(org-element-transpose, org-element-unindent-buffer): Move to
org.el.
* lisp/org-element.el (org-element-item-parser,
org-element-plain-list-parser): Make sure that the element ends at
the beginning of a line if possible.
(org-element-at-point): Return expected element when point is at an
element's end or at its contents' end.
* testing/lisp/test-org-element.el: Add test.
* testing/lisp/test-org.el: Add test.
* org.el (org-mode-map): Use `M-h' for
`org-element-mark-element'.
(org-mark-subtree): Allow a numeric prefix argument to move up
into the hierarchy of headlines.
* org-element.el (org-element-up, org-element-down): Autoload.
* lisp/org-element.el (org-element-item-interpreter): Simplify bullet
creation.
(org-element-plain-list-interpreter): Fix wrong bullets, if needed.
This change allows to intrepret plain lists without providing list's
structure, which can be a bit hairy. For example, the following
snippet now suffices to create a list programmatically:
(org-element-interpret-data
'(plain-list nil
(item (:bullet "-") (paragraph nil "a"))
(item (:bullet "-") (paragraph nil "b"))))
* org.el: Update a few keybindings.
Use [(control down)] and "\M-}" for `org-element-forward'.
Use [(control up)] and "\M-{ `org-element-backward'.
Use "\C-c\C-^" for `org-element-up'.
Use "\C-c\C-_" for `org-element-down'.
Use "\C-c\C-@" for `org-element-mark-element'.
* org-element.el (org-element-down): Throw an error when the
element has no content.
* lisp/org-element.el (org-element-at-point): Add :parent property to
output.
(org-element-context): Add :parent property to output. Also return
a single element or object instead of a list of parents.
(org-element-forward, org-element-up): Apply changes.
* testing/lisp/test-org-element.el: Add tests.
* lisp/org-element.el (org-element-at-point): Fix function when buffer
starts with an inlinetask. Also fix it when called on the last
element in a greater element or the buffer.
* org.el (org-mode-map): Add keybindings to
`org-element-transpose' and `org-narrow-to-element'.
(org-metaup): Fall back on `org-element-drag-backward'.
(org-metadown): Fall back on `org-element-drag-forward'.
Also move chunks of declarations and require statements to
get rid of compiler warnings.
* org-exp-blocks.el (org): Don't require org. Add declarations.
* org-clock.el (org): Don't require org.
* ob-exp.el (org-list-forbidden-blocks): Add declarations.