diff lisp/mh-e/mh-pick.el @ 89966:d8411455de48

Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-32 Merge from emacs--cvs-trunk--0 Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-486 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-487 Tweak permissions * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-488 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-489 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-490 Update from CVS: man/fixit.texi (Spelling): Fix typo. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-491 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-494 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-495 Update from CVS: Add missing lisp/mh-e files * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-496 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-499 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-500 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-513 Update from CVS
author Miles Bader <miles@gnu.org>
date Fri, 27 Aug 2004 07:00:34 +0000
parents 68c22ea6027c e9a6cbc8ca5e
children f042e7c0fe20
line wrap: on
line diff
--- a/lisp/mh-e/mh-pick.el	Wed Aug 18 06:38:14 2004 +0000
+++ b/lisp/mh-e/mh-pick.el	Fri Aug 27 07:00:34 2004 +0000
@@ -1,6 +1,6 @@
 ;;; mh-pick.el --- make a search pattern and search for a message in MH-E
 
-;; Copyright (C) 1993, 1995, 2001, 2003 Free Software Foundation, Inc.
+;; Copyright (C) 1993, 1995, 2001, 2003, 2004 Free Software Foundation, Inc.
 
 ;; Author: Bill Wohler <wohler@newt.com>
 ;; Maintainer: Bill Wohler <wohler@newt.com>
@@ -32,6 +32,8 @@
 
 ;;; Code:
 
+(eval-when-compile (require 'mh-acros))
+(mh-require-cl)
 (require 'mh-e)
 (require 'easymenu)
 (require 'gnus-util)
@@ -44,6 +46,9 @@
 (defvar mh-searching-folder nil)        ;Folder this pick is searching.
 (defvar mh-searching-function nil)
 
+(defconst mh-pick-single-dash  '(cc date from subject to)
+  "Search components that are supported by single-dash option in pick.")
+
 ;;;###mh-autoload
 (defun mh-search-folder (folder window-config)
   "Search FOLDER for messages matching a pattern.
@@ -139,16 +144,6 @@
   (run-hooks 'mh-pick-mode-hook))
 
 ;;;###mh-autoload
-(defun mh-do-pick-search ()
-  "Find messages that match the qualifications in the current pattern buffer.
-Messages are searched for in the folder named in `mh-searching-folder'.
-Add the messages found to the sequence named `search'.
-
-This is a deprecated function and `mh-pick-do-search' should be used instead."
-  (interactive)
-  (mh-pick-do-search))
-
-;;;###mh-autoload
 (defun mh-pick-do-search ()
   "Find messages that match the qualifications in the current pattern buffer.
 Messages are searched for in the folder named in `mh-searching-folder'.
@@ -260,6 +255,13 @@
            "-rbrace"))
         (t (error "Unknown operator '%s' seen" (car expr)))))
 
+;; All implementations of pick have special options -cc, -date, -from and
+;; -subject that allow to search for corresponding components. Any other
+;; component is searched using option --COMPNAME, for example: `pick
+;; --x-mailer mh-e'. Mailutils `pick' supports this option using a certain
+;; kludge, but it prefers the following syntax for this purpose:
+;; `--component=COMPNAME --pattern=PATTERN'.
+;;                                           -- Sergey Poznyakoff, Aug 2003
 (defun mh-pick-regexp-builder (pattern-list)
   "Generate pick search expression from PATTERN-LIST."
   (let ((result ()))
@@ -267,9 +269,18 @@
       (when (cdr pattern)
         (setq result `(,@result "-and" "-lbrace"
                        ,@(mh-pick-construct-regexp
-                          (cdr pattern) (if (car pattern)
-                                            (format "-%s" (car pattern))
-                                          "-search"))
+                          (if (and (mh-variant-p 'mu-mh) (car pattern))
+                              (format "--pattern=%s" (cdr pattern))
+                            (cdr pattern))
+                          (if (car pattern)
+                              (cond
+                               ((mh-variant-p 'mu-mh)
+                                (format "--component=%s" (car pattern)))
+                               ((member (car pattern) mh-pick-single-dash)
+                                (format "-%s" (car pattern)))
+                               (t
+                                (format "--%s" (car pattern))))
+                            "-search"))
                        "-rbrace"))))
     (cdr result)))