Export ical every 30 minutes - emacs

I'm trying to automate the creation of an ical file (the one I get after C-c C-e c a) every 30 minutes, to visualize it in a calendar app. Ideally, it should be done asynchronously to asynchronously. I tried adding this to my .emacs file
(run-with-timer 0 (* 30 60) 'org-icalendar-export-agenda-files async)
but it didn't work (as you can see, I have no idea of elisp).
Can someone help me with this?

Related

org-mode agenda view with late recurring tasks at top

I have some TODO's in my recur.org file which look like this:
** TODO Do this thing every day.
SCHEDULED: <2016-09-19 Mon .+1d>
For me, that . before the +1d means "if you happen to do this job late, then when you mark it as done it will re-schedule itself to the day after when it was marked as done." This is correct, because this job does have the property that if I don't do it for 4 days, then I don't need to do it 4 times to catch up, I just need to do it once. On the other hand, if I don't do it for 4 days then I really need to get this job done and I would hope that it gets flagged up in red when I look at my weekly agenda view with C-c a a in emacs org-mode.
Unfortunately, this does not happen. The standard agenda view lists this task as
[stuff in red here with Sched. 4x etc etc]
recur: Scheduled: TODO [#A] Do this thing every day
and the entry is in green with no indication that I'm late. This is presumably because the fact that it is scheduled every day means in particular that it is scheduled today, and so hang the fact that it's still also scheduled 4 days ago.
This is not the behaviour I want. I would like to be able to make a repeated TODO which, when done, resets the scheduled time to today+[interval], and yet I am still warned if I fail to do the task for a time period which exceeds the interval.
Experiments indicate that jobs with things like .+1w behave the same way -- they're 6 days overdue and then all of a sudden they're not overdue any more.
Could I write a custom agenda command somehow, to ensure these jobs are flagged when they are late?
Added 3rd Oct: Some further experimentation has revealed that the dot isn't the problem -- this is also the default behaviour with recurring TODOs that just are due to be rescheduled after a time delay shorter than the time it's taken me to fail to do them.
However I am now slightly more optimistic that this can somehow be solved with a custom agenda view. For C-c a L gives me a view where the recurring task shows up on the first day it's scheduled and not done, rather than the most recent day it's scheduled and not done. However C-c a L is no good for three reasons: (1) it shows tasks which are DONE (2) it shows priority C tasks which are late (and I am much less interested in these) and (3) it only acts on the current buffer. So if I learn enough about agenda views I feel like I might be able to answer my own question.
Added 9th Oct: Having now read the relevant pages of the org manual I realise that I still do not know how to do this. I am surprised. What I am asking for is an agenda view which encompasses all my org files, gives me a weekly agenda like C-c a a, and which flags the first not-yet-done occurrence of each repeating TODO task which has priority A. From a purely logic/programming point of view I don't see any obstruction to this, and I would be quite surprised if there were no way to do this in org-mode, but I certainly can't find it. Help!

Org mode time sheet

I'd like to get a custom "timesheet" report.
Curently, I do have the following:
(add-to-list 'org-agenda-custom-commands
'("r" "Weekly Timesheet"
((agenda ""))
((org-agenda-overriding-header "Weekly timesheet")
(org-agenda-span 'week)
(org-agenda-start-on-weekday 1)
(org-agenda-start-with-clockreport-mode t)
(org-agenda-time-grid nil))) t)
It works as expected, except that I'm not interested in seeing the agenda views for the 7 days: I just want the clockreport, nothing more.
How can I achieve that?
Check out the clocktable block. I use this to see a weekly recap of where I spent my time. You can setup a simple one like the following:
#+BEGIN: clocktable :scope agenda-with-archives :block lastweek
#+END:
Put your cursor on the BEGIN or END and hit the trusty C-cC-c to evaluate the clock table in-place. It will list the file, headline and time spent on the tasks.
In my example above, the scope defines where to look for the clocked items. In this case, I chose the agenda files and associated archives. For the block of time, I used lastweek to get the last 7 days.
There are many more options for configuring just what you need. Read more at
http://orgmode.org/manual/The-clock-table.html
I am not sure if this helps, but you may want to check out Tom Marble's timesheet.el. You should be able to install it from MELPA. Although it does not integrate with org agenda, this seems like the most thorough way to generate timesheet reports.
http://emacslife.com/emacs-chats/chat-tom-marble.html
https://github.com/tmarble/timesheet.el
The sample org file: https://raw.githubusercontent.com/tmarble/timesheet.el/master/share/yoyodyne.org

Autohotkey daily macro doesn't work well

I created a macro in autohotkey that is able to copy at 7:40 a.m. the last file created in a shared disk into a dropbox folder. When I launch the macro to try it, setting the "time to meet" 2 minutes later for example, it works perfectly. The problem is that the day after the macro doesn't start. Could you help me please?
Thanks
Marco
SetTimer, Chronos, 59900
Return
Chronos:
FormatTime, TimeToMeet,,HHmm
If TimeToMeet = 740 ; If you wanted the script to start at 7 am put change 1006 to 700
{
run O:\research\
winactivate, research
sleep 1000
MouseClick, left, 289, 586
send {PgDn 6}
clipboard =
Send ^c
clipwait
sleep, 1000
FileCopy, %clipboard%,C:\Dropbox\
sleep 2000
winclose research
return
}
Return
Unattended user interface automation like this may not be the most reliable aproach.
I would recommend using the Windows Task Scheduler to handle launching the process. I think this might be safer than having the script running 24 / 7 waiting to go. Even more importantly, it looks like you are doing very basic file manipulation by automating the UI. This type of work may be better acomplished with a Windows batch file or Autohotkey's functions for files. Note that batch files are less fussy about screensavers and being logged in. I love AutoHotkey, but that seems to be a weak spot. Check out the documentation for each of the functions that start with the word file. I'd be surprised if you couldn't hook some of those up to do what you need. Since you seem to be looking for a file, check this one out:
http://www.autohotkey.com/docs/commands/LoopFile.htm
I think this thread may be of help as it finds the most recent file in a folder:
http://www.autohotkey.com/board/topic/57475-open-most-recent-file-date-created-in-a-folder/
Good luck!

Emacs - kill suggestions buffers with timeout

I know this solution is posted, but I cannot find it. I had in my .emacs code to kill suggestions buffers automatically after n seconds (mine was set to 5). This allowed me to not have to switch to that pane and kill it or have 90 auto-complete or suggestions buffers open. I can no longer find the code though. Does anybody know how to do this?
Thanks
Try Midnight Mode, included with recent versions of Emacs.
(run-with-idle-timer SECS REPEAT 'x-function)
Perform an action the next time Emacs is idle for SECS seconds.
The action is to call FUNCTION with arguments ARGS.
SECS may be an integer, a floating point number, or the internal
time format returned by, e.g., `current-idle-time'.
If Emacs is currently idle, and has been idle for N seconds (N < SECS),
then it will call FUNCTION in SECS - N seconds from now.
If REPEAT is non-nil, do the action each time Emacs has been idle for
exactly SECS seconds (that is, only once for each time Emacs becomes idle).
You define a function x-function that kills buffers you want.

How to periodically run a task within emacs?

Is there a way to periodically run an elisp function in a long-running emacs, similar to cron, but within the emacs process?
For example I want to "automatically run (recentf-save-list) every half hour" because it otherwise only runs on exit, which sucks when emacs occasionally crashes. (There are other examples as well so looking for a general solution rather than one in particular for recentf).
Check out run-with-timer.
(run-with-timer 0 (* 30 60) 'recentf-save-list)
You might also find midnight mode useful. One can arbitrarily define 'midnight' and then add hooks as desired.