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: enriched-mode and switching major modes. Date: Sun, 5 Sep 2004 19:59:39 -0500 (CDT) Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Message-ID: <200409060059.i860xdo20431@raven.dms.auburn.edu> References: <200409042358.i84Nwjt19152@raven.dms.auburn.edu> NNTP-Posting-Host: deer.gmane.org X-Trace: sea.gmane.org 1094432832 23251 80.91.224.253 (6 Sep 2004 01:07:12 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 6 Sep 2004 01:07:12 +0000 (UTC) Cc: boris@gnu.org, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Sep 06 03:07:05 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1C47yK-0000Fc-00 for ; Mon, 06 Sep 2004 03:07:05 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1C483T-0006wY-Qu for ged-emacs-devel@m.gmane.org; Sun, 05 Sep 2004 21:12:23 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1C482l-0006db-Jt for emacs-devel@gnu.org; Sun, 05 Sep 2004 21:11:39 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1C482e-0006Z5-2X for emacs-devel@gnu.org; Sun, 05 Sep 2004 21:11:33 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1C482c-0006Wt-4b for emacs-devel@gnu.org; Sun, 05 Sep 2004 21:11:30 -0400 Original-Received: from [131.204.53.104] (helo=manatee.dms.auburn.edu) by monty-python.gnu.org with esmtp (Exim 4.34) id 1C47rO-0002nZ-UA; Sun, 05 Sep 2004 20:59:55 -0400 Original-Received: from raven.dms.auburn.edu (raven.dms.auburn.edu [131.204.53.29]) by manatee.dms.auburn.edu (8.12.10/8.12.10) with ESMTP id i860xmuE003193; Sun, 5 Sep 2004 19:59:48 -0500 (CDT) Original-Received: (from teirllm@localhost) by raven.dms.auburn.edu (8.11.7p1+Sun/8.11.7) id i860xdo20431; Sun, 5 Sep 2004 19:59:39 -0500 (CDT) X-Authentication-Warning: raven.dms.auburn.edu: teirllm set sender to teirllm@dms.auburn.edu using -f Original-To: rms@gnu.org In-reply-to: (message from Richard Stallman on Sun, 05 Sep 2004 13:25:40 -0400) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:26809 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:26809 Richard Stallman wrote: `enriched-mode' sets buffer-local values for these variables, but when the major mode is set by `after-find-file', these variables are killed. It sounds like enriched-mode is called too early. What is the command that you give? C-x C-f on a file called enriched.text. But any time one switches major modes in a buffer in Enriched mode, the same problems arise. I now believe that Enriched mode should be temporarily disabled when switching major modes and later re-enabled by post-command-hook. That not only resets all killed local variables, it also seems to be the only way to correctly update `enriched-old-bindings', which is necessary when switching major modes. The following patch implements this. It should work OK even in case the user quits or an error occurs. I can install it if it looks OK. ===File ~/enriched.el-diff================================== *** enriched.el 02 Jul 2004 21:39:16 -0500 1.4 --- enriched.el 05 Sep 2004 19:16:50 -0500 *************** *** 1,6 **** ;;; enriched.el --- read and save files in text/enriched format ! ;; Copyright (c) 1994, 1995, 1996, 2002 Free Software Foundation, Inc. ;; Author: Boris Goldowsky ;; Keywords: wp, faces --- 1,6 ---- ;;; enriched.el --- read and save files in text/enriched format ! ;; Copyright (c) 1994, 1995, 1996, 2002, 2004 Free Software Foundation, Inc. ;; Author: Boris Goldowsky ;; Keywords: wp, faces *************** *** 155,160 **** --- 155,164 ---- The value is a list of \(VAR VALUE VAR VALUE...).") (make-variable-buffer-local 'enriched-old-bindings) + ;; A non-nil value indicates that Enriched mode was temporarily disabled + ;; by `enriched-before-change-major-mode' while switching major modes. + (defvar enriched-change-major-mode-flag nil) + ;;; ;;; Define the mode ;;; *************** *** 197,203 **** (make-local-variable 'default-text-properties) (setq indent-line-function 'indent-to-left-margin ;WHY?? -sm buffer-display-table enriched-display-table) ! (use-hard-newlines 1 nil) (let ((sticky (plist-get default-text-properties 'front-sticky)) (p enriched-par-props)) (dolist (x p) --- 201,207 ---- (make-local-variable 'default-text-properties) (setq indent-line-function 'indent-to-left-margin ;WHY?? -sm buffer-display-table enriched-display-table) ! (use-hard-newlines 1 (if enriched-change-major-mode-flag 'never nil)) (let ((sticky (plist-get default-text-properties 'front-sticky)) (p enriched-par-props)) (dolist (x p) *************** *** 205,211 **** (if sticky (setq default-text-properties (plist-put default-text-properties ! 'front-sticky sticky))))))) ;;; ;;; Keybindings --- 209,234 ---- (if sticky (setq default-text-properties (plist-put default-text-properties ! 'front-sticky sticky)))) ! (add-hook 'change-major-mode-hook ! 'enriched-before-change-major-mode nil t))) ! (setq enriched-change-major-mode-flag nil)) ! ! ;; Enriched mode sets several local variables that are killed when ! ;; changing major modes. They need to be reset. Also, when the major ! ;; mode changes, `enriched-old-bindings' needs to be correctly ! ;; updated. Therefore, we disable Enriched mode before changing the ! ;; major mode and enable it back afterward. ! (defun enriched-before-change-major-mode () ! (when enriched-mode ! (let ((inhibit-quit t)) ! (enriched-mode 0) ! (setq enriched-change-major-mode-flag t)))) ! ! (defun enriched-after-change-major-mode () ! (when enriched-change-major-mode-flag (enriched-mode 1))) ! ! (add-hook 'post-command-hook 'enriched-after-change-major-mode) ;;; ;;; Keybindings ============================================================