Merge e00d256889
into f5ff58bb4f
This commit is contained in:
commit
73138bd0cc
49
puml-mode.el
49
puml-mode.el
|
@ -106,14 +106,36 @@
|
|||
(insert msg)
|
||||
(insert "\n"))))))
|
||||
|
||||
(defun puml-plantuml-program-and-args ()
|
||||
"Determines program and args for calling plantuml.
|
||||
Returns a list of two elements:
|
||||
- program name
|
||||
- list of arguments
|
||||
If unable to determine how to call plantuml, does not return."
|
||||
(let ((puml-plantuml-command-path (executable-find "plantuml")))
|
||||
(cond
|
||||
((file-exists-p puml-plantuml-jar-path)
|
||||
(list
|
||||
"java" ;; program
|
||||
(list "-jar" (shell-quote-argument puml-plantuml-jar-path)))) ;; args
|
||||
(puml-plantuml-command-path
|
||||
(list
|
||||
puml-plantuml-command-path ;; program
|
||||
())) ;; args
|
||||
(t
|
||||
(error "Could not find file plantuml.jar at %s nor command
|
||||
plantuml in PATH" puml-plantuml-jar-path)))))
|
||||
|
||||
(defun puml-init ()
|
||||
"Initialize the keywords or builtins from the cmdline language output."
|
||||
(unless (file-exists-p puml-plantuml-jar-path)
|
||||
(error "Could not find plantuml.jar at %s" puml-plantuml-jar-path))
|
||||
(let ((plantuml-program-and-args (puml-plantuml-program-and-args)))
|
||||
(let ((plantuml-program (car plantuml-program-and-args))
|
||||
(plantuml-args (cadr plantuml-program-and-args)))
|
||||
(with-temp-buffer
|
||||
(shell-command (concat "java -jar "
|
||||
(shell-quote-argument puml-plantuml-jar-path)
|
||||
" -charset UTF-8 -language") (current-buffer))
|
||||
(apply 'call-process plantuml-program nil t nil
|
||||
(append plantuml-args (list
|
||||
"-charset" "UTF-8"
|
||||
"-language")))
|
||||
(goto-char (point-min))
|
||||
(let ((found (search-forward ";" nil t))
|
||||
(word "")
|
||||
|
@ -146,7 +168,7 @@
|
|||
puml-plantuml-builtins
|
||||
(split-string
|
||||
(buffer-substring-no-properties pos (point)))))))
|
||||
(setq found (search-forward ";" nil nil)))))))
|
||||
(setq found (search-forward ";" nil nil)))))))))
|
||||
|
||||
(defconst puml-preview-buffer "*PUML Preview*")
|
||||
|
||||
|
@ -207,9 +229,16 @@ default output type for new buffers."
|
|||
(coding-system-for-read (and imagep 'binary))
|
||||
(coding-system-for-write (and imagep 'binary)))
|
||||
|
||||
(let ((ps (start-process "PUML" buf
|
||||
"java" "-jar" (shell-quote-argument puml-plantuml-jar-path)
|
||||
(puml-output-type-opt) "-p")))
|
||||
(let ((plantuml-program-and-args (puml-plantuml-program-and-args)))
|
||||
(let ((plantuml-program (car plantuml-program-and-args))
|
||||
(plantuml-args (cadr plantuml-program-and-args)))
|
||||
|
||||
(let ((ps (apply 'start-process "PUML" buf
|
||||
plantuml-program
|
||||
(append plantuml-args (list
|
||||
(puml-output-type-opt)
|
||||
"-p")))))
|
||||
|
||||
(process-send-region ps (point-min) (point-max))
|
||||
(process-send-eof ps)
|
||||
(set-process-sentinel ps
|
||||
|
@ -224,7 +253,7 @@ default output type for new buffers."
|
|||
(t (switch-to-buffer puml-preview-buffer)))
|
||||
(when imagep
|
||||
(image-mode)
|
||||
(set-buffer-multibyte t)))))))
|
||||
(set-buffer-multibyte t)))))))))
|
||||
|
||||
(unless puml-plantuml-kwdList
|
||||
(puml-init)
|
||||
|
|
Loading…
Reference in New Issue