From mboxrd@z Thu Jan 1 00:00:00 1970 From: Xebar Saram Subject: Re: export to ics a specific buffer every X hours Date: Thu, 25 Aug 2016 10:32:54 +0300 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=94eb2c097548f72329053ae067e3 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:56168) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bcp9m-0001tm-NG for emacs-orgmode@gnu.org; Thu, 25 Aug 2016 03:33:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bcp9j-0002B3-Lh for emacs-orgmode@gnu.org; Thu, 25 Aug 2016 03:32:57 -0400 Received: from mail-yb0-x232.google.com ([2607:f8b0:4002:c09::232]:33000) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bcp9j-0002Ap-GE for emacs-orgmode@gnu.org; Thu, 25 Aug 2016 03:32:55 -0400 Received: by mail-yb0-x232.google.com with SMTP id a7so12653081ybi.0 for ; Thu, 25 Aug 2016 00:32:55 -0700 (PDT) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Philip Hudson Cc: org mode --94eb2c097548f72329053ae067e3 Content-Type: text/plain; charset=UTF-8 Hi again all so i have a related question so ill continue in this thread. i have been using this command succesfully in the last few weeks (defun z/export-to-ics () (interactive) (rename-file (org-icalendar-export-to-ics) "/home/zeltak/org/files/export/kcal.ics") (message "exported to ics")) this forces me to first open the file i want (meetings.org) and then launch the above command. is there a way to auto make the above function to auto export meeting.org each time without opening it first? thx Z On Wed, Jul 13, 2016 at 6:27 PM, Philip Hudson wrote: > You have _two_ concerns here. First is what to do when you save > "meetings.org", second is what to do every half hour. Your code > handles both of them, essentially correctly, but in the wrong place. > > On 13 July 2016 at 09:41, Xebar Saram wrote: > > Thx > > > > i do have this now > > > > (defun z/save-meeting-to-ics () > > "If the current file is in '~/.dotfiles', the code blocks are > tangled" > > (when (equal (buffer-file-name) > > (expand-file-name "/home/zeltak/org/files/agenda/ > meetings.org")) > > This means the code will only execute if the current buffer is > "meetings.org" when it executes. That _is_ what you want when you save > meetings.org, but it _is not_ what you want when the timer executes. > > Break out the body of the `when' form into its own function, and call > that function from the timer, instead of `z/save-meeting-to-ics'. > > > (rename-file (org-icalendar-export-to-ics) > > "/home/zeltak/org/files/export/kcal.ics") > > (message "exported to ics"))) > > > > ;;run every 30 minutes > > > > (run-with-timer 0 (* 30 60) 'z/save-meeting-to-ics) > > ;;(run-with-idle-timer 600 t #'org-agenda-redo) ;; to rebuild it every > 600 > > second > > ;; (add-hook 'after-save-hook #'z/save-meeting-to-ics) > > > > yet i cant get the ics file to be created niether when i save the > > meeting.org file > > For this, you need to add `z/save-meeting-to-ics' to the Emacs global > variable `after-save-hook' using function `add-hook'. > > > nor every 600 seconds. > > You mean 1800 seconds, I think. > > > what am i missing here? > > > > thx > > > > Z > > > > On Sun, Jun 26, 2016 at 9:49 PM, Philip Hudson > > wrote: > >> > >> On 26 June 2016 at 16:38, Xebar Saram wrote: > >> > Hi all > >> > > >> > so i have pathetic coding skill but managed somehow to come up with > this > >> > > >> > (defun z/save-meeting-to-ics () > >> > "If the current file is in '~/.dotfiles', the code blocks are > >> > tangled" > >> > (when (equal (buffer-file-name) > >> > (expand-file-name > >> > "/home/zeltak/org/files/agenda/meetings.org")) > >> > (org-icalendar-export-to-ics) > >> > (message "exported to ics"))) > >> > > >> > this does save the org file "meetings.org" to an ICS file in the same > >> > folder > >> > as the file. but i want to do 2 additional things: > >> > 1)save the resulting ICS file to a different directory > >> > 2)run this function every X hours (lets say every 2 hours) > >> > > >> > any clue guys? > >> > > >> > thx! > >> > > >> > Z > >> > >> For 1), change: > >> > >> (org-icalendar-export-to-ics) > >> > >> to something like this: > >> > >> (rename-file (org-icalendar-export-to-ics) your-preferred-pathname) > >> > >> For 2), evaluate this: > >> > >> (info "(elisp) Timers") > >> > >> -- > >> Phil Hudson http://hudson-it.ddns.net > >> @UWascalWabbit PGP/GnuPG ID: 0x887DCA63 > > > > > > > > -- > Phil Hudson http://hudson-it.ddns.net > @UWascalWabbit PGP/GnuPG ID: 0x887DCA63 > --94eb2c097548f72329053ae067e3 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi again all

so i have a related questi= on so ill continue in this thread. i have been using this command succesful= ly in the last few weeks

(defun z/export-to-i= cs ()
(interactive)
(rename-file (org-icalendar-export-= to-ics)
"/home/zeltak/org/files/export/kcal.ics")
=
(message "exported to ics"))

=
this forces me to first open the file i want (meetings.org) and then launch the above command. is t= here a way to auto make the above function to auto export meeting.org each time without opening it first?

thx

Z

On Wed, Jul 13, 2016 at 6:27 PM, P= hilip Hudson <phil.hudson@iname.com> wrote:
You have _two_ concerns here. First is what to do whe= n you save
"= meetings.org", second is what to do every half hour. Your code
handles both of them, essentially correctly, but in the wrong place.

On 13 July 2016 at 09:41, Xebar Saram <zeltakc@gmail.com> wrote:
> Thx
>
> i do have this now
>
>=C2=A0 =C2=A0(defun z/save-meeting-to-ics ()
>=C2=A0 =C2=A0 =C2=A0"If the current file is in '~/.dotfiles= 9;, the code blocks are tangled"
>=C2=A0 =C2=A0 =C2=A0(when (equal (buffer-file-name)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (expand-= file-name "/home/zeltak/org/files/agenda/meetings.org"))

This means the code will only execute if the current buffer is
"= meetings.org" when it executes. That _is_ what you want when you s= ave
meetin= gs.org, but it _is not_ what you want when the timer executes.

Break out the body of the `when' form into its own function, and call that function from the timer, instead of `z/save-meeting-to-ics'.

>=C2=A0 (rename-file (org-icalendar-export-to-ics)
> "/home/zeltak/org/files/export/kcal.ics")
>=C2=A0 =C2=A0 =C2=A0 =C2=A0(message "exported to ics")))
>
> ;;run every 30 minutes
>
> (run-with-timer 0 (* 30 60) 'z/save-meeting-to-ics)
> ;;(run-with-idle-timer 600 t #'org-agenda-redo) ;; to rebuild it e= very 600
> second
> ;;=C2=A0 (add-hook 'after-save-hook #'z/save-meeting-to-ics) >
> yet i cant get the ics file to be created niether when i save the
> me= eting.org file

For this, you need to add `z/save-meeting-to-ics' to the Emacs g= lobal
variable `after-save-hook' using function `add-hook'.

> nor every 600 seconds.

You mean 1800 seconds, I think.

> what am i missing here?
>
> thx
>
> Z
>
> On Sun, Jun 26, 2016 at 9:49 PM, Philip Hudson <phil.hudson@iname.com>
> wrote:
>>
>> On 26 June 2016 at 16:38, Xebar Saram <zeltakc@gmail.com> wrote:
>> > Hi all
>> >
>> > so i have pathetic coding skill but managed somehow to come u= p with this
>> >
>> >=C2=A0 (defun z/save-meeting-to-ics ()
>> >=C2=A0 =C2=A0 =C2=A0"If the current file is in '~/.do= tfiles', the code blocks are
>> > tangled"
>> >=C2=A0 =C2=A0 =C2=A0(when (equal (buffer-file-name)
>> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= (expand-file-name
>> > "/home/zeltak/org/files/agenda/meetings.org")) >> >=C2=A0 =C2=A0 =C2=A0 =C2=A0(org-icalendar-export-to-ics)
>> >=C2=A0 =C2=A0 =C2=A0 =C2=A0(message "exported to ics"= ;)))
>> >
>> > this does save the org file "meetings.org" to an ICS = file in the same
>> > folder
>> > as the file. but i want to do 2 additional things:
>> > 1)save the resulting ICS file to a different directory
>> > 2)run this function every X hours (lets say every 2 hours) >> >
>> > any clue guys?
>> >
>> > thx!
>> >
>> > Z
>>
>> For 1), change:
>>
>>=C2=A0 =C2=A0 =C2=A0(org-icalendar-export-to-ics)
>>
>> to something like this:
>>
>>=C2=A0 =C2=A0 =C2=A0(rename-file (org-icalendar-export-to-ics) your= -preferred-pathname)
>>
>> For 2), evaluate this:
>>
>>=C2=A0 =C2=A0 =C2=A0(info "(elisp) Timers")
>>
>> --
>> Phil Hudson=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0http://hudson-it.ddns.net
>> @UWascalWabbit=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0PGP/GnuPG ID: 0x887DCA63
>
>



--
Phil Hudson=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0http://hudson-it.ddns.net
@UWascalWabbit=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0PGP/GnuPG ID: 0x887DCA63

--94eb2c097548f72329053ae067e3--