From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: yary Newsgroups: gmane.emacs.bugs Subject: bug#15577: 24.3; dir-local variables not applied when switching major-mode Date: Fri, 18 Oct 2013 11:43:54 -0400 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1382111119 27270 80.91.229.3 (18 Oct 2013 15:45:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 18 Oct 2013 15:45:19 +0000 (UTC) Cc: 15577 <15577@debbugs.gnu.org> To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Oct 18 17:45:23 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VXCEq-0001mr-Uv for geb-bug-gnu-emacs@m.gmane.org; Fri, 18 Oct 2013 17:45:21 +0200 Original-Received: from localhost ([::1]:58379 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VXCEq-0001dt-JP for geb-bug-gnu-emacs@m.gmane.org; Fri, 18 Oct 2013 11:45:20 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40172) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VXCEh-0001VT-RP for bug-gnu-emacs@gnu.org; Fri, 18 Oct 2013 11:45:16 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VXCEa-0004u3-Kv for bug-gnu-emacs@gnu.org; Fri, 18 Oct 2013 11:45:11 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:43034) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VXCEa-0004sl-Bb for bug-gnu-emacs@gnu.org; Fri, 18 Oct 2013 11:45:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1VXCEZ-0008D2-CO for bug-gnu-emacs@gnu.org; Fri, 18 Oct 2013 11:45:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: yary Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 18 Oct 2013 15:45:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15577 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 15577-submit@debbugs.gnu.org id=B15577.138211106531492 (code B ref 15577); Fri, 18 Oct 2013 15:45:03 +0000 Original-Received: (at 15577) by debbugs.gnu.org; 18 Oct 2013 15:44:25 +0000 Original-Received: from localhost ([127.0.0.1]:57053 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VXCDx-0008Bs-2D for submit@debbugs.gnu.org; Fri, 18 Oct 2013 11:44:25 -0400 Original-Received: from mail-we0-f169.google.com ([74.125.82.169]:49076) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VXCDt-0008BY-6a for 15577@debbugs.gnu.org; Fri, 18 Oct 2013 11:44:22 -0400 Original-Received: by mail-we0-f169.google.com with SMTP id q58so4001664wes.0 for <15577@debbugs.gnu.org>; Fri, 18 Oct 2013 08:44:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=GseDk7ManB1DGYKxXVYyQbkL69+jymwZRc44AnYrdgc=; b=DfYPsHW7SKd+nHYGQUuQFcuGPttpo7Kq0bwTCnjJr3VORRMEHH1NpN7u+KQzGhabm9 ZmgF5XHs4KoBi7+in1Pxq1Q/ffxc5omHRDKsNcE0l4omSlic2eLwYdjysphAnY56qKMt g9P7gx+NFP3p50wG4GtQHHH375TFMzd98j2TgVVI32EMbTRpMneoc0fpu1hxLL4+yV5d 6AEcmgtL8LrPBJi4O9nzq/cwwJjM7SbzPyOs/+1uX9e7V2YaG0pUOuz1mkkJoFFi2fTL 7xRzwCvqFG7NqWdG1mLOfloy7jl8QXHi6iCrFXdiJGJn0kao0A5/dVyq43EJ+Sm1ESTA ydbA== X-Received: by 10.180.99.99 with SMTP id ep3mr3022024wib.11.1382111055034; Fri, 18 Oct 2013 08:44:15 -0700 (PDT) Original-Received: by 10.194.83.72 with HTTP; Fri, 18 Oct 2013 08:43:54 -0700 (PDT) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:79365 Archived-At: My implementation thoughts for core-level fixes, after working on personal workarounds. For sub-issue #1 "dir-locals not being applied in the new mode," divide the responsibility for setting file-locals and dir-locals between `normal-mode find-file=t' and `define-derived-mode'. Just have `define-derived-mode' call `(hack-dir-local-variables)(hack-local-variables-apply)' unless it is being called as a result of `normal-mode t'. There's no change needed for the normal-mode function or anything it calls, except perhaps setting something that the define-derived-mode macro can check. For sub-issue #2 "an easier way for us to preserve minor-modes and buffer-local variables when switching modes"- I discovered this exchange showing it's been raised before https://lists.gnu.org/archive/html/emacs-devel/2007-12/msg00366.html which resulted in adding the property `permanent-local-hook' to compliment the `permanent-local' property, facilitating minor-mode preservation. That was in the context of helping mode authors preserve specific minor-modes. In itself, it isn't enough for a generic minor-mode preservation but it can help. A function to preserve any minor-mode needs to a. Get all of that mode's customizable buffer-locals. Ideally the minor-mode, or emacs core, would provide a function for that purpose. If not, might be able to reliably get a list by creating a scratch buffer, saving results of `buffer-local-variables', enabling the minor mode in question, then mark the differences from a subsequent call to `buffer-local-variables'. b. Mark those variables as permanent-local Then either b1. Continue to allow major-mode changes to disable all minor-modes, but re-enable the user-requested minor-modes after calling kill-all-local-variables. This doesn't require any use of `permanent-local-hook'; the minor mode is being disabled and re-enabled and any hooks can be normally uninstalled & re-installed & re-run b2. Apply `permanent-local-hook' to all the minor-mode's hook functions. The minor mode might provide those symbols via a function for that purpose, or perhaps they could be auto-discovered. Alas I don't yet know enough about Emacs' minor-mode handling to get further with these thoughts. Thanks for bearing with me. -y