[Top][All Lists]

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

enriched-mode and switching major modes.

From: Luc Teirlinck
Subject: enriched-mode and switching major modes.
Date: Sat, 4 Sep 2004 18:58:45 -0500 (CDT)

I noted in an earlier message that when visiting a file that Emacs
earlier saved in text/enriched format, say enriched.text (which forces
Text mode), Enriched mode is turned on, but `use-hard-newlines' is nil
(and hence hard newlines do not work).  I suggested solving that
problem by making `use-hard-newlines' a permanent local and Richard
agreed.  I still believe that `use-hard-newlines' should be a
permanent local, regardless of the problems with Enriched mode, but I
will wait a little bit before installing, since some related issues
need to be discussed..

There are several other similar problems.  In the same enriched.text
buffer, `default-text-properties' is nil, which also messes up some
stuff.  Also, `indent-line-function' is `indent-relative' instead of
`indent-to-left-margin'.  `buffer-display-table' is nil.
`enriched-old-bindings' is nil.  These problems have the same cause as
the one I noted earlier for `use-hard-newlines'.  `enriched-mode' sets
buffer-local values for these variables, but when the major mode is
set by `after-find-file', these variables are killed.

Of course, similar problems arise whenever the _user_ switches major
modes in a buffer already in Enriched mode: all local variables are

Enriched mode is currently a minor mode and a permanent local as a
variable.  It can not possibly set local variables that are
non-permanent locals for the reasons described above.  If it _has_ to
do that, it should be a major mode.

One solution is to make Enriched mode into a major mode.  It already
very much "feels" like one.

The other solution would be to make all variables that Enriched mode
needs to set permanent locals.  For `use-hard-newlines' we already
decided that there was no problem. 

`default-text-properties' is currently not even an automatically local
variable, but maybe it should be made into a permanent local.  It is
_only_ used by enriched mode, so making it into a permanent local
should not cause problems.

`buffer-display-table' is used by several other packages, but all seem
to use it in buffers where changing the major mode does not seem to
make any sense to begin with.  So it could be made into a permanent local.

I believe that there is no way to make `indent-line-function' into a
permanent local.  Here, I believe that the solution is to no longer
have Enriched mode set the variable.  Setting `indent-line-function'
is the prerogative of the major mode.  If Enriched mode absolutely
_needs_ to set `indent-line-function' to `indent-to-left-margin', then
Enriched mode _needs_ to be a major mode (and then the other problems
automatically disappear).

`enriched-old-bindings' should not be a permanent local.  Its
implementation is iffy to begin with.  Here I believe all we can do is
rely on the fact that disabling Enriched mode only seems to make sense
if it was enabled by mistake.  Thus, problems arising from
`enriched-old-bindings' having the wrong value, though they
theoretically exist, are unlikely to arise in practice.  Making
Enriched mode into a major mode would make `enriched-old-bindings'
completely unnecessary.



reply via email to

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