Commit Graph

602 Commits

Author SHA1 Message Date
TEC 90e7813dd7
org-macs: Set some process variables in org-async
* lisp/org-macs.el (org-async-call): When eking out maximum performance
from external commands, there are a few potentially important process
variables. `org-async-call' is extended to support setting these, with
default values that differ from Emacs' defaults but should enable better
performance in general.
2024-04-16 19:58:50 +08:00
TEC 36d1b5d3b2
org-macs: Support blocking on async tasks
* lisp/org-macs.el (org-async--blocking-tasks, org-async-wait-for,
org-async--cleanup-process, org-async--execute-callback): Add support
for waiting for a set of async tasks to complete via the new function
`org-async-wait-for'.
2024-04-16 19:58:49 +08:00
TEC cfed7bbc79
org-macs: Ensure that filter run before callbacks
* lisp/org-macs.el (org-async--cleanup-process): Run
`accept-process-output` until no further output is fetched on process
exit, so we can assume that the callbacks are run after all filter
invocations.
2024-04-16 19:58:49 +08:00
TEC 2b36e6f5d3
org-macs: Add :coding kwarg to org-async-call
* lisp/org-macs.el (org-async-call): It is recommended in
(info "(elisp) Decoding Output") that the process coding system be set.
To allow for this we add a new keyword argument, :coding, and set the
default value to utf-8.
2024-04-16 19:58:49 +08:00
TEC 7bc9de054a
org-macs: Rework async filter
* lisp/org-macs.el (org-async--filter, org-async-call): Expose :info to
the async filter function, and make the obvious modifications to the
process buffer content.
2024-04-16 19:58:48 +08:00
TEC fe5712eac8
org-macs: Accept nested org-async callbacks
* lisp/org-macs.el (org-async--execute-callback, org-async-call): Change
the org-async call arguments callback form to start with the symbol
org-async-task.  This allows for a list of callbacks to be
differentiated from a single callback.  `org-async-call' is also
extended to accept a a callback of this form as its sole argument.

* lisp/org-latex-preview.el (org-latex-preview--image-extract-async,
org-latex-preview--tex-compile-async, org-create-formula-image-async):
Use the new async callback form.
2024-04-16 19:58:48 +08:00
TEC 6b6aff2ef2
org-macs: Add an async command execution system
* lisp/org-macs.el (org-async--stack, org-async--wait-queue,
org-async-process-limit, org-async-timeout,
org-async-check-timeout-interval, org-async--counter, org-async-call,
org-async--sentinel, org-async--cleanup-process,
org-async--execute-callback, org-async--monitor-scheduled,
org-async--monitor): Introduce an asynchronous command execution system.
2024-04-16 19:58:48 +08:00
Ihor Radchenko 78e9dd0c42
Fix when user customization makes Org dialogues pop up in new frames
* 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@
2024-04-10 15:42:52 +03:00
Ihor Radchenko 18fbb9985f
Honor `display-buffer-alist' when creating dialogues
* lisp/org-macs.el (org-display-buffer-split): New function to display
just the new buffer and current buffer visible in the frame.  To be
used as `display-buffer' ACTION parameter.
* lisp/org-agenda.el (org-agenda-get-restriction-and-command):
(org-agenda-fit-window-to-buffer):
(org-agenda-prepare-window):
(org-agenda-switch-to):
* lisp/org-capture.el (org-capture-place-template):
* lisp/org-goto.el (org-goto-location):
* lisp/org-src.el (org-src-switch-to-buffer):
* lisp/org.el (org-tree-to-indirect-buffer):
(org-fast-todo-selection):
(org-add-log-note):
(org-fast-tag-selection):
(org-submit-bug-report):
* lisp/ox.el (org-export--dispatch-ui): Get rid of calling
`delete-other-windows' manually.  Instead, make use of
`org-display-buffer-slip' + `pop-to-buffer'/`display-buffer'.  This
way, user overrides in `display-buffer-alist' are honored.
* lisp/org-plot.el (org-plot/gnuplot):
* lisp/org.el (org-offer-links-in-entry): When `delete-other-windows'
cannot be avoided, make it ignore errors in the frames where
displaying a lone window is forbidden.
2024-04-07 13:34:13 +03:00
Ihor Radchenko ea6296a4d9
Consistently label fold types when `org-fold-core-style' is 'overlays
* lisp/org-clock.el (org-clock-find-position):
* lisp/org-compat.el (org-flag-drawer):
* lisp/org-src.el (org-edit-src-exit):
* lisp/org.el (org-log-beginning): Do not force 'outline folds when
`org-fold-core-style' is 'overlays.  The erroneous logic dates back to
the time when all the folding was done via 'outline folds to save up
on the number of overlays in buffer.  This is not longer the case -
newer Emacs no longer struggle with number of overlays and we fall
back to using text properties in older Emacs.

Reported-by: Bruno Cardoso <cardoso.bc@gmail.com>
Link: https://orgmode.org/list/87sezzmd1m.fsf@gmail.com
2024-04-06 15:21:10 +03:00
Ihor Radchenko 051e7b9d7c
Reduce repetitive calls to `find-buffer-visiting' + `find-file-noselect'
* lisp/org-macs.el (org-with-file-buffer): New macro switching to a
file buffer temporarily and killing it if a buffer visiting file did
not exist previously.
(org-file-buffer-created): New variable set when buffer visiting file
has been created.
* lisp/ob-tangle.el (org-babel-tangle-file):
* lisp/org-archive.el (org-archive-subtree):
* lisp/org-refile.el (org-refile):
(org-refile-check-position):
(org-refile-new-child):
* lisp/ox-org.el (org-org-publish-to-org):
* lisp/ox-publish.el (org-publish-org-to):
(org-publish-find-property): Avoid calling `find-buffer-visiting' +
`find-file-noselect'.  The latter calls the former.  Instead, either
just call `find-file-noselect' or use `org-with-file-buffer'.

This commit addresses O(N_buffers) complexity in
`find-buffer-visiting', reducing the number of calls to it.

See Emacs bug#66117.
2024-03-16 11:21:30 +03:00
Psionik K b6f8078ab4
org-do-remove-indentation: Ignore invisible text
* lisp/org-macs.el (org-do-remove-indentation): Set
`buffer-invisibility-spec' to nil before detecting the column or
moving to a column.

This fixes src_block indentation removal for org-modern-mode but will
also correct other cases of hidden indentation.

TINYCHANGE
2024-03-12 15:19:50 +03:00
Ihor Radchenko a1b8554f6f
org-mks: Do not leave window around
* lisp/org-macs.el (org-mks): Make sure that selection window is
closed upon exiting.  See also fef873b1c.

Reported-by: Björn Bidar <bjorn.bidar@thaodan.de>
Link: https://orgmode.org/list/874jdg2ipo.fsf@
2024-03-12 15:12:42 +03:00
Ihor Radchenko 755fef38f5
Merge branch 'bugfix' 2024-02-28 10:54:50 +03:00
Ihor Radchenko 80dff08ed1
Fix unescaped \ in docstrings
* lisp/org-macs.el (org-split-string):
* lisp/ox-latex.el (org-latex-guess-babel-language): Fix docstrings,
as revealed by compiler warnings.
2024-02-28 10:52:58 +03:00
Ihor Radchenko a250fc745f
org-compile-file: Retain all the logs when PROCESS is a list
* lisp/org-macs.el (org-compile-file): When PROCESS is a list of shell
commands, do not erase logs of all but last commands.
2024-02-13 12:59:38 +01:00
Ihor Radchenko 78dc58508d
Obsolete org-switch-to-buffer-other-window and org-no-popups
* lisp/org-compat.el (org-switch-to-buffer-other-window):
(org-no-popups): Move from org-macs.el and mark obsolete.
* lisp/ob-lilypond.el (org-babel-lilypond-execute-tangled-ly):
(org-babel-lilypond-mark-error-line):
* lisp/ol.el (org-insert-link):
* lisp/org-agenda.el (org-agenda-get-restriction-and-command):
(org-agenda-prepare-window):
(org-agenda-goto):
(org-agenda-open-link):
(org-agenda-clock-goto):
(org-agenda-diary-entry-in-org-file):
(org-agenda-add-entry-to-org-agenda-diary-file):
(org-agenda-show-the-flagging-note):
* lisp/org-attach.el (org-attach):
* lisp/org-capture.el (org-capture-place-template):
(org-capture-fill-template):
* lisp/org-clock.el (org-clock-select-task):
* lisp/org-macs.el (org-mks):
* lisp/org-src.el (org-src-switch-to-buffer):
* lisp/org-table.el (org-table-edit-field):
(org-table-edit-formulas):
(org-table-show-reference):
* lisp/org.el (org-fast-todo-selection):
(org-add-log-note):
(org-fast-tag-selection):
* lisp/ox.el (org-export-stack-view):
(org-export--dispatch-ui): Use `switch-to-buffer-other-window'.
* etc/ORG-NEWS (Org mode no longer disallows configuring
~display-buffer-alist~ to open Org popups in other frame): Document
the breaking change.

Reported-by: Jan Seeger
Link: https://orgmode.org/list/87pmr3mfq3.fsf@localhost
2024-01-24 15:00:26 +01:00
Kyle Meyer 6e17ddd334 Merge branch 'bugfix' 2024-01-20 21:33:37 -05:00
Stefan Kangas 50183ada86 Backport commit 725a3f32f from Emacs
; Fix typos in symbol names
725a3f32f8ba78ac5fffcd03be5b82cbc2c1b275
Stefan Kangas
Sun Jan 14 15:16:54 2024 +0100
2024-01-20 21:25:59 -05:00
Kyle Meyer 72a2db86d9 Merge branch 'bugfix' 2024-01-06 16:02:02 -05:00
Po Lu 9f1d6dfd73 Backport commit 8e1c56ae4 from Emacs
; Add 2024 to copyright years
8e1c56ae46754dd7baedff49a464f078f0e9912d
Po Lu
Tue Jan 2 09:47:10 2024 +0800
2024-01-06 15:48:23 -05:00
Ihor Radchenko 80ce6152ba
lisp/org-table.el: Improve cell alignment accuracy
* 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
2023-12-28 16:17:03 +01:00
Ihor Radchenko bd9dc32178
org-assert-version: Disable version check in .elc files for built-in Org mode
* lisp/org-macs.el (org-assert-version): Record
`org--inhibit-version-check' during compile time inside
`org-assert-version'.  This way, .elc files generated when compiling
built-in Org mode in Emacs git tree never trigger version mismatch
warning.

Link: https://yhetil.org/emacs-devel/87zfxzdbna.fsf@yahoo.com
2023-12-25 15:50:08 +01:00
Ihor Radchenko eadeaa8533
org-assert-version: Disable version check in .elc files for built-in Org mode
* lisp/org-macs.el (org-assert-version): Record
`org--inhibit-version-check' during compile time inside
`org-assert-version'.  This way, .elc files generated when compiling
built-in Org mode in Emacs git tree never trigger version mismatch
warning.

Link: https://yhetil.org/emacs-devel/87zfxzdbna.fsf@yahoo.com
2023-12-24 13:47:04 +01:00
Ihor Radchenko 7440911e49
Merge branch 'bugfix' 2023-12-24 11:58:52 +01:00
Ihor Radchenko af18216738
org-assert-version: Convert to warning. Add info when building Emacs git
* lisp/org-macs.el (org-assert-version): Do not throw an error - it is
preventing Org loading and creating more breakage than the problem it
is trying to solve (the version mismatch is problematic occasionally,
while the error was thrown every single time).  Document what to do
when version mismatch is encountered for Org mode built inside Emacs
git repository.

Link: https://yhetil.org/emacs-devel/83frzsccuy.fsf@gnu.org/T/#t
2023-12-24 11:53:39 +01:00
Ihor Radchenko 571186631a
lisp/org-macs.el (org-current-text-column): Improve error message
The previous version is apparently not clear enough for some people.

Link: https://list.orgmode.org/412FBC9A-3DA2-48A7-A57F-AA90A40B5BEA@gmail.com/T/#t
2023-12-19 12:51:04 +01:00
Ihor Radchenko d6924212bd
lisp/org-macs.el: Fix some checkdoc warnings
* lisp/org-macs.el (org-with-remote-undo): Avoid using Elisp symbol
without quotes.
(org-with-wide-buffer): Mark the argument in docstring.
2023-12-15 12:21:10 +01:00
Ihor Radchenko 1fe051fa19
fixup! org-string-width: Fix measuring lines beyond window width 2023-12-05 20:38:32 +01:00
Ihor Radchenko 4a7a1f2fe7
org-string-width: Fix measuring lines beyond window width
* lisp/org-macs.el (org-string-width): Pass non-nil X-LIMIT argument
to `window-text-pixel-size' to not limit the maximum width to window
pixel width.

