From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chong Yidong Newsgroups: gmane.emacs.bugs Subject: bug#2833: 23.0.92; Bug in Directory Variables Date: Wed, 08 Apr 2009 22:59:44 -0400 Message-ID: <87fxgicz1b.fsf__3338.94516011259$1239247537$gmane$org@cyd.mit.edu> Reply-To: Chong Yidong , 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 1239247451 5313 80.91.229.12 (9 Apr 2009 03:24:11 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 9 Apr 2009 03:24:11 +0000 (UTC) Cc: 2833@emacsbugs.donarmstrong.com To: emacs-devel@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Apr 09 05:25:30 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 1LrktL-00066J-Up for geb-bug-gnu-emacs@m.gmane.org; Thu, 09 Apr 2009 05:25:28 +0200 Original-Received: from localhost ([127.0.0.1]:54605 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lrkrx-00035Q-6x for geb-bug-gnu-emacs@m.gmane.org; Wed, 08 Apr 2009 23:24:01 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lrkrs-00035L-50 for bug-gnu-emacs@gnu.org; Wed, 08 Apr 2009 23:23:56 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lrkrn-000359-JJ for bug-gnu-emacs@gnu.org; Wed, 08 Apr 2009 23:23:55 -0400 Original-Received: from [199.232.76.173] (port=40512 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lrkrn-000356-Dk for bug-gnu-emacs@gnu.org; Wed, 08 Apr 2009 23:23:51 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:60600) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Lrkrm-0002Ff-UA for bug-gnu-emacs@gnu.org; Wed, 08 Apr 2009 23:23:51 -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 n393Nnwg003500; Wed, 8 Apr 2009 20:23:49 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.13.8/8.13.8/Submit) id n39356Q2029897; Wed, 8 Apr 2009 20:05:06 -0700 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: Chong Yidong Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Thu, 09 Apr 2009 03:05: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.123924588627223 (code B ref 2833); Thu, 09 Apr 2009 03:05:06 +0000 Original-Received: (at 2833) by emacsbugs.donarmstrong.com; 9 Apr 2009 02:58:06 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-Received: from cyd.mit.edu (CYD.MIT.EDU [18.115.2.24]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id n392w26b027205 for <2833@emacsbugs.donarmstrong.com>; Wed, 8 Apr 2009 19:58:04 -0700 Original-Received: by cyd.mit.edu (Postfix, from userid 1000) id DAB5C57E247; Wed, 8 Apr 2009 22:59:44 -0400 (EDT) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Resent-Date: Wed, 08 Apr 2009 23:23:55 -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:27017 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. This is not an ideal time to make changes of this sort, but I think this problem (i.e., inability to detect changes in .dir-locals.el files) is quite a serious one. So please help me review this patch. *** trunk/lisp/files.el.~1.1044.~ 2009-04-08 10:42:40.000000000 -0400 --- trunk/lisp/files.el 2009-04-08 22:50:03.000000000 -0400 *************** *** 3187,3194 **** (defvar dir-locals-class-alist '() "Alist mapping class names (symbols) to variable lists.") ! (defvar dir-locals-directory-alist '() ! "Alist mapping directory roots to variable classes.") (defsubst dir-locals-get-class-variables (class) "Return the variable list for CLASS." --- 3187,3199 ---- (defvar dir-locals-class-alist '() "Alist mapping class names (symbols) to variable lists.") ! (defvar dir-locals-directory-cache '() ! "List of cached directory roots for directory-local variable files. ! Each element in this list has the form (DIR ATIME CLASS), where ! DIR is the name of the directory, ATIME is the time when this ! cache entry was created (as a floating point number, per ! `float-time'), and CLASS is the name of a project class (a ! symbol).") (defsubst dir-locals-get-class-variables (class) "Return the variable list for CLASS." *************** *** 3241,3247 **** (setq directory (file-name-as-directory (expand-file-name directory))) (unless (assq class dir-locals-class-alist) (error "No such class `%s'" (symbol-name class))) ! (push (cons directory class) dir-locals-directory-alist)) (defun dir-locals-set-class-variables (class variables) "Map the type CLASS to a list of variable settings. --- 3246,3252 ---- (setq directory (file-name-as-directory (expand-file-name directory))) (unless (assq class dir-locals-class-alist) (error "No such class `%s'" (symbol-name class))) ! (push (list directory (float-time) class) dir-locals-directory-cache)) (defun dir-locals-set-class-variables (class variables) "Map the type CLASS to a list of variable settings. *************** *** 3284,3295 **** across different environments and users.") (defun dir-locals-find-file (file) ! "Find the directory-local variables FILE. ! This searches upward in the directory tree. ! If a local variables file is found, the file name is returned. ! If the file is already registered, a cons from ! `dir-locals-directory-alist' is returned. ! Otherwise this returns nil." (setq file (expand-file-name file)) (let* ((dir-locals-file-name (if (eq system-type 'ms-dos) --- 3289,3304 ---- across different environments and users.") (defun dir-locals-find-file (file) ! "Find the directory-local variables for FILE. ! This searches upward in the directory tree from FILE. ! ! If the file is already registered and has not been modified since ! we added it to `dir-locals-directory-cache', this returns a cons ! cell of the form (DIRECTORY . CLASS), using the entry in ! `dir-locals-directory-cache'. ! Otherwise, if a local variables file is found, the file name is ! returned. ! Otherwise, this returns nil." (setq file (expand-file-name file)) (let* ((dir-locals-file-name (if (eq system-type 'ms-dos) *************** *** 3300,3318 **** ;; `locate-dominating-file' may have abbreviated the name. (when locals-file (setq locals-file (expand-file-name dir-locals-file-name locals-file))) ! (dolist (elt dir-locals-directory-alist) (when (and (eq t (compare-strings file nil (length (car elt)) (car elt) nil nil (memq system-type '(windows-nt cygwin ms-dos)))) (> (length (car elt)) (length (car dir-elt)))) (setq dir-elt elt))) ! (if (and locals-file dir-elt) ! (if (> (length (file-name-directory locals-file)) ! (length (car dir-elt))) ! locals-file ! dir-elt) ! (or locals-file dir-elt)))) (defun dir-locals-read-from-file (file) "Load a variables FILE and register a new class and instance. --- 3309,3338 ---- ;; `locate-dominating-file' may have abbreviated the name. (when locals-file (setq locals-file (expand-file-name dir-locals-file-name locals-file))) ! ;; Find the best cached value in `dir-locals-directory-cache'. ! (dolist (elt dir-locals-directory-cache) (when (and (eq t (compare-strings file nil (length (car elt)) (car elt) nil nil (memq system-type '(windows-nt cygwin ms-dos)))) (> (length (car elt)) (length (car dir-elt)))) (setq dir-elt elt))) ! (let ((use-cache (and dir-elt ! (or (null locals-file) ! (<= (length (file-name-directory locals-file)) ! (length (car dir-elt))))))) ! (if use-cache ! ;; Check the validity of the cache. ! (if (and (file-readable-p (car dir-elt)) ! (< (float-time (nth 5 (file-attributes (car dir-elt)))) ! (nth 1 dir-elt))) ! ;; This cache entry is OK. ! (cons (nth 0 dir-elt) (nth 2 dir-elt)) ! ;; This cache entry is invalid; clear it. ! (setq dir-locals-directory-cache ! (delq dir-elt dir-locals-directory-cache)) ! locals-file) ! locals-file)))) (defun dir-locals-read-from-file (file) "Load a variables FILE and register a new class and instance.