GNU bug report logs - #19140
dir-locals-collect-variables discrepancy in handling non-file buffers

Previous Next

Package: emacs;

Reported by: Ivan Shmakov <ivan <at> siamics.net>

Date: Fri, 21 Nov 2014 16:14:02 UTC

Severity: minor

Tags: patch

Fixed in version 25.1

Done: Ivan Shmakov <ivan <at> siamics.net>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Ivan Shmakov <ivan <at> siamics.net>
To: 19140 <at> debbugs.gnu.org
Subject: bug#19140: dir-locals-collect-variables discrepancy in handling non-file buffers 
Date: Mon, 19 Jan 2015 08:55:43 +0000
[Message part 1 (text/plain, inline)]
>>>>> Katsumi Yamaoka <yamaoka <at> jpl.org> writes:
>>>>> On Tue, 30 Dec 2014 19:45:57 +0000, Ivan Shmakov wrote:

[…]

 >> * lisp/files.el (dir-locals-collect-variables): Use
 >> default-directory in place of the file name while working on
 >> non-file buffers (as hack-dir-local-variables already does.)

 > After this change, I got to get unknown errors[1] when building
 > Ma Gnus.  To reproduce the same result, try the following in the
 > Emacs source tree:

 > % cd lisp/gnus 
 > % emacs -batch -Q --eval FORM 

 > where FORM is:

 > '(with-temp-buffer (let ((default-directory (expand-file-name ".")))
 > (insert-file-contents "./auth-source.el") (hack-local-variables)))'

 > And you will see

 > (args-out-of-range "/DIR/emacs/lisp/gnus" 21 nil)

 > or something similar (where 21 is 1+ the number of letters of the dir
 > name).

 > The FORM above is what `custom-make-dependencies' does.

	ACK, thanks.  Indeed, this change assumes that the result for
	(expand-file-name default-directory) ends with a ‘/’, yet that’s
	only the case when default-directory itself ends with a ‘/’,
	which I believe it should; consider, e. g.:

(defun cd-absolute (dir)
  "Change current directory to given absolute file name DIR."
  ;; Put the name into directory syntax now,
  ;; because otherwise expand-file-name may give some bad results.
  (setq dir (file-name-as-directory dir))
  …)

	The issue at hand could be solved by using the first of the
	patches MIMEd.  However, I believe that such a change may easily
	mask bugs in the other parts of the code, so the proper solution
	would probably be a fix to custom-make-dependencies, as per the
	second patch MIMEd.

	Could you please check if both indeed resolve the issue at hand?

	TIA.

[…]

-- 
FSF associate member #7257  http://boycottsystemd.org/  … 3013 B6A0 230E 334A
[Message part 2 (text/diff, inline)]
--- a/lisp/files.el	2015-01-17 19:02:00 +0000
+++ b/lisp/files.el
@@ -3604,7 +3604,8 @@ defun dir-locals-collect-variables (class-variables root variables)
 Return the new variables list."
   (let* ((file-name (or (buffer-file-name)
 			;; Handle non-file buffers, too.
-			(expand-file-name default-directory)))
+			(file-name-as-directory
+			 (expand-file-name default-directory))))
 	 (sub-file-name (if file-name
                             ;; FIXME: Why not use file-relative-name?
 			    (substring file-name (length root)))))
[Message part 3 (text/diff, inline)]
--- a/lisp/cus-dep.el	2015-01-01 22:26:41 +0000
+++ b/lisp/cus-dep.el	2015-01-19 08:49:23 +0000
@@ -62,7 +62,8 @@ defun custom-make-dependencies ()
       (while (setq subdir (pop command-line-args-left))
         (message "Directory %s" subdir)
         (let ((files (directory-files subdir nil "\\`[^=.].*\\.el\\'"))
-              (default-directory (expand-file-name subdir))
+              (default-directory
+		(file-name-as-directory (expand-file-name subdir)))
               (preloaded (concat "\\`\\(\\./+\\)?"
                                  (regexp-opt preloaded-file-list t)
                                  "\\.el\\'")))

This bug report was last modified 10 years and 100 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.