4 (eval-when-compile (require 'cl
))
9 "Interface to the Eclipse IDE."
12 (defun eclim-executable-find ()
14 (dolist (eclipse-root '("/Applications/eclipse" "/usr/lib/eclipse"
15 "/usr/local/lib/eclipse"))
16 (and (file-exists-p (setq file
(expand-file-name "plugins" eclipse-root
)))
17 (setq file
(car (last (directory-files file t
"^org.eclim_"))))
18 (file-exists-p (setq file
(expand-file-name "bin/eclim" file
)))
21 (defcustom eclim-executable
22 (or (executable-find "eclim") (eclim-executable-find))
23 "Location of eclim executable."
27 (defcustom eclim-auto-save nil
28 "Determines whether to save the buffer when retrieving completions.
29 eclim can only complete correctly when the buffer has been
32 :type
'(choice (const :tag
"Off" nil
)
35 (defvar eclim--project-dir nil
)
36 (make-variable-buffer-local 'eclim--project-dir
)
38 (defvar eclim--project-name nil
)
39 (make-variable-buffer-local 'eclim--project-name
)
41 (defvar eclim--doc nil
)
42 (make-variable-buffer-local 'eclim--doc
)
44 (defun eclim--buffer-lines ()
45 (goto-char (point-max))
47 (while (= 0 (forward-line -
1))
48 (push (buffer-substring-no-properties (line-beginning-position)
53 (defun eclim--call-process (&rest args
)
54 (let ((coding-system-for-read 'utf-8
))
56 (if (= 0 (apply 'call-process eclim-executable nil t nil
59 ;; TODO: A more meaningful error message
60 (message "Eclim command failed")
63 (defun eclim--project-dir ()
64 "Return this file's project root directory."
65 (or eclim--project-dir
66 (setq eclim--project-dir
69 (locate-dominating-file buffer-file-name
".project"))))))
71 (defun eclim--project-name ()
72 (or eclim--project-name
73 (setq eclim--project-name
74 (car (cddr (assoc (eclim--project-dir)
75 (eclim/project-list
)))))))
77 (defun eclim/project-list
()
78 (mapcar (lambda (line) (nreverse (split-string line
" *- *" nil
)))
79 (eclim--call-process "project_list")))
81 (define-minor-mode eclim-mode
82 "An interface to the Eclipse IDE."