unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#2355: 23.0.60; Enabling minor-mode disables major mode
@ 2009-02-17 11:45 Leo
  2009-02-17 14:37 ` Juanma Barranquero
  0 siblings, 1 reply; 15+ messages in thread
From: Leo @ 2009-02-17 11:45 UTC (permalink / raw)
  To: emacs-pretest-bug

Please describe exactly what actions triggered the bug
and the precise symptoms of the bug:

In a file like this:

---------------- file: sample.tex ----------------
%% -*- mode:outline-minor; -*-

% Empty
--------------------------------------------------

Opening it and emacs will put it in fundamental mode with
outline-minor-mode and it is undesirable.

However,

---------------- file: sample.tex ----------------
% Empty

%% Local Variables:
%% mode: outline-minor
%% End:
--------------------------------------------------

Emacs will put it in LaTeX/TeX mode with outline-minor-mode.

I wonder if this is a bug.

Best,
Leo

GNU Emacs 23.0.60.1 (i386-mingw-nt5.1.2600) of 2008-12-14 on BREPNB






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

* bug#2355: 23.0.60; Enabling minor-mode disables major mode
  2009-02-17 11:45 bug#2355: 23.0.60; Enabling minor-mode disables major mode Leo
@ 2009-02-17 14:37 ` Juanma Barranquero
  2009-02-17 14:45   ` Processed: " Emacs bug Tracking System
  2009-02-17 16:04   ` Leo
  0 siblings, 2 replies; 15+ messages in thread
From: Juanma Barranquero @ 2009-02-17 14:37 UTC (permalink / raw)
  To: Leo; +Cc: control, 2355

tags 2355 + notabug
quit

> ---------------- file: sample.tex ----------------
> %% -*- mode:outline-minor; -*-

You're abusing the "mode" file variable. It's intended to set the
*major* mode. See node "57.3.4.1 Specifying File Variables" in the
Emacs manual.

> ---------------- file: sample.tex ----------------
> % Empty
>
> %% Local Variables:
> %% mode: outline-minor
> %% End:
> --------------------------------------------------
>
> Emacs will put it in LaTeX/TeX mode with outline-minor-mode.
>
> I wonder if this is a bug.

