From: "Michael A. Shulman" <shulman@ugcs.caltech.edu>
Cc: emacs-devel@gnu.org
Subject: Re: [MMM] Re: narrow-to-here-document
Date: Mon, 7 Jul 2003 16:45:41 -0700 [thread overview]
Message-ID: <20030707234541.GC11786@schilling.ugcs.caltech.edu> (raw)
In-Reply-To: <200307040032.h640WhKL015234@rum.cs.yale.edu>
On Thu, Jul 03, 2003 at 08:32:43PM -0400, Stefan Monnier wrote:
> I think we need feedback from the mmm-mode people before making any
> decision on such an issue. I haven't looked at mmm-mode recently,
> but it used to try and deal with font-lock, indentation and stuff like
> that. I'd actually expect them to need/want ad-hoc support from
> font-lock.el (for example) but haven't heard anything (maybe they
> complain about such things in their own .el files rather than here).
Our current implementation is able to do reasonably well by using
font-lock-fontify-region-function and font-lock-beginning-of-syntax-function,
but we'd love to have better support from font-lock (and other
packages) for this sort of thing. Thanks, Stefan, for crossposting to
the mmm list, since I wasn't following emacs-devel.
Briefly, the way mmm-mode works is to parse the buffer for regions
that it thinks (based on its configuration) ought to be edited using a
different major mode, and create overlays to mark those positions.
(It's not currently as good as we'd like at updating these overlays
dynamically as text is edited, but I believe this is just because no
one has sat down to write good code to do it.) Then it uses
post-command-hook to check which region the point is in and make the
buffer look (almost) like it's in the associated major mode. It
primarily does this by changing keymaps, syntax tables, and lots of
other buffer-local variables. Some of these values are stored
buffer-locally, and others region-locally (all managed manually, of
course).
I don't mean to co-opt this disucssion for mmm, since it started on a
somewhat different (though related) topic. But a "wish list" of
possible features in emacs to make mmm and related packages easier has
been on my mind for a while, and the discussion has been moving in
that direction. So here are a few things I think emacs could do to
make this sort of stuff easier and more effective.
1. Have a "registry" of some sort for major modes, where they can
store enough information for mmm to turn them on effectively in small
regions. Currently, the way mmm finds out what local variables and so
on to set for each mode is to create temporary buffers and save the
values of individual local variables. Among other things, this
requires mmm mode knowing about all local variables that any major
mode could want to set, and so we have a huge list of what variables
to look for and what modes to look for them in. In addition, some
major modes expect things like a file name set in all buffers, so we
have to do kludgy things to the temporary buffer to try to make them
work.
2. Have some sort of built-in support for variables that are localized
to a text region within a buffer, such as an overlay or a text
property. I'm not sure how or if this would work in general, but it's
effectively what mmm does already to some extent. In particular, some
variables want to keep different values in different regions even of
the same major mode, in particular variables that store the state of
syntax parsing. This leads to...
3. Better support in the syntax parsing routines allowing the caller
to specify starting and ending positions and states. One of
our biggest problems is that submodes end up trying to parse their
syntax beyond the beginning of their region and getting confused, so
ideally we would be able to tell them where to start their parsing,
and what state to start parsing in. Sometimes the start state needs
to be a continuation of the end state of the previous region in that
mode (as with some literate programming, PHP, etc.), but sometimes
it ought to be an independent start for each region.
This is similar to the 'syntactic realm' idea that David Kastrup
suggested. I don't think we've tried using intangible properties, for
the reasons mentioned and perhaps others, but Joe Kelsey has had some
success using syntax-table text properties to make the text that's not
supposed to be parsed be treated as a single word or as whitespace, as
appropriate. Joe, want to comment?
4. Effectively the same thing for font-lock, which uses the syntax
parsing functions but also its own parsing functions. In general
we've had more success hacking around font-lock than around syntax,
because font-lock provides more customization variables and its state
is easier to understand.
If we want to continue this discussion, should it stay crossposted, or
only on emacs-devel?
--
Michael A. Shulman
http://www.ugcs.net/~shulman
The goal of psychological, as of biological, development is
self-realization, or individuation. But since man knows himself only
as an ego, and the self, as a totality, is indescribable and
indistinguishable from a God-image, self-realization... amounts to
God's incarnation.
-- Carl Gustav Jung
next prev parent reply other threads:[~2003-07-07 23:45 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-06-20 13:59 narrow-to-here-document Masatake YAMATO
2003-06-20 14:10 ` narrow-to-here-document Ilya Zakharevich
2003-06-20 16:26 ` narrow-to-here-document Masatake YAMATO
2003-06-21 7:15 ` narrow-to-here-document Stephen J. Turnbull
2003-06-21 8:01 ` narrow-to-here-document David Kastrup
2003-06-21 14:19 ` narrow-to-here-document Ilya Zakharevich
2003-06-21 14:48 ` narrow-to-here-document David Kastrup
2003-06-22 8:33 ` narrow-to-here-document Ilya Zakharevich
2003-06-23 17:10 ` narrow-to-here-document Kevin Rodgers
2003-06-25 6:10 ` narrow-to-here-document Masatake YAMATO
2003-06-25 8:04 ` narrow-to-here-document David Kastrup
2003-06-25 8:21 ` narrow-to-here-document Masatake YAMATO
2003-06-26 0:34 ` narrow-to-here-document Kim F. Storm
2003-06-26 5:30 ` narrow-to-here-document Richard Stallman
2003-06-25 23:18 ` narrow-to-here-document Stefan Daschek
2003-06-26 5:59 ` mmm-mode.el(Re: narrow-to-here-document) Masatake YAMATO
2003-06-26 6:12 ` narrow-to-here-document David Kastrup
2003-06-26 13:00 ` narrow-to-here-document Alan Shutko
2003-06-30 0:34 ` narrow-to-here-document Miles Bader
2003-06-30 6:13 ` narrow-to-here-document Kai Großjohann
2003-06-30 17:19 ` narrow-to-here-document David Kastrup
2003-06-30 20:11 ` narrow-to-here-document Kai Großjohann
2003-07-04 0:07 ` narrow-to-here-document Stefan Monnier
2003-07-04 6:46 ` narrow-to-here-document Kai Großjohann
2003-07-01 15:17 ` narrow-to-here-document Richard Stallman
2003-07-04 0:32 ` narrow-to-here-document Stefan Monnier
2003-07-07 23:45 ` Michael A. Shulman [this message]
2003-07-08 7:19 ` [MMM] narrow-to-here-document Kai Großjohann
2003-07-10 16:44 ` Richard Stallman
2003-07-08 14:12 ` mmm-mode needs (was: narrow-to-here-document) Stefan Monnier
2003-07-08 20:02 ` [MMM] Re: narrow-to-here-document Richard Stallman
2003-06-25 16:58 ` narrow-to-here-document Kevin Rodgers
[not found] ` <20030625.143750.116352160.jet@gyve.org>
2003-06-26 5:29 ` narrow-to-here-document Richard Stallman
2003-06-26 7:19 ` narrow-to-here-document Miles Bader
2003-06-26 17:45 ` narrow-to-here-document Tak Ota
2003-06-26 23:10 ` narrow-to-here-document David Kastrup
2003-06-27 2:07 ` narrow-to-here-document Miles Bader
2003-06-27 2:49 ` narrow-to-here-document Richard Stallman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030707234541.GC11786@schilling.ugcs.caltech.edu \
--to=shulman@ugcs.caltech.edu \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.