unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#35847: org-babel clojure bug? nil prepended to all results?
@ 2019-05-21 13:18 Brian Beckman
  0 siblings, 0 replies; only message in thread
From: Brian Beckman @ 2019-05-21 13:18 UTC (permalink / raw)
  To: 35847, bc.beckman

[-- Attachment #1: Type: text/plain, Size: 3253 bytes --]

I originally submitted this to the nrepl / cider group in github because my
workaround entailed a (most likely bogus) change to nrepl, but they closed
it and told me to submit it here. My original submission is copied below.
The response of the nrepl maintainer can be found at
https://github.com/nrepl/nrepl/issues/146

## Expected behavior

in org-babel, I expect the following
```
#+begin_src clojure
(* 6 (+ 6 2))
#+end_src

#+RESULTS:
: 48
```
## Actual behavior
```
#+begin_src clojure
(* 6 (+ 6 2))
#+end_src

#+RESULTS:
: nil48

```
## Steps to reproduce the problem

Make sure your emacs init.el (or other startup fixture like .spacemacs) has
org-babel support for Cider and Clojure, as with the following

```
  (require 'ob-clojure)
  (org-babel-do-load-languages
   'org-babel-load-languages
   '(
     (C           . t)
     (awk         . t)
     (clojure     . t) ))
```
Make a lein new app foo so that you have a project.clj file.
Create any old .org file in the foo project directory.
Put the code snippet above in the .org file.
Do M-x cider-jack-in with the cursor in that code block.
Do C-c C-c with cursor in the code block to evaluate the code block.
See the prepended "nil?" It's the same with every other code block. Every
result gets a prepended "nil."

## my workaround

I changed `elpa/cider-20190321.2129/nrepl-dict.el::nrepl--merge` as follows
to get my stuff to work. No idea whether this is a robust or worthwhile
change.

```
(defun nrepl--merge (dict1 dict2 &optional no-join)
  "Join nREPL dicts DICT1 and DICT2 in a meaningful way.
String values for non \"id\" and \"session\" keys are concatenated. Lists
are appended. nREPL dicts merged recursively. All other objects are
accumulated into a list. DICT1 is modified destructively and
then returned.
If NO-JOIN is given, return the first non nil dict."
  (if no-join
      (or dict1 dict2)
    (cond ((null dict1) dict2)
          ((null dict2) dict1)
          ((stringp dict1) (concat dict1 dict2))
          ((nrepl-dict-p dict1)
           (nrepl-dict-map
            (lambda (k2 v2)
              (nrepl-dict-put dict1 k2
                              (nrepl--merge (nrepl-dict-get dict1 k2)
                                            ;; bbeckman bug?  CHANGED RIGHT
HERE *****
                                            (if (and (string= k2 "value")
                                                     (stringp v2)
                                                     (string= v2 "nil"))
                                                "" v2)
                                            (member k2 '("id" "session")))))
            dict2)
           dict1)
          ((and (listp dict2) (listp dict1)) (append dict1 dict2))
          ((listp dict1) (append dict1 (list dict2)))
          (t `(,dict1 ,dict2)))))

```

## Environment & Version information

```
: Emacs version: GNU Emacs 26.2 (build 2, x86_64-pc-linux-gnu, GTK+ Version
3.24.4)
:  of 2019-04-12
: org version: 9.2.2

```
### Clojure version
1.10.0

### Java version

openjdk version "11.0.3" 2019-04-16
OpenJDK Runtime Environment (build 11.0.3+7-Ubuntu-1ubuntu218.10.1)
OpenJDK 64-Bit Server VM (build 11.0.3+7-Ubuntu-1ubuntu218.10.1, mixed
mode, sharing)

### Operating system

Ubuntu 18.04

[-- Attachment #2: Type: text/html, Size: 4290 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-05-21 13:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-21 13:18 bug#35847: org-babel clojure bug? nil prepended to all results? Brian Beckman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).