Commit graph

5705 commits

Author SHA1 Message Date
Ihor Radchenko 1967aa43e5
org-src-preserve-indentation: Refactor handling src block flags
* lisp/org-src.el (org-src-preserve-indentation-p): New function
checking whether block should preserve indentation.  This function
abstracts away the check for block type, indentation flag, and
customized `org-src-preserve-indentation' value.
(org-src--edit-element):
* lisp/ob-core.el (org-babel--normalize-body):
(org-babel-read-element):
(org-babel-update-block-body):
* lisp/ob-exp.el (org-babel-exp-process-buffer):
* lisp/org-element.el (org-element-example-block-interpreter):
(org-element-src-block-interpreter):
* lisp/org.el (org-fixup-indentation):
(org-indent-region):
* lisp/ox.el (org-export-unravel-code): Use the new function instead
of duplicating code.

* lisp/ob-haskell.el (org-babel-haskell-export-to-lhs): Add FIXME.  We
do not have access to the block element here and cannot easily check
the flag.

* lisp/ob-tangle.el (org-babel-tangle-single-block):
* lisp/org-src.el (org-src-font-lock-fontify-block):
* lisp/org.el (org-indent-line): Check block flag in addition to `org-src-preserve-indentation'.

This commit unifies logic deciding whether to preserve block
indentation into a single place to avoid confusion.
2023-07-13 11:51:15 +03:00
Ilya Chernyshov c74c4ab18d
lisp/org-element.el: Add new timestamp property :range-type
The new property is needed to reduce ambiguity when interpreting the
parsed data.

* lisp/org-element.el (org-element-timestamp-interpreter): Preserve old
behavior when :range-type is `nil'.  Take into account :range-type
value when interpreting ranges.  When :range-type is `timerange',
return a timerange (<YYYY-mm-DD HH:MM-HH:MM>).  If :range-type is
`daterange' return a daterange (<...>--<...>).  When :range-type is
nil, return a daterange (as it was before).  When :range-type is
`daterange' or `timerange' and :type is `active'/`inactive', throw an
error.
(org-element-timestamp-parser): Add :range-type property.

* lisp/org.el (org-timestamp-split-range): Make sure that :range-type
is nil for a split timestamp.

* testing/lisp/test-org-element.el
(test-org-element/timestamp-interpreter): Add new tests.
(test-org-element/timestamp-parser): Add tests for :range-type
property.

* etc/ORG-NEWS (Major changes and additions to Org API): Add news about this property.

Link: https://list.orgmode.org/orgmode/87y1ot6dqz.fsf@gmail.com/
2023-07-12 11:12:46 +03:00
Sébastien Miquel 2e2ed40553
org-src.el: Use native value of `indent-tabs-mode' for indentation
* lisp/org.el (org-indent-line): Simplify native indentation inside
src block.  Ensure we add the org indentation if the line is empty.
* lisp/org-macs.el (org-do-remove-indentation): Preserve
indentation (spaces vs tabs) past the common indentation to remove.
Do not empty blank lines.
* lisp/org-src.el (org-src--contents-for-write-back): Preserve the
native indentation (spaces vs tabs).  If necessary, add a common org
indentation to the block according to org's `indent-tabs-mode'.
(org-src-font-lock-fontify-block): Display the native indentation tab
characters with a fixed width, according to the native tab width
value, to preserve vertical alignement in the org buffer.
* testing/lisp/test-org-src.el (test-org-src/indented-blocks): Update
tests.  Indentation no longer obeys `indent-tabs-mode' from the org
buffer, but is separated in an eventual org part, and the native part.

Link: https://list.orgmode.org/87a5wcez7e.fsf@localhost/T/#t
2023-07-07 11:58:43 +03:00
Evgenii Klimov 402f72ad4f
lisp/org.el: Add final hooks to S-/M-/S-M-cursor commands
* lisp/org.el (org-metaleft-final-hook, org-metaright-final-hook,
org-metaup-final-hook, org-metadown-final-hook): Define final hooks
for S-cursor commands.
(org-metaleft, org-metaright, org-metaup, org-metadown): Add final
hooks to M-commands and document them in the docstring.

* lisp/org.el (org-shiftup, org-shiftdown, org-shiftright,
org-shiftleft): Document hooks for S-cursor commands in the docstring.

* lisp/org.el (org-shiftmetaleft-final-hook,
org-shiftmetaright-final-hook, org-shiftmetaup-final-hook,
org-shiftmetadown-final-hook): Define final hooks for the S-M-cursor
commands.
(org-shiftmetaleft, org-shiftmetaright, org-shiftmetaup,
org-shiftmetadown): Add final hooks to the S-M-cursor commands and
document hooks in the docstring.

* etc/ORG-NEWS (New final hooks for Modifier-Cursor keys): Document
new hooks.

TINYCHANGE
2023-07-05 13:40:19 +03:00
Ihor Radchenko e34b72eec6
org-make-tags-matcher: Do not try collecting tags from non-Org buffers
* lisp/org.el (org-make-tags-matcher): When building tag completion
table, do not attempt to call `org-get-buffer-tags' when current
buffer is not an Org buffer.

Reported-by: Colin Baxter <m43cap@yandex.com>
Link: https://orgmode.org/list/87ilb1fakk.fsf@yandex.com
2023-07-03 15:28:08 +03:00
Ihor Radchenko ea401fb1f4
org-agenda-ignore-properties: Bump :package-version
* lisp/org.el (org-agenda-ignore-properties): Remove :version keyword
and bump :package-version after changing the allowed values.
2023-07-01 14:36:19 +03:00
Ihor Radchenko 96b754c105
org-get-category, org-get-tags: Clarify that match data is modified
* lisp/org.el (org-get-category):
(org-get-tags): Update docstrings, documenting that these functions
may modify match data.
2023-07-01 14:36:19 +03:00
Ihor Radchenko 5ed3e1dfc3
org-refresh-category-properties: Do not check element cache
* lisp/org.el (org-refresh-category-properties): Do not check if
org-element-cache is active.  This function is now obsolete and can
only be called on purpose by third-party code that probably expects
the text properties to be assigned regardless whether the cache is
active.

This commit also fixes compiler warning as
`org-element--cache-active-p' is not declared anymore in lisp/org.el.
2023-07-01 14:36:17 +03:00
Ihor Radchenko f93d855c51
Prefer forward-line' over beginning-of-line'
The latter is much slower.

Link: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=63225#98
2023-07-01 14:36:14 +03:00
Ihor Radchenko 1c7c67b3c6
org-indent-drawer, org-indent-block: Remove unnecessary checks
* lisp/org.el:
(org-indent-block):
(org-indent-drawer): Do not try to check drawer/block twice.
2023-07-01 14:36:13 +03:00
Ihor Radchenko 2b96501070
org-element: Simplify drawer and property drawer regexps
* lisp/org-element.el (org-element-drawer-re-nogroup): New constant
regexp matching drawer line without creating regexp groups.
(org-element--current-element): Use the new constant.
* lisp/org.el (org-drawer-regexp): Ensure that it is the same with
org-element version and mark for removal/alias.
(org-property-drawer-re): Simplify, removing unnecessary matching of
node property structures.

Link: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=63225#62
2023-07-01 14:36:05 +03:00
Ihor Radchenko e1a2ea65ef
Allow syntax nodes to be supplied in place of POM in API functions
* lisp/org-agenda.el (org-agenda-entry-get-agenda-timestamp):
* lisp/org-element.el (org-element-context):
* lisp/org-habit.el (org-is-habit-p):
* lisp/org-id.el (org-id-get):
* lisp/org-macs.el (org-with-point-at):
* lisp/org.el (org-fast-tag-selection):
(org-get-tags):
(org-entry-properties):
(org--property-local-values):
(org-entry-get):
(org-entry-delete):
(org-entry-remove-from-multivalued-property):
(org-entry-member-in-multivalued-property):
(org-entry-put-multivalued-property):
(org-entry-get-with-inheritance):
(org-entry-put):
(org-read-property-value):
(org-read-property-value):
(org-property-get-allowed-values): Allow POM to be a cached Org syntax
node.
2023-07-01 14:36:04 +03:00
Ihor Radchenko 598d7bbcf2
Remove APPT_WARNTIME text property cache
* lisp/org.el (org-agenda-ignore-properties):
(org-agenda-prepare-buffers): Remove APPT_WARNTIME cache.
* lisp/org-agenda.el (org-agenda-get-timestamps):
(org-agenda-get-sexps):
(org-agenda-get-deadlines):
(org-agenda-get-scheduled): Use `org-entry-get' to retrieve
APPT_WARNTIME.
2023-07-01 14:36:02 +03:00
Ihor Radchenko 5898fcf269
Remove unused declares 2023-07-01 14:36:01 +03:00
Ihor Radchenko ebbdd67a2a
Remove effort property cache
* lisp/org-compat.el (org-refresh-effort-properties): Obsolete.
* lisp/org-clock.el (org-clock-in):
* lisp/org.el (org-default-properties):
(org-edit-agenda-file-list)
(org-set-property-and-value): Remove unnecessary calls to
`org-refresh-effort-properties'.
(org-agenda-ignore-properties): Update the allowed values.
2023-07-01 14:36:00 +03:00
Ihor Radchenko 31d53cb015
org-end-of-subtree: Use org-element API
* lisp/org.el (org-end-of-subtree): Skip all the blank lines before,
not just the last empty.  Update the docstring.
2023-07-01 14:35:58 +03:00
Ihor Radchenko def4bfa9c1
org-scan-tag: Switch to pure use of `org-element-cache-map' 2023-07-01 14:35:57 +03:00
Ihor Radchenko 3024e933c0
org-get-buffer-tags: Switch to org-element API 2023-07-01 14:35:55 +03:00
Ihor Radchenko 6938857369
org-goto-first-child: Switch to org-element API 2023-07-01 14:35:54 +03:00
Ihor Radchenko fefaadc2d5
org-element: Optimize working with match data and Emacs regexps
* lisp/org-element.el: Add commentary explaining some regexp-related
optimizations useful for the parser.

