This commit is contained in:
Raymundo Vásquez Ruiz
2019-12-01 19:55:19 +01:00
parent db783b92af
commit b62e260b24
460 changed files with 21878 additions and 4341 deletions

16
elpa/mmm-mode-0.5.7/.gitignore vendored Normal file
View File

@@ -0,0 +1,16 @@
autom4te.cache
aclocal.m4
configure
config.log
config.status
Makefile
Makefile.in
elc-stamp
mmm.info*
*.elc
*.tar.gz
script
stamp-vti
version.texi
mmm-mode-pkg.el
mmm-mode-autoloads.el

View File

@@ -0,0 +1,16 @@
MMM Mode was originally designed and written by Michael Shulman
<viritrilbia@gmail.com>.
It was inspired by mmm.el for XEmacs by Gongquan Chen <chen@posc.org>.
Recent contributors have included:
bishop <bishop@platypus.bc.ca>
Joe Kelsey <joe@zircon.seattle.wa.us>
Alan Shutko <ats@acm.org>
Michael Alan Dorman <mdorman@users.sourceforge.net>
Brian P Templeton <plovre@users.sourceforge.net>
Yann Dirson <ydirson@fr.alcove.com>
Marcus Harnisch
and others...

340
elpa/mmm-mode-0.5.7/COPYING Normal file
View File

@@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,24 @@
-*-text-*-
Checklist for New MMM Mode Releases
0. Test all new code, under all Emacsen if possible. Check that the
package builds and installs.
1. Check everything into Git.
2. Update the NEWS and TODO files and any other commentary files and
check them into Git.
3. Update version numbers and dates in `mmm-mode.el', `configure.in',
and `mmm-vars.el'. Check them in with comment "Released x.x.x".
4. Make a Git snapshot (`C-x v s') of the MMM Mode directory. This is
the point at which a release becomes official.
5. Run `make dist' and upload the tarball. Upload to SourceForge.
Adding Files
To add a file to the distribution, edit `Makefile.am' and add it to
lisp_LISP (if an .el file) or EXTRA_DIST (otherwise). If necessary,
add autoloads for functions or submode classes to `mmm-auto.el'.

192
elpa/mmm-mode-0.5.7/FAQ Normal file
View File

@@ -0,0 +1,192 @@
-*-outline-*-
Frequently Asked Questions about MMM Mode
=========================================
* How do I write/capitalize the name of this package/mode?
However you want. The author says `MMM Mode' (and occasionally `MMM')
when discussing the entire package, and `mmm-mode' when discussing the
emacs mode or function. He does think, however, that `Mmm' looks
rather ugly, although that is how SourceForge insists on capitalizing
the name of the mailing list.
* How do I get rid of that ugly gray background color?
Put the following line in your Emacs initialization file:
(setq mmm-submode-decoration-level 0)
You may want to try using MMM Mode for a while with the background
highlight, however, or merely changing it to a different color. There
are two reasons it's there by default:
1. MMM Mode isn't as smart as you might hope it would be about
recognizing new submode regions, so the presence or absence of the
highlight can let you know at a glance where it thinks they are.
2. Just like the rest of font-lock, it helps you mentally organize the
code; you can see at a glance that THIS code is executed as Perl,
but THAT code is straight HTML (or whatever). You can get even
more help by setting the above variable to 2, in which case regions
will get a background color according to their function.
* I typed `<%' (or other delimiter) but I'm still in the wrong mode.
MMM Mode isn't that smart yet. You have to tell it explicitly to
reparse (`C-c % C-5' or `C-c % C-b') when you add new submode regions,
and both delimiters have to be present. Hopefully a future version
will be able to automatically recognize new regions an you type them,
but that version is not yet here.
However, most submode classes provide insertion commands that remove
the need to type the delimiters as well as the need to reparse the
block: type `C-c % h' for a list of available insertion commands for
current submode class(es).
With a recent update, you can set `mmm-parse-when-idle' to t, to allow
MMM Mode to reparse the buffer when it's modified and Emacs is idle.
This comes at a certain performance cost.
* Why is the first character of the end delimiter in the submode region?
It isn't. When your cursor looks like it is over that character, it
is actually *before* that character and therefore inside the submode
region. You can check that the offending character does not have the
background highlight--that is, if you haven't set the decoration level
to 0. For example, in the following text (where -!- represents the
cursor position)
print <<END_TEXT;
here is some text
-!-END_TEXT
The 'E' at the beginning of the END_TEXT line is not actually part of
the submode region. But with the cursor as indicated (that is, the
box is blinking over the `E' which follows the actual cursor
position), Emacs is in text-mode.
* Why won't MMM Mode work with `foo-mode'?
Foo-mode probably has extra variables or states that need to be set
up, that MMM Mode doesn't yet know about. Often this sort of problem
can be fixed by adding elements to `mmm-save-local-variables'. If you
know some Elisp, you may want to try and track down the problem
yourself, or you can contact the mailing list and ask for help.
Either way, please file an issue, so that in the future, folks can
use MMM Mode and foo-mode together more easily.
* I'm getting an emacs error, what did I do wrong?
Most likely nothing. MMM Mode is still more or less alpha software
and is quite likely to contain bugs; probably something in your
configuration has brought a new bug to light. Please send the text of
the error, along with a stack backtrace (1) and the relevant portions
of your emacs initialization file, to either the maintainer or the
mailing list, and hopefully a fix can be worked out.
Of course, it's also possible that there is an error in your
configuration. Double-check the elisp syntax in your init file, or
inspect the backtrace yourself. If the error happens while loading
your init code, try manually evaluating it line by line (`C-x C-e') to
see where the error occurs. Folks on the mailing list can also help
point out errors, but only with your init code and a backtrace.
If you're having a problem with syntax highlighting, debugging is
complicated by the fact that font-lock swallows errors. To trigger the
error, evaluate the following in the problem buffer (with `M-:'):
(font-lock-fontify-region (point-min) (point-max))
(1) To get a stack backtrace of an error, set the emacs variable
`debug-on-error' to non-nil (type `M-x toggle-debug-on-error RET' or
`M-: (setq debug-on-error t) RET'), then repeat the actions which
caused the error. A stack backtrace should pop up which you can
select and copy. If the error occurs while loading emacs, invoke
emacs with the `--debug-init' (Emacs) or `-debug-init' (XEmacs)
switch.
* Will MMM Mode work with (Emacs 23 / XEmacs 20 / XEmacs 21 / etc...)?
MMM Mode was designed for FSF Emacs and works best in versions 23 and 24.
But don't let that stop you from trying it under other variants of
emacs. If you encounter problems, feel free to ask the mailing list,
but success is not guaranteed.
XEmacs 21 has problems with font-lock: for example, often apostrophes in
a different submode region can cause code to be incorrectly font-locked
as a string.
Versions of FSF Emacs < 23 and XEmacs < 21 are not supported.
* XEmacs says `Symbol's function definition is void: make-indirect-buffer'.
You probably used FSF Emacs to compile MMM as it is the one used by
default if both are installed. To explicitly set the emacs to use
when byte compiling, do the following:
$ cd mmm-mode-x.x.x
$ make distclean
$ ./configure --with-xemacs=/path/to/xemacs
$ make
$ make install
Running `make distclean' is only necessary if you have already
compiled MMM Mode for the wrong emacs, but can never hurt. The exact
error message this problem produces may change with newer versions of
MMM Mode; always be sure you have compiled for the correct emacsen.
* I want to install the Git version, but there's no `configure' script.
The `configure' script which is included in the official distributions
is not present in Git, because it is automatically generated by GNU
Automake/Autoconf from files like `Makefile.am' and `configure.in'.
To build the Git version the same way as the official distributions,
you must first run `autogen.sh':
$ cd mmm-mode
$ ./autogen.sh
and then you can continue as usual:
$ ./configure
$ make
$ make install
Note that autogen.sh requires aclocal, automake, and autoconf, which
may or may not be installed on your system, since they are considered
developer tools rather than end-user tools. If you can't or don't
want to install them, however, you can still use the Git version of
MMM Mode by manually copying all the `.el' files into a directory in
your `load-path'. Optionally, you may also byte-compile them manually
(this is what `make' normally does). Byte-compiling gives some speed
improvement, but if you experience problems, the stack traces are
sometimes more informative if you are using the source files only.
The Info files `mmm.info-*' are also not included in Git, since they
are generated from `mmm.texinfo' by the program `makeinfo'. If you
want to install the Info documentation from Git, you will have to run
this manually as well, and copy the resulting info files into the
appropriate location for your system.
The Git version is, of course, even less guaranteed to be bug-free
than the official distributions. But please report any problems you
have with it, so they can be fixed for the next release.
* You haven't answered my question; how can I get more help?
Create an issue at <https://github.com/purcell/mmm-mode/issues>, or
check out the MMM Mode web site, <http://mmm-mode.sourceforge.net>,
there is a link to the subscription page for the MMM Mode mailing list.
When asking a question or reporting a problem, be sure to give the
versions of emacs and MMM Mode you are using, and any other relevant
information.

182
elpa/mmm-mode-0.5.7/INSTALL Normal file
View File

@@ -0,0 +1,182 @@
Basic Installation
==================
These are generic installation instructions.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, a file
`config.cache' that saves the results of its tests to speed up
reconfiguring, and a file `config.log' containing compiler output
(useful mainly for debugging `configure').
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If at some point `config.cache'
contains results you don't want to keep, you may remove or edit it.
The file `configure.in' is used to create `configure' by a program
called `autoconf'. You only need `configure.in' if you want to change
it or regenerate `configure' using a newer version of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system. If you're
using `csh' on an old version of System V, you might need to type
`sh ./configure' instead to prevent `csh' from trying to execute
`configure' itself.
Running `configure' takes awhile. While running, it prints some
messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package.
4. Type `make install' to install the programs and any data files and
documentation.
5. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that
the `configure' script does not know about. You can give `configure'
initial values for variables by setting them in the environment. Using
a Bourne-compatible shell, you can do that on the command line like
this:
CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
Or on systems that have the `env' program, you can do it like this:
env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you must use a version of `make' that
supports the `VPATH' variable, such as GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
If you have to use a `make' that does not supports the `VPATH'
variable, you have to compile the package for one architecture at a time
in the source code directory. After you have installed the package for
one architecture, use `make distclean' before reconfiguring for another
architecture.
Installation Names
==================
By default, `make install' will install the package's files in
`/usr/local/bin', `/usr/local/man', etc. You can specify an
installation prefix other than `/usr/local' by giving `configure' the
option `--prefix=PATH'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
give `configure' the option `--exec-prefix=PATH', the package will use
PATH as the prefix for installing programs and libraries.
Documentation and other data files will still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=PATH' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them.
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features
=================
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Specifying the System Type
==========================
There may be some features `configure' can not figure out
automatically, but needs to determine by the type of host the package
will run on. Usually `configure' can figure that out, but if it prints
a message saying it can not guess the host type, give it the
`--host=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name with three fields:
CPU-COMPANY-SYSTEM
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the host type.
If you are building compiler tools for cross-compiling, you can also
use the `--target=TYPE' option to select the type of system they will
produce code for and the `--build=TYPE' option to select the type of
system on which you are compiling the package.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `config.site' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Operation Controls
==================
`configure' recognizes the following options to control how it
operates.
`--cache-file=FILE'
Use and save the results of the tests in FILE instead of
`./config.cache'. Set FILE to `/dev/null' to disable caching, for
debugging `configure'.
`--help'
Print a summary of the options to `configure', and exit.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
messages will still be shown).
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`--version'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`configure' also accepts some other, not widely useful, options.

View File

@@ -0,0 +1,16 @@
## Process this file with automake to produce Makefile.in
## The MMM Mode distribution is `flat', so we have no SUBDIRS macro.
lisp_LISP = mmm-compat.el mmm-vars.el mmm-utils.el mmm-auto.el \
mmm-region.el mmm-class.el mmm-cmds.el mmm-mode.el \
mmm-sample.el mmm-mason.el mmm-univ.el mmm-rpm.el mmm-cweb.el \
mmm-noweb.el mmm-myghty.el mmm-erb.el mmm-defaults.el
info_TEXINFOS = mmm.texinfo
# This is a hack IMO. Automake should recognize lisp files as
# "sources" and include them in the distribution, but it doesn't.
EXTRA_DIST = $(lisp_LISP) README.Mason FAQ
# See also `elisp-comp' for another hack.

328
elpa/mmm-mode-0.5.7/NEWS Normal file
View File

@@ -0,0 +1,328 @@
MMM Mode NEWS -- history of user-visible changes. -*-outline-*-
Copyright (C) 2003, 2004, 2013-2015 Free Software Foundation, Inc.
See the file COPYING for copying conditions.
Please submit bug reports at https://github.com/purcell/mmm-mode/issues
* Changes in MMM Mode 0.5.7
Fixes for mmm-indent-line-narrowed.
* Changes in MMM Mode 0.5.6
Emacs 25 compatibility fix when cl is not loaded.
* Changes in MMM Mode 0.5.5
Introduced mode transition hooks, like mmm-x-enter-hook and mmm-y-exit-hook.
New function mmm-indent-line-narrowed, to use as mmm-indent-line-function.
`cl-lib' is a new dependency, replacing `cl'. It comes bundled with
recent versions of Emacs, and for older ones it can be installed from
GNU ELPA.
* Changes in MMM Mode 0.5.4
Fixes for indentation, SMIE support, and minor bugs.
* Changes in MMM Mode 0.5.2
Introduced `mmm-after-syntax-propertize-functions'. A primary major
mode can set it to adjust `syntax-table' text properties in submode
regions.
New file `mmm-defaults.el'. A user can simply require it and have
basic setup for ERB, EJS and PHP files (for the last one, `php-mode'
has to be installed separately).
`mmm-add-classes' is autoloaded.
`mmm-beginning-of-syntax' was removed.
Assorted highlighting and syntax detection improvements.
* Changes in MMM Mode 0.5.1
Some minor documentation updates and bugfixes.
* Changes in MMM Mode 0.5.0
** Compatibility with recent Emacsen
Updated to work with Emacs 23 and 24. Removed some compatibility code
for older versions. Added new local variables used in the latest js-mode
and cc-engine modes.
** New submode classes
New submode classes for ERB and EJS templates, both in mmm-erb.el. It
also includes a smart indentation algorithm, supporting them together
with script and style tag subregions in HTML code.
** Parsing when idle
Setting `mmm-parse-when-idle' will make MMM Mode re-parse modified
buffers when Emacs is idle. This can lead to visible pauses, though,
depending on the size of the buffer and the number of subregions.
** Support submode-specific syntax functions
Relevant for Emacs 24: we define a composite syntax-propertize-function
that delegates syntax recognition to respective submode functions.
For users, this means regular expressions in js-mode and string
interpolations and percent literals in ruby-mode.
** Indentation
More consistent indentation behavior, the default implementation
delegates to the submode at the end of the indentation.
The major mode can provide its own implementation by setting
mmm-indent-line-function, to handle specific mode combinations better.
* Changes in MMM Mode 0.4.8
** Delimiter Regions
The delimiters which mark off submode regions now have their own
overlays. They can be highlighted if you so desire using appropriate
class arguments and/or the variable mmm-delimiter-face. They are also
in an appropriate major mode, or non-mode as the case may be.
** Nested Submodes
Nested submodes are now vaguely supported.
** RPM Spec File
An RPM spec file, contributed by <bishop@platypus.bc.ca>, is now
included for people who wish to build their own SRPM to install from.
** New Submode Classes
Many thanks to Joe Kelsey for writing a very intelligent class for
editing Noweb files, and to Alan Shutko for one for CWeb files. We
also have a mode for SGML DTD definitions from Yann Dirson.
** Numerous bugfixes and small improvements
* Changes in MMM Mode 0.4.7
** Multiple Decoration Levels
You now have finer control over how colorful your submode regions are,
via `mmm-submode-decoration-level'. Level 0 turns coloring off--no
messing around with faces required. Level 1 (default) is the same as
in previous versions. Level 2 colors regions according to function:
initialization, cleanup, output, declaration, comment, etc.
** Preferred Major Modes
The variable `mmm-major-mode-preferences' lets you tell MMM what modes
you prefer for different programming languages and they will be used
by all submode classes.
** New Submode Classes
New submode classes for JSP and ePerl are included. A major bug in
the handling of embedded Java (and other C-type languages) was fixed,
so the JSP class should work consistently.
* MMM Mode 0.4.6 is a bug-fix release with one user-visible change:
** New Submode Class for RPM Spec Files
Contributed by Marcus Harnisch, the `rpm' submode class allows editing
appropriate parts of RPM spec files in shell-script mode.
* Changes in MMM Mode 0.4.5
** Font-Lock works again in XEmacs
The MMM code to handle font-locking broke in XEmacs several versions
back due to differences in the font-lock implementation between Emacs
and XEmacs. It appears to be working once again.
** Here-Document submode class improved
Here-document names such as <<TEXT_EOF and <<END_PERL_CODE are now
correctly recognized, and `mmm-here-doc-mode-alist' allows you to
define your own mappings from here-document names to submodes.
* Changes in MMM Mode 0.4.4
** Tab Completion in `mmm-ify-by-class' (`C-c % C-c')
When interactively specifying a submode class, completion on all
defined public (not internal/private) submode classes is available.
** Submode classes can now be autoloaded
You don't need (require 'mmm-mason) or (require 'mmm-sample) in your
.emacs file any more; all the supplied submode classes that are not
automatically loaded are autoloaded from their files of definition.
** Here-Document submode class can now recognize any submode
As long as the name of the here-document is or begins with the name of
the appropriate submode, suitably mangled, such as <<HTML or
<<HTML_MODE or <<HTML_MODE_EOF, it should be correctly recognized.
** New File Variables submode class
Actually, this is an old submode class that now works (better than
before) with the new post-0.3.8 syntax for class definition. It is a
good candidate for membership in `mmm-global-classes' if you use many
file-local variables, but is not there by default.
** New flags :include-{front,back}
If the keywords INCLUDE-FRONT or INCLUDE-BACK are set to non-nil
values in a submode class definition, the corresponding delimiter will
be included inside the submode region.
** New values for :{front,back}-offset
The keywords FRONT-OFFSET and BACK-OFFSET can now be function to call,
such as `beginning-of-line' or `end-of-line', or lists of values to
apply in sequence, such as (end-of-line 1).
** Search for next region now starts at end of previous one
...rather than at the end of the previous region's ending delimiter.
This allows matching regions ended only by the start of the next one.
* Changes in MMM Mode 0.4.3
** Syntax of Universal Class Changed
Instead of %[MODE]% ... %[/MODE]%, the universal class now uses
{%MODE%} ... {%/MODE%} which isn't quite as ugly and doesn't to my
knowledge conflict with any other syntax.
** Some Bugs under Emacs 19 and XEmacs Fixed
* Changes in MMM Mode 0.4.2
** Global Classes and `Universal' Class
The new variable `mmm-global-classes' is the inverse of `mmm-classes'
in that it contains submode classes which apply to all MMM Mode
buffers unless turned off manually with file-local variables. By
default, it contains the class `universal', which defines the syntax
%[MODE]% ... %[/MODE]% to specify regions of any mode. This allows,
for instance, example code embedded in an email to be both edited by
the sender and viewed by the receiver in an appropriate mode.
** New Embperl Submode Class
The new supplied submode class `embperl', which can be loaded with
(require 'mmm-sample), detects the Embperl syntax [+...+] (and so on)
for embedded Perl code.
* Changes in MMM Mode 0.4.1
** Font Lock Parsing Speed Improved
Extra regions were being parsed due to an error in finding the right
regions, slowing down the parsing considerably. This has been fixed.
* Changes in MMM Mode 0.4.0
** Improved Local Variable Saving
Local variables can now be saved for only some major modes, as well as
both globally, per-buffer, or per-submode region. This facility is
now used to save the font-lock cache state, possible improving the
font-lock support. See the docs for `mmm-save-local-variables'.
** Get and Set Class Parameters
The functions `mmm-[get,set]-class-parameters' do just that. The
latter modifies the definition of a submode class, affecting all
subsequent applications of that class.
** New Implementation for MMM Global Mode
The implementation of MMM Global Mode has been changed from the
"stack-walk" method to the "post-command-hook" method used by
global-font-lock-mode. This is arguably cleaner, but more
importantly, waits until after all local variables and text are loaded
before trying to enabling MMM Mode.
* MMM Mode 0.3.10 is a bug-fix release with no user-visible changes
* MMM Mode 0.3.9 is a bug-fix release with no user-visible changes
* Changes in MMM Mode 0.3.8
** IMPORTANT: Default key bindings have changed.
The MMM Mode commands, including interactive MMM-ification and
re-parsing buffer regions, are now bound by default to key sequences
of the form `C-c % C-<letter>', rather than `C-c % <letter>' as
in previous versions. Key sequences of the form `C-c % <letter>' are
now reserved for submode region insertion. The old behavior can be
restored by setting the variable `mmm-use-old-command-keys' to a
non-nil value before MMM Mode is loaded--then insertion commands are
bound to `C-c % C-<letter>' sequences.
** New Global Mode added
MMM Global Mode can now turn MMM Mode on automatically in all buffers,
or only in buffers that have associated submode classes. It replaces
the previous function `mmm-add-find-file-hook', which still works for
now. A side effect of this change is that it is no longer necessary
to use `mmm-add-mode-ext-class': `mmm-mode-ext-classes-alist' can be
modified directly.
The hack used by MMM Global Mode to insinuate itself into all buffers
is different from, but vaguely similar to, the one used by FSF Emacs'
Global Font Lock Mode. In order that future writers of global modes
don't have to reinvent the wheel, MMM Global Mode provides the hook
`mmm-major-mode-hook' which is run (in theory) whenever a major mode
starts up. Perhaps in future this will be provided in a separate
package.
** Automatic submode region insertion commands
Submode classes can now define skeletons for automatic insertion of
submode regions with delimiters. For example, when using the Mason
class, the key sequence `C-c % %' will (by default) insert the text
`<% -!- %>' with point where indicated and submode region already
present. These commands also wrap around words as described in the
documentation of `skeleton-insert'.
** Info Documentation File
MMM Mode now has an (admittedly incomplete) manual in Texinfo format.
It can be found in the files `mmm.info' or `mmm.texinfo' in the
distribution.
** Automatic Installation
MMM Mode now uses GNU automake/autoconf for ease of installation. See
the files README and INSTALL for more information.
** Changed submode class specification format
This change affects only people who define their own submode classes.
The format for defining submode classes has changed; it now uses
keyword arguments for clarity and has a few more possible arguments,
including skeletons for submode region insertion.

110
elpa/mmm-mode-0.5.7/README Normal file
View File

@@ -0,0 +1,110 @@
MMM Mode for Emacs
==================
OVERVIEW
MMM Mode is a minor mode for Emacs that allows Multiple Major Modes
to coexist in one buffer. It is well-suited to editing:
* Preprocessed code, such as server-side Ruby, Perl or PHP embedded in HTML
* Code generating code, such as HTML output by CGI scripts
* Embedded code, such as Javascript in HTML
* Literate programming: code interspersed with documentation, e.g. Noweb
INSTALLATION
Use any of the following options:
1. Users of package.el (a.k.a. ELPA) can easily install MMM Mode from
the ELPA package repository at https://elpa.gnu.org/ -- this is the
preferred and best-supported installation mechanism.
2. Since currently MMM Mode is written in pure Emacs Lisp, you could just
copy all the *.el files in the distribution to a directory in your
`load-path', and optionally byte-compile them manually (see the Emacs
Manual). The configure installation also installs the MMM Mode info manual
in your site info directory, so if you're installing manually, you might
want to do that too.
3. MMM Mode has a standard GNU configure-driven installation.
(See the file INSTALL for generic instructions, most of which don't apply.)
To install in the standard locations, unpack the archive, `cd' to
the mmm-mode-X.X.X directory created, and run these commands:
make maintainer-clean # optional step
./autogen.sh
./configure
make
make install
If you have more than one version of emacs installed and want to
use MMM in a version other than /usr/bin/emacs, you must set the
environment variable EMACS before running `configure', e.g.
EMACS=/usr/bin/xemacs ./configure
make
make install
If you want to use MMM in more than one version of emacs, you must
either have separate site-lisp directories (such as Debian does), or
load it from source every time; byte-compiled files are not portable
between emacsen.
CONFIGURATION
Once MMM Mode is installed, it has to be configured correctly. This
can be done in a site-start file or in user's initialization files;
usually the latter is preferable, except possibly for autoloads.
First the package needs to be loaded, with either
(require 'mmm-mode)
or instead, to save time during emacs startup,
(require 'mmm-auto)
Then you will probably want to set something like this:
(setq mmm-global-mode 'maybe)
(mmm-add-mode-ext-class 'html-mode "\\.php\\'" 'html-php)
The first line tells MMM Mode to load itself whenever you open an
appropriate file, and the second is an example which says to notice
PHP regions in html-mode files having a `.php' extension. Both
lines are necessary.
You will, of course, want to change and duplicate the second line
according to your needs. either of the first two parameters can be
`nil', meaning not to consider that criterion. For example, if all
your html files, regardless of extension, are Mason components, you
will want something like:
(mmm-add-mode-ext-class 'html-mode nil 'mason)
whereas if all your files with a `.nw' extension, regardless of
primary mode (some may be LaTeX, others HTML, say) are Noweb, you
will prefer
(mmm-add-mode-ext-class nil "\\.nw\\'" 'noweb)
See the info file for more extensive documentation, and for other
configuration options.
DOCUMENTATION
For further information, see (in order) the accompanying info file,
the documentation strings of functions and variables, the comments
in the source code, and the source code itself.
UPDATES
The latest version of MMM Mode should always be available from
https://github.com/purcell/mmm-mode
FEEDBACK
Bug reports, suggestions and questions can be submitted at
https://github.com/purcell/mmm-mode/issues.
Thanks for using MMM Mode!

View File

@@ -0,0 +1,122 @@
-*-text-*-
Using MMM Mode for Mason: An Overview
=====================================
Since many users of MMM Mode use it for Mason <www.masonhq.com>, and
since the Mason submode class is the most complex one supplied, a
few comments regarding its usage are in order. Even if you don't
use Mason, this file may be of interest to you as an example of MMM
usage and possible problems.
INSTALLATION AND LOADING
For general installation and information, see the README file and
the texinfo documentation. The submode class for Mason components
is called `mason' and is automatically loaded from `mmm-mason.el'
the first time it is used.
MODES AND EXTENSIONS
If you want to have mason submodes automatically in all Mason files,
you can use `mmm-mode-ext-classes-alist'; the details depend on what
you call your Mason components and what major mode you use. Some
example elements of `mmm-mode-ext-classes-alist' follow, with
comments on the corresponding naming scheme.
(html-mode "\\.html\\'" mason) ;; Any .html file in html-mode
(hm--html-mode nil mason) ;; Any buffer in hm--html-mode
(sgml-mode nil mason) ;; Any buffer in sgml-mode
(nil "\\.\\(mason\\|html\\)\\'" mason) ;; All .mason and .html files
(nil "\\.m[dc]\\'" mason) ;; All .md and .mc files
(nil "\\`/var/www/mason/" mason) ;; Any file in the directory
(nil nil mason) ;; All buffers.
In order for any of these to work, you must set `mmm-global-mode' to
a non-nil value, such as `t' or `maybe' (the two of which mean
different things; see the documentation). This can be done with a
line in .emacs such as the following:
(setq mmm-global-mode 'maybe)
If you use an extension for your Mason files that emacs does not
automatically place in your preferred HTML Mode (be it html-mode,
sgml-html-mode, hm--html-mode, or whatever), you will probably want
to associate that extension with your HTML Mode (this is a feature
of emacs, not MMM Mode). An example is shown below.
(add-to-list 'auto-mode-alist '("\\.mason\\'" . html-mode))
This also goes for "special" Mason files such as autohandlers and
dhandlers. The code below tells emacs to use html-mode for files
named `autohandler' and `dhandler'.
(add-to-list 'auto-mode-alist '("\\(auto\\|d\\)handler\\'" . html-mode))
An alternate solution is to change the names of your autohandlers
and dhandlers so that emacs recognizes them as HTML automatically.
Similar code can be used to recognize all files in a given directory
as HTML and/or Mason.
CPERL PROBLEMS
There are certain problems with CPerl mode in submode regions. (Not
to say that the original perl-mode would do any better--it hasn't
been much tried.) First of all, the first line of a Perl section
is usually indented as if it were a continuation line. A fix for
this is to start with a semicolon on the first line. The insertion
key commands do this whenever the Mason syntax allows it.
<%perl>;
print $var;
</%perl>
In addition, some users have reported that the CPerl indentation
sometimes does not work. This problem has not yet been tracked
down, however, and more data about when it happens would be helpful.
PSGML PROBLEMS
Some people have reported problems using PSGML with Mason. Adding
the following line to a .emacs file should suffice to turn PSGML off
and cause emacs to use a simpler HTML mode:
(autoload 'html-mode "sgml-mode" "HTML Mode" t)
Earlier versions of PSGML may require instead the following fix:
(delete '("\\.html$" . sgml-html-mode) auto-mode-alist)
(delete '("\\.shtml$" . sgml-html-mode) auto-mode-alist)
Other users report using PSGML with Mason and MMM Mode without
difficulty. If you don't have problems and want to use PSGML, you
may need to replace `html-mode' in the suggested code with
`sgml-html-mode'. (Depending on your version of PSGML, this may not
be necessary.) Similarly, if you are using XEmacs and want to use
the alternate HTML mode `hm--html-mode', replace `html-mode' with
that symbol.
One problem that crops up when using PSGML with Mason is that even
ignoring the special tags and Perl code (which, as I've said,
haven't caused me any problems), Mason components often are not a
complete SGML document. For instance, my autohandlers often say
<body>
<% $m->call_next %>
</body>
in which case the actual components contain no doctype declaration,
<html>, <head>, or <body>, confusing PSGML. One solution I've found
is to use the variable `sgml-parent-document' in such incomplete
components; try, for example, these lines at the end of a component.
%# Local Variables:
%# sgml-parent-document: ("autohandler" "body" nil ("body"))
%# sgml-doctype: "/top/level/autohandler"
%# End:
This tells PSGML that the current file is a sub-document of the file
`autohandler' and is included inside a <body> tag, thus alleviating
its confusion, and also instructs it where to find the doctype
declaration (assuming your top-level autohandler has one). This
alleviates most problems for me. I admit to not understanding PSGML
internals very well, so YMMV.

61
elpa/mmm-mode-0.5.7/TODO Normal file
View File

@@ -0,0 +1,61 @@
Hey Emacs, this is a -*-text-*- file!
To Do List for MMM Mode
=======================
Custom mode functions like `mason-mode'.
Make Mason work a little better with PSGML. The fix I've found works,
but it would be nifty if MMM could do it automatically. Maybe the
custom-mode thing could set the variables, or a hook somewhere.
Apostrophes mess up Perl parsing in XEmacs but not Emacs. I thought
it was because XEmacs sets `font-lock-beginning-of-syntax-function'
after MMM does, but changing that that didn't fix it.
Support for: ASP
DEB and/or RPM packages would be nice.
The local-variables improvements can probably be used to set minor
modes locally to submode regions. This could replace tmmofl,
especially if we search for regions other than by regexps, say by
syntax properties.
Trap paragraph motion commands to stop at submode boundaries?
It would be nice if C-j ended a Mason one-liner and began a new one on
the next line. This is a rather Mason-specific thing, but other
classes might have similar single-line regions. Add a new submode
class argument, such as KEYMAP, or even ONE-LINE?
Allow a submode class to specify its allowable "parent" submode
classes. This could also be used to implement htp.p, by first
scanning for the function calls as a major-mode submode region, then
requiring that parent type for the HTML mode class. Nested submodes
alternate highlight colors, say with `mmm-secondary-submode-face'.
Ought %text in Mason to be a non-submode, since any Mason tags inside
it will probably be /edited/ as Perl (being, say, code examples)?
Only problem is it might confuse the programmer into thinking that
code will get executed. Maybe use a different face. Could do that
with another grouping class, say uneval-mason, that overrides the
faces of mason and has :parent mason-text, and allow a mode to specify
what about it changes depending on its parent, or a parent to specify
changes to its children, or a group to specify changes to its members.
Port or generalize the relevant bits from ERB indentation code to similar
packages for other languages.
Make re-parsing the buffer into regions incremental: take the position
of the most early change, see the submodes nesting there, and resume
parsing with that data. Shouldn't be too hard, conceptually. Maybe
even ignore the nesting, backtrack to a position where there are no
overlays, and re-parse from there (see mmm-parse-apply as a starting
point). Remember to handle delimiter inclusion and offsets as best
possible.
Thus, make re-parsing automatic (from syntax-propertize-function,
probably), making manual control unnecessary.
Remove XEmacs stuff?

View File

@@ -0,0 +1,165 @@
dnl
dnl Execute arbitrary emacs lisp
dnl
AC_DEFUN(AC_EMACS_LISP, [
elisp="$2"
if test -z "$3"; then
AC_MSG_CHECKING(for $1)
fi
AC_CACHE_VAL(EMACS_cv_SYS_$1,[
OUTPUT=./conftest-$$
echo ${EMACS} -batch -eval "(let ((x ${elisp})) (write-region (if (stringp x) (princ x) (prin1-to-string x)) nil \"${OUTPUT}\"))" >& AC_FD_CC 2>&1
${EMACS} -batch -eval "(let ((x ${elisp})) (write-region (if (stringp x) (princ x 'ignore) (prin1-to-string x)) nil \"${OUTPUT}\"nil 5))" >& AC_FD_CC 2>&1
retval=`cat ${OUTPUT}`
echo "=> ${retval}" >& AC_FD_CC 2>&1
rm -f ${OUTPUT}
EMACS_cv_SYS_$1=$retval
])
$1=${EMACS_cv_SYS_$1}
if test -z "$3"; then
AC_MSG_RESULT($$1)
fi
])
AC_DEFUN(AC_XEMACS_P, [
AC_MSG_CHECKING([if $EMACS is really XEmacs])
AC_EMACS_LISP(xemacsp,(if (string-match \"XEmacs\" emacs-version) \"yes\" \"no\") ,"noecho")
XEMACS=${EMACS_cv_SYS_xemacsp}
EMACS_FLAVOR=emacs
if test "$XEMACS" = "yes"; then
EMACS_FLAVOR=xemacs
fi
AC_MSG_RESULT($XEMACS)
AC_SUBST(XEMACS)
AC_SUBST(EMACS_FLAVOR)
])
AC_DEFUN(AC_PATH_LISPDIR, [
AC_XEMACS_P
if test "$prefix" = "NONE"; then
AC_MSG_CHECKING([prefix for your Emacs])
AC_EMACS_LISP(prefix,(expand-file-name \"..\" invocation-directory),"noecho")
prefix=${EMACS_cv_SYS_prefix}
AC_MSG_RESULT($prefix)
fi
AC_ARG_WITH(lispdir, --with-lispdir Where to install lisp files, lispdir=${withval})
AC_MSG_CHECKING([where .elc files should go])
if test -z "$lispdir"; then
dnl Set default value
theprefix=$prefix
if test "x$theprefix" = "xNONE"; then
theprefix=$ac_default_prefix
fi
lispdir="\$(datadir)/${EMACS_FLAVOR}/site-lisp"
for thedir in share lib; do
potential=
if test -d ${theprefix}/${thedir}/${EMACS_FLAVOR}/site-lisp; then
lispdir="\$(prefix)/${thedir}/${EMACS_FLAVOR}/site-lisp"
break
fi
done
fi
AC_MSG_RESULT($lispdir)
AC_SUBST(lispdir)
])
dnl
dnl Determine the emacs version we are running.
dnl Automatically substitutes @EMACS_VERSION@ with this number.
dnl
AC_DEFUN(AC_EMACS_VERSION, [
AC_MSG_CHECKING(for emacs version)
AC_EMACS_LISP(version,(and (boundp 'emacs-major-version) (format \"%d.%d\" emacs-major-version emacs-minor-version)),"noecho")
EMACS_VERSION=${EMACS_cv_SYS_version}
AC_SUBST(EMACS_VERSION)
AC_MSG_RESULT(${EMACS_VERSION})
])
dnl
dnl Determine whether the specified version of Emacs supports packages
dnl or not. Currently, only XEmacs 20.3 does, but this is a general
dnl check.
dnl
AC_DEFUN(AC_EMACS_PACKAGES, [
AC_ARG_WITH(package-dir, --with-package-dir Configure as a XEmacs package in directory, [ EMACS_PACKAGE_DIR="${withval}"])
if test -n "$EMACS_PACKAGE_DIR"; then
if test "$prefix" != "NONE"; then
AC_MSG_ERROR([--with-package-dir and --prefix are mutually exclusive])
fi
dnl Massage everything to use $(prefix) correctly.
prefix=$EMACS_PACKAGE_DIR
datadir='$(prefix)/etc/w3'
infodir='$(prefix)/info'
lispdir='$(prefix)/lisp/w3'
fi
AC_SUBST(EMACS_PACKAGE_DIR)
])
dnl
dnl Check whether a function exists in a library
dnl All '_' characters in the first argument are converted to '-'
dnl
AC_DEFUN(AC_EMACS_CHECK_LIB, [
if test -z "$3"; then
AC_MSG_CHECKING(for $2 in $1)
fi
library=`echo $1 | tr _ -`
AC_EMACS_LISP($1,(progn (fmakunbound '$2) (condition-case nil (progn (require '$library) (fboundp '$2)) (error (prog1 nil (message \"$library not found\"))))),"noecho")
if test "${EMACS_cv_SYS_$1}" = "nil"; then
EMACS_cv_SYS_$1=no
fi
if test "${EMACS_cv_SYS_$1}" = "t"; then
EMACS_cv_SYS_$1=yes
fi
HAVE_$1=${EMACS_cv_SYS_$1}
AC_SUBST(HAVE_$1)
if test -z "$3"; then
AC_MSG_RESULT($HAVE_$1)
fi
])
dnl
dnl Check whether a variable exists in a library
dnl All '_' characters in the first argument are converted to '-'
dnl
AC_DEFUN(AC_EMACS_CHECK_VAR, [
AC_MSG_CHECKING(for $2 in $1)
library=`echo $1 | tr _ -`
AC_EMACS_LISP($1,(progn (makunbound '$2) (condition-case nil (progn (require '$library) (boundp '$2)) (error nil))),"noecho")
if test "${EMACS_cv_SYS_$1}" = "nil"; then
EMACS_cv_SYS_$1=no
fi
HAVE_$1=${EMACS_cv_SYS_$1}
AC_SUBST(HAVE_$1)
AC_MSG_RESULT($HAVE_$1)
])
dnl
dnl Perform sanity checking and try to locate the custom and widget packages
dnl
AC_DEFUN(AC_CHECK_CUSTOM, [
AC_MSG_CHECKING(for acceptable custom library)
AC_CACHE_VAL(EMACS_cv_ACCEPTABLE_CUSTOM,[
AC_EMACS_CHECK_LIB(widget,widget-convert-text,"noecho")
AC_EMACS_CHECK_LIB(wid_edit,widget-convert-text,"noecho")
if test "${HAVE_widget}" = "yes"; then
EMACS_cv_ACCEPTABLE_CUSTOM=yes
else
if test "${HAVE_wid_edit}" != "no"; then
EMACS_cv_ACCEPTABLE_CUSTOM=yes
else
EMACS_cv_ACCEPTABLE_CUSTOM=no
fi
fi
if test "${EMACS_cv_ACCEPTABLE_CUSTOM}" = "yes"; then
AC_EMACS_LISP(widget_dir,(file-name-directory (locate-library \"widget\")),"noecho")
EMACS_cv_ACCEPTABLE_CUSTOM=$EMACS_cv_SYS_widget_dir
fi
])
AC_ARG_WITH(custom, --with-custom Specify where to find the custom package, [ EMACS_cv_ACCEPTABLE_CUSTOM=`( cd $withval && pwd || echo "$withval" ) 2> /dev/null` ])
CUSTOM=${EMACS_cv_ACCEPTABLE_CUSTOM}
AC_SUBST(CUSTOM)
AC_MSG_RESULT("${CUSTOM}")
])

28
elpa/mmm-mode-0.5.7/autogen.sh Executable file
View File

@@ -0,0 +1,28 @@
#!/bin/sh
notfound=
if ! type aclocal >/dev/null 2>/dev/null; then
notfound=aclocal
elif ! type automake >/dev/null 2>/dev/null; then
notfound=automake
elif ! type autoconf >/dev/null 2>/dev/null; then
notfound=autoconf
fi
if test -n "$notfound"; then
echo OOPS: I can\'t find $notfound in your path!
echo You need aclocal, automake, and autoconf to generate configure.
echo Otherwise, you can install manually, see the README file.
exit;
fi
echo -n Running aclocal to generate aclocal.m4...
aclocal
echo done.
echo -n Running automake to generate Makefile.in...
automake
echo done.
echo -n Running autoconf to generate configure...
autoconf
echo done

View File

@@ -0,0 +1,36 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT()
AM_INIT_AUTOMAKE(mmm-mode, 0.5.7)
dnl
dnl Apparently, if you run a shell window in Emacs, it sets the EMACS
dnl environment variable to 't'. Lets undo the damage.
dnl
if test "${EMACS}" = "t"; then
EMACS=""
fi
AC_ARG_WITH(xemacs, --with-xemacs Use XEmacs to build, [ if test "${withval}" = "yes"; then EMACS=xemacs; else EMACS=${withval}; fi ])
AC_ARG_WITH(emacs, --with-emacs Use Emacs to build, [ if test "${withval}" = "yes"; then EMACS=emacs; else EMACS=${withval}; fi ])
AC_CHECK_PROG(EMACS, xemacs, xemacs, emacs)
AM_PATH_LISPDIR
AC_EMACS_VERSION
dnl Checks for programs.
dnl Checks for libraries.
dnl Checks for header files.
dnl Checks for typedefs, structures, and compiler characteristics.
dnl Checks for library functions.
AC_SUBST(EMACS)
AC_OUTPUT(Makefile)

55
elpa/mmm-mode-0.5.7/elisp-comp Executable file
View File

@@ -0,0 +1,55 @@
#!/bin/sh
# Copyright (C) 1995 Free Software Foundation, Inc.
# Fran<61>ois Pinard <pinard@iro.umontreal.ca>, 1995.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# This script byte-compiles all `.el' files which are part of its
# arguments, using GNU Emacs, and put the resulting `.elc' files into
# the current directory, so disregarding the original directories used
# in `.el' arguments.
#
# This script manages in such a way that all Emacs LISP files to
# be compiled are made visible between themselves, in the event
# they require or load-library one another.
# This script was modified by Michael Abraham Shulman
# <mas@kurukshetra.cjb.net> not to create a temporary directory, so
# that elisp files not given on the command line at the same time,
# the way Automake *actually* uses this script, can load each other.
if test $# = 0; then
echo 1>&2 "No files given to $0"
exit 1
else
if test -z "$EMACS" || test "$EMACS" = "t"; then
# Value of "t" means we are running in a shell under Emacs.
# Just assume Emacs is called "emacs".
EMACS=emacs
fi
# tempdir=elc.$$
# mkdir $tempdir
# cp $* $tempdir
# cd $tempdir
# echo "elisp-comp called on $*"
echo "(setq load-path (cons nil load-path))" > script
$EMACS -q -batch -l script -f batch-byte-compile $*
# mv *.elc ..
# cd ..
# rm -fr $tempdir
fi

251
elpa/mmm-mode-0.5.7/install-sh Executable file
View File

@@ -0,0 +1,251 @@
#!/bin/sh
#
# install - install a program, script, or datafile
# This comes from X11R5 (mit/util/scripts/install.sh).
#
# Copyright 1991 by the Massachusetts Institute of Technology
#
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
# the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation, and that the name of M.I.T. not be used in advertising or
# publicity pertaining to distribution of the software without specific,
# written prior permission. M.I.T. makes no representations about the
# suitability of this software for any purpose. It is provided "as is"
# without express or implied warranty.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch. It can only install one file at a time, a restriction
# shared with many OS's install programs.
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
# put in absolute paths if you don't have them in your path; or use env. vars.
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
transformbasename=""
transform_arg=""
instcmd="$mvprog"
chmodcmd="$chmodprog 0755"
chowncmd=""
chgrpcmd=""
stripcmd=""
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=""
dst=""
dir_arg=""
while [ x"$1" != x ]; do
case $1 in
-c) instcmd="$cpprog"
shift
continue;;
-d) dir_arg=true
shift
continue;;
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
-s) stripcmd="$stripprog"
shift
continue;;
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
shift
continue;;
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
shift
continue;;
*) if [ x"$src" = x ]
then
src=$1
else
# this colon is to work around a 386BSD /bin/sh bug
:
dst=$1
fi
shift
continue;;
esac
done
if [ x"$src" = x ]
then
echo "install: no input file specified"
exit 1
else
true
fi
if [ x"$dir_arg" != x ]; then
dst=$src
src=""
if [ -d $dst ]; then
instcmd=:
chmodcmd=""
else
instcmd=mkdir
fi
else
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if [ -f $src -o -d $src ]
then
true
else
echo "install: $src does not exist"
exit 1
fi
if [ x"$dst" = x ]
then
echo "install: no destination specified"
exit 1
else
true
fi
# If destination is a directory, append the input filename; if your system
# does not like double slashes in filenames, you may need to add some logic
if [ -d $dst ]
then
dst="$dst"/`basename $src`
else
true
fi
fi
## this sed command emulates the dirname command
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
# Make sure that the destination directory exists.
# this part is taken from Noah Friedman's mkinstalldirs script
# Skip lots of stat calls in the usual case.
if [ ! -d "$dstdir" ]; then
defaultIFS='
'
IFS="${IFS-${defaultIFS}}"
oIFS="${IFS}"
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
IFS="${oIFS}"
pathcomp=''
while [ $# -ne 0 ] ; do
pathcomp="${pathcomp}${1}"
shift
if [ ! -d "${pathcomp}" ] ;
then
$mkdirprog "${pathcomp}"
else
true
fi
pathcomp="${pathcomp}/"
done
fi
if [ x"$dir_arg" != x ]
then
$doit $instcmd $dst &&
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
else
# If we're going to rename the final executable, determine the name now.
if [ x"$transformarg" = x ]
then
dstfile=`basename $dst`
else
dstfile=`basename $dst $transformbasename |
sed $transformarg`$transformbasename
fi
# don't allow the sed command to completely eliminate the filename
if [ x"$dstfile" = x ]
then
dstfile=`basename $dst`
else
true
fi
# Make a temp file name in the proper directory.
dsttmp=$dstdir/#inst.$$#
# Move or copy the file name to the temp name
$doit $instcmd $src $dsttmp &&
trap "rm -f ${dsttmp}" 0 &&
# and set any options; do chmod last to preserve setuid bits
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $instcmd $src $dsttmp" command.
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
# Now rename the file to the real destination.
$doit $rmcmd -f $dstdir/$dstfile &&
$doit $mvcmd $dsttmp $dstdir/$dstfile
fi &&
exit 0

92
elpa/mmm-mode-0.5.7/mdate-sh Executable file
View File

@@ -0,0 +1,92 @@
#!/bin/sh
# Get modification time of a file or directory and pretty-print it.
# Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
# written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, June 1995
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Prevent date giving response in another language.
LANG=C
export LANG
LC_ALL=C
export LC_ALL
LC_TIME=C
export LC_TIME
# Get the extended ls output of the file or directory.
# On HPUX /bin/sh, "set" interprets "-rw-r--r--" as options, so the "x" below.
if ls -L /dev/null 1>/dev/null 2>&1; then
set - x`ls -L -l -d $1`
else
set - x`ls -l -d $1`
fi
# The month is at least the fourth argument
# (3 shifts here, the next inside the loop).
shift
shift
shift
# Find the month. Next argument is day, followed by the year or time.
month=
until test $month
do
shift
case $1 in
Jan) month=January; nummonth=1;;
Feb) month=February; nummonth=2;;
Mar) month=March; nummonth=3;;
Apr) month=April; nummonth=4;;
May) month=May; nummonth=5;;
Jun) month=June; nummonth=6;;
Jul) month=July; nummonth=7;;
Aug) month=August; nummonth=8;;
Sep) month=September; nummonth=9;;
Oct) month=October; nummonth=10;;
Nov) month=November; nummonth=11;;
Dec) month=December; nummonth=12;;
esac
done
day=$2
# Here we have to deal with the problem that the ls output gives either
# the time of day or the year.
case $3 in
*:*) set `date`; eval year=\$$#
case $2 in
Jan) nummonthtod=1;;
Feb) nummonthtod=2;;
Mar) nummonthtod=3;;
Apr) nummonthtod=4;;
May) nummonthtod=5;;
Jun) nummonthtod=6;;
Jul) nummonthtod=7;;
Aug) nummonthtod=8;;
Sep) nummonthtod=9;;
Oct) nummonthtod=10;;
Nov) nummonthtod=11;;
Dec) nummonthtod=12;;
esac
# For the first six month of the year the time notation can also
# be used for files modified in the last year.
if (expr $nummonth \> $nummonthtod) > /dev/null;
then
year=`expr $year - 1`
fi;;
*) year=$3;;
esac
# The result.
echo $day $month $year

