bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#35847: org-babel clojure bug? nil prepended to all results?


From: Brian Beckman
Subject: bug#35847: org-babel clojure bug? nil prepended to all results?
Date: Tue, 21 May 2019 06:18:28 -0700

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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]