[Mew-dist 10094] mew-dups.el: marking duplicate messages in a folder
sen at example.com
sen at example.com
1999年 8月 16日 (月) 16:46:37 JST
folder 内の重複したメッセージを mark するコードを書いてみました。
imls の機能をそのまま使用させていただきました。 thank you img at example.com!
インストール方法は mew-dups.el を load-path 上におき、.emacs に
(add-hook 'mew-init-hook (lambda () (require 'mew-dups)))
と記述するだけです。
`mew-summary-mark-dups' というコマンドを提供してくれます。
ちょっとしかテストしてませんが、いまのところ使えています。
-------------- next part --------------
;;; mew-dups.el --- mark duplicates in a folder
;;; Written by: Sen Nagata <sen at example.com>
;;; Important Note: most of the functions in here are based on code in
;;; mew-picks.el which was not written by me
;; Keywords: duplicates, mew, imls
;; Version: 0.1
;;; Commentary:
;;
;; installation:
;;
;; -put this file in an appropriate directory so emacs can find it
;;
;; -put:
;;
;; (add-hook 'mew-init-hook (lambda () (require 'mew-dups)))
;;
;; in .emacs (or wherever you place your mew settings)
;;
;; usage:
;;
;; -invoke mew
;; -use the command `mew-summary-mark-dups' to mark duplicates in a
;; given folder in summary mode
;;; History:
;;
;; 0.1:
;;
;; initial implementation
;;; Code:
(defconst mew-dups-version "mew-dups.el 0.1")
;; based heavily on `mew-summary-search-mark'
(defun mew-summary-mark-dups (&optional arg)
"Pick duplicate messages."
(interactive "P")
(mew-summary-only
(if arg
(mew-summary-mark-dups-region (region-beginning) (region-end))
(mew-summary-mark-dups-region (point-min) (point-max)))))
;; based heavily on `mew-summary-search-mark-region'
;; there are basically two major changes:
;;
;; 1) no pattern
;; 2) call mew-summary-pick-dups instead of mew-summary-pick
;;
(defun mew-summary-mark-dups-region (r1 r2)
(interactive "r")
(if (equal (point-min) (point-max))
(message "No messages in this buffer.")
(let ((folder (buffer-name))
first last range)
(message "Picking messages in %s ..." folder)
(goto-char r1)
(if (eobp)
() ;; r1 <= r2, so if r1 = (point-max) then no message.
(setq first (mew-summary-message-number))
(goto-char r2)
(if (eobp)
(progn
(forward-line -1)
(setq r2 (point))))
(setq last (mew-summary-message-number))
;; this is the major change
(setq range (mew-summary-pick-dups folder (concat first "-" last))))
(message "Picking messages in %s ... done" folder)
(if (null range)
(message "No message to be marked.")
(message "Marking messages ... ")
(goto-char r1)
(while (and range (< (point) r2))
(if (re-search-forward (format "^[ ]*%s[^0-9]" (car range)) nil t)
(if (not (mew-summary-marked-p))
(mew-summary-mark-as mew-mark-review)))
(setq range (cdr range)))
(beginning-of-line)
(set-buffer-modified-p nil)
(message "Marking messages ... done")))))
;; based heavily on `mew-summary-pick'
(defun mew-summary-pick-dups (folder &optional range)
(let (msgs)
(setq range (or range "all"))
(save-excursion
(mew-set-buffer-tmp)
(mew-im-call-process nil mew-prog-imls
(format "--src=%s" folder)
"--form=%n %D"
range)
;; imls doesn't fail?
;; two sections removed that were in mew-summary-picks
(goto-char (point-min))
(while (not (eobp))
;; why are there spaces after the 'D'?
(if (looking-at "^\\([0-9]+\\) D.*$")
(setq msgs (cons (mew-match 1) msgs)))
(forward-line))
(nreverse msgs))))
(provide 'mew-dups)
;;; mew-dups.el ends here
Mew-dist メーリングリストの案内