No. The buffer is autodetected as tex-mode buffer, and then the local
variables section is acted upon; but calling (funcall
'outline-minor-mode) does not change the major mode, so it stays in
tex-mode.

    Juanma






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

* Processed: Re: bug#2355: 23.0.60; Enabling minor-mode disables major mode
  2009-02-17 14:37 ` Juanma Barranquero
@ 2009-02-17 14:45   ` Emacs bug Tracking System
  2009-02-17 16:04   ` Leo
  1 sibling, 0 replies; 15+ messages in thread
From: Emacs bug Tracking System @ 2009-02-17 14:45 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: Emacs Bugs

Processing commands for control@emacsbugs.donarmstrong.com:

> tags 2355 + notabug
bug#2355: 23.0.60; Enabling minor-mode disables major mode
There were no tags set.
Tags added: notabug

> quit
Stopping processing here.

Please contact me if you need assistance.

Don Armstrong
(administrator, Emacs bugs database)




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

* bug#2355: 23.0.60; Enabling minor-mode disables major mode
  2009-02-17 14:37 ` Juanma Barranquero
  2009-02-17 14:45   ` Processed: " Emacs bug Tracking System
@ 2009-02-17 16:04   ` Leo
  2009-02-17 16:43     ` Juanma Barranquero
  1 sibling, 1 reply; 15+ messages in thread
From: Leo @ 2009-02-17 16:04 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: 2355

On 2009-02-17 14:37 +0000, Juanma Barranquero wrote:
> tags 2355 + notabug
> quit
>
>> ---------------- file: sample.tex ----------------
>> %% -*- mode:outline-minor; -*-
>
> You're abusing the "mode" file variable. It's intended to set the
> *major* mode. See node "57.3.4.1 Specifying File Variables" in the
> Emacs manual.

Why is that an abuse? The manual does not specify what is not allowed.

>> ---------------- file: sample.tex ----------------
>> % Empty
>>
>> %% Local Variables:
>> %% mode: outline-minor
>> %% End:
>> --------------------------------------------------
>>
>> Emacs will put it in LaTeX/TeX mode with outline-minor-mode.
>>
>> I wonder if this is a bug.
>
> No. The buffer is autodetected as tex-mode buffer, and then the local
> variables section is acted upon; but calling (funcall
> 'outline-minor-mode) does not change the major mode, so it stays in
> tex-mode.

Sorry I was not clear. I am questioning whether the different behaviour
between these two ways of specifying local variables is a bug or not. In
my view, it is confusing at least.

>     Juanma

-- 
.:  Leo  :.  [ sdl.web AT gmail.com ]  .: I use Emacs :.






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

* bug#2355: 23.0.60; Enabling minor-mode disables major mode
  2009-02-17 16:04   ` Leo
@ 2009-02-17 16:43     ` Juanma Barranquero
  2009-02-18  7:42       ` Leo
  0 siblings, 1 reply; 15+ messages in thread
From: Juanma Barranquero @ 2009-02-17 16:43 UTC (permalink / raw)
  To: Leo; +Cc: 2355

On Tue, Feb 17, 2009 at 17:04, Leo <sdl.web@gmail.com> wrote:

> Why is that an abuse? The manual does not specify what is not allowed.

"You can specify any number of variables/value pairs in this way, each
pair with a colon and semicolon as shown above.  `mode: MODENAME;'
specifies the major mode; this should come first in the line."

It does explicitly says that mode: specifies the major mode. It does
not say that it should not be a minor mode, but it also doesn't say
that you cannot use any arbitrary function (ending in -mode). If the
function that you use does not set major-mode, it will cause confusion
(to Emacs or the user, or both).

> Sorry I was not clear. I am questioning whether the different behaviour
> between these two ways of specifying local variables is a bug or not. In
> my view, it is confusing at least.

Mode autodetection is complex (there are file variables,
interpreter-mode-alist, magic-mode-alist, magic-fallback-mode-alist,
etc.). It is not impossible to get nonsense (or, at least, unexpected)
results when given inconsistent input data. It would perhaps be better
to detect when a supposed major mode (found with -*-, auto-mode-alist
or whatever) is not really setting major-mode, but that's another bug
;-)

    Juanma






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

* bug#2355: 23.0.60; Enabling minor-mode disables major mode
  2009-02-17 16:43     ` Juanma Barranquero
@ 2009-02-18  7:42       ` Leo
  2009-02-18  8:56         ` Juanma Barranquero
  2009-02-18 14:23         ` Stefan Monnier
  0 siblings, 2 replies; 15+ messages in thread
From: Leo @ 2009-02-18  7:42 UTC (permalink / raw)
  To: bug-gnu-emacs

On 2009-02-17 16:43 +0000, Juanma Barranquero wrote:
>> Sorry I was not clear. I am questioning whether the different
>> behaviour between these two ways of specifying local variables is a
>> bug or not. In my view, it is confusing at least.
>
> Mode autodetection is complex (there are file variables,
> interpreter-mode-alist, magic-mode-alist, magic-fallback-mode-alist,
> etc.). It is not impossible to get nonsense (or, at least, unexpected)
> results when given inconsistent input data. It would perhaps be better
> to detect when a supposed major mode (found with -*-, auto-mode-alist
> or whatever) is not really setting major-mode, but that's another bug
> ;-)

But we are only talking about file variables in this case. There are two
ways of specifying file variables: in the header and at the end of the
file. 

When they contain the pseudo-variable mode specifying a minor mode, they
behave differently.

The two behaviours are as follows.

1. put file in fundamental mode and the minor mode (when in header)
2. put file in a major mode by auto mode detection and the minor mode
   (when at the end of file)

This causes confusion. Do you think this is a bug? If not, I think at
least the manual can be improved.

Thanks,
-- 
.:  Leo  :.  [ sdl.web AT gmail.com ]  .: I use Emacs :.








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

* bug#2355: 23.0.60; Enabling minor-mode disables major mode
  2009-02-18  7:42       ` Leo
@ 2009-02-18  8:56         ` Juanma Barranquero
  2011-05-10  2:33           ` Glenn Morris
  2009-02-18 14:23         ` Stefan Monnier
  1 sibling, 1 reply; 15+ messages in thread
From: Juanma Barranquero @ 2009-02-18  8:56 UTC (permalink / raw)
  To: Leo; +Cc: 2355

On Wed, Feb 18, 2009 at 08:42, Leo <sdl.web@gmail.com> wrote:

> When they contain the pseudo-variable mode specifying a minor mode, they
> behave differently.
>
> The two behaviours are as follows.

Yes, that was perfectly clear in the bug report.

> 1. put file in fundamental mode and the minor mode (when in header)
> 2. put file in a major mode by auto mode detection and the minor mode
>   (when at the end of file)
>
> This causes confusion. Do you think this is a bug?

No. It is undefined, but harmless, behavior after a user error.

> If not, I think at
> least the manual can be improved.

As I've said, I think the only way to improve the manual regarding
this issue is to make clearer that "mode:" should *not* specify a
minor mode, and that if you use it for that, you can get unexpected
behavior.

    Juanma






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

* bug#2355: 23.0.60; Enabling minor-mode disables major mode
  2009-02-18  7:42       ` Leo
  2009-02-18  8:56         ` Juanma Barranquero
@ 2009-02-18 14:23         ` Stefan Monnier
  2009-02-18 15:13           ` Juanma Barranquero
  1 sibling, 1 reply; 15+ messages in thread
From: Stefan Monnier @ 2009-02-18 14:23 UTC (permalink / raw)
  To: Leo; +Cc: bug-gnu-emacs, 2355

> But we are only talking about file variables in this case. There are two
> ways of specifying file variables: in the header and at the end of the
> file.

> When they contain the pseudo-variable mode specifying a minor mode, they
> behave differently.

> The two behaviours are as follows.

> 1. put file in fundamental mode and the minor mode (when in header)
> 2. put file in a major mode by auto mode detection and the minor mode
>    (when at the end of file)

> This causes confusion. Do you think this is a bug? If not, I think at
> least the manual can be improved.

Yes, the difference is undesirable.  IIUC there's also another
difference: if the major mode is specified at the end, it is set after
setting the major-mode based on the file name.

It would be good to fix those discrepancies.

But it would also be good to improve the documentation so as to say
clearly that at least one of the `mode's specified should be
a major mode.


        Stefan







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

* bug#2355: 23.0.60; Enabling minor-mode disables major mode
  2009-02-18 14:23         ` Stefan Monnier
@ 2009-02-18 15:13           ` Juanma Barranquero
  2009-02-18 16:58             ` Stefan Monnier
  2009-02-18 17:49             ` Leo
  0 siblings, 2 replies; 15+ messages in thread
From: Juanma Barranquero @ 2009-02-18 15:13 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Leo, 2355

On Wed, Feb 18, 2009 at 15:23, Stefan Monnier <monnier@iro.umontreal.ca> wrote:

> IIUC there's also another
> difference: if the major mode is specified at the end, it is set after
> setting the major-mode based on the file name.

That is, indeed, what causes the difference in behavior. BTW,
lisp/doc-view.el abuses it:

 ;; Local Variables:
 ;; mode: outline-minor
 ;; End:

> It would be good to fix those discrepancies.

I don't think investing effort in fixing wrong (harmless) behavior
caused by user error is very useful...

> But it would also be good to improve the documentation so as to say
> clearly that at least one of the `mode's specified should be
> a major mode.

You seem to be implying that it is OK to use mode: to set a minor
mode. That seems to contradict the docs, at least my reading of
(emacs)"27.1 How Major Modes are Chosen" and (emacs)"57.3.4.1
Specifying File Variables".

Also, a few times has been mentioned in emacs-devel that minor modes
are intended to be set by the user, not by the file.

    Juanma






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

* bug#2355: 23.0.60; Enabling minor-mode disables major mode
  2009-02-18 15:13           ` Juanma Barranquero
@ 2009-02-18 16:58             ` Stefan Monnier
  2009-02-18 17:48               ` Juanma Barranquero
  2009-02-18 18:09               ` Johan =?UTF-8?Q?Bockg=C3=A5rd
  2009-02-18 17:49             ` Leo
  1 sibling, 2 replies; 15+ messages in thread
From: Stefan Monnier @ 2009-02-18 16:58 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: Leo, 2355

> That is, indeed, what causes the difference in behavior. BTW,
> lisp/doc-view.el abuses it:

>  ;; Local Variables:
>  ;; mode: outline-minor
>  ;; End:

This seems like a misuse because it just reflects the
author's preference.

>> It would be good to fix those discrepancies.
> I don't think investing effort in fixing wrong (harmless) behavior
> caused by user error is very useful...

I do not plan on investing any effort into it.  But a patch would
probably be welcome, if it doesn't make the code more complex.

>> But it would also be good to improve the documentation so as to say
>> clearly that at least one of the `mode's specified should be
>> a major mode.

> You seem to be implying that it is OK to use mode: to set a minor mode.

Yes, it is.

> That seems to contradict the docs, at least my reading of
> (emacs)"27.1 How Major Modes are Chosen" and (emacs)"57.3.4.1
> Specifying File Variables".

My 57.3.4.1 here says:

      You can use the `mode' "variable" to set minor modes as well as the
   major modes; in fact, you can use it more than once, first to set the
   major mode and then to set minor modes which are specific to particular
   buffers.  But most minor modes should not be specified in the file at
   all, because they represent user preferences.


-- Stefan






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

* bug#2355: 23.0.60; Enabling minor-mode disables major mode
  2009-02-18 16:58             ` Stefan Monnier
@ 2009-02-18 17:48               ` Juanma Barranquero
  2009-02-18 19:46                 ` Stefan Monnier
  2009-02-18 18:09               ` Johan =?UTF-8?Q?Bockg=C3=A5rd
  1 sibling, 1 reply; 15+ messages in thread
From: Juanma Barranquero @ 2009-02-18 17:48 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Leo, 2355

On Wed, Feb 18, 2009 at 17:58, Stefan Monnier <monnier@iro.umontreal.ca> wrote:

> This seems like a misuse because it just reflects the
> author's preference.

OK.

> My 57.3.4.1 here says:
>
>      You can use the `mode' "variable" to set minor modes as well as the
>   major modes; in fact, you can use it more than once, first to set the
>   major mode and then to set minor modes which are specific to particular
>   buffers.  But most minor modes should not be specified in the file at
>   all, because they represent user preferences.

OK, I'll eat my words right now :-)  (Sorry, Leo, you were right)

OTOH, I think that's a documentation bug (ordering, not content).
There's this paragraph at the start:

  You can specify any number of variables/value pairs in this way, each
  pair with a colon and semicolon as shown above.  `mode: MODENAME;'
  specifies the major mode; this should come first in the line.  The
  VALUEs are not evaluated; they are used literally.  Here is an example
  that specifies Lisp mode and sets two variables with numeric values:

then about fifty lines discussing other things, then

      Some "variable names" have special meanings in a local variables
   list.  Specifying the "variable" `mode' really sets the major mode,
   while any value specified for the "variable" `eval' is simply evaluated
   as an expression (its value is ignored). [...etc...]

(which again seems to suggest that mode: sets the major mode, BTW),
then the two paragraphs that talk about minor modes. So after three
quick browses of that node in search of mode information, I failed to
get the significant info. While I readily admit that my reading
ability in hurried situations (and foreign languages) could be
improved, I'd like to suggest that 57.3.4.1 would also benefit from
some reordering. :)

    Juanma






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

