• Gnus tweaks

    From Ivan Shmakov@21:1/5 to All on Sat Jul 21 06:55:24 2018
    I have recently figured out how to disable "unseen" messages
    tracking in Gnus (which I do not use, and which thus just wastes
    .newsrc.eld space for no benefit), and decided to document a few
    of the tweaks I've made to the Gnus (5.13 / Emacs 25.1+1 debian
    4+deb9u1) I use.

    As usual, opinions on why these may be good, bad or irrelevant,
    as well as constructive criticism, etc., are welcome.


    Table of contents

    Removing "unseen" tracking
    Require MIME, do not guess the encoding
    Use Emacs built-in word-wrap instead of Gnus "treating"
    Archive sent messages "as-is," without MIME-reencoding


    Removing "unseen" tracking

    (eval-after-load 'gnus-sum
    (progn
    ;; This list is used by gnus-update-marks, among others
    (setq gnus-article-mark-lists
    (delete '(seen . seen) gnus-article-mark-lists))
    (defun gnus-compute-unseen-list ()
    (setq gnus-newsgroup-unseen nil))
    ;; Not strictly necessary, but just in case
    (defun gnus-article-unseen-p (header)
    nil)))


    Require MIME, do not guess the encoding

    After 25 years of MIME existence, I'd rather be notified if an
    article comes without the relevant headers. Which are,
    thankfully, often next to trivial to add to newsreaders which
    aren't MIME-aware yet, like (replace utf-8 if necessary):

    MIME-Version: 1.0
    Content-Type: text/plain; charset=utf-8
    Content-Transfer-Encoding: 8bit

    (Or one can just stick to ASCII for one's posts; this article,
    for instance, is ought to be pure-ASCII.)

    (setq gnus-default-charset 'us-ascii
    gnus-group-charset-alist nil)

    Please note that due to a long-standing bug in the gateway
    operation, no such headers are used for fido7.* newsgroups;
    so if the latter are used, the respective entry should be
    retained in gnus-group-charset-alist.


    Use Emacs built-in word-wrap instead of Gnus "treating"

    While using Emacs to contribute to Wikimedia projects, which
    typically format paragraphs in the source code as single lines
    of arbitrary length, I've learned to rely on Emacs word-wrap
    and wrap-prefix variables for presentation, and have since
    switched to using them in preference to whatever mode-specific
    "paragraph filling" there may be (including Gnus, Rcirc,
    jabber.el, but also XML documents I write.)

    ;;; gnus-art: Article mode commands for Gnus
    (setq gnus-treat-fill-long-lines nil
    gnus-article-treat-types nil
    gnus-article-mode-hook
    (list ; FIXME: a minor mode like this, perhaps?
    (lambda () (setq word-wrap t wrap-prefix " "))))


    Archive sent messages "as-is," without MIME-reencoding

    A problem with using Gnus "Gcc:" and "Fcc:" headers is that
    the message gets re-encoded before it's filed to a mailbox.
    That is: the message saved in the "sent" mailbox is not
    necessarily the same message, octet-wise, that was sent. I find
    that rather unfortunate when it comes to troubleshooting, and
    hence decided to reimplement the archival function.

    ;;; gnus-start: Startup functions for Gnus
    (setq gnus-message-archive-group nil)

    ;;; message: Major mode for editing mail and news to be sent
    (setq ;; NB: archive folders are overridden in host-cf/HOSTNAME.el
    message-send-mail-hook
    (list (lambda ()
    (my-gnus-archive-article "nnimap+okpyruAf:sent" t)))
    message-send-news-hook
    (list (lambda ()
    (my-gnus-archive-article "nnimap+okpyruAf:posted")))

    ;;; : Various functions & hooks
    (defun my-gnus-archive-article (group &optional undelimitp)
    "File the current buffer as an article to Gnus GROUP as-is.
    The buffer contents, subject to narrowing, is copied to a temporary one
    before doing anything.

    If UNDELIMITP is non-nil, call mail-sendmail-undelimit-header in the
    temporary buffer first."
    (unless (gnus-check-backend-function 'request-accept-article group)
    (error "Gnus group %s does not accept articles" group))
    (let ((from (current-buffer))
    (to (generate-new-buffer " *article to archive*")))
    (with-current-buffer to
    (insert-buffer-substring from)
    (when undelimitp
    (require 'sendmail)
    (mail-sendmail-undelimit-header))
    ;; .
    (unless (gnus-request-accept-article group nil t t)
    (error "Failed to archive in Gnus group %s" group)))))

    --
    FSF associate member #7257 http://am-1.org/~ivan/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)