unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How to configure Emacs to autoload modes?
@ 2003-02-21  5:44 Peter Wu
  2003-02-21  5:50 ` Lucas
  2003-02-21 17:56 ` Kai Großjohann
  0 siblings, 2 replies; 16+ messages in thread
From: Peter Wu @ 2003-02-21  5:44 UTC (permalink / raw)


Hello,

I downloaded the python-mode.el to lisp dir and did the byte-compile-file
successsfully. I need to add the following line in my .emacs file so that
when I open or new a Python file, Emacs will load the python-mode for me.

;; Load python-mode
(autoload 'python-mode "python-mode" "Python editing mode" t)
(setq auto-mode-alist (append '(("\\.py$" . python-mode)) auto-mode-alist))

However, I notice that if I create a XML or Perl file, I don't need to add
some similar code in the .emacs file and Emacs can do the job correctly. I
think there must be some settings that configure Emacs to offer such
functionality. Can anyone show me how to do this? Thanks!


--
Peter Wu

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

* Re: How to configure Emacs to autoload modes?
  2003-02-21  5:44 How to configure Emacs to autoload modes? Peter Wu
@ 2003-02-21  5:50 ` Lucas
  2003-02-21  9:20   ` Peter Wu
  2003-02-21 17:56 ` Kai Großjohann
  1 sibling, 1 reply; 16+ messages in thread
From: Lucas @ 2003-02-21  5:50 UTC (permalink / raw)


Un beau jour, Peter Wu <peterwu@hotmail.com> nous a dit:

> Hello,
>
> I downloaded the python-mode.el to lisp dir and did the byte-compile-file
> successsfully. I need to add the following line in my .emacs file so that
> when I open or new a Python file, Emacs will load the python-mode for me.
>
> ;; Load python-mode
> (autoload 'python-mode "python-mode" "Python editing mode" t)
> (setq auto-mode-alist (append '(("\\.py$" . python-mode)) auto-mode-alist))
>
> However, I notice that if I create a XML or Perl file, I don't need to add
> some similar code in the .emacs file and Emacs can do the job correctly. I
> think there must be some settings that configure Emacs to offer such
> functionality. Can anyone show me how to do this? Thanks!

I think that it's because Emacs knows some modes and extensions natively
(it's the same thing for C, and others).
It is built with that support, maybe you can rebuild Emacs to natively
add support to Python ?

Or am I totally wrong ? ^^

-- 
Lucas

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

* Re: How to configure Emacs to autoload modes?
  2003-02-21  5:50 ` Lucas
@ 2003-02-21  9:20   ` Peter Wu
  2003-02-21  9:42     ` Lucas
  0 siblings, 1 reply; 16+ messages in thread
From: Peter Wu @ 2003-02-21  9:20 UTC (permalink / raw)


Lucas wrote:

> Un beau jour, Peter Wu <peterwu@hotmail.com> nous a dit:
>
>> Hello,
>>
>> I downloaded the python-mode.el to lisp dir and did the
>> byte-compile-file successsfully. I need to add the following line in
>> my .emacs file so that when I open or new a Python file, Emacs will
>> load the python-mode for me.
>>
>> ;; Load python-mode
>> (autoload 'python-mode "python-mode" "Python editing mode" t)
>> (setq auto-mode-alist (append '(("\\.py$" . python-mode))
>> auto-mode-alist))
>>
>> However, I notice that if I create a XML or Perl file, I don't need to
>> add some similar code in the .emacs file and Emacs can do the job
>> correctly. I think there must be some settings that configure Emacs to
>> offer such functionality. Can anyone show me how to do this? Thanks!
>
> I think that it's because Emacs knows some modes and extensions natively
> (it's the same thing for C, and others).
> It is built with that support, maybe you can rebuild Emacs to natively
> add support to Python ?

I tried to build that support by updating the files.el and loaddefs.el but
no luck. I opened the python-mode.el and M-x update-file-autoloads. I saw
it wrote the loaddefs.el successfully. If I open that file, I do see the
python-mode in it.

Also, i tried to edit the files.el file, like this:

(defvar auto-mode-alist
  (mapc
   (lambda (elt)
     (cons (purecopy (car elt)) (cdr elt)))
   '(("\\.te?xt\\'" . text-mode)
     ("\\.c\\'" . c-mode)
     ("\\.h\\'" . c-mode)
     ("\\.py\\'" . python-mode)

Am I on the right track?


--
Cheers, Peter

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

* Re: How to configure Emacs to autoload modes?
  2003-02-21  9:20   ` Peter Wu
@ 2003-02-21  9:42     ` Lucas
  2003-02-21  9:50       ` Peter Wu
  0 siblings, 1 reply; 16+ messages in thread
From: Lucas @ 2003-02-21  9:42 UTC (permalink / raw)


Un beau jour, "Peter Wu" <peterwu@hotmail.com> nous a dit:

> I tried to build that support by updating the files.el and loaddefs.el but
> no luck. I opened the python-mode.el and M-x update-file-autoloads. I saw
> it wrote the loaddefs.el successfully. If I open that file, I do see the
> python-mode in it.
>
> Also, i tried to edit the files.el file, like this:
>
> (defvar auto-mode-alist
>   (mapc
>    (lambda (elt)
>      (cons (purecopy (car elt)) (cdr elt)))
>    '(("\\.te?xt\\'" . text-mode)
>      ("\\.c\\'" . c-mode)
>      ("\\.h\\'" . c-mode)
>      ("\\.py\\'" . python-mode)
>
> Am I on the right track?

I modified that list in my .emacs because I always fear of modifying
something directly in Emacs, but that should work too. This list is
huge, BTW ^^.

To do that in Emacs, simply :
(setq auto-mode-alist (append 
      '(("\\.ext1$" . mode-for-ext1)
        ("\\.ext2$" . mode-for-ext2)) auto-mode-alist))

But I'm sure you'll get the same result by editing files.el, with being
((((careful)) (to) '(((parenthesis))))) and "strings" that end anywhere".

-- 
Lucas

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

* Re: How to configure Emacs to autoload modes?
  2003-02-21  9:42     ` Lucas
@ 2003-02-21  9:50       ` Peter Wu
  2003-02-21  9:58         ` Lucas
  2003-02-21 17:51         ` Kevin Rodgers
  0 siblings, 2 replies; 16+ messages in thread
From: Peter Wu @ 2003-02-21  9:50 UTC (permalink / raw)


Lucas wrote:

> Un beau jour, "Peter Wu" <peterwu@hotmail.com> nous a dit:
>
>> I tried to build that support by updating the files.el and loaddefs.el
>> but no luck. I opened the python-mode.el and M-x
>> update-file-autoloads. I saw it wrote the loaddefs.el successfully. If
>> I open that file, I do see the python-mode in it.
>>
>> Also, i tried to edit the files.el file, like this:
>>
>> (defvar auto-mode-alist
>>   (mapc
>>    (lambda (elt)
>>      (cons (purecopy (car elt)) (cdr elt)))
>>    '(("\\.te?xt\\'" . text-mode)
>>      ("\\.c\\'" . c-mode)
>>      ("\\.h\\'" . c-mode)
>>      ("\\.py\\'" . python-mode)
>>
>> Am I on the right track?
>
> I modified that list in my .emacs because I always fear of modifying
> something directly in Emacs, but that should work too. This list is
> huge, BTW ^^.
>
> To do that in Emacs, simply :
> (setq auto-mode-alist (append
>       '(("\\.ext1$" . mode-for-ext1)
>         ("\\.ext2$" . mode-for-ext2)) auto-mode-alist))

Yes. This method works.

> But I'm sure you'll get the same result by editing files.el, with being
> ((((careful)) (to) '(((parenthesis))))) and "strings" that end
> anywhere".

However, it does not work for me after I modified the files.el and
loaddefs.el. What could I have missed? Thanks!


--
Cheers, Peter

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

* Re: How to configure Emacs to autoload modes?
  2003-02-21  9:50       ` Peter Wu
@ 2003-02-21  9:58         ` Lucas
  2003-02-21 11:35           ` Peter Wu
  2003-02-21 17:51         ` Kevin Rodgers
  1 sibling, 1 reply; 16+ messages in thread
From: Lucas @ 2003-02-21  9:58 UTC (permalink / raw)


Un beau jour, "Peter Wu" <peterwu@hotmail.com> nous a dit:

>> But I'm sure you'll get the same result by editing files.el, with being
>> ((((careful)) (to) '(((parenthesis))))) and "strings" that end
>> anywhere".
>
> However, it does not work for me after I modified the files.el and
> loaddefs.el. What could I have missed? Thanks!

Maybe M-x byte-compile-and-load ?

(I suggest to bind this to a shortcut ^^)

-- 
Lucas

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

* Re: How to configure Emacs to autoload modes?
  2003-02-21  9:58         ` Lucas
@ 2003-02-21 11:35           ` Peter Wu
  2003-02-21 11:50             ` Lucas
  0 siblings, 1 reply; 16+ messages in thread
From: Peter Wu @ 2003-02-21 11:35 UTC (permalink / raw)


Lucas <bonnet.lucas@wanadoo.fr> writes:

> Un beau jour, "Peter Wu" <peterwu@hotmail.com> nous a dit:
>
>>> But I'm sure you'll get the same result by editing files.el, with being
>>> ((((careful)) (to) '(((parenthesis))))) and "strings" that end
>>> anywhere".
>>
>> However, it does not work for me after I modified the files.el and
>> loaddefs.el. What could I have missed? Thanks!
>
> Maybe M-x byte-compile-and-load ?

All my previous tests include a byte-compile. But this did not help. :(

I think Emacs must be reading some files at bootup and load some
modes. I'd like to know what those files are. Emacs should do something
according to those files to respond to various modes, say cc-mode.

-- 
Peter Wu

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

* Re: How to configure Emacs to autoload modes?
  2003-02-21 11:35           ` Peter Wu
@ 2003-02-21 11:50             ` Lucas
  0 siblings, 0 replies; 16+ messages in thread
From: Lucas @ 2003-02-21 11:50 UTC (permalink / raw)


Un beau jour, Peter Wu <peterwu@hotmail.com> nous a dit:

> Lucas <bonnet.lucas@wanadoo.fr> writes:
>
>> Un beau jour, "Peter Wu" <peterwu@hotmail.com> nous a dit:
>>
>>>> But I'm sure you'll get the same result by editing files.el, with being
>>>> ((((careful)) (to) '(((parenthesis))))) and "strings" that end
>>>> anywhere".
>>>
>>> However, it does not work for me after I modified the files.el and
>>> loaddefs.el. What could I have missed? Thanks!
>>
>> Maybe M-x byte-compile-and-load ?
>
> All my previous tests include a byte-compile. But this did not help. :(

Hmmm, that looks strange... Did you try to remove the .elc, and then
re-bye-compile, it worked for me, when I had problems.
And with adding a (load "python-mode") or thing like that in your
.emacs, so that it loads the mode (slows Emacs a bit, though) at each
startup...

> I think Emacs must be reading some files at bootup and load some
> modes. I'd like to know what those files are. Emacs should do something
> according to those files to respond to various modes, say cc-mode.

You can know the load path ( C-h v load-path ), and I think that most of
the files in the path are loaded. You can even modify it, but I don't
know why your python mode doesn't start if you set up the things
correctly...

-- 
Lucas

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

* Re: How to configure Emacs to autoload modes?
  2003-02-21  9:50       ` Peter Wu
  2003-02-21  9:58         ` Lucas
@ 2003-02-21 17:51         ` Kevin Rodgers
  2003-02-21 19:29           ` Lucas
  2003-02-24  2:10           ` Peter Wu
  1 sibling, 2 replies; 16+ messages in thread
From: Kevin Rodgers @ 2003-02-21 17:51 UTC (permalink / raw)


Peter Wu wrote:

> Lucas wrote:
>>To do that in Emacs, simply :
>>(setq auto-mode-alist (append
>>      '(("\\.ext1$" . mode-for-ext1)
>>        ("\\.ext2$" . mode-for-ext2)) auto-mode-alist))
> 
> Yes. This method works.


That is the correct way to do it. 


>>But I'm sure you'll get the same result by editing files.el, with being
>>((((careful)) (to) '(((parenthesis))))) and "strings" that end
>>anywhere".
>>
> 
> However, it does not work for me after I modified the files.el and
> loaddefs.el. What could I have missed? Thanks!

The fact that they are dumped into the emacs executable and therefore not loaded
at run time.

-- 
<a href="mailto:&lt;kevin.rodgers&#64;ihs.com&gt;">Kevin Rodgers</a>

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

* Re: How to configure Emacs to autoload modes?
  2003-02-21  5:44 How to configure Emacs to autoload modes? Peter Wu
  2003-02-21  5:50 ` Lucas
@ 2003-02-21 17:56 ` Kai Großjohann
  2003-02-21 18:37   ` David Masterson
  1 sibling, 1 reply; 16+ messages in thread
From: Kai Großjohann @ 2003-02-21 17:56 UTC (permalink / raw)


Peter Wu <peterwu@hotmail.com> writes:

> However, I notice that if I create a XML or Perl file, I don't need to add
> some similar code in the .emacs file and Emacs can do the job correctly. I
> think there must be some settings that configure Emacs to offer such
> functionality. Can anyone show me how to do this? Thanks!

It's done when Emacs is built/compiled.

Your procedure is the right one, I believe.

(You could add the code to site-start.el if you want to avoid every
user having to put it in their .emacs file.)
-- 
A preposition is not a good thing to end a sentence with.

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

* Re: How to configure Emacs to autoload modes?
  2003-02-21 17:56 ` Kai Großjohann
@ 2003-02-21 18:37   ` David Masterson
  2003-02-21 20:45     ` Kai Großjohann
  0 siblings, 1 reply; 16+ messages in thread
From: David Masterson @ 2003-02-21 18:37 UTC (permalink / raw)


>>>>> Kai Großjohann writes:

> (You could add the code to site-start.el if you want to avoid every
> user having to put it in their .emacs file.)

In the case of auto-mode-alist, don't you think it's preferrable to
put the code in default.el so that users can choose to not load it via
inhibit-default-init?

-- 
David Masterson                David DOT Masterson AT synopsys DOT com
Sr. R&D Engineer               Synopsys, Inc.
Software Engineering           Sunnyvale, CA

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

* Re: How to configure Emacs to autoload modes?
  2003-02-21 17:51         ` Kevin Rodgers
@ 2003-02-21 19:29           ` Lucas
  2003-02-24  2:10           ` Peter Wu
  1 sibling, 0 replies; 16+ messages in thread
From: Lucas @ 2003-02-21 19:29 UTC (permalink / raw)


Un beau jour, Kevin Rodgers <kevin.rodgers@ihs.com> nous a dit:

>
> The fact that they are dumped into the emacs executable and therefore
> not loaded at run time.

Aha, that was the trick :)

-- 
Lucas

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

* Re: How to configure Emacs to autoload modes?
  2003-02-21 18:37   ` David Masterson
@ 2003-02-21 20:45     ` Kai Großjohann
  2003-02-21 22:09       ` David Masterson
  0 siblings, 1 reply; 16+ messages in thread
From: Kai Großjohann @ 2003-02-21 20:45 UTC (permalink / raw)


David Masterson <David.Masterson@synopsys.com> writes:

>>>>>> Kai Großjohann writes:
>
>> (You could add the code to site-start.el if you want to avoid every
>> user having to put it in their .emacs file.)
>
> In the case of auto-mode-alist, don't you think it's preferrable to
> put the code in default.el so that users can choose to not load it via
> inhibit-default-init?

Well.  People could still put (add-to-list 'auto-mode-alist ...)
statements into their ~/.emacs.

The problem that I, personally, see with inhibit-default-init is that
it's an all-or-nothing thing.  There is no way to say "I like most of
what default.el does, but please skip this setting here".

That's why I my site-start.el contains a lot of functions, each
setting up a specific package.  Then my users can pick and choose.
(Or choose and pick?)

-- 
A preposition is not a good thing to end a sentence with.

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

* Re: How to configure Emacs to autoload modes?
  2003-02-21 20:45     ` Kai Großjohann
@ 2003-02-21 22:09       ` David Masterson
  2003-02-21 23:48         ` Stefan Monnier <foo@acm.com>
  0 siblings, 1 reply; 16+ messages in thread
From: David Masterson @ 2003-02-21 22:09 UTC (permalink / raw)


>>>>> Kai Großjohann writes:
> David Masterson <David.Masterson@synopsys.com> writes:
>>>>>>> Kai Großjohann writes:

>>> (You could add the code to site-start.el if you want to avoid
>>> every user having to put it in their .emacs file.)

>> In the case of auto-mode-alist, don't you think it's preferrable to
>> put the code in default.el so that users can choose to not load it
>> via inhibit-default-init?

> Well.  People could still put (add-to-list 'auto-mode-alist ...)
> statements into their ~/.emacs.

> The problem that I, personally, see with inhibit-default-init is
> that it's an all-or-nothing thing.  There is no way to say "I like
> most of what default.el does, but please skip this setting here".

> That's why I my site-start.el contains a lot of functions, each
> setting up a specific package.  Then my users can pick and choose.
> (Or choose and pick?)

Ah, yes.  The old "chicken and egg" problem with Emacs configuration.
If you put everything in site-start.el, then potentially more things
get defined than the user really wants and the user has to undo it in
.emacs.  If you put everything in default.el, then the user may lose
control over what get's defined unless he sets inhibit-default-init.

Back in the day when I did this, I think I solved it the same way you
are.  I also put a default set of choices into default.el and just
made sure that the functions "do the right thing" if the user chooses
to set something up himself.

-- 
David Masterson                David DOT Masterson AT synopsys DOT com
Sr. R&D Engineer               Synopsys, Inc.
Software Engineering           Sunnyvale, CA

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

* Re: How to configure Emacs to autoload modes?
  2003-02-21 22:09       ` David Masterson
@ 2003-02-21 23:48         ` Stefan Monnier <foo@acm.com>
  0 siblings, 0 replies; 16+ messages in thread
From: Stefan Monnier <foo@acm.com> @ 2003-02-21 23:48 UTC (permalink / raw)


>>>>> "David" == David Masterson <David.Masterson@synopsys.com> writes:
> Ah, yes.  The old "chicken and egg" problem with Emacs configuration.

Note that I think both of those files should only contain a strict minimum.
I basically use site-start.el and put things into it that are just necessary
to setup the extra packages I have installed.  The user gets basically
the same as if the package had been bundled with Emacs, i.e. if she has
problems with it, those problems are hers and could just as well appear
(without my interfering) if the package got included in the next version
of Emacs.

Setting up auto-mode-alist and autoloads is definitely part of
this "minimum setup".


        Stefan

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

* Re: How to configure Emacs to autoload modes?
  2003-02-21 17:51         ` Kevin Rodgers
  2003-02-21 19:29           ` Lucas
@ 2003-02-24  2:10           ` Peter Wu
  1 sibling, 0 replies; 16+ messages in thread
From: Peter Wu @ 2003-02-24  2:10 UTC (permalink / raw)


On Sat Feb 22 2003 at 01:51, Kevin Rodgers <kevin.rodgers@ihs.com> wrote:

> Peter Wu wrote:
> >>
> > However, it does not work for me after I modified the files.el and
> > loaddefs.el. What could I have missed? Thanks!
> 
> The fact that they are dumped into the emacs executable and therefore not loaded
> at run time.

I think you are right. I tried to remove some entries in the files and
loaddefs.el and Emacs still *correctly* loads cc-mode.

-- 
Peter Wu

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

end of thread, other threads:[~2003-02-24  2:10 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-02-21  5:44 How to configure Emacs to autoload modes? Peter Wu
2003-02-21  5:50 ` Lucas
2003-02-21  9:20   ` Peter Wu
2003-02-21  9:42     ` Lucas
2003-02-21  9:50       ` Peter Wu
2003-02-21  9:58         ` Lucas
2003-02-21 11:35           ` Peter Wu
2003-02-21 11:50             ` Lucas
2003-02-21 17:51         ` Kevin Rodgers
2003-02-21 19:29           ` Lucas
2003-02-24  2:10           ` Peter Wu
2003-02-21 17:56 ` Kai Großjohann
2003-02-21 18:37   ` David Masterson
2003-02-21 20:45     ` Kai Großjohann
2003-02-21 22:09       ` David Masterson
2003-02-21 23:48         ` Stefan Monnier <foo@acm.com>

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).