help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Set variable in derived mode before running the parent mode function


From: Stefan Monnier
Subject: Re: Set variable in derived mode before running the parent mode function
Date: Thu, 04 Jun 2015 17:55:14 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

>>> `python-mode' are inappropriate for the derived mode; in particular, I'd
>>> like to disable auto-guessing of the indentation by setting
>>> `python-indent-guess-indent-offset' to nil.  However,
>>> `define-derived-mode' has no customization point for running code before
>>> the parent mode function.  What's the best way to solve this?
>> Add the code *after* running python-mode?  After all, setting vars
>> before would be a waste since python-mode (like all other proper major
>> modes) begins by calling kill-all-local-variables (also known as
>> fundamental-mode).
> Can't see this in python.el. python-mode is a derived-mode from prog-mode.

Yup, it starts by calling prog-mode.  Since prog-mode is a proper major
mode it will start by running kill-all-local-variables and hence
python-mode does too.  Of course prog-mode itself is a derived mode so
it doesn't directly call kill-all-local-variables, but instead it calls
fundamental-mode, which itself calls kill-all-local-variables (the two
used to be aliases, but nowadays, fundamental-mode does a little bit
more than just running kill-all-local-variables).


        Stefan


reply via email to

[Prev in Thread] Current Thread [Next in Thread]