Переместить существующие статьи в другую группу в Gnus

604
Mirzhan Irkegulov

Я настроил nnmail-split-methodsотделение почты от моего списка рассылки от всего остального:

(setq nnmail-split-methods '(("vladimir.lenin" "From:.*vladimir\.lenin") ("mail.misc" ""))) 

Новая почта теперь будет отображаться в vladimir.leninгруппе, но уже существующие будут оставаться в mail.misc. Как быстро переместить все статьи, соответствующие регулярному выражению, из одной группы в другую?

1

1 ответ на вопрос

1
Mirzhan Irkegulov

This is my probably excess and sub-optimal solution, as i couldn't find the idiomatic way. Default keybindings for every command are given in parentheses.

First of all, set the variable gnus-move-split-methods similar to your nnmail-split-methods variable. Notice that the syntax in the 1st variable is ("^From:.*eliezer" "mail.hpmor"), while in the 2nd variable is ("mail.hpmor" "^From:.*eliezer"). For example, my gnus-move-split-methods is:

(setq gnus-move-split-methods '(("^Sender:.*abbie.*" "mail.abbie") ("" "mail.misc"))) 

Open the group and make it show all articles. Call gnus-summary-limit-to-headers (/ h) and specify regex (in my example "Sender:.*abbie") to show only articles you want to move.

Use keyboard macros to facilitate moving, start macro by kmacro-start-macro (C-x (), then move your first article with gnus-summary-move-article B m, then repeat the macro by kmacro-end-and-call-macro (C-x e) and specify the number of repetitions with a universal argument (C-u).

If you don't know how many times you should repeat the macro, you can count the number of articles left by selecting all (mark-whole-buffer) and counting with count-words-region. Don't use 0 as a universal article, as for some reason it won't finish. Remember, as mails are moved physically from one folder to another, the whole operation might take time depending on how many mail you have.

If you use nnml as a mail backend, run gnus-group-compact-group (G z) on your group, so that Gnus gives you the correct article count. This also may take time depending on the amount of mail.

Notes:

  • As you see, because you set gnus-move-split-methods, when you move the article, the default group proposed in the prompt is correct.
  • gnus-summary-toggle-header (t) is helpful to find which header you need to filter with.
  • Sometimes there is no Sender: header, so I use Cc:.*abbie regexp too. You might see that headers are frequently inconsistent, so be careful.

Похожие вопросы