* Making auto-mode-alist override interpreter-mode-alist
@ 2009-07-22 16:46 Francis Devereux
2009-07-22 17:06 ` Lennart Borgman
0 siblings, 1 reply; 3+ messages in thread
From: Francis Devereux @ 2009-07-22 16:46 UTC (permalink / raw)
To: help-gnu-emacs
Hi,
I have derived a mode from python-mode that has some settings for my
company's Python coding style. I want to use this mode (bright-python-
mode) for .py files in certain directories but use the default python-
mode for all other .py files.
I have the following in my auto-mode-alist:
(set-variable 'auto-mode-alist
(append '(
...
("/Users/francis/Code/Bright/.*\\.py$" . bright-python-
mode)
...
) auto-mode-alist))
This works for most files, but not for those whose first line is #!/
usr/bin/python. They always open in python-mode, regardless of the
directory that they are in. I think that this is happening because
interpreter-mode-alist is overriding auto-mode-alist. Is there any
way to make auto-mode-alist have priority over interpreter-mode-alist?
I don't really want to remove the python entry from interpreter-mode-
alist because then Python scripts with a shebang whose names don't end
in .py wouldn't open in python-mode.
Thanks,
Francis
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Making auto-mode-alist override interpreter-mode-alist
2009-07-22 16:46 Making auto-mode-alist override interpreter-mode-alist Francis Devereux
@ 2009-07-22 17:06 ` Lennart Borgman
2009-07-23 9:36 ` Francis Devereux
0 siblings, 1 reply; 3+ messages in thread
From: Lennart Borgman @ 2009-07-22 17:06 UTC (permalink / raw)
To: Francis Devereux; +Cc: help-gnu-emacs
On Wed, Jul 22, 2009 at 6:46 PM, Francis Devereux<francis@devrx.org> wrote:
> Hi,
>
> I have derived a mode from python-mode that has some settings for my
> company's Python coding style. I want to use this mode (bright-python-mode)
> for .py files in certain directories but use the default python-mode for all
> other .py files.
>
> I have the following in my auto-mode-alist:
> (set-variable 'auto-mode-alist
> (append '(
> ...
> ("/Users/francis/Code/Bright/.*\\.py$" . bright-python-mode)
> ...
> ) auto-mode-alist))
>
> This works for most files, but not for those whose first line is
> #!/usr/bin/python. They always open in python-mode, regardless of the
> directory that they are in. I think that this is happening because
> interpreter-mode-alist is overriding auto-mode-alist. Is there any way to
> make auto-mode-alist have priority over interpreter-mode-alist?
You can defadvice python-mode instead of modifying the lists. There is
nothing magic about major mode functions. They are just functions that
set up for editing in the buffer.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Making auto-mode-alist override interpreter-mode-alist
2009-07-22 17:06 ` Lennart Borgman
@ 2009-07-23 9:36 ` Francis Devereux
0 siblings, 0 replies; 3+ messages in thread
From: Francis Devereux @ 2009-07-23 9:36 UTC (permalink / raw)
To: Lennart Borgman; +Cc: help-gnu-emacs
On 22 Jul 2009, at 18:06, Lennart Borgman wrote:
> On Wed, Jul 22, 2009 at 6:46 PM, Francis Devereux<francis@devrx.org>
> wrote:
>> Hi,
>>
>> I have derived a mode from python-mode that has some settings for my
>> company's Python coding style. I want to use this mode (bright-
>> python-mode)
>> for .py files in certain directories but use the default python-
>> mode for all
>> other .py files.
>>
>> I have the following in my auto-mode-alist:
>> (set-variable 'auto-mode-alist
>> (append '(
>> ...
>> ("/Users/francis/Code/Bright/.*\\.py$" . bright-python-
>> mode)
>> ...
>> ) auto-mode-alist))
>>
>> This works for most files, but not for those whose first line is
>> #!/usr/bin/python. They always open in python-mode, regardless of
>> the
>> directory that they are in. I think that this is happening because
>> interpreter-mode-alist is overriding auto-mode-alist. Is there any
>> way to
>> make auto-mode-alist have priority over interpreter-mode-alist?
>
> You can defadvice python-mode instead of modifying the lists. There is
> nothing magic about major mode functions. They are just functions that
> set up for editing in the buffer.
I have now solved my problem by defadvicing python-mode instead of
defining a major mode.
Thanks for the advice ;-)
Francis
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-07-23 9:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-22 16:46 Making auto-mode-alist override interpreter-mode-alist Francis Devereux
2009-07-22 17:06 ` Lennart Borgman
2009-07-23 9:36 ` Francis Devereux
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).