]> git.eshelyaron.com Git - emacs.git/commitdiff
(define-derived-mode,easy-mmode-derived-mode-p): Remove (moved to derived.el).
authorStefan Monnier <monnier@iro.umontreal.ca>
Sun, 3 Dec 2000 21:41:06 +0000 (21:41 +0000)
committerStefan Monnier <monnier@iro.umontreal.ca>
Sun, 3 Dec 2000 21:41:06 +0000 (21:41 +0000)
lisp/ChangeLog
lisp/emacs-lisp/easy-mmode.el

index 19105b69535d64ed427c63c15361cc5f4de7f537..2828bb00ed0f678eef0172b024d109519b11a6f3 100644 (file)
@@ -1,3 +1,13 @@
+2000-12-03  Stefan Monnier  <monnier@cs.yale.edu>
+
+       * emacs-lisp/easy-mmode.el (define-derived-mode) 
+       (easy-mmode-derived-mode-p): Remove (moved to derived.el).
+
+       * derived.el (define-derived-mode): Revived, moved from easy-mmode.el.
+       (derived-mode-p): New function.
+       (derived-mode-make-docstring): Add `docstring' argument.
+       Use it if available and complete it if necessary.
+
 2000-12-03  Andreas Schwab  <schwab@suse.de>
 
        * type-break.el (type-break): Don't make parent of itself.
index 2dde3559088580826c69471e67b63b9e313cb72e..87ce0cc9c2252b8ba618dc24282378be98c19648 100644 (file)
@@ -381,137 +381,6 @@ CSS contains a list of syntax specifications of the form (CHAR . SYNTAX).
      (defconst ,st (easy-mmode-define-syntax ,css ,(cons 'list args)) doc)))
 
 
-\f
-;;;
-;;; A "macro-only" reimplementation of define-derived-mode.
-;;;
-
-;;;###autoload
-(defmacro define-derived-mode (child parent name &optional docstring &rest body)
-  "Create a new mode as a variant of an existing mode.
-
-The arguments to this command are as follow:
-
-CHILD:     the name of the command for the derived mode.
-PARENT:    the name of the command for the parent mode (e.g. `text-mode').
-NAME:      a string which will appear in the status line (e.g. \"Hypertext\")
-DOCSTRING: an optional documentation string--if you do not supply one,
-           the function will attempt to invent something useful.
-BODY:      forms to execute just before running the
-           hooks for the new mode.
-
-Here is how you could define LaTeX-Thesis mode as a variant of LaTeX mode:
-
-  (define-derived-mode LaTeX-thesis-mode LaTeX-mode \"LaTeX-Thesis\")
-
-You could then make new key bindings for `LaTeX-thesis-mode-map'
-without changing regular LaTeX mode.  In this example, BODY is empty,
-and DOCSTRING is generated by default.
-
-On a more complicated level, the following command uses `sgml-mode' as
-the parent, and then sets the variable `case-fold-search' to nil:
-
-  (define-derived-mode article-mode sgml-mode \"Article\"
-    \"Major mode for editing technical articles.\"
-    (setq case-fold-search nil))
-
-Note that if the documentation string had been left out, it would have
-been generated automatically, with a reference to the keymap."
-
-  (let* ((child-name (symbol-name child))
-        (map (intern (concat child-name "-map")))
-        (syntax (intern (concat child-name "-syntax-table")))
-        (abbrev (intern (concat child-name "-abbrev-table")))
-        (hook (intern (concat child-name "-hook"))))
-        
-    (unless parent (setq parent 'fundamental-mode))
-
-    (when (and docstring (not (stringp docstring)))
-      ;; DOCSTRING is really the first command and there's no docstring
-      (push docstring body)
-      (setq docstring nil))
-
-    (unless (stringp docstring)
-      ;; Use a default docstring.
-      (setq docstring
-           (format "Major mode derived from `%s' by `define-derived-mode'.
-Inherits all of the parent's attributes, but has its own keymap,
-abbrev table and syntax table:
-
-  `%s', `%s' and `%s'
-
-which more-or-less shadow %s's corresponding tables."
-                   parent map syntax abbrev parent)))
-
-    (unless (string-match (regexp-quote (symbol-name hook)) docstring)
-      ;; Make sure the docstring mentions the mode's hook
-      (setq docstring
-           (concat docstring
-                   (if (eq parent 'fundamental-mode)
-                       "\n\nThis mode "
-                     (concat
-                      "\n\nIn addition to any hooks its parent mode "
-                      (if (string-match (regexp-quote (format "`%s'" parent))
-                                        docstring) nil
-                        (format "`%s' " parent))
-                      "might have run,\nthis mode "))
-                   (format "runs the hook `%s'" hook)
-                   ", as the final step\nduring initialization.")))
-
-    (unless (string-match "\\\\[{[]" docstring)
-      ;; And don't forget to put the mode's keymap
-      (setq docstring (concat docstring "\n\n\\{" (symbol-name map) "}")))
-
-    `(progn
-       (defvar ,map (make-sparse-keymap))
-       (defvar ,syntax (make-char-table 'syntax-table nil))
-       (defvar ,abbrev)
-       (define-abbrev-table ',abbrev nil)
-       (put ',child 'derived-mode-parent ',parent)
-     
-       (defun ,child ()
-        ,docstring
-        (interactive)
-                                       ; Run the parent.
-        (combine-run-hooks
-
-         (,parent)
-                                       ; Identify special modes.
-         (put ',child 'special (get ',parent 'special))
-                                       ; Identify the child mode.
-         (setq major-mode ',child)
-         (setq mode-name ,name)
-                                       ; Set up maps and tables.
-         (unless (keymap-parent ,map)
-           (set-keymap-parent ,map (current-local-map)))
-         (let ((parent (char-table-parent ,syntax)))
-           (unless (and parent (not (eq parent (standard-syntax-table))))
-             (set-char-table-parent ,syntax (syntax-table))))
-         (when local-abbrev-table
-           (mapatoms
-            (lambda (symbol)
-              (or (intern-soft (symbol-name symbol) ,abbrev)
-                  (define-abbrev ,abbrev (symbol-name symbol)
-                    (symbol-value symbol) (symbol-function symbol))))
-            local-abbrev-table))
-       
-         (use-local-map ,map)
-         (set-syntax-table ,syntax)
-         (setq local-abbrev-table ,abbrev)
-                                       ; Splice in the body (if any).
-         ,@body)
-                                       ; Run the hooks, if any.
-        (run-hooks ',hook)))))
-
-;; Inspired from derived-mode-class in derived.el
-(defun easy-mmode-derived-mode-p (mode)
-  "Non-nil if the current major mode is derived from MODE.
-Uses the `derived-mode-parent' property of the symbol to trace backwards."
-  (let ((parent major-mode))
-    (while (and (not (eq parent mode))
-               (setq parent (get parent 'derived-mode-parent))))
-    parent))
-
 \f
 ;;;
 ;;; easy-mmode-define-navigation