Re: Autoloading side effects (was: Re: [BUG] org-mouse is activated without explicit require)

2022-12-13 Thread Ihor Radchenko
Max Nikulin  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 .
Support Org development at ,
or support my work at 



Re: Autoloading side effects (was: Re: [BUG] org-mouse is activated without explicit require)

2022-12-12 Thread Max Nikulin

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.




Re: Autoloading side effects (was: Re: [BUG] org-mouse is activated without explicit require)

2022-12-12 Thread Matt Lundin
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'.
> - 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



Re: Autoloading side effects (was: Re: [BUG] org-mouse is activated without explicit require)

2022-12-12 Thread Ihor Radchenko
Max Nikulin  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 .
Support Org development at ,
or support my work at 



Autoloading side effects (was: Re: [BUG] org-mouse is activated without explicit require)

2022-12-11 Thread Max Nikulin

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.