Skip to content

Instantly share code, notes, and snippets.

@steinarb
Created October 3, 2021 10:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steinarb/4ed3a4b716aab22f855df9af387cce78 to your computer and use it in GitHub Desktop.
Save steinarb/4ed3a4b716aab22f855df9af387cce78 to your computer and use it in GitHub Desktop.
First 16241 bytes of .gnus.el chunk in gnus-cloud sync data written from gnus in emacs 26.3 on windows
; git gnus specific variables at the start. Remove when going production.
(require 'supercite)
; Workaround: need this line to make nndraft:drafts display the Drafts menu and the draft commands
(defvar gnus-dummy nil)
;=======================================================================
; A custom sort function, that puts new articles last
;
(defun steinar-sort-by-ticks (h1 h2)
(< (if (memq (mail-header-number (gnus-thread-header h1))
gnus-newsgroup-marked)
0 1)
(if (memq (mail-header-number (gnus-thread-header h2))
gnus-newsgroup-marked)
0 1)))
;=======================================================================
; "posting styles" setup
;
; First a convenient regexp to identify all hobby news and mail groups
; thanx to Erik Naggum
(defvar mc-newsgroups
(mapconcat #'identity
(list "^dod\..*"
"^no\\.alt\\.motorsykler"
"^nntp\\+nntp.dod.no:no.alt.motorsykler"
"^no\\.sport\\.motorsport"
"^no\\.annonser\\.motorsykkel"
"^alt\\.fan\\.ivan"
"^\\(nordunet.\\)?rec\\.motorcycles"
)
"\\|"))
(defvar mc-mailgroups
(mapconcat #'identity
(list "nnml:mail\\.dod.*"
"nnml:mail\\.utdrikk"
"nnml:hobby\\.dod.*"
"nnml:hobby\\.trip_report"
"nnml:mail\\.vfr"
"nnimap\\+privat:INBOX\\.dod*"
"nnimap\\+privat:INBOX\\.xfree86-newbie*"
"nnimap\\+privat:INBOX\\.debian-*"
)
"\\|"))
(defvar mc-groups
(mapconcat #'identity
(list mc-newsgroups
mc-mailgroups
)
"\\|"))
(defvar private-newsgroups
(mapconcat #'identity
(list "rec\\.aviation\\.military"
"alt\\.fan\\..*"
"no\\.film"
"no\\.news\\.diverse"
"no\\.teknologi\\.bil"
"NRK\\.generelt"
"rec\\.aviation\\.military"
)
"\\|"))
(defvar private-mailgroups
(mapconcat #'identity
(list "nnm[hl]:\\(\\(other\\)?folk\\|\\(hobby\\.[^d][^o][^d]\\)\\).*"
"nnml:mail\\.private"
"nnimap\\+privat:INBOX$"
"nnimap\\+privat:INBOX\\.[^d][^o][^d]*"
)
"\\|"))
(defvar private-groups
(mapconcat #'identity
(list private-newsgroups
private-mailgroups
)
"\\|"))
(defvar hobby-newsgroups
(mapconcat #'identity
(list mc-newsgroups
private-newsgroups
)
"\\|"))
(setq gnus-posting-styles
`((".*"
(name "Steinar Bang")
(address "sb@dod.no"))
(message-mail-p
(organization nil)
("BCC" "sb@cadalora.bang.priv.no"))
("^nnimap\\+privat:INBOX$"
(address "steinar@bang.priv.no"))
(message-news-p
(address "sb@dod.no")
(organization "Probably a good idea")
("Mail-Copies-To" "never")
("BCC" nil))
("nnimap\\+privat:hsilalpint-twitter"
(name "HSIL Alpint twitter")
(address "hsilalpint-twitter@bang.priv.no")
(organization nil)
("BCC" "sb@cadalora.bang.priv.no"))
("nnimap\\+privat:hsilalpint-wordpress"
(name "HSIL Alpint wordpress")
(address "hsilalpint-wordpress@bang.priv.no")
(organization nil)
("BCC" "sb@cadalora.bang.priv.no"))
("nnimap\\+privat:hsilalpint-fb"
(name "HSIL Alpint facebook")
(address "hsilalpint-fb@bang.priv.no")
(organization nil)
("BCC" "sb@cadalora.bang.priv.no"))
("nnimap\\+privat:gmail"
(address "steinarba@gmail.com")
(organization nil))
("nnml:mail.misc"
(address "steinarb@chello.no")
("BCC" "steinarb@chello.no"))
("nnimap\\+privat:\\(nisjerdverger\\|bristol\\|linux-hjelp\\|hsil-alpint-gruppe[45]\\)"
(address "sb@dod.no")
(signature "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n")
("BCC" nil))
("nnimap\\+fast"
(address "steinar.bang@fast.no")
(organization nil)
("BCC" "steinar.bang@fast.no"))
("nnimap\\+fast:INBOX/fast/0lists/ccr-"
("BCC" nil))
("nnimap\\+fast:INBOX/fast/0lists/mercury"
("BCC" nil))
("^nntp\\+news.gmane.io"
(address "sb@dod.no")
("BCC" nil))
(,mc-groups
(address "sb@dod.no"))
(,mc-newsgroups
("X-No-Archive" "yes")
(organization "Denizens of Doom, Norway Chapter"))
(,private-newsgroups
("X-No-Archive" "yes")
(organization "Anarchists Guild"))))
;; Server wide group parameter setting
(setq gnus-parameters '(("^nntp\\+news\\.gmane\\."
(spam-process
((spam spam-use-gmane))))
("^no\\."
(mm-coding-system-priorities
'(iso-8859-1)))))
(setq
rmail-default-dont-reply-to-names
"\\(sb@dod\\.no\\|steinar@bang\\.priv\\.no\\|steinar\\.bang@fast\\.no\\|steinarba@gmail\\.com\\)")
;; Message composition changes
(setq mml-insert-mime-headers-always t)
(setq nnmail-treat-duplicates 'warn ; or `delete'
nnmail-cache-accepted-message-ids t
nnmail-split-methods 'nnmail-split-fancy
nnmail-split-fancy
'(|
(from "bugzilla-daemon@\\(\\(rumple\\|anarjohka\\)\\.hq\\.\\)?troux\\.com" "troux.bugzilla")
(from "\\(\\w+\\)@\\(rumple\\|anarjohka\\)\\.hq\\.troux\\.com" "troux.cvs")
(to "metis\\.all@troux\\.com"
("subject" ".*CVS Update.*" "troux.cvs"))
(to "developmentOslo@troux\\.com" "troux.development.oslo")
(to "developmentAll@troux\\.com" "troux.development.all")
(to "TechnicalDL@troux\\.com" "troux.technical")
(to "\\(TrouxVollsveien\\|CTAllCTASCNACUKCAB\\|CX-ereoggjester\\)@computas\\.com\\|\\(metis.all\\|EuropeEmployees\\|EmployeesLysaker\\)@troux\\.com" "troux.norway")
(to "WorldwideEmployees@troux\\.com" "troux.worldwide")
(to "qt-interest@trolltech\\.com" "troux.qt.interest")
(any "steinar\\.bang@troux\\.com" "troux")
(any "sbang@troux\\.com" "troux")
(any "steinar\\.troux@gmail\\.com" "troux")
(any "steinarba@gmail\\.com" "gmail")
"mail.misc"
))
;; Handy spam reporting from Gnus
(require 'spam)
(require 'spam-report)
;; Enable the gnus-diary functions
(require 'gnus-diary)
;; We prefer good old latin1 over utf-8
(setq mm-coding-system-priorities '(iso-8859-1 utf-8))
;; Don't insert a signature by default
(setq message-signature nil)
;==========================
; Set up messages from Gnus
(add-hook 'message-setup-hook
(lambda ()
(setq message-cite-function 'sc-cite-original)
))
; Remove galloping RE: SV: when replying to a message
(setq message-subject-re-regexp
(concat
"^[ \t]*"
"\\("
"\\("
"[Aa][Nn][Tt][Ww]\\.?\\|" ; antw
"[Aa][Ww]\\|" ; aw
"[Ff][Ww][Dd]?\\|" ; fwd
"[Oo][Dd][Pp]\\|" ; odp
"[Rr][Ee]\\|" ; re
"[Rr][\311\351][Ff]\\.? ?\\|" ; ref
"[Ss][Vv]\\|" ; sv
"[Aa][Dd]" ; ad
"\\)"
"\\(\\[[0-9]*\\]\\)"
"*:[ \t]*"
"\\)"
"*[ \t]*"
))
; Make *m in *BBDB* create addresses suitable for message mode
(setq bbdb-send-mail-style 'message)
;;===========================
;; Setup of Gnus
;; Misc. settings
(setq gnus-message-archive-group nil)
(setq gnus-large-newsgroup 10000) ; I find the prompts obnoxious
(require 'nntp)
(setq nntp-connection-timeout 30) ;; 30s wait for nntp
;; Poster identity
(setq gnus-local-domain "bang.priv.no")
(setq gnus-use-generic-from t)
; Don't expire on group exit
(remove-hook
'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
;; Automatically fetch news and mail every 15 minutes when idle
(defun sb-gnus-demon-scan-imap ()
(let ((win (current-window-configuration)))
(unwind-protect
(save-window-excursion
(save-excursion
(when (gnus-alive-p)
(save-excursion
(set-buffer gnus-group-buffer)
(gnus-group-get-new-news 2)))))
(set-window-configuration win))))
(gnus-demon-add-handler 'sb-gnus-demon-scan-imap 15 t)
(gnus-demon-add-rescan)
(setq gnus-select-method
'(nntp "news"
(nntp-address "nntp.dod.no")
))
; Do not prompt before synchronizing agentized servers
(setq gnus-agent-synchronize-flags t)
; Access cygwin openssl directly, if available
(if windows-emacs
(let ((cygwin-openssl "C:/cygwin/bin/openssl.exe"))
(if (file-exists-p cygwin-openssl)
(progn
(require 'imap) ; Need this to define the imap-ssl-program variable
(setq imap-ssl-program
(mapcar '(lambda (element)
(let ((newelement element))
(if (string-match "openssl " element) ; NOTE the trailing space in the match avoid repeated replacement of the "openssl" on each Gnus startup
(setq newelement (replace-match (concat cygwin-openssl " ") t t element))
newelement)))
imap-ssl-program))))))
(setq gnus-secondary-select-methods
'((nnimap "privat"
(nnimap-address "imap.bang.priv.no")
(nnimap-authenticator cram-md5)
(nnimap-server-port 993)
(nnimap-stream ssl))
; Local DavMail, talking to an exchange server
;; (nnimap "work"
;; (nnimap-address "localhost")
;; (nnimap-server-port 1143))
(nntp "news.gmane.io")
(nndiary "")
))
;; General settings
;;=====================================================
(setq gnus-use-long-file-name t)
(setq gnus-uncacheable-groups "^nnml")
(setq gnus-permanently-visible-groups "^\\(\\(nnml\\|nnrss\\):\\|nnimap\\).*")
(setq nnimap-quirks nil)
;; Synching reads in nntp groups across machines
(setq gnus-sync-backend "/-:sb@lesync.bang.priv.no:sync/gnus")
(setq gnus-sync-global-vars '(gnus-newsrc-last-checked-date)
gnus-sync-newsrc-groups '("nntp" "nnrss")
gnus-sync-newsrc-offsets '(2 3))
;; speed settings
;;=====================================================
(setq gnus-read-active-file 'some)
;; How messages are displayed
;;=====================================================
(defun un-stupify-article ()
(interactive)
(save-excursion
(set-buffer gnus-article-buffer)
(toggle-read-only)
(message-narrow-to-head)
(goto-char (point-max))
(widen)
(let ((here (point))
(un-stup-author)
(nlines)
(counter)
(org-message-regexp "--+ ?Original Message ?--+")
)
(if (re-search-forward org-message-regexp)
(progn
;; first really quote quoted bits
(save-excursion
(re-search-forward "^Subject:")
(forward-line)
(delete-blank-lines)
(save-excursion
(let ((ici (point)))
(goto-char (point-max))
(setq nlines (count-lines ici (point)))))
(setq counter 1)
(while (< counter nlines)
(beginning-of-line)
(insert "> ")
(forward-line)
(setq counter (+ counter 1))))
(beginning-of-line)
(kill-region here (point))
(widen)
(goto-char (point-max))
(yank)
(goto-char (point-min))
(re-search-forward org-message-regexp)
(beginning-of-line)
(let ((kill-whole-line t))
(kill-line)
)
(re-search-forward "From: ")
(let ((ici (point)))
(re-search-forward "@")
(narrow-to-region ici (point))
(setq un-stup-author (current-word))
(widen))
(beginning-of-line)(kill-line)
(insert (concat "\n" un-stup-author " wrote:"))
(forward-line)
(let ((ici (point)))
(re-search-forward "^Subj")
(end-of-line)
(kill-region ici (point)))
)))
(toggle-read-only)))
(add-hook 'gnus-article-display-hook 'gnus-article-hide-pgp
'gnus-article-hide-signature)
(setq gnus-default-article-saver 'gnus-summary-save-in-folder)
(setq gnus-novice-user nil)
(setq gnus-boring-article-headers
'(long-to many-to))
(setq gnus-treat-display-smileys nil)
; I do *not* want to see HTML
(setq mm-discouraged-alternatives '("text/html" "text/richtext"))
;(setq mm-automatic-display (remove "text/html" mm-automatic-display))
(setq mm-inline-large-images t)
(setq gnus-mime-display-multipart-related-as-mixed t)
;; Store article in agent when reading it while online
(add-hook 'gnus-select-article-hook 'gnus-agent-fetch-selected-article)
;; Arnt's SCORE modifications
(setq gnus-thread-sort-functions
'(gnus-thread-sort-by-number gnus-thread-sort-by-total-score))
(setq gnus-score-find-score-files-function
'gnus-score-find-hierarchical)
(setq gnus-thread-score-function 'max)
(setq gnus-use-scoring t)
(setq gnus-use-adaptive-scoring nil)
(setq gnus-decay-scores t)
(defun gnus-set-score-limit ()
"Set the limit of when scored down articles are no longer displayed"
(setq gnus-summary-expunge-below -1500))
(add-hook 'gnus-summary-mode-hook 'gnus-set-score-limit)
;; Add score on followups to kill subthreads
(defvar gnus-default-adaptive-score-alist
'((gnus-unread-mark)
(gnus-ticked-mark (from 4))
(gnus-dormant-mark (from 5))
(gnus-del-mark (from -4) (subject -1) (followup -10))
(gnus-read-mark (from 4) (subject 2))
(gnus-expirable-mark (from -1) (subject -1))
(gnus-killed-mark (from -1) (subject -3))
(gnus-kill-file-mark)
(gnus-ancient-mark)
(gnus-low-score-mark (from -3) (followup -1000))
(gnus-catchup-mark (from -1) (subject -1) (followup -10))))
(add-hook 'gnus-group-mode-hook 'gnus-topic-mode)
;; Hook in Gnus 5 additions to the Insidious Big Brother Database
;; to coerce the real names in the Summary buffer
; (gnus-bbdb-insinuate-summary-buffer)
(defun message-send-and-exit-with-prefix ()
"Call the message-send-and-exit function with a positive number argument
to make it post the message on the foreign NNTP server of a group, instead
of the default NNTP server"
(interactive)
(message-send-and-exit 1))
;; Do not use "-f" with sendmail, because this results in
;; an X-Authentication-Warning: header
(setq message-sendmail-f-is-evil t)
;; Avoid setting the sender header, and by this use the From: address
;; as the envelope address
(add-to-list 'message-syntax-checks '(sender . disabled))
;; Sieve mail filtering settings
(setq gnus-sieve-crosspost nil) ; no crossposting in generated sieve rules
(setq message-send-mail-function 'smtpmail-send-it
smtpmail-smtp-server "mail.bang.priv.no"
smtpmail-smtp-service 119
smtpmail-auth-credentials '(("mail.bang.priv.no" 119 "myu8gwp" "l8ua5mbgAn"))
smtpmail-starttls-credentials '(("" 25 nil nil))) ;; Neccessary to nil out the key and certificate rather than having them as empty strings
;; Automate updating the read counts on nnimap groups (can have articles read in other
;; gnusen) and on gmane (lose spam marked articles).
(defun sb-list-all-groups-of-a-server (server-regexp)
(let ((server-groups ()))
(set-buffer gnus-group-buffer)
(gnus-topic-mode nil t)
(goto-char (point-min))
(while (re-search-forward server-regexp nil t)
(let ((current-group (gnus-group-group-name)))
(setq server-groups (append (list current-group) server-groups))))
(gnus-topic-mode nil t)
server-groups))
(defun sb-visit-group-to-update-read-count (group-name)
(gnus-group-read-group nil t group-name)
(gnus-summary-exit))
(defun sb-visit-all-groups-of-a-server (server-regexp)
(let ((server-groups (sb-list-all-groups-of-a-server server-regexp)))
(mapc
'sb-visit-group-to-update-read-count
server-groups)))
(defun sb-visit-gmane ()
(interactive)
(sb-visit-all-groups-of-a-server "nntp\\+news\\.gmane\\.org:"))
(defun sb-visit-privat ()
(interactive)
(sb-visit-all-groups-of-a-server "nnimap\\+privat:"))
(:type :file :file-name "~/News/all.SCORE" :timestamp "2020-04-04T09:00:10+0200" :length 59)
(("from"
("Steinar Bang" nil nil s))
(decay 737519))
(:type :file :file-name "~/News/nndoc_SCORE" :timestamp "2015-02-10T01:14:36+0100" :length 18)
((decay 735639))
(:type :file :file-name "~/News/nndoc_nnimap+privat_dod-27817.SCORE" :timestamp "2019-06-04T16:41:46+0200" :length 18)
((decay 737214))
(:type :file :file-name "~/News/nndraft_SCORE" :timestamp "2014-12-31T12:00:28+0100" :
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment