summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2015-04-30 09:52:03 +0900
committerSean Whitton <spwhitton@spwhitton.name>2015-04-30 09:52:03 +0900
commitdca3b857f585efde265938728de15ac3f98c113b (patch)
treece97c2f1d2bf1e5cbd72a0ca8030d2e5c2bb5c3d
parent4bc386d9e2d415c56f5b7bbdaa4e754020342209 (diff)
downloaddotfiles-dca3b857f585efde265938728de15ac3f98c113b.tar.gz
world time setup
-rw-r--r--.emacs.d/init.el20
-rw-r--r--.emacs.d/site-lisp/world-time-mode.el91
2 files changed, 111 insertions, 0 deletions
diff --git a/.emacs.d/init.el b/.emacs.d/init.el
index 230d4b5b..128c3d67 100644
--- a/.emacs.d/init.el
+++ b/.emacs.d/init.el
@@ -1072,6 +1072,22 @@
:init (dolist (hook '(emacs-lisp-mode-hook ielm-mode-hook))
(add-hook hook 'elisp-slime-nav-mode)))
+(use-package world-time-mode)
+
+;; and set up time zones I'm interested in
+
+(if (eq system-type 'windows-nt)
+
+ (setq display-time-world-list '(("MST7" "Phoenix")
+ ("GMT0BST" "London")
+ ("CET-1CDT" "Paris")
+ ("KST-9" "Seoul")))
+
+ (setq display-time-world-list '(("America/Phoenix" "Phoenix")
+ ("Europe/London" "London")
+ ("Europe/Paris" "Paris")
+ ("Asia/Seoul" "Seoul"))))
+
;;;; ---- functions ----
@@ -1754,6 +1770,10 @@ BINDEE may be a command or another keymap, but whatever it is, it should not be
(find-file "~/src/dotfiles/.emacs.d/init.el")
(eval-buffer)))
+ ("g t l" . world-time-list)
+ ("g t h" . helm-world-time)
+ ("g t t" . display-time-world)
+
;; Sariul launcher map
("S l" . spw/tblesson)
("S S" . spw/auto-textbook)
diff --git a/.emacs.d/site-lisp/world-time-mode.el b/.emacs.d/site-lisp/world-time-mode.el
new file mode 100644
index 00000000..891b80cf
--- /dev/null
+++ b/.emacs.d/site-lisp/world-time-mode.el
@@ -0,0 +1,91 @@
+;;; world-time-mode.el --- show whole days of world-time diffs
+
+;; Copyright (C) 2013 Nic Ferrier
+
+;; Author: Nic Ferrier <nferrier@ferrier.me.uk>
+;; Keywords: tools, calendar
+;; Version: 0.0.6
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Very useful productivity tool if you work in different time zones.
+
+;;; Code:
+
+(require 'cl)
+(require 'time)
+
+(defun world-time/zone-list (this-time)
+ "Return the vector of zoned times for TIME."
+ (apply 'vector
+ (mapcar
+ (lambda (zone)
+ (let ((original (getenv "TZ")))
+ (unwind-protect
+ (progn
+ (setenv "TZ" (car zone))
+ (list (format-time-string "%R %Z" this-time)))
+ (setenv "TZ" original))))
+ display-time-world-list)))
+
+
+(defun world-time/table-entrys ()
+ "Make the entry table for the list.
+
+Based on the next hour after the current time."
+ (let* ((currently (current-time))
+ (time-now (time-to-seconds currently))
+ (hours-since-epoch (/ time-now 3600))
+ (last-hour (* 3600.00 (floor hours-since-epoch)))
+ (next-hour (+ 3600.00 last-hour))
+ (ref-time (seconds-to-time next-hour))
+ (ref-list
+ (mapcar
+ (lambda (i)
+ (list nil
+ (world-time/zone-list
+ (time-add ref-time (seconds-to-time (* 3600.00 i))))))
+ (number-sequence 0 23))))
+ (append (list (list nil (world-time/zone-list currently))) ref-list)))
+
+(define-derived-mode
+ world-time-table-mode tabulated-list-mode "World Time"
+ "Major mode for seeing your world time list as a day."
+ (setq tabulated-list-entries 'world-time/table-entrys)
+ ;; This is wrong! it needs to be derived from display-time-world-list
+ (setq tabulated-list-format
+ (loop for time in display-time-world-list
+ vconcat (list (list (car time) 20 nil))))
+ (tabulated-list-init-header))
+
+;;;###autoload
+(defun world-time-list ()
+ "Show `display-time-world-list' full day comparison."
+ (interactive)
+ (with-current-buffer (get-buffer-create "*world-time*")
+ (world-time-table-mode)
+ (tabulated-list-print)
+ (switch-to-buffer (current-buffer))))
+
+;;;###autoload
+(defun list-world-time ()
+ "Show `display-time-world-list' full day comparison."
+ (interactive)
+ (call-interactively 'world-time-list))
+
+(provide 'world-time-mode)
+
+;;; world-time-mode.el ends here