Link: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=63225
(org-element--headline-deferred):
(org-element-item-parser):
(org-element-item-interpreter):
(org-element--list-struct):
(org-element-plain-list-parser):
(org-element-example-block-parser):
(org-element-fixed-width-interpreter):
(org-element-paragraph-parser):
(org-element-src-block-parser):
(org-element-table-parser):
(org-element--parse-generic-emphasis):
(org-element-export-snippet-interpreter):
(org-element-link-parser):
(org-element--current-element):
(org-element--collect-affiliated-keywords):
(org-element-parse-buffer):
(org-element-normalize-string):
(org-element-normalize-contents):
(org-element--parse-to):
(org-element--cache-before-change):
(org-element--cache-for-removal):
(org-element-context): Avoid storing match data unless strictly
necessary.  Explain the necessity in places where we have to use
`save-match-data'.  Prefer `looking-at-p' (does not alter match data)
to `looking-at'.  Simplify regexps.  Update docstrings clearly
indicating when match data might be modified.
* lisp/org.el:
(org-offer-links-in-entry):
* lisp/ob-exp.el (org-babel-exp-process-buffer):
* lisp/org-agenda.el: Fix places where we need to protect match data.
2023-07-01 14:35:53 +03:00
Ihor Radchenko dfd36d1969
org-up-heading-safe: Use element API 2023-07-01 14:35:52 +03:00
Ihor Radchenko eb0a293a02
Remove 'org-category text property cache
* lisp/org.el (org-get-category): Update useing
`org-entry-get-with-inheritance'.
(org-agenda-ignore-properties): Update docstring.
(org-refresh-category-properties):
(org-check-agenda-file): Do not call
`org-refresh-category-properties'.
* lisp/org-compat.el (org-refresh-category-properties): Obsolete.
* doc/org-manual.org (Speeding Up Your Agendas): Update the manual.
* testing/lisp/test-org.el (test-org/get-category): Update tests, not
calling the obsolete function.
2023-07-01 14:35:51 +03:00
Ihor Radchenko 771074ba5e
org-in-archived-heading-p: Use org-element API 2023-07-01 14:35:50 +03:00
Ihor Radchenko ec8f359bd6
org-in-commented-heading-p: Use org-element API 2023-07-01 14:35:50 +03:00
Ihor Radchenko 13ae9b95f8
org-narrow-to-subtree: Use org-element API 2023-07-01 14:35:49 +03:00
Ihor Radchenko 7cbc441915
org-entry-get-with-inheritance: Use org-element API
* lisp/org.el (org--property-local-values):
(org-entry-get-with-inheritance): Switch to pure org-element API.
2023-07-01 14:35:48 +03:00
Ihor Radchenko 3b1693c461
org-back-to-heading: Use org-element API 2023-07-01 14:35:47 +03:00
Ihor Radchenko 4d63e571e0
org-get-tags: Use org-element API
* lisp/org.el (org--get-local-tags):
(org-get-tags): Switch to pure org-element API instead of regexp
matching.
2023-07-01 14:35:47 +03:00
Ihor Radchenko bc29f5de41
org-element: New `org-element-*property*' functions
* lisp/org-element.el (org-element-begin):
(org-element-end):
(org-element-contents-begin):
(org-element-contents-end):
(org-element-post-affiliated):
(org-element-post-blank): New functions for fast access to frequently
used element properties.  The functions are `setf'-able.

Update all the relevant code in Org to use the new functions instead
of genetic property queries.
2023-07-01 14:35:43 +03:00
Ihor Radchenko 81a7e8c836
org-element-lineage: Allow TYPES to be a symbol
* lisp/org-element-ast.el (org-element-lineage): Allow TYPES argument
to be a symbol.
* lisp/ox-ascii.el (org-ascii--current-text-width):
(org-ascii-format-inlinetask-default):
(org-ascii-section):
* lisp/ox-beamer.el (org-beamer--format-block):
* lisp/ox-html.el (org-html-section):
(org-html-table-cell):
(org-html-table-row):
* lisp/ox-latex.el (org-latex-table-cell):
(org-latex-table-row):
* lisp/ox-odt.el (org-odt-headline):
(org-odt-table-style-spec):
(org-odt-get-table-cell-styles):
(org-odt-table-cell):
(org-odt-table-row):
* lisp/ox-org.el (org-org-section):
* lisp/ox-publish.el (org-publish-collect-index):
* lisp/ox-texinfo.el (org-texinfo--get-node):
(org-texinfo-section):
(org-texinfo-table-row):
* lisp/ox.el (org-export--skip-p):
(org-export-get-node-property):
(org-export-table-cell-borders):
(org-export-table-row-in-header-p):
(org-export-table-row-number):
(org-export-collect-headlines): Update all the callers.
2023-07-01 14:35:43 +03:00
Ihor Radchenko ea4f4fdf58
Rename org-export-get-parent' to org-element-parent' 2023-07-01 14:35:41 +03:00
Ihor Radchenko 44baf8f2b8
org-element-parse-buffer: New optional argument to not force undefer
* lisp/org-element.el (org-element-parse-buffer): Do not force-undefer
when new optional argument is provided.
* lisp/org-lint.el (org-lint--generate-reports):
* lisp/org.el (org-unindent-buffer):
* lisp/ox.el (org-export--missing-definitions):
(org-export--annotate-info): Do not undefer when unnecessary.

Adjust all the declare forms.
2023-07-01 14:35:37 +03:00
Ihor Radchenko a7d1dfa171
Use `org-element-type-p'
Use `org-element-type-p' across Org source, except some tests, where `eq' can
produce more meaningful failure explanations.
2023-07-01 14:35:35 +03:00
Ihor Radchenko c22697f472
Use new function names org-element-extract' and org-element-set' 2023-07-01 14:35:32 +03:00
Ihor Radchenko 184b735323
Merge branch 'bugfix' 2023-07-01 13:26:08 +03:00
Gerard Vermeulen a4586f0d71
org: fix symbol names and grammar in docstrings
* lisp/org.el (org-outline-level):
* lisp/org.el (org-current-level): change undefined symbol names
  to `org-odd-levels-only' and change "Unlike to" to "Unlike".
2023-07-01 13:25:21 +03:00
Ihor Radchenko 64a0a624d2
org-insert-structure-template: Err on empty TYPE
* lisp/org.el (org-insert-structure-template): Throw a user error on
empty TYPE input.  Throw an error when TYPE is not a string or an
empty string.

Reported-by: pva-outdoor@yandex.ru
Link: https://orgmode.org/list/87a5wij05o.fsf@yandex.ru
2023-07-01 13:22:46 +03:00
Ihor Radchenko 85aa3c1850
org-narrow-to-block: Use element API and handle all the block types
* lisp/org.el (org-narrow-to-block): Narrow to any block type,
including dynamic blocks.  Use org-element API.

Reported-by: pva-outdoor@yandex.ru
Link: https://orgmode.org/list/87a5wij05o.fsf@yandex.ru
2023-07-01 13:18:38 +03:00
Ihor Radchenko a19654583c
Refactor `org-fast-tag-selection'
* lisp/org.el (org-fast-tag-selection): Refactor the function, adding
commentary and renaming variables to more readable names.
2023-06-30 15:46:51 +03:00
Ihor Radchenko f5001c0da6
Refactor `org-fast-todo-selection'
* lisp/org.el (org-fast-todo-selection): Refactor the function, adding
commentary and renaming variables to more readable names.
2023-06-30 15:46:51 +03:00
Ihor Radchenko ca873f7fe4
Update version number for the 9.6.7 release 2023-06-25 14:06:19 +03:00
Ihor Radchenko f8b0b2babf
org-edit-special: Fix docstring
* lisp/org.el (org-edit-special): Document missing contexts in the docstring.
2023-06-25 13:45:18 +03:00
Ihor Radchenko 18f003a164
Merge branch 'bugfix' 2023-06-24 15:36:34 +03:00
Ihor Radchenko 0a842cc94b
org-forward-heading-same-level: Do not rely on match-data from `org-back-to-heading'
* lisp/org.el (org-forward-heading-same-level): Use
`org-current-level' instead of relying upon `org-back-to-heading' to
set match data.

