Commit Graph

348 Commits

Author SHA1 Message Date
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 46b9769a02
org-attach-store-link-p: Change default value to 'attached
* lisp/org-attach.el (org-attach-store-link-p): Change the default
value.
* etc/ORG-NEWS (The default value of ~org-attach-store-link-p~ is now
~attached~): Announce the change.
2024-01-25 13:59:58 +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 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 abf5156096
* lisp/org-attach.el (org-attach-attach): Do not end error message with period 2023-10-13 15:34:39 +03:00
Ihor Radchenko 8b18fc5817
org-attach-dir-from-id: Detect attachments under default `org-attach-id-dir'
* lisp/org-attach.el (org-attach-dir-from-id): When searching for an
existing attachment directory, consider the default value of of
`org-attach-id-dir', if it is changed.  This way, if user used the
default value in the past (or accidentally via emacs -Q), we can still
find the existing attachment dir.
2023-09-20 13:39:20 +03:00
Ihor Radchenko 83fd03fb6d
org-attach: Fix when called from agenda
* lisp/org-attach.el (org-attach): Do not try to call `org-attach-dir'
from non-Org buffer.  This requires parser, which cannot run in agenda
buffer.
2023-08-18 13:24:13 +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 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 f067a4bd43
org-attach-tag: Work around error when before first heading
* lisp/org-attach.el (org-attach-tag): Avoid error thrown when trying
to set tags before first heading.  This is not a proper fix, but it
will at least allow attaching files to Org file.  The tagging will be
skipped for now, until setting FILETAGS is supported by Org API.
2023-04-28 12:52:09 +02:00
Marco Wahl 0d01a198bc org-attach: Show Org Attach UI starting from top
* org-attach.el (org-attach): Move cursor to the top of the
UI-description buffer.

This matters when the buffer does not fit completely in the window for
display.  Without the change the user would see the bottom part.
2023-01-30 23:01:17 +01:00
Eli Zaretskii e0815d7545 Backport commit cae528457 from Emacs
; Add 2023 to copyright years.
cae528457cb862dc886a34240c9d4c73035b6659
Eli Zaretskii
Sun Jan 1 05:31:12 2023 -0500
2023-01-01 12:44:47 -05:00
Stefan Kangas c8ad9e4b28 Backport commit 8617edfff from Emacs
; Fix typos
8617edfffd07eb80561b4de6a37c5b0b5f442e07
Stefan Kangas
Wed Nov 30 16:59:41 2022 +0100
2022-11-30 17:19:12 -05:00
Max Nikulin 08a8c9e678
org-attach.el: ID to path functions may return nil
* lisp/org-attach.el (org-attach-dir-from-id): Ignore nil values
returned by entries from `org-attach-id-to-path-function-list'.
(org-attach-dir-get-create): Signal an error suggesting customization
of `org-attach-id-to-path-function-list' if all ID-to-path functions
return nil.
(org-attach-id-to-path-function-list): Add to the docstring examples
how to handle unusual IDs.
(org-attach-id-uuid-folder-format, org-attach-id-ts-folder-format):
Return nil if ID is too short.
(org-attach-id-fallback-folder-format): New function that may be added
as the last element of `org-attach-id-path-function-list' to handle
unexpectedly short IDs.
* etc/ORG-NEWS: Advertise the change.

Earlier an obscure error like 'org-attach-id-ts-folder-format: Args out
of range: "ftt", 0, 6' was signalled in the case of unexpectedly short
ID.

