summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.el106
-rw-r--r--funcs.el128
-rw-r--r--keybindings.el28
-rw-r--r--packages.el58
4 files changed, 320 insertions, 0 deletions
diff --git a/config.el b/config.el
new file mode 100644
index 0000000..b9e36db
--- /dev/null
+++ b/config.el
@@ -0,0 +1,106 @@
+;; Not much related configurations
+(defvar notmuch-hello-refresh-count 0)
+(setq mail-user-agent 'message-user-agent)
+
+(custom-set-variables
+ '(message-send-hook (quote (notmuch-message-mark-replied)))
+ '(notmuch-address-command "notmuch-addrlookup")
+ '(notmuch-always-prompt-for-sender t)
+ '(notmuch-crypto-process-mime t)
+ '(notmuch-fcc-dirs
+ (quote
+ (("vasudev-debian@copyninja.info" . "vasudev-debian/Sent")
+ ("vasudev@debian.org" . "vasudev-debian/Sent")
+ ("vasudev@copyninja.info" . "vasudev-copyninja.info/Sent")
+ ("kamathvasudev@gmail.com" . "Gmail-1/Sent"))))
+ '(notmuch-hello-tag-list-make-query "tag:unread")
+ '(notmuch-message-headers (quote ("Subject" "To" "Cc" "Bcc" "Date" "Reply-To")))
+ '(notmuch-saved-searches
+ (quote
+ ((:name "debian-devel" :query "tag:debian-devel and tag:unread")
+ (:name "debian-fonts" :query "tag:debian-fonts and tag:unread")
+ (:name "debian-india" :query "tag:debian-india and tag:Debian-India and tag:unread")
+ (:name "debian-devel-announce" :query "tag:debian-devel-announce and tag:unread")
+ (:name "Plan9 and 9Front" :query "tag:9fans and and tag:9front and tag:unread")
+ (:name "rkrishnan" :query "tag:rkrishnan and tag:unread")
+ (:name "Gmail/INBOX" :query "folder:Gmail-1/INBOX and tag:unread")
+ (:name "vasudev/INBOX" :query "folder:vasudev-copyninja.info/INBOX and tag:unread")
+ (:name "vasudev-debian/INBOX" :query "folder:vasudev-debian/INBOX and tag:unread")
+ (:name "debian-project" :query "tag:debian-project and tag:unread")
+ (:name "libindic-dev" :query "tag:libindic-dev and tag:unread")
+ (:name "TODO" :query "tag:TODO")
+ (:name "debian-rust" :query "tag:pkg-rust and tag:unread")
+ (:name "Tahoe Development" :query "tag:tahoe-dev and tag:unread")
+ (:name "Debian Multimedia (my packages)"
+ :query "tag:pkg-multimedia and tag:unread and \( subject:(rem.*):.* or subject:(librem.*):.* \)")
+ (:name "Debian VoIP (my packages)"
+ :query "tag:pkg-voip and tag:unread and \( subject:(*libre*):.* or subject:(baresip*):.* or subject:(biboumi*):.* \)"))))
+ '(notmuch-search-line-faces
+ (quote
+ (("deleted" :foreground "red")
+ ("unread" :weight bold)
+ ("flagged" :foreground "blue"))))
+ '(notmuch-search-oldest-first nil)
+ '(notmuch-show-all-multipart/alternative-parts nil)
+ '(notmuch-show-all-tags-list t)
+ '(notmuch-show-insert-text/plain-hook
+ (quote
+ (notmuch-wash-convert-inline-patch-to-part notmuch-wash-tidy-citations
+ notmuch-wash-elide-blank-lines
+ notmuch-wash-excerpt-citations))))
+
+(add-hook 'notmuch-hello-refresh-hook 'notmuch-hello-refresh-status-message)
+
+;; SMTP mail multi related configurations
+(setq smtpmail-multi-accounts
+ '((copyninja-mail "vasudev" "localhost" 25
+ header nil nil nil "rudra")
+ (gmail-primary nil "localhost" 25
+ header nil nil nil "rudra")))
+(setq smtpmail-multi-assosications
+ '((("From" . "kamathvasudev@gmail.com")
+ gmail-primary)
+ (("From" . "vasudev@copyninja.info")
+ copyninja-mail)
+ (("From" . "vasudev@debian.org")
+ copyninja-mail)))
+
+;; Message sending functions
+(setq send-mail-function 'smtpmail-multi-send-it
+ message-send-mail-function 'smtpmail-multi-send-it
+ smtpmail-auth-credntials "/home/vasudev/.authinfo.gpg")
+
+
+;; GNUS posting style
+(require 'gnus-art)
+(setq gnus-posting-styles
+ '(((header "to" "kamathvasudev@gmail.com")
+ (address "kamathvasudev@gmail.com"))
+ ((header "to" "vasudev@copyninja.info")
+ (address "vasudev@copyninja.info"))
+ ((header "to" "vasudev-debian@copyninja.info")
+ (address "vasudev@debian.org"))
+ ((header "to" "vasudev@debian.org")
+ (address "vasudev@debian.org"))))
+
+;; Enable bbdb configurations
+(bbdb-initialize 'message 'gnus 'sendmail)
+(setq bbdb-file "~/.bbdb.db")
+
+;; size of bbdb popup
+(setq bbdb-pop-up-window-size 10)
+
+;; What do we do when invoking bbdb interactively
+(setq bbdb-mua-update-interactive-p '(query . create))
+
+;; Make sure we look at every address in a message and not only the
+;; first one
+(setq bbdb-message-all-addresses t)
+
+(setq bbdb/mail-auto-create-p t
+ bbdb/news-auto-create-p t)
+
+(add-hook 'message-mode-hook
+ '(lambda ()
+ (flyspell-mode t)
+ (local-set-key "<TAB>" 'bbdb-complete-name)))
diff --git a/funcs.el b/funcs.el
new file mode 100644
index 0000000..c0c6570
--- /dev/null
+++ b/funcs.el
@@ -0,0 +1,128 @@
+;; Display number of message on refresh of notmuch
+(defun notmuch-hello-refresh-status-message ()
+ (unless no-display
+ (let* ((new-count
+ (string-to-number
+ (car (process-lines notmuch-command "count"))))
+ (diff-count (- new-count notmuch-hello-refresh-count)))
+ (cond
+ ((= notmuch-hello-refresh-count 0)
+ (message "You have %s messages."
+ (notmuch-hello-nice-number new-count)))
+ ((> diff-count 0)
+ (message "You have %s more messages since last refresh."
+ (notmuch-hello-nice-number diff-count)))
+ ((< diff-count 0)
+ (message "You have %s fewer messages since last refresh."
+ (notmuch-hello-nice-number (- diff-count)))))
+ (setq notmuch-hello-refresh-count new-count))))
+
+(defun notmuch-mark-all-read()
+ "Mark all as read in current search"
+ (interactive)
+ (notmuch-search-tag-all (list "-unread"))
+ (notmuch-search-refresh-view))
+
+(defun notmuch-search-tag-and-advance (&rest tags)
+ "Add tag or set of tags to current thread"
+ (mapc 'notmuch-search-tag tags)
+ (notmuch-search-next-thread))
+
+(defun notmuch-mark-as-read()
+ "Mark current thread as read"
+ (interactive)
+ (notmuch-search-tag-and-advance (list "-unread")))
+
+(defun notmuch-mark-as-spam()
+ "Mark the current message as spam"
+ (interactive)
+ (notmuch-search-tag-and-advance (list "+Spam" "-inbox" "-unread")))
+
+(defun notmuch-search-add-todo ()
+ "Add 'TODO' tag when in search-mode"
+ (interactive)
+ (notmuch-search-tag-and-advance (list "+TODO")))
+
+(defun notmuch-search-remove-todo ()
+ "Remove a 'TODO' tag in search mode"
+ (interactive)
+ (notmuch-search-tag-and-advance (list "-TODO")))
+
+(defun notmuch-mark-deleted ()
+ "Add 'deleted' tag in search mode"
+ (interactive)
+ (notmuch-search-tag-and-advance (list "+deleted")))
+
+;; Functions copied from
+;; https://notmuchmail.org/pipermail/notmuch/2012/011692.html
+(require 'bbdb-snarf)
+(defun bbdb/notmuch-snarf-header (header)
+ (let ((text (notmuch-show-get-header header)))
+ (with-temp-buffer
+ (insert text)
+ (bbdb-snarf-region (point-min) (point-max)))))
+
+(defun bbdb/notmuch-snarf-from ()
+ (interactive)
+ (bbdb/notmuch-snarf-header :From))
+
+(defun bbdb/notmuch-snarf-to ()
+ (interactive)
+ (bbdb/notmuch-snarf-header :To))
+
+;; color from line according to known / unknown sender
+ ; code taken from bbdb-gnus.el
+(defun bbdb/notmuch-known-sender ()
+ (let* ((from (plist-get headers :From))
+ (splits (mail-extract-address-components from))
+ (name (car splits))
+ (net (cadr splits))
+ (record (and splits
+ (bbdb-search-simple
+ name
+ (if (and net bbdb-canonicalize-net-hook)
+ (bbdb-canonicalize-address net)
+ net)))))
+ (and record net (member (downcase net) (bbdb-record-net record)))))
+
+(defun bbdb/check-known-sender ()
+ (interactive)
+ (if (bbdb/notmuch-known-sender) (message "Sender is known") (message "Sender is not known")))
+
+(defface notmuch-show-known-addr
+ '(
+ (((class color) (background dark)) :foreground "spring green")
+ (((class color) (background light)) :background "spring green" :foreground "black"))
+ "Face for sender or recipient already listed in bbdb"
+ :group 'notmuch-show
+ :group 'notmuch-faces)
+
+(defface notmuch-show-unknown-addr
+ '(
+ (((class color) (background dark)) :foreground "dark orange")
+ (((class color) (background light)) :background "gold" :foreground "black"))
+ "Face for sender or recipient not listed in bbdb"
+ :group 'notmuch-show
+ :group 'notmuch-faces)
+
+ ; override function from notmuch-show
+(defun notmuch-show-insert-headerline (headers date tags depth)
+ "Insert a notmuch style headerline based on HEADERS for a
+message at DEPTH in the current thread."
+ (let ((start (point))
+ (face (if (bbdb/notmuch-known-sender) 'notmuch-show-known-addr 'notmuch-show-unknown-addr))
+ (end-from))
+ (insert (notmuch-show-spaces-n (* notmuch-show-indent-messages-width depth))
+ (notmuch-show-clean-address (plist-get headers :From)))
+ (setq end-from (point))
+ (insert
+ " ("
+ date
+ ") ("
+ (propertize (mapconcat 'identity tags " ")
+ 'face 'notmuch-tag-face)
+ ")\n")
+ (overlay-put (make-overlay start (point)) 'face 'notmuch-message-summary-face)
+ (save-excursion
+ (goto-char start)
+ (overlay-put (make-overlay start end-from) 'face face))))
diff --git a/keybindings.el b/keybindings.el
new file mode 100644
index 0000000..2efc7bc
--- /dev/null
+++ b/keybindings.el
@@ -0,0 +1,28 @@
+(require 'notmuch)
+(define-key notmuch-search-mode-map "u" 'notmuch-mark-as-read)
+(define-key notmuch-search-mode-map "U" 'notmuch-mark-all-read)
+
+(define-key notmuch-search-mode-map (kbd "S-<f9>") 'notmuch-search-remove-todo)
+(define-key notmuch-search-mode-map (kbd "<f9>") 'notmuch-search-add-todo)
+
+(define-key notmuch-search-mode-map "d" 'notmuch-mark-deleted)
+(define-key notmuch-search-mode-map "s" 'notmuch-mark-as-spam)
+
+(define-key notmuch-show-mode-map "c" 'bbdb/notmuch-snarf-from)
+(define-key notmuch-show-mode-map "C" 'bbdb/notmuch-snarf-to)
+
+;; Bounce key for bouncing message
+(define-key notmuch-show-mode-map "b"
+ (lambda (&optional address)
+ "Bounce the current message."
+ (interactive "sBounce To: ")
+ (notmuch-show-view-raw-message)
+ (message-resend address)))
+
+(define-key notmuch-show-mode-map "d"
+ (lambda ()
+ "toggle deleted tag for message"
+ (interactive)
+ (if (member "deleted" (notmuch-show-get-tags))
+ (notmuch-show-tag (list "-deleted"))
+ (notmuch-show-tag (list "+deleted")))))
diff --git a/packages.el b/packages.el
new file mode 100644
index 0000000..42a5ad5
--- /dev/null
+++ b/packages.el
@@ -0,0 +1,58 @@
+;;; packages.el --- notmuch layer packages file for Spacemacs.
+;;
+;; Copyright (c) 2012-2017 Sylvain Benner & Contributors
+;;
+;; Author: Vasudev Kamath <vasudev@copyninja.info>
+;; URL: https://github.com/syl20bnr/spacemacs
+;;
+;; This file is not part of GNU Emacs.
+;;
+;;; License: GPLv3
+
+;;; Commentary:
+
+;; See the Spacemacs documentation and FAQs for instructions on how to implement
+;; a new layer:
+;;
+;; SPC h SPC layers RET
+;;
+;;
+;; Briefly, each package to be installed or configured by this layer should be
+;; added to `notmuch-packages'. Then, for each package PACKAGE:
+;;
+;; - If PACKAGE is not referenced by any other Spacemacs layer, define a
+;; function `notmuch/init-PACKAGE' to load and initialize the package.
+
+;; - Otherwise, PACKAGE is already referenced by another Spacemacs layer, so
+;; define the functions `notmuch/pre-init-PACKAGE' and/or
+;; `notmuch/post-init-PACKAGE' to customize the package as it is loaded.
+
+;;; Code:
+
+(defconst notmuch-packages
+ '(
+ notmuch
+ smtpmail-multi
+ gnus
+ bbdb
+ ))
+
+(defun notmuch/init-notmuch ()
+ (use-package notmuch
+ :defer t
+ ))
+
+(defun notmuch/init-smtpmail-multi ()
+ (use-package smtpmail-multi
+ :defer t
+ ))
+
+(defun notmuch/init-gnus ()
+ (use-package gnus
+ :defer t
+ ))
+
+(defun notmuch/init-bbdb ()
+ (use-package bbdb
+ :defer t
+ ))