changeset 34149:96ff9f3650b5

(define-derived-mode,easy-mmode-derived-mode-p): Remove (moved to derived.el).
author Stefan Monnier <monnier@iro.umontreal.ca>
date Sun, 03 Dec 2000 21:40:23 +0000
parents 7f4f9332942e
children 3f40525951d5
files lisp/emacs-lisp/easy-mmode.el
diffstat 1 files changed, 0 insertions(+), 131 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/emacs-lisp/easy-mmode.el	Sun Dec 03 21:39:34 2000 +0000
+++ b/lisp/emacs-lisp/easy-mmode.el	Sun Dec 03 21:40:23 2000 +0000
@@ -383,137 +383,6 @@
 
 
 ;;;
-;;; 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))
-
-
-;;;
 ;;; easy-mmode-define-navigation
 ;;;