Reported-by: Nick Dokos <ndokos@gmail.com>
Link: https://orgmode.org/list/87352hk0nt.fsf@alphaville.usersys.redhat.com
2023-06-24 15:33:59 +03:00
Ihor Radchenko c8c8e3326d
org-priority-show: Fix the docstring after changes in "priority" for agenda
* lisp/org.el (org-priority-show): Do not wrongly assert that the
priority is affected by scheduled and deadline values.  This was not
true in the past for Org mode buffers, and it is no longer true after
8fab6eeef renamed composite agenda rank from priority to urgency.

* etc/ORG-NEWS (~org-priority=show~ command no longer adjusts for
scheduled/deadline): Document the change, right before the NEWS item
describing changes in the agenda.
2023-06-21 20:22:43 +03:00
Ihor Radchenko a072608567
org-set-font-lock-defaults: Fix checkbox fontification
* lisp/org.el (org-set-font-lock-defaults): Use full
`org-list-full-item-re' that accounts for alphabetical bullets as
well.

Reported-by: pondersson <pondersson@gmail.com>
Link: https://orgmode.org/list/CAHewz5N5vNMiWFuG3t=bZoyVmsYswyerZ6VsLC88DGTXR+AhOA@mail.gmail.com
2023-06-14 13:49:09 +03:00
Ihor Radchenko 34082ff184
org-indent-line: Fix with line is within blank lines after heading
* lisp/org.el (org-indent-line): Fix when we are within blank lines
after heading.  ELEMENT is then `heading' and looking at :begin - 1
does not make sense.
* testing/lisp/test-org.el (test-org/indent-region): Add test.

