Using Dylan-mode for Emacs 19
>Has anybody ever gotten font-lock mode to work with the Dylan-mode
>included with Mindy 1.5?
>The main problem is that when font-lock-mode is enabled, Emacs
>complains with a "Variable binding depth exceeds max-specpdl-size"
>error message, and doesn't do the font lock. I'm using NTEmacs
>version 19.34.1 if that matters.
I had similar problems; I'm still not sure whether the problem is
limited to NT or not. However, we did manage to fix it. I've
attached a copy of dylan-mode.el that works on NTEmacs 19.34.1, and I
believe on the latest Unix version of Gnu Emacs, also. Standard
disclaimers apply: It's nearly impossible to write a substantial elisp
program that works on every single variant of Emacs.
;;; dylan-mode.el Implements indentation and basic support for Dylan (tm)
;;; Copyright (C) 1994, 1995, 1996 Carnegie Mellon University
;;; Bug reports, questions, comments, and suggestions should be sent by
;;; 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 1, 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.
;;; A copy of the GNU General Public License can be obtained from this
;;; or from the Free Software Foundation, Inc., 675 Mass Ave,
;;; Cambridge, MA 02139, USA.
;;; User modifiable variables
(defvar dylan-indent 2
"* Number of spaces to indent each sub-block.")
(defvar dylan-outdent-arrows t
"* Should '=>' in function definitions be treated specially?")
(defvar dylan-highlight-function-calls nil
"* Should font-lock mode try to distinguish all normal function calls?")
(defvar dylan-highlight-defsites t
"* Should font-lock mode try to distinguish all variable bindings?")
(defvar dylan-no-highlights-in-header t
"* Should font-lock ignore keywords in the header. (Experimental -- may
not work on all EMACSen.")
;;; Version 1.16
;;; version 0.1: Quick one day hack -- appears to be useful
;;; version 0.2: Added font lock support
;;; version 0.3: Added misc features to work towards "industrial strength"
;;; Detects "continuation lines" and indents them specially
;;; Basic comment support
;;; Added "symbol character" support (with second syntax table for
;;; indentation and font-lock)
;;; Added indentation support for "elseif" and "exception" clauses
;;; Cleaned up a number of old bugs
;;; version 0.4: Brought into compliance with new "post-DN22" syntax
;;; new comment syntax
;;; new "return types" syntax
;;; accepts sealed, open, concrete, and abstract in class definitions
;;; fixed bug in comment indentation
;;; fine tune font-lock-regexps for "define ..."
;;; version 0.5:
;;; Added "dylan-insert-block-end" function.
;;; Fixed bug in short circuiting indentation outside top level forms.
;;; version 1.0:
;;; Major code reorganization
;;; Added full case statement support
;;; Fixed "continuations" at top level
;;; Added "beginning-of-form" and "end-of-form" commands
;;; Fixed support for character literals and for "quoted" quote chars
;;; version 1.1:
;;; The "font-lock-mode" support no longer interferes with other language
;;; version 1.2:
;;; "foo-end;" was mistaken for the end of a compound statement
;;; syntax tables sometimes ended in an odd state after errors
;;; indentation sometimes failed if parens weren't balanced
;;; version 1.3:
;;; Added font lock support for "sealed", "open", etc.
;;; version 1.4:
;;; Added special-case support for generic function "continuations" and
;;; for outdenting "=>" in function definitions.
;;; version 1.5:
;;; Adjusted regexps to accept "primary" and "free" adjectives
;;; Mentioned dylan-outdent-arrows in the documentation
;;; Added a space to comment-start
;;; version 1.6:
;;; Fixed bug in generic function continuations from 1.4.
;;; version 1.7:
;;; within more general modes.
;;; version 1.8:
;;; version 1.9:
;;; Fixed bug in indentation for expressions in square and curly braces.
;;; Generalized modifier-word handling for definitions.
;;; Generalized 'define words' lists for easier extension.
;;; Fixed "exceeded max nesting" bug with long lists of items.
;;; Added switches for font-lock highlighting of functions and definition
;;; version 1.10:
;;; Fixed bug in "," reindent code. It couldn't deal with commas
;;; in the middle of strings.
;;; Add C-M-a and C-M-e for beginning and end of definition.
;;; Fix font lock syntax table for XEmacs.
;;; version 1.12:
;;; Added support for "define function"
;;; Fixed to ignore keywords in the file header.
;;; Do not require ";" after return value (contributed by
;;; fixed various bugs resulting from overzealous acceptance of newlines:
;;; the word "end" at the end of a comment line caused bad indentation
;;; empty module and library definitions did strange things.
;;; version 1.13:
;;; Fixed dylan-insert-block-end to handle "define function" properly.
;;; (Hopefully) fixed bug in indenting function result declarations,
;;; which was introduced by the previous round of fixes.
;;; version 1.14:
;;; Modified to use font-lock-syntax-table if it is defined. This
;;; eliminates the need to use unportable constructs to modify the
;;; behavior of font-lock mode -- thus, fontification should now be
;;; reliable on modern EMACSen.
;;; version 1.15
;;; Fixed syntax table bugs which primarily affected gnu-emacs
;;; 19. users.
;;; Optimized "beyond-dylan-header".
;;; Removed new-lines from various font-lock regexps so that
;;; adjacent declarations aren't glommed together.
;;; version 1.16
;;; Made symbols properly fontify as strings.
;;; Added the dylan-no-highlights-in-header variable (enabled by
;;; default) which keeps keywords in headers from being treated
;;; Known limitations:
;;; Limited support for block (i.e. "/*") comments
;;; TAB indentation doesn't work within "/*" comments
;;; Magic => support doesn't work at end of buffer
;;; Desired features:
;;; Copy indentation from first statement in body
;;; More consistency in font-lock highlighting
;;; Better support for "/*" comments
;;; Private definitions. Extensible by using add-dylan-keyword in
;;; your dylan-mode-hook.
(defun add-dylan-keyword (variable keyword)
(add-to-list variable keyword)
(if (fboundp 'font-lock-mode)
(setq font-lock-keywords dylan-font-lock-keywords)))
"Words which introduce unnamed definitions like 'define interface'.")
'("module" "library" "macro")
"Words which introduce simple named definitions like 'define library'.")
'("method" "class" "function")
"Words which introduce trickier definitions like 'define method'. These
require special definitions to be added to 'dyl-start-expressions'.")
'("constant" "variable" "generic")
"Words which introduce simple definitions (without implicit bodies).");
'("if" "block" "begin" "method" "case" "for" "select" "unless" "until"
"Words which begin statements with implicit bodies.")
'("finally" "exception" "cleanup" "else" "elseif")
"Patterns act as separators in compound statements. This may include any
general pattern which must be indented specially.")
'("above" "below" "by" "from"
"handler" "in" "instance" "let" "local" "otherwise"
"slot" "subclass" "then" "to" "virtual")
"Keywords which do not require special indentation handling, but which
should be highlighted if this capability exists.")
(defun dylan-mode-commands (map)
(define-key map ";" 'dylan-insert-and-indent)
(define-key map "," 'dylan-insert-and-indent)
(define-key map ">" 'dylan-arrow-insert)
(define-key map "\n" 'dylan-newline-and-indent)
(define-key map "\t" 'dylan-indent-line)
(define-key map "\ea" 'dylan-beginning-of-form)
(define-key map "\ee" 'dylan-end-of-form)
(define-key map "\e)" 'dylan-insert-block-end)
(define-key map "\e\C-a" 'dylan-beginning-of-defun)
(define-key map "\e\C-e" 'dylan-end-of-defun)
(define-key map "\e\C-h" 'mark-dylan-function)
(defvar dylan-mode-map ()
"Keymap used in dylan mode.")
(if (not dylan-mode-map)
(setq dylan-mode-map (make-sparse-keymap))
(defvar dylan-mode-abbrev-table nil
"Abbrev table in use in dylan-mode buffers. Provides 'hooked'
abbreviations to reindent lines containing 'separator' keywords.")
(if (not dylan-mode-abbrev-table)
(define-abbrev-table 'dylan-mode-abbrev-table ())
(define-abbrev dylan-mode-abbrev-table "end" "end" 'reindent-line)
read more »