Skip to content

Commit

Permalink
change to minor-mode
Browse files Browse the repository at this point in the history
  • Loading branch information
mopemope committed Sep 12, 2016
1 parent 751365b commit a0573c3
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 37 deletions.
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Meghanada-Mode

## A Java Develop Environment for Emacs
## A Better Java Development Environment for Emacs

`meghanada` is a new java-mode (`meghanada-mode`) that aims at improving the editing
experience for the Java. It works by using a combination of an Emacs
Expand All @@ -25,6 +25,7 @@ package and [meghanada-server][].

## Dependencies

Meghanada-Mode has been developed Emacs 24.5.

### Elisp dependencies

Expand Down Expand Up @@ -55,21 +56,18 @@ TODO install from melpa

```
(require 'meghanada)
(add-hook 'meghanada-mode-hook
(add-hook 'java-mode-hook
(lambda ()
;; customize
(setq company-transformers '(company-sort-by-backend-importance))
;; meghanada-mode on
(meghanada-mode t)
(add-hook 'before-save-hook 'delete-trailing-whitespace)))
(add-to-list 'auto-mode-alist '("\\.java\\'" . meghanada-mode))
```

### Meghanada-Server

To do so, type `M-x meghanada-install-server RET`. Server program is installed `~/.meghanada/meghanada.jar`.

If you open java file and set major-mode `meghanada-mode`, [meghanada-server][] process autostart and connect to your emacs.
If you open java file and set `meghanada-mode`, [meghanada-server][] process start automatically and connect to your emacs.

## Usage

Expand Down
21 changes: 10 additions & 11 deletions company-meghanada.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; company-meghanada.el --- Company support for Meganada -*- coding: utf-8; lexical-binding: t; -*-
;;; company-meghanada.el --- Company support for meganada -*- coding: utf-8; lexical-binding: t; -*-

;; Copyright (C) 2016 Yutaka Matsubara
;; License: http://www.gnu.org/licenses/gpl.html
Expand Down Expand Up @@ -84,7 +84,6 @@
(save-excursion
(backward-list)
(forward-char -1)
(message (format "%s" (meghanada--what-word)))
(get-text-property (point) 'return-type)))

(defun meghanada--grab-symbol-cons ()
Expand Down Expand Up @@ -199,7 +198,7 @@

(defun company-meghanada (command &optional arg &rest ignored)
(case command
(prefix (and (derived-mode-p 'meghanada-mode)
(prefix (and (meghanada-alive-p)
(not (company-in-string-or-comment))
(not (company-meghanada--in-num-literal-p))
(or (company-meghanada--prefix) 'stop)))
Expand All @@ -214,15 +213,15 @@
(post-completion
(company-meghanada--post-completion arg))))

(defun meghanada-grab-symbol-test ()
(interactive)
(message (format "%s" (meghanad--grab-symbol-cons))))
;; (defun meghanada-grab-symbol-test ()
;; (interactive)
;; (message (format "%s" (meghanad--grab-symbol-cons))))

(defun meghanada-prop-test ()
(interactive)
(let ((pos (next-property-change (point))))
(goto-char pos)
(message (format "prop:%s" (get-text-property (point) 'return-type)))))
;; (defun meghanada-prop-test ()
;; (interactive)
;; (let ((pos (next-property-change (point))))
;; (goto-char pos)
;; (message (format "prop:%s" (get-text-property (point) 'return-type)))))

(provide 'company-meghanada)

Expand Down
2 changes: 1 addition & 1 deletion flycheck-meghanada.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; flycheck-meghanada.el --- Flycheck support for Meghanada -*- coding: utf-8; lexical-binding: t -*-
;;; flycheck-meghanada.el --- Flycheck support for meghanada -*- coding: utf-8; lexical-binding: t -*-

;; Copyright (C) 2016 Yutaka Matsubara
;; License: http://www.gnu.org/licenses/gpl.html
Expand Down
55 changes: 38 additions & 17 deletions meghanada.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; meghanada.el --- A better new java-mode -*- coding: utf-8; lexical-binding: t; -*-
;;; meghanada.el --- A better java development mode -*- coding: utf-8; lexical-binding: t; -*-

;; Copyright (C) 2016 Yutaka Matsubara
;; License: http://www.gnu.org/licenses/gpl.html
Expand Down Expand Up @@ -62,7 +62,12 @@
:type 'boolean)

(defcustom meghanada-use-flycheck t
"If true, diagnostics report with flyecheck is denabled."
"If true, diagnostics report with flyecheck is enabled."
:group 'meghanada
:type 'boolean)

(defcustom meghanada-auto-start t
"If true, meghanada-server start automatically."
:group 'meghanada
:type 'boolean)

Expand Down Expand Up @@ -245,10 +250,10 @@
:noquery t
:sentinel 'meghanada--client-process-sentinel
:filter 'meghanada--client-process-filter))
(buffer-disable-undo meghanada--client-buffer)
(message "Meghanada Ready")
(setq meghanada--task-client-process (meghanada--start-task-client-process))
process))
(buffer-disable-undo meghanada--client-buffer)
(message "Meghanada Ready")
(setq meghanada--task-client-process (meghanada--start-task-client-process))
process))

(defun meghanada--start-task-client-process ()
"TODO: FIX DOC ."
Expand Down Expand Up @@ -291,7 +296,7 @@
"TODO: FIX DOC PROCESS EVENT."
(unless (process-live-p process)
(setq meghanada--task-client-process nil)
(message "meghanada-client process stopped")))
(message "meghanada-task-client process stopped")))

(defun meghanada--process-client-response (process response)
"TODO: FIX DOC PROCESS RESPONSE ."
Expand Down Expand Up @@ -418,7 +423,8 @@

(defun meghanada-alive-p ()
"TODO: FIX DOC ."
(and meghanada--client-process (process-live-p meghanada--client-process)))
(and meghanada--client-process
(process-live-p meghanada--client-process)))

;;
;; import
Expand Down Expand Up @@ -833,20 +839,35 @@
(let ((map (make-sparse-keymap)))
;; TODO default keymap
map)
"Keymap of Meghanada interactive commands.")
"Keymap for Meghanada-mode.")

;;;###autoload
(define-derived-mode meghanada-mode java-mode "MEGHANADA"
"Major mode for java delopment."
(when meghanada-use-company
(meghanada-company-enable))
(when meghanada-use-flycheck
(meghanada-flycheck-enable))
(meghanada-client-connect))

(define-minor-mode meghanada-mode
"A better java development mode for Emacs (minor-mode).
\\{meghanada-mode-map}"
nil
nil
meghanada-mode-map
(progn
(when meghanada-use-company
(meghanada-company-enable))
(when meghanada-use-flycheck
(meghanada-flycheck-enable))
(when meghanada-auto-start
(meghanada-client-connect))))

(remove-hook 'java-mode-hook 'wisent-java-default-setup)

(add-to-list 'minor-mode-alist
'(meghanada-mode (:eval (meghanada-modeline-string))))

(defun meghanada-modeline-string ()
"Return modeline string."
(cond ((not (meghanada-alive-p))
"MEGHANADA:Disconnected")
((meghanada-alive-p)
"MEGHANADA")))

(provide 'meghanada)

;;; meghanada.el ends here

0 comments on commit a0573c3

Please sign in to comment.