all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Add code from other files
@ 2024-07-03 23:44 uzibalqa
       [not found] ` <6d098cab-1a96-4eb7-a4c3-1a4cf0fb3270@starynkevitch.net>
  0 siblings, 1 reply; 12+ messages in thread
From: uzibalqa @ 2024-07-03 23:44 UTC (permalink / raw)
  To: uzibalqa via Users list for the GNU Emacs text editor


I have a file and want to add the code from other files to it.  What does one do ?




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Add code from other files
       [not found]       ` <SxRPEQkups5RAB4wfD8msM9ggAwSxaOuYjUV59-Pxcn5TgvbJgDPPqP1zLvhdl6zG3K-7t_YaVzemmmdxMwUh3avOOXJALTilqiHvtdbVnU=@proton.me>
@ 2024-07-04 12:10         ` uzibalqa
  2024-07-04 17:16           ` uzibalqa
  0 siblings, 1 reply; 12+ messages in thread
From: uzibalqa @ 2024-07-04 12:10 UTC (permalink / raw)
  To: uzibalqa via Users list for the GNU Emacs text editor

On Thursday, July 4th, 2024 at 11:19 AM, uzibalqa <uzibalqa@proton.me> wrote:

> On Thursday, July 4th, 2024 at 11:11 AM, Basile Starynkevitch basile@starynkevitch.net wrote:
> 
> > On 7/4/24 13:03, uzibalqa wrote:
> > 
> > > On Thursday, July 4th, 2024 at 3:49 AM, Basile Starynkevitch basile@starynkevitch.net wrote:
> > > 
> > > > On 7/4/24 01:44, uzibalqa wrote:
> > > > 
> > > > > I have a file and want to add the code from other files to it. What does one do ?
> > > > 
> > > > You should explain more. Are you thinking of Elisp code? GNU emacs can
> > > > be used to edit non-code files (eg LaTeX documents)
> > > > 
> > > > --
> > > > Basile STARYNKEVITCH basile@starynkevitch.net
> > > > I have an elisp file and want to include the functionality present in another .el file.
> > 
> > Can't you use the load primitive function of Elisp
> > 
> > > load is a primitive-function in ‘C source code’.
> > > 
> > > (load FILE &optional NOERROR NOMESSAGE NOSUFFIX MUST-SUFFIX)
> > > 
> > > Execute a file of Lisp code named FILE.
> > > First try FILE with ‘.elc’ appended, then try with ‘.el’, then try
> > > with a system-dependent suffix of dynamic modules (see ‘load-suffixes’),
> > > then try FILE unmodified (the exact suffixes in the exact order are
> > > determined by ‘load-suffixes’). Environment variable references in
> > > FILE are replaced with their values by calling ‘substitute-in-file-name’.
> > > This function searches the directories in ‘load-path’.
> > > 
> > > If optional second arg NOERROR is non-nil,
> > > report no error if FILE doesn’t exist.
> > > Print messages at start and end of loading unless
> > > optional third arg NOMESSAGE is non-nil (but ‘force-load-messages’
> > > overrides that).
> > > If optional fourth arg NOSUFFIX is non-nil, don’t try adding
> > > suffixes to the specified name FILE.
> > > If optional fifth arg MUST-SUFFIX is non-nil, insist on
> > > the suffix ‘.elc’ or ‘.el’ or the module suffix; don’t accept just
> > > FILE unless it ends in one of those suffixes or includes a directory name.
> > > 
> > > If NOSUFFIX is nil, then if a file could not be found, try looking for
> > > a different representation of the file by adding non-empty suffixes to
> > > its name, before trying another file. Emacs uses this feature to find
> > > compressed versions of files when Auto Compression mode is enabled.
> > > If NOSUFFIX is non-nil, disable this feature.
> > > 
> > > The suffixes that this function tries out, when NOSUFFIX is nil, are
> > > given by the return value of ‘get-load-suffixes’ and the values listed
> > > in ‘load-file-rep-suffixes’. If MUST-SUFFIX is non-nil, only the
> > > return value of ‘get-load-suffixes’ is used, i.e. the file name is
> > > required to have a non-empty suffix.
> > > 
> > > When searching suffixes, this function normally stops at the first
> > > one that exists. If the option ‘load-prefer-newer’ is non-nil,
> > > however, it tries all suffixes, and uses whichever file is the newest.
> > > 
> > > Loading a file records its definitions, and its ‘provide’ and
> > > ‘require’ calls, in an element of ‘load-history’ whose
> > > car is the file name loaded. See ‘load-history’.
> > > 
> > > While the file is in the process of being loaded, the variable
> > > ‘load-in-progress’ is non-nil and the variable ‘load-file-name’
> > > is bound to the file’s name.
> > > 
> > > Return t if the file exists and loads successfully.
> > > 
> > > Probably introduced at or before Emacs version 1.1.
 
 
What are the 'provide' and 'require' calls and should I use them ?
When is it appropriate to use 'load'. A useful feature of load is
that prints messages at start and end of loading.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Add code from other files
  2024-07-04 12:10         ` uzibalqa
@ 2024-07-04 17:16           ` uzibalqa
  2024-07-04 17:32             ` uzibalqa
  2024-07-04 19:57             ` Emanuel Berg
  0 siblings, 2 replies; 12+ messages in thread
From: uzibalqa @ 2024-07-04 17:16 UTC (permalink / raw)
  To: uzibalqa; +Cc: uzibalqa via Users list for the GNU Emacs text editor


On Thursday, July 4th, 2024 at 12:10 PM, uzibalqa <uzibalqa@proton.me> wrote:

> On Thursday, July 4th, 2024 at 11:19 AM, uzibalqa uzibalqa@proton.me wrote:
> 
> > On Thursday, July 4th, 2024 at 11:11 AM, Basile Starynkevitch basile@starynkevitch.net wrote:
> > 
> > > On 7/4/24 13:03, uzibalqa wrote:
> > > 
> > > > On Thursday, July 4th, 2024 at 3:49 AM, Basile Starynkevitch basile@starynkevitch.net wrote:
> > > > 
> > > > > On 7/4/24 01:44, uzibalqa wrote:
> > > > > 
> > > > > > I have a file and want to add the code from other files to it. What does one do ?
> > > > > 
> > > > > You should explain more. Are you thinking of Elisp code? GNU emacs can
> > > > > be used to edit non-code files (eg LaTeX documents)
> > > > > 
> > > > > --
> > > > > Basile STARYNKEVITCH basile@starynkevitch.net
> > > > > I have an elisp file and want to include the functionality present in another .el file.
> > > 
> > > Can't you use the load primitive function of Elisp
> > > 
> > > > load is a primitive-function in ‘C source code’.
> > > > 
> > > > (load FILE &optional NOERROR NOMESSAGE NOSUFFIX MUST-SUFFIX)
> > > > 
> > > > Execute a file of Lisp code named FILE.
> > > > First try FILE with ‘.elc’ appended, then try with ‘.el’, then try
> > > > with a system-dependent suffix of dynamic modules (see ‘load-suffixes’),
> > > > then try FILE unmodified (the exact suffixes in the exact order are
> > > > determined by ‘load-suffixes’). Environment variable references in
> > > > FILE are replaced with their values by calling ‘substitute-in-file-name’.
> > > > This function searches the directories in ‘load-path’.
> > > > 
> > > > If optional second arg NOERROR is non-nil,
> > > > report no error if FILE doesn’t exist.
> > > > Print messages at start and end of loading unless
> > > > optional third arg NOMESSAGE is non-nil (but ‘force-load-messages’
> > > > overrides that).
> > > > If optional fourth arg NOSUFFIX is non-nil, don’t try adding
> > > > suffixes to the specified name FILE.
> > > > If optional fifth arg MUST-SUFFIX is non-nil, insist on
> > > > the suffix ‘.elc’ or ‘.el’ or the module suffix; don’t accept just
> > > > FILE unless it ends in one of those suffixes or includes a directory name.
> > > > 
> > > > If NOSUFFIX is nil, then if a file could not be found, try looking for
> > > > a different representation of the file by adding non-empty suffixes to
> > > > its name, before trying another file. Emacs uses this feature to find
> > > > compressed versions of files when Auto Compression mode is enabled.
> > > > If NOSUFFIX is non-nil, disable this feature.
> > > > 
> > > > The suffixes that this function tries out, when NOSUFFIX is nil, are
> > > > given by the return value of ‘get-load-suffixes’ and the values listed
> > > > in ‘load-file-rep-suffixes’. If MUST-SUFFIX is non-nil, only the
> > > > return value of ‘get-load-suffixes’ is used, i.e. the file name is
> > > > required to have a non-empty suffix.
> > > > 
> > > > When searching suffixes, this function normally stops at the first
> > > > one that exists. If the option ‘load-prefer-newer’ is non-nil,
> > > > however, it tries all suffixes, and uses whichever file is the newest.
> > > > 
> > > > Loading a file records its definitions, and its ‘provide’ and
> > > > ‘require’ calls, in an element of ‘load-history’ whose
> > > > car is the file name loaded. See ‘load-history’.
> > > > 
> > > > While the file is in the process of being loaded, the variable
> > > > ‘load-in-progress’ is non-nil and the variable ‘load-file-name’
> > > > is bound to the file’s name.
> > > > 
> > > > Return t if the file exists and loads successfully.
> > > > 
> > > > Probably introduced at or before Emacs version 1.1.
> 
> 
> 
> What are the 'provide' and 'require' calls and should I use them ?
> When is it appropriate to use 'load'. A useful feature of load is
> that prints messages at start and end of loading.

I have a main file and three auxiliary files.  I can use `load` for the auxiliary 
files and use `provide` for the main file.  Would this be the correct approach ?





^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Add code from other files
  2024-07-04 17:16           ` uzibalqa
@ 2024-07-04 17:32             ` uzibalqa
  2024-07-04 19:57             ` Emanuel Berg
  1 sibling, 0 replies; 12+ messages in thread
From: uzibalqa @ 2024-07-04 17:32 UTC (permalink / raw)
  To: uzibalqa; +Cc: uzibalqa via Users list for the GNU Emacs text editor






Sent with Proton Mail secure email.

On Thursday, July 4th, 2024 at 5:16 PM, uzibalqa <uzibalqa@proton.me> wrote:

> On Thursday, July 4th, 2024 at 12:10 PM, uzibalqa uzibalqa@proton.me wrote:
> 
> > On Thursday, July 4th, 2024 at 11:19 AM, uzibalqa uzibalqa@proton.me wrote:
> > 
> > > On Thursday, July 4th, 2024 at 11:11 AM, Basile Starynkevitch basile@starynkevitch.net wrote:
> > > 
> > > > On 7/4/24 13:03, uzibalqa wrote:
> > > > 
> > > > > On Thursday, July 4th, 2024 at 3:49 AM, Basile Starynkevitch basile@starynkevitch.net wrote:
> > > > > 
> > > > > > On 7/4/24 01:44, uzibalqa wrote:
> > > > > > 
> > > > > > > I have a file and want to add the code from other files to it. What does one do ?
> > > > > > 
> > > > > > You should explain more. Are you thinking of Elisp code? GNU emacs can
> > > > > > be used to edit non-code files (eg LaTeX documents)
> > > > > > 
> > > > > > --
> > > > > > Basile STARYNKEVITCH basile@starynkevitch.net
> > > > > > I have an elisp file and want to include the functionality present in another .el file.
> > > > 
> > > > Can't you use the load primitive function of Elisp
> > > > 
> > > > > load is a primitive-function in ‘C source code’.
> > > > > 
> > > > > (load FILE &optional NOERROR NOMESSAGE NOSUFFIX MUST-SUFFIX)
> > > > > 
> > > > > Execute a file of Lisp code named FILE.
> > > > > First try FILE with ‘.elc’ appended, then try with ‘.el’, then try
> > > > > with a system-dependent suffix of dynamic modules (see ‘load-suffixes’),
> > > > > then try FILE unmodified (the exact suffixes in the exact order are
> > > > > determined by ‘load-suffixes’). Environment variable references in
> > > > > FILE are replaced with their values by calling ‘substitute-in-file-name’.
> > > > > This function searches the directories in ‘load-path’.
> > > > > 
> > > > > If optional second arg NOERROR is non-nil,
> > > > > report no error if FILE doesn’t exist.
> > > > > Print messages at start and end of loading unless
> > > > > optional third arg NOMESSAGE is non-nil (but ‘force-load-messages’
> > > > > overrides that).
> > > > > If optional fourth arg NOSUFFIX is non-nil, don’t try adding
> > > > > suffixes to the specified name FILE.
> > > > > If optional fifth arg MUST-SUFFIX is non-nil, insist on
> > > > > the suffix ‘.elc’ or ‘.el’ or the module suffix; don’t accept just
> > > > > FILE unless it ends in one of those suffixes or includes a directory name.
> > > > > 
> > > > > If NOSUFFIX is nil, then if a file could not be found, try looking for
> > > > > a different representation of the file by adding non-empty suffixes to
> > > > > its name, before trying another file. Emacs uses this feature to find
> > > > > compressed versions of files when Auto Compression mode is enabled.
> > > > > If NOSUFFIX is non-nil, disable this feature.
> > > > > 
> > > > > The suffixes that this function tries out, when NOSUFFIX is nil, are
> > > > > given by the return value of ‘get-load-suffixes’ and the values listed
> > > > > in ‘load-file-rep-suffixes’. If MUST-SUFFIX is non-nil, only the
> > > > > return value of ‘get-load-suffixes’ is used, i.e. the file name is
> > > > > required to have a non-empty suffix.
> > > > > 
> > > > > When searching suffixes, this function normally stops at the first
> > > > > one that exists. If the option ‘load-prefer-newer’ is non-nil,
> > > > > however, it tries all suffixes, and uses whichever file is the newest.
> > > > > 
> > > > > Loading a file records its definitions, and its ‘provide’ and
> > > > > ‘require’ calls, in an element of ‘load-history’ whose
> > > > > car is the file name loaded. See ‘load-history’.
> > > > > 
> > > > > While the file is in the process of being loaded, the variable
> > > > > ‘load-in-progress’ is non-nil and the variable ‘load-file-name’
> > > > > is bound to the file’s name.
> > > > > 
> > > > > Return t if the file exists and loads successfully.
> > > > > 
> > > > > Probably introduced at or before Emacs version 1.1.
> > 
> > What are the 'provide' and 'require' calls and should I use them ?
> > When is it appropriate to use 'load'. A useful feature of load is
> > that prints messages at start and end of loading.

I have a main file and three auxiliary files. I can use `load` for the auxiliary
files and use `provide` for the main file. Would this be the correct approach ?

This approach ensures that all auxiliary files are loaded when the main file is loaded, 
and that the main file can be required as a single unit.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Add code from other files
  2024-07-04 17:16           ` uzibalqa
  2024-07-04 17:32             ` uzibalqa
@ 2024-07-04 19:57             ` Emanuel Berg
  2024-07-04 21:28               ` uzibalqa
  2024-07-04 21:32               ` [External] : " Drew Adams
  1 sibling, 2 replies; 12+ messages in thread
