From mboxrd@z Thu Jan 1 00:00:00 1970 From: Darlan Cavalcante Moreira Subject: Re: How to add content from a file to a table automatically Date: Thu, 10 Jan 2013 15:12:57 -0300 Message-ID: <50ef04af.0839650a.7f7b.ffff9872@mx.google.com> References: <50ee34c8.09fb640a.6b64.0e5a@mx.google.com> <87txqpy65u.fsf@gmail.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Return-path: Received: from eggs.gnu.org ([208.118.235.92]:39737) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TtMcl-0002pP-UN for emacs-orgmode@gnu.org; Thu, 10 Jan 2013 13:13:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TtMcj-0003b5-Nu for emacs-orgmode@gnu.org; Thu, 10 Jan 2013 13:13:07 -0500 Received: from mail-yh0-f51.google.com ([209.85.213.51]:42523) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TtMcj-0003b0-H8 for emacs-orgmode@gnu.org; Thu, 10 Jan 2013 13:13:05 -0500 Received: by mail-yh0-f51.google.com with SMTP id f73so154680yha.38 for ; Thu, 10 Jan 2013 10:13:04 -0800 (PST) In-Reply-To: <87txqpy65u.fsf@gmail.com> 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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Eric Schulte Cc: emacs-orgmode Thank you Eric and Jambunathan for your answers. If I process the whole table with babel to manually add the lines from the external file than I would have to take care of updating the formula for the "Total" value as well as making sure the new content was added before the "Total" line, right?. The later is simple, but updating the formula could be complicated. Meanwhile, I'm investigating using org-capture for this. For instance, if I use a template such as #+begin_src emacs-lisp ("f" "test" table-line (file+headline "test.org" "Test table") (file "path/food.org") :table-line-pos "II-1" :immediate-finish t) #+end_src where the food.org file has a single line then I can capture with #+begin_src emacs-lisp (org-capture nil "f")' #+end_src and org-capture will place the content from the "food.org" file in a table in the "Test Table" headline of the test.org file. The advantage of using org-capture instead of pure babel is that it will already put the content in the correct place and update the formulas. However, the formulas are updated correctly only if I capture a single line each time. I think a combination of babel with org-capture is my best option. Once that is working I will use your timer approach for automating this (while I investigate inotify suggested by Jambunathan). -- Darlan At Wed, 09 Jan 2013 22:10:37 -0700, Eric Schulte wrote: > > #+Title: Periodically Rerun a Code Block > > Here's the lisp code to define a function to continually re-run a code > block. Evaluate the following code block, then =M-x continually-run=, > press ENTER and then type in the name of the code block to continually > run (in this case "date"). > #+begin_src emacs-lisp :results silent > (defvar continual-runners nil > "Holds running block timers (so they may be canceled).") > > (defun run-block-in-buffer (name buffer) > (save-match-data > (with-current-buffer buffer > (save-excursion > (org-babel-goto-named-src-block name) > (with-local-quit > (undo-boundary) > (with-temp-message (format "re-running %s" name) > (org-babel-execute-src-block)) > (undo-boundary)))))) > > (defun continually-run (name) > "Continually run the supplied code block name. > The code block is assumed to be in the current buffer." > (interactive "scode block to continually run: ") > (let ((run-buffer (current-buffer))) > (add-to-list 'continual-runners > (run-at-time nil 5 'run-block-in-buffer name run-buffer)))) > #+end_src > > Here's the code block to be continually re-run. > #+Name: date > #+begin_src sh > date > #+end_src > > And here are the results which will be continually updated. > #+RESULTS: date > : Wed Jan 9 22:04:08 MST 2013 > > Execute the following to stop all continually updating code blocks. > #+begin_src emacs-lisp :results silent > (mapc #'cancel-timer continual-runners) > #+end_src