From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Luc Teirlinck Newsgroups: gmane.emacs.devel Subject: Re: Recent attempts at standardizing major mode definitions. Date: Wed, 4 Sep 2002 16:52:11 -0500 (CDT) Sender: emacs-devel-admin@gnu.org Message-ID: <200209042152.QAA00662@eel.dms.auburn.edu> References: <200209020240.VAA26083@eel.dms.auburn.edu> <200209021651.g82Gpe007333@rum.cs.yale.edu> <200209040135.UAA28343@eel.dms.auburn.edu> <200209041524.g84FOtX19235@rum.cs.yale.edu> NNTP-Posting-Host: localhost.gmane.org X-Trace: main.gmane.org 1031176341 14517 127.0.0.1 (4 Sep 2002 21:52:21 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 4 Sep 2002 21:52:21 +0000 (UTC) Cc: monnier+gnu/emacs@rum.cs.yale.edu, emacs-devel@gnu.org Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 17mi4Q-0003lq-00 for ; Wed, 04 Sep 2002 23:52:18 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 17mido-00036B-00 for ; Thu, 05 Sep 2002 00:28:52 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 17mi5z-0001wG-00; Wed, 04 Sep 2002 17:53:55 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 17mi4N-0001hP-00 for emacs-devel@gnu.org; Wed, 04 Sep 2002 17:52:15 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 17mi4J-0001gq-00 for emacs-devel@gnu.org; Wed, 04 Sep 2002 17:52:14 -0400 Original-Received: from manatee.dms.auburn.edu ([131.204.53.104]) by monty-python.gnu.org with esmtp (Exim 4.10) id 17mi4J-0001gd-00 for emacs-devel@gnu.org; Wed, 04 Sep 2002 17:52:11 -0400 Original-Received: from eel.dms.auburn.edu (eel.dms.auburn.edu [131.204.53.108]) by manatee.dms.auburn.edu (8.9.1a/8.9.1) with ESMTP id QAA07145; Wed, 4 Sep 2002 16:52:09 -0500 (CDT) Original-Received: (from teirllm@localhost) by eel.dms.auburn.edu (8.9.3+Sun/8.9.3) id QAA00662; Wed, 4 Sep 2002 16:52:11 -0500 (CDT) X-Authentication-Warning: eel.dms.auburn.edu: teirllm set sender to teirllm@dms.auburn.edu using -f Original-To: monnier+gnu/emacs@rum.cs.yale.edu In-Reply-To: <200209041524.g84FOtX19235@rum.cs.yale.edu> (monnier+gnu/emacs@rum.cs.yale.edu) Errors-To: emacs-devel-admin@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.devel:7482 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:7482 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> ============================================================