unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Set variable in derived mode before running the parent mode function
@ 2015-06-02  9:46 Philipp Stephani
  0 siblings, 0 replies; 11+ messages in thread
From: Philipp Stephani @ 2015-06-02  9:46 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,

I've defined a derived major mode of `python-mode' using
`define-derived-mode'.  However, some of the variables set by
`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?  Using an
advice?  Or not using `define-derived-mode' in the first place?

Thanks,
Philipp

-- 
Google Germany GmbH
Dienerstraße 12
80331 München

Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Geschäftsführer: Graham Law, Christine Elizabeth Flores

Diese E-Mail ist vertraulich.  Wenn Sie nicht der richtige Adressat sind,
leiten Sie diese bitte nicht weiter, informieren Sie den Absender und löschen
Sie die E-Mail und alle Anhänge.  Vielen Dank.
       
This e-mail is confidential.  If you are not the right addressee please do not
forward it, please inform the sender, and please erase this e-mail including
any attachments.  Thanks.



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

* Re: Set variable in derived mode before running the parent mode function
       [not found] <mailman.4113.1433238449.904.help-gnu-emacs@gnu.org>
@ 2015-06-03  1:10 ` Stefan Monnier
  2015-06-04  5:03   ` Andreas Röhler
                     ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Stefan Monnier @ 2015-06-03  1:10 UTC (permalink / raw)
  To: help-gnu-emacs

> `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).


        Stefan


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

* Re: Set variable in derived mode before running the parent mode function
  2015-06-03  1:10 ` Set variable in derived mode before running the parent mode function Stefan Monnier
@ 2015-06-04  5:03   ` Andreas Röhler
  2015-06-06 15:59     ` Philipp Stephani
       [not found]   ` <mailman.4253.1433394203.904.help-gnu-emacs@gnu.org>
  2015-06-06 15:58   ` Philipp Stephani
  2 siblings, 1 reply; 11+ messages in thread
From: Andreas Röhler @ 2015-06-04  5:03 UTC (permalink / raw)
  To: help-gnu-emacs


Am 03.06.2015 um 03:10 schrieb Stefan Monnier:
>> `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.

Customizing python-indent-guess-indent-offset to nil should help already.

Andreas



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

* Re: Set variable in derived mode before running the parent mode function
       [not found]   ` <mailman.4253.1433394203.904.help-gnu-emacs@gnu.org>
@ 2015-06-04 21:55     ` Stefan Monnier
  0 siblings, 0 replies; 11+ messages in thread
From: Stefan Monnier @ 2015-06-04 21:55 UTC (permalink / raw)
  To: help-gnu-emacs

>>> `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


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

* Re: Set variable in derived mode before running the parent mode function
  2015-06-03  1:10 ` Set variable in derived mode before running the parent mode function Stefan Monnier
  2015-06-04  5:03   ` Andreas Röhler
       [not found]   ` <mailman.4253.1433394203.904.help-gnu-emacs@gnu.org>
@ 2015-06-06 15:58   ` Philipp Stephani
  2015-06-07 11:52     ` Andreas Röhler
  2 siblings, 1 reply; 11+ messages in thread
From: Philipp Stephani @ 2015-06-06 15:58 UTC (permalink / raw)
  To: Stefan Monnier, help-gnu-emacs

Stefan Monnier <monnier@iro.umontreal.ca> schrieb am Mi., 3. Juni 2015 um
03:15 Uhr:

> > `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).
>
>
>
You're right, that wouldn't work. The problem is that
python-indent-guess-indent-offset prints a message if it couldn't guess the
indentation; I'd like to suppress that message.


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

* Re: Set variable in derived mode before running the parent mode function
  2015-06-04  5:03   ` Andreas Röhler
@ 2015-06-06 15:59     ` Philipp Stephani
  2015-06-07 11:49       ` Andreas Röhler
  0 siblings, 1 reply; 11+ messages in thread
From: Philipp Stephani @ 2015-06-06 15:59 UTC (permalink / raw)
  To: Andreas Röhler, help-gnu-emacs

Andreas Röhler <andreas.roehler@easy-emacs.de> schrieb am Do., 4. Juni 2015
um 07:03 Uhr:

> Customizing python-indent-guess-indent-offset to nil should help already.
>

Yes, but it would apply to all Python files as well, not only to the
derived mode.


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

* Re: Set variable in derived mode before running the parent mode function
  2015-06-06 15:59     ` Philipp Stephani
@ 2015-06-07 11:49       ` Andreas Röhler
  0 siblings, 0 replies; 11+ messages in thread
From: Andreas Röhler @ 2015-06-07 11:49 UTC (permalink / raw)
  To: Philipp Stephani, help-gnu-emacs


Am 06.06.2015 um 17:59 schrieb Philipp Stephani:
>
>
> Andreas Röhler <andreas.roehler@easy-emacs.de 
> <mailto:andreas.roehler@easy-emacs.de>> schrieb am Do., 4. Juni 2015 
> um 07:03 Uhr:
>
>     Customizing python-indent-guess-indent-offset to nil should help
>     already.
>
>
> Yes, but it would apply to all Python files as well, not only to the 
> derived mode.

Only the --derived-- python-mode asks for variable

