Is require
idempotent? i.e. do
(require 'helm)
and
(require 'helm)
(require 'helm)
end with the same result?
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.
Sign up to join this communityYes. From Named Features (emphasis mine):
A feature name is a symbol that stands for a collection of functions, variables, etc. The file that defines them should provide the feature. Another program that uses them may ensure they are defined by requiring the feature. This loads the file of definitions if it hasn't been loaded already.
To require the presence of a feature, call
require
with the feature name as argument.require
looks in the global variablefeatures
to see whether the desired feature has been provided already. If not, it loads the feature from the appropriate file. This file should callprovide
at the top level to add the feature tofeatures
; if it fails to do so,require
signals an error.
Yes, provided that the code in helm.el
or helm.elc
respects the rule that it must call (provide 'helm)
. The call (provide 'helm)
marks the symbol helm
as a loaded feature, and this causes the second call to (require 'helm)
to do nothing.
If the loaded package does not call provide
then require
signals an error, and the feature is not marked as loaded, so a second call to (require 'helm)
would attempt the loading again (and typically fail again for the same reason).