comparison lisp/files.el @ 99531:bdd322f177a6

(project-settings-file): New variable. (project-find-settings-file): Use it, instead of hardcoding .dir.settings.el.
author Chong Yidong <cyd@stupidchicken.com>
date Thu, 13 Nov 2008 15:17:48 +0000
parents 2d4e1b33ab5c
children 53e1b713e51f
comparison
equal deleted inserted replaced
99530:0c311ab3d969 99531:bdd322f177a6
3200 (let ((elt (assq class project-class-alist))) 3200 (let ((elt (assq class project-class-alist)))
3201 (if elt 3201 (if elt
3202 (setcdr elt list) 3202 (setcdr elt list)
3203 (push (cons class list) project-class-alist)))) 3203 (push (cons class list) project-class-alist))))
3204 3204
3205 (defcustom project-settings-file ".dir-settings.el"
3206 "Settings file for per-project settings. Set this to nil if you dont want to load project-specific settings."
3207 :type '(choice
3208 (const :tag "Ignore" nil)
3209 (file :tag "File"))
3210 :group 'files)
3211
3205 (defun project-find-settings-file (file) 3212 (defun project-find-settings-file (file)
3206 "Find the settings file for FILE. 3213 "Find the settings file for FILE.
3207 This searches upward in the directory tree. 3214 This searches upward in the directory tree.
3208 If a settings file is found, the file name is returned. 3215 If a settings file is found, the file name is returned.
3209 If the file is in a registered project, a cons from 3216 If the file is in a registered project, a cons from
3210 `project-directory-alist' is returned. 3217 `project-directory-alist' is returned.
3211 Otherwise this returns nil." 3218 Otherwise this returns nil."
3212 (setq file (expand-file-name file)) 3219 (when project-settings-file
3213 (let* ((settings (locate-dominating-file file ".dir-settings.el")) 3220 (setq file (expand-file-name file))
3214 (pda nil)) 3221 (let* ((settings (locate-dominating-file file project-settings-file))
3215 ;; `locate-dominating-file' may have abbreviated the name. 3222 (pda nil))
3216 (if settings (setq settings (expand-file-name ".dir-settings.el" settings))) 3223 ;; `locate-dominating-file' may have abbreviated the name.
3217 (dolist (x project-directory-alist) 3224 (if settings (setq settings (expand-file-name ".dir-settings.el" settings)))
3218 (when (and (eq t (compare-strings file nil (length (car x)) 3225 (dolist (x project-directory-alist)
3219 (car x) nil nil)) 3226 (when (and (eq t (compare-strings file nil (length (car x))
3220 (> (length (car x)) (length (car pda)))) 3227 (car x) nil nil))
3221 (setq pda x))) 3228 (> (length (car x)) (length (car pda))))
3222 (if (and settings pda) 3229 (setq pda x)))
3223 (if (> (length (file-name-directory settings)) 3230 (if (and settings pda)
3224 (length (car pda))) 3231 (if (> (length (file-name-directory settings))
3225 settings pda) 3232 (length (car pda)))
3226 (or settings pda)))) 3233 settings pda)
3234 (or settings pda)))))
3227 3235
3228 (defun project-define-from-project-file (settings-file) 3236 (defun project-define-from-project-file (settings-file)
3229 "Load a settings file and register a new project class and instance. 3237 "Load a settings file and register a new project class and instance.
3230 SETTINGS-FILE is the name of the file holding the settings to apply. 3238 SETTINGS-FILE is the name of the file holding the settings to apply.
3231 The new class name is the same as the directory in which SETTINGS-FILE 3239 The new class name is the same as the directory in which SETTINGS-FILE