Reported-by: Raffael Stocker <r.stocker@mnet-mail.de>
Link: https://orgmode.org/list/yplmr0k4bv9d.fsf@mnet-mail.de
2023-12-05 16:40:37 +01:00
Ihor Radchenko 315417582f
lisp/org.el (org-mode): Force `tab-width' to be 8
* lisp/org-macs.el (org-current-text-column): Assert `tab-width' to be
8 to ensure consistency of the parser across user configurations.
* etc/ORG-NEWS (~tab-width~ value is now assumed to be 8): Document
the breaking change.

This breaking change is made to standardize Org mode format for list
items.  With variable `tab-width', indentation in lists may depend on
user settings leading to inconsistent Org documents when open by
different users.

Link: https://orgmode.org/list/2c9a6cbd-21c0-45bf-8fbb-4f7eccac4ae7@app.fastmail.com
2023-12-05 14:11:23 +01:00
Ihor Radchenko b1c507c0ee
org-find-base-buffer-visiting: Document function argument
* lisp/org-macs.el (org-find-base-buffer-visiting): Fix the docstring.
2023-09-20 11:02:32 +03:00
Ihor Radchenko dcd2ba4a02
* lisp/org-macs.el: Declare `org-buffer-text-pixel-width' 2023-08-15 13:49:02 +03:00
Max Nikulin 2f79c63c2c
org-macs.el: Fix Emacs-26 compatibility
lisp/org-macs.el (org-string-width): Avoid multiple variables in
`setq-local' since it is not supported by Emacs-26.

The code caused the issue was added in 0c29f53ab8723.
2023-08-11 19:24:36 +03:00
Ihor Radchenko 6c40983e86
org-with-remote-undo: Update docstring
* lisp/org-macs.el (org-with-remote-undo): Mention all the arguments.
Document that function is not useful outside agenda.
2023-08-09 11:47:07 +03:00
Roshan Shariff 4ea9a98f85
org-macs: Fix incorrect use of relative paths in org-compile-file
* org-macs.el (org-compile-file, org-compile-file-commands): Resolve
symlinks in default-directory before computing relative source path

Commit 5a8a1d4ff [1] changed org-compile-file to use
`file-relative-name` for the SOURCE argument.  This was intended to
fix bug [2] by expanding ~ directories, like a shell.  Unfortunately,
this breaks when DEFAULT-DIRECTORY is a symlink and SOURCE has an
absolute path.

For example, on macOS Ventura, ~/Dropbox is a symlink to
~/Library/CloudStorage/Dropbox.  Suppose DEFAULT-DIRECTORY is
/Users/username/Dropbox and SOURCE is /var/tmp/test.org, so its
relative path is ../../../var/tmp/test.org.  But the working directory
of a compilation process is actually ~/Library/CloudStorage/Dropbox,
relative to which the source path resolves to
/Users/username/var/tmp/test.org.  The process thus cannot find the
source file.

This commit changes `org-compile-file` and its helper function
`org-compile-file-commands` to resolve symlinks in DEFAULT-DIRECTORY
before computing the relative path of SOURCE.  If SOURCE is already
relative, it is used as-is.  The absolute path is processed by
`expand-file-name`, avoiding bug [1].

[1] https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=5a8a1d4ff
[2] https://orgmode.org/list/25528.42190.53674.62381@gargle.gargle.HOWL

TINYCHANGE
2023-08-06 09:44:13 +03:00
Ihor Radchenko 11ce194dcf
org-string-width: Fix Emacs <29 compatibility
* lisp/org-compat.el (org-buffer-text-pixel-width): New function using
`buffer-text-pixel-size' in Emacs >=29 and falling back to
`window-text-pixel-size' in older Emacs.
* lisp/org-macs.el (org-string-width): Use the new function.
2023-08-04 10:53:17 +03:00
Ihor Radchenko 323a669921
org-string-width: Remove unnecessary dedicated window check
* lisp/org-macs.el (org-string-width): Do not handle dedicated
selected window specially.  The bug fixed by 946abeb49 is no
longer reproducible using the release version of Emacs 29 and other
Emacs versions.  Apparently, it was caused by now-fixed Emacs bug
specific to Emacs 29.

Also, use `buffer-text-pixel-size' as in `string-pixel-width' from
Emacs master.  Using `window-text-pixel-size' requires setting buffer
to window, which is tricky when selected window is dedicated (see
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=64986).
2023-08-02 08:04:56 +03:00
Ihor Radchenko 884b84f7ad
org-string-width: Adapt Emacs commit 0c29f53ab8723
* lisp/org-macs.el (org-string-width): Make sure that default values
of `line-prefix' and `wrap-prefix' do not affect width calculation.