* bug#2355: 23.0.60; Enabling minor-mode disables major mode
  2009-02-18 15:13           ` Juanma Barranquero
  2009-02-18 16:58             ` Stefan Monnier
@ 2009-02-18 17:49             ` Leo
  1 sibling, 0 replies; 15+ messages in thread
From: Leo @ 2009-02-18 17:49 UTC (permalink / raw)
  To: bug-gnu-emacs

On 2009-02-18 15:13 +0000, Juanma Barranquero wrote:
>> It would be good to fix those discrepancies.
>
> I don't think investing effort in fixing wrong (harmless) behavior
> caused by user error is very useful...

You seem to always regard my use case wrong. Actually it is entirely
legitimate in accordance with the manual, not to mention there are many
similar cases one can find in the internet. The fact is people are using
mode to specify minor mode and there is no other means that can offer
more flexibility.

-- 
.:  Leo  :.  [ sdl.web AT gmail.com ]  .: I use Emacs :.








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

* bug#2355: 23.0.60; Enabling minor-mode disables major mode
  2009-02-18 16:58             ` Stefan Monnier
  2009-02-18 17:48               ` Juanma Barranquero
@ 2009-02-18 18:09               ` Johan =?UTF-8?Q?Bockg=C3=A5rd
  1 sibling, 0 replies; 15+ messages in thread
