emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Daniel Kraus <daniel@kraus.my>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: numbchild@gmail.com, Org Mode <emacs-orgmode@gnu.org>
Subject: Re: ob-clojure eval error when has comment at end of code line
Date: Thu, 27 Oct 2022 14:25:33 +0200	[thread overview]
Message-ID: <878rl1a1e0.fsf@kraus.my> (raw)
In-Reply-To: <87lep3oxcu.fsf@localhost>

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

Hi!

I had a look and apparently cider-eval returns nil when the expression
is a comment, vs the string "nil" when the Clojure expression returns nil.
Simply filtering nil values out seems to have fixed the issue
for me.
@Christopher, can you check the attached patch if this works for you?

@Ihor, a few developer related questions:
- I wanted to add a test, how can I run only test-ob-clojure?
  I don't think the tests work currently and I would fix them and add more.
- What should I use for indention? Looking in ob-clojure and org.el
  it seems that using tabs with tab-width 8 is standard but there's
  quite a few lines where it's spaces only.
- If this simple patch for example or fixing tests is good,
  should I just install it?
  Can I "freely" install minor changes to ob-clojure or should
  everything go over the mailinglist?

Thanks. I hope I can work a bit more on ob-clojure the next few days,
I think I missed a few emails, sorry. Now I have a filter rule where
mails with Clojure in the subject go to my inbox.

Cheers,
  Daniel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-ob-clojure.el-Fix-bug-with-inline-comments.patch --]
[-- Type: text/x-patch, Size: 882 bytes --]

From 87054023df0876d17771ee3885e7b1091ccdeab1 Mon Sep 17 00:00:00 2001
From: Daniel Kraus <daniel@kraus.my>
Date: Thu, 27 Oct 2022 14:16:33 +0200
Subject: [PATCH] lisp/ob-clojure.el: Fix bug with inline comments

* lisp/ob-clojure.el (ob-clojure-eval-with-cider): Filter out
  nil values from cider evaluation.
---
 lisp/ob-clojure.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/ob-clojure.el b/lisp/ob-clojure.el
index 0649469b3..eff8d04e4 100644
--- a/lisp/ob-clojure.el
+++ b/lisp/ob-clojure.el
@@ -239,7 +239,7 @@ or set the `:backend' header argument"))))
 		result0)))
       (ob-clojure-string-or-list
        (reverse (delete "" (mapcar (lambda (r)
-				     (replace-regexp-in-string "nil" "" r))
+				     (replace-regexp-in-string "nil" "" (or r "")))
 				   result0)))))))
 
 (defun ob-clojure-eval-with-slime (expanded params)
-- 
2.38.1


[-- Attachment #3: Type: text/plain, Size: 620 bytes --]


Ihor Radchenko <yantar92@posteo.net> writes:

> "Christopher M. Miles" <numbchild@gmail.com> writes:
>
>> I have following Clojure source block:
>>
>> #+begin_src clojure
>> (re-find #"\d+" "I've just finished reading Fahrenheit 451");; => "451"
>> (re-find #"Bees" "Beads aren't cheap.");; => nil
>> #+end_src
>>
>> When I press =[C-c C-c]= to evaluate source block, got error:
>>
>> When there is no comments behind code lines. No this error.
>>
>> #+begin_example
>> Debugger entered--Lisp error: (wrong-type-argument arrayp nil)
>>   replace-regexp-in-string("nil" "" nil)
>
> Daniel, could you please take a look?

  reply	other threads:[~2022-10-27 12:39 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-11  4:08 ob-clojure eval error when has comment at end of code line Christopher M. Miles
2022-10-26  7:30 ` Ihor Radchenko
2022-10-27 12:25   ` Daniel Kraus [this message]
2022-10-27 14:17     ` Max Nikulin
2022-10-28  4:05     ` Ihor Radchenko
2022-10-28  9:40       ` ob-clojure session support (was: ob-clojure eval error when has comment at end of code line) Daniel Kraus
2022-10-28 10:20         ` ob-clojure session support Bastien Guerry
2022-10-29  3:03         ` ob-clojure session support (was: ob-clojure eval error when has comment at end of code line) Ihor Radchenko
2022-10-29  8:07           ` ob-clojure session support Bastien Guerry
2022-10-30 11:33           ` ob-clojure session support (was: ob-clojure eval error when has comment at end of code line) Daniel Kraus
2022-10-30 12:45             ` Ihor Radchenko
2022-10-29 20:13       ` indent-tabs-mode in org " Daniel Kraus
2022-10-31  9:49         ` indent-tabs-mode in org Bastien Guerry

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

  List information: https://www.orgmode.org/

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

  git send-email \
    --in-reply-to=878rl1a1e0.fsf@kraus.my \
    --to=daniel@kraus.my \
    --cc=emacs-orgmode@gnu.org \
    --cc=numbchild@gmail.com \
    --cc=yantar92@posteo.net \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.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).