Emacs Configuration Management – Part I

0

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:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
;; 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) 
    (progn
      (load my-site-file)
      (find-file my-site-file))
)
 
;; load various configurations
(load (concat my-emacs-conf "configurations_config.el"))
 
;; will load and byte-compile my modular configurations
(my-load-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!

Emacs Calendar Extension – Information Unity (Part 3)

4

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:

  1. defun a standard lisp method.
  2. Include the interactive form (of which there are varying arguments it takes based on the required functionality.
  3. From within this form make calls out to the forms that we already created for importing an iCal

Read more

Tags: , , ,

Emacs Calendar Extension – Information Unity (Part 2)

0

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:

  1. Google Calendar exports calendars in the iCalendar format
  2. 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)

1
(setq diary-file (concat my-emacs-org "diary_entries"))

Next, I’ll create an alist  to hold all my calendars.

1
2
3
(setq my-ical-calendars-alist '(
 ("test", "https://www.google.com/calendar/icaltest.ics")
 ))

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 icalendar-import-file.

No problem, as there’s a built-in function to download a URL to a local temp copy – url-file-local-copy.

We’ll write our function to:

  1. Download the URL
  2. Pass the temp file to icalendar-import-file
  3. Close the buffer
1
2
3
4
5
6
7
(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.

Read more

Tags: , , ,

Emacs Dired “Shortcuts”

4

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:

  1. Create a dictionary of shortcut to locations
  2. Use Emacs interactive ability to select a shortcut name and open its location with Dired.

Read more

Tags: , , ,

Emacs Calendar Extension – Information Unity

3

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.

Read more

Tags: , , ,