all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Requiring elisp that comes with Emacs
@ 2017-01-30 16:52 Narendra Joshi
  2017-01-30 18:50 ` Skip Montanaro
  0 siblings, 1 reply; 12+ messages in thread
From: Narendra Joshi @ 2017-01-30 16:52 UTC (permalink / raw)
  To: help-gnu-emacs


Hi,
Do we really need to add `(require 'vc)' as `vc.el' comes with Emacs?
What happens when we do `require'?

Best,
Narendra 



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

* Re: Requiring elisp that comes with Emacs
  2017-01-30 16:52 Requiring elisp that comes with Emacs Narendra Joshi
@ 2017-01-30 18:50 ` Skip Montanaro
  2017-01-31 13:46   ` Narendra Joshi
  0 siblings, 1 reply; 12+ messages in thread
From: Skip Montanaro @ 2017-01-30 18:50 UTC (permalink / raw)
  To: Narendra Joshi; +Cc: help-gnu-emacs

On Mon, Jan 30, 2017 at 10:52 AM, Narendra Joshi <narendraj9@gmail.com>
wrote:

> What happens when we do `require'?


It guarantees the relevant feature is available, generally as a side effect
of loading the named package. I believe the package much "provide" its
name. If not found, an error is raised. Full details can be found here:

https://www.gnu.org/software/emacs/manual/html_node/elisp/Named-Features.html

While under the covers I imagine the implementation is much different, I my
mental model is similar to Python's import statement or C++'s namespace
statement. All three make a series of names available to you, though
require is a global operation, not local to a particular module or
translation unit.

Skip Montanaro


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

* Re: Requiring elisp that comes with Emacs
  2017-01-30 18:50 ` Skip Montanaro
@ 2017-01-31 13:46   ` Narendra Joshi
  2017-01-31 14:39     ` Óscar Fuentes
                       ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Narendra Joshi @ 2017-01-31 13:46 UTC (permalink / raw)
  To: Skip Montanaro; +Cc: help-gnu-emacs

Skip Montanaro <skip.montanaro@gmail.com> writes:

> On Mon, Jan 30, 2017 at 10:52 AM, Narendra Joshi <
> narendraj9@gmail.com> wrote:
>
>     What happens when we do `require'?
>
>
> It guarantees the relevant feature is available, generally as a side
> effect of loading the named package. I believe the package much
> "provide" its name. If not found, an error is raised. Full details
> can be found here:
>
> https://www.gnu.org/software/emacs/manual/html_node/elisp/
> Named-Features.html

My question was more about whether we need to `require` packages that
come with Emacs itself, e.g. org-mode.

>
> While under the covers I imagine the implementation is much
> different, I my mental model is similar to Python's import statement
> or C++'s namespace statement. All three make a series of names
> available to you, though require is a global operation, not local to
> a particular module or translation unit.

I think every file in the `load-path' would need to be read for a
(provide 'something) at the end while trying to
(require 'something). Languages that make sure that the name of the
module is the same as the name of the file do not have to look inside
the file. This is all speculation and I do not know how exactly things
are done in reality.

Narendra




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

* Re: Requiring elisp that comes with Emacs
  2017-01-31 13:46   ` Narendra Joshi
@ 2017-01-31 14:39     ` Óscar Fuentes
  2017-01-31 18:06       ` Skip Montanaro
  2017-01-31 14:50     ` Skip Montanaro
  2017-02-01 15:53     ` Eric Abrahamsen
  2 siblings, 1 reply; 12+ messages in thread
From: Óscar Fuentes @ 2017-01-31 14:39 UTC (permalink / raw)
  To: help-gnu-emacs

Narendra Joshi <narendraj9@gmail.com> writes:

>>     What happens when we do `require'?
>>
>>
>> It guarantees the relevant feature is available, generally as a side
>> effect of loading the named package. I believe the package much
>> "provide" its name. If not found, an error is raised. Full details
>> can be found here:
>>
>> https://www.gnu.org/software/emacs/manual/html_node/elisp/
>> Named-Features.html
>
> My question was more about whether we need to `require` packages that
> come with Emacs itself, e.g. org-mode.

Emacs comes with lots of packages. A typical user only needs a fraction
of those packages. Every package takes some time to load and then uses
resources. Loading everything by default would be a waste.

Another reason for explicitly requiring a package such as `vc' (which
typically is automatically loaded when certain conditions are met) is to
ensure that certain functions and/or variables are available because you
use them in your code (in your .emacs, for instance).

>> While under the covers I imagine the implementation is much
>> different, I my mental model is similar to Python's import statement
>> or C++'s namespace statement. All three make a series of names
>> available to you, though require is a global operation, not local to
>> a particular module or translation unit.
>
> I think every file in the `load-path' would need to be read for a
> (provide 'something) at the end while trying to
> (require 'something). Languages that make sure that the name of the
> module is the same as the name of the file do not have to look inside
> the file. This is all speculation and I do not know how exactly things
> are done in reality.

Type

C-h f require [ENTER]

A *Help* buffer will popup with the docstring for `require'. There it is
explained that the file for the require-d package is inferred from the
package name.




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

* Re: Requiring elisp that comes with Emacs
  2017-01-31 13:46   ` Narendra Joshi
  2017-01-31 14:39     ` Óscar Fuentes
@ 2017-01-31 14:50     ` Skip Montanaro
  2017-01-31 20:01       ` Narendra Joshi
  2017-02-01 15:53     ` Eric Abrahamsen
  2 siblings, 1 reply; 12+ messages in thread
From: Skip Montanaro @ 2017-01-31 14:50 UTC (permalink / raw)
  To: Narendra Joshi; +Cc: help-gnu-emacs

On Tue, Jan 31, 2017 at 7:46 AM, Narendra Joshi <narendraj9@gmail.com>
wrote:

> My question was more about whether we need to `require` packages that
> come with Emacs itself, e.g. org-mode.
>

It it's not pre-loaded and you want use it at run-time, I believe the
answer is, "yes." (It's been years and years since I did anything
non-trivial with ELisp, so I feel I have to qualify my statement.) Maybe I
misunderstood what you meant by "come with Emacs itself." I (require) a
fewpackages in my .emacs file: mouse, auto-complete-config, and lua-mode. I
didn't install any of them (someone else manages my local Emacs
installation), so they may not all be distributed with Emacs. I'm 99%
certain that at least mouse is distributed as part of Emacs. Still, I need
to (require) it to load it into the current Emacs instance so I can mess
around with the symbols and functions defined in mouse.el.

Skip


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

* Re: Requiring elisp that comes with Emacs
  2017-01-31 14:39     ` Óscar Fuentes
@ 2017-01-31 18:06       ` Skip Montanaro
  2017-01-31 20:03         ` Óscar Fuentes
  0 siblings, 1 reply; 12+ messages in thread
From: Skip Montanaro @ 2017-01-31 18:06 UTC (permalink / raw)
  To: Óscar Fuentes; +Cc: help-gnu-emacs

On Tue, Jan 31, 2017 at 8:39 AM, Óscar Fuentes <ofv@wanadoo.es> wrote:

> Type
>
> C-h f require [ENTER]
>
> A *Help* buffer will popup with the docstring for `require'. There it is
> explained that the file for the require-d package is inferred from the
> package name.
>

Thanks. When I said "this is all speculation", I meant how it works under
the covers (how it compares semantically to Python's import statement or
C++'s namespace statement), not how it locates a file to load. I realize
that require uses the argument symbol name as the basename of the source
file.

Skip


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

* Re: Requiring elisp that comes with Emacs
  2017-01-31 14:50     ` Skip Montanaro
@ 2017-01-31 20:01       ` Narendra Joshi
  2017-01-31 20:40         ` Skip Montanaro
  0 siblings, 1 reply; 12+ messages in thread
From: Narendra Joshi @ 2017-01-31 20:01 UTC (permalink / raw)
  To: Skip Montanaro; +Cc: help-gnu-emacs

Skip Montanaro <skip.montanaro@gmail.com> writes:

> (require) a fewpackages in my .emacs file: mouse,
> auto-complete-config, and lua-mode. I didn't install any of them
> (someone else manages my local Emacs installation), so they may not

That's interesting. Why would you let someone else manage it for you?

- Narendra



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

* Re: Requiring elisp that comes with Emacs
  2017-01-31 18:06       ` Skip Montanaro
@ 2017-01-31 20:03         ` Óscar Fuentes
  0 siblings, 0 replies; 12+ messages in thread
From: Óscar Fuentes @ 2017-01-31 20:03 UTC (permalink / raw)
  To: help-gnu-emacs

Skip Montanaro <skip.montanaro@gmail.com> writes:

> On Tue, Jan 31, 2017 at 8:39 AM, Óscar Fuentes <ofv@wanadoo.es> wrote:
>
>> Type
>>
>> C-h f require [ENTER]
>>
>> A *Help* buffer will popup with the docstring for `require'. There it is
>> explained that the file for the require-d package is inferred from the
>> package name.
>>
>
> Thanks. When I said "this is all speculation", I meant how it works under
> the covers (how it compares semantically to Python's import statement or
> C++'s namespace statement), not how it locates a file to load. I realize
> that require uses the argument symbol name as the basename of the source
> file.

I don't know about Python, but Elisp `require' is totally unrelated to
C++'s namespace statement. Semantically, it is loosely related to the
#include preprocessor directive, although not quite the same.

IMHO it is wrong to learn a language thinking on supposedly similar
conceps on other languages. It just creates confusion.




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

* Re: Requiring elisp that comes with Emacs
  2017-01-31 20:01       ` Narendra Joshi
@ 2017-01-31 20:40         ` Skip Montanaro
  2017-02-01 10:07           ` hector
  2017-02-01 15:10           ` Narendra Joshi
  0 siblings, 2 replies; 12+ messages in thread
From: Skip Montanaro @ 2017-01-31 20:40 UTC (permalink / raw)
  To: Narendra Joshi; +Cc: help-gnu-emacs

> Why would you let someone else manage it for you?

This is not really an Emacs question. It is more of a quality of life
question. Still, since you asked...

I let someone else manage my Emacs installations for the same reasons that:

   - I no longer rebuild my Linux kernel daily (as I used to 20 or more
   years ago)
   - I rely on a third party to maintain a complex Python environment
   (despite having been one of the core Python developers in dim, dark the
   past)
   - Let the mechanic do tune-ups on my car

There is value in stability and knowing when others are better at a
particular task than I am (or at least good enough that I can delegate to
them). I can't be an expert in everything. Sometimes, even if I know I can
do the job myself, it's worth it to let someone else do it, because time -
as they say - is money. If I'm fiddling with my Emacs installation or
changing the oil in my car, that's time when I could have been doing
something else of more personal value to me, like working on paying work,
riding my bike, or having dinner with my wife. I have more important things
to do with my time than fiddle with a complex tool chain on a continuous
(or even occasional) basis.

S

On Tue, Jan 31, 2017 at 2:01 PM, Narendra Joshi <narendraj9@gmail.com>
wrote:

> Skip Montanaro <skip.montanaro@gmail.com> writes:
>
> > (require) a fewpackages in my .emacs file: mouse,
> > auto-complete-config, and lua-mode. I didn't install any of them
> > (someone else manages my local Emacs installation), so they may not
>
> That's interesting. Why would you let someone else manage it for you?
>
> - Narendra
>


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

* Re: Requiring elisp that comes with Emacs
  2017-01-31 20:40         ` Skip Montanaro
@ 2017-02-01 10:07           ` hector
  2017-02-01 15:10           ` Narendra Joshi
  1 sibling, 0 replies; 12+ messages in thread
From: hector @ 2017-02-01 10:07 UTC (permalink / raw)
  To: Skip Montanaro, narendraj9; +Cc: help-gnu-emacs

That's a very good answer. This is how life (and society) works.

I am a do-it-yourself kind of guy. I guess that's why I like Emacs
and free software in general.

But sometimes you must accept you can't do EVERYTHING by yourself.

On Tue, Jan 31, 2017 at 02:40:55PM -0600, Skip Montanaro wrote:
> > Why would you let someone else manage it for you?
> 
> This is not really an Emacs question. It is more of a quality of life
> question. Still, since you asked...
> 
> I let someone else manage my Emacs installations for the same reasons that:
> 
>    - I no longer rebuild my Linux kernel daily (as I used to 20 or more
>    years ago)
>    - I rely on a third party to maintain a complex Python environment
>    (despite having been one of the core Python developers in dim, dark the
>    past)
>    - Let the mechanic do tune-ups on my car
> 
> There is value in stability and knowing when others are better at a
> particular task than I am (or at least good enough that I can delegate to
> them). I can't be an expert in everything. Sometimes, even if I know I can
> do the job myself, it's worth it to let someone else do it, because time -
> as they say - is money. If I'm fiddling with my Emacs installation or
> changing the oil in my car, that's time when I could have been doing
> something else of more personal value to me, like working on paying work,
> riding my bike, or having dinner with my wife. I have more important things
> to do with my time than fiddle with a complex tool chain on a continuous
> (or even occasional) basis.
> 
> S
> 
> On Tue, Jan 31, 2017 at 2:01 PM, Narendra Joshi <narendraj9@gmail.com>
> wrote:
> 
> > Skip Montanaro <skip.montanaro@gmail.com> writes:
> >
> > > (require) a fewpackages in my .emacs file: mouse,
> > > auto-complete-config, and lua-mode. I didn't install any of them
> > > (someone else manages my local Emacs installation), so they may not
> >
> > That's interesting. Why would you let someone else manage it for you?
> >
> > - Narendra
> >



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

* Re: Requiring elisp that comes with Emacs
  2017-01-31 20:40         ` Skip Montanaro
  2017-02-01 10:07           ` hector
@ 2017-02-01 15:10           ` Narendra Joshi
  1 sibling, 0 replies; 12+ messages in thread
From: Narendra Joshi @ 2017-02-01 15:10 UTC (permalink / raw)
  To: Skip Montanaro; +Cc: help-gnu-emacs

Skip Montanaro <skip.montanaro@gmail.com> writes:

That's true! :) This is the first time I am participating in a mailing
list and I really like this particular one. :)

>> Why would you let someone else manage it for you?
>
> This is not really an Emacs question. It is more of a quality of life
> question. Still, since you asked...
>
> I let someone else manage my Emacs installations for the same reasons
> that:
>
>     I no longer rebuild my Linux kernel daily (as I used to 20 or
>     more years ago)
>     I rely on a third party to maintain a complex Python environment
>     (despite having been one of the core Python developers in dim,
>     dark the past)
>     Let the mechanic do tune-ups on my car
>
> There is value in stability and knowing when others are better at a
> particular task than I am (or at least good enough that I can
> delegate to them). I can't be an expert in everything. Sometimes,
> even if I know I can do the job myself, it's worth it to let someone
> else do it, because time - as they say - is money. If I'm fiddling
> with my Emacs installation or changing the oil in my car, that's time
> when I could have been doing something else of more personal value to
> me, like working on paying work, riding my bike, or having dinner
> with my wife. I have more important things to do with my time than
> fiddle with a complex tool chain on a continuous (or even occasional)
> basis.
>
> S
>
> On Tue, Jan 31, 2017 at 2:01 PM, Narendra Joshi <narendraj9@gmail.com
>> wrote:
>
>     Skip Montanaro <skip.montanaro@gmail.com> writes:
>    
>     > (require) a fewpackages in my .emacs file: mouse,
>     > auto-complete-config, and lua-mode. I didn't install any of
>     them
>     > (someone else manages my local Emacs installation), so they may
>     not
>    
>     That's interesting. Why would you let someone else manage it for
>     you?
>    
>     - Narendra
>
>
>
>

-- 
- Narendra



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

* Re: Requiring elisp that comes with Emacs
  2017-01-31 13:46   ` Narendra Joshi
  2017-01-31 14:39     ` Óscar Fuentes
  2017-01-31 14:50     ` Skip Montanaro
@ 2017-02-01 15:53     ` Eric Abrahamsen
  2 siblings, 0 replies; 12+ messages in thread
From: Eric Abrahamsen @ 2017-02-01 15:53 UTC (permalink / raw)
  To: help-gnu-emacs

Narendra Joshi <narendraj9@gmail.com> writes:

> Skip Montanaro <skip.montanaro@gmail.com> writes:
>
>> On Mon, Jan 30, 2017 at 10:52 AM, Narendra Joshi <
>> narendraj9@gmail.com> wrote:
>>
>>     What happens when we do `require'?
>>
>>
>> It guarantees the relevant feature is available, generally as a side
>> effect of loading the named package. I believe the package much
>> "provide" its name. If not found, an error is raised. Full details
>> can be found here:
>>
>> https://www.gnu.org/software/emacs/manual/html_node/elisp/
>> Named-Features.html
>
> My question was more about whether we need to `require` packages that
> come with Emacs itself, e.g. org-mode.

Practically speaking, every package that come with Emacs will provide
autoload statements for all the common entrypoint functions. Calling
`require' will instantly load all the package's code, and all the
packages it requires. Autoload, on the other hand, will leave the
package unloaded, but load it automatically the first time you use an
autoload'ed function. Most of the time, that's all you need.

Eric




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

end of thread, other threads:[~2017-02-01 15:53 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-30 16:52 Requiring elisp that comes with Emacs Narendra Joshi
2017-01-30 18:50 ` Skip Montanaro
2017-01-31 13:46   ` Narendra Joshi
2017-01-31 14:39     ` Óscar Fuentes
2017-01-31 18:06       ` Skip Montanaro
2017-01-31 20:03         ` Óscar Fuentes
2017-01-31 14:50     ` Skip Montanaro
2017-01-31 20:01       ` Narendra Joshi
2017-01-31 20:40         ` Skip Montanaro
2017-02-01 10:07           ` hector
2017-02-01 15:10           ` Narendra Joshi
2017-02-01 15:53     ` Eric Abrahamsen

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.