From 99a40958da2888662b6dcd7093bc788d85cc66dc Mon Sep 17 00:00:00 2001 From: Tassilo Horn Date: Sat, 25 Apr 2009 12:42:03 +0200 Subject: [PATCH] Added some infrastructure --- eclim.el | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 eclim.el diff --git a/eclim.el b/eclim.el new file mode 100644 index 0000000..a44b54f --- /dev/null +++ b/eclim.el @@ -0,0 +1,86 @@ + +;;* Eclim + +(eval-when-compile (require 'cl)) + +;;** Basics + +(defgroup eclim nil + "Interface to the Eclipse IDE." + :group 'tools) + +(defun eclim-executable-find () + (let (file) + (dolist (eclipse-root '("/Applications/eclipse" "/usr/lib/eclipse" + "/usr/local/lib/eclipse")) + (and (file-exists-p (setq file (expand-file-name "plugins" eclipse-root))) + (setq file (car (last (directory-files file t "^org.eclim_")))) + (file-exists-p (setq file (expand-file-name "bin/eclim" file))) + (return file))))) + +(defcustom eclim-executable + (or (executable-find "eclim") (eclim-executable-find)) + "Location of eclim executable." + :group 'eclim + :type 'file) + +(defcustom eclim-auto-save nil + "Determines whether to save the buffer when retrieving completions. +eclim can only complete correctly when the buffer has been +saved." + :group 'eclim + :type '(choice (const :tag "Off" nil) + (const :tag "On" t))) + +(defvar eclim--project-dir nil) +(make-variable-buffer-local 'eclim--project-dir) + +(defvar eclim--project-name nil) +(make-variable-buffer-local 'eclim--project-name) + +(defvar eclim--doc nil) +(make-variable-buffer-local 'eclim--doc) + +(defun eclim--buffer-lines () + (goto-char (point-max)) + (let (lines) + (while (= 0 (forward-line -1)) + (push (buffer-substring-no-properties (line-beginning-position) + (line-end-position)) + lines)) + lines)) + +(defun eclim--call-process (&rest args) + (let ((coding-system-for-read 'utf-8)) + (with-temp-buffer + (if (= 0 (apply 'call-process eclim-executable nil t nil + "-command" args)) + (eclim--buffer-lines) + ;; TODO: A more meaningful error message + (message "Eclim command failed") + nil)))) + +(defun eclim--project-dir () + "Return this file's project root directory." + (or eclim--project-dir + (setq eclim--project-dir + (directory-file-name + (expand-file-name + (locate-dominating-file buffer-file-name ".project")))))) + +(defun eclim--project-name () + (or eclim--project-name + (setq eclim--project-name + (car (cddr (assoc (eclim--project-dir) + (eclim/project-list))))))) + +(defun eclim/project-list () + (mapcar (lambda (line) (nreverse (split-string line " *- *" nil))) + (eclim--call-process "project_list"))) + +(define-minor-mode eclim-mode + "An interface to the Eclipse IDE." + nil + "Eclim" + (eclim--project-name) + ) \ No newline at end of file -- 2.11.4.GIT