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

Difficulty configuring plantuml-mode despite scouring the README #137

Closed
factotvm opened this issue Jan 17, 2021 · 3 comments
Closed

Difficulty configuring plantuml-mode despite scouring the README #137

factotvm opened this issue Jan 17, 2021 · 3 comments

Comments

@factotvm
Copy link

Summary

I know that I am using the default ob-plantuml when trying to execute org-mode src blocks. However, I can not figure out how to have plantuml-mode override this.

I found issue #53, and I feel like I almost have the knowledge, but I wonder if the README has changed since then. I also found this comment that seems inline with what I'm doing. Let me apologize for not being particularly adept at configuring Emacs, and mostly bumble around, but here is what I have:

  (use-package plantuml-mode
    :init
    (setq plantuml-default-exec-mode 'executable)
    (setq plantuml-executable-path (trim-last-newline (shell-command-to-string "which plantuml")))
    (add-to-list 'org-src-lang-modes '("plantuml" . plantuml))))

I also tried the following function, which I found online, that loads languages on demand. This is what loads ob-plantuml (I had to remove the leading :). But when removed, I get org-babel-execute-src-block: No org-babel-execute function for plantuml!. Which is... closer.

  (defadvice org-babel-execute-src-block (around load-language nil activate)
    "Load language if needed"
    (let ((language (org-element-property :language (org-element-at-point))))
      (unless (cdr (assoc (intern language) org-babel-load-languages))
        (add-to-list 'org-babel-load-languages (cons (intern (replace-regexp-in-string ":" "" language)) t))
        (org-babel-do-load-languages 'org-babel-load-languages org-babel-load-languages))
      ad-do-it))

What configuration am I missing to ensure that plantuml-mode is used and available when I execute the src block? Thanks, and apologies up front if this is a silly question. I very much appreciate the package and your time.

@stig
Copy link

stig commented Mar 25, 2021

I think it would help us help you if you gave an example of an Org file you have, the output or error you get and the expected results. For what it's worth this works for me:

#+begin_src plantuml :file plantuml-demo.png
title Authentication Sequence

Alice->Bob: Authentication Request
note right of Bob: Bob thinks about it
Bob->Alice: Authentication Response
#+end_src

(The :file filename.png is very important.)

"Executing" that by positioning cursor anywhere in the source block and hitting C-c C-c asks me "Evaluate this plantuml code block on your system? (y or n)".

FWIW my PlantUML config (this week) is https://github.com/stig/dotfiles/blob/trunk/Emacs.org#plantuml
and my babel configuration is:

(org-babel-do-load-languages 'org-babel-load-languages
				 '((emacs-lisp . t)
				   (sql . t)
				   (shell . t)
				   (plantuml . t))))

@terlar
Copy link

terlar commented Mar 26, 2021

As far as I known plantuml-mode is not used for org-mode except for the indentation and syntax highlighting if you have enabled that. All the Babel stuff comes from ob-plantuml bundled with org-mode.

@factotvm
Copy link
Author

Thank you both for your help. With it, I now have my expected environment, which is I can write PlantUML both in a major mode and in Org mode, and it behaves identically to writing GraphViz: one is able to preview (in the former), and generate results (in the latter).

My path there was a little circuitous. I tried to follow @stig's config (that's fun to say), and after realizing (after @terlar's comment) that I am not to replace ob-plantuml with plantuml-mode, I started making progress. I got a bit stuck on trying to follow Stig's configuration in that ob-plantuml wouldn't load. Of course not, it doesn't exist as a package anymore (Terje told me that, I'm just slow).

So, I removed all configuration of ob-plantuml in my config, and set the (as of org-mode 9.4) org-plantuml-exec-mode to 'plantuml (which was really my goal all along—to use the executable configuration of plantuml-mode so that I didn't have to use the jar).

I do still have this issue (put here for completeness, but not related to plantuml-mode) the first time I try and to generate results in Org mode:

Code block produced no output.

It works the second time. Maybe it has to do with the order that things are loaded... but I'm not that worried about it.

What I'm stoked about is the major mode works flawlessly, and in Org mode it's "good enough."

Again, thank you both for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants