emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Derek Feichtinger <dfeich@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: org table with auto-incrementing numbers in a column
Date: Tue, 16 Feb 2016 09:16:38 +0000 (UTC)	[thread overview]
Message-ID: <loom.20160216T095701-420@post.gmane.org> (raw)
In-Reply-To: 87a8n1yv6m.fsf@duenenhof-wilhelm.de

Hi


> >
> > Try this
> >
> >   | N |   |
> >   |---+---|
> >   |   |   |
> >   |   |   |
> >   |   |   |
> >   |   |   |
> >   #+TBLFM: <at>$1..<at>>$1= <at>-1 + 1:: <at>2$1=1
> >

Sorry, I had a typo from copying and replacing <at> in my formula

should be


  | N |   |
  |---+---|
  | 1 |   |
  | 2 |   |
  | 3 |   |
  | 4 |   |
  #+TBLFM: <at>3$1..<at>>$1= <at>-1 + 1:: <at>2$1=1


> 
> I don't know exactly why  "N" is *not* erased but the following is
> working for me (org 8.2.10).

Hmmm... I just tested. Seems that org is treating the cells before the first
horizontal separator line as special... nice. But I seem to remember that
this was not always like this.

This made me now investigate more closely, using the formula debugger (C-c
{) for investigating the original formula.

When I use this formula

#+TBLFM: $1= @-1 + 1:: @2$1=1

Then org will first fill this part of the table (starting at cell <at>2$1)

  | N |   |
  |---+---|
  |   |   |
  | 1 |   |
  | 2 |   |
  | 3 |   |
  #+TBLFM: $1= <at>-1 + 1:: <at>2$1=1

Then it will execute the second formula, which sets the value in row 2:

  | N |   |
  |---+---|
  | 1 |   |
  | 1 |   |
  | 2 |   |
  | 3 |   |

Only upon a second evaluation of the whole table, it will arrive at

  | N |   |
  |---+---|
  | 1 |   |
  | 2 |   |
  | 3 |   |
  | 4 |   |

So, this is one of the cases where one needs to carry our iterations until
the table stays constant (can use org-table-iterate).

I also tried the same with changing the order of the two formulas. Seems
that the row formula always is executed first. So, at least this is
consistent. Why it starts at row 3 one would need to look up in the source...


> 
> | N     |
> |-------|
> |     1 |
> |     2 |
> |     3 |
> |     4 |
> |     5 |
> #+TBLFM: $1= <at> #-1
> 
> > Placing point on the TBLFM line and doing C-c C-c should recalculate the
> > whole table.

That formula works fine. It's just a difference in functionality.. the above
formula calculates a value based on the numeric position of the current row,
while the other formula looks up the value above the current row.

Cheers,
Derek

  reply	other threads:[~2016-02-16  9:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-16  4:36 org table with auto-incrementing numbers in a column Kaushal Modi
2016-02-16  6:22 ` Derek Feichtinger
2016-02-16  7:24   ` H. Dieter Wilhelm
2016-02-16  9:16     ` Derek Feichtinger [this message]
2016-02-16 16:51       ` Nicolas Goaziou
2016-02-16  9:58   ` Eric S Fraga
2016-02-16 16:28     ` Kaushal Modi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=loom.20160216T095701-420@post.gmane.org \
    --to=dfeich@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).