From: Johan =?UTF-8?Q?Bockg=C3=A5rd @ 2009-02-18 18:09 UTC (permalink / raw)
  To: bug-gnu-emacs

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> My 57.3.4.1 here says:
>
>       You can use the `mode' "variable" to set minor modes as well as the
>    major modes; in fact, you can use it more than once, first to set the
>    major mode and then to set minor modes which are specific to particular
>    buffers.  But most minor modes should not be specified in the file at
>    all, because they represent user preferences.

Indeed.  But then there's the issue that minor modes are toggled, not set.








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

* bug#2355: 23.0.60; Enabling minor-mode disables major mode
  2009-02-18 17:48               ` Juanma Barranquero
@ 2009-02-18 19:46                 ` Stefan Monnier
  0 siblings, 0 replies; 15+ messages in thread
From: Stefan Monnier @ 2009-02-18 19:46 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: Leo, 2355

> (which again seems to suggest that mode: sets the major mode, BTW),
> then the two paragraphs that talk about minor modes. So after three
> quick browses of that node in search of mode information, I failed to
> get the significant info. While I readily admit that my reading
> ability in hurried situations (and foreign languages) could be
> improved, I'd like to suggest that 57.3.4.1 would also benefit from
> some reordering. :)

Patches welcome ;-)


        Stefan






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

* bug#2355: 23.0.60; Enabling minor-mode disables major mode
  2009-02-18  8:56         ` Juanma Barranquero
