skuro / plantuml-mode

A major mode for editing PlantUML sources in Emacs
GNU General Public License v3.0
511 stars 96 forks source link

syntax error from examples of plantuml.com #101

Closed c02y closed 5 years ago

c02y commented 5 years ago

Summary

When I use old plantuml.jar in emacs+plantuml-mode, and tried an example from plantuml.com, and tried to plantuml-preview in it, it shows syntax error (check screenshot), and I tried multiple examples from plantuml.com, all of them failed.

The old plantuml.jar used to work very well years ago.

I tried to download the latest plantuml.jar and use it in emacs, when I open a plantuml buffer, it says

File mode specification error: (wrong-type-argument stringp nil)

and I tried to plantuml-preview it, it still says the same error message as screenshot plantuml

Checklist for pull requests

rajasegar commented 5 years ago

Try this

; Set your plantuml.jar path
  (setq plantuml-jar-path (expand-file-name "~/plantuml.jar"))
; Change preview mode to jar
  (setq plantuml-default-exec-mode 'jar)
c02y commented 5 years ago

No, the same old, it doesn't work, I tried the old version and the lastest version of plantuml.jar.

alexvs11 commented 5 years ago

Got the same issue. It can be fixed by changing: (let* ((url-request-location (concat plantuml-server-url "/" plantuml-output-type "/-base64-" (base64-encode-string string)))) to (let* ((url-request-location (concat plantuml-server-url "/" plantuml-output-type "/-base64-" (base64-encode-string string t))))

the problem is in a malformed multiline request

c02y commented 5 years ago

Yes, the syntax error is gone.

But when I open a pum file in emacs, it still displays error message on minibuffer:

File mode specification error: (wrong-type-argument stringp nil)
alexvs11 commented 5 years ago

@c02y M-x toggle-debug-on-error I would make a PR, but there is still some instability with encoding of answer %)

skuro commented 5 years ago

@alexvs11 looks like a good catch, can you please elaborate on the last sentence though? Is there any further issue with server interactions that your solution wouldn't fix?

skuro commented 5 years ago

@c02y as suggested, enabling debug will give us a stack trace to work with. Could you please M-x toggle-debug-on-error, trigger the issue and post here the stack trace?

piotr-kozbial commented 5 years ago

As for "File mode specification error", I have that too when I try to open a *.pum file. Afterwards I have no syntax highlighting, although the major mode is set to "plantuml".

I'm using Spacemacs with plantuml layer. Here's the version:

"GNU Emacs 25.2.2 (x86_64-pc-linux-gnu, GTK+ Version 3.23.2) of 2018-08-27, modified by Debian"

And here's the stack-trace:

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  string-to-number(nil)
  plantuml-init(server)
  plantuml-init-once()
  plantuml-mode()
  set-auto-mode-0(plantuml-mode nil)
  set-auto-mode()
  normal-mode(t)
  after-find-file(nil t)
  find-file-noselect-1(#<buffer diagram.pum> "~/diagram.pum" nil nil "~/diagram.pum" (4989866 2049))
  find-file-noselect("/home/ja/diagram.pum" nil nil nil)
  find-file("/home/ja/diagram.pum")
  helm-find-file-or-marked("/home/ja/diagram.pum")
  helm-execute-selection-action-1()
  helm-execute-selection-action()
  helm-internal(helm-source-find-files "/home/ja/" "Find files or url: " nil nil "*helm find files*" nil nil nil)
  apply(helm-internal (helm-source-find-files "/home/ja/" "Find files or url: " nil nil "*helm find files*" nil nil nil))
  helm(helm-source-find-files "/home/ja/" "Find files or url: " nil nil "*helm find files*" nil nil nil)
  apply(helm (helm-source-find-files "/home/ja/" "Find files or url: " nil nil "*helm find files*" nil nil nil))
  helm(:sources helm-source-find-files :input "/home/ja/" :case-fold-search smart :preselect nil :ff-transformer-show-only-basename t :default nil :prompt "Find files or url: " :buffer "*helm find files*")
  helm-find-files-1("/home/ja/")
  (let* ((hist (and arg helm-ff-history (helm-find-files-history))) (default-input hist) (input (cond ((and (eq major-mode (quote dired-mode)) default-input) (file-name-directory default-input)) ((and (not (string= default-input "")) default-input)) (t (expand-file-name (helm-current-directory)))))) (set-text-properties 0 (length input) nil input) (helm-find-files-1 input))
  spacemacs/helm-find-files(nil)
  funcall-interactively(spacemacs/helm-find-files nil)
  call-interactively(spacemacs/helm-find-files nil nil)
  command-execute(spacemacs/helm-find-files)
c02y commented 5 years ago

As for "File mode specification error", I have that too when I try to open a *.pum file. Afterwards I have no syntax highlighting, although the major mode is set to "plantuml". I'm using Spacemacs with plantuml layer.

@piotr-kozbial Exactly the same here.

@skuro

  1. M-x toggle-debug-on-error
  2. open the test.pum file here is the Backtrace buffer:
    
    Debugger entered--Lisp error: (wrong-type-argument stringp nil)
    string-to-number(nil)
    plantuml-init(server)
    plantuml-init-once()
    plantuml-mode()
    set-auto-mode-0(plantuml-mode nil)
    set-auto-mode()
    normal-mode(t)
    after-find-file(nil t)
    find-file-noselect-1(#<buffer test.pum> "~/test.pum" nil nil "~/test.pum" (569925 53))
    find-file-noselect("/home/chz/test.pum")
    mapcar(find-file-noselect ("/home/chz/test.pum"))
    (let* ((files (helm-marked-candidates)) (buffers (mapcar (quote find-file-noselect) files))) (spacemacs//helm-open-buffers-in-windows buffers))
    (lambda (candidate) (let* ((files (helm-marked-candidates)) (buffers (mapcar (quote find-file-noselect) files))) (spacemacs//helm-open-buffers-in-windows buffers)))("/home/chz/test.pum")
    helm-execute-selection-action-1()
    helm-execute-selection-action()
    helm-internal(helm-source-find-files "/home/chz/" "Find files or url: " nil nil "*helm find files*" nil "/home/chz/Documentation" nil)
    apply(helm-internal (helm-source-find-files "/home/chz/" "Find files or url: " nil nil "*helm find files*" nil "/home/chz/Documentation" nil))
    helm(helm-source-find-files "/home/chz/" "Find files or url: " nil nil "*helm find files*" nil "/home/chz/Documentation" nil)
    apply(helm (helm-source-find-files "/home/chz/" "Find files or url: " nil nil "*helm find files*" nil "/home/chz/Documentation" nil))
    helm(:sources helm-source-find-files :input "/home/chz/" :case-fold-search smart :preselect nil :ff-transformer-show-only-basename t :default "/home/chz/Documentation" :prompt "Find files or url: " :buffer "*helm find files*")
    helm-find-files-1("/home/chz/")
    (let* ((hist (and arg helm-ff-history (helm-find-files-history))) (default-input hist) (input (cond ((and (eq major-mode (quote dired-mode)) default-input) (file-name-directory default-input)) ((and (not (string= default-input "")) default-input)) (t (expand-file-name (helm-current-directory)))))) (set-text-properties 0 (length input) nil input) (helm-find-files-1 input))
    spacemacs/helm-find-files(nil)
    funcall-interactively(spacemacs/helm-find-files nil)
    call-interactively(spacemacs/helm-find-files nil nil)
    command-execute(spacemacs/helm-find-files)

And the content of the test.pum, if it matters, is copied from http://plantuml.com/zh/sequence-diagram:

@startuml Alice -> Bob: Authentication Request Bob --> Alice: Authentication Response

Alice -> Bob: Another authentication Request Alice <-- Bob: another authentication Response @enduml

skuro commented 5 years ago

Alright, I can reproduce the issue locally, thank you so much for your input. Seems to be a problem with parsing the language spec since the server is not working anymore with https. As a workaround, you could customize plantuml-server-url to use http instead of https although I would not really feel good with myself suggesting anyone to drop encryption when accessing a public website.

I'll raise the issue with the guys behind the online plantuml server. Keep you posted.

skuro commented 5 years ago

Interestingly, only the /language endpoint, which plantuml-mode uses to fetch keywords in order to do syntax highlight, causes a redirect, whereas rendering commands still work

piotr-kozbial commented 5 years ago

Thanks! I'll use the workaround for the time being - I use jar exec mode, so it doesn't really compromise much.

skuro commented 5 years ago

The HTTPS endpoint works again and I cannot reproduce the issue anymore. Should be fixed.

c02y commented 5 years ago

Ths syntax error is gone, but the plantuml-preview doens't work

1. M-x toggle-debug-on-error
2. open the test.pum file (the same one)
3. M-x plantuml-preview
3. Check the screenshot, empty in *`*PLANTUML Preview\** buffer

No *Backtrace* buffer is created, and here is the content of *Messages* buffer(ImageMagick package is installed):

Contacting host: www.plantuml.com:443 [2 times]
ImageMagick error: negative or zero image size `/tmp/magick-57602adGE5S8ZQEW' @ error/image.c/SetImageExtent/2663
ImageMagick error: width or height exceeds limit `/tmp/magick-5760rqhj3HIAcKla' @ error/cache.c/OpenPixelCache/3666
Type C-c C-c or C-c C-x to view the image as text or hex.
ImageMagick error: negative or zero image size `/tmp/magick-5760p5yeAuwVqLco' @ error/image.c/SetImageExtent/2663
ImageMagick error: negative or zero image size `/tmp/magick-57600HrUMcjGLQ8B' @ error/image.c/SetImageExtent/2663
ImageMagick error: width or height exceeds limit `/tmp/magick-5760kM_ZBlAVG9EU' @ error/cache.c/OpenPixelCache/3666
ImageMagick error: width or height exceeds limit `/tmp/magick-5760nTUPlwSveuRq' @ error/cache.c/OpenPixelCache/3666
ImageMagick error: negative or zero image size `/tmp/magick-5760KpVH2tqUnXl3' @ error/image.c/SetImageExtent/2663
ImageMagick error: negative or zero image size `/tmp/magick-5760qsKAiFzIb2CY' @ error/image.c/SetImageExtent/2663

plant

iT-Boyer commented 3 years ago

the same issue,how to fix?