emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] org-timestamp-change changes minutes in multiples of rounding time
@ 2010-06-22 11:10 Puneeth
  2010-06-22 12:22 ` Puneeth
  2010-06-22 13:33 ` Carsten Dominik
  0 siblings, 2 replies; 6+ messages in thread
From: Puneeth @ 2010-06-22 11:10 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 319 bytes --]

Hi,

(org-timestamp-change n 'minutes) changes timestamp only by 5 minutes
(when my org-time-stamp-rounding-minutes is (0 5)) for any non-zero
value of n.

I think the timestamp should change by an integer multiple of 5. Do
you think this is correct behaviour?

A patch for the same has been attached.

Thanks,
Puneeth

[-- Attachment #2: org-timestamp-change.patch --]
[-- Type: application/octet-stream, Size: 589 bytes --]

diff --git a/lisp/org.el b/lisp/org.el
index e25194c..b4d2bd7 100755
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -14981,7 +14981,8 @@ in the timestamp determines what will be changed."
       (setq time0 (org-parse-time-string ts))
       (when (and (eq org-ts-what 'minute)
 		 (eq current-prefix-arg nil))
-	(setq n (* dm (cond ((> n 0) 1) ((< n 0) -1) (t 0))))
+	(setq n (* dm (cond ((> n 0) (max (/ n dm) 1)) 
+			    ((< n 0) (min (/ n dm) -1)) (t 0))))
 	(when (not (= 0 (setq rem (% (nth 1 time0) dm))))
 	  (setcar (cdr time0) (+ (nth 1 time0)
 				 (if (> n 0) (- rem) (- dm rem))))))

[-- Attachment #3: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: [PATCH] org-timestamp-change changes minutes in multiples of rounding time
  2010-06-22 11:10 [PATCH] org-timestamp-change changes minutes in multiples of rounding time Puneeth
@ 2010-06-22 12:22 ` Puneeth
  2010-06-22 13:33 ` Carsten Dominik
  1 sibling, 0 replies; 6+ messages in thread
From: Puneeth @ 2010-06-22 12:22 UTC (permalink / raw)
  To: emacs-orgmode

On Tue, Jun 22, 2010 at 4:40 PM, Puneeth <punchagan@gmail.com> wrote:
[..]
> A patch for the same has been attached.

Sorry hadn't looked at this piece of documentation in the manual[1]
          (/ -17 6)
               ⇒ -2   (could in theory be −3 on some machines)

The patch could be modified to make it consistent.

[1] http://www.gnu.org/s/emacs/manual/html_node/elisp/Arithmetic-Operations.html

-- 
Puneeth

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

* Re: [PATCH] org-timestamp-change changes minutes in multiples of rounding time
  2010-06-22 11:10 [PATCH] org-timestamp-change changes minutes in multiples of rounding time Puneeth
  2010-06-22 12:22 ` Puneeth
@ 2010-06-22 13:33 ` Carsten Dominik
  2010-06-22 13:48   ` Puneeth
  1 sibling, 1 reply; 6+ messages in thread
From: Carsten Dominik @ 2010-06-22 13:33 UTC (permalink / raw)
  To: Puneeth; +Cc: emacs-orgmode


On Jun 22, 2010, at 1:10 PM, Puneeth wrote:

> Hi,
>
> (org-timestamp-change n 'minutes) changes timestamp only by 5 minutes
> (when my org-time-stamp-rounding-minutes is (0 5)) for any non-zero
> value of n.
>
> I think the timestamp should change by an integer multiple of 5. Do
> you think this is correct behaviour?

Hi Puneeth,

no, I do not think so.  The variable is called "-rounding", not "-step".

Cheers

- Carsten

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

* Re: [PATCH] org-timestamp-change changes minutes in multiples of rounding time
  2010-06-22 13:33 ` Carsten Dominik
@ 2010-06-22 13:48   ` Puneeth
  2010-06-22 14:17     ` Carsten Dominik
  0 siblings, 1 reply; 6+ messages in thread
From: Puneeth @ 2010-06-22 13:48 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode

Hi Carsten,

On Tue, Jun 22, 2010 at 7:03 PM, Carsten Dominik
<carsten.dominik@gmail.com> wrote:
>
> On Jun 22, 2010, at 1:10 PM, Puneeth wrote:
[..]
> no, I do not think so.  The variable is called "-rounding", not "-step".

Sorry for the unclear message. Let me explain.

I tried to use the function shown below (imitating a similar function
by Juan Pechier [1]). But this function only changes the time by
either +5 or -5 minutes for whatever value of "n". Should it not,
increase the time by a multiple of 5 mins?

8<----------------------------------------

(defun upminutes ( n )
  "update all timestamps n minutes"
  (interactive "nAdd minutes: ")
  (save-excursion
    (goto-char (point-min))
     (while (re-search-forward "[[<]" nil t)
       (when (org-at-timestamp-p t)
         (org-timestamp-change n 'minute)
         ))))

8<----------------------------------------

Thanks,
Puneeth

[1] http://lists.gnu.org/archive/html/emacs-orgmode/2010-06/msg00229.html

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

* Re: [PATCH] org-timestamp-change changes minutes in multiples of rounding time
  2010-06-22 13:48   ` Puneeth
@ 2010-06-22 14:17     ` Carsten Dominik
  2010-06-22 14:46       ` Puneeth
  0 siblings, 1 reply; 6+ messages in thread
From: Carsten Dominik @ 2010-06-22 14:17 UTC (permalink / raw)
  To: Puneeth; +Cc: emacs-orgmode

Hi Puneeth,

I have now understood, and changed the behavior so that
your function should work correctly.

Note that the rounding only works now if you use S-up and S-down
on the minutes.  If you give your function of 13 minutes, it will  
change all time stamps by 13 minutes, not a rounded number.

HTH

- Carsten


On Jun 22, 2010, at 3:48 PM, Puneeth wrote:

> Hi Carsten,
>
> On Tue, Jun 22, 2010 at 7:03 PM, Carsten Dominik
> <carsten.dominik@gmail.com> wrote:
>>
>> On Jun 22, 2010, at 1:10 PM, Puneeth wrote:
> [..]
>> no, I do not think so.  The variable is called "-rounding", not "- 
>> step".
>
> Sorry for the unclear message. Let me explain.
>
> I tried to use the function shown below (imitating a similar function
> by Juan Pechier [1]). But this function only changes the time by
> either +5 or -5 minutes for whatever value of "n". Should it not,
> increase the time by a multiple of 5 mins?
>
> 8<----------------------------------------
>
> (defun upminutes ( n )
>  "update all timestamps n minutes"
>  (interactive "nAdd minutes: ")
>  (save-excursion
>    (goto-char (point-min))
>     (while (re-search-forward "[[<]" nil t)
>       (when (org-at-timestamp-p t)
>         (org-timestamp-change n 'minute)
>         ))))
>
> 8<----------------------------------------
>
> Thanks,
> Puneeth
>
> [1] http://lists.gnu.org/archive/html/emacs-orgmode/2010-06/msg00229.html

- Carsten

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

* Re: [PATCH] org-timestamp-change changes minutes in multiples of rounding time
  2010-06-22 14:17     ` Carsten Dominik
@ 2010-06-22 14:46       ` Puneeth
  0 siblings, 0 replies; 6+ messages in thread
From: Puneeth @ 2010-06-22 14:46 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode

Hi Carsten,

On Tue, Jun 22, 2010 at 7:47 PM, Carsten Dominik
<carsten.dominik@gmail.com> wrote:
[..]
> Note that the rounding only works now if you use S-up and S-down
> on the minutes.  If you give your function of 13 minutes, it will change all
> time stamps by 13 minutes, not a rounded number.
>
> HTH

Thanks!

--
Puneeth

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

end of thread, other threads:[~2010-06-22 14:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-22 11:10 [PATCH] org-timestamp-change changes minutes in multiples of rounding time Puneeth
2010-06-22 12:22 ` Puneeth
2010-06-22 13:33 ` Carsten Dominik
2010-06-22 13:48   ` Puneeth
2010-06-22 14:17     ` Carsten Dominik
2010-06-22 14:46       ` Puneeth

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).