From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Brian Beckman Newsgroups: gmane.emacs.bugs Subject: bug#35847: org-babel clojure bug? nil prepended to all results? Date: Tue, 21 May 2019 06:18:28 -0700 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000014981058965b062" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="74883"; mail-complaints-to="usenet@blaine.gmane.org" To: 35847@debbugs.gnu.org, bc.beckman@gmail.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue May 21 16:30:14 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hT5mP-000JKW-2P for geb-bug-gnu-emacs@m.gmane.org; Tue, 21 May 2019 16:30:13 +0200 Original-Received: from localhost ([127.0.0.1]:54787 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hT5mN-0005V2-P8 for geb-bug-gnu-emacs@m.gmane.org; Tue, 21 May 2019 10:30:11 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:43893) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hT5mG-0005Tg-M2 for bug-gnu-emacs@gnu.org; Tue, 21 May 2019 10:30:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hT5mF-0008OC-2x for bug-gnu-emacs@gnu.org; Tue, 21 May 2019 10:30:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:55170) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hT5mE-0008Nz-Tc for bug-gnu-emacs@gnu.org; Tue, 21 May 2019 10:30:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hT5mE-0005Mg-Mc for bug-gnu-emacs@gnu.org; Tue, 21 May 2019 10:30:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Brian Beckman Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 21 May 2019 14:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 35847 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org, Brian Beckman Original-Received: via spool by submit@debbugs.gnu.org id=B.155844898320566 (code B ref -1); Tue, 21 May 2019 14:30:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 21 May 2019 14:29:43 +0000 Original-Received: from localhost ([127.0.0.1]:40481 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hT5lu-0005Lc-TA for submit@debbugs.gnu.org; Tue, 21 May 2019 10:29:43 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:41348) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hT4fL-00034f-CL for submit@debbugs.gnu.org; Tue, 21 May 2019 09:18:51 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:44383) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hT4fG-0003qT-9L for submit@debbugs.gnu.org; Tue, 21 May 2019 09:18:46 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:55729) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hT4fE-000239-F3 for bug-gnu-emacs@gnu.org; Tue, 21 May 2019 09:18:46 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hT4fD-0003l5-2x for bug-gnu-emacs@gnu.org; Tue, 21 May 2019 09:18:44 -0400 Original-Received: from mail-ua1-x934.google.com ([2607:f8b0:4864:20::934]:35174) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hT4fC-0003iv-Q6 for bug-gnu-emacs@gnu.org; Tue, 21 May 2019 09:18:43 -0400 Original-Received: by mail-ua1-x934.google.com with SMTP id r7so6604205ual.2 for ; Tue, 21 May 2019 06:18:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=twdFPReOgK6AtQt0rk/BUEjVo0A7xeK0D9JO3WFrA/0=; b=SrG0ZQrCAKgznhkxApdKnWT/7th+gSNJGpuzWUhpzgFrWrz8FDLQx3mnD506bIRB/J wpr5F/AMW73kUha4vdNbkQ1UFmDSBc9p/YyK40ZMAeDexfdQzLxMZ2BZvNujqKg5H5Id XuFosfqcQYz8sXHOGNIJCfbej7FcXr7QzQ/Rs7u7AAC86VvrI3v5TYFFJV63dQqp+Fae oX7EVOuVnnIzloM6KAAZ7niee8SY4Mw63CIJp1GLt+j8w0yFJbbICpxPKhcP93hTgZyd trHObQnI/uAxoYhVH9wT6q8HM2aJCWXNtos0+PIrcwPDUvDYCkdoRkNZFbkFiiA6aaYP bILg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=twdFPReOgK6AtQt0rk/BUEjVo0A7xeK0D9JO3WFrA/0=; b=Irs9kaUkv4lZ8y45Fa8wzo1zUfFn0XefgRd/sHEaR0NO6ze7E1PqSbyLvz2KxVoOD/ 493QamDiQzfuKRBfGW0vO7gIuW0sfP/+J4hlW3F47bjvexWoGho23Uwi5KNsN4yAkRdV WHMo6L8xuL4AX1N6bQoyQeUYhj8RdQSRXd0lAXnGkGceC81rANMUwg9XO7dKe/hVcc3S +jvkcUQX+/NLvblJ74UJcmO1XN0VexyV0wi6sn0uR+2pNpsWzNqgVBjWNS7a2es2hUD9 8lhhKEWNDvpVeliKOey4jKUUYGTCImbuiHwPRteXGyAsgMnDlmIBHC12j9mBnhtz0FVX CqcA== X-Gm-Message-State: APjAAAUb7PTStGA2yYkszssCQiH20nowz994I2+CmsmSBxchGrBXxT8J fUZ+6emLwD4Fo0XSPlVRwciAe2h2+p0nm3HNeTe3nNZKcz0= X-Google-Smtp-Source: APXvYqwL9CPuIB6gKRbV4Ob8nQ9RoLB2jrgyZdh5FXuXgLYorSAuXML+5YCysndR6pz1G5ssy3ABYJvf+URN5oxvda4= X-Received: by 2002:a9f:3731:: with SMTP id z46mr10290424uad.16.1558444721128; Tue, 21 May 2019 06:18:41 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Mailman-Approved-At: Tue, 21 May 2019 10:29:41 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:159612 Archived-At: --000000000000014981058965b062 Content-Type: text/plain; charset="UTF-8" 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 --000000000000014981058965b062 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I originally submitted this to the nrepl / cider group in gith= ub because my workaround entailed a (most likely bogus) change to nrepl, bu= t they closed it and told me to submit it here. My original submission is c= opied below. The response of the nrepl maintainer can be found at=C2=A0https://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 rep= roduce the problem

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

```
=C2=A0 (require 'ob-clojure)
=C2=A0 (or= g-babel-do-load-languages
=C2=A0 =C2=A0'org-babel-load-languages
= =C2=A0 =C2=A0'(
=C2=A0 =C2=A0 =C2=A0(C =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 . t)
=C2=A0 =C2=A0 =C2=A0(awk =C2=A0 =C2=A0 =C2=A0 =C2=A0 . t)=C2=A0 =C2=A0 =C2=A0(clojure =C2=A0 =C2=A0 . t) ))
```
Make a lein n= ew app foo so that you have a project.clj file.
Create any old .org fil= e 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. E= very result gets a prepended "nil."

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

```
(defun nrepl--merge (dict1 dict2 &optional no-joi= n)
=C2=A0 "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 ot= her objects are
accumulated into a list. DICT1 is modified destructively= and
then returned.
If NO-JOIN is given, return the first non nil dic= t."
=C2=A0 (if no-join
=C2=A0 =C2=A0 =C2=A0 (or dict1 dict2)
= =C2=A0 =C2=A0 (cond ((null dict1) dict2)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 ((null dict2) dict1)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ((stringp di= ct1) (concat dict1 dict2))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ((nrepl-di= ct-p dict1)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(nrepl-dict-map
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (lambda (k2 v2)
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (nrepl-dict-put dict1 k2
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 (nrepl--merge (nrepl-dict-get dict1 k2)
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; bb= eckman bug?=C2=A0 CHANGED RIGHT HERE *****
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (if (and (string=3D k2= "value")
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(stringp v2)<= br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(string=3D v2 "nil")= )
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 "" v2)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (member k2 '("= ;id" "session")))))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 dict2)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0dict1)
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 ((and (listp dict2) (listp dict1)) (append dict= 1 dict2))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ((listp dict1) (append dict= 1 (list dict2)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (t `(,dict1 ,dict2))= )))

```

## Environment & Version information

```: Emacs version: GNU Emacs 26.2 (build 2, x86_64-pc-linux-gnu, GTK+ Versi= on 3.24.4)
: =C2=A0of 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-Ubun= tu-1ubuntu218.10.1, mixed mode, sharing)
=C2=A0
### Operating system<= br>
Ubuntu 18.04
--000000000000014981058965b062--