* lisp/org-table.el (orgtbl-setup): Move setting up keymap to top
level instead of awkward re-`defun' used previously to ensure that
setup is evaluated once. Make it possible to honor the value of
`orgtbl-optimized' during runtime, if it is changed.
(orgtbl-mode): Remove re-`defun'.
* lisp/org-table.el (org-table-eval-formula): Use more strict regexp
to detect mode string in formulas.
* testing/lisp/test-org-table.el (test-org-table/eval-formula): Add
test.
Reported-by: Nick Dokos <ndokos@gmail.com>
Link: https://orgmode.org/list/87ply5v1gj.fsf@localhost
* lisp/org-macs.el (org-sort-function): New customization defining how
Org mode should sort headlines, table lines, agenda lines, etc.
(org-string<):
(org-string<=):
(org-string>=):
(org-string>): Use the new customization.
(org-string<>): Add docstring.
(org-sort-function-fallback): New helper function to help users on
MacOS where `string-collate-lessp' is not reliable.
* lisp/oc-basic.el (org-cite-basic--field-less-p):
* lisp/org-agenda.el (org-cmp-category):
(org-cmp-alpha):
* lisp/org-list.el (org-sort-list):
* lisp/org-mouse.el (org-mouse-list-options-menu):
* lisp/org-table.el (org-table-sort-lines):
* lisp/org.el (org-tags-sort-function):
(org-sort-entries):
* lisp/ox-publish.el (org-publish-sitemap): Honor the new
customization.
* lisp/org-mouse.el (org-mouse-tag-menu):
(org-mouse-popup-global-menu):
* lisp/org-agenda.el (org-cmp-tag): Honor `org-tags-sort-function' and
falling back to `org-string<' if note set.
* etc/ORG-NEWS (New option controlling how Org mode sorts things
~org-sort-function~): Announce the change.
This change aims to standardize the way Org mode performs sorting of
user data. In particular, it addresses issues with oddities of string
collation rules on MacOS and tricky language environments like
Turkish.
Link: https://orgmode.org/list/87jzleptcs.fsf@localhost
* lisp/org-table.el (org-table-make-reference): Drop branch of `if'
unused during runtime. This preserves _interactive_ behavior.
* testing/lisp/test-org-table.el (test-org-table/org-table-make-reference/mode-string-none):
(test-org-table/org-table-make-reference/mode-string-N): Fix tests to
check for the existing _interactive_ behavior. When running make
test (eq "" "") happens to return t and tests were passing previously
by accident despite actual behavior during user session being
different. Fix the tests to avoid breaking changes in the user
experience.
Link: https://list.orgmode.org/orgmode/20230827214320.46754-1-salutis@me.com/
* lisp/org-table.el (org-table-convert-region): When detecting
delimiter in, do not unconditionally fall back to CSV parser. Only do
it when the line contains commas and use a simple single tab/space
split otherwise. Add new special delimeter-detection strategy when
SEPARATOR is 'babel-auto - convert to | full line | table instead of
falling back to tab/space split when the region contains a single
line.
* lisp/ob-core.el (org-babel-import-elisp-from-file): Force special
strategy when converting data to lisp.
The commit fixes the problem with first `re-search-forward' in the
`cond' moving point to end of the region, making the third `cond'
branch never match.
A special strategy specific to babel is necessary to preserve the
historic behavior with lines like
: single line with spaces
being converted to a single table cell
: | single line with space |
Reported-by: Matt <matt@excalamus.com>
Link: https://orgmode.org/list/18f24d87b62.d55e94e24743657.3252620114689708448@excalamus.com
* lisp/org-table.el (org-table-header-set-header): Display table
header even when the point is below the table, as long as the table is
visible at the top of the window.
* lisp/ol.el (org-insert-link):
* lisp/org-agenda.el (org-agenda-get-restriction-and-command):
* lisp/org-attach.el (org-attach):
* lisp/org-clock.el (org-clock-select-task):
* lisp/org-goto.el (org-goto-location):
* lisp/org-macs.el (org-mks):
* lisp/org-table.el (org-table-fedit-finish):
* lisp/org.el (org-offer-links-in-entry):
* lisp/ox.el (org-export-dispatch): Arrange the dialogue window to be
killed when it is displayed in a new frame.
`save-window-configuration' is not enough in such scenarios. Use
`quit-window' instead.
* lisp/org-table.el (org-table-edit-formulas): Prohibit popping up
table editor in a new frame. This is because the major mode for
formula editing makes assumptions about where the editor window is
located and does not work reliably in a separate frame.
Reported-by: Björn Bidar <bjorn.bidar@thaodan.de>
Link: https://orgmode.org/list/87jzlcoxuq.fsf@
* lisp/org-table.el (org-table-to-lisp): When parsing table, keep text
properties. These text properties are required to calculate table
alignment with invisible text.
* testing/lisp/test-org-table.el (test-org-table/align): Add new test.
Reported-by: Kostadin Ninev <dinkonin@gmail.com>
Link: https://orgmode.org/list/1709041784097.2987395179.620232376@gmail.com
* lisp/org-table.el (org-table-to-lisp): Refactored.
* etc/ORG-NEWS: Document changes.
`org-table-to-lisp' is significantly faster.
It no longer uses regexps, nor clobbers the global regexp state.
* lisp/org-table.el (org-table-header-set-header): Make sure that
Emacs finishes any queued redisplay before calculating window
boundaries. Do not make assumptions about the same character width of
table lines.
(org-table-row-get-visible-string): Refactor calculation of the visual
text representation. Inherit all the text properties - in particular,
composition. Collect non-intersecting overlays into text properties.
Reported-by: Ypo <ypuntot@gmail.com>
Link: https://orgmode.org/list/87a605oyht.fsf@localhost
* lisp/org-table.el (org-table-make-reference): Comment out the code
that always returns nil, replacing it with explicit nil. This line is
certainly a fault in logic, but we do not know of any associated bugs.
So, just leave a FIXME to potential future refactoring and avoid the
compiler complaining about this code every time.
* lisp/org-macs.el (org-string-width): Add new optional argument
providing reference face to be used for relative width calculation.
Use `ceiling' when the total string width is a fraction of "a" width.
* lisp/org-table.el (org-table-blank-field):
(org-table-clean-line):
(org-table--shrink-field):
(org-table--align-field):
(org-table-align):
(org-table-justify-field-maybe): Use org-table face as reference for
width calculation.
When org-table face is not default, `org-string-width' may not return
correct width as " " and "-" in the table may not have the same width
as "a" with default face used as reference in `org-string-width'.
With this patch, the width calculation becomes more accurate, although
may still be off if the table faces are customized to be more
piece-mill.
Reported-by: ltmsyvag
Link: https://emacs-china.org/t/org-9-6-5-org/24484
* lisp/org-table.el (org-table-make-reference): Use `equal' instead of
`eq' to compare strings.
This change makes the following warning go away:
Warning (comp): org-table.el:2867:23: \
Warning: `eq' called with literal string that may never match (arg 2)
This change does not affect the behavior of `org-table-make-reference'
because `eq' treats all instances of the empty string as the same
object anyway, e.g., `(eq (string-trim "aaabbb" "a+" "b+") "")' ==> t.
The only effect of this change is to eliminate the warning.
* lisp/org-clock.el (org-clock-overlays):
* lisp/org-colview.el (org-columns-overlays):
* lisp/org-num.el (org-num--overlays):
* lisp/org-table.el (org-table-header-overlay):
(org-table-coordinate-overlays):
* lisp/org.el (org-custom-properties-overlays):
(org-occur-highlights):
(org-inline-image-overlays): Mark as permanent-local to not lose track
of the overlays when changing major modes.
Reported-by: Eli Qian <eli.q.qian@gmail.com>
Link: https://orgmode.org/list/871qgmeleu.fsf@gmail.com
* 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.
* 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.
* lisp/org.el (org-time-stamp-formats):
(org-timestamp-formats):
(org-time-stamp-rounding-minutes):
(org-timestamp-rounding-minutes):
(org-time-stamp-custom-formats):
(org-timestamp-custom-formats):
(org-time-stamp):
(org-timestamp):
(org-time-stamp-inactive):
(org-timestamp-inactive):
(org-insert-time-stamp):
(org-insert-timestamp):
(org-toggle-time-stamp-overlays):
(org-toggle-timestamp-overlays):
(org-time-stamp-to-now):
(org-timestamp-to-now):
* lisp/ox.el (org-export-time-stamp-file):
(org-export-timestamp-file): Rename using "timestamp" term, keeping
the old name as alias.
* doc/org-manual.org: Update all the uses, adding #+findex and
#+vindex entries. Keep the alias names for searchability.
Adjust all the callers.
The following "time-stamp" uses are unchanged:
1. `org-time-stamp-format' where obsolete and _different_ function
`org-timestamp-format' still exists.
2. :time-stamp-file property in export INFO plist. Changing this
would be breaking.
3. ORG-NEWS remains unchanged.
* doc/org-manual.org (Exporting): Add cindex entry for both "backend"
and "back-end" for better searchability.
All other changes are trivial.
Note that `org-element-export-snippet-parser' will still use :back-end
property. So will ox.el in INFO channel.
* org-table.el (org-self-insert-command): Use `last-command-event'
instead of `last-input-event'. Using `last-input-event' causes
problems in the presence of `evil-escape'. Consider a buffer that has
`orgtbl-mode' enabled while evil-escape is in use. Assume the
evil-escape sequence is "fd". Typing "f RET" will instead insert "RET
RET" into the buffer, since `last-input-event' is "RET", but
`last-command-event' is "f".
TINYCHANGE
* lisp/ob-haskell.el (org-babel-haskell-export-to-lhs): Use
non-interactive `insert-file-contents' + `write-region' to avoid
triggering various interactive hooks. Ensure that temp files are
always deleted.
* lisp/org-agenda.el (org-agenda-write):
* lisp/org-table.el: Simplify code using `write-region'.
* lisp/ox-odt.el (org-odt-template): Use `insert-file-contents' +
`write-region' instead of `find-file-noselect' that may trigger
various hooks. The new approach makes `revert-buffer' not
necessary (and do not trigger `revert-buffer' hooks). Also, the
problem with backups will no longer exists.
Original idea: https://list.orgmode.org/orgmode/20221002035931.12191-1-dafydd.lukes@gmail.com/
* lisp/org-table.el (org-table-blank-field):
(org-table-clean-line): Avoid `org-string-width' modifying match data.
As long as `org-string-width' creates a new window buffer, third-party
modes and Emacs distributions might modify the match data in buffer
hooks. Hence, we cannot assume that match data is not modified even
though `org-string-width' code itself does not alter the match data.
Note: Adding `save-match-data' around function calls is generally a
good practice when the surrounding code relies on the match data being
intact. Elisp conventions don't prohibit functions to modify match
data without notice in their docstring.
Reported-by: Thomas Schneider <qsx@chaotikum.eu>
Link: https://orgmode.org/list/wwufsc7edzu.fsf@chaotikum.eu
This reverts commit 10e857d428.
* lisp/ob-core.el:
(org-babel-merge-params):
(org-babel-process-params):
(org-babel-read):
* lisp/org-table.el: Add FIXME comments to places where arbitrary code
execution may happen.
The extra query is reverted until we develop a better code execution
safety system for Org. The commit introduced too many user queries,
making the whole idea of asking users to execute code from Org files
not useful.
Link: https://orgmode.org/list/878rinadlq.fsf@localhost
* lisp/org-table.el: Explicitly load org-fold-core.
'make single' warns that org-fold-core-ignore-modifications in
org-table.el (introduced a few commits back) is not known to be
defined, and the Emacs repo would show the same warning.