* [BUG] org-mouse is activated without explicit require
@ 2022-12-11 3:25 Matt Lundin
2022-12-11 3:49 ` Greg Minshall
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Matt Lundin @ 2022-12-11 3:25 UTC (permalink / raw)
To: emacs-orgmode
I'm not too familiar with how emacs handles autoloads. However, I find
org-mouse is automatically loaded if I call describe-function and then
tab complete after typing "", "org-", "org-m", etc. This seems enough to
load the entirely of the org-mouse.el file.
The problem is that this adds a lambda function to org-mode-hook that
activates all org-mouse functionality at the next call of org-mode or
org-mode-restart. This has two unexpected effects:
1. It changes the behavior of mouse clicks without the user's explicit
request.
2. It advise org-open-at-point, with the result that it is no longer
possible to get a list of all links in an entry when calling
org-open-at-point on a headline. (See separate bug report on this.)
I am able to reproduce this with a minimal .emacs config and the most
recent git version (after running "make clean && make").
Steps to reproduce:
1. /usr/bin/emacs -Q -l ~/minimal.el
where ~/minimal.el is...
--8<---------------cut here---------------start------------->8---
(add-to-list 'load-path "~/org-mode/lisp/")
--8<---------------cut here---------------end--------------->8---
2. C-h f org-m [tab]
Note that "org-mouse-" functions appear in the completion list. Even if
one aborts describe-function at this point, org-mouse has been loaded
and org-mode-hook now contains a lambda function to activate the
functionality of org-mouse (org-defkey, advice-add, etc.).
3. Open an org buffer for the first time or call "M-x org-mode-restart"
in an already opened buffer
"C-h v org-open-at-point" now reports the following advice:
--8<---------------cut here---------------start------------->8---
This function has :around advice: ‘org--mouse-open-at-point’.
--8<---------------cut here---------------end--------------->8---
Also notice that org-mouse features are now active in org buffers.
Thanks,
Matt
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [BUG] org-mouse is activated without explicit require
2022-12-11 3:25 [BUG] org-mouse is activated without explicit require Matt Lundin
@ 2022-12-11 3:49 ` Greg Minshall
2022-12-11 4:38 ` Samuel Wales
2022-12-11 9:45 ` Ihor Radchenko
2 siblings, 0 replies; 11+ messages in thread
From: Greg Minshall @ 2022-12-11 3:49 UTC (permalink / raw)
To: Matt Lundin; +Cc: emacs-orgmode
Matt,
> I'm not too familiar with how emacs handles autoloads. However, I find
> org-mouse is automatically loaded if I call describe-function and then
> tab complete after typing "", "org-", "org-m", etc. This seems enough
> to load the entirely of the org-mouse.el file.
i'm also not an expert on autoload, but i noticed this in the e-lisp
info pages:
----
Autoload by Prefix
During completion for the commands ‘describe-variable’ and
‘describe-function’, Emacs will try to load files which may contain
definitions matching the prefix being completed.
----
and, i wonder if that at least explains part of your question.
cheers, Greg
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [BUG] org-mouse is activated without explicit require
2022-12-11 3:25 [BUG] org-mouse is activated without explicit require Matt Lundin
2022-12-11 3:49 ` Greg Minshall
@ 2022-12-11 4:38 ` Samuel Wales
2022-12-11 9:45 ` Ihor Radchenko
2 siblings, 0 replies; 11+ messages in thread
From: Samuel Wales @ 2022-12-11 4:38 UTC (permalink / raw)
To: Matt Lundin; +Cc: emacs-orgmode
hi matt,
superb bug report. happy human rights day.
isn't there a policy someplace in the elisp manual that states that
loading a package should have no major[tm] side effects?
the emacs behavior of loading upon completion is new to me and a
surprise. the org list of links behavior is new to me.
n.b. i personally find org-mouse to a be excellent for accessibility
reasons. i am always either in mouse mode or keyboard mode and it
adds a lot of functionality. could even use a bit more, such as
selecting todo kw.
sorry cannot address your bug further. it does seem there are things
needing fixing.
On 12/10/22, Matt Lundin <mdl@imapmail.org> wrote:
> I'm not too familiar with how emacs handles autoloads. However, I find
> org-mouse is automatically loaded if I call describe-function and then
> tab complete after typing "", "org-", "org-m", etc. This seems enough to
> load the entirely of the org-mouse.el file.
>
> The problem is that this adds a lambda function to org-mode-hook that
> activates all org-mouse functionality at the next call of org-mode or
> org-mode-restart. This has two unexpected effects:
>
> 1. It changes the behavior of mouse clicks without the user's explicit
> request.
> 2. It advise org-open-at-point, with the result that it is no longer
> possible to get a list of all links in an entry when calling
> org-open-at-point on a headline. (See separate bug report on this.)
>
> I am able to reproduce this with a minimal .emacs config and the most
> recent git version (after running "make clean && make").
>
> Steps to reproduce:
>
> 1. /usr/bin/emacs -Q -l ~/minimal.el
>
> where ~/minimal.el is...
>
> --8<---------------cut here---------------start------------->8---
> (add-to-list 'load-path "~/org-mode/lisp/")
> --8<---------------cut here---------------end--------------->8---
>
> 2. C-h f org-m [tab]
>
> Note that "org-mouse-" functions appear in the completion list. Even if
> one aborts describe-function at this point, org-mouse has been loaded
> and org-mode-hook now contains a lambda function to activate the
> functionality of org-mouse (org-defkey, advice-add, etc.).
>
> 3. Open an org buffer for the first time or call "M-x org-mode-restart"
> in an already opened buffer
>
> "C-h v org-open-at-point" now reports the following advice:
>
> --8<---------------cut here---------------start------------->8---
> This function has :around advice: ‘org--mouse-open-at-point’.
> --8<---------------cut here---------------end--------------->8---
>
> Also notice that org-mouse features are now active in org buffers.
>
> Thanks,
>
> Matt
>
>
--
The Kafka Pandemic
A blog about science, health, human rights, and misopathy:
https://thekafkapandemic.blogspot.com
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [BUG] org-mouse is activated without explicit require
2022-12-11 3:25 [BUG] org-mouse is activated without explicit require Matt Lundin
2022-12-11 3:49 ` Greg Minshall
2022-12-11 4:38 ` Samuel Wales
@ 2022-12-11 9:45 ` Ihor Radchenko
2022-12-11 14:49 ` Autoloading side effects (was: Re: [BUG] org-mouse is activated without explicit require) Max Nikulin
2 siblings, 1 reply; 11+ messages in thread
From: Ihor Radchenko @ 2022-12-11 9:45 UTC (permalink / raw)
To: Matt Lundin; +Cc: emacs-orgmode
Matt Lundin <mdl@imapmail.org> writes:
> I'm not too familiar with how emacs handles autoloads. However, I find
> org-mouse is automatically loaded if I call describe-function and then
> tab complete after typing "", "org-", "org-m", etc. This seems enough to
> load the entirely of the org-mouse.el file.
>
> The problem is that this adds a lambda function to org-mode-hook that
> activates all org-mouse functionality at the next call of org-mode or
> org-mode-restart. This has two unexpected effects:
>
> 1. It changes the behavior of mouse clicks without the user's explicit
> request.
> 2. It advise org-open-at-point, with the result that it is no longer
> possible to get a list of all links in an entry when calling
> org-open-at-point on a headline. (See separate bug report on this.)
Confirmed.
We cannot do much about Emacs' handling of autoloads, but what we can
(and should) do is changing org-mouse to become a global minor mode.
Then, loading org-mouse will cause no side effects.
It will be a breaking change though. Not for Org 9.6.
Note that this bug is not new. org-mouse has not been changed for a long
time.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Autoloading side effects (was: Re: [BUG] org-mouse is activated without explicit require)
2022-12-11 9:45 ` Ihor Radchenko
@ 2022-12-11 14:49 ` Max Nikulin
2022-12-12 10:25 ` Ihor Radchenko
2022-12-12 15:42 ` Autoloading side effects (was: Re: [BUG] org-mouse is activated without explicit require) Matt Lundin
0 siblings, 2 replies; 11+ messages in thread
From: Max Nikulin @ 2022-12-11 14:49 UTC (permalink / raw)
To: emacs-orgmode
On 11/12/2022 16:45, Ihor Radchenko wrote:
> We cannot do much about Emacs' handling of autoloads, but what we can
> (and should) do is changing org-mouse to become a global minor mode.
> Then, loading org-mouse will cause no side effects.
I am afraid, requirement that loading should not cause side effects is
too strict and it will make usage inconvenient. Examples:
- ol-info calls `org-link-set-parameters'.
- org-protocol installs an advice for `server-visit-files'. (It should
not be necessary, but currently Emacs does not provide a better option.)
However I agree that it is undesired when attempt to call interactive
help causes side effects. I would say that in such cases loading of
packages should be sandboxed and should not propagate to global scope.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Autoloading side effects (was: Re: [BUG] org-mouse is activated without explicit require)
2022-12-11 14:49 ` Autoloading side effects (was: Re: [BUG] org-mouse is activated without explicit require) Max Nikulin
@ 2022-12-12 10:25 ` Ihor Radchenko
2022-12-12 16:20 ` Max Nikulin
2022-12-12 15:42 ` Autoloading side effects (was: Re: [BUG] org-mouse is activated without explicit require) Matt Lundin
1 sibling, 1 reply; 11+ messages in thread
From: Ihor Radchenko @ 2022-12-12 10:25 UTC (permalink / raw)
To: Max Nikulin; +Cc: emacs-orgmode
Max Nikulin <manikulin@gmail.com> writes:
> On 11/12/2022 16:45, Ihor Radchenko wrote:
>> We cannot do much about Emacs' handling of autoloads, but what we can
>> (and should) do is changing org-mouse to become a global minor mode.
>> Then, loading org-mouse will cause no side effects.
>
> I am afraid, requirement that loading should not cause side effects is
> too strict and it will make usage inconvenient. Examples:
> - ol-info calls `org-link-set-parameters'.
We have `org-modules' that can handle calling `org-link-set-parameters'.
> - org-protocol installs an advice for `server-visit-files'. (It should
> not be necessary, but currently Emacs does not provide a better option.)
Can we ask Emacs devs to help us with this problem?
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Autoloading side effects (was: Re: [BUG] org-mouse is activated without explicit require)
2022-12-12 10:25 ` Ihor Radchenko
@ 2022-12-12 16:20 ` Max Nikulin
2022-12-13 9:52 ` Ihor Radchenko
0 siblings, 1 reply; 11+ messages in thread
From: Max Nikulin @ 2022-12-12 16:20 UTC (permalink / raw)
To: emacs-orgmode
On 12/12/2022 17:25, Ihor Radchenko wrote:
> Max Nikulin writes:
>>
>> I am afraid, requirement that loading should not cause side effects is
>> too strict and it will make usage inconvenient. Examples:
>> - ol-info calls `org-link-set-parameters'.
>
> We have `org-modules' that can handle calling `org-link-set-parameters'.
Sorry, but I have not got your idea. Currently `org-modules' is just a
list of packages that should be loaded with org.el.
It is possible to introduce some convention either in Org or in Emacs to
add default action for a package. Then in addition to just loading a
package (with no side effects) a set of functions should be implemented
that loads and *activates* the package.
>> - org-protocol installs an advice for `server-visit-files'. (It should
>> not be necessary, but currently Emacs does not provide a better option.)
>
> Can we ask Emacs devs to help us with this problem?
org-protocol may use approach similar to emacsclient-mail.desktop
without advice:
Exec=sh -c "exec emacsclient --alternate-editor=
--display=\\"\\$DISPLAY\\" --eval \\\\(message-mailto\\\\
\\\\\\"%u\\\\\\"\\\\)"
By adding another bunch of backslashes and a bit more complex shell
command it is possible to avoid at least obvious issues with the command
above.
Actually I have created
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=59743
Implement `command-line-args-left' for emacsclient --eval expressions
but I was too late to the party. The discussion in
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=57752
28.1.91; emacsclient-mail.desktop doesn't work for me
was stalled with no outcome.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Autoloading side effects (was: Re: [BUG] org-mouse is activated without explicit require)
2022-12-12 16:20 ` Max Nikulin
@ 2022-12-13 9:52 ` Ihor Radchenko
2022-12-13 14:32 ` [BUG] org-mouse is activated without explicit require Max Nikulin
0 siblings, 1 reply; 11+ messages in thread
From: Ihor Radchenko @ 2022-12-13 9:52 UTC (permalink / raw)
To: Max Nikulin; +Cc: emacs-orgmode
Max Nikulin <manikulin@gmail.com> writes:
>> We have `org-modules' that can handle calling `org-link-set-parameters'.
>
> Sorry, but I have not got your idea. Currently `org-modules' is just a
> list of packages that should be loaded with org.el.
>
> It is possible to introduce some convention either in Org or in Emacs to
> add default action for a package. Then in addition to just loading a
> package (with no side effects) a set of functions should be implemented
> that loads and *activates* the package.
We can simply process 'ol-* in `org-modules' specially.
Although, I am not having second thoughts about behaviour of require.
The original issue reported in this thread is actually strange - we have
no single autoload cookie in org-mouse.el. May it be something to do
with the new Emacs autoload generation?
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [BUG] org-mouse is activated without explicit require
2022-12-13 9:52 ` Ihor Radchenko
@ 2022-12-13 14:32 ` Max Nikulin
2022-12-14 9:59 ` Ihor Radchenko
0 siblings, 1 reply; 11+ messages in thread
From: Max Nikulin @ 2022-12-13 14:32 UTC (permalink / raw)
To: emacs-orgmode
On 13/12/2022 16:52, Ihor Radchenko wrote:
> Max Nikulin writes:
>
>>> We have `org-modules' that can handle calling `org-link-set-parameters'.
...> We can simply process 'ol-* in `org-modules' specially.
I do not consider it is a good idea. Third party packages may call
`org-link-set-parameters' as well. That is why I would prefer a more
general approach of package activation.
> The original issue reported in this thread is actually strange - we have
> no single autoload cookie in org-mouse.el. May it be something to do
> with the new Emacs autoload generation?
I do not think it is something new. Even in Emacs-26
`generate-file-autoloads' adds
(if (fboundp 'register-definition-prefixes)
(register-definition-prefixes "org-mouse" '("org-")))
to org-loaddefs.el. The function is called for all sources by
`org-make-org-loaddefs' (defined in mk/org-fixup.el).
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [BUG] org-mouse is activated without explicit require
2022-12-13 14:32 ` [BUG] org-mouse is activated without explicit require Max Nikulin
@ 2022-12-14 9:59 ` Ihor Radchenko
0 siblings, 0 replies; 11+ messages in thread
From: Ihor Radchenko @ 2022-12-14 9:59 UTC (permalink / raw)
To: Max Nikulin; +Cc: emacs-orgmode
Max Nikulin <manikulin@gmail.com> writes:
> On 13/12/2022 16:52, Ihor Radchenko wrote:
>> Max Nikulin writes:
>>
>>>> We have `org-modules' that can handle calling `org-link-set-parameters'.
> ...> We can simply process 'ol-* in `org-modules' specially.
>
> I do not consider it is a good idea. Third party packages may call
> `org-link-set-parameters' as well. That is why I would prefer a more
> general approach of package activation.
In this particular case, manual loading might actually be an advantage:
each call to `org-link-set-parameters' updates Org syntax, causing a
bunch of regexp re-calculations. The end result is slower Org loading.
If we could load multiple ol-* modules together, things could be made
faster.
I am not concerned about loading third-party packages here.
We cannot do more general approach anyway as long as we support older
Emacs.
However, we might suggest the general loading mechanism to Emacs devel.
Do you think it would be worth it?
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Autoloading side effects (was: Re: [BUG] org-mouse is activated without explicit require)
2022-12-11 14:49 ` Autoloading side effects (was: Re: [BUG] org-mouse is activated without explicit require) Max Nikulin
2022-12-12 10:25 ` Ihor Radchenko
@ 2022-12-12 15:42 ` Matt Lundin
1 sibling, 0 replies; 11+ messages in thread
From: Matt Lundin @ 2022-12-12 15:42 UTC (permalink / raw)
To: Max Nikulin, emacs-orgmode
Max Nikulin <manikulin@gmail.com> writes:
> I am afraid, requirement that loading should not cause side effects is
> too strict and it will make usage inconvenient. Examples:
> - ol-info calls `org-link-set-parameters'.
> - org-protocol installs an advice for `server-visit-files'. (It should
> not be necessary, but currently Emacs does not provide a better option.)
>
> However I agree that it is undesired when attempt to call interactive
> help causes side effects. I would say that in such cases loading of
> packages should be sandboxed and should not propagate to global scope.
For reference, another module that causes global side effects when
calling interactive help is org-ctags.el. It advises `visit-tags-table`
and `xref-find-definitions` and adds a hook to `org-mode-hook`.
Matt
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2022-12-14 10:00 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-11 3:25 [BUG] org-mouse is activated without explicit require Matt Lundin
2022-12-11 3:49 ` Greg Minshall
2022-12-11 4:38 ` Samuel Wales
2022-12-11 9:45 ` Ihor Radchenko
2022-12-11 14:49 ` Autoloading side effects (was: Re: [BUG] org-mouse is activated without explicit require) Max Nikulin
2022-12-12 10:25 ` Ihor Radchenko
2022-12-12 16:20 ` Max Nikulin
2022-12-13 9:52 ` Ihor Radchenko
2022-12-13 14:32 ` [BUG] org-mouse is activated without explicit require Max Nikulin
2022-12-14 9:59 ` Ihor Radchenko
2022-12-12 15:42 ` Autoloading side effects (was: Re: [BUG] org-mouse is activated without explicit require) Matt Lundin
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).