Browse Source

Time stamps: Changing time ranges as a block.

Anupam Sengupta writes:

>  I routinely use time ranges (and occasionally time-stamp ranges)
>  in my org files to document the scheduled block of time for a
>  meeting or activity.  As an example, I will mark meetings as:
>
>  * A Meeting
>   <2009-03-12 Thu 10:00-11:00>
>
>  As often happens with meetings, rescheduling needs to be done and
>  I use S-<up> or S-<down> on the time-stamp to make the
>  modifications.  While this works fine, it usually leads to a
>  duplication when the *time* part of the time-stamp needs to be
>  changed.
>
>  For the same example above, if the time-block has now changed to
>  11:00-12:00, then I need to do S-<up> on both the "10:00" and the
>  "11:00" string.  I.e,
>
>
>  * A Meeting
>   <2009-03-12 Thu 11:00-11:00>
>                    ^
>                    +---------------- After the first S-<up>
>
>  * A Meeting
>   <2009-03-12 Thu 11:00-12:00>
>                          ^
>                          +---------------- After the second S-<up>
>
>  Can we have a feature (with a toggle option perhaps) which would
>  *move* the block (i.e., both time entries) by the same amount
>  when either one is moved in the same direction. I.e., the
>  proposal is to have:
>
>  * A Meeting
>   <2009-03-12 Thu 11:00-12:00>
>                    ^     ^
>                    |     |
>                    |     +---------- Automatically shifted
>                    +---------------- After the S-<up>

This is in fact how changing time works in many applications, and
it does make sense here as well.  The commits implements this
change.

It also implements a way to change the start time of an entry from
the agenda.  The date is normally changed with S-right/left.
Now, if you add a C-u prefix, the hour will be changed.  If you
immediately press S-right/left again, hours will continue to be
changed.

A double prefix will do the same for minutes.
Carsten Dominik 16 years ago
parent
commit
acfcb14c82
5 changed files with 97 additions and 10 deletions
  1. 5 0
      doc/ChangeLog
  2. 12 6
      doc/org.texi
  3. 11 0
      lisp/ChangeLog
  4. 62 4
      lisp/org-agenda.el
  5. 7 0
      lisp/org.el

+ 5 - 0
doc/ChangeLog

@@ -1,3 +1,8 @@
+2009-03-14  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org.texi (Creating timestamps, Agenda commands): Document new
+	behavior when changing time stamps.
+
 2009-03-11  Carsten Dominik  <carsten.dominik@gmail.com>
 2009-03-11  Carsten Dominik  <carsten.dominik@gmail.com>
 
 
 	* org.texi (Structure editing): Document the new command
 	* org.texi (Structure editing): Document the new command

+ 12 - 6
doc/org.texi

@@ -4717,10 +4717,13 @@ CUA mode (@pxref{Conflicts}).
 @item S-@key{up}
 @item S-@key{up}
 @itemx S-@key{down}
 @itemx S-@key{down}
 Change the item under the cursor in a timestamp.  The cursor can be on a
 Change the item under the cursor in a timestamp.  The cursor can be on a
-year, month, day, hour or minute.  Note that if the cursor is in a
-headline and not at a time stamp, these same keys modify the priority of
-an item.  (@pxref{Priorities}). The key bindings also conflict with
-CUA mode (@pxref{Conflicts}).
+year, month, day, hour or minute.  When the time stamp contains a time range
+like @samp{15:30-16:30}, modifying the first time will also shift the second,
+shifting the time block with constant length.  To change the length, modify
+the second time.  Note that if the cursor is in a headline and not at a time
+stamp, these same keys modify the priority of an item.
+(@pxref{Priorities}). The key bindings also conflict with CUA mode
+(@pxref{Conflicts}).
 @c
 @c
 @kindex C-c C-y
 @kindex C-c C-y
 @cindex evaluate time range
 @cindex evaluate time range
@@ -6855,9 +6858,12 @@ command.
 @item S-@key{right}
 @item S-@key{right}
 Change the time stamp associated with the current line by one day into the
 Change the time stamp associated with the current line by one day into the
 future.  With a numeric prefix argument, change it by that many days.  For
 future.  With a numeric prefix argument, change it by that many days.  For
-example, @kbd{3 6 5 S-@key{right}} will change it by a year.  The stamp is
+example, @kbd{3 6 5 S-@key{right}} will change it by a year.  With a
+@kbd{C-u} prefix, change the time by one hour.  If you immediately repeat the
+command, it will continue to change hours even without the prefix arg.  With
+a double @kbdC-u C-u} prefix, do the same for changing minutes.  The stamp is
 changed in the original org file, but the change is not directly reflected in
 changed in the original org file, but the change is not directly reflected in
-the agenda buffer.  Use the @kbd{r} key to update the buffer.
+the agenda buffer.  Use @kbd{r} or @kbd{g} to update the buffer.
 @c
 @c
 @kindex S-@key{left}
 @kindex S-@key{left}
 @item S-@key{left}
 @item S-@key{left}

+ 11 - 0
lisp/ChangeLog

@@ -1,3 +1,14 @@
+2009-03-14  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org-agenda.el (org-agenda-menu): Add new commands to menu.
+	(org-agenda-do-date-later, org-agenda-do-date-earlier)
+	(org-agenda-date-later-minutes, org-agenda-date-earlier-minutes)
+	(org-agenda-date-later-hours, org-agenda-date-earlier-hours): New
+	commands.
+
+	* org.el (org-timestamp-change): Move end-time along with start
+	time.
+
 2009-03-12  Carsten Dominik  <carsten.dominik@gmail.com>
 2009-03-12  Carsten Dominik  <carsten.dominik@gmail.com>
 
 
 	* org-exp.el (org-export-target-internal-links)
 	* org-exp.el (org-export-target-internal-links)

+ 62 - 4
lisp/org-agenda.el

@@ -1260,10 +1260,10 @@ The following commands are available:
 (org-defkey org-agenda-mode-map "z"        'org-agenda-add-note)
 (org-defkey org-agenda-mode-map "z"        'org-agenda-add-note)
 (org-defkey org-agenda-mode-map "k"        'org-agenda-action)
 (org-defkey org-agenda-mode-map "k"        'org-agenda-action)
 (org-defkey org-agenda-mode-map "\C-c\C-x\C-k" 'org-agenda-action)
 (org-defkey org-agenda-mode-map "\C-c\C-x\C-k" 'org-agenda-action)
-(org-defkey org-agenda-mode-map [(shift right)] 'org-agenda-date-later)
-(org-defkey org-agenda-mode-map [(shift left)] 'org-agenda-date-earlier)
-(org-defkey org-agenda-mode-map [?\C-c ?\C-x (right)] 'org-agenda-date-later)
-(org-defkey org-agenda-mode-map [?\C-c ?\C-x (left)] 'org-agenda-date-earlier)
+(org-defkey org-agenda-mode-map [(shift right)] 'org-agenda-do-date-later)
+(org-defkey org-agenda-mode-map [(shift left)] 'org-agenda-do-date-earlier)
+(org-defkey org-agenda-mode-map [?\C-c ?\C-x (right)] 'org-agenda-do-date-later)
+(org-defkey org-agenda-mode-map [?\C-c ?\C-x (left)] 'org-agenda-do-date-earlier)
 
 
 (org-defkey org-agenda-mode-map ">" 'org-agenda-date-prompt)
 (org-defkey org-agenda-mode-map ">" 'org-agenda-date-prompt)
 (org-defkey org-agenda-mode-map "\C-c\C-s" 'org-agenda-schedule)
 (org-defkey org-agenda-mode-map "\C-c\C-s" 'org-agenda-schedule)
@@ -1377,6 +1377,10 @@ The following commands are available:
      "--"
      "--"
      ["Change Date +1 day" org-agenda-date-later (org-agenda-check-type nil 'agenda 'timeline)]
      ["Change Date +1 day" org-agenda-date-later (org-agenda-check-type nil 'agenda 'timeline)]
      ["Change Date -1 day" org-agenda-date-earlier (org-agenda-check-type nil 'agenda 'timeline)]
      ["Change Date -1 day" org-agenda-date-earlier (org-agenda-check-type nil 'agenda 'timeline)]
+     ["Change Time +1 hour" org-agenda-do-date-later :active (org-agenda-check-type nil 'agenda 'timeline) :keys "C-u S-right"]
+     ["Change Time -1 hour" org-agenda-do-date-earlier :active (org-agenda-check-type nil 'agenda 'timeline) :keys "C-u S-left"]
+     ["Change Time +  min" org-agenda-date-later :active (org-agenda-check-type nil 'agenda 'timeline) :keys "C-u C-u S-right"]
+     ["Change Time -  min" org-agenda-date-earlier :active (org-agenda-check-type nil 'agenda 'timeline) :keys "C-u C-u S-left"]
      ["Change Date to ..." org-agenda-date-prompt (org-agenda-check-type nil 'agenda 'timeline)])
      ["Change Date to ..." org-agenda-date-prompt (org-agenda-check-type nil 'agenda 'timeline)])
     ("Clock"
     ("Clock"
      ["Clock in" org-agenda-clock-in t]
      ["Clock in" org-agenda-clock-in t]
@@ -5635,6 +5639,38 @@ the same tree node, and the headline of the tree node in the Org-mode file."
       (org-agenda-change-all-lines newhead hdmarker)
       (org-agenda-change-all-lines newhead hdmarker)
       (beginning-of-line 1))))
       (beginning-of-line 1))))
 
 
+(defun org-agenda-do-date-later (arg)
+  (interactive "P")
+  (cond
+   ((or (equal arg '(16))
+	(memq last-command
+	      '(org-agenda-date-later-minutes org-agenda-date-earlier-minutes)))
+    (setq this-command 'org-agenda-date-later-minutes)
+    (org-agenda-date-later-minutes 1))
+   ((or (equal arg '(4))
+	(memq last-command
+	      '(org-agenda-date-later-hours org-agenda-date-earlier-hours)))
+    (setq this-command 'org-agenda-date-later-hours)
+    (org-agenda-date-later-hours 1))
+   (t
+    (org-agenda-date-later (prefix-numeric-value arg)))))
+
+(defun org-agenda-do-date-earlier (arg)
+  (interactive "P")
+  (cond
+   ((or (equal arg '(16))
+	(memq last-command
+	      '(org-agenda-date-later-minutes org-agenda-date-earlier-minutes)))
+    (setq this-command 'org-agenda-date-earlier-minutes)
+    (org-agenda-date-earlier-minutes 1))
+   ((or (equal arg '(4))
+	(memq last-command
+	      '(org-agenda-date-later-hours org-agenda-date-earlier-hours)))
+    (setq this-command 'org-agenda-date-earlier-hours)
+    (org-agenda-date-earlier-hours 1))
+   (t
+    (org-agenda-date-earlier (prefix-numeric-value arg)))))
+
 (defun org-agenda-date-later (arg &optional what)
 (defun org-agenda-date-later (arg &optional what)
   "Change the date of this item to one day later."
   "Change the date of this item to one day later."
   (interactive "p")
   (interactive "p")
@@ -5659,6 +5695,28 @@ the same tree node, and the headline of the tree node in the Org-mode file."
   (interactive "p")
   (interactive "p")
   (org-agenda-date-later (- arg) what))
   (org-agenda-date-later (- arg) what))
 
 
+(defun org-agenda-date-later-minutes (arg)
+  "Change the time of this item, in units of `org-time-stamp-rounding-minutes'."
+  (interactive "p")
+  (setq arg (* arg (cadr org-time-stamp-rounding-minutes)))
+  (org-agenda-date-later arg 'minute))
+
+(defun org-agenda-date-earlier-minutes (arg)
+  "Change the time of this item, in units of `org-time-stamp-rounding-minutes'."
+  (interactive "p")
+  (setq arg (* arg (cadr org-time-stamp-rounding-minutes)))
+  (org-agenda-date-earlier arg 'minute))
+
+(defun org-agenda-date-later-hours (arg)
+  "Change the time of this item, in hour steps."
+  (interactive "p")
+  (org-agenda-date-later arg 'hour))
+
+(defun org-agenda-date-earlier-hours (arg)
+  "Change the time of this item, in hour steps."
+  (interactive "p")
+  (org-agenda-date-earlier arg 'hour))
+
 (defun org-agenda-show-new-time (marker stamp &optional prefix)
 (defun org-agenda-show-new-time (marker stamp &optional prefix)
   "Show new date stamp via text properties."
   "Show new date stamp via text properties."
   ;; We use text properties to make this undoable
   ;; We use text properties to make this undoable

+ 7 - 0
lisp/org.el

@@ -12499,6 +12499,13 @@ in the timestamp determines what will be changed."
 			 (+ (if (eq org-ts-what 'month) n 0)  (nth 4 time0))
 			 (+ (if (eq org-ts-what 'month) n 0)  (nth 4 time0))
 			 (+ (if (eq org-ts-what 'year) n 0)   (nth 5 time0))
 			 (+ (if (eq org-ts-what 'year) n 0)   (nth 5 time0))
 			 (nthcdr 6 time0)))
 			 (nthcdr 6 time0)))
+      (when (and (member org-ts-what '(hour minute))
+		 extra
+		 (string-match "-\\([012][0-9]\\):\\([0-5][0-9]\\)" extra))
+	(setq extra (org-modify-ts-extra
+		     extra
+		     (if (eq org-ts-what 'hour) 2 5)
+		     n dm)))
       (when (integerp org-ts-what)
       (when (integerp org-ts-what)
 	(setq extra (org-modify-ts-extra extra org-ts-what n dm)))
 	(setq extra (org-modify-ts-extra extra org-ts-what n dm)))
       (if (eq what 'calendar)
       (if (eq what 'calendar)