Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix mail stuff, mu4e working now

  • Loading branch information...
commit 4a8a11f904e4b0d54bc9a71cfb8d2204b70e05a8 1 parent 6f79823
@dakrone authored
View
1  .emacs.d/hinmanm/bindings.el
@@ -141,3 +141,4 @@
(global-set-key (kbd "C-c ;") 'iy-go-to-char-continue)
(global-set-key (kbd "C-c ,") 'iy-go-to-char-continue-backward)
+(global-set-key (kbd "C-c m") 'mu4e)
View
33 .emacs.d/hinmanm/erc-stuff.el
@@ -2,15 +2,15 @@
;; ==== Growl support on OSX ====
-(defun growl-notification (title message &optional sticky)
- "Send a Growl notification"
- (do-applescript
- (format "tell application \"GrowlHelperApp\"
- notify with name \"Emacs Notification\" title \"%s\" description \"%s\" application name \"Emacs.app\" sticky %s
- end tell"
- title
- (replace-regexp-in-string "\"" "'" message)
- (if sticky "yes" "no"))))
+;; (defun growl-notification (title message &optional sticky)
+;; "Send a Growl notification"
+;; (do-applescript
+;; (format "tell application \"GrowlHelperApp\"
+;; notify with name \"Emacs Notification\" title \"%s\" description \"%s\" application name \"Emacs.app\" sticky %s
+;; end tell"
+;; title
+;; (replace-regexp-in-string "\"" "'" message)
+;; (if sticky "yes" "no"))))
;; ==== ERC stuff ====
;; Only track my nick(s)
@@ -28,13 +28,13 @@
(setq erc-track-exclude-types '("JOIN" "NICK" "PART" "QUIT" "MODE"
"324" "329" "332" "333" "353" "477"))
-(defun call-growl (matched-type nick msg)
- (let* ((nick (first (split-string nick "!"))))
- (growl-notification nick msg)))
+;; (defun call-growl (matched-type nick msg)
+;; (let* ((nick (first (split-string nick "!"))))
+;; (growl-notification nick msg)))
;; only add the hook for Mac
-(when (eq window-system 'ns)
- (add-hook 'erc-text-matched-hook 'call-growl))
+;; (when (eq window-system 'ns)
+;; (add-hook 'erc-text-matched-hook 'call-growl))
(setq erc-button-url-regexp
"\\([-a-zA-Z0-9_=!?#$@~`%&*+\\/:;,]+\\.\\)+[-a-zA-Z0-9_=!?#$@~`%&*+\\/:;,]*[-a-zA-Z0-9\\/]")
@@ -73,8 +73,7 @@
"joegallo" "jimduey" "leathekd" "rhickey" "zkim" "steve"
"imotov" "joekinsella" "craig" "technomancy" "ddillinger"
"yazirian")
- erc-keywords '("clojuredocs" "clj-http" "cheshire" "itsy" "opennlp"
- "clj-json")
+ erc-keywords '("clojuredocs" "clj-http" "cheshire" "itsy" "opennlp")
erc-ignore-list '("sonian-chef")
erc-log-matches-types-alist
'((keyword . "ERC Keywords")
@@ -82,7 +81,7 @@
erc-log-matches-flag t
erc-prompt-for-nickserv-password nil)
(require 'erc-services)
- (require 'erc-spelling)
+;; (require 'erc-spelling)
(and
(require 'erc-highlight-nicknames)
(add-to-list 'erc-modules 'highlight-nicknames)
View
266 .emacs.d/hinmanm/mail.el
@@ -7,22 +7,10 @@
(setq mu4e-mu-binary "/usr/local/bin/mu")
-(setq mu4e-maildir "~/.mail"
- ;; rest of the paths are relative to mu4e-maildir
- mu4e-sent-folder "/sent"
- mu4e-drafts-folder "/drafts"
- mu4e-trash-folder "/trash"
- mu4e-refile-folder "/archive")
+(setq mu4e-get-mail-command "offlineimap")
-(setq mu4e-get-mail-command "offlineimap"
- mu4e-update-interval 300)
-
-(setq message-send-mail-functio 'smtpmail-send-it)
(setq smtpmail-smtp-server "smtp.example.org")
-(setq mu4e-sent-messages-behavior 'delete)
-
-(add-to-list 'mu4e-bookmarks
- '("size:5M..500M" "Big messages" ?b))
+;;(setq mu4e-sent-messages-behavior 'delete)
;; save attachments to the desktop
(setq mu4e-attachment-dir "~/Desktop")
@@ -30,3 +18,253 @@
(setq mu4e-view-show-images t
mu4e-view-image-max-width 800)
+
+;; David's (and now my) config
+
+ ;; Vars used below
+(defvar kdl-mu4e-new-mail nil
+ "Boolean to represent if there is new mail.")
+
+(defvar kdl-mu4e-url-location-list '()
+ "Stores the location of each link in a mu4e view buffer")
+
+;; This is also defined in init.el, but b/c ESK runs all files in the
+;; user-dir before init.el it must also be defined here
+(defvar message-filter-regexp-list '()
+ "regexps to filter matched msgs from the echo area when message is called")
+
+(setq message-kill-buffer-on-exit t ;; kill sent msg buffers
+ ;; use msmtp
+ message-send-mail-function 'message-send-mail-with-sendmail
+ sendmail-program "/usr/local/bin/msmtp"
+ ;; Look at the from header to determine the account from which
+ ;; to send. Might not be needed b/c of kdl-msmtp
+ mail-specify-envelope-from t
+ mail-envelope-from 'header
+ message-sendmail-envelope-from 'header
+ ;; emacs email defaults
+ user-mail-address "lee@writequit.org"
+ user-full-name "Lee Hinman"
+ mail-host-address "writequit.org"
+ ;; mu4e defaults
+ mu4e-maildir "~/.mail"
+ ;; misc mu settings
+ ;; Unicode FTW
+ ;; mu4e-use-fancy-chars t
+ mu4e-use-fancy-chars nil
+ ;; Let gmail handle putting the message into Sent
+ ;; mu4e-sent-messages-behavior 'delete
+ ;; use the python html2text shell command to strip html
+ ;; mu4e-html2text-command "/Users/david/dev/html2text/html2text.py -b 72"
+ ;; check for new messages ever 30 minutes
+ mu4e-update-interval 180)
+
+ ;; Multi-account support
+(defun kdl-mu4e-current-account (&optional msg ignore-message-at-point)
+ "Figure out what the current account is based on the message being
+ composed, the message under the point, or (optionally)the message
+ passed in. Also supports ignoring the msg at the point."
+ (let ((cur-msg (or msg
+ mu4e-compose-parent-message
+ (and (not ignore-message-at-point)
+ (mu4e-message-at-point)))))
+ (when cur-msg
+ (let ((maildir (mu4e-msg-field cur-msg :maildir)))
+ (string-match "/\\(.*?\\)/" maildir)
+ (match-string 1 maildir)))))
+
+;; Support for multiple accounts
+(setq mu4e-sent-folder (lambda (msg) (format "/%s/[Gmail].Sent Mail"
+ (kdl-mu4e-current-account msg)))
+ mu4e-drafts-folder (lambda (msg) (format "/%s/[Gmail].Drafts"
+ (kdl-mu4e-current-account msg)))
+ mu4e-trash-folder (lambda (msg) (format "/%s/[Gmail].Trash"
+ (kdl-mu4e-current-account msg)))
+ mu4e-refile-folder (lambda (msg) (format "/%s/[Gmail].All Mail"
+ (kdl-mu4e-current-account msg)))
+ ;; The following list represents the account followed by key /
+ ;; value pairs of vars to set when the account is chosen
+ kdl-mu4e-account-alist
+ '(("gmail"
+ (user-mail-address "matthew.hinman@gmail.com")
+ (msmtp-account "gmail")
+ (mu4e-sent-messages-behavior delete))
+ ("sonian"
+ (user-mail-address "lee.hinman@sonian.net")
+ (msmtp-account "sonian")
+ (mu4e-sent-messages-behavior delete))
+ ("writequit"
+ (user-mail-address "lee@writequit.org")
+ (msmtp-account "writequit")
+ (mu4e-sent-messages-behavior sent)))
+ ;; These are used when mu4e checks for new messages
+ mu4e-my-email-addresses
+ (mapcar (lambda (acct) (cadr (assoc 'user-mail-address (cdr acct))))
+ kdl-mu4e-account-alist))
+
+(defun kdl-mu4e-choose-account ()
+ "Prompt the user for an account to use"
+ (completing-read (format "Compose with account: (%s) "
+ (mapconcat #'(lambda (var) (car var))
+ kdl-mu4e-account-alist "/"))
+ (mapcar #'(lambda (var) (car var))
+ kdl-mu4e-account-alist)
+ nil t nil nil (caar kdl-mu4e-account-alist)))
+
+(defun kdl-mu4e-set-compose-account ()
+ "Set various vars when composing a message. The vars to set are
+ defined in kdl-mu4e-account-alist."
+ (let* ((account (or (kdl-mu4e-current-account nil t)
+ (kdl-mu4e-choose-account)))
+ (account-vars (cdr (assoc account kdl-mu4e-account-alist))))
+ (when account-vars
+ (mapc #'(lambda (var)
+ (set (car var) (cadr var)))
+ account-vars))))
+(add-hook 'mu4e-compose-pre-hook 'kdl-mu4e-set-compose-account)
+
+ ;; Send mail through msmtp (setq stuff is below)
+(defun kdl-msmtp ()
+ "Add some arguments to the msmtp call in order to route the message
+ through the right account."
+ (if (message-mail-p)
+ (save-excursion
+ (let* ((from (save-restriction (message-narrow-to-headers)
+ (message-fetch-field "from"))))
+ (setq message-sendmail-extra-arguments (list "-a" msmtp-account))))))
+(add-hook 'message-send-mail-hook 'kdl-msmtp)
+
+ ;; Notification stuff
+(setq global-mode-string
+ (if (string-match-p "kdl-mu4e-new-mail"
+ (prin1-to-string global-mode-string))
+ global-mode-string
+ (cons
+ ;; '(kdl-mu4e-new-mail "✉" "")
+ '(kdl-mu4e-new-mail "MAIL" "")
+ global-mode-string)))
+
+(defun kdl-mu4e-unread-mail-query ()
+ "The query to look for unread messages in all account INBOXes.
+ More generally, change this code to affect not only when the
+ envelope icon appears in the modeline, but also what shows up in
+ mu4e under the Unread bookmark"
+ (mapconcat
+ (lambda (acct)
+ (let ((name (car acct)))
+ (format "%s"
+ (mapconcat (lambda (fmt)
+ (format fmt name))
+ '("flag:unread AND maildir:/%s/INBOX")
+ " "))))
+ kdl-mu4e-account-alist
+ " OR "))
+
+(defun kdl-mu4e-new-mail-p ()
+ "Predicate for if there is new mail or not"
+ (not (eq 0 (string-to-number
+ (replace-regexp-in-string
+ "[ \t\n\r]" "" (shell-command-to-string
+ (concat "mu find "
+ (kdl-mu4e-unread-mail-query)
+ " | wc -l")))))))
+
+(defun kdl-mu4e-notify ()
+ "Function called to update the new-mail flag used in the mode-line"
+ ;; This delay is to give emacs and mu a chance to have changed the
+ ;; status of the mail in the index
+ (run-with-idle-timer
+ 1 nil (lambda () (setq kdl-mu4e-new-mail (kdl-mu4e-new-mail-p)))))
+
+;; I put a lot of effort (probably too much) into getting the
+;; 'new mail' icon to go away by showing or hiding it:
+;; - periodically (this runs even when mu4e isn't running)
+(setq kdl-mu4e-notify-timer (run-with-timer 0 300 'kdl-notmuch-notify))
+;; - when the index is updated (this runs when mu4e is running)
+(add-hook 'mu4e-index-updated-hook 'kdl-mu4e-notify)
+;; - after mail is processed (try to make the icon go away)
+(defadvice mu4e-mark-execute-all
+ (after mu4e-mark-execute-all-notify activate) 'kdl-mu4e-notify)
+;; - when a message is opened (try to make the icon go away)
+(add-hook 'mu4e-view-mode-hook 'kdl-mu4e-notify)
+;; wrap lines
+(add-hook 'mu4e-view-mode-hook 'visual-line-mode)
+
+(defun kdl-mu4e-quit-and-notify ()
+ "Bury the buffer and check for new messages. Mainly this is intended
+ to clear out the envelope icon when done reading mail."
+ (interactive)
+ (bury-buffer)
+ (kdl-mu4e-notify))
+
+;; Make 'quit' just bury the buffer
+(define-key mu4e-headers-mode-map "q" 'kdl-mu4e-quit-and-notify)
+(define-key mu4e-main-mode-map "q" 'kdl-mu4e-quit-and-notify)
+
+ ;; View mode stuff
+;; Make it possible to tab between links
+(defun kdl-mu4e-populate-url-locations (&optional force)
+ "Scans the view buffer for the links that mu4e has identified and
+ notes their locations"
+ (when (or (null kdl-mu4e-url-location-list) force)
+ (make-local-variable 'kdl-mu4e-url-location-list)
+ (let ((pt (next-single-property-change (point-min) 'face)))
+ (while pt
+ (when (equal (get-text-property pt 'face) 'mu4e-view-link-face)
+ (add-to-list 'kdl-mu4e-url-location-list pt t))
+ (setq pt (next-single-property-change pt 'face)))))
+ kdl-mu4e-url-location-list)
+
+(defun kdl-mu4e-move-to-link (pt)
+ (if pt
+ (goto-char pt)
+ (error "No link found.")))
+
+(defun kdl-mu4e-forward-url ()
+ "Move the point to the beginning of the next link in the buffer"
+ (interactive)
+ (let* ((pt-list (kdl-mu4e-populate-url-locations)))
+ (kdl-mu4e-move-to-link
+ (or (some (lambda (pt) (when (> pt (point)) pt)) pt-list)
+ (some (lambda (pt) (when (> pt (point-min)) pt)) pt-list)))))
+
+(defun kdl-mu4e-backward-url ()
+ "Move the point to the beginning of the previous link in the buffer"
+ (interactive)
+ (let* ((pt-list (reverse (kdl-mu4e-populate-url-locations))))
+ (kdl-mu4e-move-to-link
+ (or (some (lambda (pt) (when (< pt (point)) pt)) pt-list)
+ (some (lambda (pt) (when (< pt (point-max)) pt)) pt-list)))))
+
+(define-key mu4e-view-mode-map (kbd "TAB") 'kdl-mu4e-forward-url)
+(define-key mu4e-view-mode-map (kbd "<backtab>") 'kdl-mu4e-backward-url)
+
+ ;; Misc
+;; The bookmarks for the main screen
+(setq mu4e-bookmarks
+ `((,(kdl-mu4e-unread-mail-query) "New messages" ?b)
+ ("date:today..now" "Today's messages" ?t)
+ ("date:7d..now" "Last 7 days" ?w)
+ ("mime:image/*" "Messages with images" ?p)
+ ("size:5M..500M" "Big messages" ?B)))
+
+;; Skip the main mu4e screen and go right to unread
+(defun kdl-mu4e-view-unread ()
+ "Open the Unread bookmark directly"
+ (interactive)
+ (mu4e~start)
+ (mu4e-headers-search-bookmark (mu4e-get-bookmark-query ?b)))
+
+(global-set-key (kbd "C-c 2") 'kdl-mu4e-view-unread)
+
+;; Don't echo some mu4e messages
+(add-to-list 'message-filter-regexp-list "mu4e.*Indexing.*processed")
+(add-to-list 'message-filter-regexp-list "mu4e.*Retrieving mail")
+(add-to-list 'message-filter-regexp-list "mu4e.*Started")
+
+ ;; Start it up
+(when (eq window-system 'ns)
+ ;; start mu4e
+ (mu4e~start)
+ ;; check for unread messages
+ (kdl-mu4e-notify))
View
1  .emacs.d/hinmanm/misc.el
@@ -68,6 +68,7 @@
;; ==== Appearance ====
+(set-fontset-font "fontset-default" 'symbol "Monaco")
(set-default-font "Anonymous Pro")
(set-face-attribute 'default nil :height 115)
;; Anti-aliasing
View
1  .emacs.d/init.el
@@ -3,6 +3,7 @@
(add-to-list 'load-path "~/.emacs.d/")
(add-to-list 'load-path (concat "~/.emacs.d/" (user-login-name)))
+;; loads ~/.emacs.d/hinmanm/<file>.el safely
( load "safe-load" nil t)
(safe-load "imports" nil t)
(safe-load "clojure-stuff" nil t)
View
3  .vim/.netrwhist
@@ -1,5 +1,6 @@
let g:netrw_dirhistmax =10
-let g:netrw_dirhist_cnt =3
+let g:netrw_dirhist_cnt =4
let g:netrw_dirhist_1='/Users/hinmanm/.pentadactyl'
let g:netrw_dirhist_2='/Users/hinmanm/.ssh'
let g:netrw_dirhist_3='/Users/hinmanm/.offlineimap'
+let g:netrw_dirhist_4='/Users/hinmanm'
Please sign in to comment.
Something went wrong with that request. Please try again.