;ELC ;;; compiled by kwzh@hal.gnu.ai.mit.edu on Tue May 2 20:20:18 1995 ;;; from file /gd/gnu/emacs/19.0/lisp/derived.el ;;; emacs version 19.28.90.69. ;;; bytecomp version FSF 2.10 ;;; optimization is on. ;;; this file uses opcodes which do not exist in Emacs 18. (if (and (boundp 'emacs-version) (or (and (boundp 'epoch::version) epoch::version) (string-lessp emacs-version "19"))) (error "`/gd/gnu/emacs/19.0/lisp/derived.el' was compiled for Emacs 19")) #@1256 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 (ie. text-mode). NAME: a string which will appear in the status line (ie. "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. (defalias 'define-derived-mode '(macro . #[(child parent name &optional docstring &rest body) "ƒ;„ B†Ã\f \"ÆÇÈ DDÉ ÂÊ\fCËÌÈ\fDÍBBÎÈ DÏBBEÐÑÈ DEÐÒEÔÈ DDÕÈ DDÖÈ DD× ØÈ DDC\"BBBBBBBBBBBBE‡" [docstring body nil derived-mode-make-docstring parent child progn derived-mode-init-mode-variables quote defun (interactive) if get ((quote special)) put ((quote special) t) setq major-mode mode-name name derived-mode-set-keymap derived-mode-set-syntax-table derived-mode-set-abbrev-table append derived-mode-run-hooks] 19 (#$ . 485)])) #@172 Find the class of a major mode. A mode's class is the first ancestor which is NOT a derived mode. Use the `derived-mode-parent' property of the symbol to trace backwards. (defalias 'derived-mode-class #[(mode) "ÁNƒÁN‰‚‡" [mode derived-mode-parent] 3 (#$ . 2289)]) #@55 Construct a setup-function name based on a mode name. (defalias 'derived-mode-setup-function-name #[(mode) "ÀÁ\n!ÃP!‡" [intern symbol-name mode "-setup"] 3 (#$ . 2567)]) (put (quote derived-mode-setup-function-name) (quote byte-optimizer) (quote byte-compile-inline-expand)) #@46 Construct a hooks name based on a mode name. (defalias 'derived-mode-hooks-name #[(mode) "ÀÁ\n!ÃP!‡" [intern symbol-name mode "-hooks"] 3 (#$ . 2848)]) (put (quote derived-mode-hooks-name) (quote byte-optimizer) (quote byte-compile-inline-expand)) #@44 Construct a map name based on a mode name. (defalias 'derived-mode-map-name #[(mode) "ÀÁ\n!ÃP!‡" [intern symbol-name mode "-map"] 3 (#$ . 3102)]) (put (quote derived-mode-map-name) (quote byte-optimizer) (quote byte-compile-inline-expand)) #@53 Construct a syntax-table name based on a mode name. (defalias 'derived-mode-syntax-table-name #[(mode) "ÀÁ\n!ÃP!‡" [intern symbol-name mode "-syntax-table"] 3 (#$ . 3348)]) (put (quote derived-mode-syntax-table-name) (quote byte-optimizer) (quote byte-compile-inline-expand)) #@54 Construct an abbrev-table name based on a mode name. (defalias 'derived-mode-abbrev-table-name #[(mode) "ÀÁ\n!ÃP!‡" [intern symbol-name mode "-abbrev-table"] 3 (#$ . 3630)]) (put (quote derived-mode-abbrev-table-name) (quote byte-optimizer) (quote byte-compile-inline-expand)) #@208 Initialise variables for a new mode. Right now, if they don't already exist, set up a blank keymap, an empty syntax table, and an empty abbrev table -- these will be merged the first time the mode is used. (defalias 'derived-mode-init-mode-variables #[(mode) "À Âà !ÄP!)!„2ÅÆ Âà !ÄP!)ÇÈÉ \"F!ˆÊ Âà !ÄP!)ËÌ#ˆÀ Âà !ÍP!)!„dÅÆ Âà !ÍP!)ÎÈÏ \"F!ˆÊ Âà !ÍP!)ËÌ#ˆÀ Âà !ÐP!)!ƒu̇ÅÆ Âà !ÐP!)ÑÈÒ \"F!‡" [boundp mode intern symbol-name "-map" eval defvar (make-sparse-keymap) format "Keymap for %s." put derived-mode-unmerged t "-syntax-table" (make-vector 256 nil) "Syntax table for %s." "-abbrev-table" (progn (define-abbrev-table (derived-mode-abbrev-table-name mode) nil) (make-abbrev-table)) "Abbrev table for %s."] 7 (#$ . 3914)]) #@59 Construct a docstring for a new mode if none is provided. (defalias 'derived-mode-make-docstring #[(parent child) "ÀÁ\n ‰\n‰ &‡" [format "This major mode is a variant of `%s', created by `define-derived-mode'.\nIt inherits all of the parent's attributes, but has its own keymap,\nabbrev table and syntax table:\n\n `%s-map' and `%s-syntax-table'\n\nwhich more-or-less shadow\n\n `%s-map' and `%s-syntax-table'\n\n\\{%s-map}" parent child] 8 (#$ . 4656)]) #@64 Set the keymap of the new mode, maybe merging with the parent. (defalias 'derived-mode-set-keymap #[(mode) "ÁÂ!ÃP!)Å\f!Ç \fÉNƒ!Ê\"ˆË\fÉÌ#ˆÍ!+‡" [mode intern symbol-name "-map" map-name eval new-map current-local-map old-map derived-mode-unmerged derived-mode-merge-keymaps put nil use-local-map] 4 (#$ . 5120)]) #@70 Set the syntax table of the new mode, maybe merging with the parent. (defalias 'derived-mode-set-syntax-table #[(mode) "ÁÂ!ÃP!)Å Ç\f!\fÉNƒ!Ê\"ˆË\fÉÌ#ˆÍ!+‡" [mode intern symbol-name "-syntax-table" table-name syntax-table old-table eval new-table derived-mode-unmerged derived-mode-merge-syntax-tables put nil set-syntax-table] 4 (#$ . 5453)]) #@107 Set the abbrev table if it exists. Always merge its parent into it, since the merge is non-destructive. (defalias 'derived-mode-set-abbrev-table #[(mode) "ÁÂ!ÃP!) Ç\f!É\"ˆ‰+‡" [mode intern symbol-name "-abbrev-table" table-name local-abbrev-table old-table eval new-table derived-mode-merge-abbrev-tables] 3 (#$ . 5818)]) #@30 Run the hooks if they exist. (defalias 'derived-mode-run-hooks #[(mode) "ÁÂ!ÃP!)Å\f!…Æ\f!)‡" [mode intern symbol-name "-hooks" hooks-name boundp run-hooks] 3 (#$ . 6163)]) #@139 Merge an old keymap into a new one. The old keymap is set to be the last cdr of the new one, so that there will be automatic inheritance. (defalias 'derived-mode-merge-keymaps #[(old new) "‰:ƒ| @:ƒ3 @@!Ä \"Ä \"È !ƒ2È!ƒ2É \"ˆ+Ê @!ƒu @GS‰ ÌYƒt !Ä \"Ä \"È !ƒjÈ!ƒjÉ \"ˆ+ S‰ ‚A) A‰‚)GS›¡‡" [new tail vector key lookup-key subnew old subold keymapp derived-mode-merge-keymaps vectorp i 0] 4 (#$ . 6348)]) #@121 Merge an old syntax table into a new one. Where the new table already has an entry, nothing is copied from the old one. (defalias 'derived-mode-merge-syntax-tables #[(old new) "À G\nG^‰ W…\" \fH„ \f\n\fHIˆ\fT‰‚ *‡" [0 new old end idx] 5 (#$ . 6800)]) (defalias 'derived-mode-merge-abbrev-tables #[(old new) "…ÁÂ\"‡" [old mapatoms #[(symbol) "ÀÁ\n! \"†Ä Á\n!\nJ\nK$‡" [intern-soft symbol-name symbol new define-abbrev] 5]] 3]) (provide (quote derived))