Commit graph

24 commits

Author SHA1 Message Date
Ihor Radchenko e81a094383
Assert all the Org files to load the same Org version
* lisp/org-compat.el (org-assert-version): New macro comparing Org
version at compile time and laod time.

Add `org-assert-version' call to all files:

* lisp/org-macs.el:
* lisp/org-crypt.el:
* lisp/org-ctags.el:
* lisp/org-cycle.el:
* lisp/org-datetree.el:
* lisp/org-duration.el:
* lisp/org-element.el (avl-tree):
* lisp/org-entities.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-fold-core.el:
* lisp/org-fold.el:
* lisp/org-footnote.el:
* lisp/org-goto.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-keys.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-macro.el:
* lisp/org-mobile.el:
* lisp/org-mouse.el:
* lisp/org-num.el:
* lisp/org-pcomplete.el:
* lisp/org-persist.el:
* lisp/org-plot.el:
* lisp/org-protocol.el:
* lisp/org-refile.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-tempo.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-beamer.el:
* lisp/ox-html.el:
* lisp/ox-icalendar.el:
* lisp/ox-koma-letter.el:
* lisp/ox-latex.el:
* lisp/ox-man.el:
* lisp/ox-md.el:
* lisp/ox-odt.el:
* lisp/ox-org.el:
* lisp/ox-publish.el:
* lisp/ox-texinfo.el:
* lisp/ox.el:
2022-09-04 12:24:55 +08:00
Ihor Radchenko dd0a723603
org-fold-core: Do not override default fontification
* lisp/org-fold-core.el: Remove the code overriding
`font-lock-default-fontify-region'.  Emacs itself is skipping
fontification of invisible text and doing it more efficiently.  The
org-fold fontification overrides are redundant, except when some
poorly written third-party code is forcing fontification inside folded
regions.  However, Org does not need to entertain poorly written third
party code, especially when the required supporting code is reducing
font-lock performance and is complicating the maintenance.
(org-fold-core--specs):
(org-fold-core-add-folding-spec): Remove `:font-lock-skip' spec.
(org-fold-core-initialize):
(org-fold-core--fontifying):
(org-fold-core-region):
(org-fold-core--force-fontification):
(org-fold-core-fontify-region): Remove custom fontification.
* lisp/org-fold.el (org-fold-initialize): Remove `:font-lock-skip'
spec.
* lisp/org-macs.el (org-fold-core--force-fontification):
(org-with-forced-fontification):
(org-buffer-substring-fontified):
(org-looking-at-fontified): Remove org-fold's font-lock logic.
2022-08-23 12:01:34 +08:00
Ihor Radchenko 6cd7c6fb1c
org-fold-core: Improve integration with isearch API
* lisp/org-fold-core.el (org-fold-core--isearch-show):
(org-fold-core--isearch-show-temporary): Allow REGION argument to be
overlay.

Fixes https://orgmode.org/list/62f834ed.050a0220.afd79.0022SMTPIN_ADDED_BROKEN@mx.google.com
2022-08-14 08:38:55 +08:00
Ihor Radchenko 15658b8665
org-fold-core: New API to fold/restore buffer folding state
* lisp/org-fold-core.el (org-fold-core-get-regions): New function to
retrieve the list of folded regions in buffer.
(org-fold-core-regions): New function to set folding state in buffer
according to the list returned by `org-fold-core-get-regions'.
(org-fold-core-save-visibility): New macro, equivalent to
`org-fold-save-outline-visibility'.
2022-08-13 14:59:01 +08:00
Ihor Radchenko 687d5702d2
org-fold-core-next-folding-state-change: Fix when using overlays
* lisp/org-fold-core.el (org-fold-core-next-folding-state-change):
Consider overlay properties.
2022-08-13 14:55:50 +08:00
Paul Eggert 6013cb161d Fix doc string quoting problems with '
The Emacs doc string convention is to document values as-is when that
is clear, and surrounded by `single quotes' otherwise. For example, a
doc string "(a b c)" stands for a list of symbols, and the doc string
"`a'" stands for a single symbol. The doc string "\\=`a" is typically
not correct for that single symbol, because that is equivalent to
"(quote a)" and the typical intent is to talk about the symbol, not
about the Lisp quoting construct.  One needs "\\=`X" only when talking
about something intended to be equivalent to "(quote X)", as in the
doc string "(provide \\='org-xyz)".
2022-07-25 13:10:29 -07:00
Ihor Radchenko 8e2fed82ed
org-fold: Make sure that changes do not leave partially folded headings
* lisp/org-fold-core.el (org-fold-core--fix-folded-region): Check
fragility in all the indirect buffers.
* lisp/org-fold.el (org-fold--reveal-headline-at-point): New function
revealing heading line or full heading when the heading only contains
blank lines.
(org-fold--reveal-outline-maybe): Check headline at the end of folded
region as well.  Use `org-fold-core--fix-folded-region'.
* lisp/org.el (org-insert-heading): Make sure that the newline in
front of heading is revealed.
2022-07-12 21:51:40 +08:00
Ihor Radchenko c66bdb0c9b
org-fold-core-style: Clarify "error-prone" in the docstring
* lisp/org-fold-core.el (org-fold-core-style): Explain that the new
folding with text properties can be problematic with third-party
packages, not with Org itself.

See https://orgmode.org/list/877d4jve13.fsf@gmail.com
2022-07-12 09:02:47 +08:00
Stefan Kangas 0ed0dea229
Delete some Emacs 24 compat code
Org mode supports Emacs 26 or newer:
https://orgmode.org/worg/org-maintenance.html#emacs-compatibility

* lisp/org-compat.el (org-set-transient-map)
(org-font-lock-ensure): Delete compat aliases.  Update callers.
(org-define-error): Redefine as obsolete function alias for
`define-error'.  Update callers.
(string-suffix-p): Delete compatibility definition.

