emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Loading a package applies automatically to future sessions?


From: Clément Pit-Claudel
Subject: Re: Loading a package applies automatically to future sessions?
Date: Thu, 1 Feb 2018 22:05:48 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0

On 2018-02-01 21:14, Richard Stallman wrote:
> [[[ To any NSA and FBI agents reading my email: please consider    ]]]
> [[[ whether defending the US Constitution against all enemies,     ]]]
> [[[ foreign or domestic, requires you to follow Snowden's example. ]]]
> 
>   > I think things already work the way users expect. Let's look at
>   > Python. When you install a package using 'pip', the package files are
>   > placed on Python's search path. Thereafter, 'import <package>' works
>   > without any further "activation" step. The package is automatically
>   > made available in future sessions, although it is not loaded until
>   > requested.
> 
> In Python, once a package is on the search path, the user needs to
> give a specific command to make it callable from a given module.
> 
> I think Emacs should work the same way.

There may be a misunderstanding.  Emacs already works in (mostly) the same way: 
Emacs' `require' is very close to Python's `import'.

> If I understood correctly, it is currently NOT the same, because in
> Emacs the package doesn't require any command to make the package
> callable.  Simply getting it from ELPA makes it callable _all the time_.

No, this isn't quite right.  For example, if package foo has a function foo-x, 
you will need (in most cases) to (require 'foo) before you can call foo-x.

There are some differences, but they are small:

* `require' works globally in Emacs, so once package foo is `require'd in one 
file, all subsequently executed code can call foo-x, without calling (require 
'foo) again.  This is why packages that are in loaded in temacs and dumped 
don't need to be `require'd.

* Emacs has autoloads, small pieces of code from packages that are run 
inconditionally.  Autoloads are what makes it possible to call certain 
functions without requiring the corresponding package first.  In spirit, this 
is very similar to Python's `pth' files.  Autoload files are a performance 
issue in some cases, because there are many of them (although each is fairly 
small). Stefan's patch makes them much faster.

Hope this helps,
Clément.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]