Reported-by: Janek F <xerusx@pm.me>
Link: https://list.orgmode.org/KC8PcypJapBpJQtJxM0kX5N7Z0THL2Lq6EQjBMzpw1-vgQf72egZ2JOIlTbPYiqAVD4MdSBhrhBZr2Ykf5DN1mocm1ANvvuKKZShlkgzKYM=@pm.me
2022-11-16 09:47:03 +08:00
Ihor Radchenko 0d60013f0e
org-attach-attach: Fix when `org-attach-store-link-p' is t
* lisp/org-attach.el (org-attach-attach): Store link to the original
file location when `org-attach-store-link-p' is set to t, as promised
by the variable docstring.
2022-11-05 11:00:15 +08:00
Ihor Radchenko 094ee4490d
org-attach-store-link-p: Explain all the values in the docstring
* lisp/org-attach.el (org-attach-store-link-p): Detail what each of
the allowed values mean, in addition to the :type tags.
2022-11-05 11:00:14 +08:00
Ihor Radchenko 48b237d9e2
org-attach-attach: Fix storing link to attached files
* lisp/org-attach.el (org-attach-attach): Fix typo when
`org-attach-store-link-p' is set to t.  Instead of `file', we need
`attach-file': the link to the attached file, not the original.
2022-10-24 12:37:32 +08:00
Ihor Radchenko fe90cab956
lisp/ox.el: Rename abnormal hook names to end with "-functions"
* lisp/ox.el (org-export-before-processing-functions):
(org-export-before-parsing-functions): Rename
`org-export-before-processing-hook' and
`org-export-before-parsing-hook' to use "-functions" suffix as these
hooks are abnormal hooks and we need not to use "-hook" suffix in
abnormal hooks.
* lisp/org-compat.el (org-export-before-processing-hook):
(org-export-before-parsing-hook): Declare obsolete.
* lisp/org-attach.el (org-export-before-parsing-functions): Use the
new hook name.
2022-09-06 21:42:11 +08:00
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 d2a110ffe2
org-attach-attach: Allow attaching directories using 'cp method
* lisp/org-attach.el (org-attach-attach): Use `copy-directory' when
FILE is a directory.  Remove trailing slash before processing.
2022-07-21 19:23:18 +08:00
TEC 0583a0c5ea
org: Add setting for remote file download policy
* lisp/org.el (org-resource-download-policy, org-safe-remote-resources):
Two new customisations to configure the policy for downloading remote
resources.
(org--should-fetch-remote-resource-p, org--safe-remote-resource-p,
org--confirm-resource-safe): Introduce the new function
`org--should-fetch-remote-resource-p' for internal use determining
whether a remote resource should be downloaded according to the download
policy.  This function makes use of two helper functions,
`org--safe-remote-resource-p' and `org--confirm-resource-safe'.
(org-file-contents): Apply `org--safe-remote-resource-p' to file
downloading.

* lisp/org-persist.el (org-persist-write): Apply
`org--safe-remote-resource-p' to url downloading.

* lisp/org-attach.el (org-attach-attach, org-attach-url): Apply
`org--safe-remote-resource-p' to url downloading.
2022-07-16 17:46:01 +08:00
Ihor Radchenko ad304faea1
org-attach-attach: Avoid linking to path starting with ~
* lisp/org-attach.el (org-attach-attach): Auto-expand ~ in the file
patch when using symlink (`lns') attach method.

