Posted by Jake on Aug 28, 2014 in Emacs, Emacs Lisp, Programming
I love Emacs – I use it for everything. Local file editing, remote file editing via Tramp, terminals, calendars, email, news groups, rss / atom feeds, reminders, time keeping, todo lists, document generation (from org-mode) – literally just about everything I can.
As you can imagine that amount of usability takes quite a bit of customization. Luckily, the Emacs community has done most of the heavy lifting. All that I have to manage is my own programmatic idiosyncrasies and – the init.el…
It became huge, and messy, and cumbersome. And like any good programmer it made me feel dirty – it needed organized and modularized. But again like any good coder – I didn’t want it to be manual. I wanted drop-in, auto-discover modularity that didn’t require any additional scripting.
Like most things coding (when you don’t know what you are doing) you start out on a quest to discover what’s available in the language of question for you to leverage. And that, to me, is the fun part – the acquisition of knowledge. The problem at hand is just a reason for you to dig deeper and learn – but I digress…
This post – like most of mine – is segmented. Mostly because I’m long-winded when discussing this material. However, I think this one is pretty good and you should come back to read the follow-ups. Why? Because of the snippet to follow and this explanation:
I currently have over 41 csutomization emacs .el files (1 or more for each mode / package) and my init.el file is simply:
;; set up path helpers
(setq my-emacs-d "~/.emacs.d/")
(setq my-emacs-elpa (concat my-emacs-d "elpa/"))
(setq my-emacs-conf (concat my-emacs-d "emacs-conf/"))
(setq my-emacs-live (concat my-emacs-d "emacs-live/"))
(setq my-emacs-org (concat my-emacs-d "emacs-org/"))
(setq my-emacs-3p (concat my-emacs-d "third-party/"))
(setq my-site-file "~/site_conf.el")
;; load site file if it exists
(if (file-exists-p my-site-file)
;; load various configurations
(load (concat my-emacs-conf "configurations_config.el"))
;; will load and byte-compile my modular configurations
I can add a thousand configuration files – and my init.el never will get any larger. The key? My configurations_config.el – which isn’t as crazy as you’d think it would be. I like to think it’s a thing of beauty – but you can weigh in on my next post when we dig into it!
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.