python-indent-guess-indent-offset

and does (python-indent-guess-indent-offset) if t



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

* Re: Set variable in derived mode before running the parent mode function
  2015-06-06 15:58   ` Philipp Stephani
@ 2015-06-07 11:52     ` Andreas Röhler
  2015-06-21 12:24       ` Philipp Stephani
       [not found]       ` <mailman.5357.1434889492.904.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 11+ messages in thread
From: Andreas Röhler @ 2015-06-07 11:52 UTC (permalink / raw)
  To: help-gnu-emacs


Am 06.06.2015 um 17:58 schrieb Philipp Stephani:
> Stefan Monnier <monnier@iro.umontreal.ca> schrieb am Mi., 3. Juni 2015 um
> 03:15 Uhr:
>
>>> `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).
>>
>>
>>
> You're right, that wouldn't work. The problem is that
> python-indent-guess-indent-offset prints a message if it couldn't guess the
> indentation; I'd like to suppress that message.


Disabling a message is another thing than disabling auto-guessing.

Look into python.el, definition of

python-indent-guess-indent-offset

Messaging is done from last line there. Put it at an extra line - i.e. a 
new line at the end of "(message
" sexp. Than comment out that line.






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

* Re: Set variable in derived mode before running the parent mode function
  2015-06-07 11:52     ` Andreas Röhler
@ 2015-06-21 12:24       ` Philipp Stephani
       [not found]       ` <mailman.5357.1434889492.904.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 11+ messages in thread
From: Philipp Stephani @ 2015-06-21 12:24 UTC (permalink / raw)
  To: Andreas Röhler, help-gnu-emacs

Andreas Röhler <andreas.roehler@easy-emacs.de> schrieb am So., 7. Juni 2015
um 13:52 Uhr:

>
> Am 06.06.2015 um 17:58 schrieb Philipp Stephani:
> > Stefan Monnier <monnier@iro.umontreal.ca> schrieb am Mi., 3. Juni 2015
> um
> > 03:15 Uhr:
> >
> >>> `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).
> >>
> >>
> >>
> > You're right, that wouldn't work. The problem is that
> > python-indent-guess-indent-offset prints a message if it couldn't guess
> the
> > indentation; I'd like to suppress that message.
>
>
> Disabling a message is another thing than disabling auto-guessing.
>
> Look into python.el, definition of
>
> python-indent-guess-indent-offset
>
> Messaging is done from last line there. Put it at an extra line - i.e. a
> new line at the end of "(message
> " sexp. Than comment out that line.
>
>
Sure, but that would disable the message for all users. I could totally
live with that (Emacs is already too chatty), but Stefan would need to
agree that it's fine to remove the message entirely.


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

* Re: Set variable in derived mode before running the parent mode function
       [not found]       ` <mailman.5357.1434889492.904.help-gnu-emacs@gnu.org>
@ 2015-06-21 17:32         ` Stefan Monnier
  2015-12-28 17:48           ` Philipp Stephani
  0 siblings, 1 reply; 11+ messages in thread
From: Stefan Monnier @ 2015-06-21 17:32 UTC (permalink / raw)
  To: help-gnu-emacs

> live with that (Emacs is already too chatty), but Stefan would need to
> agree that it's fine to remove the message entirely.

I have no opinion on this.  You should talk the python.el's
maintainer instead.


        Stefan


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

* Re: Set variable in derived mode before running the parent mode function
  2015-06-21 17:32         ` Stefan Monnier
@ 2015-12-28 17:48           ` Philipp Stephani
  0 siblings, 0 replies; 11+ messages in thread
From: Philipp Stephani @ 2015-12-28 17:48 UTC (permalink / raw)
  To: Stefan Monnier, help-gnu-emacs

Stefan Monnier <monnier@iro.umontreal.ca> schrieb am So., 21. Juni 2015 um
19:35 Uhr:

> > live with that (Emacs is already too chatty), but Stefan would need to
> > agree that it's fine to remove the message entirely.
>
> I have no opinion on this.  You should talk the python.el's
> maintainer instead.
>
>
Actually there's already a variable
`python-indent-guess-indent-offset-verbose' (introduced in commit
1d02107dab6f844a7c537bb5e98aff4e5f061246), which should resolve this issue.


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

end of thread, other threads:[~2015-12-28 17:48 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.4113.1433238449.904.help-gnu-emacs@gnu.org>
2015-06-03  1:10 ` Set variable in derived mode before running the parent mode function Stefan Monnier
2015-06-04  5:03   ` Andreas Röhler
2015-06-06 15:59     ` Philipp Stephani
2015-06-07 11:49       ` Andreas Röhler
     [not found]   ` <mailman.4253.1433394203.904.help-gnu-emacs@gnu.org>
2015-06-04 21:55     ` Stefan Monnier
2015-06-06 15:58   ` Philipp Stephani
2015-06-07 11:52     ` Andreas Röhler
2015-06-21 12:24       ` Philipp Stephani
     [not found]       ` <mailman.5357.1434889492.904.help-gnu-emacs@gnu.org>
2015-06-21 17:32         ` Stefan Monnier
2015-12-28 17:48           ` Philipp Stephani
2015-06-02  9:46 Philipp Stephani

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).