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

fix: handling of d2-flags #48

Merged
merged 1 commit into from
Jul 1, 2024
Merged

fix: handling of d2-flags #48

merged 1 commit into from
Jul 1, 2024

Conversation

terlar
Copy link
Contributor

@terlar terlar commented Jun 11, 2024

They were only passed to the org babel execution and not to the regular compile file command.

This also converts it to a list instead of a string in order to better fit the call-process function.

@andorsk
Copy link
Owner

andorsk commented Jun 17, 2024

thank you for the improved handling and PR! Will review and hopefully can merge this in!

@terlar
Copy link
Contributor Author

terlar commented Jun 17, 2024

Thank you, just a heads up, I did change the d2-flags from a string to a list. We could also keep it as a string for backwards compatibility. I guess that is the main "questionable" change.

d2-mode.el Outdated
@@ -117,7 +117,7 @@
(cmd (concat (shell-quote-argument d2-location)
" " temp-file
" " (org-babel-process-file-name out-file)
" " d2-flags)))
" " (string-join d2-flags " "))))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to require subr-x to support the string-join function?

Copy link
Owner

@andorsk andorsk Jun 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @terlar . I think it's fine breaking compatibility here. I think this is going to be a bump into a new version. Probably 0.2 to signify breaking. Along with #47. Maybe some linting updates as well.

I'm super swamped today/tomorrow, but I will try to review this over the weekend/later half of the week. Sorry for the delay and thank you again for the contribution.

string-join is built in Emacs 25. Think we are fine. We can also just add the function directly:

;;;###autoload
(defsubst string-join (strings &optional separator)
"Join all STRINGS using SEPARATOR.
Optional argument SEPARATOR must be a string, a vector, or a list of
characters; nil stands for the empty string."
(declare (pure t) (side-effect-free t))
(mapconcat #'identity strings separator))

I'd prefer to not require a library for something as simple as string-join but i'm not entirely opposed to it either.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, no stress. Take your pace. Yeah, if we have to require a library we might as well just do mapconcat, perhaps we also want to shell escape all arguments as well anyway.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good. will get this merged in asap. Something came up this weekend and going to have to delay my review until mid next week. my apologies. I'm looking forward to the review.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries, then I will have time to update with mapconcat instead

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/andorsk/d2-mode/actions/runs/9472621470/job/26295213297?pr=48#step:5:59 <- string join needs to be added in, per this. I will add a suggestion here for string-join. Lmk if you're ok wth it

(progn
(d2-browse-file output))
(progn
(d2-browse-file output))
(progn
(display-buffer (find-file-noselect output t))))))

Copy link
Owner

@andorsk andorsk Jun 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the following:

Suggested change
;;;###autoload
(defsubst string-join (strings &optional separator)
"Join all STRINGS using SEPARATOR.
Optional argument SEPARATOR must be a string, a vector, or a list of
characters; nil stands for the empty string."
(declare (pure t) (side-effect-free t))
(mapconcat #'identity strings separator))

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: tested this and it seemed to work. Let's get this in and merge to main. After #47 , bump version.

Copy link
Contributor Author

@terlar terlar Jul 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went for mapconcat directly instead, since then I can specify the separator and can also apply the shell-quote-argument to all arguments which is good practice.

@andorsk
Copy link
Owner

andorsk commented Jun 30, 2024

@terlar, thanks for being patient. Can we get string-join added in above, and make sure the builds above are fixed? Should be good to go after that.

They were only passed to the org babel execution and not to the regular
compile file command.

This also converts it to a list instead of a string in order to better
fit the call-process function.
@andorsk
Copy link
Owner

andorsk commented Jul 1, 2024

note: ci is breaking due to some weird upstream issues, but one from each os ( mac, windows, and ubuntu ) all passed, so I think this is fine.

New issue tagged here: #49 for this. LGTM, and approved.

Copy link
Owner

@andorsk andorsk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good. approved.

@andorsk andorsk merged commit 6dc1ae9 into andorsk:main Jul 1, 2024
4 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants