From 9c50cd7103e490f186beeedc1fe0e3df691e0b11 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 22 Oct 2016 14:15:22 -0500 Subject: [PATCH 1/8] Replaced shell-command with call-process. this fixes a couple issues: (1) when the mode is first loaded and plantuml-init is executed, Emacs window is split into two, which is not necessary. (2) under cygwin emacs and windows native Java combination, shell-quote-argument is cauisng file path format change and making Java unable to load jar file. file-exists-p is also skipped if cygwin emacs is running. --- plantuml-mode.el | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/plantuml-mode.el b/plantuml-mode.el index 6947bcd..48cf1a4 100644 --- a/plantuml-mode.el +++ b/plantuml-mode.el @@ -79,16 +79,12 @@ (defcustom plantuml-suppress-deprecation-warning t "To silence the deprecation warning when `puml-mode' is found upon loading.") -(defun plantuml-command-line () - "Compose the PlantUML command line as a string." - (mapconcat 'identity (cons plantuml-java-command plantuml-java-args) " ")) - (defun plantuml-render-command (&rest arguments) "Create a command line to execute PlantUML with arguments (as ARGUMENTS)." - (let ((cmd (concat (plantuml-command-line) " " (shell-quote-argument plantuml-jar-path))) - (argstring (mapconcat 'identity arguments " "))) - (plantuml-debug (format "Command is %s" cmd)) - (concat cmd " " argstring))) + (let* ((cmd-list (append plantuml-java-args (list plantuml-jar-path) arguments)) + (cmd (mapconcat 'identity cmd-list "|"))) + (plantuml-debug (format "Command is [%s]" cmd)) + cmd-list)) ;;; syntax table (defvar plantuml-mode-syntax-table @@ -134,11 +130,12 @@ (defun plantuml-init () "Initialize the keywords or builtins from the cmdline language output." - (unless (file-exists-p plantuml-jar-path) + (unless (or (eq system-type 'cygwin) (file-exists-p plantuml-jar-path)) (error "Could not find plantuml.jar at %s" plantuml-jar-path)) (with-temp-buffer - (let ((cmd (plantuml-render-command "-charset UTF-8 -language"))) - (shell-command cmd (current-buffer)) + (let ((cmd-args (append (list plantuml-java-command nil t nil) + (plantuml-render-command "-charset" "UTF-8" "-language")))) + (apply 'call-process cmd-args) (goto-char (point-min))) (let ((found (search-forward ";" nil t)) (word "") From 9c509f879dd16bce7d8b49853dc6fc5e375a60af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20M=C3=BCller?= Date: Wed, 26 Oct 2016 01:03:37 +0200 Subject: [PATCH 2/8] Add plantuml-preview-current-block Add a function that allows to preview the current block. The current block is defined to be the region beginning at previous "@startuml" and ending at "@enduml". The prefix argument is handled according to the existing prview functions. --- plantuml-mode.el | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/plantuml-mode.el b/plantuml-mode.el index 6947bcd..c803e9c 100644 --- a/plantuml-mode.el +++ b/plantuml-mode.el @@ -278,6 +278,18 @@ Uses prefix (as PREFIX) to choose where to display it: (region-beginning) (region-end)) "\n@enduml"))) +(defun plantuml-preview-current-block (prefix) + "Preview diagram from the PlantUML sources from the previous @startuml to the next @enduml. +Uses prefix (as PREFIX) to choose where to display it: +- 4 (when prefixing the command with C-u) -> new window +- 16 (when prefixing the command with C-u C-u) -> new frame. +- else -> new buffer" + (interactive "p") + (save-restriction + (narrow-to-region + (search-backward "@startuml") (search-forward "@enduml")) + (plantuml-preview-buffer prefix))) + (defun plantuml-preview (prefix) "Preview diagram from the PlantUML sources. Uses the current region if one is active, or the entire buffer otherwise. From 0cfd6d9e3830c33bfaf144ffef86f30642e03749 Mon Sep 17 00:00:00 2001 From: Andrew Lyu Date: Fri, 28 Oct 2016 12:13:24 +0800 Subject: [PATCH 3/8] Remove duplicate rows --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 207e7f2..efbd62c 100644 --- a/README.md +++ b/README.md @@ -33,11 +33,10 @@ Also, to enable preview you need to tell `plantuml-mode` where to locate the Pla # Enable the major mode -You can automatically enable `plantuml-mode` for files with extension `.plantuml` or `plantuml` by adding the following to your `.emacsrc`: +You can automatically enable `plantuml-mode` for files with extension `.plantuml` by adding the following to your `.emacsrc`: ;; Enable plantuml-mode for PlantUML files (add-to-list 'auto-mode-alist '("\\.plantuml\\'" . plantuml-mode)) - (add-to-list 'auto-mode-alist '("\\.plantuml\\'" . plantuml-mode)) Of course, you can always enable manually the major mode by typing `M-x plantuml-mode` once in the desired PlantUML file buffer. From 5629fe1ce7d16b6c4dead16587865c1f009d40b4 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 22 Oct 2016 09:13:52 -0500 Subject: [PATCH 4/8] Fixed regexp match pattern to truely match suffixes .plantuml .pum .plu. --- plantuml-mode.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plantuml-mode.el b/plantuml-mode.el index c803e9c..45c3350 100644 --- a/plantuml-mode.el +++ b/plantuml-mode.el @@ -361,7 +361,7 @@ Uses prefix (as PREFIX) to choose where to display it: (message "Making completion list...%s" "done"))))) ;;;###autoload -(add-to-list 'auto-mode-alist '("\\.(plantuml\\|pum\\|plantuml\\|plu)\\'" . plantuml-mode)) +(add-to-list 'auto-mode-alist '("\\.\\(plantuml\\|pum\\|plu\\)\\'" . plantuml-mode)) ;;;###autoload (define-derived-mode plantuml-mode prog-mode "plantuml" From f43e67b091acb8c8c389b60960ade0d2a417b8dd Mon Sep 17 00:00:00 2001 From: Andrew Lyu Date: Fri, 28 Oct 2016 12:13:24 +0800 Subject: [PATCH 5/8] Remove duplicate rows --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 207e7f2..efbd62c 100644 --- a/README.md +++ b/README.md @@ -33,11 +33,10 @@ Also, to enable preview you need to tell `plantuml-mode` where to locate the Pla # Enable the major mode -You can automatically enable `plantuml-mode` for files with extension `.plantuml` or `plantuml` by adding the following to your `.emacsrc`: +You can automatically enable `plantuml-mode` for files with extension `.plantuml` by adding the following to your `.emacsrc`: ;; Enable plantuml-mode for PlantUML files (add-to-list 'auto-mode-alist '("\\.plantuml\\'" . plantuml-mode)) - (add-to-list 'auto-mode-alist '("\\.plantuml\\'" . plantuml-mode)) Of course, you can always enable manually the major mode by typing `M-x plantuml-mode` once in the desired PlantUML file buffer. From 68e5e5258475d39a1dd989286c304923c4b56d1f Mon Sep 17 00:00:00 2001 From: Andrew Lyu Date: Fri, 28 Oct 2016 12:13:24 +0800 Subject: [PATCH 6/8] Remove duplicate rows --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 207e7f2..efbd62c 100644 --- a/README.md +++ b/README.md @@ -33,11 +33,10 @@ Also, to enable preview you need to tell `plantuml-mode` where to locate the Pla # Enable the major mode -You can automatically enable `plantuml-mode` for files with extension `.plantuml` or `plantuml` by adding the following to your `.emacsrc`: +You can automatically enable `plantuml-mode` for files with extension `.plantuml` by adding the following to your `.emacsrc`: ;; Enable plantuml-mode for PlantUML files (add-to-list 'auto-mode-alist '("\\.plantuml\\'" . plantuml-mode)) - (add-to-list 'auto-mode-alist '("\\.plantuml\\'" . plantuml-mode)) Of course, you can always enable manually the major mode by typing `M-x plantuml-mode` once in the desired PlantUML file buffer. From 64af0f1cc3392811a33b3371eb86c6f4bedbaec1 Mon Sep 17 00:00:00 2001 From: Carlo Sciolla Date: Fri, 11 Nov 2016 08:53:52 +0100 Subject: [PATCH 7/8] Untabified --- plantuml-mode.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plantuml-mode.el b/plantuml-mode.el index 9c505f7..b63a6d6 100644 --- a/plantuml-mode.el +++ b/plantuml-mode.el @@ -82,7 +82,7 @@ (defun plantuml-render-command (&rest arguments) "Create a command line to execute PlantUML with arguments (as ARGUMENTS)." (let* ((cmd-list (append plantuml-java-args (list plantuml-jar-path) arguments)) - (cmd (mapconcat 'identity cmd-list "|"))) + (cmd (mapconcat 'identity cmd-list "|"))) (plantuml-debug (format "Command is [%s]" cmd)) cmd-list)) @@ -134,7 +134,7 @@ (error "Could not find plantuml.jar at %s" plantuml-jar-path)) (with-temp-buffer (let ((cmd-args (append (list plantuml-java-command nil t nil) - (plantuml-render-command "-charset" "UTF-8" "-language")))) + (plantuml-render-command "-charset" "UTF-8" "-language")))) (apply 'call-process cmd-args) (goto-char (point-min))) (let ((found (search-forward ";" nil t)) From 673e5244438f628dc52b1c78e6cbceb59017301d Mon Sep 17 00:00:00 2001 From: Carlo Sciolla Date: Fri, 11 Nov 2016 09:12:58 +0100 Subject: [PATCH 8/8] Expand file names before any `shell-quote-argument` happens to support ~ in paths --- plantuml-mode.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plantuml-mode.el b/plantuml-mode.el index b63a6d6..ddfdd2b 100644 --- a/plantuml-mode.el +++ b/plantuml-mode.el @@ -81,7 +81,7 @@ (defun plantuml-render-command (&rest arguments) "Create a command line to execute PlantUML with arguments (as ARGUMENTS)." - (let* ((cmd-list (append plantuml-java-args (list plantuml-jar-path) arguments)) + (let* ((cmd-list (append plantuml-java-args (list (expand-file-name plantuml-jar-path)) arguments)) (cmd (mapconcat 'identity cmd-list "|"))) (plantuml-debug (format "Command is [%s]" cmd)) cmd-list)) @@ -217,7 +217,7 @@ default output type for new buffers." `(start-process "PLANTUML" ,buf plantuml-java-command ,@plantuml-java-args - (shell-quote-argument plantuml-jar-path) + (shell-quote-argument (expand-file-name plantuml-jar-path)) (plantuml-output-type-opt) "-p")) (defun plantuml-preview-string (prefix string)