emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: files.el: Patch to make project-settings optional/customizable


From: Dan Nicolaescu
Subject: Re: files.el: Patch to make project-settings optional/customizable
Date: Sun, 23 Nov 2008 00:10:06 -0800 (PST)

Stefan Monnier <address@hidden> writes:

  > > I agree it does feel like that, but still, making it a defconst seems
  > > like the tasteful thing to do...
  > 
  > We could make it read-only, like we do for t, nil, :toto, and
  > enable-multibyte-characters.

Or just get rid of the defconst.  Let's look at the code in question:

(defconst dir-locals-file ".dir-locals.el"
  "File that contains directory-local variables.
It has to be constant to enforce uniform values
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 ((locals-file (locate-dominating-file file dir-locals-file))
        (dir-elt nil))
    ;; `locate-dominating-file' may have abbreviated the name.
    (when locals-file
      (setq locals-file (expand-file-name dir-locals-file locals-file)))
    (dolist (elt dir-locals-directory-alist)
      (when (and (eq t (compare-strings file nil (length (car elt))
                                        (car elt) nil nil))
                 (> (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))))

So there are 2 uses .dir-locals.el 3 lines apart in the same 24 lines function.
The defconst adds 4 lines.  It's hard to keep a straight face and claim
that the defconst is a good idea.   
(and the 2 uses could be reduced to a single one if we make
locate-dominating-file return an expanded file name -- which seems to be
a good idea anyway).

It's kind of painful that this discussion is still going on, it should
have never occurred in the first place...




reply via email to

[Prev in Thread] Current Thread [Next in Thread]