[Mew-dist 07431] saving pick patterns and using them again later...
sen_ml at example.com
sen_ml at example.com
1999年 2月 14日 (日) 19:10:29 JST
hello,
is it possible to save pick patterns in mew and use them later (i.e.
later invocations of mew)? i couldn't figure this out from the
documentation. does anyone else think this would be a nice feature to
have?
attached is a sample implementation.
-------------- next part --------------
;; -*- emacs-lisp -*-
;;
;; name: mew-filter.el
;; version: 0.1
;; description: sample implementation for supporting the use of saved pick
;; patterns
;; creation date: 1999-02-11
;; author: "Sen Nagata" <sen at example.com>
;; warning: not optimized at all
;; required:
;;
;; -mew (tested for 1.93)
;; installation:
;;
;; -put this file in an appropriate directory (so emacs can find it)
;;
;; <necessary>
;; -put:
;;
;; (add-hook 'mew-init-hook (lambda () (require 'mew-filter)))
;;
;; in your .emacs file.
;;
;; -put a file named 'my-mew-filter-patterns.el' of an appropriate
;; format (see the 'details' section for details) somewhere in your
;; load-path.
;;
;; <optional>
;; -put:
;;
;; (add-hook
;; 'mew-summary-mode-hook
;; (lambda ()
;; (define-key mew-summary-mode-map
;; "\C-c/" 'mew-filter-using-saved-pattern)))
;;
;; in your .emacs.
;; details:
;;
;; this package provides an additional interface to the functionality
;; provided in mew-summary-search (by default bound to '/').
;;
;; i got tired of specifying the same pick patterns repeatedly, so i wrote
;; this little hack which allows me to specify saved patterns via aliases.
;;
;; the aliases are stored in a file called my-mew-filter-patterns.el. the
;; file contains a single setq statement(?) something like the following:
;;
;; (setq
;; mew-filter-saved-patterns
;; (list
;; '("bob" . "from=bob at example.com")
;; '("matilda" . "from=matilda")
;; '("archimedes" . "to=archimedes|cc=archimedes")
;; )
;; )
;;
;; a user invokes the command mew-filter-using-saved-pattern
;; (bound to "C-c /" by default) to use the aforementioned functionality.
;; usage:
;;
;; -invoke mew
;; -try out the command mew-filter-using-saved-pattern (C-c /)
;; notes and todo:
;;
;; -provide some way for the user to save new patterns and aliases w/o
;; editing my-mew-filter-patterns.el directly.
;; -figure out some way to record patterns which are specified when using
;; mew-summary-search and provide a way to name them later?
;; how should we handle the dependecy on mew?
;; doing the following seems to have catastrophic effects on my machine :-(
;(require 'mew)
;; will this work?
(eval-when-compile
(require 'mew))
(defconst mew-filter-version "mew-filter.el 0.1")
;; return a data structure which completing-read can use
(defun mew-filter-load-pattern-table ()
;; my-mew-filter-patterns.el setqs the variable mew-filter-saved-patterns
(load "my-mew-filter-patterns.el")
mew-filter-saved-patterns
;; the reason i did things this way was because i want to be able to
;; modify my list of saved patterns w/o having to restart mew or manually
;; re-evaluate mew-saved-picks -- there may be a better way.
)
;; key should be a key in alist, and alist should be a list
;; like mew-filter-saved-patterns
(defun mew-filter-lookup-pattern (key alist)
(cdr (assoc key alist))
)
;; heavily based on mew-summary-search
(defun mew-filter-using-saved-pattern ()
"Pick messages according to a saved pick pattern."
(interactive)
(mew-summary-only ; this is a macro
(let* ((folder (buffer-name)) ; buffer-name -> current folder
(pattern-table (mew-filter-load-pattern-table))
(pattern
(mew-filter-lookup-pattern
(completing-read "Saved filter pattern: " pattern-table)
pattern-table))
(range nil))
(if (null (file-directory-p (mew-expand-folder folder)))
(message "No such folder %s" folder)
(message "Picking messages in %s ..." folder)
(setq range (mew-summary-pick folder pattern))
(message "Picking messages in %s ... done" folder)
(if (get-buffer folder)
(switch-to-buffer folder)
(mew-symmary-folder-create folder))
(if range (mew-summary-scan-body mew-prog-imls
'mew-summary-mode
folder
mew-cs-scan
(list range 'erase)))))
)
)
;; since this will be used via 'require'...
(provide 'mew-filter)
-------------- next part --------------
;; this file stores 'pick' patterns and aliases for them
;; this is used by functions in mew-filter.el
(setq
mew-filter-saved-patterns
(list
;; yuck, lots of backslashes...
'("mew" . "subject=\\\\[Mew-dist")
'("pgp-users" . "to=pgp-users@|cc=pgp-users@")
)
)
Mew-dist メーリングリストの案内