all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Brian Beckman <bc.beckman@gmail.com>
To: 35847@debbugs.gnu.org, bc.beckman@gmail.com
Subject: bug#35847: org-babel clojure bug? nil prepended to all results?
Date: Tue, 21 May 2019 06:18:28 -0700	[thread overview]
Message-ID: <CAK2VK6tMXL07D0qVg6v_nvrO5X9vmQ9xOGgge8gRO6VB=KHXsQ@mail.gmail.com> (raw)

[-- 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 --]

             reply	other threads:[~2019-05-21 13:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-21 13:18 Brian Beckman [this message]
2020-05-22 12:14 ` bug#35847: org-babel clojure bug? nil prepended to all results? Bastien

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAK2VK6tMXL07D0qVg6v_nvrO5X9vmQ9xOGgge8gRO6VB=KHXsQ@mail.gmail.com' \
    --to=bc.beckman@gmail.com \
    --cc=35847@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.