all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* org-table-copy-down incrementor
@ 2014-04-12 11:56 Stacey Marshall
  2014-04-17 16:06 ` Bastien
  0 siblings, 1 reply; 12+ messages in thread
From: Stacey Marshall @ 2014-04-12 11:56 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

I've been using org-mode for a little over a year, wish I had been using it for far longer.
I am not a member of this list...  I discovered it via <http://orgmode.org/org.html#Feedback>, a link to the list there would be helpful.

I discovered org-table-copy-down and its ability to increment dates.  I would like to be able to specify the number to increment, and then ideally increment by that number again.  For example lets say I want to create a table of Mondays....

| [2014-05-19 Mon] |   |   |   |   |   |   |   |
| [2014-05-26 Mon] |   |   |   |   |   |   |   |
| [2014-06-02 Mon] |   |   |   |   |   |   |   |
| [2014-06-09 Mon] |   |   |   |   |   |   |   |

Firstly, should I be using #+TBLFM: to fill in the table above...  I think that would only work if I was writing across columns, and would require a calculation for each field... is that right?  Hmm, is their a repeat keyword.....

I wonder if a simple solution might be to add a couple of custom variables, say 
org-table-copy-inc-count to hold the count, and for the time specific 
org-table-copy-inc-by to specify what is being incremented, i.e. days, hours, mins.

For my use a simple integer would have sufficed, but a time element would be more suitable for others uses.


*** /opt/local/share/emacs/site-lisp/org/org-table.el	Tue May 14 15:13:53 2013
--- /var/folders/6f/qt_5cdl91051fz5tbwrf8yy00000gn/T/ediff275HnR	Sat Apr 12 12:52:12 2014
***************
*** 224,229 ****
--- 224,250 ----
    :group 'org-table-calculation
    :type 'boolean)
  
+ (defcustom org-table-copy-inc-count 1
+   "Increment value used to increment field following copy by \\[org-table-copy-down]."
+   :group 'org-table-calculation
+   :type 'integer)
+ 
+ (defcustom org-table-copy-inc-by 'day
+   "Measure in which to increment org-table-copy-inc-count value by  \\[org-table-copy-down].
+ Possible values are:
+ day
+ month
+ year
+ minute
+ second"
+   :group 'org-table-calculation
+   :type '(choice
+ 	  (const :tag "day" day)
+ 	  (const :tag "month" month)
+ 	  (const :tag "year" year)
+ 	  (const :tag "minute" minute)
+ 	  (const :tag "second" second)))
+ 
  (defcustom org-calc-default-modes
    '(calc-internal-prec 12
  		       calc-float-format  (float 8)
***************
*** 1150,1156 ****
  	  (insert txt)
  	  (org-move-to-column col)
  	  (if (and org-table-copy-increment (org-at-timestamp-p t))
! 	      (org-timestamp-up-day)
  	    (org-table-maybe-recalculate-line))
  	  (org-table-align)
  	  (org-move-to-column col))
--- 1171,1178 ----
  	  (insert txt)
  	  (org-move-to-column col)
  	  (if (and org-table-copy-increment (org-at-timestamp-p t))
! 	      (org-timestamp-change org-table-copy-inc-count org-table-copy-inc-by)
! ;	      (org-timestamp-up-day)
  	    (org-table-maybe-recalculate-line))
  	  (org-table-align)
  	  (org-move-to-column col))

The above works for my needs, but perhaps someone has a more elegant solution...


Yours sincerely,

Stacey

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: org-table-copy-down incrementor
  2014-04-12 11:56 org-table-copy-down incrementor Stacey Marshall
@ 2014-04-17 16:06 ` Bastien
  2014-04-30 16:25   ` Michael Brand
  0 siblings, 1 reply; 12+ messages in thread
From: Bastien @ 2014-04-17 16:06 UTC (permalink / raw)
  To: Stacey Marshall; +Cc: emacs-orgmode

Hi Stacey,

Stacey Marshall <stacey.marshall@oracle.com> writes:

> I am not a member of this list...  I discovered it via
> <http://orgmode.org/org.html#Feedback>, a link to the list there would
> be helpful.

I added a link to the manual, thanks.

> I discovered org-table-copy-down and its ability to increment dates.
> I would like to be able to specify the number to increment, and then
> ideally increment by that number again.  For example lets say I want
> to create a table of Mondays....

The idea came up earlier on to let org-table-copy-down increment by
using a table formula -- which is my TODO list for Org 8.3.  I'll let
the list know when it's ready, but I think it would be a useful
feature.

Thanks,

-- 
 Bastien

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: org-table-copy-down incrementor
  2014-04-17 16:06 ` Bastien
@ 2014-04-30 16:25   ` Michael Brand
  2014-05-20 14:11     ` Bastien
  0 siblings, 1 reply; 12+ messages in thread
From: Michael Brand @ 2014-04-30 16:25 UTC (permalink / raw)
  To: Bastien; +Cc: Org Mode, Stacey Marshall

Hi Bastien

On Thu, Apr 17, 2014 at 6:06 PM, Bastien <bzg@gnu.org> wrote:
> The idea came up earlier on to let org-table-copy-down increment by
> using a table formula -- which is my TODO list for Org 8.3.  I'll let
> the list know when it's ready, but I think it would be a useful
> feature.

For me it would be already enough and preferred when the increment
would be the same as in the two fields above point. Like in other well
known spreadsheet applications. Without new Org custom variables and
without the possibility or requirement of providing a table formula:

    | 2 |
    | 5 |

    SHIFT-RET =>

    | 2 |
    | 5 |
    | 8 |

or

    |  1.1 |
    | -0.5 |

    SHIFT-RET =>

    |  1.1 |
    | -0.5 |
    | -2.1 |

or

    | [2014-04-30 Wed] |
    | [2014-05-07 Wed] |

    SHIFT-RET =>

    | [2014-04-30 Wed] |
    | [2014-05-07 Wed] |
    | [2014-05-14 Wed] |

etc.

Michael

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: org-table-copy-down incrementor
  2014-04-30 16:25   ` Michael Brand
@ 2014-05-20 14:11     ` Bastien
  2014-05-20 16:26       ` Michael Brand
  2014-05-30 10:37       ` Stacey Marshall
  0 siblings, 2 replies; 12+ messages in thread
From: Bastien @ 2014-05-20 14:11 UTC (permalink / raw)
  To: Michael Brand; +Cc: Org Mode, Stacey Marshall

Hi Michael,

Michael Brand <michael.ch.brand@gmail.com> writes:

> For me it would be already enough and preferred when the increment
> would be the same as in the two fields above point.

I pushed a change in master for this -- can you please check it works
as expected for you?

Thanks for this suggestion!  (A lot easier than other routes likes
using a dedicated #+TBLINC line.)

Best,

-- 
 Bastien

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: org-table-copy-down incrementor
  2014-05-20 14:11     ` Bastien
@ 2014-05-20 16:26       ` Michael Brand
  2014-05-20 19:45         ` Bastien
  2014-05-30 10:37       ` Stacey Marshall
  1 sibling, 1 reply; 12+ messages in thread
From: Michael Brand @ 2014-05-20 16:26 UTC (permalink / raw)
  To: Bastien; +Cc: Org Mode, Stacey Marshall

Hi Bastien

On Tue, May 20, 2014 at 4:11 PM, Bastien <bzg@gnu.org> wrote:
> Michael Brand <michael.ch.brand@gmail.com> writes:
>> For me it would be already enough and preferred when the increment
>> would be the same as in the two fields above point.
>
> I pushed a change in master for this --

Thank you for implementing this.

> can you please check it works as expected for you?

Yes it does: SHIFT-RET on the last row of the tables
    | 2 |
    | 5 |
and
    | 2 |
and
    | [2014-04-30 Wed] |
    | [2014-05-07 Wed] |
and
    | [2014-04-30 Wed] |
increment as expected.

As I see only now the use case
    |  1.1 |
    | -0.5 |
does not seem easy to increment by -1.6 due to the formatting of the
result, so I don't expect it to be implemented. (number-to-string is
not enough because of the inaccuracy of the fraction.)

> (const :tag "Don't increment the value when copying a field" t)))

Wasn't the t meant to be nil?

Michael

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: org-table-copy-down incrementor
  2014-05-20 16:26       ` Michael Brand
@ 2014-05-20 19:45         ` Bastien
  2014-05-21 15:32           ` Michael Brand
  0 siblings, 1 reply; 12+ messages in thread
From: Bastien @ 2014-05-20 19:45 UTC (permalink / raw)
  To: Michael Brand; +Cc: Org Mode, Stacey Marshall

Hi Michael,

Michael Brand <michael.ch.brand@gmail.com> writes:

> As I see only now the use case
>     |  1.1 |
>     | -0.5 |
> does not seem easy to increment by -1.6 due to the formatting of the
> result, so I don't expect it to be implemented. (number-to-string is
> not enough because of the inaccuracy of the fraction.)

Yes.  There is also `thing-at-point' which does not recognize 1.1 as a
number... I circumvented this by using `calc-eval'.  The above should
now work correctly.

>> (const :tag "Don't increment the value when copying a field" t)))
>
> Wasn't the t meant to be nil?

It was a typo, thanks for reporting it!

-- 
 Bastien

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: org-table-copy-down incrementor
  2014-05-20 19:45         ` Bastien
@ 2014-05-21 15:32           ` Michael Brand
  2014-05-21 15:49             ` Bastien
  0 siblings, 1 reply; 12+ messages in thread
From: Michael Brand @ 2014-05-21 15:32 UTC (permalink / raw)
  To: Bastien; +Cc: Org Mode, Stacey Marshall

Hi Bastien

On Tue, May 20, 2014 at 9:45 PM, Bastien <bzg@gnu.org> wrote:
> Yes.  There is also `thing-at-point' which does not recognize 1.1 as a
> number... I circumvented this by using `calc-eval'.  The above should
> now work correctly.

Yes it does. Using Calc is a nice solution, thank you.

I did not notice before but the first commit
7ac468ff5547891503b6b8f5fa03793d79b3bff6
changed SHIFT-RET on the empty field
    | 2 |
    | 5 |
    |   |
to add a new row instead of only replacing the current field.

Michael

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: org-table-copy-down incrementor
  2014-05-21 15:32           ` Michael Brand
@ 2014-05-21 15:49             ` Bastien
  2014-05-21 16:22               ` Michael Brand
  0 siblings, 1 reply; 12+ messages in thread
From: Bastien @ 2014-05-21 15:49 UTC (permalink / raw)
  To: Michael Brand; +Cc: Org Mode, Stacey Marshall

Hi Michael,

Michael Brand <michael.ch.brand@gmail.com> writes:

> I did not notice before but the first commit
> 7ac468ff5547891503b6b8f5fa03793d79b3bff6
> changed SHIFT-RET on the empty field
>     | 2 |
>     | 5 |
>     |   |
> to add a new row instead of only replacing the current field.

This is now fixed in master, thanks for spotting this.

-- 
 Bastien

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: org-table-copy-down incrementor
  2014-05-21 15:49             ` Bastien
@ 2014-05-21 16:22               ` Michael Brand
  2014-05-21 16:38                 ` Bastien
  0 siblings, 1 reply; 12+ messages in thread
From: Michael Brand @ 2014-05-21 16:22 UTC (permalink / raw)
  To: Bastien; +Cc: Org Mode, Stacey Marshall

Hi Bastien

On Wed, May 21, 2014 at 5:49 PM, Bastien <bzg@gnu.org> wrote:
> Michael Brand <michael.ch.brand@gmail.com> writes:
>> I did not notice before but the first commit
>> 7ac468ff5547891503b6b8f5fa03793d79b3bff6
>> changed SHIFT-RET on the empty field
>>     | 2 |
>>     | 5 |
>>     |   |
>> to add a new row instead of only replacing the current field.
>
> This is now fixed in master, thanks for spotting this.

I get a "setq: Wrong type argument: stringp" with SHIFT-RET in the empty
field of
    | 2 |
    |   |
and
    | [2014-04-30 Wed] |
    |                  |
and
    | 1.1 |
    |     |

Michael

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: org-table-copy-down incrementor
  2014-05-21 16:22               ` Michael Brand
@ 2014-05-21 16:38                 ` Bastien
  2014-05-21 17:09                   ` Michael Brand
  0 siblings, 1 reply; 12+ messages in thread
From: Bastien @ 2014-05-21 16:38 UTC (permalink / raw)
  To: Michael Brand; +Cc: Org Mode, Stacey Marshall

Michael Brand <michael.ch.brand@gmail.com> writes:

> I get a "setq: Wrong type argument: stringp" with SHIFT-RET in the empty
> field of
>     | 2 |
>     |   |
> and
>     | [2014-04-30 Wed] |
>     |                  |
> and
>     | 1.1 |
>     |     |

Er, fixed, thanks!

-- 
 Bastien

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: org-table-copy-down incrementor
  2014-05-21 16:38                 ` Bastien
@ 2014-05-21 17:09                   ` Michael Brand
  0 siblings, 0 replies; 12+ messages in thread
From: Michael Brand @ 2014-05-21 17:09 UTC (permalink / raw)
  To: Bastien; +Cc: Org Mode, Stacey Marshall

Hi Bastien

On Wed, May 21, 2014 at 6:38 PM, Bastien <bzg@gnu.org> wrote:
> Er, fixed, thanks!

I tried some (3 * 2 * 2) variants and all work, thank you.

Michael

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: org-table-copy-down incrementor
  2014-05-20 14:11     ` Bastien
  2014-05-20 16:26       ` Michael Brand
@ 2014-05-30 10:37       ` Stacey Marshall
  1 sibling, 0 replies; 12+ messages in thread
From: Stacey Marshall @ 2014-05-30 10:37 UTC (permalink / raw)
  To: Bastien; +Cc: Org Mode

Hi Bastien,

I'm late to this party I know, but wanted to confirm all is working well for me too.

Best regards,

Stacey

On 20 May 2014, at 15:11, Bastien <bzg@gnu.org> wrote:

> Hi Michael,
> 
> Michael Brand <michael.ch.brand@gmail.com> writes:
> 
>> For me it would be already enough and preferred when the increment
>> would be the same as in the two fields above point.
> 
> I pushed a change in master for this -- can you please check it works
> as expected for you?
> 
> Thanks for this suggestion!  (A lot easier than other routes likes
> using a dedicated #+TBLINC line.)
> 
> Best,
> 
> -- 
> Bastien

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2014-05-30 10:37 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-12 11:56 org-table-copy-down incrementor Stacey Marshall
2014-04-17 16:06 ` Bastien
2014-04-30 16:25   ` Michael Brand
2014-05-20 14:11     ` Bastien
2014-05-20 16:26       ` Michael Brand
2014-05-20 19:45         ` Bastien
2014-05-21 15:32           ` Michael Brand
2014-05-21 15:49             ` Bastien
2014-05-21 16:22               ` Michael Brand
2014-05-21 16:38                 ` Bastien
2014-05-21 17:09                   ` Michael Brand
2014-05-30 10:37       ` Stacey Marshall

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.