Move gnus init to main org file

This commit is contained in:
Tom Willemse 2018-01-01 16:49:54 -08:00
parent 9ae6f7f1be
commit a850175555
4 changed files with 133 additions and 153 deletions

View file

@ -5,14 +5,14 @@ include ../../dotfiles.mk
AUTOLOADS_FILE = site-lisp/site-autoloads.el
UNWANTED = $(AUTOLOADS_FILE) site-lisp/flycheck_% site-lisp/flycheck-%
SITE_LISPS = $(addsuffix c,$(filter-out $(UNWANTED),$(wildcard site-lisp/*.el)))
INIT_LISPS = init/oni-org-init.elc init/oni-js2-init.elc \
INIT_LISPS = init/oni-org-init.elc init/oni-js2-init.elc init/oni-gnus-init.elc \
$(addsuffix .elc,$(basename $(wildcard init/*.org)))
VENDOR_DIRS = $(wildcard vendor-lisp/*)
.PHONE: all snippets
all: $(SITE_LISPS) init.elc $(INIT_LISPS) $(AUTOLOADS_FILE) snippets
init.el init/oni-org-init.el init/oni-js2-init.el: init.org
init.el init/oni-org-init.el init/oni-js2-init.el init/oni-gnus-init.el: init.org
$(call tangle,emacs-lisp)
%.el: %.org

View file

@ -1406,6 +1406,137 @@ Computing Environment".
(add-hook 'jabber-chat-mode-hook 'oni:set-default-directory)
#+END_SRC
** Gnus
:PROPERTIES:
:header-args: :tangle "init/oni-gnus-init.el"
:END:
Gnus is the very extensible Emacs news reader, which just happens
to also function very well as a mail reader. Since it is so
extensible and also configurable the configuration for it tends to
get big, so I split it into a separate file.
#+BEGIN_SRC emacs-lisp :tangle yes
(with-eval-after-load 'gnus (load "oni-gnus-init"))
#+END_SRC
Configuring Gnus is actually configuring a handful of packages, so
I require them all when Gnus is loaded so the byte compiler won't
yell at me.
#+BEGIN_SRC emacs-lisp
(require 'gnus)
(require 'gnus-msg)
(require 'mail-source)
(require 'message)
(require 'nnfolder)
(require 'sendmail)
#+END_SRC
I don't like having a lot of files spread around in my =.emacs.d=
directory, so put all of Gnus', Message's and nnfolder's data in
=.emacs.d/data=.
#+BEGIN_SRC emacs-lisp
(setq gnus-directory (locate-user-emacs-file "data/News")
gnus-article-save-directory gnus-directory
gnus-cache-directory gnus-directory
gnus-kill-files-directory gnus-directory)
(setq mail-source-directory (locate-user-emacs-file "data/Mail")
message-directory mail-source-directory
nnfolder-directory mail-source-directory)
#+END_SRC
Use msmtp to send my messages.
#+BEGIN_SRC emacs-lisp
(setq send-mail-function 'send-mail-send-it
message-send-mail-function 'message-send-mail-with-sendmail
sendmail-program "/usr/bin/msmtp")
#+END_SRC
I've been using Gnus for a while now and I don't think I fit the
profile of a novice anymore. Turning this off will stop Gnus from
asking me if I'm sure I want to delete a certain message, I do this
a lot because expiring messages seems to take too long for my
tastes.
#+BEGIN_SRC emacs-lisp
(setq gnus-novice-user nil)
#+END_SRC
Add a keybinding to the Gnus summary mode to easily delete
messages.
#+BEGIN_SRC emacs-lisp
(defun oni-gnus-delete-forward (&optional n)
"Delete the article under point and move to the next one.
Do this N times."
(interactive "p")
(dotimes (_ (or n 1))
(gnus-summary-delete-article)
(gnus-summary-next-subject 1)))
(define-key gnus-summary-mode-map (kbd "M-d") #'oni-gnus-delete-forward)
#+END_SRC
Change the format of how each line for a group in the Group buffer
is displayed. This shows the group name, the select method, group
subscription status, the process mark (whatever that is), whether
there is a summary buffer open for that group, number of unread
articles and the number of ticked articles.
#+BEGIN_SRC emacs-lisp
(setq gnus-group-line-format "%P%(%20G%): %-10s %S%p%B %5y %5T\n")
#+END_SRC
*** Mail accounts
I mostly use two email accounts.
**** ryuslash.org
Set my main email account as the primary select method for Gnus.
#+BEGIN_SRC emacs-lisp
(setq gnus-select-method
'(nnmaildir "ryuslash" (directory "~/documents/mail/ryuslash/")))
#+END_SRC
When sending mail from the ryuslash inbox, use the ryuslash msmtp
account.
#+BEGIN_SRC emacs-lisp
(add-to-list 'gnus-posting-styles
'(".*"
(address "tom@ryuslash.org")
(eval (setq message-sendmail-extra-arguments
'("-a" "ryuslash")))))
#+END_SRC
**** gmail.com
Add my other personal email as a secondary select method.
#+BEGIN_SRC emacs-lisp
(add-to-list 'gnus-secondary-select-methods
'(nnmaildir "gmail"
(directory "~/documents/mail/gmail/")))
#+END_SRC
When sending mail from the gmail account, use the gmail msmtp
accound and set the proper email address.
#+BEGIN_SRC emacs-lisp
(add-to-list 'gnus-posting-styles
'("gmail:"
(name "Tom Willemse")
(address "ryuslash@gmail.com")
(eval (setq message-sendmail-extra-arguments
'("-a" "gmail")))))
#+END_SRC
** Org mode
:PROPERTIES:
:header-args: :tangle "init/oni-org-init.el"

View file

@ -1,112 +0,0 @@
Gnus is one of the most extensible Email programs on the
planet. And it's not even made for email but NNTP.
#+BEGIN_SRC emacs-lisp
(require 'gnus)
(require 'gnus-msg)
(require 'mail-source)
(require 'message)
(require 'nnfolder)
(require 'sendmail)
(require 'oni-helpers)
#+END_SRC
Store all Gnus-related data in my data directory.
#+BEGIN_SRC emacs-lisp
(setq gnus-directory (oni:data-location "News")
gnus-article-save-directory gnus-directory
gnus-cache-directory gnus-directory
gnus-kill-files-directory gnus-directory)
#+END_SRC
Store all Mail source-related data in my data directory.
#+BEGIN_SRC emacs-lisp
(setq mail-source-directory (oni:data-location "Mail"))
#+END_SRC
Store all message-related data in the same place as the Mail source
data.
#+BEGIN_SRC emacs-lisp
(setq message-directory (oni:data-location "Mail"))
#+END_SRC
Store all nnfolder-related data in the same place as the Mail
source data.
#+BEGIN_SRC emacs-lisp
(setq nnfolder-directory (oni:data-location "Mail"))
#+END_SRC
Use msmtp to send mail.
#+BEGIN_SRC emacs-lisp
(setq send-mail-function 'sendmail-send-it)
(setq sendmail-program "/usr/bin/msmtp")
#+END_SRC
Tell Gnus I'm not a novice anymore. One of the features of Gnus I
use a lot is deleting messages and as long as Gnus thinks I'm a
novice it will ask me if I'm sure every single time.
#+BEGIN_SRC emacs-lisp
(setq gnus-novice-user nil)
#+END_SRC
Add a keybinding to the Gnus summary mode to easily delete
messages.
#+BEGIN_SRC emacs-lisp
(define-key gnus-summary-mode-map (kbd "M-d") 'oni-gnus-delete-forward)
#+END_SRC
Change the Gnus group buffer line format.
#+BEGIN_SRC emacs-lisp
(setq gnus-group-line-format "%P%(%20G%): %-10s %S%p%B %5y %5T\n")
#+END_SRC
* ryuslash.org
Set my main email address as the primary select method for Gnus.
#+BEGIN_SRC emacs-lisp
(setq gnus-select-method
'(nnmaildir "ryuslash" (directory "~/documents/mail/ryuslash/")))
#+END_SRC
When sending mail from the ryuslash inbox, use the ryuslash msmtp
account.
#+BEGIN_SRC emacs-lisp
(add-to-list 'gnus-posting-styles
'(".*"
(address "tom@ryuslash.org")
(eval (setq message-sendmail-extra-arguments
'("-a" "ryuslash")))))
#+END_SRC
* gmail
Add my other personal email as a secondary select method.
#+BEGIN_SRC emacs-lisp
(add-to-list 'gnus-secondary-select-methods
'(nnmaildir "gmail"
(directory "~/documents/mail/gmail/")))
#+END_SRC
When sending mail from the gmail account, use the gmail msmtp
accound and set the proper email address.
#+BEGIN_SRC emacs-lisp
(add-to-list 'gnus-posting-styles
'("gmail:"
(name "Tom Willemse")
(address "ryuslash@gmail.com")
(eval (setq message-sendmail-extra-arguments
'("-a" "gmail")))))
#+END_SRC

View file

@ -1,39 +0,0 @@
;;; oni-gnus.el --- Extra commands and functions for gnus -*- lexical-binding: t; -*-
;; Copyright (C) 2016 Tom Willemse
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords:
;; 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:
;; Here are some extra commands and functions for gnus.
;;; Code:
(require 'gnus-sum)
;;;###autoload
(defun oni-gnus-delete-forward (&optional n)
"Delete the article under point and move to the next one.
Do this N times."
(interactive "p")
(dotimes (_ (or n 1))
(gnus-summary-delete-article)
(gnus-summary-next-subject 1)))
(provide 'oni-gnus)
;;; oni-gnus.el ends here