-
Notifications
You must be signed in to change notification settings - Fork 99
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
Save generated diagrams to file #46
Comments
OK, let's discuss. I positioned this as a "yet another preview functionality", not to generate or manage output files. I intentionally designed this to use a single temporary file generation to always show latest compile result in a single preview window in an external browser. This is in line with current preview design, that is, by typing C-cC-c, you instantly sees the result of a current work-in-progress diagram source in a single preview buffer "PLANTUML Preview" without requiring any other typing and switching Emacs buffer editing context, keep it simple approach. Also this is not to manage the browser, but just starting a browser as part of "preview functionality" like creating the "PLANTUML Preview" preview buffer. If we had a browser that can take standard input or other IPC method to read source data and shows diagram to the user, no temporary file would be even needed. Creating file and starting a browser is a "preview function" which consists of rendering source and showing the result in a UI on a volatile basis. A few comments:
"broader" can mean "more complicated", and it is not necessary to achieve the goal of: As a text mode Emacs user, a Windows user and a multi-display workstation user, I would like to edit any PlantUML source data in temporary buffers or file buffers in Emacs, taking advantage of nice language support features like keyword coloring, completion, indentation, pretty formatting etc, and check updated diagram on a fixed location in another large screen frequently and instantly, without switching Emacs editing context and without moving fingers away from Emacs. And, because the goal of the feature is not to save files in various locations, I do not have a good requirements how the multi file management should work. For example:
Yes, it might be a good idea still to support general multiple file generation and management, but that isn't the objective of this particular feature. Also supporting file savings feature could mean extra complexity with no real users. If you have a specific use cases you think plantuml-mode should support and used by some users, please elaborate a bit, we can build a set of requirements based on such concrete use cases. From example you cited above like 'website static/' folder, not sure exact work flow looks like. (I can guess but not sure it will be accurate.)
Sure, it might need some more adjustment in the future as this software evolves. 'A maintenance hell' sounds a bit strong though, and maybe too early to say. It can limit the community's possibility for future usability evolution.
Why we should limit ourselves to just Emacs? If there is a way to support PlantUML user in various different environment and workflows, as long as Emacs is involved and plantuml-mode can help, there should be nothing wrong to have plantuml-mode support such needs. While Emacs preview should evolve, plantuml-mode can also optimize other means to help various users. Anyway, let me think about how generic file management part can be added to support what you recommend while still meeting the above mentioned goal. (Please don't get me wrong - I appreciate your feedback and insight, and understand what you are trying to do and trying to avoid. Let's continue this thread and agree on a solution. Also due to time limitation towards year end, I might be slow in responding to the thread. Please bear with me.) |
So, it took me a while before coming back to this, sorry for the delay... Let me start with my mutual appreciation of the time you spent on Anyway, more on the subject matter: it currently feels to me that the without moving fingers away from Emacs and Why we should limit ourselves to just Emacs? are not really going in the same direction. The moment we include into the picture an external app, such as a browser, which is started (-> controlled, or at least this is what I would imagine a user to expect) by emacs, you are actually moving away from emacs, at least cognitively if not with your fingers. And in this case I'd rather give users a more direct API with which to integrate, for instance writing to a file at a predictable location so that As far as use cases for save-to-file go, I can think of a few already, but I'd rather stick to preview with an external app as expressed above. Now, if we devise a strategy to create the output files with a predictable path, we could then implement the browser-based preview as you suggested, but instead of treating browser as a special case we could think of it just as the app we want to use to preview the result, which should be a command that accepts a path as an argument. This seems to me a more solid strategy to handle this specific kind of workflow. On the strategy to define the output path for a diagram, and especially considering the
What do you think? |
Just use If you'd like to preview the plantuml result using png image format by default, put |
@c02y Versions:
@skuro Thanks for the plantuml-mode, and some of my opinions:
Eagerly waiting for the feature of save to a file 👍 |
I have tried following this one to save generated image but in mini buffer i got, Text is read only. So, is there a way i can save output to file? Note: I am using Emacs 27. |
@nedijahij try turning the display mode to text by BTW, as a best practice, |
@alphatan ah wow it is working! Thank na. |
Hey everyone, just for your information, I have been working on this in https://github.com/exot/plantuml-mode/tree/add-file-export (see https://github.com/exot/plantuml-mode/tree/add-file-export-shadow for the version I am actually using right now). Feel free to test! Best, Daniel |
Testing works :-) Thank you (edit) But after more testing C-c C-c generates the image which previews ok, the image saves from the buffer using C-x C-s (thanks @c02y ) as a png / svg and using the add-file-shadow version from @exot . The saved image can be opened by dired and opened outside of emacs with a variety of apps BUT if inserted into either a .md or .org file within emacs it returns a unknown image error. Other images in same formats work without issue. Very odd. Thanks all for an interesting journey :-) |
Hey @kevin-gwyrdh, thanks for reporting you findings! :) Have you also tried to use Best, Daniel Footnotes
|
Hi @exot Thanks that works! Curious |
Taking the discussion from #39, which introduced both a way to store the generated diagrams into files and open a browser to view the graphics.
Save to a file
That's a very good addition, it can definitely help out folks and keep the generated diagrams somewhere when needed. But as in your implementation you use custom variables, they become global state which would result in the same file being ovewritten in case more than one PlantUML file is being worked on at the same time. I would rather have the output file being setup on a per-buffer basis, using browser tabs to switch to the generated diagram of interest.
My point is that saving files can be a broader thing than just preview: you could store them into some
git
tree, your websitestatic/
folder, etc. You need different diagrams to output in different paths.Manage the browser
It feels to me like taking control over the browser is stretching
plantuml-mode
responsibilities too far. I can expect users to mostly use web browsers or emacs itself for preview, but I can still see too much variation in people setups to makeplantuml-start-external-browser
more of a maintenance hell then an added value (thinking here of FF + Chrome + Safari + IE, plus versions).Once the diagram is saved to a file, people who prefer other apps than emacs have a quick way to open up their favorite viewer. I'd leave
plantuml-mode
to optimize for emacs preview and leave it to the user to make his/her own workflow with a different app.The text was updated successfully, but these errors were encountered: