Skip to content
Make Emacs watch and respond to changes in geographical location on OS X
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
CoreLocationTest.m Check in original source for helper May 22, 2015
EmacsLocationHelper
Makefile
README.md Add Patreon badge Sep 9, 2017
osx-location-pkg.el
osx-location.el

README.md

Melpa Status Melpa Stable Status Support me

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, 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

You can’t perform that action at this time.