all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#19140: dir-locals-collect-variables discrepancy in handling non-file buffers
@ 2014-11-21 16:12 Ivan Shmakov
  2014-12-30 19:45 ` Ivan Shmakov
  0 siblings, 1 reply; 7+ messages in thread
From: Ivan Shmakov @ 2014-11-21 16:12 UTC (permalink / raw)
  To: 19140

[-- Attachment #1: Type: text/plain, Size: 1208 bytes --]

Package:  emacs
Severity: minor

	Please consider the patch MIMEd.

	* 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.)

	The issue I observe is as follows.  First, I create ~/foo and
	~/foo/ru directories, and a ~/foo/.dir-locals.el file like:

((nil
  (ispell-local-dictionary  . "esperanto"))
 ("ru"
  (nil
   (ispell-local-dictionary . "russian"))))

	Then:

(with-temp-buffer
  (cd "~/foo/ru/")
  (hack-dir-local-variables-non-file-buffer)
  ;; .
  dir-local-variables-alist)

	The result is '((ispell-local-dictionary . "esperanto")),
	contrary to the expected '((… . "russian")).

	This does not happen for buffers associated with files:

(with-current-buffer (find-file-noselect "~/foo/ru/bar")
  (hack-dir-local-variables)
  ;; .
  dir-local-variables-alist)

	Reading the code suggests that dir-locals-collect-variables
	fails to handle the (stringp key) case properly when ‘file-name’
	is nil, which is what my patch is intended to fix.

-- 
FSF associate member #7257  np. Conclusion — Apocalyptica    … B6A0 230E 334A

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/diff, Size: 562 bytes --]

--- a/lisp/files.el
+++ b/lisp/files.el
@@ -3567,8 +3569,10 @@
 (defun dir-locals-collect-variables (class-variables root variables)
   "Collect entries from CLASS-VARIABLES into VARIABLES.
 ROOT is the root directory of the project.
 Return the new variables list."
-  (let* ((file-name (buffer-file-name))
+  (let* ((file-name (or (buffer-file-name)
+			;; handle non-file buffers, too
+			default-directory))
 	 (sub-file-name (if file-name
                             ;; FIXME: Why not use file-relative-name?
 			    (substring file-name (length root)))))

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-02-14 21:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-21 16:12 bug#19140: dir-locals-collect-variables discrepancy in handling non-file buffers Ivan Shmakov
2014-12-30 19:45 ` Ivan Shmakov
2015-01-19  7:30   ` Katsumi Yamaoka
2015-01-19  8:55     ` Ivan Shmakov
2015-01-19  9:28       ` Katsumi Yamaoka
2015-01-19  9:55         ` Ivan Shmakov
2015-02-14 21:09           ` Ivan Shmakov

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.