emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Tiny piece of customization for ctrl-c ctrl-c within a timestamp
@ 2010-10-16 16:34 Marc-Oliver Ihm
  2010-10-16 19:43 ` Jeff Horn
  2010-10-16 20:11 ` Sebastian Rose
  0 siblings, 2 replies; 5+ messages in thread
From: Marc-Oliver Ihm @ 2010-10-16 16:34 UTC (permalink / raw)
  To: emacs-orgmode

Hello !


I sometimes find myself adjusting timestamps just by editing its text;
e.g. changing <2010-10-16 Su> to <2011-10-16 Su>. However after that
editing, the day of week is usually wrong (or might be right, I just
dont know).

With this small piece of lisp, one just needs to press ctrl-c ctrl-c
while the cursor is in a timestamp and the day of week is adjusted.


(defun org-set-weekday-of-timestamp ()
  "Check if cursor is within a timestamp and compute weekday from numeric
date"
  (interactive)
  (when (org-at-timestamp-p t)
    (org-timestamp-change 0 'year)
    (message "Weekday of timestamp has been adjusted.")
    t
  ))

(add-hook 'org-ctrl-c-ctrl-c-hook 'org-set-weekday-of-timestamp)


Maybe someone else might find that useful too.


With kind regards, Marc-Oliver Ihm

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

* Re: Tiny piece of customization for ctrl-c ctrl-c within a timestamp
  2010-10-16 16:34 Tiny piece of customization for ctrl-c ctrl-c within a timestamp Marc-Oliver Ihm
@ 2010-10-16 19:43 ` Jeff Horn
  2010-10-16 19:58   ` Nick Dokos
  2010-10-16 20:11 ` Sebastian Rose
  1 sibling, 1 reply; 5+ messages in thread
From: Jeff Horn @ 2010-10-16 19:43 UTC (permalink / raw)
  To: Marc-Oliver Ihm; +Cc: emacs-orgmode

Very useful, since I often do the same! Thanks for this.

On Sat, Oct 16, 2010 at 12:34 PM, Marc-Oliver Ihm <ihm@online.de> wrote:
> Hello !
>
>
> I sometimes find myself adjusting timestamps just by editing its text;
> e.g. changing <2010-10-16 Su> to <2011-10-16 Su>. However after that
> editing, the day of week is usually wrong (or might be right, I just
> dont know).
>
> With this small piece of lisp, one just needs to press ctrl-c ctrl-c
> while the cursor is in a timestamp and the day of week is adjusted.
>
>
> (defun org-set-weekday-of-timestamp ()
>  "Check if cursor is within a timestamp and compute weekday from numeric
> date"
>  (interactive)
>  (when (org-at-timestamp-p t)
>    (org-timestamp-change 0 'year)
>    (message "Weekday of timestamp has been adjusted.")
>    t
>  ))
>
> (add-hook 'org-ctrl-c-ctrl-c-hook 'org-set-weekday-of-timestamp)
>
>
> Maybe someone else might find that useful too.
>
>
> With kind regards, Marc-Oliver Ihm
>
>
> _______________________________________________
> 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
>



-- 
Jeffrey Horn
Graduate Lecturer and PhD Student in Economics
George Mason University

(704) 271-4797
jhorn@gmu.edu
jrhorn424@gmail.com

http://www.failuretorefrain.com/jeff/

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

* Re: Tiny piece of customization for ctrl-c ctrl-c within a timestamp
  2010-10-16 19:43 ` Jeff Horn
@ 2010-10-16 19:58   ` Nick Dokos
  2010-10-17  6:31     ` Marc-Oliver Ihm
  0 siblings, 1 reply; 5+ messages in thread
From: Nick Dokos @ 2010-10-16 19:58 UTC (permalink / raw)
  To: Jeff Horn; +Cc: nicholas.dokos, emacs-orgmode, Marc-Oliver Ihm

Jeff Horn <jrhorn424@gmail.com> wrote:

> Very useful, since I often do the same! Thanks for this.
> 
> On Sat, Oct 16, 2010 at 12:34 PM, Marc-Oliver Ihm <ihm@online.de> wrote:
> > Hello !
> >
> >
> > I sometimes find myself adjusting timestamps just by editing its text;
> > e.g. changing <2010-10-16 Su> to <2011-10-16 Su>. However after that
> > editing, the day of week is usually wrong (or might be right, I just
> > dont know).
> >
> > With this small piece of lisp, one just needs to press ctrl-c ctrl-c
> > while the cursor is in a timestamp and the day of week is adjusted.
> >
> >
> > (defun org-set-weekday-of-timestamp ()
> >  "Check if cursor is within a timestamp and compute weekday from numeric
> > date"
> >  (interactive)
> >  (when (org-at-timestamp-p t)
> >    (org-timestamp-change 0 'year)
> >    (message "Weekday of timestamp has been adjusted.")
> >    t
> >  ))
> >
> > (add-hook 'org-ctrl-c-ctrl-c-hook 'org-set-weekday-of-timestamp)
> >
> >
> > Maybe someone else might find that useful too.
> >
> >
> > With kind regards, Marc-Oliver Ihm
> >

My hack for this is S-<right> S-<left>: it advances the date up and down
by 1 but has the side effect of setting the day of the week correctly.

Nick

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

* Re: Tiny piece of customization for ctrl-c ctrl-c within a timestamp
  2010-10-16 16:34 Tiny piece of customization for ctrl-c ctrl-c within a timestamp Marc-Oliver Ihm
  2010-10-16 19:43 ` Jeff Horn
@ 2010-10-16 20:11 ` Sebastian Rose
  1 sibling, 0 replies; 5+ messages in thread
From: Sebastian Rose @ 2010-10-16 20:11 UTC (permalink / raw)
  To: Marc-Oliver Ihm; +Cc: emacs-orgmode

Marc-Oliver Ihm <ihm@online.de> writes:
> Hello !
>
>
> I sometimes find myself adjusting timestamps just by editing its text;
> e.g. changing <2010-10-16 Su> to <2011-10-16 Su>. However after that
> editing, the day of week is usually wrong (or might be right, I just
> dont know).

Hi Marc-Oliver,



http://orgmode.org/manual/Creating-timestamps.html#Creating-timestamps

describes all you need to change timestamps without errors:

   S-<left>
   S-<right>
       Change date at cursor by one day. These key bindings conflict
       with shift-selection and related modes (see Conflicts).
   S-<up>
   S-<down>
       Change the item under the cursor in a timestamp. The cursor can
       be on a year, month, day, hour or minute. When the timestamp
       contains a time range like `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
       timestamp, these same keys modify the priority of an item. (see
       Priorities). The key bindings also conflict with shift-selection
       and related modes (see Conflicts).



Also, `C-c .'  while on a timestamp you may use the calendar interface
to change the timestamp.   Days of the week will be OK.



  Sebastian

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

* Re: Tiny piece of customization for ctrl-c ctrl-c within a timestamp
  2010-10-16 19:58   ` Nick Dokos
@ 2010-10-17  6:31     ` Marc-Oliver Ihm
  0 siblings, 0 replies; 5+ messages in thread
From: Marc-Oliver Ihm @ 2010-10-17  6:31 UTC (permalink / raw)
  To: emacs-orgmode

Am 16.10.2010 21:58, schrieb Nick Dokos:
> Jeff Horn <jrhorn424@gmail.com> wrote:
> 
>> Very useful, since I often do the same! Thanks for this.
>>
>> On Sat, Oct 16, 2010 at 12:34 PM, Marc-Oliver Ihm <ihm@online.de> wrote:
>>> Hello !
>>>
>>>
>>> I sometimes find myself adjusting timestamps just by editing its text;
>>> e.g. changing <2010-10-16 Su> to <2011-10-16 Su>. However after that
>>> editing, the day of week is usually wrong (or might be right, I just
>>> dont know).
>>>
>>> With this small piece of lisp, one just needs to press ctrl-c ctrl-c
>>> while the cursor is in a timestamp and the day of week is adjusted.
>>>
>>>
>>> (defun org-set-weekday-of-timestamp ()
>>>  "Check if cursor is within a timestamp and compute weekday from numeric
>>> date"
>>>  (interactive)
>>>  (when (org-at-timestamp-p t)
>>>    (org-timestamp-change 0 'year)
>>>    (message "Weekday of timestamp has been adjusted.")
>>>    t
>>>  ))
>>>
>>> (add-hook 'org-ctrl-c-ctrl-c-hook 'org-set-weekday-of-timestamp)
>>>
>>>
>>> Maybe someone else might find that useful too.
>>>
>>>
>>> With kind regards, Marc-Oliver Ihm
>>>
> 
> My hack for this is S-<right> S-<left>: it advances the date up and down
> by 1 but has the side effect of setting the day of the week correctly.
> 
> Nick
> 
> _______________________________________________
> 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
> 

S-<right> S-<left> is nearly as short, and I did not think about it :-)
The only remaining advantage of my hack (besides the apparent
disadvantage of needing explicit customization) is, that it increases
the dwimity of ctrl-c ctrl-c ...

Thanx and kind regards, Marc-Oliver Ihm

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

end of thread, other threads:[~2010-10-17  6:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-16 16:34 Tiny piece of customization for ctrl-c ctrl-c within a timestamp Marc-Oliver Ihm
2010-10-16 19:43 ` Jeff Horn
2010-10-16 19:58   ` Nick Dokos
2010-10-17  6:31     ` Marc-Oliver Ihm
2010-10-16 20:11 ` Sebastian Rose

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