[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Recent attempts at standardizing major mode definitions.
From: |
Luc Teirlinck |
Subject: |
Re: Recent attempts at standardizing major mode definitions. |
Date: |
Wed, 4 Sep 2002 16:52:11 -0500 (CDT) |
Stefan Monnier wrote:
If there is a difference, it's a bug, so please report it.
Sorry, I should have thought about that possibility. I assumed the
difference was deliberate. I include a transcript of an ielm session.
First we define my-mode as a derived mode of text-mode, then as a
derived mode of fundamental-mode. text-mode's abbrev table gets
copied, fundamental-mode's not. I believe that whatever behavior for
abbrevs we decide on, the behavior should be the same for both, if we
are talking about a "true" derived mode of fundamental-mode.
===File ~/derivedstuff======================================
*** Welcome to IELM *** Type (describe-mode) for help.
ELISP> (emacs-version)
"GNU Emacs 21.3.50.1 (i686-pc-linux-gnu, X toolkit)\n of 2002-09-01 on
swt40.swt.com"
ELISP> (macroexpand `(define-derived-mode my-mode text-mode "Mymode"
"docstring" (defvar mymode-var 1)))
(progn
(defvar my-mode-map
(make-sparse-keymap))
(defvar my-mode-syntax-table
(make-syntax-table))
(defvar my-mode-abbrev-table
(progn
(define-abbrev-table 'my-mode-abbrev-table nil)
my-mode-abbrev-table))
(put 'my-mode 'derived-mode-parent 'text-mode)
(defun my-mode nil "docstring\n\nIn addition to any hooks its parent mode
`text-mode' might have run,\nthis mode runs the hook `my-mode-hook', as the
final step\nduring initialization.\n\n\\{my-mode-map}"
(interactive)
(delay-mode-hooks
(text-mode)
(setq major-mode 'my-mode)
(setq mode-name "Mymode")
(progn
(if
(get 'text-mode 'mode-class)
(put 'my-mode 'mode-class
(get 'text-mode 'mode-class)))
(unless
(keymap-parent my-mode-map)
(set-keymap-parent my-mode-map
(current-local-map)))
(let
((parent
(char-table-parent my-mode-syntax-table)))
(unless
(and parent
(not
(eq parent
(standard-syntax-table))))
(set-char-table-parent my-mode-syntax-table
(syntax-table))))
(when local-abbrev-table
(mapatoms
(lambda
(symbol)
(or
(intern-soft
(symbol-name symbol)
my-mode-abbrev-table)
(define-abbrev my-mode-abbrev-table
(symbol-name symbol)
(symbol-value symbol)
(symbol-function symbol))))
local-abbrev-table)))
(use-local-map my-mode-map)
(set-syntax-table my-mode-syntax-table)
(setq local-abbrev-table my-mode-abbrev-table)
(defvar mymode-var 1))
(run-mode-hooks 'my-mode-hook)))
ELISP> (macroexpand `(define-derived-mode my-mode fundamental-mode "Mymode"
"docstring" (defvar mymode-var 1)))
(progn
(defvar my-mode-map
(make-sparse-keymap))
(defvar my-mode-syntax-table
(make-syntax-table))
(defvar my-mode-abbrev-table
(progn
(define-abbrev-table 'my-mode-abbrev-table nil)
my-mode-abbrev-table))
(put 'my-mode 'derived-mode-parent 'nil)
(defun my-mode nil "docstring\n\nThis mode runs the hook `my-mode-hook', as
the final step\nduring initialization.\n\n\\{my-mode-map}"
(interactive)
(delay-mode-hooks
(kill-all-local-variables)
(setq major-mode 'my-mode)
(setq mode-name "Mymode")
nil
(use-local-map my-mode-map)
(set-syntax-table my-mode-syntax-table)
(setq local-abbrev-table my-mode-abbrev-table)
(defvar mymode-var 1))
(run-mode-hooks 'my-mode-hook)))
ELISP>
============================================================
- Re: Recent attempts at standardizing major mode definitions., (continued)
Re: Recent attempts at standardizing major mode definitions., Luc Teirlinck, 2002/09/03
Re: Recent attempts at standardizing major mode definitions., Luc Teirlinck, 2002/09/03
Re: Recent attempts at standardizing major mode definitions., Luc Teirlinck, 2002/09/03
- Re: Recent attempts at standardizing major mode definitions., Stefan Monnier, 2002/09/04
- Re: Recent attempts at standardizing major mode definitions., Luc Teirlinck, 2002/09/04
- Re: Recent attempts at standardizing major mode definitions., Stefan Monnier, 2002/09/06
- Re: Recent attempts at standardizing major mode definitions., David Masterson, 2002/09/06
- Re: Recent attempts at standardizing major mode definitions., Luc Teirlinck, 2002/09/06
- Re: Recent attempts at standardizing major mode definitions., Luc Teirlinck, 2002/09/06