Posted by Jake on Mar 30, 2013 in Emacs Lisp, Lisp, Programming
Ok, this post should wrap up the series – finally. Sorry it’s taken me a while, but got caught up in life for a bit…
To summarize what we’ve covered so far, I figured out how to get a iCal file imported into Emacs calendaring system, remove duplicates, and do a little post-processing in order to get it looking the way I wanted.
Up to this point, it’s all been manual calls with
eval-region and that just won’t cut it! We need an Emacsian way of both a) Automatically running this code on start up (which the provided functions can already handle, and b) Being able to manually re-execute at any time via Emacsian means.
The running on start up, as I’ve said, is already handled via normal elisp code execution. We really just need to enable that same functionality through manual Emacs interaction.
Looking through documentation and many blog posts I discovered how to interact with the Emacs system – and it’s actually pretty simple. You only have to do a couple of things, actually:
defun a standard lisp method.
- Include the
interactive form (of which there are varying arguments it takes based on the required functionality.
- From within this form make calls out to the forms that we already created for importing an iCal
Posted by Jake on Mar 13, 2013 in Emacs, Emacs Lisp, Lisp, Programming
Go back to the first post in this series, I was trying to solve the problem of having many views of my calendars, but only a single source of record. Specifically, I wanted to be able to view this “source” calendar in Emacs without the manual syncing process.
As was discussed earlier, a few of the issues were solved:
- Google Calendar exports calendars in the iCalendar format
- Emacs Calendar is able to import an iCalendar format file via URL
Stellar! This is going to be easy! I’ll just list out my calendars’ iCalendar URLs (provided by Google), and have Emacs Calendar cycle through them and import them. Nice 🙂
First, let’s create a var that points to our diary file (that way we can export it to our site config if necessary)
(setq diary-file (concat my-emacs-org "diary_entries"))
Next, I’ll create an alist to hold all my calendars.
(setq my-ical-calendars-alist '(
All nice and easy thus far. The next thing we need to do is write a nifty function to help import the URL as icalender.el can only import from a file via
No problem, as there’s a built-in function to download a URL to a local temp copy –
We’ll write our function to:
- Download the URL
- Pass the temp file to icalendar-import-file
- Close the buffer
(defun import-remote-ical (url my-diary-file)
"Download ics file from URL and add to diary"
(let ((tmpfile (url-file-local-copy url)))
(icalendar-import-file tmpfile my-diary-file nil)
(kill-buffer (car (last (split-string tmpfile "/"))))
I run it and am astounded that it works! So I run it a few more times to make sure I’m not imagining things. Yup – it does work!
I hurriedly open my diary file, anxious to see my handiwork and… (wait for it) … uggh. There are multiple duplicates for each event. I should’ve known that it couldn’t of been that easy.
Posted by Jake on Mar 12, 2013 in Emacs, Emacs Lisp, Lisp, Programming
I’m always trying to make my development workflow more efficient – whether it be tools or process – and this post solved one of my recent pain points – as well as giving me another practical problem to solve with Lisp.
As I noted previously, I’m really heavy into Emacs use at the moment: development, calendaring, RSS, news, Jabber IM – all from within this awesome thing called Emacs.
As I started to use it more and more for all types of different chores – and more specific to this post – file editing, I began to notice fairly quickly that directory navigation with Dired (Ctrl-X d, by default) led to far too many keystrokes to get to disparate locations – and to boot there was no notion of persistent “favorites” or “shortcuts”.
The above may just be my newness to the Emacs ecosystem and the functionality may actually exist – but it never turned up in my many searches. So I went about providing my own solution.
NOTE: This effort had no intention of making handy-dandy menu items as I don’t like them – or the mouse for that matter – all that much. Maybe I’ll add that at some point for thoroughness sake – we’ll see.
The plan was simple:
- Create a dictionary of shortcut to locations
- Use Emacs interactive ability to select a shortcut name and open its location with Dired.
Posted by Jake on Mar 8, 2013 in Emacs Lisp, Lisp, Programming
Well, I’ve been away for a while. Honestly, I find it hard to make time to post – but I swear, I’m going to make more of an effort because I’m actually working on some very exciting stuff.
I’ll put off the super exciting stuff for a bit, but did want to post something exciting – to me at least…
As a preface, I’ve been getting into pretty heavy use of Emacs over the last few months. To the extent that I’m on a mission to use it for as a replacement for as many apps as possible. If you are aware of Emacs and the multitudes of extensions then you know just how powerful it can be. To the point that my desires of an Emacs-only desktop are not outside the realm of possibility – but I’ll get into that in some later posts.
So one of the things I hate in life is repeating myself – specifically in the realm of information. Having to put to-do items into multiple devices, multiple contacts apps, multiple calendar apps, etc.