336
elpa/mmm-mode-0.5.7/missing Executable file
View File

@@ -0,0 +1,336 @@
#! /bin/sh
# Common stub for a few missing GNU programs while installing.
# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003 Free Software Foundation, Inc.
# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
if test $# -eq 0; then
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
fi
run=:
# In the cases where this matters, `missing' is being run in the
# srcdir already.
if test -f configure.ac; then
configure_ac=configure.ac
else
configure_ac=configure.in
fi
case "$1" in
--run)
# Try to run requested program, and just exit if it succeeds.
run=
shift
"$@" && exit 0
;;
esac
# If it does not exist, or fails to run (possibly an outdated version),
# try to emulate it.
case "$1" in
-h|--h|--he|--hel|--help)
echo "\
$0 [OPTION]... PROGRAM [ARGUMENT]...
Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
error status if there is no known handling for PROGRAM.
Options:
-h, --help display this help and exit
-v, --version output version information and exit
--run try to run the given command, and emulate it if it fails
Supported PROGRAM values:
aclocal touch file \`aclocal.m4'
autoconf touch file \`configure'
autoheader touch file \`config.h.in'
automake touch all \`Makefile.in' files
bison create \`y.tab.[ch]', if possible, from existing .[ch]
flex create \`lex.yy.c', if possible, from existing .c
help2man touch the output file
lex create \`lex.yy.c', if possible, from existing .c
makeinfo touch the output file
tar try tar, gnutar, gtar, then tar without non-portable flags
yacc create \`y.tab.[ch]', if possible, from existing .[ch]"
;;
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
echo "missing 0.4 - GNU automake"
;;
-*)
echo 1>&2 "$0: Unknown \`$1' option"
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
;;
aclocal*)
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
# We have it, but it failed.
exit 1
fi
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified \`acinclude.m4' or \`${configure_ac}'. You might want
to install the \`Automake' and \`Perl' packages. Grab them from
any GNU archive site."
touch aclocal.m4
;;
autoconf)
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
# We have it, but it failed.
exit 1
fi
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified \`${configure_ac}'. You might want to install the
\`Autoconf' and \`GNU m4' packages. Grab them from any GNU
archive site."
touch configure
;;
autoheader)
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
# We have it, but it failed.
exit 1
fi
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified \`acconfig.h' or \`${configure_ac}'. You might want
to install the \`Autoconf' and \`GNU m4' packages. Grab them
from any GNU archive site."
files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
test -z "$files" && files="config.h"
touch_files=
for f in $files; do
case "$f" in
*:*) touch_files="$touch_files "`echo "$f" |
sed -e 's/^[^:]*://' -e 's/:.*//'`;;
*) touch_files="$touch_files $f.in";;
esac
done
touch $touch_files
;;
automake*)
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
# We have it, but it failed.
exit 1
fi
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
You might want to install the \`Automake' and \`Perl' packages.
Grab them from any GNU archive site."
find . -type f -name Makefile.am -print |
sed 's/\.am$/.in/' |
while read f; do touch "$f"; done
;;
autom4te)
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
# We have it, but it failed.
exit 1
fi
echo 1>&2 "\
WARNING: \`$1' is needed, and you do not seem to have it handy on your
system. You might have modified some files without having the
proper tools for further handling them.
You can get \`$1' as part of \`Autoconf' from any GNU
archive site."
file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
if test -f "$file"; then
touch $file
else
test -z "$file" || exec >$file
echo "#! /bin/sh"
echo "# Created by GNU Automake missing as a replacement of"
echo "# $ $@"
echo "exit 0"
chmod +x $file
exit 1
fi
;;
bison|yacc)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified a \`.y' file. You may need the \`Bison' package
in order for those modifications to take effect. You can get
\`Bison' from any GNU archive site."
rm -f y.tab.c y.tab.h
if [ $# -ne 1 ]; then
eval LASTARG="\${$#}"
case "$LASTARG" in
*.y)
SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" y.tab.c
fi
SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" y.tab.h
fi
;;
esac
fi
if [ ! -f y.tab.h ]; then
echo >y.tab.h
fi
if [ ! -f y.tab.c ]; then
echo 'main() { return 0; }' >y.tab.c
fi
;;
lex|flex)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified a \`.l' file. You may need the \`Flex' package
in order for those modifications to take effect. You can get
\`Flex' from any GNU archive site."
rm -f lex.yy.c
if [ $# -ne 1 ]; then
eval LASTARG="\${$#}"
case "$LASTARG" in
*.l)
SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" lex.yy.c
fi
;;
esac
fi
if [ ! -f lex.yy.c ]; then
echo 'main() { return 0; }' >lex.yy.c
fi
;;
help2man)
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
# We have it, but it failed.
exit 1
fi
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified a dependency of a manual page. You may need the
\`Help2man' package in order for those modifications to take
effect. You can get \`Help2man' from any GNU archive site."
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
if test -z "$file"; then
file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
fi
if [ -f "$file" ]; then
touch $file
else
test -z "$file" || exec >$file
echo ".ab help2man is required to generate this page"
exit 1
fi
;;
makeinfo)
if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then
# We have makeinfo, but it failed.
exit 1
fi
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified a \`.texi' or \`.texinfo' file, or any other file
indirectly affecting the aspect of the manual. The spurious
call might also be the consequence of using a buggy \`make' (AIX,
DU, IRIX). You might want to install the \`Texinfo' package or
the \`GNU make' package. Grab either from any GNU archive site."
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
if test -z "$file"; then
file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
fi
touch $file
;;
tar)
shift
if test -n "$run"; then
echo 1>&2 "ERROR: \`tar' requires --run"
exit 1
fi
# We have already tried tar in the generic part.
# Look for gnutar/gtar before invocation to avoid ugly error
# messages.
if (gnutar --version > /dev/null 2>&1); then
gnutar "$@" && exit 0
fi
if (gtar --version > /dev/null 2>&1); then
gtar "$@" && exit 0
fi
firstarg="$1"
if shift; then
case "$firstarg" in
*o*)
firstarg=`echo "$firstarg" | sed s/o//`
tar "$firstarg" "$@" && exit 0
;;
esac
case "$firstarg" in
*h*)
firstarg=`echo "$firstarg" | sed s/h//`
tar "$firstarg" "$@" && exit 0
;;
esac
fi
echo 1>&2 "\
WARNING: I can't seem to be able to run \`tar' with the given arguments.
You may want to install GNU tar or Free paxutils, or check the
command line arguments."
exit 1
;;
*)
echo 1>&2 "\
WARNING: \`$1' is needed, and you do not seem to have it handy on your
system. You might have modified some files without having the
proper tools for further handling them. Check the \`README' file,
it often tells you about the needed prerequisites for installing
this package. You may also peek at any GNU archive site, in case
some other package would contain this missing \`$1' program."
exit 1
;;
esac
exit 0

View File

@@ -0,0 +1,38 @@
#! /bin/sh
# mkinstalldirs --- make directory hierarchy
# Author: Noah Friedman <friedman@prep.ai.mit.edu>
# Created: 1993-05-16
# Public domain
errstatus=0
for file
do
set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
shift
pathcomp=
for d
do
pathcomp="$pathcomp$d"
case "$pathcomp" in
-* ) pathcomp=./$pathcomp ;;
esac
if test ! -d "$pathcomp"; then
echo "mkdir $pathcomp"
mkdir "$pathcomp" || lasterr=$?
if test ! -d "$pathcomp"; then
errstatus=$lasterr
fi
fi
pathcomp="$pathcomp/"
done
done
exit $errstatus
# mkinstalldirs ends here

View File

@@ -0,0 +1,178 @@
;;; mmm-auto.el --- loading and enabling MMM Mode automatically
;; Copyright (C) 2000-2004, 2012, 2013, 2018 Free Software Foundation, Inc.
;; Author: Michael Abraham Shulman <mas@kurukshetra.cjb.net>
;;{{{ GPL
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;}}}
;;; Commentary:
;; This file contains functions and hooks to load and enable MMM Mode
;; automatically. It sets up autoloads for the main MMM Mode functions
;; and interactive commands, and also sets up MMM Global Mode.
;;{{{ Comments on MMM Global Mode
;; This is a kludge borrowed from `global-font-lock-mode'. The idea
;; is the same: we have a function (here `mmm-mode-on-maybe') that we
;; want to be run whenever a major mode starts. Unfortunately, there
;; is no hook (like, say `major-mode-hook') that all major modes run
;; when they are finished. `post-command-hook', however, is run after
;; *every* command, so we do our work in there. (Actually, using
;; `post-command-hook' is even better than being run by major mode
;; functions, since it is run after all local variables and text are
;; loaded, which may not be true in certain cases for the other.)
;; FIXME: There's now after-change-major-mode-hook which should DTRT.
;; In order to do this magic, we rely on the fact that there *is* a
;; hook that all major modes run when *beginning* their work. They
;; call `kill-all-local-variables' (unless they are broken), which in
;; turn runs `change-major-mode-hook'. So we add a function to *that*
;; hook which saves the current buffer and temporarily adds a function
;; to `post-command-hook' which processes that buffer.
;; Actually, in the interests of generality, what that function does
;; is run the hook `mmm-major-mode-hook'. Our desired function
;; `mmm-mode-on-maybe' is then added to that hook. This way, if the
;; user wants to run something else on every major mode, they can just
;; add it to `mmm-major-mode-hook' and take advantage of this hack.
;;}}}
;;; Code:
(require 'mmm-vars)
;;{{{ Autoload Submode Classes
(defvar mmm-autoloaded-classes
'((mason "mmm-mason" nil)
(myghty "mmm-myghty" nil)
(html-css "mmm-sample" nil)
(html-js "mmm-sample" nil)
(here-doc "mmm-sample" nil)
(embperl "mmm-sample" nil)
(eperl "mmm-sample" nil)
(jsp "mmm-sample" nil)
(file-variables "mmm-sample" nil)
(rpm-sh "mmm-rpm" t)
(rpm "mmm-rpm" nil)
(cweb "mmm-cweb" nil)
(sgml-dtd "mmm-sample" nil)
(noweb "mmm-noweb" nil)
(html-php "mmm-sample" nil)
)
"Alist of submode classes autoloaded from files.
Elements look like \(CLASS FILE PRIVATE) where CLASS is a submode
class symbol, FILE is a string suitable for passing to `load', and
PRIVATE is non-nil if the class is invisible to the user. Classes can
be added to this list with `mmm-autoload-class'.")
(defun mmm-autoload-class (class file &optional private)
"Autoload submode class CLASS from file FILE.
PRIVATE, if non-nil, means the class is user-invisible. In general,
private classes need not be autoloaded, since they will usually be
invoked by a public class in the same file."
;; Don't autoload already defined classes
(unless (assq class mmm-classes-alist)
(add-to-list 'mmm-autoloaded-classes
(list class file private))))
;;}}}
;;{{{ Autoload Functions
;; To shut up the byte compiler.
(eval-and-compile
(autoload 'mmm-mode-on "mmm-mode" "Turn on MMM Mode. See `mmm-mode'.")
(autoload 'mmm-mode-off "mmm-mode" "Turn off MMM Mode. See `mmm-mode'.")
(autoload 'mmm-update-font-lock-buffer "mmm-region")
(autoload 'mmm-ensure-fboundp "mmm-utils")
(autoload 'mmm-mode "mmm-mode"
"Minor mode to allow multiple major modes in one buffer.
Without ARG, toggle MMM Mode. With ARG, turn MMM Mode on iff ARG is
positive and off otherwise." t))
;; These may actually be used.
(autoload 'mmm-ify-by-class "mmm-cmds" "" t)
(autoload 'mmm-ify-by-regexp "mmm-cmds" "" t)
(autoload 'mmm-ify-region "mmm-cmds" "" t)
(autoload 'mmm-parse-buffer "mmm-cmds" "" t)
(autoload 'mmm-parse-region "mmm-cmds" "" t)
(autoload 'mmm-parse-block "mmm-cmds" "" t)
(autoload 'mmm-clear-current-region "mmm-cmds" "" t)
(autoload 'mmm-reparse-current-region "mmm-cmds" "" t)
(autoload 'mmm-end-current-region "mmm-cmds" "" t)
(autoload 'mmm-insertion-help "mmm-cmds" "" t)
(autoload 'mmm-insert-region "mmm-cmds" "" t)
;;}}}
;;{{{ MMM Global Mode
(defvar mmm-changed-buffers-list ()
"Buffers that need to be checked for running the major mode hook.")
(defun mmm-major-mode-change ()
"Add this buffer to `mmm-changed-buffers-list' for checking.
When the current command is over, MMM Mode will be turned on in this
buffer depending on the value of `mmm-global-mode'. Actually,
everything in `mmm-major-mode-hook' will be run."
(and (boundp 'mmm-mode)
mmm-mode
(mmm-mode-off))
(add-to-list 'mmm-changed-buffers-list (current-buffer))
(add-hook 'post-command-hook #'mmm-check-changed-buffers))
(add-hook 'change-major-mode-hook #'mmm-major-mode-change)
(defun mmm-check-changed-buffers ()
"Run major mode hook for the buffers in `mmm-changed-buffers-list'."
(remove-hook 'post-command-hook #'mmm-check-changed-buffers)
(dolist (buffer mmm-changed-buffers-list)
(when (buffer-live-p buffer)
(with-current-buffer buffer
(mmm-run-major-mode-hook))))
(setq mmm-changed-buffers-list '()))
(defun mmm-mode-on-maybe ()
"Conditionally turn on MMM Mode.
Turn on MMM Mode if `mmm-global-mode' is non-nil and there are classes
to apply, or always if `mmm-global-mode' is t."
(cond ((eq mmm-global-mode t) (mmm-mode-on))
((not mmm-global-mode))
((mmm-get-all-classes nil) (mmm-mode-on)))
(when mmm-mode
(mmm-update-font-lock-buffer)))
(add-hook 'mmm-major-mode-hook #'mmm-mode-on-maybe)
(defalias 'mmm-add-find-file-hooks #'mmm-add-find-file-hook)
(defun mmm-add-find-file-hook ()
"Equivalent to (setq mmm-global-mode 'maybe).
This function is deprecated and may be removed in future."
(message "Warning: `mmm-add-find-file-hook' is deprecated.")
(setq mmm-global-mode 'maybe))
;;}}}
(provide 'mmm-auto)
;;; mmm-auto.el ends here

View File

@@ -0,0 +1,335 @@
;;; mmm-class.el --- MMM submode class variables and functions
;; Copyright (C) 2000-2004, 2011-2015, 2018 Free Software Foundation, Inc.
;; Author: Michael Abraham Shulman <viritrilbia@gmail.com>
;;{{{ GPL
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;}}}
;;; Commentary:
;; This file contains variable and function definitions for
;; manipulating and applying MMM submode classes. See `mmm-vars.el'
;; for variables that list classes.
;;; Code:
(require 'cl-lib)
(require 'mmm-vars)
(require 'mmm-region)
;;; CLASS SPECIFICATIONS
;;{{{ Get Class Specifications
(defun mmm-get-class-spec (class)
"Get the class specification for CLASS.
CLASS can be either a symbol to look up in `mmm-classes-alist' or a
class specifier itself."
(cond ((symbolp class) ; A symbol must be looked up
(or (cdr (assq class mmm-classes-alist))
(and (cadr (assq class mmm-autoloaded-classes))
(load (cadr (assq class mmm-autoloaded-classes)))
(cdr (assq class mmm-classes-alist)))
(signal 'mmm-invalid-submode-class (list class))))
((listp class) ; A list must be a class spec
class)
(t (signal 'mmm-invalid-submode-class (list class)))))
;;}}}
;;{{{ Get and Set Class Parameters
(defun mmm-get-class-parameter (class param)
"Get the value of the parameter PARAM for CLASS, or nil if none."
(cadr (member param (mmm-get-class-spec class))))
(defun mmm-set-class-parameter (class param value)
"Set the value of the parameter PARAM for CLASS to VALUE.
Creates a new parameter if one is not present."
(let* ((spec (mmm-get-class-spec class))
(current (member param spec)))
(if current
(setcar (cdr current) value)
(nconc spec (list param value)))))
;;}}}
;;{{{ Apply Classes
(cl-defun mmm-apply-class
(class &optional (start (point-min)) (stop (point-max)) face)
"Apply the submode class CLASS from START to STOP in FACE.
If FACE is nil, the face for CLASS is used, or the default face if
none is specified by CLASS."
;; The "special" class t means do nothing. It is used to turn on
;; MMM Mode without applying any classes.
(unless (eq class t)
(apply #'mmm-ify :start start :stop stop
(append (mmm-get-class-spec class)
(list :face face)))
(mmm-run-class-hook class)
;; Hack in case class hook sets mmm-buffer-mode-display-name etc.
(mmm-set-mode-line)))
(cl-defun mmm-apply-classes
(classes &key (start (point-min)) (stop (point-max)) face)
"Apply all submode classes in CLASSES, in order.
All classes are applied regardless of any errors that may occur in
other classes. If any errors occur, `mmm-apply-classes' exits with an
error once all classes have been applied."
(let (invalid-classes)
(dolist (class classes)
(condition-case err
(mmm-apply-class class start stop face)
(mmm-invalid-submode-class
;; Save the name of the invalid class, so we can report them
;; all together at the end.
(cl-pushnew (cl-second err) invalid-classes :test #'equal))))
(when invalid-classes
(signal 'mmm-invalid-submode-class invalid-classes))))
;;}}}
;;{{{ Apply All Classes
;; FIXME: This should be called by syntax-propertize-function,
;; not vice versa.
(cl-defun mmm-apply-all (&key (start (point-min)) (stop (point-max)))
"MMM-ify from START to STOP by all submode classes.
The classes come from mode/ext, `mmm-classes', `mmm-global-classes',
and interactive history."
(mmm-clear-overlays start stop 'strict)
(mmm-apply-classes (mmm-get-all-classes t) :start start :stop stop)
(mmm-update-submode-region)
;; Try to continue supporting XEmacs for a while.
(when (fboundp 'syntax-propertize)
(syntax-ppss-flush-cache start)
(syntax-propertize stop))
(mmm-refontify-maybe start stop))
;;}}}
;;; BUFFER SCANNING
;;{{{ Scan for Regions
(cl-defun mmm-ify
(&rest all &key classes handler
;; Many args are marked as "unused" below, but that's only
;; because they're used via `all'.
submode _match-submode
(start (point-min)) (stop (point-max))
front back _save-matches (case-fold-search t)
(beg-sticky (not (number-or-marker-p front)))
(end-sticky (not (number-or-marker-p back)))
_include-front _include-back
(front-offset 0) (back-offset 0)
(front-delim nil) (back-delim nil)
(delimiter-mode mmm-delimiter-mode)
front-face back-face
_front-verify _back-verify
_front-form _back-form
creation-hook
face _match-face
_save-name _match-name
;; FIXME: Since those args's arent' used directly (only passed down
;; via `all'), these default values aren't obeyed!
(_front-match 0) (_back-match 0)
_end-not-begin
;insert private
&allow-other-keys
)
"Create submode regions from START to STOP according to arguments.
If CLASSES is supplied, it must be a list of valid CLASSes. Otherwise,
the rest of the arguments are for an actual class being applied. See
`mmm-classes-alist' for information on what they all mean."
;; Make sure we get the default values in the `all' list.
(setq all (append
all
(list :start start :stop stop
:beg-sticky beg-sticky :end-sticky end-sticky
:front-offset front-offset :back-offset back-offset
:front-delim front-delim :back-delim back-delim
:front-match 0 :back-match 0
)))
(cond
;; If we have a class list, apply them all.
(classes
(mmm-apply-classes classes :start start :stop stop :face face))
;; Otherwise, apply this class.
;; If we have a handler, call it.
(handler
(apply handler all))
;; Otherwise, we search from START to STOP for submode regions,
;; continuining over errors, until we don't find any more. If FRONT
;; and BACK are number-or-markers, this should only execute once.
(t
(mmm-save-all
(goto-char start)
(cl-loop for (beg end front-pos back-pos matched-front matched-back
matched-submode matched-face matched-name
invalid-resume ok-resume) =
(apply #'mmm-match-region :start (point) all)
while beg
if end ; match-submode, if present, succeeded.
do
(condition-case nil
(progn
(mmm-make-region
(or matched-submode submode) beg end
:face (or matched-face face)
:front front-pos :back back-pos
:evaporation 'front
:match-front matched-front :match-back matched-back
:beg-sticky beg-sticky :end-sticky end-sticky
:name matched-name
:delimiter-mode delimiter-mode
:front-face front-face :back-face back-face
:creation-hook creation-hook
)
(goto-char ok-resume))
;; If our region is invalid, go back to the end of the
;; front match and continue on.
(mmm-error (goto-char invalid-resume)))
;; If match-submode was unable to find a match, go back to
;; the end of the front match and continue on.
else do (goto-char invalid-resume)
)))))
;;}}}
;;{{{ Match Regions
(cl-defun mmm-match-region
(&key start stop front back front-verify back-verify
front-delim back-delim
include-front include-back front-offset back-offset
front-form back-form save-matches match-submode match-face
front-match back-match end-not-begin
save-name match-name
&allow-other-keys)
"Find the first valid region between point and STOP.
Return \(BEG END FRONT-POS BACK-POS FRONT-FORM BACK-FORM SUBMODE FACE
NAME INVALID-RESUME OK-RESUME) specifying the region. See
`mmm-match-and-verify' for the valid values of FRONT and BACK
\(markers, regexps, or functions). A nil value for END means that
MATCH-SUBMODE failed to find a valid submode. INVALID-RESUME is the
point at which the search should continue if the region is invalid,
and OK-RESUME if the region is valid."
(when (mmm-match-and-verify front start stop front-verify)
(let ((beg (mmm-match->point include-front front-offset front-match))
(front-pos (if front-delim
(mmm-match->point t front-delim front-match)
nil))
(invalid-resume (match-end front-match))
(front-form (mmm-get-form front-form)))
(let ((submode (if match-submode
(condition-case nil
(mmm-save-all
(funcall match-submode front-form))
(mmm-no-matching-submode
(cl-return-from
mmm-match-region
(cl-values beg nil nil nil nil nil nil nil nil
invalid-resume nil))))
nil))
(name (cond ((functionp match-name)
(mmm-save-all (funcall match-name front-form)))
((stringp match-name)
(if save-name
(mmm-format-matches match-name)
match-name))))
(face (cond ((functionp match-face)
(mmm-save-all
(funcall match-face front-form)))
(match-face
(cdr (assoc front-form match-face))))))
(when (mmm-match-and-verify
(if save-matches
(mmm-format-matches back)
back)
beg stop back-verify)
(let* ((end (mmm-match->point (not include-back)
back-offset back-match))
(back-pos (if back-delim
(mmm-match->point nil back-delim back-match)
nil))
(back-form (mmm-get-form back-form))
(ok-resume (if end-not-begin
(match-end back-match)
end)))
(cl-values beg end front-pos back-pos front-form back-form
submode face name
invalid-resume ok-resume)))))))
(defun mmm-match->point (beginp offset match)
"Find a point of starting or stopping from the match data. If
BEGINP, start at \(match-beginning MATCH), else \(match-end MATCH),
and move OFFSET. Handles all values of OFFSET--see `mmm-classes-alist'."
(save-excursion
(goto-char (if beginp
(match-beginning match)
(match-end match)))
(dolist (spec (if (listp offset) offset (list offset)))
(if (numberp spec)
(forward-char (or spec 0))
(funcall spec)))
(point)))
(defun mmm-match-and-verify (pos start stop &optional verify)
"Find first match for POS between point and STOP satisfying VERIFY.
Return non-nil if a match was found, and set match data. POS can be a
number-or-marker, a regexp, or a function.
If POS is a number-or-marker, it is used as-is. If it is a string, it
is searched for as a regexp until VERIFY returns non-nil. If it is a
function, it is called with argument STOP and must return non-nil iff
a match is found, and set the match data. Note that VERIFY is ignored
unless POS is a regexp."
(cond
;; A marker can be used as-is, but only if it's in bounds.
((and (number-or-marker-p pos) (>= pos start) (<= pos stop))
(goto-char pos)
(looking-at "")) ; Set the match data
;; Strings are searched for as regexps.
((stringp pos)
(cl-loop always (re-search-forward pos stop 'limit)
until (or (not verify) (mmm-save-all (funcall verify)))))
;; Otherwise it must be a function.
((functionp pos)
(funcall pos stop))))
;;}}}
;;{{{ Get Delimiter Forms
(defun mmm-get-form (form)
"Return the delimiter form specified by FORM.
If FORM is nil, call `mmm-default-get-form'. If FORM is a string,
return it. If FORM is a function, call it. If FORM is a list, return
its `car' \(usually in this case, FORM is a one-element list
containing a function to be used as the delimiter form."
(cond ((stringp form) form)
((not form) (mmm-default-get-form))
((functionp form) (mmm-save-all (funcall form)))
((listp form) (car form))))
(defun mmm-default-get-form ()
(regexp-quote (match-string 0)))
;;}}}
(provide 'mmm-class)
;;; mmm-class.el ends here

View File

@@ -0,0 +1,443 @@
;;; mmm-cmds.el --- MMM Mode interactive commands and keymap
;; Copyright (C) 2000-2003, 2011-2013, 2018 Free Software Foundation, Inc.
;; Author: Michael Abraham Shulman <viritrilbia@gmail.com>
;;{{{ GPL
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;}}}
;;; Commentary:
;; This file contains the interactive commands for MMM Mode.
;;; Code:
(require 'cl-lib)
(require 'font-lock)
(require 'mmm-compat)
(require 'mmm-vars)
(require 'mmm-class)
;; APPLYING CLASSES
;;{{{ Applying Predefined Classes
(defun mmm-ify-by-class (class)
"Add submode regions according to an existing submode class."
(interactive
(list (intern
(completing-read
"Submode Class: "
(cl-remove-duplicates
(mapcar (lambda (spec) (list (symbol-name (car spec))))
(append
(cl-remove-if (lambda (spec) (plist-get (cdr spec) :private))
mmm-classes-alist)
(cl-remove-if #'caddr mmm-autoloaded-classes)))
:test #'equal)
nil t))))
(unless (eq class (intern ""))
(mmm-apply-class class)
(mmm-add-to-history class)
(mmm-update-font-lock-buffer)))
;;}}}
;;{{{ Applying by the Region
(defun mmm-ify-region (submode front back)
"Add a submode region for SUBMODE coinciding with current region."
(interactive "aSubmode: \nr")
(mmm-ify :submode submode :front front :back back)
(setq front (mmm-make-marker front t nil)
back (mmm-make-marker back nil nil))
(mmm-add-to-history `(:submode ,submode :front ,front :back ,back))
(mmm-enable-font-lock submode))
;;}}}
;;{{{ Applying Simple Regexps
(defun mmm-ify-by-regexp
(submode front front-offset back back-offset save-matches)
"Add SUBMODE regions to the buffer delimited by FRONT and BACK.
With prefix argument, prompts for all additional keywords arguments.
See `mmm-classes-alist'."
(interactive "aSubmode:
sFront Regexp:
nOffset from Front Regexp:
sBack Regexp:
nOffset from Back Regexp:
nNumber of matched substrings to save: ")
(let ((args (mmm-save-keywords submode front back front-offset
back-offset save-matches)))
(apply #'mmm-ify args)
(mmm-add-to-history args))
(mmm-enable-font-lock submode))
;;}}}
;; EDITING WITH REGIONS
;;{{{ Re-parsing Areas
(defun mmm-parse-buffer ()
"Re-apply all applicable submode classes to current buffer.
Clears all current submode regions, reapplies all past interactive
mmm-ification, and applies `mmm-classes' and mode-extension classes."
(interactive)
(message "MMM-ifying buffer...")
(mmm-apply-all)
(message "MMM-ifying buffer...done"))
(defun mmm-parse-region (start stop)
"Re-apply all applicable submode classes between START and STOP.
Clears all current submode regions, reapplies all past interactive
mmm-ification, and applies `mmm-classes' and mode-extension classes."
(interactive "r")
(message "MMM-ifying region...")
(mmm-apply-all :start start :stop stop)
(message "MMM-ifying region...done"))
(defun mmm-parse-block (&optional lines)
"Re-parse LINES lines before and after point \(default 1).
Clears all current submode regions, reapplies all past interactive
mmm-ification, and applies `mmm-classes' and mode-extension classes.
This command is intended for use when you have just typed what should
be the delimiters of a submode region and you want to create the
region. However, you may want to look into the various types of
delimiter auto-insertion that MMM Mode provides. See, for example,
`mmm-insert-region'."
(interactive "p")
(message "MMM-ifying block...")
(cl-destructuring-bind (start stop) (mmm-get-block lines)
(when (< start stop)
(mmm-apply-all :start start :stop stop)))
(message "MMM-ifying block...done"))
(defun mmm-get-block (lines)
(let ((inhibit-point-motion-hooks t))
(list (save-excursion
(forward-line (- lines))
(beginning-of-line)
(point))
(save-excursion
(forward-line lines)
(end-of-line)
(point)))))
;;}}}
;;{{{ Reparse Current Region
(defun mmm-reparse-current-region ()
"Clear and reparse the area of the current submode region.
Use this command if a submode region's boundaries have become wrong."
(interactive)
(let ((ovl (mmm-overlay-at (point) 'all)))
(when ovl
(let ((beg (save-excursion
(goto-char (mmm-front-start ovl))
(forward-line -1)
(point)))
(end (save-excursion
(goto-char (mmm-back-end ovl))
(forward-line 1)
(point))))
(mmm-parse-region beg end)))))
;;}}}
;;{{{ Clear Submode Regions
;; See also `mmm-clear-history' which is interactive.
(defun mmm-clear-current-region ()
"Deletes the submode region point is currently in, if any."
(interactive)
(delete-overlay (mmm-overlay-at (point) 'all)))
(defun mmm-clear-regions (start stop)
"Deletes all submode regions from START to STOP."
(interactive "r")
(mmm-clear-overlays start stop))
(defun mmm-clear-all-regions ()
"Deletes all submode regions in the current buffer."
(interactive)
(mmm-clear-overlays))
;;}}}
;;{{{ End Current Region
(cl-defun mmm-end-current-region (&optional arg)
"End current submode region.
If ARG is nil, end it at the most appropriate place, usually its
current back boundary. If ARG is non-nil, end it at point. If the
current region is correctly bounded, the first does nothing, but the
second deletes that delimiter as well.
If the region's BACK property is a string, it is inserted as above and
the overlay moved if necessary. If it is a function, it is called with
two arguments--the overlay, and \(if ARG 'middle t)--and must do the
entire job of this function."
(interactive "P")
(let ((ovl (mmm-overlay-at)))
(when ovl
(combine-after-change-calls
(save-match-data
(save-excursion
(when (mmm-match-back ovl)
(if arg
(replace-match "")
(cl-return-from mmm-end-current-region)))))
(let ((back (overlay-get ovl 'back)))
(cond ((stringp back)
(save-excursion
(unless arg (goto-char (overlay-end ovl)))
(save-excursion (insert back))
(move-overlay ovl (overlay-start ovl) (point))))
((functionp back)
(funcall back ovl (if arg 'middle t))))))
(mmm-refontify-maybe (save-excursion (forward-line -1) (point))
(save-excursion (forward-line 1) (point))))))
;;}}}
;;{{{ Narrow to Region
(defun mmm-narrow-to-submode-region (&optional pos)
"Narrow to the submode region at point."
(interactive)
;; Probably don't use mmm-current-overlay here, because this is
;; sometimes called from inside messy functions.
(let ((ovl (mmm-overlay-at pos)))
(when ovl
(narrow-to-region (overlay-start ovl) (overlay-end ovl)))))
;; The inverse command is `widen', usually on `C-x n w'
;;}}}
;; INSERTING REGIONS
;;{{{ Insert regions by keystroke
;; This is the "default" binding in the MMM Mode keymap. Keys defined
;; by classes should be control keys, to avoid conflicts with MMM
;; commands.
(defun mmm-insert-region (arg)
"Insert a submode region based on last character in invoking keys.
Keystrokes after `mmm-mode-prefix-key' which are not bound to an MMM
Mode command \(see `mmm-command-modifiers') are passed on to this
function. If they have the modifiers `mmm-insert-modifiers', then they
are looked up, sans those modifiers, in all current submode classes to
find an insert skeleton. For example, in Mason, `p' \(with appropriate
prefix and modifiers) will insert a <%perl>...</%perl> region."
(interactive "P")
(let* ((seq (this-command-keys))
(event (aref seq (1- (length seq))))
(mods (event-modifiers event))
(key (mmm-event-key event)))
(if (cl-subsetp mmm-insert-modifiers mods)
(mmm-insert-by-key
(append (cl-set-difference mods mmm-insert-modifiers)
key)
arg))))
(defun mmm-insert-by-key (key &optional arg)
"Insert a submode region based on event KEY.
Inspects all the classes of the current buffer to find a matching
:insert key sequence. See `mmm-classes-alist'. ARG, if present, is
passed on to `skeleton-proxy-new' to control wrapping.
KEY must be a list \(MODIFIERS... . BASIC-KEY) where MODIFIERS are
symbols such as shift, control, etc. and BASIC-KEY is a character code
or a symbol such as tab, return, etc. Note that if there are no
MODIFIERS, the dotted list becomes simply BASIC-KEY."
(cl-multiple-value-bind (class skel str) (mmm-get-insertion-spec key)
(when skel
(let ((after-change-functions nil)
(old-undo buffer-undo-list) undo)
;; XEmacs' skeleton doesn't manage positions by itself, so we
;; have to do it.
(if mmm-xemacs (setq skeleton-positions nil))
(skeleton-proxy-new skel str arg)
(cl-destructuring-bind (back end beg front) skeleton-positions
;; TODO: Find a way to trap invalid-parent signals from
;; make-region and undo the skeleton insertion.
(let ((match-submode (plist-get class :match-submode))
(match-face (plist-get class :match-face))
(match-name (plist-get class :match-name))
(front-form (regexp-quote (buffer-substring front beg)))
(back-form (regexp-quote (buffer-substring end back)))
submode face name)
(setq submode
(mmm-modename->function
(if match-submode
(mmm-save-all (funcall match-submode front-form))
(plist-get class :submode))))
(setq face
(cond ((functionp match-face)
(mmm-save-all
(funcall match-face front-form)))
(match-face
(cdr (assoc front-form match-face)))
(t
(plist-get class :face))))
(setq name
(cond ((plist-get class :skel-name)
;; Optimize the name to the user-supplied str
;; if we are so instructed.
str)
;; Call it if it is a function
((functionp match-name)
(mmm-save-all (funcall match-name front-form)))
;; Now we know it's a string, does it need to
;; be formatted?
((plist-get class :save-name)
;; Yes. Haven't done a match before, so
;; match the front regexp against the given
;; form to format the string
(string-match (plist-get class :front)
front-form)
(mmm-format-matches match-name front-form))
(t
;; No, just use it as-is
match-name)))
(mmm-make-region
submode beg end
:face face
:name name
:front front :back back
:match-front front-form :match-back back-form
:evaporation 'front
;;; :beg-sticky (plist-get class :beg-sticky)
;;; :end-sticky (plist-get class :end-sticky)
:beg-sticky t :end-sticky t
:creation-hook (plist-get class :creation-hook))
(mmm-enable-font-lock submode)))
;; Now get rid of intermediate undo boundaries, so that the entire
;; insertion can be undone as one action. This should really be
;; skeleton's job, but it doesn't do it.
(setq undo buffer-undo-list)
(while (not (eq (cdr undo) old-undo))
(when (eq (cadr undo) nil)
(setcdr undo (cddr undo)))
(setq undo (cdr undo)))))))
(defun mmm-get-insertion-spec (key &optional classlist)
"Get the insertion info for KEY from all classes in CLASSLIST.
Return \(CLASS SKEL STR) where CLASS is the class spec a match was
found in, SKEL is the skeleton to insert, and STR is the argument.
CLASSLIST defaults to the return value of `mmm-get-all-classes',
including global classes."
(cl-loop for classname in (or classlist (mmm-get-all-classes t))
for class = (mmm-get-class-spec classname)
for inserts = (plist-get class :insert)
for skel = (cddr (assoc key inserts))
with str
;; If SKEL is a dotted pair, it means call another key's
;; insertion spec with an argument.
unless (consp (cdr skel))
do (setq str (cdr skel)
skel (cddr (assoc (car skel) inserts)))
if skel return (list class skel str)
;; If we have a group class, recurse.
if (plist-get class :classes)
if (mmm-get-insertion-spec key it)
return it))
;;}}}
;;{{{ Help on Insertion
(defun mmm-insertion-help ()
"Display help on currently available MMM insertion commands."
(interactive)
(with-output-to-temp-buffer "*Help*"
(princ "Available MMM Mode Insertion Commands:\n")
(princ "Key Inserts\n")
(princ "--- -------\n\n")
(mapcar #'mmm-display-insertion-key
(mmm-get-all-insertion-keys))))
(defun mmm-display-insertion-key (spec)
"Print an insertion binding to standard output.
SPEC should be \(KEY NAME ...) where KEY is an insertion key and NAME
is a symbol naming the insertion."
(let* ((str (make-string 16 ?\ ))
;; This gets us a dotted list, because of the way insertion
;; keys are specified.
(key (append mmm-insert-modifiers (car spec)))
(lastkey (nthcdr (max (1- (safe-length key)) 0) key)))
;; Now we make it a true list
(if (consp key)
(setcdr lastkey (list (cdr lastkey)))
(setq key (list key)))
;; Get the spacing right
(store-substring str 0
(key-description
(apply #'vector (append mmm-mode-prefix-key (list key)))))
(princ str)
;; Now print the binding symbol
(princ (cadr spec))
(princ "\n")))
(defun mmm-get-all-insertion-keys (&optional classlist)
"Return an alist of all currently available insertion keys.
Elements look like \(KEY NAME ...) where KEY is an insertion key and
NAME is a symbol naming the insertion."
(cl-remove-duplicates
(cl-loop for classname in (or classlist (mmm-get-all-classes t))
for class = (mmm-get-class-spec classname)
append (plist-get class :insert) into keys
;; If we have a group class, recurse.
if (plist-get class :classes)
do (setq keys (append keys (mmm-get-all-insertion-keys it)))
finally return keys)
:test #'equal
:key (lambda (x) (cons (car x) (cadr x)))
:from-end t))
;;}}}
;;{{{ Auto Insertion (copied from interactive session);-COM-
;-COM-
;-COM-;; Don't use `mmm-ify-region' of course. And rather than having
;-COM-;; classes define their own functions, we should have them pass a
;-COM-;; skeleton as an attribute. Then our insert function can turn off
;-COM-;; after-change hooks and add the submode region afterward.
;-COM-
;-COM-(define-skeleton mmm-see-inline
;-COM- "" nil
;-COM- -1 @ " " _ " " @ "%>"
;-COM- '(apply #'mmm-ify-region 'cperl-mode (reverse skeleton-positions)))
;-COM-
;-COM-(define-skeleton mmm-see-other
;-COM- "" nil
;-COM- @ ";\n" _ "\n" @ "<%/" str ">"
;-COM- '(apply #'mmm-ify-region 'cperl-mode (reverse skeleton-positions)))
;-COM-
;-COM-(add-hook 'after-change-functions 'mmm-detect t)
;-COM-
;-COM-(defun mmm-detect (beg end length)
;-COM- (when (mmm-looking-back-at "<% ")
;-COM- (mmm-see-inline))
;-COM- (when (mmm-looking-back-at "<%\\(\\w+\\)>")
;-COM- (mmm-see-other (match-string 1))))
;-COM-
;;}}}
(provide 'mmm-cmds)
;;; mmm-cmds.el ends here

View File

@@ -0,0 +1,130 @@
;;; mmm-compat.el --- MMM Hacks for compatibility with other Emacsen
;; Copyright (C) 2000, 2003, 2011, 2013 Free Software Foundation, Inc.
;; Author: Michael Abraham Shulman <viritrilbia@gmail.com>
;;{{{ GPL
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;}}}
;;; Commentary:
;; This file provides a number of hacks that are necessary for MMM
;; Mode to function in different Emacsen. MMM Mode is designed for
;; FSF Emacs, but these hacks usually enable it to work
;; almost perfectly in XEmacs 21.
;;; Code:
;;{{{ Emacsen Detection
(defvar mmm-xemacs (featurep 'xemacs)
"Whether we are running XEmacs.")
;;}}}
;;{{{ Regexp-Opt (XEmacs)
;; As of XEmacs' xemacs-base package version 1.82,
;; the regexp-opt API is compatible with GNU Emacs.
(defalias 'mmm-regexp-opt 'regexp-opt)
;;}}}
;;{{{ Overlays (XEmacs)
;; The main thing we use from FSF Emacs that XEmacs doesn't support
;; are overlays. XEmacs uses extents instead, but comes with a package
;; to emulate overlays.
(when mmm-xemacs
;; This does almost everything we need.
(require 'overlay))
;; We also use a couple "special" overlay properties which have
;; different names for XEmacs extents.
(defvar mmm-evaporate-property
(if (featurep 'xemacs) 'detachable 'evaporate)
"The name of the overlay property controlling evaporation.")
;; We don't use this any more, since its behavior is different in FSF
;; and XEmacs: in the one it replaces the buffer's local map, but in
;; the other it gets stacked on top of it. Instead we just set the
;; buffer's local map temporarily.
;;;(defvar mmm-keymap-property
;;; (if (featurep 'xemacs) 'keymap 'local-map)
;;; "The name of the overlay property controlling keymaps.")
;;}}}
;;{{{ Keymaps and Events (XEmacs)
;; In XEmacs, keymaps are a primitive type, while in FSF Emacs, they
;; are a list whose car is the symbol `keymap'. Among other things,
;; this means that they handle default bindings differently.
(defmacro mmm-set-keymap-default (keymap binding)
(if (featurep 'xemacs)
`(set-keymap-default-binding ,keymap ,binding)
`(define-key ,keymap [t] ,binding)))
;; In XEmacs, events are a primitive type, while in FSF Emacs, they
;; are represented by characters or vectors. We treat them as vectors.
;; We can use `event-modifiers' in both Emacsen to extract the
;; modifiers, but the function to extract the basic key is different.
(defmacro mmm-event-key (event)
(if (featurep 'xemacs)
`(event-key ,event)
`(event-basic-type ,event)))
;;}}}
;;{{{ Skeleton (XEmacs)
;; XEmacs' `skeleton' package doesn't provide `@' to record positions.
(defvar skeleton-positions ())
(defun mmm-fixup-skeleton ()
"Add `@' to `skeleton-further-elements' if XEmacs and not there.
This makes `@' in skeletons act approximately like it does in FSF."
(and (featurep 'xemacs)
(defvar skeleton-further-elements ())
(not (assoc '@ skeleton-further-elements))
(add-to-list 'skeleton-further-elements
'(@ ''(push (point) skeleton-positions)))))
;;}}}
;;{{{ Make Temp Buffers (XEmacs)
(defmacro mmm-make-temp-buffer (buffer name)
"Return a buffer with name based on NAME including the text of BUFFER.
This text should not be modified."
(if (fboundp 'make-indirect-buffer)
`(make-indirect-buffer ,buffer (generate-new-buffer-name ,name))
`(save-excursion
(set-buffer (generate-new-buffer ,name))
(insert-buffer ,buffer)
(current-buffer))))
;;}}}
;;{{{ Emacs < 26 requires namespaced CL functions
(if (>= emacs-major-version 26)
(defalias 'mmm-mapcan 'mapcan)
(require 'cl-lib)
(defalias 'mmm-mapcan 'cl-mapcan))
;;}}}
(provide 'mmm-compat)
;;; mmm-compat.el ends here

View File

@@ -0,0 +1,100 @@
;;; mmm-cweb.el --- MMM submode class for CWeb programs
;; Copyright (C) 2001, 2002, 2013 Free Software Foundation, Inc.
;; Author: Alan Shutko <ats@acm.org>
;;{{{ GPL
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;}}}
;;; Commentary:
;; This file contains the definition of an MMM Mode submode class for
;; editing CWeb programs.
;;; Code:
(require 'mmm-compat)
(require 'mmm-vars)
(require 'mmm-auto)
(defvar mmm-cweb-section-tags
'("@ " "@*"))
(defvar mmm-cweb-section-regexp
(concat "^" (mmm-regexp-opt mmm-cweb-section-tags t)))
(defvar mmm-cweb-c-part-tags
'("@c" "@>=" "@>+=" "@p"))
(defvar mmm-cweb-c-part-regexp
(concat (mmm-regexp-opt mmm-cweb-c-part-tags t)))
(defun mmm-cweb-in-limbo (pos)
"Check to see if POS is in limbo, ie before any cweb sections."
(save-match-data
(save-excursion
(goto-char pos)
(not (re-search-backward mmm-cweb-section-regexp nil t)))))
(defun mmm-cweb-verify-brief-c ()
"Verify function for cweb-brief-c class.
Checks whether the match is in limbo."
(not (mmm-cweb-in-limbo (match-beginning 0))))
(mmm-add-group
'cweb
`(
(cweb-c-part
:submode c-mode
:front ,mmm-cweb-c-part-regexp
:back ,mmm-cweb-section-regexp)
(cweb-label
:submode tex-mode
:front "@<"
:back "@>"
:face mmm-comment-submode-face
:insert ((?l cweb-label nil @ "@<" @ "@>")))
(cweb-brief-c
:submode c-mode
:front "[^\\|]\\(|\\)[^|]"
:front-match 1
:front-verify mmm-cweb-verify-brief-c
; :front-offset -1
:back "[^\\|]\\(|\\)"
:back-match 1
; :back-offset 1
:end-not-begin t
:insert ((?| cweb-c-in-tex nil "|" @ "|")))
(cweb-comment
:submode tex-mode
:front "/[*]"
:back "[*]/"
:face mmm-comment-submode-face)
))
;; (add-to-list 'mmm-mode-ext-classes-alist
;; '(plain-tex-mode "\\.w\\'" cweb))
;; (add-to-list 'mmm-mode-ext-classes-alist
;; '(latex-mode "\\.w\\'" cweb))
;; (add-to-list 'auto-mode-alist '("\\.w\\'" . tex-mode))
(provide 'mmm-cweb)
;;; mmm-cweb.el ends here

View File

@@ -0,0 +1,62 @@
;;; mmm-defaults.el --- Friendly defaults for MMM Mode
;; Copyright (C) 2013 Free Software Foundation, Inc.
;; Author: Dmitry Gutov <dgutov@yandex.ru>
;;{{{ GPL
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;; Commentary:
;; To enable multiple mode support in ERB, EJS and PHP files, just add the
;; following line to your init file:
;;
;; (require 'mmm-defaults)
;;
;; Note that for PHP you still need to have php-mode (installed separately).
;;
;; TODO: Add more file types and classes here. Mention this file in README.
;;; Code:
(require 'mmm-auto)
(setq mmm-global-mode 'auto)
;;; ERB and EJS
(mmm-add-mode-ext-class 'html-erb-mode "\\.erb\\'" 'erb)
(mmm-add-mode-ext-class 'html-erb-mode "\\.ejs\\'" 'ejs)
(mmm-add-mode-ext-class 'html-erb-mode nil 'html-js)
(mmm-add-mode-ext-class 'html-erb-mode nil 'html-css)
(add-to-list 'auto-mode-alist '("\\.html\\.erb\\'" . html-erb-mode))
(add-to-list 'auto-mode-alist '("/[^.]+\\.erb\\'" . html-erb-mode))
(add-to-list 'auto-mode-alist '("\\.jst\\.ejs\\'" . html-erb-mode))
;;; PHP
(mmm-add-mode-ext-class 'html-mode nil 'html-js)
(mmm-add-mode-ext-class 'html-mode nil 'html-css)
(mmm-add-mode-ext-class 'html-mode "\\.php\\'" 'html-php)
(add-to-list 'auto-mode-alist '("\\.html\\.php\\'" . html-mode))
(add-to-list 'auto-mode-alist '("/[^.]+\\.php\\'" . html-mode))
(provide 'mmm-defaults)
;;; mmm-defaults.el ends here

View File

@@ -0,0 +1,243 @@
;;; mmm-erb.el --- ERB templates editing support
;; Copyright (C) 2012, 2013, 2018 Free Software Foundation, Inc.
;; Author: Dmitry Gutov <dgutov@yandex.ru>
;;{{{ GPL
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;}}}
;;; Commentary:
;; This file contains definitions of ERB and EJS submode classes, and well as
;; support functions for proper indentation.
;; Usage:
;; (require 'mmm-auto)
;; (setq mmm-global-mode 'auto)
;; (mmm-add-mode-ext-class 'html-erb-mode "\\.html\\.erb\\'" 'erb)
;; (mmm-add-mode-ext-class 'html-erb-mode "\\.jst\\.ejs\\'" 'ejs)
;; (mmm-add-mode-ext-class 'html-erb-mode nil 'html-js)
;; (mmm-add-mode-ext-class 'html-erb-mode nil 'html-css)
;; (add-to-list 'auto-mode-alist '("\\.html\\.erb\\'" . html-erb-mode))
;; (add-to-list 'auto-mode-alist '("\\.jst\\.ejs\\'" . html-erb-mode))
;; Optional settings:
;; (setq mmm-submode-decoration-level 2
;; mmm-parse-when-idle t)
;; nXML as primary mode (supports only JS and CSS subregions):
;; (mmm-add-mode-ext-class 'nxml-web-mode nil 'html-js)
;; (mmm-add-mode-ext-class 'nxml-web-mode nil 'html-css)
;; (add-to-list 'auto-mode-alist '("\\.xhtml\\'" . nxml-web-mode))
;;; Code:
(require 'sgml-mode)
(require 'cl-lib)
(require 'mmm-vars)
(require 'mmm-region)
(mmm-add-classes
'((erb :submode ruby-mode :front "<%[#=]?" :back "-?%>"
:match-face (("<%#" . mmm-comment-submode-face)
("<%=" . mmm-output-submode-face)
("<%" . mmm-code-submode-face))
:insert ((?% erb-code nil @ "<%" @ " " _ " " @ "%>" @)
(?# erb-comment nil @ "<%#" @ " " _ " " @ "%>" @)
(?= erb-expression nil @ "<%=" @ " " _ " " @ "%>" @))
:creation-hook mmm-erb-mark-as-special)
(ejs :submode js-mode :front "<%[#=]?" :back "-?%>"
:match-face (("<%#" . mmm-comment-submode-face)
("<%=" . mmm-output-submode-face)
("<%" . mmm-code-submode-face))
:insert ((?% ejs-code nil @ "<%" @ " " _ " " @ "%>" @)
(?# ejs-comment nil @ "<%#" @ " " _ " " @ "%>" @)
(?= ejs-expression nil @ "<%=" @ " " _ " " @ "%>" @))
:creation-hook mmm-erb-mark-as-special)))
(defun mmm-erb-mark-as-special ()
"Hook function to run in ERB and EJS tag regions."
(overlay-put mmm-current-overlay 'mmm-special-tag t))
;;;###autoload
(define-derived-mode html-erb-mode html-mode "ERB-HTML"
(setq sgml-unclosed-tags nil) ; Simplifies indentation logic.
(set (make-local-variable 'mmm-indent-line-function) #'mmm-erb-indent-line)
(add-hook 'mmm-after-syntax-propertize-functions
#'html-erb-after-syntax-propertize nil t))
(defun html-erb-after-syntax-propertize (overlay _mode beg end)
(when overlay
(with-silent-modifications
(funcall
(syntax-propertize-rules ("<\\|>" (0 ".")))
beg end))))
(defun mmm-erb-indent-line ()
"Indent the current line intelligently."
(interactive)
(let ((offset (- (current-column) (current-indentation))))
(back-to-indentation)
(mmm-update-submode-region)
(if (and mmm-current-overlay mmm-current-submode
(< (overlay-start mmm-current-overlay) (point-at-bol)))
;; Region starts before the current line (and contains indentation).
;; If it starts on the current line, then either first part of the line
;; is in primary mode, or we're on the first line of a script or style
;; tag contents. In the latter case, better to also indent it according
;; to the primary mode (as text): `js-indent-line' ignores narrowing,
;; gets confused by the angle bracket on the previous line and thus
;; breaks our "top level" heuristic.
(mmm-erb-indent-line-submode)
(mmm-erb-indent-line-primary))
(when (> offset 0) (forward-char offset))))
(defun mmm-erb-indent-line-submode ()
"Indent line within a submode."
(let (added-whitespace)
(if (<= (overlay-end mmm-current-overlay)
(save-excursion (back-to-indentation) (point)))
;; We're at a closing tag.
(mmm-erb-indent-to-region-start)
(save-restriction
(save-excursion
(goto-char (overlay-start mmm-current-overlay))
(when (not (looking-at "^\\|\\s-*$"))
;; Submode region has text on the same line as the opening tag,
;; pad it with whitespace to make the following lines line up.
(setq added-whitespace (current-column))
(insert-char ?\s added-whitespace)))
(narrow-to-region (overlay-start mmm-current-overlay)
(overlay-end mmm-current-overlay))
(funcall (mmm-erb-orig-indent-function mmm-current-submode))
(when added-whitespace
;; Remove the padding.
(save-excursion
(goto-char (overlay-start mmm-current-overlay))
(delete-char added-whitespace))))
;; If submode indent function moved us to bol,
;; we're on the top level, indent according to the primary mode.
(when (zerop (current-indentation))
(mmm-erb-indent-to-region-start
(mmm-erb-indent-offset mmm-primary-mode))))))
(defun mmm-erb-indent-to-region-start (&optional additional-offset)
"Indent line to match start of region, possibly adding ADDITIONAL-OFFSET."
(indent-line-to
(save-excursion
(goto-char (1- (overlay-start mmm-current-overlay)))
(+ (current-indentation)
(or additional-offset 0)))))
(defun mmm-erb-indent-line-primary ()
"Indent line in primary mode."
(let* ((here (point))
;; Go before previous line's tag.
(start (progn (forward-line -1)
(back-to-indentation)
(let ((lcon (sgml-lexical-context)))
(when (eq (car lcon) 'tag)
;; Tag spreads several lines.
(goto-char (cdr lcon))
(back-to-indentation)))
(point)))
(regions (mmm-regions-in start here))
(n 0))
;; Collect indent modifier depending on type of tags.
(cl-loop for region in regions
for type = (mmm-erb-scan-region region)
when type do
(if (eq type 'close)
(when (cl-plusp n) (cl-decf n))
(cl-incf n (if (eq type 'close) 0 1))))
(let ((eol (progn (goto-char here) (end-of-line 1) (point))))
;; Look for "else" and "end" instructions to adjust modifier.
;; If a block start instruction comes first, abort.
(cl-loop for region in (mmm-regions-in here eol)
for type = (mmm-erb-scan-region region)
until (eq type 'open)
when (memq type '(middle close)) do (cl-decf n)))
(goto-char here)
(funcall (mmm-erb-orig-indent-function mmm-primary-mode))
(let* ((indent (current-indentation))
(indent-step (mmm-erb-indent-offset mmm-primary-mode)))
(indent-line-to (+ indent (if n (* indent-step n) 0))))))
(defun mmm-erb-scan-region (region)
(when region ; Can be nil if a line is empty, for example.
(cl-destructuring-bind (submode beg end ovl) region
(let ((scan-fn (plist-get '(ruby-mode mmm-erb-scan-erb
js-mode mmm-erb-scan-ejs)
submode)))
(and scan-fn
(overlay-get ovl 'mmm-special-tag)
(save-excursion
(goto-char beg)
(skip-syntax-forward "-")
(funcall scan-fn end)))))))
(defconst mmm-erb-ruby-close-re "\\<end\\>\\|}"
"Regexp to match the end of a Ruby block.")
(defun mmm-erb-scan-erb (limit)
(cond ((looking-at "\\(?:if\\|unless\\|for\\|while\\)\\b") 'open)
((looking-at "\\(?:else\\|elsif\\)\\b") 'middle)
((looking-at mmm-erb-ruby-close-re) 'close)
((and (re-search-forward (concat "\\(?: +do +\\| *{ *\\)"
"\\(?:|[A-Za-z0-9_, ]*|\\)? *")
limit t)
(let ((pt (point)))
(not (when (< pt limit)
(goto-char limit)
(skip-syntax-backward "-")
(looking-back mmm-erb-ruby-close-re pt)))))
'open)))
(defun mmm-erb-scan-ejs (limit)
(cond ((looking-at "\\(?:if\\|for\\|while\\)\\b") 'open)
((looking-at "} *else\\b") 'middle)
((looking-at "}") 'close)
((re-search-forward " *{ *" limit t) 'open)))
(defun mmm-erb-orig-indent-function (mode)
(get mode 'mmm-indent-line-function))
(defvar mmm-erb-offset-var-alist
'((html-erb-mode . sgml-basic-offset)
(nxml-web-mode . nxml-child-indent)))
(defun mmm-erb-indent-offset (mode)
(let ((name (cdr (assoc mode mmm-erb-offset-var-alist))))
(when name (symbol-value name))))
;;;###autoload
(define-derived-mode nxml-web-mode nxml-mode "nXML-Web"
(set (make-local-variable 'mmm-indent-line-function) #'mmm-erb-indent-line))
(provide 'mmm-erb)
;;; mmm-erb.el ends here

View File

@@ -0,0 +1,175 @@
;;; mmm-mason.el --- MMM submode class for Mason components
;; Copyright (C) 2000-2003, 2013, 2018 Free Software Foundation, Inc.
;; Author: Michael Abraham Shulman <viritrilbia@gmail.com>
;;{{{ GPL
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;}}}
;;; Commentary:
;; This file contains the definition of an MMM Mode submode class for
;; editing Mason components. See the file README.Mason for more
;; details.
;;; Code:
(require 'mmm-compat)
(require 'mmm-vars)
(require 'mmm-auto)
;;{{{ Perl Tags
(defvar mmm-mason-perl-tags
'("perl" "init" "cleanup" "once" "filter" "shared"
"perl_init" "perl_cleanup" "perl_once" "perl_filter"))
(defvar mmm-mason-pseudo-perl-tags
'("args" "perl_args" "attr" "flags"))
(defvar mmm-mason-non-perl-tags
'("doc" "perl_doc" "text" "perl_text" "def" "perl_def" "method"))
(defvar mmm-mason-perl-tags-regexp
(concat "<%" (mmm-regexp-opt mmm-mason-perl-tags t) ">")
"Matches tags beginning Mason sections containing Perl code.
Saves the name of the tag matched.")
(defvar mmm-mason-pseudo-perl-tags-regexp
(concat "<%" (mmm-regexp-opt mmm-mason-pseudo-perl-tags t) ">")
"Match tags beginning Mason sections that look like Perl but aren't.
Saves the name of the tag matched.")
(defvar mmm-mason-tag-names-regexp
(regexp-opt (append mmm-mason-perl-tags mmm-mason-non-perl-tags) t)
"Matches any Mason tag name after the \"<%\". Used to verify that a
\"<%\" sequence starts an inline section.")
(defun mmm-mason-verify-inline ()
(not (looking-at mmm-mason-tag-names-regexp)))
;;}}}
;;{{{ Add Classes
(mmm-add-group
'mason
`((mason-text
:submode nil
:front "<%text>"
:back "</%text>"
:insert ((?t mason-<%text> nil @ "<%text>" @ "\n"
_ "\n" @ "</%text>" @)))
(mason-doc
:submode text-mode
:face mmm-comment-submode-face
:front "<%doc>"
:back "</%doc>"
:face nil
:insert ((?d mason-<%doc> nil @ "<%doc>" @ "\n"
_ "\n" @ "</%doc>" @)))
(mason-perl
:submode perl
:match-face (("<%perl>" . mmm-code-submode-face)
("<%init>" . mmm-init-submode-face)
("<%cleanup>" . mmm-cleanup-submode-face)
("<%once>" . mmm-init-submode-face)
("<%filter>" . mmm-special-submode-face)
("<%shared>" . mmm-init-submode-face))
:front ,mmm-mason-perl-tags-regexp
:back "</%~1>"
:save-matches 1
:match-name "~1"
:save-name 1
:insert ((?, mason-<%TAG> "Perl section: " @ "<%" str ">" @
";\n" _ "\n" @ "</%" str ">" @)
(?< mason-<%TAG> ?, . nil)
(?p mason-<%perl> ?, . "perl")
(?i mason-<%init> ?, . "init")
(?c mason-<%cleanup> ?, . "cleanup")
(?o mason-<%once> ?, . "once")
(?l mason-<%filter> ?, . "filter")
(?s mason-<%shared> ?, . "shared")))
(mason-pseudo-perl
:submode perl
:face mmm-declaration-submode-face
:front ,mmm-mason-pseudo-perl-tags-regexp
:back "</%~1>"
:save-matches 1
:insert ((?. mason-pseudo-<%TAG> "Pseudo-perl section: " @ "<%" str ">" @
"\n" _ "\n" @ "</%" str ">" @)
(?> mason-pseudo-<%TAG> ?, . nil)
(?a mason-<%args> ?. . "args")
(?f mason-<%flags> ?. . "flags")
(?r mason-<%attr> ?. . "attr")))
(mason-inline
:submode perl
:face mmm-output-submode-face
:front "<%"
:front-verify mmm-mason-verify-inline
:back "%>"
:insert ((?% mason-<%-%> nil @ "<%" @ " " _ " " @ "%>" @)
(?5 mason-<%-%> ?% . nil)))
(mason-call
:submode perl
:face mmm-special-submode-face
:front "<&"
:back "&>"
:insert ((?& mason-<&-&> nil @ "<&" @ " " _ " " @ "&>" @)
(?7 mason-<&-&> ?% . nil)))
(mason-one-line-comment
:submode text-mode
:face mmm-comment-submode-face
:front "^%#"
:back "\n"
:insert ((?# mason-%-comment nil (mmm-mason-start-line)
@ "%" @ "# " _ @ '(mmm-mason-end-line) "\n" @)
(?3 mason-%-comment ?# . nil)))
(mason-one-line
:submode perl
:face mmm-code-submode-face
:front "^%"
:back "\n"
:insert ((return mason-%-line nil (mmm-mason-start-line)
@ "%" @ " " _ @ '(mmm-mason-end-line) "\n" @)))))
;;}}}
;;{{{ One-line Sections
(defun mmm-mason-start-line ()
(if (bolp)
""
"\n"))
(defun mmm-mason-end-line ()
(if (eolp)
(delete-char 1)))
;;}}}
;;{{{ Set Mode Line
(defun mmm-mason-set-mode-line ()
(setq mmm-buffer-mode-display-name "Mason"))
(add-hook 'mmm-mason-class-hook #'mmm-mason-set-mode-line)
;;}}}
(provide 'mmm-mason)
;;; mmm-mason.el ends here

View File

@@ -0,0 +1,309 @@
;;; mmm-mode.el --- Allow Multiple Major Modes in a buffer
;; Copyright (C) 1999-2004, 2012-2015, 2018 Free Software Foundation, Inc.
;; Emacs Lisp Archive Entry
;; Package: mmm-mode
;; Author: Michael Abraham Shulman <viritrilbia@gmail.com>
;; Maintainer: Dmitry Gutov <dgutov@yandex.ru>
;; URL: https://github.com/purcell/mmm-mode
;; Keywords: convenience, faces, languages, tools
;; Version: 0.5.7
;; Package-Requires: ((cl-lib "0.2"))
;;{{{ GPL
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published
;; by the Free Software Foundation; either version 2, or (at your
;; option) any later version.
;; This file is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;}}}
;;; Commentary:
;; MMM Mode is a minor mode that allows multiple major modes to
;; coexist in a single buffer. Refer to the documentation of the
;; function `mmm-mode' for more detailed information. This file
;; contains mode on/off functions and the mode keymap, but mostly
;; just loads all the subsidiary files.
;{{{ Parameter Naming
;; Since version 0.3.7, I've tried to use a uniform scheme for naming
;; parameters. Here's a brief summary.
;; BEG and END refer to the beginning and end of a region.
;; FRONT and BACK refer to the respective delimiters of a region.
;; FRONT- and BACK-OFFSET are the offsets from delimiter matches.
;; FRONT-BEG through BACK-END are the endings of the delimiters.
;; START and STOP bound actions, like searching, fontification, etc.
;}}}
;{{{ CL and Parameters
;; Keyword parameters can be nice because it makes it easier to see
;; what's getting passed as what. But I try not to use them in user
;; functions, because CL doesn't make good documentation strings.
;; Similarly, any hook or callback function can't take keywords,
;; since Emacs as a whole doesn't use them. And for small parameter
;; lists, they are overkill. So I use them only for a large number of
;; optional parameters, such as `mmm-make-region'.
;; An exception is the various submode class application functions,
;; which all take all their arguments as keywords, for consistency
;; and so the classes alist looks nice.
;; When using keyword arguments, defaults should *always* be supplied
;; in all arglists. (This pertains mostly to :start and :stop
;; arguments, usually defaulting to (point-min) and (point-max)
;; respectively.) `mmm-save-keywords' should only be used for lists
;; with more than four arguments, such as in `mmm-ify-by-regexp'.
;; In general, while I have no qualms about using things from CL like
;; `cl-mapl', `cl-loop' and `cl-destructuring-bind', I try not to use `cl-defun'
;; more than I have to. For one, it sometimes makes bad documentation
;; strings. Furthermore, to a `defun'ned function, a nil argument is
;; the same as no argument, so it will use its (manual) default, but
;; to a `cl-defun'ned function, a nil argument *is* the argument, so
;; any default specified in the arglist will be ignored. Confusion of
;; this type should be avoided when at all possible.
;;}}}
;;; Code:
(require 'cl-lib)
;; If we don't load font-lock now, but it is loaded later, the
;; necessary mmm-font-lock-* properties may not be there.
(require 'font-lock)
(require 'mmm-compat)
(require 'mmm-utils)
(require 'mmm-vars)
(require 'mmm-auto)
(require 'mmm-region)
(require 'mmm-class)
;; This file is set up to autoload by `mmm-auto.el'.
;; (require 'mmm-cmds)
(require 'mmm-univ)
;;{{{ Toggle Function
(defun mmm-mode (&optional arg)
"Minor mode to allow multiple major modes in one buffer.
Without ARG, toggle MMM Mode. With ARG, turn MMM Mode on iff ARG is
positive and off otherwise.
Commands Available:
\\<mmm-mode-map>
\\{mmm-mode-map}
BASIC CONCEPTS
The idea of MMM Mode is to allow multiple major modes to coexist in
the same buffer. There is one \"primary\" major mode that controls
most of the buffer, and a number of \"submodes\" that each hold sway
over certain regions. The submode regions are usually highlighted by
a background color for ease of recognition. While the point is in a
submode region, the following changes \(are supposed to) occur:
1. The local keymap and the syntax table are that of the submode.
2. The mode line changes to show what submode region is active.
3. The major mode menu and mouse popup menu are that of the submode.
4. Some local variables of the submode shadow the default mode's.
5. Font-lock fontifies correctly for the submode.
6. Indentation function dispatches to the appropriate submode.
7. User-specified hooks run when the point enters or exits a submode.
The user may specify a number of hooks which may run when the point
transitions between submodes, or between the primary mode and a
submode. When a major mode is entered, the hook mmm-x-enter-hook is
run, where x is the name of the major mode. When a major mode is
left, the hook mmm-y-exit-hook is run, where y is the name of the
major mode. Users may also specify hooks with names of the form
mmm-x-y-hook which are run when the point leaves a mode named x,
and enters a mode named y.
For further information, including installation and configuration
instructions, see the Info file mmm.info which is included with the
distribution of MMM Mode. Many of MMM's configuration variables are
available through M-x customize-group RET mmm."
(interactive "P")
(if (if arg (> (prefix-numeric-value arg) 0) (not mmm-mode))
(mmm-mode-on)
(mmm-mode-off)))
(add-to-list 'minor-mode-alist (list 'mmm-mode mmm-mode-string))
;;}}}
;;{{{ Mode On
(defun mmm-mode-on ()
"Turn on MMM Mode. See `mmm-mode'."
(interactive)
;; This function is called from mode hooks, so we need to make sure
;; we're not in a temporary buffer. We don't need to worry about
;; recursively ending up in ourself, however, since by that time the
;; variable `mmm-mode' will already be set.
(mmm-valid-buffer
(unless mmm-mode
(setq mmm-primary-mode major-mode)
(when (fboundp 'c-make-styles-buffer-local)
(c-make-styles-buffer-local t))
(mmm-update-mode-info major-mode)
(setq mmm-region-saved-locals-for-dominant
;; FIXME: Neither is defined in recent Emacs.
(cl-list* (list 'font-lock-cache-state nil)
(list 'font-lock-cache-position (make-marker))
(copy-tree (cdr (assq major-mode mmm-region-saved-locals-defaults)))))
;; Without the next line, the (make-marker) above gets replaced
;; with the starting value of nil, and all comes to naught.
(mmm-set-local-variables major-mode nil)
(mmm-add-hooks)
(mmm-fixup-skeleton)
(set (make-local-variable 'font-lock-fontify-region-function)
#'mmm-fontify-region)
(when (boundp 'syntax-begin-function)
(set (make-local-variable 'syntax-begin-function) nil))
(set (make-local-variable 'syntax-propertize-function)
#'mmm-syntax-propertize-function)
(set (make-local-variable 'indent-line-function) mmm-indent-line-function)
(setq mmm-mode t)
(condition-case err
(mmm-apply-all)
(mmm-error
;; Complain, but don't die, since we want files to go ahead
;; and be opened anyway, and the mode to go ahead and be
;; turned on. Should we delete all previously made submode
;; regions when we find an invalid one?
(message "%s" (error-message-string err))))
(run-hooks 'mmm-mode-hook)
(mmm-run-major-hook))))
;;}}}
;;{{{ Mode Off
(defun mmm-mode-off ()
"Turn off MMM Mode. See `mmm-mode'."
(interactive)
(when mmm-mode
(mmm-remove-hooks)
(mmm-clear-overlays)
(mmm-clear-history)
(mmm-clear-mode-ext-classes)
(mmm-clear-local-variables)
(mmm-update-submode-region)
(setq font-lock-fontify-region-function
(get mmm-primary-mode 'mmm-fontify-region-function))
(mmm-update-font-lock-buffer)
(mmm-refontify-maybe)
(setq mmm-mode nil)
;; Restore the mode line
(setq mmm-primary-mode-display-name nil
mmm-buffer-mode-display-name nil)
(mmm-set-mode-line)))
;;}}}
;;{{{ Mode Keymap
(defvar mmm-mode-map (make-sparse-keymap)
"Keymap for MMM Minor Mode.")
(defvar mmm-mode-prefix-map (make-sparse-keymap)
"Keymap for MMM Minor Mode after `mmm-mode-prefix-key'.")
(defvar mmm-mode-menu-map (make-sparse-keymap "MMM")
"Keymap for MMM Minor Mode menu.")
(defun mmm-define-key (key binding &optional keymap)
(define-key (or keymap mmm-mode-prefix-map)
(vector (append mmm-command-modifiers (list key)))
binding))
(when mmm-use-old-command-keys
(mmm-use-old-command-keys))
(mmm-define-key ?c 'mmm-ify-by-class)
(mmm-define-key ?x 'mmm-ify-by-regexp)
(mmm-define-key ?r 'mmm-ify-region)
(mmm-define-key ?b 'mmm-parse-buffer)
(mmm-define-key ?g 'mmm-parse-region)
(mmm-define-key ?% 'mmm-parse-block)
(mmm-define-key ?5 'mmm-parse-block)
(mmm-define-key ?k 'mmm-clear-current-region)
(mmm-define-key ?\ 'mmm-reparse-current-region)
(mmm-define-key ?e 'mmm-end-current-region)
(mmm-define-key ?z 'mmm-narrow-to-submode-region)
;; This one is exact, since C-h is (usually) already used for help.
(define-key mmm-mode-prefix-map [?h] 'mmm-insertion-help)
;; Default bindings to do insertion (dynamic)
(mmm-set-keymap-default mmm-mode-prefix-map 'mmm-insert-region)
;; Set up the prefix help command, since otherwise the default binding
;; overrides it.
(define-key mmm-mode-prefix-map (vector help-char) prefix-help-command)
;; And put it all onto the prefix key
(define-key mmm-mode-map mmm-mode-prefix-key mmm-mode-prefix-map)
;; Order matters for the menu bar.
(define-key mmm-mode-menu-map [off]
'("MMM Mode Off" . mmm-mode-off))
(define-key mmm-mode-menu-map [sep0] '(menu-item "----"))
(define-key mmm-mode-menu-map [clhist]
'("Clear History" . mmm-clear-history))
(define-key mmm-mode-menu-map [end]
'("End Current" . mmm-end-current-region))
(define-key mmm-mode-menu-map [clear]
'("Clear Current" . mmm-clear-current-region))
(define-key mmm-mode-menu-map [reparse]
'("Reparse Current" . mmm-reparse-current-region))
(define-key mmm-mode-menu-map [sep10] '(menu-item "----"))
(define-key mmm-mode-menu-map [ins-help]
'("List Insertion Keys" . mmm-insertion-help))
(define-key mmm-mode-menu-map [sep20] '(menu-item "----"))
(define-key mmm-mode-menu-map [region]
'(menu-item "MMM-ify Region" mmm-ify-region :enable mark-active))
(define-key mmm-mode-menu-map [regexp]
'("MMM-ify by Regexp" . mmm-ify-by-regexp))
(define-key mmm-mode-menu-map [class]
'("Apply Submode Class" . mmm-ify-by-class))
(define-key mmm-mode-menu-map [sep30] '(menu-item "----"))
(define-key mmm-mode-menu-map [parse-region]
'(menu-item "Parse Region" mmm-parse-region :enable mark-active))
(define-key mmm-mode-menu-map [parse-buffer]
'("Parse Buffer" . mmm-parse-buffer))
(define-key mmm-mode-menu-map [parse-block]
'("Parse Block" . mmm-parse-block))
(define-key mmm-mode-map [menu-bar mmm] (cons "MMM" mmm-mode-menu-map))
(add-to-list 'minor-mode-map-alist (cons 'mmm-mode mmm-mode-map))
;;}}}
(provide 'mmm-mode)
;;; mmm-mode.el ends here

View File

@@ -0,0 +1,40 @@
Summary: Emacs - Edit different parts of a file in different major modes
Name: mmm-mode
Version: 0.4.7
Release: 1
URL: http://unc.dl.sourceforge.net/sourceforge/mmm-mode
Source0: ${URL}/%{name}-%{version}.tar.gz
License: GPL; Michael Abraham Shulman <viritrilbia@gmail.com>
Group: Applications/Editors
BuildRoot: %{_tmppath}/%{name}-%(id -u -n)
BuildArch: noarch
Requires: emacs
%description
MMM Mode is an add-on package for emacs that enables the user to edit
different parts of a file in different major modes. It is well suited
for editing embedded code and code-generating code.
%prep
%setup -q
%configure
%build
%__make
%install
rm -rf $RPM_BUILD_ROOT
%makeinstall
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root)
%doc AUTHORS ChangeLog FAQ INSTALL NEWS README README.Mason TODO
%{_infodir}/mmm.info*
%{_datadir}/emacs/site-lisp/*.el*
%changelog
* Sat Mar 22 2003 <bishop@flotsam.platypus.bc.ca>
- Initial build.

View File

@@ -0,0 +1,187 @@
;;; mmm-myghty.el --- MMM submode class for Myghty components
;; Copyright (C) 2000, 2004, 2013, 2018 Free Software Foundation, Inc.
;; Author: Ben Bangert
;; Original Author: Michael Abraham Shulman <viritrilbia@users.sourceforge.net>
;; Based on mmm-mason.el, trivial changes by Ben Bangert
;;{{{ GPL
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;}}}
;;; Commentary:
;; I went to the hard (sarcasm) effort of applying two global
;; search/replaces, and adding a few keywords for additional
;; blocks that Myghty introduced. Many thanks to Michael for writing
;; the mmm-mason without which I would never have found the time
;; to patch up for Myghty.
;;; Code:
(require 'mmm-compat)
(require 'mmm-vars)
(require 'mmm-auto)
;;{{{ Python Tags
(defvar mmm-myghty-python-tags
'("python" "init" "cleanup" "once" "filter" "shared" "global"
"threadlocal" "requestlocal"
"python_init" "python_cleanup" "python_once" "python_filter"))
(defvar mmm-myghty-pseudo-python-tags
'("args" "python_args" "attr" "flags"))
(defvar mmm-myghty-non-python-tags
'("doc" "python_doc" "text" "python_text" "def" "python_def" "method"))
(defvar mmm-myghty-python-tags-regexp
(concat "<%" (mmm-regexp-opt mmm-myghty-python-tags t) ">")
"Matches tags beginning Myghty sections containing Python code.
Saves the name of the tag matched.")
(defvar mmm-myghty-pseudo-python-tags-regexp
(concat "<%" (mmm-regexp-opt mmm-myghty-pseudo-python-tags t) ">")
"Match tags beginning Myghty sections that look like Python but aren't.
Saves the name of the tag matched.")
(defvar mmm-myghty-tag-names-regexp
(regexp-opt (append mmm-myghty-python-tags mmm-myghty-non-python-tags) t)
"Matches any Myghty tag name after the \"<%\". Used to verify that a
\"<%\" sequence starts an inline section.")
(defun mmm-myghty-verify-inline ()
(not (looking-at mmm-myghty-tag-names-regexp)))
;;}}}
;;{{{ Add Classes
(mmm-add-group
'myghty
`((myghty-text
:submode nil
:front "<%text>"
:back "</%text>"
:insert ((?t myghty-<%text> nil @ "<%text>" @ "\n"
_ "\n" @ "</%text>" @)))
(myghty-doc
:submode text-mode
:face mmm-comment-submode-face
:front "<%doc>"
:back "</%doc>"
:face nil
:insert ((?d myghty-<%doc> nil @ "<%doc>" @ "\n"
_ "\n" @ "</%doc>" @)))
(myghty-python
:submode python
:match-face (("<%python>" . mmm-code-submode-face)
("<%init>" . mmm-init-submode-face)
("<%cleanup>" . mmm-cleanup-submode-face)
("<%once>" . mmm-init-submode-face)
("<%global>" . mmm-init-submode-face)
("<%filter>" . mmm-special-submode-face)
("<%shared>" . mmm-init-submode-face)
("<%threadlocal>" . mmm-init-submode-face)
("<%requestlocal>" . mmm-init-submode-face))
:front ,mmm-myghty-python-tags-regexp
:back "</%~1>"
:save-matches 1
:match-name "~1"
:save-name 1
:insert ((?, myghty-<%TAG> "Python section: " @ "<%" str ">" @
";\n" _ "\n" @ "</%" str ">" @)
(?< myghty-<%TAG> ?, . nil)
(?p myghty-<%python> ?, . "python")
(?i myghty-<%init> ?, . "init")
(?c myghty-<%cleanup> ?, . "cleanup")
(?o myghty-<%once> ?, . "once")
(?g myghty-<%global> ?, . "global")
(?t myghty-<%threadlocal> ?, . "threadlocal")
(?e myghty-<%requestlocal> ?, . "requestlocal")
(?l myghty-<%filter> ?, . "filter")
(?s myghty-<%shared> ?, . "shared")))
(myghty-pseudo-python
:submode python
:face mmm-declaration-submode-face
:front ,mmm-myghty-pseudo-python-tags-regexp
:back "</%~1>"
:save-matches 1
:insert ((?. myghty-pseudo-<%TAG> "Pseudo-python section: " @ "<%" str ">" @
"\n" _ "\n" @ "</%" str ">" @)
(?> myghty-pseudo-<%TAG> ?, . nil)
(?a myghty-<%args> ?. . "args")
(?f myghty-<%flags> ?. . "flags")
(?r myghty-<%attr> ?. . "attr")))
(myghty-inline
:submode python
:face mmm-output-submode-face
:front "<%"
:front-verify mmm-myghty-verify-inline
:back "%>"
:insert ((?% myghty-<%-%> nil @ "<%" @ " " _ " " @ "%>" @)
(?5 myghty-<%-%> ?% . nil)))
(myghty-call
:submode python
:face mmm-special-submode-face
:front "<&"
:back "&>"
:insert ((?& myghty-<&-&> nil @ "<&" @ " " _ " " @ "&>" @)
(?7 myghty-<&-&> ?% . nil)))
(myghty-one-line-comment
:submode text-mode
:face mmm-comment-submode-face
:front "^%#"
:back "\n"
:insert ((?# myghty-%-comment nil (mmm-myghty-start-line)
@ "%" @ "# " _ @ '(mmm-myghty-end-line) "\n" @)
(?3 myghty-%-comment ?# . nil)))
(myghty-one-line
:submode python
:face mmm-code-submode-face
:front "^%"
:back "\n"
:insert ((return myghty-%-line nil (mmm-myghty-start-line)
@ "%" @ " " _ @ '(mmm-myghty-end-line) "\n" @)))))
;;}}}
;;{{{ One-line Sections
(defun mmm-myghty-start-line ()
(if (bolp)
""
"\n"))
(defun mmm-myghty-end-line ()
(if (eolp)
(delete-char 1)))
;;}}}
;;{{{ Set Mode Line
(defun mmm-myghty-set-mode-line ()
(setq mmm-buffer-mode-display-name "Myghty"))
(add-hook 'mmm-myghty-class-hook #'mmm-myghty-set-mode-line)
;;}}}
(provide 'mmm-myghty)
;;; mmm-myghty.el ends here

View File

@@ -0,0 +1,421 @@
;;; mmm-noweb.el --- MMM submode class for Noweb programs
;;
;; Copyright 2003, 2004 Joe Kelsey <joe@zircon.seattle.wa.us>
;; Copyright 2018 Free Software Foundation, Inc.
;;
;; The filling, completion and chunk motion commands either taken
;; directly from or inspired by code in:
;; noweb-mode.el - edit noweb files with GNU Emacs
;; Copyright 1995 by Thorsten.Ohl @ Physik.TH-Darmstadt.de
;; with a little help from Norman Ramsey <norman@bellcore.com>
;;
;;{{{ GPL
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;}}}
;;; Commentary:
;; This file contains the definition of an MMM Mode submode class for
;; editing Noweb programs.
;;
;; FIXME: The more advanced features don't work: `mmm-name-at' and
;; `mmm-syntax-region' are undefined. Need to dig around in the bug reports
;; and/or discussions, wherever the code using them was submitted.
;;; Code:
(require 'cl-lib)
(require 'mmm-region)
(require 'mmm-vars)
(require 'mmm-mode)
;;{{{ Variables
(defvar mmm-noweb-code-mode 'fundamental-mode
"*Major mode for editing code chunks.
This is set to FUNDAMENTAL-MODE by default, but you might want to change
this in the Local Variables section of your file to something more
appropriate, like C-MODE, FORTRAN-MODE, or even INDENTED-TEXT-MODE."
;; FIXME: Any of CC Mode modes aren't really appropriate:
;; https://github.com/purcell/mmm-mode/issues/57
)
(defvar mmm-noweb-quote-mode nil
"*Major mode for quoted code chunks within documentation chunks.
If nil, defaults to `mmm-noweb-code-mode', which see.")
(defvar mmm-noweb-quote-string "quote"
"*String used to form quoted code submode region names.
See `mmm-noweb-quote'.")
(defvar mmm-noweb-quote-number 0
"*Starting value appended to `mmm-noweb-quote-string'.
See `mmm-noweb-quote'.")
(defvar mmm-noweb-narrowing nil
"*Narrow the region to the current pair of chunks.")
;;}}}
;;{{{ Support for mmm submode stuff
(defun mmm-noweb-chunk (_form)
"Return the noweb code mode chosen by the user.
If the next 100 characters of the buffer contain a string of the form
\"-*- MODE -*-\", then return MODE as the chosen mode, otherwise
return the value of `mmm-noweb-code-mode'."
;; Look for -*- mode -*- in the first two lines.
;; 120 chars = 40 chars for #! + 80 chars for following line...
(if (re-search-forward "-\\*-\\s +\\(\\S-+\\)\\s +-\\*-" (+ (point) 120) t)
(let* ((string (match-string-no-properties 1))
(modestr (intern (if (string-match "mode\\'" string)
string
(concat string "-mode")))))
(or (mmm-ensure-modename modestr)
mmm-noweb-code-mode))
mmm-noweb-code-mode))
(defun mmm-noweb-quote (_form)
"Create a unique name for a quoted code region within a documentation chunk."
(or mmm-noweb-quote-mode
mmm-noweb-code-mode))
(defun mmm-noweb-quote-name (_form)
"Create a unique name for a quoted code region within a documentation chunk."
(setq mmm-noweb-quote-number (1+ mmm-noweb-quote-number))
(concat mmm-noweb-quote-string "-"
(number-to-string mmm-noweb-quote-number)))
(defun mmm-noweb-chunk-name (form)
"Get the chunk name from FRONT-FORM."
(string-match "<<\\(.*\\)>>=" form)
(match-string-no-properties 1 form))
;;}}}
;;{{{ mmm noweb submode group
;; We assume that the global document mode is latex or whatever, the
;; user wants. This class controls the code chunk submodes. We use
;; match-submode to either return the value in mmm-noweb-code-mode or to
;; look at the first line of the chunk for a submode setting. We reset
;; case-fold-search because chunk names are case sensitive. The front
;; string identifies the chunk name between the <<>>. Since this is
;; done, name-match can use the same functions as save-matches for back.
;; Our insert skeleton places a new code chunk and the skel-name lets us
;; optimize the skelton naming to use the inserted string.
(mmm-add-group
'noweb
'((noweb-chunk
:match-submode mmm-noweb-chunk
:case-fold-search nil
:front "^<<\\(.*\\)>>="
:match-name "~1"
:save-name 1
:front-offset (end-of-line 1)
:back "^@\\( \\|$\\|\\( %def .*$\\)\\)"
:insert ((?c noweb-code "Code Chunk Name: "
"\n" @ "<<" str ">>=" @ "\n" _ "\n" @ "@ " @ "\n"))
:skel-name t
)
(noweb-quote
:match-submode mmm-noweb-quote
:face mmm-special-submode-face
:front "\\[\\["
; :name-match mmm-noweb-quote-name
:back "\\]\\]"
:insert ((?q noweb-quote nil @ "[[" @ _ @ "]]" @))
)
))
;;}}}
;;{{{ Noweb regions
(defun mmm-noweb-regions (start stop regexp)
"Return a liat of regions of the form (NAME BEG END) that exclude
names which match REGEXP."
(let* ((remove-next nil)
(regions
(cl-maplist (lambda (pos-list)
(if (cdr pos-list)
(if remove-next
(setq remove-next nil)
(let ((name (or (mmm-name-at (car pos-list) 'beg)
(symbol-name mmm-primary-mode))))
(if (and regexp (string-match regexp name) )
(progn
(setq remove-next t)
nil)
(list name
(car pos-list) (cadr pos-list)))))))
(mmm-submode-changes-in start stop))))
;; The above loop leaves lots of nils in the list...
;; Removing them saves us from having to do the (last x 2)
;; trick that mmm-regions-in does.
(setq regions (delq nil regions))))
;;}}}
;;{{{ Filling, etc
(defun mmm-noweb-narrow-to-doc-chunk ()
"Narrow to the current doc chunk.
The current chunk includes all quoted code chunks (i.e., \[\[...\]\]).
This function is only valid when called with point in a doc chunk or
quoted code chunk."
(interactive)
(let ((name (mmm-name-at (point))))
(if (or (null name) (string-match "^quote" name))
(let ((prev (cond
((= (point) (point-min)) (point))
(t (cadar (last (mmm-noweb-regions (point-min) (point)
"^quote"))))))
(next (cond
((= (point) (point-max)) (point))
(t (save-excursion
(goto-char (cadr
(cadr (mmm-noweb-regions (point)
(point-max)
"^quote"))))
(forward-line -1)
(point))))))
(narrow-to-region prev next)))))
(defun mmm-noweb-fill-chunk (&optional justify)
"Fill the current chunk according to mode.
Run `fill-region' on documentation chunks and `indent-region' on code
chunks."
(interactive "P")
(save-restriction
(let ((name (mmm-name-at (point))))
(if (and name (not (string-match "^quote" name)))
(if (or indent-region-function indent-line-function)
(progn
(mmm-space-other-regions)
(indent-region (overlay-start mmm-current-overlay)
(overlay-end mmm-current-overlay) nil))
(error "No indentation functions defined in %s!" major-mode))
(progn
(mmm-word-other-regions)
(fill-paragraph justify)))
(mmm-undo-syntax-other-regions))))
(defun mmm-noweb-fill-paragraph-chunk (&optional justify)
"Fill a paragraph in the current chunk."
(interactive "P")
(save-restriction
(let ((name (mmm-name-at (point))))
(if (and name (not (string-match "^quote" name)))
(progn
(mmm-space-other-regions)
(fill-paragraph justify))
(progn
(mmm-word-other-regions)
(fill-paragraph justify)))
(mmm-undo-syntax-other-regions))))
(defun mmm-noweb-fill-named-chunk (&optional _justify)
"Fill the region containing the named chunk."
(interactive "P")
(save-restriction
(let* ((name (or (mmm-name-at) (symbol-name mmm-primary-mode)))
(list (cdr (assoc name (mmm-names-alist (point-min) (point-max))))))
(if (or (string= name (symbol-name mmm-primary-mode))
(string-match "^quote" name))
(progn
(mmm-word-other-regions)
(do-auto-fill))
(progn
(mmm-space-other-regions)
(indent-region (caar list) (cadar (last list)) nil)))
(mmm-undo-syntax-other-regions))))
(defun mmm-noweb-auto-fill-doc-chunk ()
"Replacement for `do-auto-fill'."
(save-restriction
(mmm-noweb-narrow-to-doc-chunk)
(mmm-word-other-regions)
(do-auto-fill)
(mmm-undo-syntax-other-regions)))
(defun mmm-noweb-auto-fill-doc-mode ()
"Install the improved auto fill function, iff necessary."
(if auto-fill-function
;; FIXME: Use add-function?
(setq auto-fill-function #'mmm-noweb-auto-fill-doc-chunk)))
(defun mmm-noweb-auto-fill-code-mode ()
"Install the default auto fill function, iff necessary."
(if auto-fill-function
;; FIXME: Use remove-function?
(setq auto-fill-function #'do-auto-fill)))
;;}}}
;;{{{ Functions on named chunks
(defun mmm-noweb-complete-chunk ()
"Try to complete the chunk name."
(interactive)
(let ((end (point))
(beg (save-excursion
(if (re-search-backward "<<"
(save-excursion
(beginning-of-line)
(point))
t)
(match-end 0)
nil))))
(if beg
(let* ((pattern (buffer-substring beg end))
(alist (mmm-names-alist (point-min) (point-max)))
(completion (try-completion pattern alist)))
(cond ((eq completion t))
((null completion)
(message "Can't find completion for \"%s\"" pattern)
(ding))
((not (string= pattern completion))
(delete-region beg end)
(insert completion)
(if (not (looking-at ">>"))
(insert ">>")))
(t
(message "Making completion list...")
(with-output-to-temp-buffer "*Completions*"
(display-completion-list
(all-completions pattern alist)))
(message "Making completion list...%s" "done"))))
(message "Not at chunk name..."))))
(defvar mmm-noweb-chunk-history nil
"History for `mmm-noweb-goto-chunk'.")
(defun mmm-noweb-goto-chunk ()
"Goto the named chunk."
(interactive)
(widen)
(let* ((completion-ignore-case t)
(alist (mmm-names-alist (point-min) (point-max)))
(chunk (completing-read
"Chunk: " alist nil t
(mmm-name-at (point))
mmm-noweb-chunk-history)))
(goto-char (caadr (assoc chunk alist)))))
(defun mmm-noweb-goto-next (&optional cnt)
"Goto the continuation of the current chunk."
(interactive "p")
(widen)
(let ((name (mmm-name-at (point))))
(if name
(let ((list (cdr (assoc name (mmm-names-alist
(overlay-end mmm-current-overlay)
(point-max))))))
(if list
(goto-char (caar (nthcdr (1- cnt) list))))))))
(defun mmm-noweb-goto-previous (&optional cnt)
"Goto the continuation of the current chunk."
(interactive "p")
(widen)
(let ((name (mmm-name-at (point))))
(if name
(let ((list (reverse
(cdr (assoc name
(mmm-names-alist (point-min)
(overlay-start
mmm-current-overlay)))))))
(if list
(goto-char (cadar (nthcdr cnt list))))))))
;;}}}
;;{{{ Key mappings
(defvar mmm-noweb-map (make-sparse-keymap))
(defvar mmm-noweb-prefix-map (make-sparse-keymap))
(define-key mmm-noweb-map mmm-mode-prefix-key mmm-noweb-prefix-map)
(mmm-define-key ?d 'mmm-noweb-narrow-to-doc-chunk mmm-noweb-prefix-map)
(mmm-define-key ?n 'mmm-noweb-goto-next mmm-noweb-prefix-map)
(mmm-define-key ?p 'mmm-noweb-goto-previous mmm-noweb-prefix-map)
(mmm-define-key ?q 'mmm-noweb-fill-chunk mmm-noweb-prefix-map)
;; Cannot use C-g as goto command, so use C-s.
(mmm-define-key ?s 'mmm-noweb-goto-chunk mmm-noweb-prefix-map)
(define-key mmm-noweb-prefix-map "\t" 'mmm-noweb-complete-chunk)
;; Don't want to add to either the mmm mode map (used in other mmm
;; buffers) or the local map (used in other major mode buffers), so we
;; make a full-buffer spanning overlay and add the map there.
(defun mmm-noweb-bind-keys ()
(save-restriction
(widen)
(let ((ovl (make-overlay (point-min) (point-max) nil nil t)))
;; 'keymap', not 'local-map'
(overlay-put ovl 'keymap mmm-noweb-map))))
(add-hook 'mmm-noweb-class-hook #'mmm-noweb-bind-keys)
;; TODO: make this overlay go away if mmm is turned off
;;}}}
;; These functions below living here temporarily until a real place is
;; found.
(defun mmm-syntax-region-list (syntax regions)
"Apply SYNTAX to a list of REGIONS of the form (BEG END).
If SYNTAX is not nil, set the syntax-table property of each region.
If SYNTAX is nil, remove the region syntax-table property.
See `mmm-syntax-region'."
(mapcar (lambda (reg)
(mmm-syntax-region (car reg) (cadr reg) syntax))
regions))
(defun mmm-syntax-other-regions (syntax &optional name)
"Apply SYNTAX cell to other regions.
Regions are separated by name, using either `mmm-name-at' or the
optional NAME to determine the current region name."
(if (null name)
(setq name (or (mmm-name-at)
(symbol-name mmm-primary-mode))))
(mapcar (lambda (reg)
(if (not (string= (car reg) name))
(mmm-syntax-region-list syntax (cdr reg))))
(mmm-names-alist (point-min) (point-max))))
(defun mmm-word-other-regions ()
"Give all other regions word syntax."
(interactive)
(mmm-syntax-other-regions '(2 . 0))
(setq parse-sexp-lookup-properties t))
(defun mmm-space-other-regions ()
"Give all other regions space syntax."
(interactive)
(mmm-syntax-other-regions '(0 . 0))
(setq parse-sexp-lookup-properties t))
(defun mmm-undo-syntax-other-regions ()
"Remove syntax-table property from other regions."
(interactive)
(mmm-syntax-other-regions nil)
(setq parse-sexp-lookup-properties nil))
(provide 'mmm-noweb)
;;; mmm-noweb.el ends here

View File

@@ -0,0 +1,923 @@
;;; mmm-region.el --- Manipulating and behavior of MMM submode regions
;; Copyright (C) 2000-2003, 2010-2015, 2018 Free Software Foundation, Inc.
;; Author: Michael Abraham Shulman <viritrilbia@gmail.com>
;;{{{ GPL
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;}}}
;;; Commentary:
;; This file provides the functions and variables to create, delete,
;; and inspect submode regions, as well as functions that make them
;; behave like the submode with respect to syntax tables, local maps,
;; font lock, etc.
;; See mmm-class.el for functions which scan the buffer and decide
;; where to create regions.
;;; Code:
(require 'cl-lib)
(require 'font-lock)
(require 'mmm-compat)
(require 'mmm-utils)
(require 'mmm-auto)
(require 'mmm-vars)
;; INSPECTION
;;{{{ Current Overlays
;; Emacs counts an overlay starting at POS as "at" POS, but not an
;; overlay ending at POS. XEmacs is more sensible and uses beg- and
;; end-stickiness to determine whether an endpoint is within an
;; extent. Here we want to act like XEmacs does.
(defsubst mmm-overlay-at (&optional pos type)
"Return the highest-priority MMM Mode overlay at POS.
See `mmm-included-p' for the values of TYPE."
(car (mmm-overlays-at pos type)))
(defun mmm-overlays-at (&optional pos type)
"Return a list of the MMM overlays at POS, in decreasing priority.
See `mmm-included-p' for the values of TYPE."
(or pos (setq pos (point)))
(mmm-sort-overlays
(cl-remove-if-not
(lambda (ovl)
(and (overlay-get ovl 'mmm)
(mmm-included-p ovl pos type)))
;; XEmacs complains about positions outside the buffer
(overlays-in (max (1- pos) (point-min))
(min (1+ pos) (point-max))))))
(defun mmm-included-p (ovl pos &optional type)
"Return true if the overlay OVL contains POS.
If OVL strictly contains POS, always return true. If OVL starts or
ends at POS, return true or false based on the value of TYPE, which
should be one of nil, `beg', `end', `none', or `all'.
* If TYPE is nil, return true for an overlay starting at POS only if
it is beg-sticky, and for one ending at POS only if it is end-sticky.
* If TYPE is `beg', return true for any overlay starting at POS but
false for any ending at POS.
* If TYPE is `end', return true for any overlay ending at POS but
false for any starting at POS.
* If TYPE is `all', return true for any overlay starting or ending at POS.
* If TYPE is `none' (or any other value), return false for any
overlay starting or ending at POS."
(let ((beg (overlay-start ovl))
(end (overlay-end ovl)))
(cond ((and (= beg pos) (= end pos))
;; Do the Right Thing for zero-width overlays
(cl-case type
((nil) (and (overlay-get ovl 'beg-sticky)
(overlay-get ovl 'end-sticky)))
((none) nil)
(t t)))
((= beg pos)
(cl-case type
((nil) (overlay-get ovl 'beg-sticky))
((beg all) t)
(t nil)))
((= end pos)
(cl-case type
((nil) (overlay-get ovl 'end-sticky))
((end all) t)
(t nil)))
((and (> end pos) (< beg pos))
t))))
;; `mmm-overlays-in' has been retired as altogether too confusing a
;; name, when what is really meant is one of the following three:
(defun mmm-overlays-containing (start stop)
"Return all MMM overlays containing the region START to STOP.
The overlays are returned in order of decreasing priority. No
attention is paid to stickiness."
(mmm-sort-overlays
(cl-remove-if-not
(lambda (ovl)
(and (overlay-get ovl 'mmm)
(<= (overlay-start ovl) start)
(>= (overlay-end ovl) stop)))
(overlays-in (max start (point-min))
(min stop (point-max))))))
(defun mmm-overlays-contained-in (start stop)
"Return all MMM overlays entirely contained in START to STOP.
The overlays are returned in order of decreasing priority. No
attention is paid to stickiness."
(mmm-sort-overlays
(cl-remove-if-not
(lambda (ovl)
(and (overlay-get ovl 'mmm)
(>= (overlay-start ovl) start)
(<= (overlay-end ovl) stop)))
(overlays-in (max start (point-min))
(min stop (point-max))))))
(defun mmm-overlays-overlapping (start stop)
"Return all MMM overlays overlapping the region START to STOP.
The overlays are returned in order of decreasing priority. No
attention is paid to stickiness."
(mmm-sort-overlays
(cl-remove-if-not
(lambda (ovl)
(overlay-get ovl 'mmm))
(overlays-in (max start (point-min))
(min stop (point-max))))))
(defun mmm-sort-overlays (overlays)
"Sort OVERLAYS in order of decreasing priority."
(sort (cl-copy-list overlays)
(lambda (x y) (> (or (overlay-get x 'priority) 0)
(or (overlay-get y 'priority) 0)))))
;;}}}
;;{{{ Current Submode
(defvar mmm-current-overlay nil
"What submode region overlay we think we are currently in.
May be out of date; call `mmm-update-current-submode' to correct it.")
(make-variable-buffer-local 'mmm-current-overlay)
(defvar mmm-previous-overlay nil
"What submode region overlay we were in just before this one.
Set by `mmm-update-current-submode'.")
(make-variable-buffer-local 'mmm-previous-overlay)
(defvar mmm-current-submode nil
"What submode we think we are currently in.
May be out of date; call `mmm-update-current-submode' to correct it.")
(make-variable-buffer-local 'mmm-current-submode)
(defvar mmm-previous-submode nil
"What submode we were in just before this one.
Set by `mmm-update-current-submode'.")
(make-variable-buffer-local 'mmm-previous-submode)
(defun mmm-update-current-submode (&optional pos)
"Update current and previous position variables to POS, or point.
Return non-nil if the current region changed.
Also deletes overlays that ought to evaporate because their delimiters
have disappeared."
(mapc #'delete-overlay
(cl-remove-if (lambda (ovl)
(or (not (eq (overlay-get ovl 'mmm-evap) 'front))
(overlay-buffer (overlay-get ovl 'front))))
(mmm-overlays-at pos)))
(let ((ovl (mmm-overlay-at pos)))
(if (eq ovl mmm-current-overlay)
nil
(mmm-set-current-pair (if ovl (overlay-get ovl 'mmm-mode)) ovl)
t)))
(defun mmm-set-current-pair (mode ovl)
"Set the current submode to MODE, the current overlay to OVL
and update the saved previous values."
(setq mmm-previous-overlay mmm-current-overlay
mmm-previous-submode mmm-current-submode)
(setq mmm-current-submode mode
mmm-current-overlay ovl))
(defun mmm-submode-at (&optional pos type)
"Return the submode at POS \(or point), or NIL if none.
See `mmm-included-p' for values of TYPE."
(let ((ovl (mmm-overlay-at pos type)))
(if ovl (overlay-get ovl 'mmm-mode))))
;;}}}
;;{{{ Delimiter Matching and Boundaries
(defun mmm-match-front (ovl)
"Return non-nil if the front delimiter of OVL matches as it should.
Sets the match data to the front delimiter, if it is a regexp.
Otherwise, calls it as a function with point at the beginning of the
front delimiter overlay \(i.e. where the front delimiter ought to
start) and one argument being the region overlay. The function should
return non-nil if the front delimiter matches correctly, and set the
match data appropriately."
(let* ((front-ovl (overlay-get ovl 'front))
(front (if front-ovl (overlay-get front-ovl 'match))))
(when front
(save-excursion
(goto-char (overlay-start front-ovl))
(if (stringp front)
;; It's a regexp
(looking-at front)
;; It's a function
(funcall front ovl))))))
(defun mmm-match-back (ovl)
"Return non-nil if the back delimiter of OVL matches as it should.
Sets the match data to the back delimiter, if it is a regexp.
Otherwise, calls it as a function with point at the beginning of the
back delimiter overlay \(i.e. where the back delimiter ought to start)
and one argument being the region overlay. The function should return
non-nil if the back delimiter matches correctly, and set the match
data appropriately."
(let* ((back-ovl (overlay-get ovl 'back))
(back (if back-ovl (overlay-get back-ovl 'match))))
(when back
(save-excursion
(goto-char (overlay-start back-ovl))
(if (stringp back)
;; It's a regexp
(looking-at back)
;; It's a function
(funcall back ovl))))))
(defun mmm-front-start (ovl)
"Return the position at which the front delimiter of OVL starts."
(let ((front (overlay-get ovl 'front)))
;; Overlays which have evaporated become "overlays in no buffer"
(if (and front (overlay-buffer front))
(overlay-start front)
(overlay-start ovl))))
(defun mmm-back-end (ovl)
"Return the position at which the back delimiter of OVL ends."
(let ((back (overlay-get ovl 'back)))
;; Overlays which have evaporated become "overlays in no buffer"
(if (and back (overlay-buffer back))
(overlay-end back)
(overlay-end ovl))))
;;}}}
;; CREATION & DELETION
;;{{{ Make Submode Regions
(defun mmm-valid-submode-region (submode beg end)
"Check if the region between BEG and END is valid for SUBMODE.
This region must be entirely contained within zero or more existing
submode regions, none of which start or end inside it, and it must be
a valid child of the highest-priority of those regions, if any.
Signals errors, returns `t' if no error."
;; First check if the placement is valid. Every existing region
;; that overlaps this one must contain it in its entirety.
(let ((violators (cl-set-difference
(mmm-overlays-overlapping beg end)
(mmm-overlays-containing beg end))))
(if violators
(signal 'mmm-subregion-invalid-placement
violators)))
;; Now check if it is inside a valid parent
(let ((parent-mode (mmm-submode-at beg 'beg)))
(and parent-mode
;; TODO: Actually check parents here. For present purposes,
;; we just make sure we aren't putting a submode inside one
;; of the same type. Actually, what we should really be
;; doing is checking classes/names of regions, not just the
;; submodes.
(eq submode parent-mode)
(signal 'mmm-subregion-invalid-parent
(list parent-mode))))
t)
(cl-defun mmm-make-region
(submode beg end &key face
front back (evaporation 'front)
delimiter-mode front-face back-face
display-name
(match-front "") (match-back "")
(beg-sticky t) (end-sticky t)
name creation-hook
)
"Make a submode region from BEG to END of SUBMODE.
BEG and END are buffer positions or markers with BEG <= END \(although
see EVAPORATION below). SUBMODE is a major mode function or a valid
argument to `mmm-modename->function'. FACE is a valid display face.
FRONT and BACK specify the positions of the front and back delimiters
for this region, if any. If FRONT is a buffer position or marker, the
front delimiter runs from it to BEG. FRONT can also be a two-element
list \(FRONT-BEG FRONT-END) specifying the exact position of the front
delimiter. One must have FRONT-BEG < FRONT-END <= BEG.
Similarly, BACK may be a buffer position or marker, in which case the
back delimiter runs from END to BACK. BACK can also be a two-element
list \(BACK-BEG BACK-END) specifying the exact position, in which case
we must have END <= BACK-BEG < BACK-END.
EVAPORATION specifies under what conditions this submode region should
disappear.
* If `nil', the region never disappears. This can cause serious
problems when using cut-and-paste and is not recommended.
* If the value is t, the region disappears whenever it has zero
length. This is recommended for manually created regions used for
temporary editing convenience.
* If the value is `front', the region will disappear whenever the text
in its front delimiter disappears, that is, whenever the overlay
which marks its front delimiter has zero width.
The default value is `front'. However, if the parameter FRONT is nil,
then this makes no sense, so the default becomes `t'. Note that if
EVAPORATION is `t', then an error is signalled if BEG = END.
MATCH-FRONT \(resp. MATCH-BACK) is a regexp or function to match the
correct delimiters, see `mmm-match-front' \(resp. `mmm-match-back').
It is ignored if FRONT \(resp. BACK) is nil. At present these are not
used much.
DELIMITER-MODE specifies the major mode to use for delimiter regions.
A `nil' value means they remain in the primary mode.
FACE, FRONT-FACE, and BACK-FACE, are faces to use for the region, the
front delimiter, and the back delimiter, respectively, under high
decoration \(see `mmm-submode-decoration-level').
BEG-STICKY and END-STICKY determine whether the front and back of the
region, respectively, are sticky with respect to new insertion. The
default is yes.
NAME is a string giving the \"name\" of this submode region. Submode
regions with the same name are considered part of the same code
fragment and formatted accordingly.
DISPLAY-NAME is a string to display in the mode line when point is in
this submode region. If nil or not given, the name associated with
SUBMODE is used. In delimiter regions, \"--\" is shown.
CREATION-HOOK should be a function to run after the region is created,
with point at the start of the new region."
;; Check placement of region and delimiters
(unless (if (eq evaporation t)
(< beg end)
(<= beg end))
(signal 'mmm-subregion-invalid-placement (list beg end)))
(when front
(unless (listp front)
(setq front (list front beg)))
(unless (and (< (car front) (cadr front))
(<= (cadr front) beg))
(signal 'mmm-subregion-invalid-placement front)))
(when back
(unless (listp back)
(setq back (list end back)))
(unless (and (< (car back) (cadr back))
(<= end (car back)))
(signal 'mmm-subregion-invalid-placement back)))
(setq submode (mmm-modename->function submode))
;; Check embedding in existing regions
(mmm-valid-submode-region submode beg end)
(mmm-mode-on)
(when submode
(mmm-update-mode-info submode))
(and (not front) (eq evaporation 'front) (setq evaporation t))
(let ((region-ovl
(mmm-make-overlay submode beg end name face beg-sticky end-sticky
(or (eq evaporation t) nil) display-name)))
;; Save evaporation type for checking later
(overlay-put region-ovl 'mmm-evap evaporation)
;; Calculate priority to supersede anything already there.
;; XXX: Actually, don't, in order not to hide the region highlighting.
;; Let's try omitting the priorities and see if any problems crop up.
;; (overlay-put region-ovl 'priority (length (mmm-overlays-at beg)))
;; Make overlays for the delimiters, with appropriate pointers.
(when front
(let ((front-ovl
(mmm-make-overlay delimiter-mode (car front) (cadr front)
nil front-face nil nil t "--" t)))
(overlay-put region-ovl 'front front-ovl)
(overlay-put front-ovl 'region region-ovl)
(overlay-put front-ovl 'match match-front)))
(when back
(let ((back-ovl
(mmm-make-overlay delimiter-mode (car back) (cadr back)
nil back-face nil nil t "--" t)))
(overlay-put region-ovl 'back back-ovl)
(overlay-put back-ovl 'region region-ovl)
(overlay-put back-ovl 'match match-back)))
;; Update everything and run all the hooks
(mmm-save-all
;; Can be nil when a zero-width region is immediately evaporated
(when (overlay-start region-ovl)
(goto-char (overlay-start region-ovl)))
(mmm-set-current-pair submode region-ovl)
(mmm-set-local-variables submode region-ovl)
(mmm-run-submode-hook submode)
(when creation-hook
(funcall creation-hook)))
(mmm-update-submode-region)
region-ovl))
(defun mmm-make-overlay (submode beg end name face beg-sticky end-sticky evap
&optional display-name delim)
"Internal function to make submode overlays.
Does not handle delimiters. Use `mmm-make-region'."
(let ((ovl (make-overlay beg end nil (not beg-sticky) end-sticky)))
(mapc
(lambda (pair) (overlay-put ovl (car pair) (cadr pair)))
`((mmm t) ; Mark all submode overlays
(mmm-mode ,submode)
,@(if delim '((delim t)) nil)
(mmm-local-variables
;; Have to be careful to make new list structure here
,(cl-list* (list 'font-lock-cache-state nil)
(list 'font-lock-cache-position (make-marker))
(copy-tree
(cdr (assq submode mmm-region-saved-locals-defaults)))))
(name ,name)
(display-name ,display-name)
;; Need to save these, because there's no way of accessing an
;; overlay's official "front-advance" parameter once it's created.
(beg-sticky ,beg-sticky)
(end-sticky ,end-sticky)
;; These have special meaning to Emacs
(,mmm-evaporate-property ,evap)
(face ,(mmm-get-face face submode delim))
))
ovl))
(defun mmm-get-face (face submode &optional delim)
(cond ((= mmm-submode-decoration-level 0) nil)
((and (= mmm-submode-decoration-level 2) face) face)
(delim 'mmm-delimiter-face)
(submode 'mmm-default-submode-face)))
;;}}}
;;{{{ Clear Overlays
;; See also `mmm-clear-current-region'.
(defun mmm-clear-overlays (&optional start stop strict)
"Clears all MMM overlays overlapping START and STOP.
If STRICT, only clear those entirely included in that region."
(mapc #'delete-overlay
(if strict
(mmm-overlays-contained-in (or start (point-min))
(or stop (point-max)))
(mmm-overlays-overlapping (or start (point-min))
(or stop (point-max)))))
(mmm-update-submode-region))
;;}}}
;; BASIC UPDATING
;;{{{ Submode Info
(defun mmm-update-mode-info (mode &optional force)
"Save the global-saved and buffer-saved variables for MODE.
Global saving is done on properties of the symbol MODE and buffer
saving in `mmm-buffer-saved-locals'. This function must be called for
both the dominant mode and all submodes, in each file. Region-saved
variables are initialized from `mmm-region-saved-locals-defaults',
which is set here as well. See `mmm-save-local-variables'. If FORCE
is non-nil, don't quit if the info is already there."
(let ((buffer-entry (assq mode mmm-buffer-saved-locals))
(region-entry (assq mode mmm-region-saved-locals-defaults))
global-vars buffer-vars region-vars
;; http://debbugs.gnu.org/13836
buffer-file-truename)
(unless (and (not force)
(get mode 'mmm-local-variables)
buffer-entry
region-entry)
(let ((temp-buffer (mmm-make-temp-buffer (current-buffer)
mmm-temp-buffer-name))
(filename (buffer-file-name))
(mmm-in-temp-buffer t)
;; Don't try to use jit-lock, it's automatically disabled
;; starting with 24.4 anyway.
font-lock-support-mode)
(unwind-protect
(with-current-buffer temp-buffer
;; Handle stupid modes that need the file name set.
(when (memq mode mmm-set-file-name-for-modes)
(setq buffer-file-name filename))
(funcall mode)
(when (featurep 'font-lock)
(put mode 'mmm-font-lock-mode font-lock-mode)
;; These can't be in the local variables list, because we
;; replace their actual values, but we want to use their
;; original values elsewhere.
(put mode 'mmm-fontify-region-function
font-lock-fontify-region-function)
(put mode 'mmm-syntax-propertize-function
(and (boundp 'syntax-propertize-function)
syntax-propertize-function))
(put mode 'mmm-indent-line-function indent-line-function))
;; Get variables
(setq global-vars (mmm-get-locals 'global)
buffer-vars (mmm-get-locals 'buffer)
region-vars (mmm-get-locals 'region))
(put mode 'mmm-mode-name mode-name))
(kill-buffer temp-buffer)))
(put mode 'mmm-local-variables global-vars)
(if buffer-entry
(setcdr buffer-entry buffer-vars)
(push (cons mode buffer-vars) mmm-buffer-saved-locals))
(if region-entry
(setcdr region-entry region-vars)
(push (cons mode region-vars)
mmm-region-saved-locals-defaults)))))
;;}}}
;;{{{ Updating Hooks
(defun mmm-update-submode-region ()
"Update all MMM properties correctly for the current position.
This function and those it calls do the actual work of setting the
different keymaps, syntax tables, local variables, etc. for submodes."
(when (mmm-update-current-submode)
(mmm-save-changed-local-variables mmm-previous-submode
mmm-previous-overlay)
(let ((new-mode (or mmm-current-submode mmm-primary-mode))
(old-mode (or mmm-previous-submode mmm-primary-mode)))
(mmm-run-constructed-hook old-mode new-mode)
(mmm-run-constructed-hook old-mode "exit")
(mmm-run-constructed-hook new-mode "enter")
(mmm-update-mode-info new-mode)
(mmm-set-local-variables new-mode mmm-current-overlay)
(mmm-enable-font-lock new-mode))
(mmm-set-mode-line)
(dolist (func (if mmm-current-overlay
(overlay-get mmm-current-overlay 'entry-hook)
mmm-primary-mode-entry-hook))
(ignore-errors (funcall func)))))
(defun mmm-add-hooks ()
(if (featurep 'xemacs)
(make-local-hook 'post-command-hook))
(add-hook 'post-command-hook #'mmm-update-submode-region nil t)
(when mmm-parse-when-idle
(add-hook 'pre-command-hook #'mmm-mode-reset-timer nil t)
(add-hook 'after-change-functions #'mmm-mode-edit nil t)))
(defun mmm-remove-hooks ()
(remove-hook 'post-command-hook #'mmm-update-submode-region t)
(remove-hook 'pre-command-hook #'mmm-mode-reset-timer t)
(remove-hook 'after-change-functions #'mmm-mode-edit t))
;;}}}
;;{{{ Local Variables
(defun mmm-get-local-variables-list (type mode)
"Filter `mmm-save-local-variables' to match TYPE and MODE.
Return a list \(VAR ...). In some cases, VAR will be a cons cell
\(GETTER . SETTER) -- see `mmm-save-local-variables'."
(mmm-mapcan (lambda (element)
(and (if (and (consp element)
(cdr element)
(cadr element))
(eq (cadr element) type)
(eq type 'global))
(if (and (consp element)
(cddr element)
(not (eq (nth 2 element) t)))
(if (functionp (nth 2 element))
(funcall (nth 2 element))
(member mode (nth 2 element)))
t)
(list (if (consp element) (car element) element))))
mmm-save-local-variables))
(defun mmm-get-locals (type)
"Get the local variables and values for TYPE from this buffer.
Return \((VAR VALUE) ...). In some cases, VAR will be of the form
\(GETTER . SETTER) -- see `mmm-save-local-variables'."
(mmm-mapcan (lambda (var)
(if (consp var)
`((,var ,(funcall (car var))))
(and (boundp var)
;; This seems logical, but screws things up.
;;(local-variable-p var)
`((,var ,(symbol-value var))))))
(mmm-get-local-variables-list type major-mode)))
;; FIXME: Has no callers. Used for debugging?
(defun mmm-get-saved-local (mode ovl var)
"Get the value of the local variable VAR saved for MODE and OVL, if any."
(cadr (assq var (mmm-get-saved-local-variables ovl mode))))
;; FIXME: It's too easy to accidentally pass nil as MODE here.
;; We probably should call this from `mmm-set-current-pair', and not
;; rely on its callers to default to the primary mode when appropriate.
;; Also, incorporate the opmimization from `mmm-fontify-region-list'.
(defun mmm-set-local-variables (mode ovl)
"Set all the local variables saved for MODE and OVL.
Looks up global, buffer and region saves. When MODE is nil, just
the region ones."
(mapcar (lambda (var)
;; (car VAR) may be (GETTER . SETTER)
(if (consp (car var))
(funcall (cdar var) (cadr var))
(make-local-variable (car var))
(set (car var) (cadr var))))
(mmm-get-saved-local-variables mode ovl)))
;; Used for debugging.
(defun mmm-diff-local-variables (mode ovl)
(let (res)
(mapc (lambda (var)
(let ((current-value (if (consp (car var))
(funcall (caar var))
(symbol-value (car var)))))
(unless (equal current-value (cadr var))
(push
(message "var: %s, current: %s, saved: %s" (car var)
current-value (cadr var))
res))))
(mmm-get-saved-local-variables mode ovl))
res))
(defun mmm-get-saved-local-variables (mode ovl)
(append (get mode 'mmm-local-variables)
(cdr (assq mode mmm-buffer-saved-locals))
(if ovl
(overlay-get ovl 'mmm-local-variables)
mmm-region-saved-locals-for-dominant)))
(defun mmm-save-changed-local-variables (mode ovl)
"Save by-buffer and by-region variables for MODE and OVL.
Called when we move to a new submode region, with MODE and OVL the
region and mode for the previous position."
(let ((buffer-vars (cdr (assq (or mode mmm-primary-mode)
mmm-buffer-saved-locals)))
(region-vars (if ovl
(overlay-get ovl 'mmm-local-variables)
mmm-region-saved-locals-for-dominant))
(set-local-value
(lambda (var)
(setcar (cdr var)
;; (car VAR) may be (GETTER . SETTER)
(if (consp (car var))
(funcall (caar var))
(symbol-value (car var)))))))
(mapc set-local-value buffer-vars)
(mapc set-local-value region-vars)))
(defun mmm-clear-local-variables ()
"Clear all buffer- and region-saved variables for current buffer."
(setq mmm-buffer-saved-locals ()
mmm-region-saved-locals-defaults ()
mmm-region-saved-locals-for-dominant ()))
;;}}}
;; FONT LOCK
;;{{{ Enable Font Lock
(defun mmm-enable-font-lock (mode)
"Turn on font lock if it is not already on and MODE enables it."
(mmm-update-mode-info mode)
(and (not font-lock-mode)
(get mode 'mmm-font-lock-mode)
(font-lock-mode 1)))
(defun mmm-update-font-lock-buffer ()
"Turn on font lock if any mode in the buffer enables it."
(if (cl-some (lambda (mode)
(get mode 'mmm-font-lock-mode))
(cons mmm-primary-mode
(mapcar (lambda (ovl)
(overlay-get ovl 'mmm-mode))
(mmm-overlays-overlapping
(point-min) (point-max)))))
(font-lock-mode 1)
(font-lock-mode 0)))
;; FIXME: Most uses of this function happen when the buffer is parsed
;; into regions manually. That should go away after
;; syntax-propertize-function does this.
(defun mmm-refontify-maybe (&optional start stop)
"Re-fontify from START to STOP, or entire buffer, if enabled."
(when font-lock-mode
(if (fboundp 'font-lock-flush)
(progn
(font-lock-flush start stop)
;; FIXME: Do we really need to do this eagerly here?
(font-lock-ensure start stop))
(if (or start stop)
(font-lock-fontify-region (or start (point-min))
(or stop (point-max)))
(with-no-warnings (font-lock-fontify-buffer))))))
;;}}}
;;{{{ Get Submode Regions
;; In theory, these are general functions that have nothing to do
;; with font-lock, but they aren't used anywhere else, so we might as
;; well have them close.
(defun mmm-submode-changes-in (start stop)
"Return a list of all submode-change positions from START to STOP.
The list is sorted in order of increasing buffer position."
(let ((changes (sort (cl-remove-duplicates
(mmm-mapcan (lambda (ovl)
`(,(overlay-start ovl)
,(overlay-end ovl)))
(mmm-overlays-overlapping start stop)))
#'<)))
(when (or (not changes) (< start (car changes)))
(push start changes))
(let ((last (last changes)))
(when (> stop (car last))
(setcdr last (list stop))))
changes))
(defun mmm-regions-in (start stop)
"Return a list of regions of the form (MODE BEG END OVL) whose disjoint
union covers the region from START to STOP, including delimiters."
(when (> stop start)
(let ((regions
(cl-maplist (lambda (pos-list)
(when (cdr pos-list)
(let ((ovl (mmm-overlay-at (car pos-list) 'beg)))
(list (if ovl
(overlay-get ovl 'mmm-mode)
mmm-primary-mode)
(car pos-list) (cadr pos-list)
ovl))))
(mmm-submode-changes-in start stop))))
(setcdr (last regions 2) nil)
regions)))
(defun mmm-regions-alist (start stop)
"Return a list of lists of the form \(MODE . REGIONS) where REGIONS
is a list of elements of the form \(BEG END OVL). The disjoint union all
of the REGIONS covers START to STOP."
(let ((regions (mmm-regions-in start stop))
alist)
(mapc (lambda (region)
(let* ((mode (car region))
(elem (cdr region))
(kv (assoc mode alist)))
(if kv
(push elem (cdr kv))
(push (cons mode (list elem)) alist))))
regions)
(mapcar (lambda (kv)
(cons (car kv) (nreverse (cdr kv))))
alist)))
;;}}}
;;{{{ Fontify Regions
(defun mmm-fontify-region (start stop &optional loudly)
"Fontify from START to STOP keeping track of submodes correctly."
(let ((saved-mode mmm-current-submode)
(saved-ovl mmm-current-overlay))
(unwind-protect
(progn
(when loudly
(message "Fontifying %s with submode regions..." (buffer-name)))
;; Necessary to catch changes in font-lock cache state and position.
(mmm-save-changed-local-variables
mmm-current-submode mmm-current-overlay)
(mapc (lambda (elt)
(when (get (car elt) 'mmm-font-lock-mode)
(mmm-fontify-region-list (car elt) (cdr elt))))
(mmm-regions-alist start stop)))
;; `post-command-hook' contains `mmm-update-submode-region',
;; but jit-lock runs later, so we need to restore local vars now.
(mmm-set-current-pair saved-mode saved-ovl)
(mmm-set-local-variables (or saved-mode mmm-primary-mode) saved-ovl)))
(when loudly (message nil)))
(defvar syntax-ppss-cache)
(defvar syntax-ppss-last)
(defun mmm-fontify-region-list (mode regions)
"Fontify REGIONS, each like (BEG END), in mode MODE."
(save-excursion
(let ((func (get mode 'mmm-fontify-region-function))
font-lock-extend-region-functions)
(mapc (lambda (reg)
(cl-destructuring-bind (beg end ovl) reg
(goto-char beg)
;; Here we do the same sort of thing that
;; `mmm-update-submode-region' does, but we force it
;; to use a specific mode, and don't save anything,
;; fontify, or change the mode line.
(mmm-set-current-pair mode ovl)
(mmm-set-local-variables (unless (eq mmm-previous-submode mode)
mode)
mmm-current-overlay)
(save-restriction
(let ((font-lock-dont-widen t)
;; FIXME: Messing with syntax-ppss-* vars should not
;; be needed any more in Emacs≥26.
syntax-ppss-last syntax-ppss-cache)
;; TODO: Remove this conditional when cc-mode
;; respects submode boundaries.
(when (and ovl (not (memq mode mmm-c-derived-modes)))
(narrow-to-region beg end))
(funcall func beg end nil)))
;; Catch changes in font-lock cache.
(mmm-save-changed-local-variables
mmm-current-submode mmm-current-overlay)))
regions))))
;;}}}
;;{{{ Syntax
(defvar mmm-after-syntax-propertize-functions nil
"List of functions to call after applying `syntax-table' text
properties to a submode region. It is passed four arguments: the
region overlay, the submode and the bounds of the region.")
(defun mmm-syntax-propertize-function (start stop)
"Composite function that applies `syntax-table' text properties.
It iterates over all submode regions between START and STOP and
calls each respective submode's `syntax-propertize-function'."
(let ((saved-mode mmm-current-submode)
(saved-ovl mmm-current-overlay))
(mmm-save-changed-local-variables
mmm-current-submode mmm-current-overlay)
(unwind-protect
(mapc (lambda (elt)
(let* ((mode (car elt))
(func (get mode 'mmm-syntax-propertize-function))
(beg (cadr elt)) (end (nth 2 elt))
(ovl (nth 3 elt))
;; FIXME: Messing with syntax-ppss-* vars should not
;; be needed any more in Emacs≥26.
syntax-ppss-cache
syntax-ppss-last)
(goto-char beg)
(mmm-set-current-pair mode ovl)
(mmm-set-local-variables mode mmm-current-overlay)
(save-restriction
(when mmm-current-overlay
(narrow-to-region (overlay-start mmm-current-overlay)
(overlay-end mmm-current-overlay)))
(cond
(func
(funcall func beg end))
(font-lock-syntactic-keywords
(let ((syntax-propertize-function nil))
(font-lock-fontify-syntactic-keywords-region beg end))))
(run-hook-with-args 'mmm-after-syntax-propertize-functions
mmm-current-overlay mode beg end))))
(mmm-regions-in start stop))
(mmm-set-current-pair saved-mode saved-ovl)
(mmm-set-local-variables (or saved-mode mmm-primary-mode) saved-ovl))))
;;}}}
;;{{{ Indentation
(defvar mmm-indent-line-function #'mmm-indent-line
"The function to call to indent a line.
This will be the value of `indent-line-function' for the whole
buffer. It's supposed to delegate to the appropriate submode's
indentation function. See `mmm-indent-line' as the starting point.")
(defun mmm-indent-line-narrowed ()
"An indent function which works on some modes where `mmm-indent-line' doesn't.
Works like `mmm-indent-line', but narrows the buffer before indenting to
appease modes which rely on constructs like (point-min) to indent."
(interactive)
(save-excursion
(back-to-indentation)
(mmm-update-submode-region)
(let ((indent-function (get
(if (and mmm-current-overlay
(> (overlay-end mmm-current-overlay) (point)))
mmm-current-submode
mmm-primary-mode)
'mmm-indent-line-function)))
(if mmm-current-overlay
(save-restriction
(narrow-to-region (overlay-start mmm-current-overlay)
(overlay-end mmm-current-overlay))
(funcall indent-function))
(funcall indent-function)))))
(defun mmm-indent-line ()
(interactive)
(funcall
(save-excursion
(back-to-indentation)
(mmm-update-submode-region)
(get
(if (and mmm-current-overlay
(> (overlay-end mmm-current-overlay) (point)))
mmm-current-submode
mmm-primary-mode)
'mmm-indent-line-function))))
;;}}}
(provide 'mmm-region)
;;; mmm-region.el ends here

View File

@@ -0,0 +1,80 @@
;;; mmm-rpm.el --- MMM submode class for RPM spec files
;; Copyright (C) 2000 by Marcus Harnisch <Marcus.Harnisch@gmx.net>
;; Author: Marcus Harnisch <Marcus.Harnisch@gmx.net>
;;{{{ GPL
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;}}}
;;; Commentary:
;; This file contains the definition of an MMM Mode submode class for
;; editing shell script sections within RPM (Redhat Package Manager)
;; spec files. I recommend to use it in combination with
;; rpm-spec-mode.el by Stig Bj<42>rlykke <stigb@tihlde.hist.no> and Steve
;; Sanbeg <sanbeg@dset.com> (http://www.xemacs.org/~stigb/rpm-spec-mode.el)
;;; Installation:
;; 1. Copy this file where Emacs can find it.
;;
;; 2. Add the following lines to one of your startup files (e.g. ~/.emacs):
;;
;; (add-to-list 'mmm-mode-ext-classes-alist
;; '(rpm-spec-mode "\\.spec\\'" rpm-sh))
;;; Code:
(require 'mmm-auto)
(defconst mmm-rpm-sh-start-tags
'("prep" "build" "install" "clean" "preun" "postun" "pre"
"post" "triggerin" "triggerun" "triggerpostun")
"List containing RPM tags that start a shell-script section in a spec file")
(defvar mmm-rpm-sh-end-tags
(append '("files" "description" "package") mmm-rpm-sh-start-tags)
"List containing RPM tags that end a shell-script section in a spec file")
(defvar mmm-rpm-sh-start-regexp
(concat "^%" (mmm-regexp-opt mmm-rpm-sh-start-tags t) "\\b.*$")
"Regexp matching RPM tags that start a shell-script section in a spec file")
(defvar mmm-rpm-sh-end-regexp
(concat "\\'\\|^%" (mmm-regexp-opt mmm-rpm-sh-end-tags t) "\\b.*$")
"Regexp matching RPM tags that end a shell-script section in a spec file")
(mmm-add-group
'rpm
`((rpm-sh
:submode sh-mode
:face mmm-code-submode-face
;; match tags that starts sh-script region
:front ,mmm-rpm-sh-start-regexp
;; match end of buffer or next tag that ends sh-script region
:back ,mmm-rpm-sh-end-regexp
:front-offset 1
:back-offset 0
:save-matches 0
)))
(provide 'mmm-rpm)
;;; mmm-rpm.el ends here

View File

@@ -0,0 +1,384 @@
;;; mmm-sample.el --- Sample MMM submode classes
;; Copyright (C) 2000-2004, 2012-2015, 2018 Free Software Foundation, Inc.
;; Author: Michael Abraham Shulman <viritrilbia@gmail.com>
;;{{{ GPL
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;}}}
;;; Commentary:
;; This file contains several sample submode classes for use with MMM
;; Mode. For a more detailed, advanced example, see `mmm-mason.el'.
;; In order to use any of classes defined here, just require `mmm-auto' and
;; add the respective (major mode -> class <- file extension) associations
;; with `mmm-add-mode-ext-class'.
;;; Code:
(require 'cl-lib)
(require 'mmm-auto)
(require 'mmm-vars)
;;{{{ <Perl> in httpd.conf
;; This is the simplest example. Many applications will need no more
;; than a simple regexp.
;;
;; Usage: (mmm-add-mode-ext-class 'apache-generic-mode nil 'httpd-conf-perl)
(mmm-add-classes
'((httpd-conf-perl
:submode perl
:delimiter-mode nil
:front "<Perl>"
:back "</Perl>")))
;;}}}
;;{{{ JavaScript in HTML
;; We use two classes here, both for code in a <script> tag, one wrapped in
;; CDATA, another not. And another class to group them together.
;;
;; Usage: (mmm-add-mode-ext-class 'html-mode nil 'html-js)
(mmm-add-group
'html-js
'((js-script-cdata
:submode js-mode
:face mmm-code-submode-face
:front "<script[^>]*>[ \t\n]*\\(//\\)?<!\\[CDATA\\[[ \t]*\n?"
:back "[ \t]*\\(//\\)?]]>[ \t\n]*</script>")
(js-script
:submode js-mode
:face mmm-code-submode-face
:front "<script[^>]*>[ \t]*\n?"
:back "[ \t]*</script>"
:insert ((?j js-tag nil @ "<script type=\"text/javascript\">\n"
@ "" _ "" @ "\n</script>" @)))))
;;}}}
;;{{{ CSS in HTML
(mmm-add-group
'html-css
'((css-cdata
:submode css
:face mmm-code-submode-face
:front "<style[^>]*>[ \t\n]*\\(//\\)?<!\\[CDATA\\[[ \t]*\n?"
:back "[ \t]*\\(//\\)?]]>[ \t\n]*</style>")
(css
:submode css
:face mmm-code-submode-face
:front "<style[^>]*>[ \t]*\n?"
:back "[ \t]*</style>"
:insert ((?c css-tag nil @ "<style type=\"text/css\">\n"
@ "" _ "" @ "\n</style>" @)))))
;;}}}
;;{{{ Here-documents
;; Here we match the here-document syntax used by Perl and shell
;; scripts. We try to be automagic about recognizing what mode the
;; here-document should be in. To make sure that it is recognized
;; correctly, the name of the mode, perhaps minus `-mode', in upper
;; case, and/or with hyphens converted to underscores, should be
;; separated from the rest of the here-document name by hyphens or
;; underscores.
(defvar mmm-here-doc-mode-alist '()
"Alist associating here-document name regexps to submodes.
Normally, this variable is unnecessary, as the `here-doc' submode
class tries to automagically recognize the right submode. If you use
here-document names that it doesn't recognize, however, then you can
add elements to this alist. Each element is \(REGEXP . MODE) where
REGEXP is a regular expression matched against the here-document name
and MODE is a major mode function symbol.")
(defun mmm-here-doc-get-mode (string)
(string-match "[a-zA-Z_-]+" string)
(setq string (match-string 0 string))
(or (mmm-ensure-modename
;; First try the user override variable.
(cl-some (lambda (pair)
(if (string-match (car pair) string) (cdr pair) nil))
mmm-here-doc-mode-alist))
(let ((words (split-string (downcase string) "[_-]+")))
(or (mmm-ensure-modename
;; Try the whole name, stopping at "mode" if present.
(intern
(mapconcat #'identity
(nconc (cl-ldiff words (member "mode" words))
(list "mode"))
"-")))
;; Try each word by itself (preference list)
(cl-some (lambda (word)
(mmm-ensure-modename (intern word)))
words)
;; Try each word with -mode tacked on
(cl-some (lambda (word)
(mmm-ensure-modename
(intern (concat word "-mode"))))
words)
;; Try each pair of words with -mode tacked on
(cl-loop for (one two) on words
if (mmm-ensure-modename
(intern (concat one two "-mode")))
return it)
;; I'm unaware of any modes whose names, minus `-mode',
;; are more than two words long, and if the entire mode
;; name (perhaps minus `-mode') doesn't occur in the
;; here-document name, we can give up.
(signal 'mmm-no-matching-submode nil)))))
(mmm-add-classes
'((here-doc
:front "<<[\"\'\`]?\\([a-zA-Z0-9_-]+\\)"
:front-offset (end-of-line 1)
:back "^~1$"
:save-matches 1
:delimiter-mode nil
:match-submode mmm-here-doc-get-mode
:insert ((?d here-doc "Here-document Name: " @ "<<" str _ "\n"
@ "\n" @ str "\n" @))
)))
;;}}}
;;{{{ Embperl
(mmm-add-group
'embperl
'((embperl-perl
:submode perl
:front "\\[\\([-\\+!\\*\\$]\\)"
:back "~1\\]"
:save-matches 1
:match-name "embperl"
:match-face (("[+" . mmm-output-submode-face)
("[-" . mmm-code-submode-face)
("[!" . mmm-init-submode-face)
("[*" . mmm-code-submode-face)
("[$" . mmm-special-submode-face))
:insert ((?p embperl "Region Type (Character): " @ "[" str
@ " " _ " " @ str "]" @)
(?+ embperl+ ?p . "+")
(?- embperl- ?p . "-")
(?! embperl! ?p . "!")
(?* embperl* ?p . "*")
(?$ embperl$ ?p . "$")
)
)
(embperl-comment
:submode text-mode
:face mmm-comment-submode-face
:front "\\[#"
:back "#\\]"
:insert ((?# embperl-comment nil @ "[#" @ " " _ " " @ "#]" @))
)))
;;}}}
;;{{{ ePerl
(mmm-add-group
'eperl
'((eperl-expr
:submode perl
:face mmm-output-submode-face
:front "<:="
:back ":>"
:insert ((?= eperl-expr nil @ "<:=" @ " " _ " " @ ":>" @)))
(eperl-code
:submode perl
:face mmm-code-submode-face
:front "<:"
:back "_?:>"
:match-name "eperl"
:insert ((?p eperl-code nil @ "<:" @ " " _ " " @ ":>" @)
(?: eperl-code ?p . nil)
(?_ eperl-code_ nil @ "<:" @ " " _ " " @ "_:>" @)))
(eperl-comment
:submode text
:face mmm-comment-submode-face
:front ":>//"
:back "\n")
))
;;}}}
;;{{{ File Variables
;; This submode class puts file local variable values, specified with
;; a `Local Variables:' line as in (emacs)File Variables, into Emacs
;; Lisp Mode. It is a good candidate to put in `mmm-global-classes'.
(defun mmm-file-variables-verify ()
;; It would be nice to cache this somehow, which could be done in a
;; buffer-local variable with markers for positions, but the trick
;; is knowing when to expire the cache.
(let ((bounds
(save-excursion
(save-match-data
(goto-char (point-max))
(backward-page)
(and (re-search-forward "^\\(.*\\)Local Variables:" nil t)
(list (match-string 1)
(progn (end-of-line) (point))
(and (search-forward
(format "%sEnd:" (match-string 1))
nil t)
(progn (beginning-of-line)
(point)))))))))
(and bounds (caddr bounds)
(save-match-data
(string-match (format "^%s" (regexp-quote (car bounds)))
(match-string 0)))
(> (match-beginning 0) (cadr bounds))
(< (match-end 0) (caddr bounds)))))
(defun mmm-file-variables-find-back (bound)
(forward-sexp)
(if (> (point) bound)
nil
(looking-at "")))
(mmm-add-classes
'((file-variables
:front ".+:"
:front-verify mmm-file-variables-verify
:back mmm-file-variables-find-back
:submode emacs-lisp-mode
:delimiter-mode nil
)))
;;}}}
;;{{{ JSP Pages
(mmm-add-group 'jsp
`((jsp-comment
:submode text-mode
:face mmm-comment-submode-face
:front "<%--"
:back "--%>"
:insert ((?- jsp-comment nil @ "<%--" @ " " _ " " @ "--%>" @))
)
(jsp-code
:submode java
:match-face (("<%!" . mmm-declaration-submode-face)
("<%=" . mmm-output-submode-face)
("<%" . mmm-code-submode-face))
:front "<%[!=]?"
:back "%>"
:match-name "jsp"
:insert ((?% jsp-code nil @ "<%" @ " " _ " " @ "%>" @)
(?! jsp-declaration nil @ "<%!" @ " " _ " " @ "%>" @)
(?= jsp-expression nil @ "<%=" @ " " _ " " @ "%>" @))
)
(jsp-directive
:submode text-mode
:face mmm-special-submode-face
:front "<%@"
:back "%>"
:insert ((?@ jsp-directive nil @ "<%@" @ " " _ " " @ "%>" @))
)))
;;}}}
;;{{{ SGML DTD
;; Thanks to Yann Dirson <ydirson@fr.alcove.com> for writing and
;; contributing this submode class.
(mmm-add-classes
'((sgml-dtd
:submode dtd-mode
:face mmm-declaration-submode-face
:delimiter-mode nil
:front "<! *doctype[^>[]*\\["
:back "]>")))
;;}}}
;;{{{ PHP in HTML
(mmm-add-group 'html-php
'((html-php-output
:submode php-mode
:face mmm-output-submode-face
:front "<\\?php *echo "
:back "\\(\\?>\\|\\'\\)"
:include-front t
:front-offset 5
:insert ((?e php-echo nil @ "<?php" @ " echo " _ " " @ "?>" @))
)
(html-php-code
:submode php-mode
:face mmm-code-submode-face
:front "<\\?\\(php\\)?"
:back "\\(\\?>\\|\\'\\)"
:insert ((?p php-section nil @ "<?php" @ " " _ " " @ "?>" @)
(?b php-block nil @ "<?php" @ "\n" _ "\n" @ "?>" @))
)))
;;}}}
;; NOT YET UPDATED
;;{{{ HTML in PL/SQL;-COM-
;-COM-
;-COM-;; This one is the most complex example. In PL/SQL, HTML is generally
;-COM-;; output as a (single quote delimited) string inside a call to htp.p or
;-COM-;; its brethren. The problem is that there may be strings outside of
;-COM-;; htp.p calls that should not be HTML, so we need to only look inside
;-COM-;; these calls. The situation is complicated by PL/SQL's rule that two
;-COM-;; sequential single quotes in a string mean to put a single quote
;-COM-;; inside the string.
;-COM-
;-COM-;; These functions have not been thoroughly tested, and always search
;-COM-;; the entire buffer, ignoring START and END.
;-COM-
;-COM-(defun mmm-html-in-plsql (start end)
;-COM- (save-match-data
;-COM- (let ((case-fold-search t))
;-COM- (and (re-search-forward "htp.p\\(\\|rn\\|rint\\)1?(" nil t)
;-COM- (mmm-html-in-plsql-in-htp
;-COM- ;; Find the end of the procedure call
;-COM- (save-excursion (forward-char -1) (forward-sexp) (point))
;-COM- start end)))))
;-COM-
;-COM-(defun mmm-html-in-plsql-in-htp (htp-end start end)
;-COM- (let (beg end)
;-COM- (or (and (re-search-forward "'" htp-end 'limit)
;-COM- (setf beg (match-end 0))
;-COM- ;; Find an odd number of 's to end the string.
;-COM- (do ((lgth 0 (length (match-string 0))))
;-COM- ((oddp lgth) t)
;-COM- (re-search-forward "'+" nil t))
;-COM- (setf end (1- (match-end 0)))
;-COM- (cons (cons beg end)
;-COM- (mmm-html-in-plsql-in-htp htp-end start end)))
;-COM- ;; No more strings in the procedure call; look for another.
;-COM- (and (eql (point) htp-end)
;-COM- (mmm-html-in-plsql start end)))))
;-COM-
;-COM-(add-to-list 'mmm-classes-alist
;-COM- '(htp-p (:function html-mode mmm-html-in-plsql)))
;-COM-
;;}}}
(provide 'mmm-sample)
;;; mmm-sample.el ends here

View File

@@ -0,0 +1,64 @@
;;; mmm-univ.el --- The "Universal" Submode Class
;; Copyright (C) 2000, 2001, 2013 Free Software Foundation, Inc.
;; Author: Michael Abraham Shulman <mas@kurukshetra.cjb.net>
;;{{{ GPL
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;}}}
;;; Commentary:
;; This file defines the "universal" submode class, the default value
;; of `mmm-global-classes', which specifies a standard way to indicate
;; that part of a buffer should be in a different mode--for example,
;; in an email message.
;;; Code:
(require 'mmm-auto)
(require 'mmm-vars)
(defun mmm-univ-get-mode (string)
(string-match "[a-zA-Z-]+" string)
(setq string (match-string 0 string))
(let ((modestr (intern (if (string-match "mode\\'" string)
string
(concat string "-mode")))))
(or (mmm-ensure-modename modestr)
(signal 'mmm-no-matching-submode nil))))
(mmm-add-classes
`((universal
:front "{%\\([a-zA-Z-]+\\)%}"
:back "{%/~1%}"
:insert ((?/ universal "Submode: " @ "{%" str "%}" @ "\n" _ "\n"
@ "{%/" str "%}" @))
:match-submode mmm-univ-get-mode
:save-matches 1
)))
(provide 'mmm-univ)
;;; Local Variables:
;;; mmm-global-classes: nil
;;; End:
;;; mmm-univ.el ends here

View File

@@ -0,0 +1,157 @@
;;; mmm-utils.el --- Coding Utilities for MMM Mode
;; Copyright (C) 2000-2003, 2011-2013 Free Software Foundation, Inc.
;; Author: Michael Abraham Shulman <viritrilbia@gmail.com>
;;{{{ GPL
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;}}}
;;; Commentary:
;; This file provides a number of macros and other coding utilities
;; for MMM Mode.
;;; Code:
;;{{{ Valid Buffer
;; We used to wrap almost everything in this, but I realized that
;; only `mmm-mode-on' really needs it. Kept it as a macro, though,
;; for modularity and in case we need it somewhere else.
(defmacro mmm-valid-buffer (&rest body)
"Execute BODY if in a valid buffer for MMM Mode to be enabled. This
means not hidden, not a minibuffer, not in batch mode, and not in of
`mmm-never-modes'."
`(unless (or (eq (aref (buffer-name) 0) ?\ )
(window-minibuffer-p (selected-window))
(memq major-mode mmm-never-modes)
noninteractive
mmm-in-temp-buffer)
,@body))
;;;(def-edebug-spec mmm-valid-buffer t)
;;}}}
;;{{{ Save Everything
;; Never trust callback functions to preserve anything.
(defmacro mmm-save-all (&rest body)
"Execute BODY forms, then restoring point, mark, current buffer,
restrictions, and match data."
`(save-excursion
(save-restriction
(save-match-data
,@body))))
;;;(def-edebug-spec mmm-save-all t)
;;}}}
;;{{{ String Formatting
(defun mmm-format-string (string arg-pairs)
"Format STRING by replacing arguments as specified by ARG-PAIRS.
Each element of ARG-PAIRS is \(REGEXP . STR) where each STR is to be
substituted for the corresponding REGEXP wherever it matches."
(let ((case-fold-search nil))
(save-match-data
(dolist (pair arg-pairs)
(while (string-match (car pair) string)
(setq string (replace-match
(if (fboundp 'format-mode-line)
(format-mode-line (cdr pair))
(cdr pair))
t t string))))))
string)
(defun mmm-format-matches (string &optional on-string)
"Format STRING by matches from the current match data.
Strings like ~N are replaced by the Nth subexpression from the last
global match. Does nothing if STRING is not a string.
ON-STRING, if supplied, means to use the match data from a
`string-match' on that string, rather than the global match data."
(when (stringp string)
(let ((old-data (match-data))
subexp)
(save-match-data
(while (string-match "~\\([0-9]\\)" string)
(setq subexp (string-to-number (match-string-no-properties 1 string))
string (replace-match
(save-match-data
(set-match-data old-data)
(match-string-no-properties subexp on-string))
t t string))))))
string)
;;}}}
;;{{{ Save Keywords
(defmacro mmm-save-keyword (param)
"If the value of PARAM as a variable is non-nil, return the list
\(:PARAM (symbol-value PARAM)), otherwise NIL. Best used only when it
is important that nil values disappear."
`(if (and (boundp ',param) ,param)
(list (intern (concat ":" (symbol-name ',param))) ,param)
nil))
(defmacro mmm-save-keywords (&rest params)
"Return a list saving the non-nil elements of PARAMS. E.g.
\(let \(\(a 1) \(c 2)) \(mmm-save-keywords a b c)) ==> \(:a 1 :c 2)
Use of this macro can make code more readable when there are a lot of
PARAMS, but less readable when there are only a few. Also best used
only when it is important that nil values disappear."
`(append ,@(mapcar (lambda (param)
(macroexpand `(mmm-save-keyword ,param)))
params)))
;;}}}
;;{{{ Looking Back At
(defun mmm-looking-back-at (regexp &optional bound)
"Return t if text before point matches REGEXP.
Modifies the match data. If supplied, BOUND means not to look farther
back that that many characters before point. Otherwise, it defaults to
\(length REGEXP), which is good enough when REGEXP is a simple
string."
(eq (point)
(save-excursion
(and (re-search-backward regexp
(- (point) (or bound (length regexp)))
t)
(match-end 0)))))
;;}}}
;;{{{ Markers
;; Mostly for remembering interactively made regions
(defun mmm-make-marker (pos beg-p sticky-p)
"Make, and return, a marker at POS that is or isn't sticky.
BEG-P represents whether the marker delimits the beginning of a
region \(or the end of it). STICKY-P is whether it should be sticky,
i.e. whether text inserted at the marker should be inside the region."
(let ((mkr (set-marker (make-marker) pos)))
(set-marker-insertion-type mkr (if beg-p (not sticky-p) sticky-p))
mkr))
;;}}}
(provide 'mmm-utils)
;;; mmm-utils.el ends here

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,112 @@
;; Copyright (C) 2013-2014 Free Software Foundation, Inc.
;; This file is part of GNU Emacs.
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;;; Code:
(require 'ert-x)
(defvar foo-mode-keywords
`((,(concat "\\b"
(regexp-opt '("foo" "bar") t)
"\\b")
. font-lock-keyword-face)))
(define-derived-mode foo1-mode fundamental-mode ""
(setq font-lock-defaults '(foo-mode-keywords t t)))
(ert-deftest mmm-font-lock-without-font-lock-syntax-table ()
(ert-with-test-buffer nil
(let (mmm-mode-ext-classes-alist
mmm-parse-when-idle)
(insert "foo // foo_bar")
(fundamental-mode)
(mmm-mode-on)
(mmm-ify-by-regexp 'foo1-mode "// " 0 "\\'" 0 nil)
(font-lock-fontify-region (point-min) (point-max))
(beginning-of-buffer)
(should-not (get-text-property (point) 'face))
(search-forward "fo" nil nil 2)
(should (eq (get-text-property (point) 'face) font-lock-keyword-face))
(search-forward "ba")
(should (eq (get-text-property (point) 'face) font-lock-keyword-face)))))
(define-derived-mode foo2-mode fundamental-mode ""
(setq font-lock-defaults '(foo-mode-keywords t t ((?_ . "w")))))
(ert-deftest mmm-font-lock-with-font-lock-syntax-table ()
(ert-with-test-buffer nil
(let (mmm-mode-ext-classes-alist
mmm-parse-when-idle)
(insert "foo // foo_bar")
(fundamental-mode)
(mmm-mode-on)
(mmm-ify-by-regexp 'foo2-mode "// " 0 "\\'" 0 nil)
(font-lock-fontify-region (point-min) (point-max))
(should-not (next-single-property-change (point-min) 'face)))))
(define-derived-mode foo3-mode fundamental-mode ""
(setq font-lock-defaults '(foo-mode-keywords nil t ((?_ . "w")))))
(ert-deftest mmm-syntax-propertize-function-preserves-current-syntax-table ()
(ert-with-test-buffer nil
(let (mmm-mode-ext-classes-alist
mmm-parse-when-idle)
(insert "foo_and_bar\n\nfoo")
(foo3-mode)
(mmm-mode-on)
(syntax-ppss-flush-cache (point-min))
;; It locally changes `syntax-table' to `font-lock-syntax-table'
;; and calls `syntax-ppss' inside that before fontifying.
(font-lock-fontify-region (point-min) (point-max))
(let ((pt (next-single-property-change (point-min) 'face)))
(should pt)
(goto-char pt)
(should (looking-at "foo\\'"))))))
(ert-deftest mmm-fontify-region-list-ignores-outside-for-syntactic-ff-tion ()
(ert-with-test-buffer nil
(let (mmm-mode-ext-classes-alist
mmm-parse-when-idle)
(insert "unpaired '!\n")
(insert "js>>\n")
(insert "var woo = js;\n")
(foo1-mode)
(mmm-mode-on)
(syntax-ppss-flush-cache (point-min))
(mmm-ify-by-regexp 'js-mode "js>>\n" 0 "\\'" 0 nil)
(font-lock-fontify-region (point-min) (point-max))
(search-backward "var")
(should (eq 'font-lock-keyword-face
(get-text-property (point) 'face))))))
(ert-deftest mmm-fontify-region-list-carries-string-after-subregion ()
(ert-with-test-buffer nil
(let (mmm-mode-ext-classes-alist
mmm-parse-when-idle)
(insert "<p class=\"foo <% 1 + 2 %> bar tee\"</p>")
(html-mode)
(mmm-mode-on)
(syntax-ppss-flush-cache (point-min))
(mmm-ify-by-regexp 'js-mode "<%" 0 "%>" 0 nil)
(font-lock-fontify-region (point-min) (point-max))
(search-backward "1")
(should (null (get-text-property (point) 'face)))
(search-forward "bar")
(should (eq 'font-lock-string-face
(get-text-property (point) 'face))))))

View File

@@ -0,0 +1,103 @@
;; Copyright (C) 2013 Free Software Foundation, Inc.
;; This file is part of GNU Emacs.
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;;; Code:
(require 'ert)
(require 'ert-x)
(require 'mmm-erb)
(defvar mmm-erb-text
"<%= foo do %>
<div class=\"clear\"/>
<% end %>")
(defconst mmm-erb-edge-emacs (string-lessp "24.3.50" emacs-version))
(defun mmm-erb-current-overlay-string ()
(buffer-substring-no-properties
(overlay-start mmm-current-overlay)
(overlay-end mmm-current-overlay)))
(defmacro mmm-erb-deftest (name &rest body)
(let ((expected-result (and (eq (car body) :expected-result)
(nth 1 body))))
(when expected-result
(setq body (nthcdr 2 body)))
`(ert-deftest ,(intern (format "mmm-erb-%s" name)) ()
:expected-result ,(or expected-result :passed)
(ert-with-test-buffer nil
(let ((buffer-file-name "foo.html.erb")
(mmm-global-mode 'maybe)
mmm-parse-when-idle
mmm-mode-ext-classes-alist)
(mmm-add-mode-ext-class 'html-erb-mode "\\.html\\.erb\\'" 'erb)
(html-erb-mode)
(mmm-mode-on-maybe)
(should mmm-mode)
,@body)))))
(put 'mmm-erb-deftest 'lisp-indent-function 'defun)
(mmm-erb-deftest parses-buffer
(insert mmm-erb-text)
(mmm-apply-all)
(should (not mmm-current-overlay))
(search-backward "foo")
(should (mmm-update-current-submode))
(should (string= " foo do " (mmm-erb-current-overlay-string)))
(search-forward "end")
(should (mmm-update-current-submode))
(should (string= " end " (mmm-erb-current-overlay-string))))
(defun mmm-erb-assert-string-syntax ()
(goto-char (point-min))
(search-forward "\"")
(should (nth 3 (syntax-ppss)))
(search-forward "\"")
(should (not (nth 3 (syntax-ppss)))))
(defun mmm-erb-assert-non-string-syntax ()
(goto-char (point-min))
(search-forward "\"")
(should (not (nth 3 (syntax-ppss))))
(search-forward "\"")
(should (not (nth 3 (syntax-ppss)))))
(mmm-erb-deftest attribute-values-are-strings
(insert mmm-erb-text)
(mmm-apply-all)
(mmm-erb-assert-string-syntax))
(mmm-erb-deftest quotes-outside-tags-dont-make-strings
:expected-result (if mmm-erb-edge-emacs :passed :failed)
(insert "<% foo do %><p>\"foo bar\"</p><% end %>")
(mmm-apply-all)
(mmm-erb-assert-non-string-syntax))
(mmm-erb-deftest gt-inside-subregion-doesnt-change-nesting
(insert "<% if 2 > 1 %><div class=\"foo\"/><% end %>")
(mmm-apply-all)
(mmm-erb-assert-string-syntax))
(mmm-erb-deftest lt-inside-subregion-doesnt-change-nesting
:expected-result (if mmm-erb-edge-emacs :passed :failed)
(insert "<% if 2 < 1 %><p>\"foo bar\"</p><% end %>")
(mmm-apply-all)
(mmm-erb-assert-non-string-syntax))

File diff suppressed because it is too large Load Diff