Link: https://git.savannah.gnu.org/cgit/emacs.git/commit/?h=emacs-29&id=0c29f53ab8723dd5a9f31ce8a6e913cc08132e56
2023-08-01 10:06:01 +03:00
Ihor Radchenko dd586c5f42
* lisp/org-macs.el (org-time-convert-to-list): Provide declaration
Update obsolete declaration using the function that is used now.
This fixes native-comp warning.
2023-07-30 12:27:21 +03:00
Ihor Radchenko d5006e195a
Merge branch 'bugfix' 2023-07-30 12:22:09 +03:00
Ihor Radchenko da1bc002f2
Backport Emacs commit 670174a6d5f
* lisp/org-macs.el (org-replace-escapes): Suppress byte-compiler
warning about modifying constant string.

Unlike, 39786a8dbf, this commit does not
create merge conflicts.
2023-07-30 12:21:37 +03:00
Ihor Radchenko 3007511f3f
org-string-width: Reuse buffer when calculating string width
* lisp/org-macs.el (org-string-width): Use dedicated buffer instead of
creating a new one every time.  The idea is from `string-pixel-width'.
2023-07-17 12:33:03 +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
Justin Vallon f18fad60b6
org-id-uuid: Use compat org-time-convert-to-list for emacs <27.1
* lisp/org-macs.el (org-id-uuid): Use `org-time-convert-to-list'
instead of `time-convert', which is not yet available in Emacs 26.
2023-07-05 13:28:38 +03:00
Ihor Radchenko a04e16bd11
lisp/org-macs.el: Restructure file outline, fixing compiler warning
Add new section "Misc", moving all the functions that do not belong to
other sections below.  This also fixes defun order for
`org-compile-file' that needs `org-trim' to be defined.
2023-07-01 14:36:18 +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 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 607c230d74
org-with-point-at: Accept syntax node as POM 2023-07-01 14:35:46 +03:00
Ihor Radchenko 7da765e459
Revert "org-replace-escapes: Fix compiler warning"
This reverts commit 39786a8dbf.

In favor of an equivalent upstream Emacs commit 670174a6d5f.
2023-06-26 13:43:44 +03:00