From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eike Subject: Re: [PATCH] ob-core: check argument to goto-char Date: Sat, 30 Apr 2016 20:47:55 +0200 Message-ID: <87bn4r9bms.fsf@eknet.org> References: <87d1p79x17.fsf@eknet.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46048) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1awZwH-0005FE-CV for emacs-orgmode@gnu.org; Sat, 30 Apr 2016 14:48:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1awZw1-0002JO-Ch for emacs-orgmode@gnu.org; Sat, 30 Apr 2016 14:48:19 -0400 Received: from eknet.org ([188.40.107.134]:35583) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1awZw1-0002CU-6s for emacs-orgmode@gnu.org; Sat, 30 Apr 2016 14:48:09 -0400 In-reply-to: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: "Charles C. Berry" Cc: emacs-orgmode Charles C. Berry writes: > On Sat, 30 Apr 2016, Eike wrote: > >> >> Hi, >> >> I have some code that uses `org-babel-insert-result' and I've found that >> evaluating for example >> >> (org-babel-insert-result "a") >> >> results in an error. > > Although not explicitly marked as such, `org-babel-insert-result' seems > intended as an internal function for processing babel RESULTs. ok, I didn't know. >> The reason is that `goto-char' is called with a nil >> argument. > > When your snippet is in a src block or inline src block, there is no > error. Also, no error when point is in a src block and you run the snippet > with > > : M-x eval-expression RET (org-babel-insert-result "a") RET > > So, it looks like you are trying to evaluate the snippet above when > point is not in a src block. AFAICS, there is no guarantee that such usage > will succeed. > > Failure in such uses seems more like a feature than a bug. Ok, so it wasn't clear to me that point must be in a src block. Since the results are passed as argument, I made the false assumption that it inserts them where point currently is /or/ after a src block. The lisp code at that point (ob-core.el l.2212) invokes goto-char with nil which is caused by `inline' being nil. But the next line checks for `inline' being nil as does the line before: (if existing-result (goto-char existing-result) …) so I thought it might be good to check for that in the else-branch, too. >> I simply put the snippet in a `when' clause, but since the >> function is quite large I'm not so sure if it's now doing always the >> correct thing. At least my org files seem still to work…. >> >> I've added the patch in case it is ok to be applied. Maybe someone can >> have a look at it. >> > > See http://orgmode.org/worg/org-contribute.html for details on how to > contribute. Also, running `make test' on new code is a good idea. > > If you can explain what you are trying to achieve, someone may suggest a > fix that does not require retooling babel internals. I didn't really mean you to apply my patch, but rather have a look at it: thanks for that. I thought it's simpler to send a patch file than to explain in words… `make test' doesn't show unexpected failures to me, did I miss something? I'm sorry for breaking any contributing rules, I'll try to do better next time. What I want to do: I want to insert an org table somewhere in an org buffer. The data is not from an src block but retrieved from somewhere else. So I have a list like `(("id" "num") hline ("a" "1") ("b" "2"))' and I'd like to put it in a buffer as an org table (the buffer is in org-mode). It is certainly not my intention to retool babel internals to achieve this. My impression was that this may be a bug. But it may not, that's why I asking here. Thanks Eike -- gpg: AD7AC35E finger print: 137F BB0B 1639 D25F DC5D E59C B412 C5F5 AD7A C35E