From: Emanuel Berg @ 2024-07-04 19:57 UTC (permalink / raw)
  To: help-gnu-emacs

uzibalqa wrote:

> I have a main file and three auxiliary files. I can use
> `load` for the auxiliary files and use `provide` for the
> main file. Would this be the correct approach ?

Use `provide' downmost in all your files, and whenever one
function is needed in some other file, you `require' that file
first (topmost) in THAT file.

Is a good way to do it.

If you byte-compile it will tell you, if some file uses
something not defined in that file, and also not require'd
from another where it is.

So you can both find bugs that way and find out what needs to
be required by what.

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Add code from other files
  2024-07-04 19:57             ` Emanuel Berg
@ 2024-07-04 21:28               ` uzibalqa
  2024-07-04 21:50                 ` Emanuel Berg
  2024-07-04 21:32               ` [External] : " Drew Adams
  1 sibling, 1 reply; 12+ messages in thread
From: uzibalqa @ 2024-07-04 21:28 UTC (permalink / raw)
  To: Emanuel Berg; +Cc: help-gnu-emacs

On Thursday, July 4th, 2024 at 7:57 PM, Emanuel Berg <incal@dataswamp.org> wrote:

> uzibalqa wrote:
> 
> > I have a main file and three auxiliary files. I can use
> > `load` for the auxiliary files and use `provide` for the
> > main file. Would this be the correct approach ?
> 
> 
> Use `provide' downmost in all your files, and whenever one function
> is needed in some other file, you` require' that file first (topmost) 
> in THAT file.
> 
> Is a good way to do it.