Fixes https://orgmode.org/list/CAN_Dec_LyTKgSN_kiftee9GULM7FPER5frQFant3n_2C3cwM-g@mail.gmail.com
2022-07-04 21:01:43 +08:00
Ryan Scott 226119124d
ob-core.el/babel: Special handling for attachment links in src block
* ob-core.el (org-babel-merge-params): Specifying the symbol 'attach`
or string "'attach" as the value of the `:dir' header now functions as
":dir (org-attach-dir nil t) :mkdirp t".
(org-babel-result-to-file): Optional TYPE argument accepts symbol
'attachment to fixup up paths under `(org-attach-dir)' and use the
link type "attachment:" when that is detected.
(org-babel-insert-result): Pass symbol `attachment' as TYPE to
`org-babel-result-to-file'.
* org-attach.el (org-attach-dir): Added autoload header to simplify
dependencies necessary to support this feature (called in
`org-babel-merge-params').
* test-ob.el (test-ob-core/dir-attach): Added unit test for the new
attach feature.
2022-06-14 21:44:25 +08:00
Marco Wahl 28da0649e6 org-attach: Extend range for org-attach-commands
* lisp/org-attach.el (org-attach): Get rid of the use of the second
arg of `commandp`, by making `org-attach-commands` accept any
commands (including keyboard macros).

Patch from Stefan Monnier.
https://list.orgmode.org/jwvwni7y70r.fsf-monnier+emacs@gnu.org/
2022-02-06 23:57:14 +01:00
Marco Wahl 4fdfe9c584 org-attach: Clean up some magic numbers
* lisp/org-attach.el (org-attach): Clean up some magic numbers.

Patch from Stefan Monnier.
https://list.orgmode.org/jwvwni7y70r.fsf-monnier+emacs@gnu.org/
2022-02-06 23:48:32 +01:00
Kyle Meyer aae2ac3a68 Merge branch 'bugfix' 2022-01-01 15:21:37 -05:00
Kyle Meyer 5a229cbc44 Update copyright year to 2022 2022-01-01 15:17:08 -05:00
Nicholas Vollmer fac96da572 org-attach.el: Fix checkdoc warnings
* org-attach.el: Fix checkdoc warnings.
2021-10-02 19:15:52 +02:00
Bastien 806ac1b7f6 *el: Fix indentation 2021-09-29 09:22:47 +02:00
Nicholas Vollmer 4d1a77aec6 org-attach: Fix byte-comp function warning
* (org-attach.el): Declare function for byte compiler.
2021-09-25 22:46:34 +02:00
Stefan Kangas 51cdd6e30f Various minor docfixes found by checkdoc 2021-09-16 21:24:59 +02:00
Marco Wahl 81eb8c5f9e attach: Fix for Emacs<28
* lisp/org-compat.el: Introduce org-directory-empty-p which is directory-empty-p from Emacs 28.
* lisp/org-attach.el (org-attach-sync): Use org-directory-empty-p instead of directory-empty-p.
* etc/ORG-NEWS: Note about org-directory-empty-p.

Thanks Kyle identifying the issue.  Thanks Arthur for suggesting a
fix.
2021-08-10 22:20:48 +02:00
Marco Wahl 61e0837325 org-attach: Possibly delete empty attach directory
* lisp/org-attach.(org-attach-sync): Enable possible deletion of empty
attachment directories.  `org-attach-sync-delete-empty-dir' controls
the action: Never delete, Always delete or Query the user (default).
2021-07-09 21:03:44 +02:00
Kyle Meyer e0fb2339f4 Merge branch 'km/from-emacs-master'
Porting from Emacs's master to Org's maint branch has been on hold
leading up to the Emacs 27.2 release to avoid any required fixup syncs
carrying those commits into the emacs-27 branch.  This merge brings
those changes into master.  The km/from-emacs-master branch should be
merged to maint when Emacs 27.2 has been released (assuming Org 9.5
hasn't been released, in which case maint will be tracking 9.5.x and
already include these changes).
2021-02-14 18:06:23 -05:00
Stefan Kangas d904f9e5da Backport commit f88a7897a from Emacs
* lisp/ob-R.el (org-babel-R-write-object-command):
* lisp/org-attach.el (org-attach-after-change-hook):
* lisp/org.el (org-stamp-time-of-day-regexp): Shorten doc strings to
not exceed 80-column limits.  (Bug#44858)

Shorten over-wide docstrings in variables
f88a7897a80ee9129bdc444cafff32d026c4b6d8
Stefan Kangas
Sat Dec 19 18:21:06 2020 +0100
2021-02-14 17:38:07 -05:00
Kyle Meyer 291993888d Merge branch 'maint' 2021-01-01 15:02:10 -05:00
Kyle Meyer 99eafe3787 Update copyright year to 2021 2021-01-01 14:59:01 -05:00
Kyle Meyer d631a51e01 org-attach: Silence byte-compiler
de6d90224 (org-attach: Consider inlinetasks when calculating attach
dir, 2020-12-17) introduced a call to org-inlinetask-goto-beginning
and org-inlinetask-in-task-p, each behind a featurep guard.
2020-12-23 00:05:39 -05:00
Ihor Radchenko de6d90224c org-attach: Consider inlinetasks when calculating attach dir
* lisp/org-attach.el (org-attach): When inside inlinetask, return
attachment dir of that task.  When outside inlinetask, return
attachment dir of the main task ignoring any inlinetasks above point.

The call to `org-back-to-heading-or-point-min` does not move point to
the actual heading when there is inlinetask above the point.  The
result is incorrect return value or even creation of property drawer
below *...** END line of the last inline task before point.
2020-12-17 07:26:31 +01:00
Kyle Meyer eac255d911 Merge branch 'maint' 2020-07-08 00:12:06 -04:00
Kyle Meyer e62ca4a1bf org-attach: Fix :type for org-attach-use-inheritance
* lisp/org-attach.el (org-attach-use-inheritance): Drop repeated :type
keyword that incorrectly marked the option as boolean.

Reported-by: Philip Blagoveschensky <philip@crabman.me>
https://orgmode.org/list/7036d668-eb09-ba4d-0b46-503fbc4a50ce@crabman.me
2020-07-08 00:11:34 -04:00
Kyle Meyer 0a8faecb7f Merge branch 'maint' 2020-03-05 23:24:24 -05:00
Tim Visher 70c1eec559 org-attach.el: Use `force' arg everywhere in `org-attach-delete-all'
* lisp/org-attach.el (org-attach-delete-all): Use `force' arg
throughout function.

`org-attach-delete-all` advertised a `force` option but passing it
only forced its way past the initial "Really remove all…" query.  This
was unexpected and not properly documented.

This extends the use of the `force` argument to the `delete-directory`
call and documents its meaning in the docstring.

TINYCHANGE
2020-03-05 23:24:14 -05:00
Nicolas Goaziou 041138e47c Remove `org-export-link-as-file'
* lisp/ol.el (org-link-parameters): Remove reference to the function.
* lisp/ox.el (org-export-link-as-file): Remove function.
* testing/lisp/test-ox.el (test-org-export/link-as-file): Remove test.

The current implementation is not satisfactory, and not useful in the
code base. Using a pre-export hook turning custom link type into
"file" is enough for now. See "attachement" links for an example.
2020-02-28 01:30:30 +01:00
Gustav Wikström 0e0df5abf3 attach: translate directly as file links during export
* lisp/org-attach.el (org-attach-expand-links): translate directly as
file links during export.
2020-02-28 01:27:47 +01:00
Nicolas Goaziou 42ec2462a0 Do not leak "attachment" links
* lisp/ol.el (org-link-open): Remove "attachment" for special cases.
* lisp/org-attach.el (org-attach-expand-links):
(org-attach-follow): New functions.
(org-attach-link-expand): Remove function.
* lisp/org-element.el (org-element-link-parser):
* lisp/ox-ascii.el (org-ascii-link):
* lisp/ox-html.el (org-html-link):
* lisp/ox-latex.el (org-latex--inline-image):
(org-latex-link):
* lisp/ox-man.el (org-man-link):
* lisp/ox-md.el (org-md-link):
* lisp/ox-odt.el (org-odt-inline-image-rules):
(org-odt-link):
* lisp/ox-texinfo.el (org-texinfo-inline-image-rules):
(org-texinfo-link): Remove "attachment" from special cases.
2020-02-22 14:22:49 +01:00
Bastien 5dd7721242 Use `org-switch-to-buffer-other-window' in a few places
* lisp/org-src.el (org-src-switch-to-buffer):
* lisp/org-attach.el (org-attach):
* lisp/ob-lilypond.el (org-babel-lilypond-execute-tangled-ly)
(org-babel-lilypond-mark-error-line): Use
`org-switch-to-buffer-other-window' instead of
`switch-to-buffer-other-window'.
2020-02-17 09:04:19 +01:00
Kyle Meyer ea94a0da43 Merge branch 'maint' 2020-02-13 00:04:16 -05:00
Alan Mackenzie 5056a48ff5 Backport commit 530067463 from Emacs
* lisp/org-attach.el (org-attach-unset-directory): Replace "different
than" by "different from".

Correct "different than" to "different from" where appropriate
530067463bffc982f02dcc4f2805d389704575b4
Alan Mackenzie
Sun Feb 9 14:33:14 2020 +0000
2020-02-13 00:03:19 -05:00