From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Charles C. Berry" Subject: Re: [PATCH] ob-core: check argument to goto-char Date: Sat, 30 Apr 2016 14:15:43 -0700 Message-ID: References: <87d1p79x17.fsf@eknet.org> <87bn4r9bms.fsf@eknet.org> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48990) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1awcFE-0003oT-52 for emacs-orgmode@gnu.org; Sat, 30 Apr 2016 17:16:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1awcF2-0007an-E6 for emacs-orgmode@gnu.org; Sat, 30 Apr 2016 17:16:02 -0400 Received: from iport-acv6-out.ucsd.edu ([132.239.0.13]:39388) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1awcF1-0007ZG-0P for emacs-orgmode@gnu.org; Sat, 30 Apr 2016 17:15:56 -0400 In-Reply-To: <87bn4r9bms.fsf@eknet.org> 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: Eike Cc: emacs-orgmode On Sat, 30 Apr 2016, Eike wrote: > > > Charles C. Berry writes: > >> On Sat, 30 Apr 2016, Eike wrote: >> >>> >>> Hi, >>> [much deleted] > > 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). > The easiest way to borrow babel tools is to use babel to execute src blocks directly. Here is a start. Run this src block to define a function `insert-quoted-list-as-result': #+BEGIN_SRC emacs-lisp (defun insert-quoted-list-as-result (my-list) (save-excursion (insert (format "#+BEGIN_SRC emacs-lisp\n '%S\n#+END_SRC\n\n" my-list)) (let ((org-confirm-babel-evaluate nil)) (org-babel-execute-src-block))) (delete-region (point) (org-babel-where-is-src-block-result))) #+END_SRC Then put the next line in an *.org buffer and try it out by typing C-x C-e just below the line: : (insert-quoted-list-as-result '(("id" "num") hline ("a" "1") ("b" "2"))) Note that it only works if point is on its own line. So you want to add some checks to prevent execution otherwise or to insert newlines as needed before invoking the function. Also note: if there is a #+RESULTS: block immediately following, it will be replaced, which you may not want. And you may want to remove the #+RESULTS: line, too. HTH, Chuck