]> code.delx.au - gnu-emacs-elpa/blobdiff - company-eclim.el
Bumped copyright years.
[gnu-emacs-elpa] / company-eclim.el
index 96573e3f61e27b739100d82aa79869fae2b9cd68..97487fc69f97525e696cc58cb1aef06612fe2744 100644 (file)
@@ -1,8 +1,8 @@
 ;;; company-eclim.el --- a company-mode completion back-end for eclim.
 ;;
-;; Copyright (C) 2009 Nikolaj Schumacher
+;; Copyright (C) 2009-2010 Nikolaj Schumacher
 ;;
-;; This file is part of company 0.4.2.
+;; This file is part of company 0.4.3.
 ;;
 ;; This program is free software; you can redistribute it and/or
 ;; modify it under the terms of the GNU General Public License
@@ -35,7 +35,7 @@
   :group 'company
   :type 'file)
 
-(defcustom company-eclim-auto-save nil
+(defcustom company-eclim-auto-save t
   "*Determines whether to save the buffer when retrieving completions.
 eclim can only complete correctly when the buffer has been saved."
   :group 'company
@@ -62,12 +62,14 @@ eclim can only complete correctly when the buffer has been saved."
     lines))
 
 (defun company-eclim--call-process (&rest args)
-  (let ((coding-system-for-read 'utf-8))
+  (let ((coding-system-for-read 'utf-8)
+        res)
     (with-temp-buffer
-      (if (= 0 (apply 'call-process company-eclim-executable nil t nil
-                      "-command" args))
+      (if (= 0 (setq res (apply 'call-process company-eclim-executable nil t nil
+                                "-command" args)))
           (company-eclim--buffer-lines)
-        (message "Company-eclim command failed")
+        (message "Company-eclim command failed with error %d:\n%s" res
+                 (buffer-substring (point-min) (point-max)))
         nil))))
 
 (defun company-eclim--project-list ()
@@ -78,7 +80,8 @@ eclim can only complete correctly when the buffer has been saved."
   (if (eq company-eclim--project-dir 'unknown)
       (setq company-eclim--project-dir
             (directory-file-name
-             (company-locate-dominating-file buffer-file-name ".project")))
+             (expand-file-name
+              (company-locate-dominating-file buffer-file-name ".project"))))
     company-eclim--project-dir))
 
 (defun company-eclim--project-name ()
@@ -94,7 +97,8 @@ eclim can only complete correctly when the buffer has been saved."
                                           (company-eclim--project-dir)))
         (project-name (company-eclim--project-name)))
     (when company-eclim-auto-save
-      (save-buffer)
+      (when (buffer-modified-p)
+        (basic-save-buffer))
       ;; FIXME: Sometimes this isn't finished when we complete.
       (company-eclim--call-process "java_src_update"
                                   "-p" (company-eclim--project-name)