* lisp/org-fold-core.el (org-fold-core--seq-partition): Delete private
function and update callers to use `seq-partition'.

* lisp/org-macs.el (org-without-partial-completion): Move from here...
* lisp/org-compat.el (org-without-partial-completion): ...to here.
Redefine as obsolete function alias for `progn'.
2022-07-02 12:10:00 +08:00
Stefan Kangas 41e19f1d7a
; Fix typos 2022-07-01 17:42:52 +08:00
Stefan Kangas 13d97ee18c
Prefer "website" to "homepage"
Emacs now advises using "website" (instead of "homepage") and
consequently to use the "URL" comment header instead of "Homepage".

* README:
* README_ELPA:
* doc/org-guide.org (Creating Footnotes):
* doc/org-manual.org (Creating Footnotes):
* etc/styles/README (URL): Prefer "website" to "homepage".

* lisp/*.el:
* mk/org-fixup.el: Replace the "Homepage" header comment with "URL".
2022-06-26 10:10:48 +08:00
Robert Pluim e9da29b6fa
Escape single left quotes in docstrings
* lisp/ob-core.el (org-babel-default-header-args):
* lisp/ob-julia.el (org-babel-julia-evaluate-external-process):
(org-babel-julia-evaluate-session):
* lisp/ob-lua.el (org-babel-lua-read-string):
* lisp/ob-table.el (org-sbe):
* lisp/oc-basic.el (org-cite-basic--shorten-names):
* lisp/org-agenda.el (org-agenda-sorting-strategy):
(org-agenda--mark-blocked-entry):
(org-agenda-set-restriction-lock):
* lisp/org-fold-core.el (org-fold-core--specs):
(org-fold-core-remove-folding-spec):
(org-fold-core-get-folding-spec):
(org-fold-core--isearch-overlays):
* lisp/org-plot.el (org--plot/prime-factors):
* lisp/org-table.el (org-table-collapse-header):
* lisp/org.el (org-special-ctrl-o):
(org-latex-to-html-convert-command):
* lisp/ox-html.el (org-html--unlabel-latex-environment):
* lisp/ox-publish.el (org-publish-find-property):
Use \\=' when there's a need for a single left quote in a docstring.

The emacs-29 byte compiler complains about such usage.
2022-06-16 20:51:02 +08:00
Robert Pluim 3baac35b55 Don't quote symbols in defcustom types
* lisp/org-fold-core.el (org-fold-core-style):
* lisp/org-persist.el (org-persist-remote-files):
(org-persist-default-expiry):
Don't quote the symbol given as value for a const.
2022-06-14 16:05:17 +03:00
Ihor Radchenko d6bae908f3
Fix macro indentation and re-indent code misindented by nameless
* lisp/org-fold-core.el (org-fold-core-cycle-over-indirect-buffers):
(org-fold-core-ignore-modifications):
(org-fold-core-ignore-fragility-checks):
* lisp/org-macs.el (org-element-with-disabled-cache): Fix incorrect
indentation declare statement.  Body-only macros should use (indent 0)
to avoid indenting first line differently from other body.
* lisp/org-capture.el:
* lisp/org-clock.el:
* lisp/org-fold-core.el:
* lisp/org-fold.el:
* lisp/org-id.el:
* lisp/org-list.el:
* lisp/org-macs.el:
* lisp/org.el: Reindent.

Reported in https://orgmode.org/list/CAKJdtO_Z4LBGek3SUc6-a_Z0-dDd6L26_YfMYpZTn7F92uxXJQ@mail.gmail.com
2022-05-14 16:58:35 +08:00
Ihor Radchenko d5a52be0a5
org-fold-core: Remove `org-fold-core-first-unfold-functions'
* lisp/org-fold-core.el (org-fold-core-first-unfold-functions):
Remove.  This is very too tricky to implement.  In particular, when we
use jit-lock, there can be a race between calls to
`org-fold-core-region' and fontification.  For example, consider that
one of the functions in the hook folds drawers and everything is
folded initially.  Then, if the user requests unfolding headlines,
drawers, and blocks, it happens before jit-lock is ran in invisible
parts of buffer (out of the display).  Those parts will be folded
despite user explicitly requested full unfold, which is wrong.  Fixing
this behaviour would involve implementing a full-fledged tracker on
top of jit-lock, which is very too complex and will likely introduce
hard-to-debug errors.

* lisp/org-fold-core.el (org-fold-core-initialize):
(org-fold-core-region):
(org-fold-core-remove-optimisation):
* lisp/org-cycle.el (org-cycle-hide-drawers):
(org-cycle-hide-archived-subtrees): Do not use
`org-fold-core-first-unfold-functions'.

Fixes https://list.orgmode.org/80k0ar1lml.fsf@felesatra.moe/T/#u
2022-05-12 21:38:01 +08:00
Ihor Radchenko 2e4ed52b19
org-fold: Revert old behaviour when handling invisible edits
* lisp/org-fold-core.el (org-fold-core-folded-p): Allow list of fold
types to be passed as argument.
* lisp/org-fold.el (org-fold-check-before-invisible-edit--overlays):
(org-fold-check-before-invisible-edit--text-properties): Make
overlay/text-property behaviour consistent.  Do not handle edits
inside folded links.  Fix inconsistencies.
* testing/lisp/test-org-fold.el:
* testing/lisp/test-org.el: Move folding-related tests to new test
file.
* testing/lisp/test-org-fold.el:
(test-org-fold/org-catch-invisible-edits): New test.

See https://orgmode.org/list/m2o809q170.fsf@gmail.com
2022-05-08 17:26:42 +08:00
Ihor Radchenko 24c1c877cf
org-fold-core-fontify-region: Calculate jit-lock-bounds accurately
* lisp/org-fold-core.el (org-fold-core-fontify-region): Collect all
the return values of `font-lock-default-fontify-region' on visible
regions and extend jit-lock-bounds accordingly.
2022-04-25 19:40:18 +08:00
Ihor Radchenko 2249f4d7e5
org-fold-core-fontify-region: Remove unused variable
* lisp/org-fold-core.el (org-fold-core-fontify-region):
2022-04-25 19:40:17 +08:00
Ihor Radchenko 9bc6c363da
org-fold-core: Fix edge case when fontification goes beyond requested
* lisp/org-fold-core.el (org-fold-core-fontify-region): Run
`org-fold-core-first-unfold-functions' on all the regions unmarked by
'org-fold-core-fontified property instead of using incorrect
heuristics with `point' position.  Make sure that fontified region is
registered as fontified according to the return value of
`font-lock-default-fontify-region'

Fixes https://orgmode.org/list/8735i5gd8n.fsf@gmail.com
2022-04-25 19:40:16 +08:00
Ihor Radchenko 219bc6c2d3
org-fold-core-fontify-region: Fix cases when fontification is not registered
* lisp/org-fold-core.el (org-fold-core-fontify-region): Handle FORCE
argument better.  Skip unnecessary code parts when FORCE is non-nil.
Assign `fontified' text property manually in the actually fontified
regions.  We cannot just supply correct return value since jit-lock
does not allow piecewise fontification.
2022-04-25 19:40:14 +08:00
Ihor Radchenko 3da1b2d240
org-fold-core: Fix fontification inside folded regions
* lisp/org-fold-core.el (org-fold-core-initialize): Declare
`org-fold-core-fontified' text property for font-lock.
(org-fold-core--force-fontification): New variable controlling forced
fontification inside folded regions.
(org-fold-core-fontify-region): Fix cases when BEG is inside folded
region.  Respect `org-fold-core--force-fontification'.
* lisp/org-macs.el (org-with-forced-fontification): New macro.
(org-buffer-substring-fontified):
(org-looking-at-fontified): Do not rely on jit-lock.  Use
`org-fold-core-fontified' text property to determine whether text is
already fontified.
2022-04-25 19:40:09 +08:00
Anders Johansson 240a14988f
Fix typo: delete-duplicates → delete-dups 2022-04-25 19:40:04 +08:00
Ihor Radchenko 52a0ef94c9
Backport contributed commits 2022-04-25 19:40:03 +08:00
Ihor Radchenko 88f86237c5
Add org-fold-core: new folding engine 2022-04-25 19:39:35 +08:00