1

您如何表达组织模式表的以下条件?

for every cell between the 2nd and 3rd hline: 
  if the cell is empty, 
    set the contents of the cell to todays date.
  else
    leave the cells contents as they are.

所以,鉴于下表,我想在空单元格中插入今天的日期。

|------------------|
| date             |
|------------------|
| [2014-05-23 Fri] |
| [2014-05-24 Sat] |
|                  |
|------------------|
4

1 回答 1

3

自定义计算函数 appendToday 会做你想做的事。它处理 hlines 之间的所有字段也为空的情况。

(defmath appendToday (idx v)
  (let ((d (date (month (now)) (day (now))))
        (len (vlen v)))
    (if (<= idx len)
      (if (equal (cadr v) 0)
        d
        (nth idx v)
      )
      d
    )
  )
)

评估前的表格如下所示:

|------------------|
| <2014-05-26 Mon> |
|                  |
|                  |
|                  |
|                  |
|                  |
|------------------|
#+TBLFM: @I..@II$1=appendToday(@#,@I..@II$1)

评估后的表格如下:

|------------------|
| <2014-05-26 Mon> |
| <2014-05-28 Wed> |
| <2014-05-28 Wed> |
| <2014-05-28 Wed> |
| <2014-05-28 Wed> |
| <2014-05-28 Wed> |
|------------------|
#+TBLFM: @I..@II$1=appendToday(@#,@I..@II$1)
于 2014-05-28T23:39:13.017 回答