@ 2011-05-10  2:33           ` Glenn Morris
  0 siblings, 0 replies; 15+ messages in thread
From: Glenn Morris @ 2011-05-10  2:33 UTC (permalink / raw)
  To: 2355-done

Version: 24.1

The use of "mode:" to enable minor modes is now deprecated
(precisely because it has problems like this and others).
Use "eval: (minor-mode)" instead. See bug#8613.





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

end of thread, other threads:[~2011-05-10  2:33 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-17 11:45 bug#2355: 23.0.60; Enabling minor-mode disables major mode Leo
2009-02-17 14:37 ` Juanma Barranquero
2009-02-17 14:45   ` Processed: " Emacs bug Tracking System
2009-02-17 16:04   ` Leo
2009-02-17 16:43     ` Juanma Barranquero
2009-02-18  7:42       ` Leo
2009-02-18  8:56         ` Juanma Barranquero
2011-05-10  2:33           ` Glenn Morris
2009-02-18 14:23         ` Stefan Monnier
2009-02-18 15:13           ` Juanma Barranquero
2009-02-18 16:58             ` Stefan Monnier
2009-02-18 17:48               ` Juanma Barranquero
2009-02-18 19:46                 ` Stefan Monnier
2009-02-18 18:09               ` Johan =?UTF-8?Q?Bockg=C3=A5rd
2009-02-18 17:49             ` Leo

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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