From c7c9fc606990a627ba273f8a04bfac03bae67e78 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Thu, 11 Dec 2014 15:31:39 -0800 Subject: [PATCH] mu4e sync and make EDITOR work again. --- dotfiles/lib/mu4e_sync.sh | 3 +++ dotfiles/lib/shellenv/emacs.sh | 2 +- dotfiles/lib/shellrc/mu4e.sh | 28 ++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100755 dotfiles/lib/mu4e_sync.sh create mode 100644 dotfiles/lib/shellrc/mu4e.sh diff --git a/dotfiles/lib/mu4e_sync.sh b/dotfiles/lib/mu4e_sync.sh new file mode 100755 index 00000000..6273d98f --- /dev/null +++ b/dotfiles/lib/mu4e_sync.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env zsh +refresh_config +update_mail diff --git a/dotfiles/lib/shellenv/emacs.sh b/dotfiles/lib/shellenv/emacs.sh index 0058df8c..b6924a28 100644 --- a/dotfiles/lib/shellenv/emacs.sh +++ b/dotfiles/lib/shellenv/emacs.sh @@ -77,7 +77,7 @@ function time_emacs { } # Make emacs the default editor. -export EDITOR='emacs_open' +export EDITOR="e() { zsh -c 'emacs_open '"'"$@"; return 0; }; e' export VISUAL="$EDITOR" # This is ugly as sin but I can't figure out how else to do it. export GIT_EDITOR="zsh -c 'emacs_open '"'"$@"; return 0' diff --git a/dotfiles/lib/shellrc/mu4e.sh b/dotfiles/lib/shellrc/mu4e.sh new file mode 100644 index 00000000..c46ce73f --- /dev/null +++ b/dotfiles/lib/shellrc/mu4e.sh @@ -0,0 +1,28 @@ +MAILDIR="$HOME/Mail" +DBUS_COOKIE="$HOME/.sauron-dbus" + +function sauron_msg { + if test -z "$DBUS_SESSION_BUS_ADDRESS"; then + echo "DBUS session not found." + if test -e $DBUS_COOKIE; then + export DBUS_SESSION_BUS_ADDRESS="`cat $DBUS_COOKIE`" + else + echo "DBUS cookie not found, unable to send message" + fi + fi + if test -n "$DBUS_SESSION_BUS_ADDRESS"; then + dbus-send --session \ + --dest="org.gnu.Emacs" \ + --type=method_call \ + "/org/gnu/Emacs/Sauron" \ + "org.gnu.Emacs.Sauron.AddMsgEvent" \ + string:"$1" uint32:3 string:"$2" + fi +} + +function update_mail { + offlineimap + for f in `find "$MAILDIR/INBOX/" -mmin -5 -a -type f`; do + sauron_msg "Gmail" "$(mu view $f | grep -B 10 Date)" + done +}