osx-location

https://github.com/purcell/osx-location.git

git clone 'git://github.com/purcell/osx-location.git'
6

Melpa Status Melpa Stable Status

osx-location.el

This library uses OS X CoreLocation services to put useful information into variables osx-location-latitude and osx-location-longitude.

Installation

If you choose not to use one of the convenient packages in Melpa and Marmalade, you'll need to add the directory containing osx-location.el and EmacsLocationHelper to your load-path, and then (require 'osx-location).

If you don't trust the required bundled executable (EmacsLocationHelper) which does the communication with CoreServices, you can build it yourself from the instructions here or using the bundled Makefile.

Usage

Start monitoring the location asynchronously like this:

 M-x osx-location-watch

To add code which responds to location changes, use osx-location-changed-hook. For example, you might add a hook function which updates calendar-latitude and calendar-longitude (defined in the built-in library solar), and then use rase.el to execute code automatically at sunrise or sunset.

Hook functions take no arguments; when your hook function runs, it can use the freshly-updated values of osx-location-latitude and osx-location-longitude.

Here's an example:

(eval-after-load 'osx-location
  '(when (eq system-type 'darwin)
     (add-hook 'osx-location-changed-hook
               (lambda ()
                 (setq calendar-latitude osx-location-latitude
                       calendar-longitude osx-location-longitude
                       calendar-location-name (format "%s, %s" osx-location-latitude osx-location-longitude))))))

Steve Purcell's blog // @sanityinc on Twitter