So most of my auxiliary tools to a package will have (provide 'this-tool)
Then at the start of my package I have (require 'this-tool).
 
> If you byte-compile it will tell you, if some file uses
> something not defined in that file, and also not require'd
> from another where it is.

I do not understand the second comment "telling me if some file uses
something not require'd from another where it is".  What does that mean ?

What is then the role of load ?

> So you can both find bugs that way and find out what needs to
> be required by what.
> 
> --
> underground experts united
> https://dataswamp.org/~incal





^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: [External] : Re: Add code from other files
  2024-07-04 19:57             ` Emanuel Berg
  2024-07-04 21:28               ` uzibalqa
@ 2024-07-04 21:32               ` Drew Adams
  2024-07-04 22:07                 ` uzibalqa
  1 sibling, 1 reply; 12+ messages in thread
From: Drew Adams @ 2024-07-04 21:32 UTC (permalink / raw)
  To: Emanuel Berg, help-gnu-emacs@gnu.org

> Use `provide' downmost in all your files, and whenever one
> function is needed in some other file, you `require' that file
> first (topmost) in THAT file.
> 
> Is a good way to do it.
> 
> If you byte-compile it will tell you, if some file uses
> something not defined in that file, and also not require'd
> from another where it is.
> 
> So you can both find bugs that way and find out what needs to
> be required by what.

In addition, there's this case (not too common),
mentioned in (elisp) `Named Features':

   Although top-level calls to 'require' are evaluated
 during byte compilation, 'provide' calls are not.
 Therefore, you can ensure that a file of definitions
 is loaded before it is byte-compiled by including a
 'provide' followed by a 'require' for the same feature,
 as in the following example.

     (provide 'my-feature)  ; Ignored by byte compiler,
                            ;   evaluated by 'load'.
     (require 'my-feature)  ; Evaluated by byte compiler.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Add code from other files
  2024-07-04 21:28               ` uzibalqa
@ 2024-07-04 21:50                 ` Emanuel Berg
  0 siblings, 0 replies; 12+ messages in thread
From: Emanuel Berg @ 2024-07-04 21:50 UTC (permalink / raw)
  To: help-gnu-emacs

uzibalqa wrote:

>> Use `provide' downmost in all your files, and whenever one
>> function is needed in some other file, you` require' that
>> file first (topmost) in THAT file.
>> 
>> Is a good way to do it.
>
> So most of my auxiliary tools to a package will have
> (provide 'this-tool) Then at the start of my package I have
> (require 'this-tool).

Yes, do that to all files. They provide themselves last and
require all they need - well, before they use it! They don't
have to be topmost but it looks neat. ABC order is optional :)

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: [External] : Re: Add code from other files
  2024-07-04 21:32               ` [External] : " Drew Adams
@ 2024-07-04 22:07                 ` uzibalqa
  2024-07-04 23:20                   ` uzibalqa
  0 siblings, 1 reply; 12+ messages in thread
From: uzibalqa @ 2024-07-04 22:07 UTC (permalink / raw)
  To: Drew Adams; +Cc: Emanuel Berg, help-gnu-emacs@gnu.org

On Thursday, July 4th, 2024 at 9:32 PM, Drew Adams <drew.adams@oracle.com> wrote:

> > Use `provide' downmost in all your files, and whenever one function is needed in some other file, you` require' that file
> > first (topmost) in THAT file.
> > 
> > Is a good way to do it.
> > 
> > If you byte-compile it will tell you, if some file uses
> > something not defined in that file, and also not require'd
> > from another where it is.
> > 
> > So you can both find bugs that way and find out what needs to
> > be required by what.
> 
> 
> In addition, there's this case (not too common),
> mentioned in (elisp) `Named Features':
> 
> Although top-level calls to 'require' are evaluated
> during byte compilation, 'provide' calls are not.
> Therefore, you can ensure that a file of definitions
> is loaded before it is byte-compiled by including a
> 'provide' followed by a 'require' for the same feature,
> as in the following example.
> 
> (provide 'my-feature) ; Ignored by byte compiler,
> ; evaluated by 'load'.
> (require 'my-feature) ; Evaluated by byte compiler.

Please do not complicate my life.  Do I really need to use this not too 
common case ?




^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: [External] : Re: Add code from other files
  2024-07-04 22:07                 ` uzibalqa
@ 2024-07-04 23:20                   ` uzibalqa
  2024-07-05  0:12                     ` Emanuel Berg
  2024-07-05 19:59                     ` uzibalqa
  0 siblings, 2 replies; 12+ messages in thread
From: uzibalqa @ 2024-07-04 23:20 UTC (permalink / raw)
  To: uzibalqa; +Cc: Drew Adams, Emanuel Berg, help-gnu-emacs@gnu.org


On Thursday, July 4th, 2024 at 10:07 PM, uzibalqa <uzibalqa@proton.me> wrote:

> On Thursday, July 4th, 2024 at 9:32 PM, Drew Adams drew.adams@oracle.com wrote:
> 
> > > Use `provide' downmost in all your files, and whenever one function is needed in some other file, you` require' that file
> > > first (topmost) in THAT file.
> > > 
> > > Is a good way to do it.
> > > 
> > > If you byte-compile it will tell you, if some file uses
> > > something not defined in that file, and also not require'd
> > > from another where it is.
> > > 
> > > So you can both find bugs that way and find out what needs to
> > > be required by what.
> > 
> > In addition, there's this case (not too common),
> > mentioned in (elisp) `Named Features':
> > 
> > Although top-level calls to 'require' are evaluated
> > during byte compilation, 'provide' calls are not.
> > Therefore, you can ensure that a file of definitions
> > is loaded before it is byte-compiled by including a
> > 'provide' followed by a 'require' for the same feature,
> > as in the following example.
> > 
> > (provide 'my-feature) ; Ignored by byte compiler,
> > ; evaluated by 'load'.
> > (require 'my-feature) ; Evaluated by byte compiler.
> 
> 
> Please do not complicate my life. Do I really need to use this not too
> common case ?

Can someone explain to me why I should not use `load` ?  What is load useful for,
but not useful in my case ?




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [External] : Re: Add code from other files
  2024-07-04 23:20                   ` uzibalqa
@ 2024-07-05  0:12                     ` Emanuel Berg
  2024-07-05 19:59                     ` uzibalqa
  1 sibling, 0 replies; 12+ messages in thread
From: Emanuel Berg @ 2024-07-05  0:12 UTC (permalink / raw)
  To: help-gnu-emacs

uzibalqa wrote:

> Can someone explain to me why I should not use `load` ?
> What is load useful for, but not useful in my case ?

Maybe `load' always loads an arbitrary file, while `require'
only loads it when it is provided and not already loaded.

It should be mentioned in the docstrings?

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: [External] : Re: Add code from other files
  2024-07-04 23:20                   ` uzibalqa
  2024-07-05  0:12                     ` Emanuel Berg
@ 2024-07-05 19:59                     ` uzibalqa
  1 sibling, 0 replies; 12+ messages in thread
From: uzibalqa @ 2024-07-05 19:59 UTC (permalink / raw)
  To: uzibalqa; +Cc: Drew Adams, Emanuel Berg, help-gnu-emacs@gnu.org

On Thursday, July 4th, 2024 at 11:20 PM, uzibalqa <uzibalqa@proton.me> wrote:

> On Thursday, July 4th, 2024 at 10:07 PM, uzibalqa uzibalqa@proton.me wrote:
> 
> > On Thursday, July 4th, 2024 at 9:32 PM, Drew Adams drew.adams@oracle.com wrote:
> > 
> > > > Use `provide' downmost in all your files, and whenever one function is needed in some other file, you` require' that file
> > > > first (topmost) in THAT file.
> > > > 
> > > > Is a good way to do it.
> > > > 
> > > > If you byte-compile it will tell you, if some file uses
> > > > something not defined in that file, and also not require'd
> > > > from another where it is.
> > > > 
> > > > So you can both find bugs that way and find out what needs to
> > > > be required by what.
> > > 
> > > In addition, there's this case (not too common),
> > > mentioned in (elisp) `Named Features':
> > > 
> > > Although top-level calls to 'require' are evaluated
> > > during byte compilation, 'provide' calls are not.
> > > Therefore, you can ensure that a file of definitions
> > > is loaded before it is byte-compiled by including a
> > > 'provide' followed by a 'require' for the same feature,
> > > as in the following example.
> > > 
> > > (provide 'my-feature) ; Ignored by byte compiler,
> > > ; evaluated by 'load'.
> > > (require 'my-feature) ; Evaluated by byte compiler.
> > 
> > Please do not complicate my life. Do I really need to use this not too
> > common case ?
> 
> Can someone explain to me why I should not use `load` ? What is load useful for,
> but not useful in my case ?

From what I could find,  the 'require' function is generally preferred over 'load' 
to avoid duplicate loading.  Still, the auxiliary files will only be used by the 
master file and not in other places.




^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2024-07-05 19:59 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-03 23:44 Add code from other files uzibalqa
     [not found] ` <6d098cab-1a96-4eb7-a4c3-1a4cf0fb3270@starynkevitch.net>
     [not found]   ` <V97NPYqXKDP9XylZkSZkh_dbBhS_SXc-ezIV4g8yCaobeMBzi1PSGBdP_G-h1WeRu0XUm-K_jVE9BefEr63O8ceF3tJ3hxj-38oe3fagwTU=@proton.me>
     [not found]     ` <2fa9f251-0c84-46b5-9a88-b525eb79a413@starynkevitch.net>
     [not found]       ` <SxRPEQkups5RAB4wfD8msM9ggAwSxaOuYjUV59-Pxcn5TgvbJgDPPqP1zLvhdl6zG3K-7t_YaVzemmmdxMwUh3avOOXJALTilqiHvtdbVnU=@proton.me>
2024-07-04 12:10         ` uzibalqa
2024-07-04 17:16           ` uzibalqa
2024-07-04 17:32             ` uzibalqa
2024-07-04 19:57             ` Emanuel Berg
2024-07-04 21:28               ` uzibalqa
2024-07-04 21:50                 ` Emanuel Berg
2024-07-04 21:32               ` [External] : " Drew Adams
2024-07-04 22:07                 ` uzibalqa
2024-07-04 23:20                   ` uzibalqa
2024-07-05  0:12                     ` Emanuel Berg
2024-07-05 19:59                     ` uzibalqa

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.