Re: [BUG] Tangling of clojure code blocks is broken [9.7 (9.7-??-0807107 @ /Users/ag/.emacs.d/.local/straight/build-30.0.50/org/)]

2023-05-08 Thread Ihor Radchenko
Daniel Kraus  writes:

> The problem is that or :results value (/the default) I only want the
> result of the last expression and I do that `binding` of stdout to surpress
> all other output.
> But I guess during tangle this should just be ignored?
> Is there a simple way to find out if `org-babel-execute:clojure` is
> executed or tangled?

You can just move this extra logic arranging :results to
org-babel-execute:clojure.

> If it should be ignored on tangle, what about the :var defines.

:var defines are affecting how the code is written. :results should not.
So, :var is expected to affect tangling.
If necessary, code block expansion can be disabled via :no-expand header
argument:

   By default Org expands code blocks during tangling.  The ‘no-expand’
header argument turns off such expansions.  Note that one side-effect of
expansion by ‘org-babel-expand-src-block’ also assigns values (see *note
Environment of a Code Block::) to variables.  Expansions also replace
noweb references with their targets (see *note Noweb Reference
Syntax::).  Some of these expansions may cause premature assignment,
hence this option.  This option makes a difference only for tangling.
It has no effect when exporting since code blocks for execution have to
be expanded anyway.

> We recently discussed this for ob-scheme where there was a problem with the
> `let` wrapper.
> Is it ok or expected that a the tangled code is wrapped in a let block?
> Should I change it to a global `def`?

I think that keeping `let' should be fine as long as it does not break
things. In the previous discussion, the whole issue was that `let' was
not always safe in that particular lisp dialect.

We just need to make sure that it is documented.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [BUG] Tangling of clojure code blocks is broken [9.7 (9.7-??-0807107 @ /Users/ag/.emacs.d/.local/straight/build-30.0.50/org/)]

2023-05-08 Thread Daniel Kraus
Hi!

Ag  writes:

> Setting :results output header makes it work as expected. Without it -
> it's as I described, wrapped.

I can reproduce the bug.

The problem is that or :results value (/the default) I only want the
result of the last expression and I do that `binding` of stdout to surpress
all other output.
But I guess during tangle this should just be ignored?
Is there a simple way to find out if `org-babel-execute:clojure` is
executed or tangled?

If it should be ignored on tangle, what about the :var defines.
We recently discussed this for ob-scheme where there was a problem with the
`let` wrapper.
Is it ok or expected that a the tangled code is wrapped in a let block?
Should I change it to a global `def`?

Thanks for the bug report.

PS, a minimal repo is

minimal-org-clj.el:
#+BEGIN_SRC emacs-lisp
;;; Minimal setup to load latest `org-mode'.

;; Activate debugging.
(setq debug-on-error t
  debug-on-signal nil
  debug-on-quit nil)

;; Add latest Org mode to load path.
(add-to-list 'load-path (expand-file-name "/home/daniel/.emacs.d/lib/org/lisp"))

(org-babel-do-load-languages
 'org-babel-load-languages
 '((clojure . t)))
#+END_SRC

/usr/bin/emacs -Q -l minimal-org-clj.el

And then tangle something like:

#+begin_src clojure :backend babashka :tangle foo.clj
{:foo :bar}
#+end_src

Cheers,
  Daniel



Re: [BUG] Tangling of clojure code blocks is broken [9.7 (9.7-??-0807107 @ /Users/ag/.emacs.d/.local/straight/build-30.0.50/org/)]

2023-05-08 Thread Ihor Radchenko
Ag Ibragimov  writes:

> I'm using the latest, org-version reports "Org mode version 9.7 
> (9.7-??-fdea200 ..."

Please detail the steps you tried. At least "version 9.7" does not look
right because the latest version is labeled "9.7-pre".

Also, provide the clojure backend you are using.

> This particular line here is causing the problem I described:
>
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/tree/lisp/ob-clojure.el#n191
>
> ```emacs-lisp
> (if cljs-p
> "(binding [cljs.core/*print-fn* (constantly nil)]"
>   "(binding [*out* (java.io.StringWriter.)]") ;;; <- this one
> ```

Maybe, but please provide more data to reproduce the problem on our side.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [BUG] Tangling of clojure code blocks is broken [9.7 (9.7-??-0807107 @ /Users/ag/.emacs.d/.local/straight/build-30.0.50/org/)]

2023-05-07 Thread Ag
Setting :results output header makes it work as expected. Without it -
it's as I described, wrapped.

On Mon, May 8, 2023 at 12:18 AM Ag Ibragimov  wrote:
>
> Ihor Radchenko  writes:
>
> > I see the expected result on my side.
>
> I'm using the latest, org-version reports "Org mode version 9.7 
> (9.7-??-fdea200 ..."
> This particular line here is causing the problem I described:
>
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/tree/lisp/ob-clojure.el#n191
>
> ```emacs-lisp
> (if cljs-p
> "(binding [cljs.core/*print-fn* (constantly nil)]"
>   "(binding [*out* (java.io.StringWriter.)]") ;;; <- this one
> ```
>


-- 
Regards,
Ag.



Re: [BUG] Tangling of clojure code blocks is broken [9.7 (9.7-??-0807107 @ /Users/ag/.emacs.d/.local/straight/build-30.0.50/org/)]

2023-05-07 Thread Ag Ibragimov
Ihor Radchenko  writes:

> I see the expected result on my side.

I'm using the latest, org-version reports "Org mode version 9.7 (9.7-??-fdea200 
..."
This particular line here is causing the problem I described:

https://git.savannah.gnu.org/cgit/emacs/org-mode.git/tree/lisp/ob-clojure.el#n191

```emacs-lisp
(if cljs-p
"(binding [cljs.core/*print-fn* (constantly nil)]"
  "(binding [*out* (java.io.StringWriter.)]") ;;; <- this one
```



Re: [BUG] Tangling of clojure code blocks is broken [9.7 (9.7-??-0807107 @ /Users/ag/.emacs.d/.local/straight/build-30.0.50/org/)]

2023-05-06 Thread Ihor Radchenko
Ag Ibragimov  writes:

> Repro steps:
> ...
> Observed:
>
> It's wrapping the content into
> `(prn (binding [*out* (java.io.StringWriter.)]{:foo :bar}))`
>
> Expected:
>
> {:foo :bar}

I see the expected result on my side.
May you follow the steps starting from emacs -Q or make repro?
See https://orgmode.org/manual/Feedback.html#Feedback

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at