From mboxrd@z Thu Jan 1 00:00:00 1970 From: Darlan Cavalcante Moreira Subject: How to add content from a file to a table automatically Date: Thu, 10 Jan 2013 00:25:56 -0300 Message-ID: <50ee34c8.09fb640a.6b64.0e5a@mx.google.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]:59997) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tt8mJ-0001nY-DD for emacs-orgmode@gnu.org; Wed, 09 Jan 2013 22:26:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tt8mI-0004rF-69 for emacs-orgmode@gnu.org; Wed, 09 Jan 2013 22:26:03 -0500 Received: from mail-ye0-f180.google.com ([209.85.213.180]:53783) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tt8mI-0004rB-0w for emacs-orgmode@gnu.org; Wed, 09 Jan 2013 22:26:02 -0500 Received: by mail-ye0-f180.google.com with SMTP id m9so18259yen.25 for ; Wed, 09 Jan 2013 19:26:01 -0800 (PST) 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: emacs-orgmode Is there a way to detect when a file changes and then add the content from it (if any, the file could be empty) to a specified org-mode table? Each line in that file is already constructed in a way that it could be copied and pasted to the table directly (but I can change that if it makes things easier). For instance, suppose I have the table below --8<---------------cut here---------------start------------->8--- #+TBLNAME: FoodJanuary2013 | | *Place* | *Date* | *Debit (R$)* | *Credit (R$)* | |---+-----------+------------------+--------------+---------------| | | Some name | [2013-01-07 Seg] | 0.00 | 10.00 | |---+-----------+------------------+--------------+---------------| | # | | *Total* | 0.00 | 10.00 | #+TBLFM: @3$4=vsum(@2..@-1);%.2f::@3$5=vsum(@2..@-1);%.2f --8<---------------cut here---------------end--------------->8--- and a file "food.txt" that was modified externally (Dropbox sync) and now has the content below --8<---------------cut here---------------start------------->8--- | # | place name | [2013-01-08 Ter] | 0.00 | 12.50 | | # | other place | [2013-01-09 Qua] | 9.30 | 0.00 | --8<---------------cut here---------------end--------------->8--- I'd like the table to be automatically updated to include these two new lines so that it should now corresponds to --8<---------------cut here---------------start------------->8--- #+TBLNAME: FoodJanuary2013 | | *Place* | *Date* | *Debit (R$)* | *Credit (R$)* | |---+-------------+------------------+--------------+---------------| | | Some name | [2013-01-09 Qua] | 0.00 | 10.00 | | # | place name | [2013-01-08 Ter] | 0.00 | 12.50 | | # | other place | [2013-01-09 Qua] | 9.30 | 0.00 | |---+-------------+------------------+--------------+---------------| | # | | *Total* | 9.30 | 22.50 | #+TBLFM: @5$4=vsum(@2..@-1);%.2f::@5$5=vsum(@2..@-1);%.2f --8<---------------cut here---------------end--------------->8--- Adapting the formula as org-mode would automatically do if I typed enter twice before the last hline is important, but updating the total value is not (although nice), since I can do that with "C-u C-u C-c *" later when I actually see the table. After that the content of the file should be erased to prevent future additions of the same information. Any hints on how to do the different parts for this are welcome. -- Darlan Ps: I use the latest org-mode and Emacs versions (from git and bzr, respectively) in a Linux box. The motivation for all this is that I use org-mode tables to control my expenses, but I want to be able to add new expenses from my android phone. Using the "tasker" app (REALLY good) I could create a simple UI to add the expense to a file that will be synced using Dropbox (one file for each category, which corresponds to a different table). All of this is working and now I the next step is the one described in this e-mail.