help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gnus] How to show mails from an specific mailing list?


From: Filipp Gunbin
Subject: Re: [gnus] How to show mails from an specific mailing list?
Date: Tue, 22 Jun 2021 16:30:17 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (darwin)

On 22/06/2021 00:57 -0500, Rodrigo Morales wrote:

> I sometimes want to read mails from an specific mailing list. However,
> since I'm on multiple mailing lists, the Summary buffer show messages
> from all mailing lists. My question is: Is there any way to make Gnus
> show messages from a given mailing list?

I use client splitting and a mapping file, like this.

File contains lines like:

ml.auctex auctex@gnu.org
ml.auctex-devel auctex-devel@gnu.org
ml.bash-announce bash-announce@gnu.org
ml.bash-bug bug-bash@gnu.org

Then in .gnus.el I do:

(let ((mail-lists (fg-dotemacs-read-group-to-email
                   "~/file.txt")))
  (setq nnmail-split-methods
        (nconc
         ;; <any rules before...>
         ;;
         ;; mail list to group:
         (mapcar (lambda (list)
                   (list (car list)
                         (concat "\\(From\\|To\\):.*\\<" (cadr list) "\\>")))
                 mail-lists)
         ;;
         ;; <any rules after...>
         )))

Supporting functions:

(defun fg-dotemacs-read-group-to-email (file)
  "Read mappings from FILE and return list of entries (GROUP-NAME
EMAIL).  Each line should be like: 'ml.my-list
my-list@example.org', email is treated as literal and
regexp-quoted."
  (mapcar (lambda (list)
            (if (= (length list) 2)
                (list (car list) (regexp-quote (cadr list)))
              (error "Invalid line: %S" list)))
          (mapcar #'split-string
                  (fg-dotemacs-read-lines file))))

(defun fg-dotemacs-read-lines (file)
  "Returns all non-blank lines of FILE as a list of strings.
Leading and trailing whitespace is trimmed off.  If the first
non-whitespace character on a line is '#' then the line is
treated as comment and skipped."
  (let (res)
    (with-temp-buffer
      (insert-file-contents (expand-file-name file))
      (while (not (eobp))
        (beginning-of-line)
        (unless (looking-at "[ \t]*$\\|[ \t]*#")
          (push (string-trim
                 (buffer-substring (point) (line-end-position)))
                res))
        (forward-line)))
    (nreverse res)))

There's also "fancy splitting", you can read about it in (info "(gnus)
Fancy Mail Splitting"), I haven't checked it yet.

Filipp



reply via email to

[Prev in Thread] Current Thread [Next in Thread]