[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Making auto-mode-alist override interpreter-mode-alist
From: |
Lennart Borgman |
Subject: |
Re: Making auto-mode-alist override interpreter-mode-alist |
Date: |
Wed, 22 Jul 2009 19:06:24 +0200 |
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.