rkiggen / ob-powershell

Emacs Babel Powershell implementation
MIT License
13 stars 6 forks source link

Integrate some changes from https://gist.github.com/cbilson/ae0d90d163be4d769f8a15ddb58292bc #6

Closed fpvmorais closed 2 months ago

fpvmorais commented 1 year ago

Hello,

@cbilson created this gist in 2018 and I've leater added support for variables in the code. My elisp-fu is not great and I'm not sure if this is the right way to do it, but I've been using this since 2019 and has served me well. It seems you have this published in Melpa. Would you be open for a pull request?

zzeitt commented 2 months ago

Could you give me an example about how to use var in your provided ob-powershell.el? Because when I tested it with :var tmp="string", I got this error. image

fpvmorais commented 2 months ago

This works for me:

#+begin_src powershell :var tmp="Hello"

Write-Host $tmp

#+end_src 

#+RESULTS:
: Hello

image

zzeitt commented 2 months ago

That's weird. What I have done is replacing the melpa version ob-powershell.el with the revised one. Seems like the replacement doesn't take effect.

fpvmorais commented 2 months ago

Well you can try to use my fork of the code. This is what I am using:

(use-package ob-powershell
  :straight (ob-powershell.el :type git
                              :repo "https://github.com/fpvmorais/ob-powershell.git";
                              :local-repo "ob-powershell")
  :commands
  (org-babel-execute:powershell
   org-babel-expand-body:powershell))
#+begin_src powershell :var tmp="Hello"

Write-Host $tmp

#+end_src 

#+RESULTS:
: Hello
fpvmorais commented 2 months ago

If you're using Powershell core, you should also check the ob-pwsh (https://github.com/togakangaroo/ob-pwsh) It also lacks the variable stuff, but I added them on my fork: https://github.com/fpvmorais/ob-pwsh.git

zzeitt commented 2 months ago

After manually installing it, it works! Thx!