From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#2833: 23.0.92; Bug in Directory Variables Date: Thu, 09 Apr 2009 10:27:22 -0400 Message-ID: References: <87fxgicz1b.fsf@cyd.mit.edu> Reply-To: Stefan Monnier , 2833@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1239288823 21979 80.91.229.12 (9 Apr 2009 14:53:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 9 Apr 2009 14:53:43 +0000 (UTC) Cc: 2833@emacsbugs.donarmstrong.com To: Chong Yidong Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Apr 09 16:54:59 2009 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Lrved-0005U1-8u for geb-bug-gnu-emacs@m.gmane.org; Thu, 09 Apr 2009 16:54:59 +0200 Original-Received: from localhost ([127.0.0.1]:52349 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LrvdF-00077U-0o for geb-bug-gnu-emacs@m.gmane.org; Thu, 09 Apr 2009 10:53:33 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LrvU0-0000qk-IQ for bug-gnu-emacs@gnu.org; Thu, 09 Apr 2009 10:44:00 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LrvTv-0000nt-JQ for bug-gnu-emacs@gnu.org; Thu, 09 Apr 2009 10:43:59 -0400 Original-Received: from [199.232.76.173] (port=43797 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LrvTv-0000nl-BR for bug-gnu-emacs@gnu.org; Thu, 09 Apr 2009 10:43:55 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:38107) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LrvTu-0001Xr-PR for bug-gnu-emacs@gnu.org; Thu, 09 Apr 2009 10:43:55 -0400 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id n39Ehnqt000847; Thu, 9 Apr 2009 07:43:49 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.13.8/8.13.8/Submit) id n39EZ6wa030385; Thu, 9 Apr 2009 07:35:06 -0700 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: Stefan Monnier Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Thu, 09 Apr 2009 14:35:06 +0000 Resent-Message-ID: Resent-Sender: owner@emacsbugs.donarmstrong.com X-Emacs-PR-Message: followup 2833 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by 2833-submit@emacsbugs.donarmstrong.com id=B2833.123928725228182 (code B ref 2833); Thu, 09 Apr 2009 14:35:06 +0000 Original-Received: (at 2833) by emacsbugs.donarmstrong.com; 9 Apr 2009 14:27:32 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-Received: from ironport2-out.teksavvy.com (ironport2-out.teksavvy.com [206.248.154.182]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id n39ERSAr028167 for <2833@emacsbugs.donarmstrong.com>; Thu, 9 Apr 2009 07:27:29 -0700 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ar4FAJOi3UlMCqib/2dsb2JhbACBUs00g3sGhRE X-IronPort-AV: E=Sophos;i="4.40,160,1238990400"; d="scan'208";a="36825206" Original-Received: from 76-10-168-155.dsl.teksavvy.com (HELO pastel.home) ([76.10.168.155]) by ironport2-out.teksavvy.com with ESMTP; 09 Apr 2009 10:27:22 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 537A6804C; Thu, 9 Apr 2009 10:27:22 -0400 (EDT) In-Reply-To: <87fxgicz1b.fsf@cyd.mit.edu> (Chong Yidong's message of "Wed, 08 Apr 2009 22:59:44 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.92 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Resent-Date: Thu, 09 Apr 2009 10:43:59 -0400 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:27025 Archived-At: > The following patch changes the directory local variables code so that > the cache stores the file atime. Before using each cache entry, we > check that against the file modtime. I'm not sure this is the right thing to do: - We don't know that the (float-time) is in sync with the filesystem's time, so the check may not work right. Better check the file's current mtime against the file's mtime when it was last read. - the variable you changed could previously be setq in the .emacs, whereas you changed it into an internal var. FWIW, here's the patch I was working on instead. Stefan --- files.el.~1.1044.~ 2009-04-08 20:09:55.000000000 -0400 +++ files.el 2009-04-09 10:24:53.000000000 -0400 @@ -3314,21 +3314,31 @@ dir-elt) (or locals-file dir-elt)))) +(defvar dir-locals--file-cache nil + "Cache of dir-locals files's contents.") + (defun dir-locals-read-from-file (file) "Load a variables FILE and register a new class and instance. FILE is the name of the file holding the variables to apply. The new class name is the same as the directory in which FILE is found. Returns the new class name." + (let ((mtime (nth 5 (file-attributes file))) + (cache (assoc file dir-locals--file-cache))) + (unless (equal (nth 1 cache) mtime) + (setq dir-locals--file-cache (delq cache dir-locals--file-cache)) + (setq cache nil)) + (if cache + (nth 2 cache) + (let ((val (with-temp-buffer - ;; We should probably store the modtime of FILE and then - ;; reload it whenever it changes. (insert-file-contents file) (let* ((dir-name (file-name-directory file)) (class-name (intern dir-name)) (variables (read (current-buffer)))) (dir-locals-set-class-variables class-name variables) - (dir-locals-set-directory-class dir-name class-name) - class-name))) + class-name)))) + (push (list file mtime val) dir-locals--file-cache) + val)))) (declare-function c-postprocess-file-styles "cc-mode" ())