From: Nikolaj Schumacher Date: Mon, 20 Apr 2009 12:00:56 +0000 (+0200) Subject: Added Windows root dir compatibility fixes. X-Git-Url: https://code.delx.au/gnu-emacs-elpa/commitdiff_plain/d503ff5fd70d310d5e71ae21f2ba8568d293b2f1 Added Windows root dir compatibility fixes. --- diff --git a/company-eclim.el b/company-eclim.el index a3c32a6d5..4b8a5c94c 100644 --- a/company-eclim.el +++ b/company-eclim.el @@ -74,23 +74,11 @@ eclim can only complete correctly when the buffer has been saved." (mapcar (lambda (line) (nreverse (split-string line " *- *" nil))) (company-eclim--call-process "project_list"))) -(defun company-eclim--locate-dominating-file (file name) - (catch 'root - (let ((dir (file-name-directory buffer-file-name))) - (while (not (equal dir "/")) - (when (file-exists-p (expand-file-name name dir)) - (throw 'root dir)) - (setq dir (file-name-directory (directory-file-name dir))))))) - (defun company-eclim--project-dir () (if (eq company-eclim--project-dir 'unknown) (setq company-eclim--project-dir (directory-file-name - (if (fboundp 'locate-dominating-file) - (expand-file-name (locate-dominating-file buffer-file-name - ".project")) - (company-eclim--locate-dominating-file buffer-file-name - ".project")))) + (company-locate-dominating-file buffer-file-name ".project"))) company-eclim--project-dir)) (defun company-eclim--project-name () diff --git a/company-etags.el b/company-etags.el index ac9da5701..a5080cdea 100644 --- a/company-etags.el +++ b/company-etags.el @@ -36,16 +36,11 @@ buffer automatically." (make-variable-buffer-local 'company-etags-buffer-table) (defun company-etags-find-table () - (let ((dir (if buffer-file-name - (file-name-directory buffer-file-name) - (expand-file-name default-directory))) - file) - (while (not (or file (equal dir "/"))) - (unless (file-exists-p (setq file (expand-file-name "TAGS" dir))) - (setq file nil - dir (file-name-directory (directory-file-name dir))))) + (let ((file (company-locate-dominating-file (or buffer-file-name + default-directory) + "TAGS"))) (when file - (list file)))) + (list (expand-file-name file))))) (defun company-etags-buffer-table () (or (and company-etags-use-main-table-list tags-table-list) diff --git a/company-xcode.el b/company-xcode.el index e2e3be320..df76a5782 100644 --- a/company-xcode.el +++ b/company-xcode.el @@ -79,9 +79,11 @@ valid in most contexts." (let ((dir (if buffer-file-name (file-name-directory buffer-file-name) (expand-file-name default-directory))) + (prev-dir nil) file) - (while (not (or file (equal dir "/"))) + (while (not (or file (equal dir prev-dir))) (setq file (car (directory-files dir t ".xcodeproj\\'" t)) + prev-dir dir dir (file-name-directory (directory-file-name dir)))) file)) diff --git a/company.el b/company.el index 8ea671168..d3caee658 100644 --- a/company.el +++ b/company.el @@ -69,6 +69,8 @@ ;; ;;; Change Log: ;; +;; Windows compatibility fixes. +;; ;; 2009-04-19 (0.4.1) ;; Added `global-company-mode'. ;; Performance enhancements. @@ -633,6 +635,18 @@ keymap during active completions (`company-active-map'): (car (setq ppss (cdr ppss))) (nth 3 ppss)))) +(if (fboundp 'locate-dominating-file) + (defalias 'company-locate-dominating-file 'locate-dominating-file) + (defun company-locate-dominating-file (file name) + (catch 'root + (let ((dir (file-name-directory file)) + (prev-dir nil)) + (while (not (equal dir prev-dir)) + (when (file-exists-p (expand-file-name name dir)) + (throw 'root dir)) + (setq prev-dir dir + dir (file-name-directory (directory-file-name dir)))))))) + (defun company-call-backend (&rest args) (if (functionp company-backend) (apply company-backend args)