Skip to content

Instantly share code, notes, and snippets.

@tbielawa
Created March 12, 2012 15:23
Show Gist options
  • Save tbielawa/2022620 to your computer and use it in GitHub Desktop.
Save tbielawa/2022620 to your computer and use it in GitHub Desktop.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:
;; From my defuns.el file
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; We should avoid trying to launch OfflineIMAP multiple times.
;; OfflineIMAP will quit on its own, but we'll get nasty error
;; messages
(defun offlineimap-runningp ()
"Tell us if the Offlineimap process is already running or not."
(interactive)
(let
((imap-buffer (get-buffer "*OfflineIMAP*")))
(if (null imap-buffer)
nil
t)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Lets get some email going!
(defun email()
"Notmuch mail client and the imap poller"
(interactive)
(load-file "~/.emacs.d/notmuch-config.el")
(if (null (offlineimap-runningp))
(offlineimap))
(if (null (get-buffer "*notmuch-hello*"))
(progn
(color-theme-twilight)
(notmuch)
t)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Toggle dem buffas
(defun toggle-mail-buffers ()
"Toggle back and forth between notmuch and offlineimap"
(interactive)
(unless (email)
(let ((cb (buffer-name))
(nm "*notmuch-hello*")
(oi "*OfflineIMAP*"))
(message "Current buffer: %s" cb)
(if (string= cb nm) ;; if current buffer is notmuch, switch to offlineimap
(progn
(message "If! (cb is nm)")
(message "Switching to %s from %s" oi cb)
(switch-to-buffer oi)
(goto-char (point-max)))
;; else (curbuf is offlineimap, switch to notmuch
(progn
(message "Else! (cb is not nm)")
(message "Switching to %s from %s" nm cb)
(switch-to-buffer nm)
(notmuch-hello-update)
)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:
;; From my modes.el file
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:
;;; Lets generalize for a moment. Keep host specific stuff out of the way
(let
((hostname (getenv "HOSTNAME")))
(if (string-equal hostname "deepfryer")
(progn
;;; Lets get our email syncing in the background while running 'email'
(require 'offlineimap)
;;; Then we can think about the mail reader
(require 'notmuch)
;; Sign messages by default (http://notmuchmail.org/emacstips/#index11h2)
(add-hook 'message-setup-hook 'mml-secure-sign-pgpmime)
;; Remedy tag hooks
(require 'remedy-tag-mode)
(global-set-key (kbd "<f8>") 'toggle-mail-buffers))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment