From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: Bug: clocktable doesn't preserve formulas with :scope file-with-archives Date: Thu, 27 Oct 2016 11:47:39 +0200 Message-ID: <87eg32i0n8.fsf@nicolasgoaziou.fr> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:60258) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bzhHl-0004Jj-Bc for emacs-orgmode@gnu.org; Thu, 27 Oct 2016 05:47:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bzhHf-0007qi-Ln for emacs-orgmode@gnu.org; Thu, 27 Oct 2016 05:47:45 -0400 Received: from relay3-d.mail.gandi.net ([2001:4b98:c:538::195]:38946) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1bzhHf-0007pl-FO for emacs-orgmode@gnu.org; Thu, 27 Oct 2016 05:47:39 -0400 In-Reply-To: (dale@codefu.org's message of "Fri, 21 Oct 2016 13:13:57 -0500") 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: Dale Cc: emacs-orgmode@gnu.org Hello, Dale writes: > Hi! I've found that the "#+TBLFM:" in a clocktable can get changed or > deleted when used together with ":scope file-with-archives". Here's a > minimal org file to reproduce with: > > ------8<------ > * Test > :LOGBOOK: > CLOCK: [2016-10-20 Thu 17:42]--[2016-10-20 Thu 18:03] => 0:21 > :END: > > #+BEGIN: clocktable :scope file-with-archives > #+TBLFM: $3=string("foo") > > #+END: > ------8<------ > > Steps to reproduce: > > 1. emacs -Q, load above file with org-mode from Git > > 2. Update clocktable dblock (move to "#+BEGIN" and C-c C-c) > > Expected result: a third column is added with value "foo" in every > row; #+TBLFM line is preserved > > Observed result: table has two columns, the second of which contains > "foo" in every row; #+TBLFM line changes from $3=string("foo") to > $2=string("foo") > > If you keep updating the block, the formula's "$2" then becomes "$1". > Do it one more time and the "#+TBLFM:" is preserved but now the > formula is gone entirely. > > Emacs : GNU Emacs 25.1.1 (x86_64-apple-darwin15.6.0) > of 2016-09-23 > Package: Org-mode version 8.2.10 (release_8.2.10 @ /opt/local/share/emacs/25.1/\ > lisp/org/) > > I have also reproduced this with org-mode from Git as of an hour or so ago. > > My hunch is that the problem is in org-clocktable-write-default. It > writes the table (the dblock's contents have already been deleted), > restores any #+TBLFM: line that used to be there pre-update, and then, > if you're using :scope file-with-archives, it deletes the file column, > which is the first column. The order here is the problem: > org-table-delete-column updates the formula in #+TBLFM, decrementing > the column reference to account for the deleted column. > > If this sounds right then I'd suggest that the solution may be as > simple as just updating org-clocktable-write-default to insert table > formulas *after* deleting the file column Thank you for the report and the analysis. This is now fixed. Regards, -- Nicolas Goaziou