Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keybinding and function to generate image from current buffer #2

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions README.org
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
* README
integrating this project to my org-mode sounds good, i do not need to open either ida or eclipse. (thanks goodness)
but the problem is that i wrote some big uml graphs with more than hundred lines, it became difficult to figure out problems. In addition, to handle``if'' and ``endif'' loop is another troublesome topic. When i have many ``if'' and ``endif'', i always find that i can not figure out where i am. i upgrade this program for those people who has the similar exp. by the way thanks for zwz's work :)
Integrating this project to my org-mode sounds good, I do not need to open
either ida or eclipse. (thanks goodness) But the problem is that I wrote some
big uml graphs with more than hundred lines, it became difficult to figure out
problems. In addition, to handle ``if'' and ``endif'' loop is another
troublesome topic. When I have many ``if'' and ``endif'', I always find that I
can not figure out where I am. I upgrade this program for those people who has
the similar exp. By the way thanks for zwz's work :)

+ fix regexp
+ append keywords
+ indent
support if, endif, note, end note
+ indent support if, endif, note, end note
+ auto-complete
+ generate image from current buffer (C-c C-c)

** TODO-LIST
+ +plantuml-line-indent+
Expand Down
35 changes: 27 additions & 8 deletions plantuml-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
;; Author: Zhang Weize (zwz)
;; wildsoul
;; Maintainer: wildsoul
;; Version: 0.3
;; Version: 0.4
;; Package-Requires: ((auto-complete "1.4"))
;; URL: https://github.com/wildsoul/plantuml-mode
;; Keywords: uml, ascii
Expand Down Expand Up @@ -75,10 +75,31 @@
"Major mode for editing plantuml file."
:group 'languages)

(defun plantuml--check-jar ()
"Checks whether `plantuml-jar-path' exists."
(unless (file-exists-p plantuml-jar-path)
(error "Could not find plantuml.jar at %s" plantuml-jar-path)))

(defun plantuml--create-command (command-args)
(concat "java -jar "
(shell-quote-argument plantuml-jar-path)
" "
command-args))

(defun plantuml-generate-image ()
"Generates image out of current buffer."
(interactive)
(plantuml--check-jar)
(shell-command (plantuml--create-command (buffer-name))))

(defvar plantuml-jar-path nil )
(defvar plantuml-mode-hook nil "Standard hook for plantuml-mode.")
(defvar plantuml-mode-version nil "plantuml-mode version string.")
(defvar plantuml-mode-map nil "Keymap for plantuml-mode")
(defvar plantuml-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "C-c C-c") 'plantuml-generate-image)
map)
"Keymap for plantuml-mode")
(defvar plantuml-indent-regexp-end "^[ \t]*\\(?:@enduml\\|endif\\|end\s+note\\|}\\)")
(defvar plantuml-indent-regexp-start"^[ \t]*\\(?:@startuml\\|\\(?:.*\\)?\s*\\(?:[<>.*a-z-|]+\\)?\s*\\(?:\\[[a-zA-Z]+\\]\\)?\s+if\\|note\s+over\\|note\s+\\(\\(?:\\(?:buttom\\|left\\|right\\|top\\)\\)\\)\\(?:\s+of\\)?\\|\\(?:class\\|enum\\)\s+.*{\\)")
(defvar plantuml-indent-regexp-arrow "^[ \t]*\\(?:\\(?:<\\|<|\\|o\\|\\*\\)\\(?:\\.\\|-\\)\\(?:down\\|up\\|left\\|right\\)?\\(?:\\.\\|-\\)\\|\\(?:-\\|\\.\\)\\(?:down\\|up\\|left\\|right\\)?\\(?:-\\|\\.\\)\\(?:>\\||>\\|\\*\\|o\\)\\)")
Expand Down Expand Up @@ -110,12 +131,9 @@
;;; font-lock
(defun plantuml-init ()
"Initialize the keywords or builtins from the cmdline language output"
(unless (file-exists-p plantuml-jar-path)
(error "Could not find plantuml.jar at %s" plantuml-jar-path))
(plantuml--check-jar)
(with-temp-buffer
(shell-command (concat "java -jar "
(shell-quote-argument plantuml-jar-path)
" -language") (current-buffer))
(shell-command (plantuml--create-command "-language") (current-buffer))
(goto-char (point-min))
(let ((found (search-forward ";" nil nil))
(word "")
Expand Down Expand Up @@ -279,7 +297,8 @@ This affects only the current buffer."
(defun plantuml-mode ()
"Major mode for plantuml.
Shortcuts Command Name
\\[plantuml-complete-symbol] `plantuml-complete-symbol'"
\\[plantuml-complete-symbol] `plantuml-complete-symbol'
\\[plantuml-generate-image] `plantuml-generate-image'"
(interactive)
(kill-all-local-variables)

Expand Down