Reported-by: Jens Schmidt <jschmidt4gnu@vodafonemail.de>
Link: https://orgmode.org/list/d7129804-1f42-ea2b-85e8-18ea1ee32d73@vodafonemail.de
2023-06-11 13:16:31 +03:00
Ihor Radchenko c9f3de6e8f
Merge branch 'bugfix' 2023-06-07 20:34:23 +03:00
Steven Allen f2e71ee726
org.el: inline display of attached images in link descriptions
* lisp/org.el (org-display-inline-images): inline display of attached
images in link descriptions.

Previously, `org-display-inline-images' only inlined images in link
descriptions when they were explicit "file:" links. This change adds
support for "attachment:" links. E.g.:

    [[https://orgmode.org][attachment:emacs-screenshot.png]]
2023-06-07 20:32:26 +03:00
Ihor Radchenko ba8c468634
org-insert-todo-heading-respect-content: Fix regression in b4e41b
* lisp/org.el (org-insert-todo-heading-respect-content): Do not force
first TODO keyword in the inserted heading.  Instead, accept prefix
arguments and pass them directly to `org-insert-todo-heading'.
* etc/ORG-NEWS (~org-insert-todo-heading-respect-content~ now accepts
prefix arguments): Document the change.
*
testing/lisp/test-org.el (test-org/insert-todo-heading-respect-content):
Add tests.

Reported-by: Xuan Wang <xuan.public@gmail.com>
Link: https://orgmode.org/list/CALjN2yehOVYZuU+tURes+mJ5XyTrRY1O0UG1ijH-6TjJ=W0ibw@mail.gmail.com
2023-06-07 15:18:16 +03:00