* elmo-imap4.el (elmo-imap4-clear-login): Don't send LOGIN command
[elisp/wanderlust.git] / wl / wl-util.el
1 ;;; wl-util.el --- Utility modules for Wanderlust.
2
3 ;; Copyright (C) 1998,1999,2000 Yuuichi Teranishi <teranisi@gohome.org>
4 ;; Copyright (C) 2000 A. SAGATA <sagata@nttvdt.hil.ntt.co.jp>
5 ;; Copyright (C) 2000 Katsumi Yamaoka <yamaoka@jpl.org>
6
7 ;; Author: Yuuichi Teranishi <teranisi@gohome.org>
8 ;;      A. SAGATA <sagata@nttvdt.hil.ntt.co.jp>
9 ;;      Katsumi Yamaoka <yamaoka@jpl.org>
10 ;; Keywords: mail, net news
11
12 ;; This file is part of Wanderlust (Yet Another Message Interface on Emacsen).
13
14 ;; This program is free software; you can redistribute it and/or modify
15 ;; it under the terms of the GNU General Public License as published by
16 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; any later version.
18 ;;
19 ;; This program is distributed in the hope that it will be useful,
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22 ;; GNU General Public License for more details.
23 ;;
24 ;; You should have received a copy of the GNU General Public License
25 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
26 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
27 ;; Boston, MA 02111-1307, USA.
28 ;;
29
30 ;;; Commentary:
31 ;;
32
33 ;;; Code:
34 ;;
35 (require 'bytecomp)
36 (require 'elmo-util)
37 (require 'elmo-flag)
38
39 (condition-case nil (require 'pp) (error nil))
40
41 (eval-when-compile
42   (require 'time-stamp)
43   (defalias-maybe 'next-command-event 'ignore)
44   (defalias-maybe 'event-to-character 'ignore)
45   (defalias-maybe 'key-press-event-p 'ignore)
46   (defalias-maybe 'button-press-event-p 'ignore)
47   (defalias-maybe 'set-process-kanji-code 'ignore)
48   (defalias-maybe 'set-process-coding-system 'ignore)
49   (defalias-maybe 'dispatch-event 'ignore))
50
51 (defalias 'wl-set-work-buf 'elmo-set-work-buf)
52 (make-obsolete 'wl-set-work-buf 'elmo-set-work-buf)
53
54 (defmacro wl-append (val func)
55   (list 'if val
56       (list 'nconc val func)
57     (list 'setq val func)))
58
59 (defalias 'wl-parse 'elmo-parse)
60 (make-obsolete 'wl-parse 'elmo-parse)
61
62 (defun wl-delete-duplicates (list &optional all hack-addresses)
63   "Delete duplicate equivalent strings from the LIST.
64 If ALL is t, then if there is more than one occurrence of a string in the LIST,
65  then all occurrences of it are removed instead of just the subsequent ones.
66 If HACK-ADDRESSES is t, then the strings are considered to be mail addresses,
67  and only the address part is compared (so that \"Name <foo>\" and \"foo\"
68  would be considered to be equivalent.)"
69   (let ((hashtable (make-vector 29 0))
70         (new-list nil)
71         sym-string sym)
72     (fillarray hashtable 0)
73     (while list
74       (setq sym-string
75             (if hack-addresses
76                 (wl-address-header-extract-address (car list))
77               (car list))
78             sym-string (or sym-string "-unparseable-garbage-")
79             sym (intern sym-string hashtable))
80       (if (boundp sym)
81           (and all (setcar (symbol-value sym) nil))
82         (setq new-list (cons (car list) new-list))
83         (set sym new-list))
84       (setq list (cdr list)))
85     (delq nil (nreverse new-list))))
86
87 ;; string utils.
88 (defalias 'wl-string-member 'elmo-string-member)
89 (defalias 'wl-string-match-member 'elmo-string-match-member)
90 (defalias 'wl-string-delete-match 'elmo-string-delete-match)
91 (defalias 'wl-string-match-assoc 'elmo-string-match-assoc)
92 (defalias 'wl-string-assoc 'elmo-string-assoc)
93 (defalias 'wl-string-rassoc 'elmo-string-rassoc)
94
95 (defalias 'wl-parse-addresses 'elmo-parse-addresses)
96
97 (defun wl-append-element (list element)
98   (if element
99       (append list (list element))
100     list))
101
102 (defmacro wl-push (v l)
103   "Insert V at the head of the list stored in L."
104   (list 'setq l (list 'cons v l)))
105
106 (defmacro wl-pop (l)
107   "Remove the head of the list stored in L."
108   (list 'car (list 'prog1 l (list 'setq l (list 'cdr l)))))
109
110 (defun wl-ask-folder (func mes-string)
111   (let* (key keve
112              (cmd (if (featurep 'xemacs)
113                       (event-to-character last-command-event)
114                     (string-to-char (format "%s" (this-command-keys))))))
115     (message "%s" mes-string)
116     (setq key (car (setq keve (wl-read-event-char))))
117     (if (or (equal key ?\ )
118             (and cmd
119                  (equal key cmd)))
120         (progn
121           (message "")
122           (funcall func))
123       (wl-push (cdr keve) unread-command-events))))
124
125 (defun wl-require-update-all-folder-p (name)
126   "Return non-nil if NAME is draft or queue folder."
127   (or (string= name wl-draft-folder)
128       (string= name wl-queue-folder)))
129
130 ;(defalias 'wl-make-hash 'elmo-make-hash)
131 ;;(make-obsolete 'wl-make-hash 'elmo-make-hash)
132
133 ;;(defalias 'wl-get-hash-val 'elmo-get-hash-val)
134 ;;(make-obsolete 'wl-get-hash-val 'elmo-get-hash-val)
135
136 ;;(defalias 'wl-set-hash-val 'elmo-set-hash-val)
137 ;;(make-obsolete 'wl-set-hash-val 'elmo-set-hash-val)
138
139 (defsubst wl-set-string-width (width string &optional padding ignore-invalid)
140   "Make a new string which have specified WIDTH and content of STRING.
141 `wl-invalid-character-message' is used when invalid character is contained.
142 If WIDTH is negative number, padding chars are added to the head and
143 otherwise, padding chars are added to the tail of the string.
144 The optional 3rd arg PADDING, if non-nil, specifies a padding character
145 to add the result instead of white space.
146 If optional 4th argument is non-nil, don't use `wl-invalid-character-message'
147 even when invalid character is contained."
148   (static-cond
149    ((and (fboundp 'string-width) (fboundp 'truncate-string-to-width)
150          (not (featurep 'xemacs)))
151     (if (> (string-width string) (abs width))
152         (setq string (truncate-string-to-width string (abs width))))
153     (if (= (string-width string) (abs width))
154         string
155       (when (and (not ignore-invalid)
156                  (< (abs width) (string-width string)))
157         (setq string
158               (truncate-string-to-width wl-invalid-character-message
159                                         (abs width))))
160       (let ((paddings (make-string
161                        (max 0 (- (abs width) (string-width string)))
162                        (or padding ?\ ))))
163         (if (< width 0)
164             (concat paddings string)
165           (concat string paddings)))))
166    (t
167     (elmo-set-work-buf
168      (set-buffer-multibyte default-enable-multibyte-characters)
169      (insert string)
170      (when (> (current-column) (abs width))
171        (when (> (move-to-column (abs width)) (abs width))
172          (condition-case nil ; ignore error
173              (backward-char 1)
174            (error)))
175        (setq string (buffer-substring (point-min) (point))))
176      (if (= (current-column) (abs width))
177          string
178        (let ((paddings (make-string (- (abs width) (current-column))
179                                     (or padding ?\ ))))
180          (if (< width 0)
181              (concat paddings string)
182            (concat string paddings))))))))
183
184 (defun wl-mode-line-buffer-identification (&optional id)
185   (let ((priorities '(biff plug title)))
186     (let ((items (reverse wl-mode-line-display-priority-list))
187           item)
188       (while items
189         (setq item (car items)
190               items (cdr items))
191         (unless (memq item '(biff plug))
192           (setq item 'title))
193         (setq priorities (cons item (delq item priorities)))))
194     (let (priority result)
195       (while priorities
196         (setq priority (car priorities)
197               priorities (cdr priorities))
198         (cond
199          ((eq 'biff priority)
200           (when wl-biff-check-folder-list
201             (setq result (append result '((wl-modeline-biff-status
202                                            wl-modeline-biff-state-on
203                                            wl-modeline-biff-state-off))))))
204          ((eq 'plug priority)
205           (when wl-show-plug-status-on-modeline
206             (setq result (append result '((wl-modeline-plug-status
207                                            wl-modeline-plug-state-on
208                                            wl-modeline-plug-state-off))))))
209          (t
210           (setq result (append result (or id '("Wanderlust: %12b")))))))
211       (prog1
212           (setq mode-line-buffer-identification (if (stringp (car result))
213                                                     result
214                                                   (cons "" result)))
215         (force-mode-line-update t)))))
216
217 (defalias 'wl-display-error 'elmo-display-error)
218 (make-obsolete 'wl-display-error 'elmo-display-error)
219
220 (defun wl-get-assoc-list-value (assoc-list folder &optional match)
221   (catch 'found
222     (let ((alist assoc-list)
223           value pair)
224       (while alist
225         (setq pair (car alist))
226         (if (and (eq match 'function)
227                  (functionp (car pair)))
228             (when (funcall (car pair) folder)
229               (throw 'found (cdr pair)))
230           (if (string-match (car pair) folder)
231               (cond ((eq match 'all)
232                      (setq value (append value (list (cdr pair)))))
233                     ((eq match 'all-list)
234                      (setq value (append value (cdr pair))))
235                     ((or (not match) (eq match 'function))
236                      (throw 'found (cdr pair))))))
237         (setq alist (cdr alist)))
238       value)))
239
240 (defmacro wl-match-string (pos string)
241   "Substring POSth matched STRING."
242   (` (substring (, string) (match-beginning (, pos)) (match-end (, pos)))))
243
244 (defmacro wl-match-buffer (pos)
245   "Substring POSth matched from the current buffer."
246   (` (buffer-substring-no-properties
247       (match-beginning (, pos)) (match-end (, pos)))))
248
249 (put 'wl-as-coding-system 'lisp-indent-function 1)
250 (put 'wl-as-mime-charset 'lisp-indent-function 1)
251
252 (eval-and-compile
253   (cond
254    (wl-on-mule3
255     (defmacro wl-as-coding-system (coding-system &rest body)
256       (` (let ((coding-system-for-read (, coding-system))
257                (coding-system-for-write (, coding-system)))
258            (,@ body)))))
259    (wl-on-mule
260     (defmacro wl-as-coding-system (coding-system &rest body)
261       (` (let ((file-coding-system-for-read (, coding-system))
262                (file-coding-system (, coding-system)))
263            (,@ body)))))
264    (t
265     (defmacro wl-as-coding-system (coding-system &rest body)
266       (` (progn (,@ body)))))))
267
268 (defmacro wl-as-mime-charset (mime-charset &rest body)
269   (` (wl-as-coding-system (mime-charset-to-coding-system (, mime-charset))
270        (,@ body))))
271
272 (defalias 'wl-string 'elmo-string)
273 (make-obsolete 'wl-string 'elmo-string)
274
275 (if (not (fboundp 'overlays-in))
276     (defun overlays-in (beg end)
277       "Return a list of the overlays that overlap the region BEG ... END.
278 Overlap means that at least one character is contained within the overlay
279 and also contained within the specified region.
280 Empty overlays are included in the result if they are located at BEG
281 or between BEG and END."
282       (let ((ovls (overlay-lists))
283             tmp retval)
284         (if (< end beg)
285             (setq tmp end
286                   end beg
287                   beg tmp))
288         (setq ovls (nconc (car ovls) (cdr ovls)))
289         (while ovls
290           (setq tmp (car ovls)
291                 ovls (cdr ovls))
292           (if (or (and (<= (overlay-start tmp) end)
293                        (>= (overlay-start tmp) beg))
294                   (and (<= (overlay-end tmp) end)
295                        (>= (overlay-end tmp) beg)))
296               (setq retval (cons tmp retval))))
297         retval)))
298
299 (defsubst wl-repeat-string (str times)
300   (let ((loop times)
301         ret-val)
302     (while (> loop 0)
303       (setq ret-val (concat ret-val str))
304       (setq loop (- loop 1)))
305     ret-val))
306
307 (defun wl-append-assoc-list (item value alist)
308   "make assoc list '((item1 value1-1 value1-2 ...)) (item2 value2-1 ...)))"
309   (let ((entry (assoc item alist)))
310     (if entry
311         (progn
312           (when (not (member value (cdr entry)))
313             (nconc entry (list value)))
314           alist)
315       (append alist
316               (list (list item value))))))
317
318 (defun wl-delete-alist (key alist)
319   "Delete by side effect any entries specified with KEY from ALIST.
320 Return the modified ALIST.  Key comparison is done with `assq'.
321 Write `(setq foo (wl-delete-alist key foo))' to be sure of changing
322 the value of `foo'."
323   (let (entry)
324     (while (setq entry (assq key alist))
325       (setq alist (delq entry alist)))
326     alist))
327
328 (defun wl-delete-associations (keys alist)
329   "Delete by side effect any entries specified with KEYS from ALIST.
330 Return the modified ALIST.  KEYS must be a list of keys for ALIST.
331 Deletion is done with `wl-delete-alist'.
332 Write `(setq foo (wl-delete-associations keys foo))' to be sure of
333 changing the value of `foo'."
334   (while keys
335     (setq alist (wl-delete-alist (car keys) alist))
336     (setq keys (cdr keys)))
337   alist)
338
339 (defun wl-filter-associations (keys alist)
340   (let (entry result)
341     (while keys
342       (when (setq entry (assq (car keys) alist))
343         (setq result (cons entry result)))
344       (setq keys (cdr keys)))
345     result))
346
347 (defun wl-inverse-alist (keys alist)
348   "Inverse ALIST, copying.
349 Return an association list represents the inverse mapping of ALIST,
350 from objects to KEYS.
351 The objects mapped (cdrs of elements of the ALIST) are shared."
352   (let (x y tmp result)
353     (while keys
354       (setq x (car keys))
355       (setq y (cdr (assq x alist)))
356       (if y
357           (if (setq tmp (assoc y result))
358               (setq result (cons (append tmp (list x))
359                                  (delete tmp result)))
360             (setq result (cons (list y x) result))))
361       (setq keys (cdr keys)))
362     result))
363
364 (eval-when-compile
365   (require 'static))
366 (static-unless (fboundp 'pp)
367   (defvar pp-escape-newlines t)
368   (defun pp (object &optional stream)
369     "Output the pretty-printed representation of OBJECT, any Lisp object.
370 Quoting characters are printed when needed to make output that `read'
371 can handle, whenever this is possible.
372 Output stream is STREAM, or value of `standard-output' (which see)."
373     (princ (pp-to-string object) (or stream standard-output)))
374
375   (defun pp-to-string (object)
376     "Return a string containing the pretty-printed representation of OBJECT,
377 any Lisp object.  Quoting characters are used when needed to make output
378 that `read' can handle, whenever this is possible."
379     (save-excursion
380       (set-buffer (generate-new-buffer " pp-to-string"))
381       (unwind-protect
382           (progn
383             (lisp-mode-variables t)
384             (let ((print-escape-newlines pp-escape-newlines))
385               (prin1 object (current-buffer)))
386             (goto-char (point-min))
387             (while (not (eobp))
388               (cond
389                ((looking-at "\\s(\\|#\\s(")
390                 (while (looking-at "\\s(\\|#\\s(")
391                   (forward-char 1)))
392                ((and (looking-at "\\(quote[ \t]+\\)\\([^.)]\\)")
393                      (> (match-beginning 1) 1)
394                      (= ?\( (char-after (1- (match-beginning 1))))
395                      ;; Make sure this is a two-element list.
396                      (save-excursion
397                        (goto-char (match-beginning 2))
398                        (forward-sexp)
399                        ;; Avoid mucking with match-data; does this test work?
400                        (char-equal ?\) (char-after (point)))))
401                 ;; -1 gets the paren preceding the quote as well.
402                 (delete-region (1- (match-beginning 1)) (match-end 1))
403                 (insert "'")
404                 (forward-sexp 1)
405                 (if (looking-at "[ \t]*\)")
406                     (delete-region (match-beginning 0) (match-end 0))
407                   (error "Malformed quote"))
408                 (backward-sexp 1))
409                ((condition-case err-var
410                     (prog1 t (down-list 1))
411                   (error nil))
412                 (backward-char 1)
413                 (skip-chars-backward " \t")
414                 (delete-region
415                  (point)
416                  (progn (skip-chars-forward " \t") (point)))
417                 (if (not (char-equal ?' (char-after (1- (point)))))
418                     (insert ?\n)))
419                ((condition-case err-var
420                     (prog1 t (up-list 1))
421                   (error nil))
422                 (while (looking-at "\\s)")
423                   (forward-char 1))
424                 (skip-chars-backward " \t")
425                 (delete-region
426                  (point)
427                  (progn (skip-chars-forward " \t") (point)))
428                 (if (not (char-equal ?' (char-after (1- (point)))))
429                     (insert ?\n)))
430                (t (goto-char (point-max)))))
431             (goto-char (point-min))
432             (indent-sexp)
433             (buffer-string))
434         (kill-buffer (current-buffer))))))
435
436 (defsubst wl-get-date-iso8601 (date)
437   (or (get-text-property 0 'wl-date date)
438       (let* ((d1 (timezone-fix-time date nil nil))
439              (time (format "%04d%02d%02dT%02d%02d%02d"
440                            (aref d1 0) (aref d1 1) (aref d1 2)
441                            (aref d1 3) (aref d1 4) (aref d1 5))))
442         (put-text-property 0 1 'wl-date time date)
443         time)))
444
445 (defun wl-make-date-string ()
446   (let ((s (current-time-string)))
447     (string-match "\\`\\([A-Z][a-z][a-z]\\) +[A-Z][a-z][a-z] +[0-9][0-9]? *[0-9][0-9]?:[0-9][0-9]:[0-9][0-9] *[0-9]?[0-9]?[0-9][0-9]"
448                   s)
449     (concat (wl-match-string 1 s) ", "
450             (timezone-make-date-arpa-standard s (current-time-zone)))))
451
452 (defun wl-date-iso8601 (date)
453   "Convert the DATE to YYMMDDTHHMMSS."
454   (condition-case ()
455       (wl-get-date-iso8601 date)
456     (error "")))
457
458 (defun wl-url-news (url &rest args)
459   (interactive "sURL: ")
460   (if (string-match "^news:\\(.*\\)$" url)
461       (wl-summary-goto-folder-subr
462        (concat "-" (elmo-match-string 1 url)) nil nil nil t)
463     (message "Not a news: url.")))
464
465 (defun wl-url-nntp (url &rest args)
466   (interactive "sURL: ")
467   (let (folder fld-name server port msg)
468     (if (string-match
469          "^nntp://\\([^:/]*\\):?\\([0-9]*\\)/\\([^/]*\\)/\\([0-9]*\\).*$" url)
470         (progn
471           (if (eq (length (setq fld-name
472                                 (elmo-match-string 3 url))) 0)
473               (setq fld-name nil))
474           (if (eq (length (setq port
475                                 (elmo-match-string 2 url))) 0)
476               (setq port (int-to-string elmo-nntp-default-port)))
477           (if (eq (length (setq server
478                                 (elmo-match-string 1 url))) 0)
479               (setq server elmo-nntp-default-server))
480           (setq folder (concat "-" fld-name "@" server ":" port))
481           (if (eq (length (setq msg
482                                 (elmo-match-string 4 url))) 0)
483               (wl-summary-goto-folder-subr
484                folder nil nil nil t)
485             (wl-summary-goto-folder-subr
486              folder 'update nil nil t)
487             (wl-summary-jump-to-msg (string-to-number msg))
488             (wl-summary-redisplay)))
489       (message "Not a nntp: url."))))
490
491 (defmacro wl-concat-list (list separator)
492   (` (mapconcat 'identity (delete "" (delq nil (, list))) (, separator))))
493
494 (defun wl-current-message-buffer ()
495   (when (buffer-live-p wl-current-summary-buffer)
496     (with-current-buffer wl-current-summary-buffer
497       (or wl-message-buffer
498           (and (wl-summary-message-number)
499                (wl-message-buffer-display
500                 wl-summary-buffer-elmo-folder
501                 (wl-summary-message-number)
502                 wl-summary-buffer-display-mime-mode
503                 nil nil))))))
504
505 (defmacro wl-kill-buffers (regexp)
506   (` (mapcar (function
507               (lambda (x)
508                 (if (and (buffer-name x)
509                          (string-match (, regexp) (buffer-name x)))
510                     (and (get-buffer x)
511                          (kill-buffer x)))))
512              (buffer-list))))
513
514 (defun wl-collect-summary ()
515   (let (result)
516     (mapcar
517      (function (lambda (x)
518                  (if (and (string-match "^Summary"
519                                         (buffer-name x))
520                           (save-excursion
521                             (set-buffer x)
522                             (equal major-mode 'wl-summary-mode)))
523                      (setq result (nconc result (list x))))))
524      (buffer-list))
525     result))
526
527 (defun wl-collect-draft ()
528   (let ((draft-regexp (concat "^" (regexp-quote wl-draft-folder)))
529         result)
530     (dolist (buffer (buffer-list))
531       (when (with-current-buffer buffer
532               (and (eq major-mode 'wl-draft-mode)
533                    (buffer-name)
534                    (string-match draft-regexp (buffer-name))))
535         (setq result (cons buffer result))))
536     (nreverse result)))
537
538 (defvar wl-inhibit-save-drafts nil)
539 (defvar wl-disable-auto-save nil)
540 (make-variable-buffer-local 'wl-disable-auto-save)
541
542 (defun wl-save-drafts ()
543   "Save all drafts. Return nil if there is no draft buffer."
544   (if wl-inhibit-save-drafts
545       'inhibited
546     (let ((wl-inhibit-save-drafts t)
547           (msg (current-message))
548           (buffers (wl-collect-draft)))
549       (save-excursion
550         (dolist (buffer buffers)
551           (set-buffer buffer)
552           (when (and (not wl-disable-auto-save)
553                      (buffer-modified-p))
554             (wl-draft-save))))
555       (message "%s" (or msg ""))
556       buffers)))
557
558 (static-if (fboundp 'read-directory-name)
559     (defun wl-read-directory-name (prompt dir)
560       (read-directory-name prompt dir dir))
561   (defun wl-read-directory-name (prompt dir)
562     (let ((dir (read-file-name prompt dir)))
563       (unless (file-directory-p dir)
564         (error "%s is not directory" dir))
565       dir)))
566
567 ;; local variable check.
568 (static-if (fboundp 'local-variable-p)
569     (defalias 'wl-local-variable-p 'local-variable-p)
570   (defmacro wl-local-variable-p (symbol &optional buffer)
571     (` (if (assq (, symbol) (buffer-local-variables (, buffer)))
572            t))))
573
574 (defun wl-number-base36 (num len)
575   (if (if (< len 0)
576           (<= num 0)
577         (= len 0))
578       ""
579     (concat (wl-number-base36 (/ num 36) (1- len))
580             (char-to-string (aref "zyxwvutsrqponmlkjihgfedcba9876543210"
581                                   (% num 36))))))
582
583 (defvar wl-unique-id-char nil)
584
585 (defun wl-unique-id ()
586   ;; Don't use microseconds from (current-time), they may be unsupported.
587   ;; Instead we use this randomly inited counter.
588   (setq wl-unique-id-char
589         (% (1+ (or wl-unique-id-char (logand (random t) (1- (lsh 1 20)))))
590            ;; (current-time) returns 16-bit ints,
591            ;; and 2^16*25 just fits into 4 digits i base 36.
592            (* 25 25)))
593   (let ((tm (static-if (fboundp 'current-time)
594                 (current-time)
595               (let* ((cts (split-string (current-time-string) "[ :]"))
596                      (m (cdr (assoc (nth 1 cts)
597                                     '(("Jan" . "01") ("Feb" . "02")
598                                       ("Mar" . "03") ("Apr" . "04")
599                                       ("May" . "05") ("Jun" . "06")
600                                       ("Jul" . "07") ("Aug" . "08")
601                                       ("Sep" . "09") ("Oct" . "10")
602                                       ("Nov" . "11") ("Dec" . "12"))))))
603                 (list (string-to-int (concat (nth 6 cts) m
604                                              (substring (nth 2 cts) 0 1)))
605                       (string-to-int (concat (substring (nth 2 cts) 1)
606                                              (nth 4 cts) (nth 5 cts)
607                                              (nth 6 cts))))))))
608     (concat
609      (if (memq system-type '(ms-dos emx vax-vms))
610          (let ((user (downcase (user-login-name))))
611            (while (string-match "[^a-z0-9_]" user)
612              (aset user (match-beginning 0) ?_))
613            user)
614        (wl-number-base36 (user-uid) -1))
615      (wl-number-base36 (+ (car   tm)
616                           (lsh (% wl-unique-id-char 25) 16)) 4)
617      (wl-number-base36 (+ (nth 1 tm)
618                           (lsh (/ wl-unique-id-char 25) 16)) 4)
619      ;; Append the name of the message interface, because while the
620      ;; generated ID is unique to this newsreader, other newsreaders
621      ;; might otherwise generate the same ID via another algorithm.
622      wl-unique-id-suffix)))
623
624 (defvar wl-message-id-function 'wl-draft-make-message-id-string)
625 (defun wl-draft-make-message-id-string ()
626   "Return Message-ID field value."
627   (concat "<" (wl-unique-id)
628           (let (from user domain)
629             (if (and wl-message-id-use-wl-from
630                      (progn
631                        (setq from (wl-address-header-extract-address wl-from))
632                        (and (string-match "^\\(.*\\)@\\(.*\\)$" from)
633                             (setq user   (match-string 1 from))
634                             (setq domain (match-string 2 from)))))
635                 (format "%%%s@%s>" user domain)
636               (format "@%s>"
637                       (or wl-message-id-domain
638                           (if wl-local-domain
639                               (concat (system-name) "." wl-local-domain)
640                             (system-name))))))))
641
642 ;;; Profile loading.
643 (defvar wl-load-profile-function 'wl-local-load-profile)
644 (defun wl-local-load-profile ()
645   "Load `wl-init-file'."
646   (message "Initializing...")
647   (load wl-init-file 'noerror 'nomessage))
648
649 (defun wl-load-profile ()
650   "Call `wl-load-profile-function' function."
651   (funcall wl-load-profile-function))
652
653 ;;;
654
655 (defmacro wl-count-lines ()
656   (` (save-excursion
657        (beginning-of-line)
658        (count-lines 1 (point)))))
659
660 (defun wl-horizontal-recenter ()
661   "Recenter the current buffer horizontally."
662   (beginning-of-line)
663   (re-search-forward "[[<]" (point-at-eol) t)
664   (if (< (current-column) (/ (window-width) 2))
665       (set-window-hscroll (get-buffer-window (current-buffer) t) 0)
666     (let* ((orig (point))
667            (end (window-end (get-buffer-window (current-buffer) t)))
668            (max 0))
669       (when end
670         ;; Find the longest line currently displayed in the window.
671         (goto-char (window-start))
672         (while (and (not (eobp))
673                     (< (point) end))
674           (end-of-line)
675           (setq max (max max (current-column)))
676           (forward-line 1))
677         (goto-char orig)
678         ;; Scroll horizontally to center (sort of) the point.
679         (if (> max (window-width))
680             (set-window-hscroll
681              (get-buffer-window (current-buffer) t)
682              (min (- (current-column) (/ (window-width) 3))
683                   (+ 2 (- max (window-width)))))
684           (set-window-hscroll (get-buffer-window (current-buffer) t) 0))
685         max))))
686
687 ;; Draft auto-save
688 (defun wl-auto-save-drafts ()
689   (unless (wl-save-drafts)
690     (wl-stop-save-drafts)))
691
692 (static-cond
693  (wl-on-xemacs
694   (defvar wl-save-drafts-timer-name "wl-save-drafts")
695
696   (defun wl-start-save-drafts ()
697     (when (numberp wl-auto-save-drafts-interval)
698       (unless (get-itimer wl-save-drafts-timer-name)
699         (start-itimer wl-save-drafts-timer-name
700                       'wl-auto-save-drafts
701                       wl-auto-save-drafts-interval
702                       wl-auto-save-drafts-interval
703                       t))))
704
705   (defun wl-stop-save-drafts ()
706     (when (get-itimer wl-save-drafts-timer-name)
707       (delete-itimer wl-save-drafts-timer-name))))
708  (t
709   (defun wl-start-save-drafts ()
710     (when (numberp wl-auto-save-drafts-interval)
711       (require 'timer)
712       (if (get 'wl-save-drafts 'timer)
713           (progn
714             (timer-set-idle-time (get 'wl-save-drafts 'timer)
715                                  wl-auto-save-drafts-interval t)
716             (timer-activate-when-idle (get 'wl-save-drafts 'timer)))
717         (put 'wl-save-drafts 'timer
718              (run-with-idle-timer
719               wl-auto-save-drafts-interval t 'wl-auto-save-drafts)))))
720
721   (defun wl-stop-save-drafts ()
722     (when (get 'wl-save-drafts 'timer)
723       (cancel-timer (get 'wl-save-drafts 'timer))))))
724
725 (defun wl-set-auto-save-draft (&optional arg)
726   (interactive "P")
727   (unless (setq wl-disable-auto-save
728                 (cond
729                  ((null arg) (not wl-disable-auto-save))
730                  ((< (prefix-numeric-value arg) 0) t)
731                  (t nil)))
732     (wl-start-save-drafts))
733   (when (interactive-p)
734     (message "Auto save is %s (in this buffer)"
735              (if wl-disable-auto-save "disabled" "enabled"))))
736
737 ;; Biff
738 (static-cond
739  (wl-on-xemacs
740   (defvar wl-biff-timer-name "wl-biff")
741
742   (defun wl-biff-stop ()
743     (when (get-itimer wl-biff-timer-name)
744       (delete-itimer wl-biff-timer-name)))
745
746   (defun wl-biff-start ()
747     (wl-biff-stop)
748     (when wl-biff-check-folder-list
749       (start-itimer wl-biff-timer-name 'wl-biff-check-folders
750                     wl-biff-check-interval wl-biff-check-interval
751                     wl-biff-use-idle-timer))))
752
753  (t
754   (defun wl-biff-stop ()
755     (when (get 'wl-biff 'timer)
756       (cancel-timer (get 'wl-biff 'timer))))
757
758   (defun wl-biff-start ()
759     (require 'timer)
760     (when wl-biff-check-folder-list
761       (if wl-biff-use-idle-timer
762           (if (get 'wl-biff 'timer)
763               (progn (timer-set-idle-time (get 'wl-biff 'timer)
764                                           wl-biff-check-interval t)
765                      (timer-activate-when-idle (get 'wl-biff 'timer)))
766             (put 'wl-biff 'timer
767                  (run-with-idle-timer
768                   wl-biff-check-interval t 'wl-biff-event-handler)))
769         (if (get 'wl-biff 'timer)
770             (progn
771               (timer-set-time (get 'wl-biff 'timer)
772                               (timer-next-integral-multiple-of-time
773                                (current-time) wl-biff-check-interval)
774                               wl-biff-check-interval)
775               (timer-activate (get 'wl-biff 'timer)))
776           (put 'wl-biff 'timer
777                (run-at-time
778                 (timer-next-integral-multiple-of-time
779                  (current-time) wl-biff-check-interval)
780                 wl-biff-check-interval
781                 'wl-biff-event-handler))))))
782
783   (defun-maybe timer-next-integral-multiple-of-time (time secs)
784     "Yield the next value after TIME that is an integral multiple of SECS.
785 More precisely, the next value, after TIME, that is an integral multiple
786 of SECS seconds since the epoch.  SECS may be a fraction.
787 This function is imported from Emacs 20.7."
788     (let ((time-base (ash 1 16)))
789       (if (fboundp 'atan)
790           ;; Use floating point, taking care to not lose precision.
791           (let* ((float-time-base (float time-base))
792                  (million 1000000.0)
793                  (time-usec (+ (* million
794                                   (+ (* float-time-base (nth 0 time))
795                                      (nth 1 time)))
796                                (nth 2 time)))
797                  (secs-usec (* million secs))
798                  (mod-usec (mod time-usec secs-usec))
799                  (next-usec (+ (- time-usec mod-usec) secs-usec))
800                  (time-base-million (* float-time-base million)))
801             (list (floor next-usec time-base-million)
802                   (floor (mod next-usec time-base-million) million)
803                   (floor (mod next-usec million))))
804         ;; Floating point is not supported.
805         ;; Use integer arithmetic, avoiding overflow if possible.
806         (let* ((mod-sec (mod (+ (* (mod time-base secs)
807                                    (mod (nth 0 time) secs))
808                                 (nth 1 time))
809                              secs))
810                (next-1-sec (+ (- (nth 1 time) mod-sec) secs)))
811           (list (+ (nth 0 time) (floor next-1-sec time-base))
812                 (mod next-1-sec time-base)
813                 0)))))
814
815   (defun wl-biff-event-handler ()
816     ;; PAKURing from FSF:time.el
817     (wl-biff-check-folders)
818     ;; Do redisplay right now, if no input pending.
819     (sit-for 0)
820     (let* ((current (current-time))
821            (timer (get 'wl-biff 'timer))
822            ;; Compute the time when this timer will run again, next.
823            (next-time (timer-relative-time
824                        (list (aref timer 1) (aref timer 2) (aref timer 3))
825                        (* 5 (aref timer 4)) 0)))
826       ;; If the activation time is far in the past,
827       ;; skip executions until we reach a time in the future.
828       ;; This avoids a long pause if Emacs has been suspended for hours.
829       (or (> (nth 0 next-time) (nth 0 current))
830           (and (= (nth 0 next-time) (nth 0 current))
831                (> (nth 1 next-time) (nth 1 current)))
832           (and (= (nth 0 next-time) (nth 0 current))
833                (= (nth 1 next-time) (nth 1 current))
834                (> (nth 2 next-time) (nth 2 current)))
835           (progn
836             (timer-set-time timer (timer-next-integral-multiple-of-time
837                                    current wl-biff-check-interval)
838                             wl-biff-check-interval)
839             (timer-activate timer)))))))
840
841 (defsubst wl-biff-notify (new-mails notify-minibuf)
842   (when (and (not wl-modeline-biff-status) (> new-mails 0))
843     (run-hooks 'wl-biff-notify-hook))
844   (when (and wl-modeline-biff-status (eq new-mails 0))
845     (run-hooks 'wl-biff-unnotify-hook))
846   (setq wl-modeline-biff-status (> new-mails 0))
847   (force-mode-line-update t)
848   (when notify-minibuf
849     (cond ((zerop new-mails) (message "No mail."))
850           ((= 1 new-mails) (message "You have a new mail."))
851           (t (message "You have %d new mails." new-mails)))))
852
853 ;; Internal variable.
854 (defvar wl-biff-check-folders-running nil)
855
856 (defun wl-biff-check-folders ()
857   (interactive)
858   (if wl-biff-check-folders-running
859       (when (interactive-p)
860         (message "Biff process is running."))
861     (setq wl-biff-check-folders-running t)
862     (when (interactive-p)
863       (message "Checking new mails..."))
864     (let ((new-mails 0)
865           (flist (or wl-biff-check-folder-list (list wl-default-folder)))
866           folder)
867       (if (eq (length flist) 1)
868           (wl-biff-check-folder-async (wl-folder-get-elmo-folder
869                                        (car flist) 'biff) (interactive-p))
870         (unwind-protect
871             (while flist
872               (setq folder (wl-folder-get-elmo-folder (car flist))
873                     flist (cdr flist))
874               (when (and (elmo-folder-plugged-p folder)
875                          (elmo-folder-exists-p folder))
876                 (setq new-mails
877                       (+ new-mails
878                          (nth 0 (wl-biff-check-folder folder))))))
879           (setq wl-biff-check-folders-running nil)
880           (wl-biff-notify new-mails (interactive-p)))))))
881
882 (defun wl-biff-check-folder (folder)
883   (if (eq (elmo-folder-type-internal folder) 'pop3)
884       (unless (elmo-pop3-get-session folder 'any-exists)
885         (wl-folder-check-one-entity (elmo-folder-name-internal folder)
886                                     'biff))
887     (wl-folder-check-one-entity (elmo-folder-name-internal folder)
888                                 'biff)))
889
890 (defun wl-biff-check-folder-async-callback (diff data)
891   (if (nth 1 data)
892       (with-current-buffer (nth 1 data)
893         (wl-folder-entity-hashtb-set wl-folder-entity-hashtb
894                                      (nth 0 data)
895                                      (list (nth 0 diff)
896                                            (- (nth 1 diff) (nth 0 diff))
897                                            (nth 2 diff))
898                                      (current-buffer))))
899   (setq wl-folder-info-alist-modified t)
900   (setq wl-biff-check-folders-running nil)
901   (sit-for 0)
902   (wl-biff-notify (car diff) (nth 2 data)))
903
904 (defun wl-biff-check-folder-async (folder notify-minibuf)
905   (if (and (elmo-folder-plugged-p folder)
906            (wl-folder-entity-exists-p (elmo-folder-name-internal folder)))
907       (progn
908         (elmo-folder-set-biff-internal folder t)
909         (if (and (eq (elmo-folder-type-internal folder) 'imap4)
910                  (elmo-folder-use-flag-p folder))
911             ;; Check asynchronously only when IMAP4 and use server diff.
912             (progn
913               (setq elmo-folder-diff-async-callback
914                     'wl-biff-check-folder-async-callback)
915               (setq elmo-folder-diff-async-callback-data
916                     (list (elmo-folder-name-internal folder)
917                           (get-buffer wl-folder-buffer-name)
918                           notify-minibuf))
919               (elmo-folder-diff-async folder))
920           (unwind-protect
921               (wl-biff-notify (car (wl-biff-check-folder folder))
922                               notify-minibuf)
923             (setq wl-biff-check-folders-running nil))))
924     (setq wl-biff-check-folders-running nil)))
925
926 (if (and (fboundp 'regexp-opt)
927          (not (featurep 'xemacs)))
928     (defalias 'wl-regexp-opt 'regexp-opt)
929   (defun wl-regexp-opt (strings &optional paren)
930     "Return a regexp to match a string in STRINGS.
931 Each string should be unique in STRINGS and should not contain any regexps,
932 quoted or not.  If optional PAREN is non-nil, ensure that the returned regexp
933 is enclosed by at least one regexp grouping construct."
934     (let ((open-paren (if paren "\\(" "")) (close-paren (if paren "\\)" "")))
935       (concat open-paren (mapconcat 'regexp-quote strings "\\|")
936               close-paren))))
937
938 (defalias 'wl-expand-newtext 'elmo-expand-newtext)
939 (defalias 'wl-regexp-opt 'elmo-regexp-opt)
940
941 (defun wl-region-exists-p ()
942   "Return non-nil if a region exists on current buffer."
943   (static-if (featurep 'xemacs)
944       (region-active-p)
945     (and transient-mark-mode mark-active)))
946
947 (defun wl-deactivate-region ()
948   "Deactivate region on current buffer"
949   (static-if (not (featurep 'xemacs))
950       (setq mark-active nil)))
951
952 (defvar wl-line-string)
953 (defun wl-line-parse-format (format spec-alist)
954   "Make a formatter from FORMAT and SPEC-ALIST."
955   (let (f spec specs stack)
956     (setq f
957           (with-temp-buffer
958             (insert format)
959             (goto-char (point-min))
960             (while (search-forward "%" nil t)
961               (cond
962                ((looking-at "%")
963                 (goto-char (match-end 0)))
964                ((looking-at "\\(-?\\(0?\\)[0-9]*\\)\\([^0-9]\\)")
965                 (cond
966                  ((string= (match-string 3) "(")
967                   (if (zerop (length (match-string 1)))
968                       (error "No number specification for %%( line format"))
969                   (push (list
970                          (match-beginning 0) ; start
971                          (match-end 0)       ; start-content
972                          (string-to-number
973                           (match-string 1))  ; width
974                          specs) ; specs
975                         stack)
976                   (setq specs nil))
977                  ((string= (match-string 3) ")")
978                   (let ((entry (pop stack))
979                         form)
980                     (unless entry
981                       (error
982                        "No matching %%( parenthesis in summary line format"))
983                     (goto-char (car entry)) ; start
984                     (setq form (buffer-substring (nth 1 entry) ; start-content
985                                                  (- (match-beginning 0) 1)))
986                     (delete-region (car entry) (match-end 0))
987                     (insert "s")
988                     (setq specs
989                           (append
990                            (nth 3 entry)
991                            (list (list 'wl-set-string-width (nth 2 entry)
992                                        (append
993                                         (list 'format form)
994                                         specs)))))))
995                  (t
996                   (setq spec
997                         (if (setq spec (assq (string-to-char (match-string 3))
998                                              spec-alist))
999                             (nth 1 spec)
1000                           (match-string 3)))
1001                   (unless (string= "" (match-string 1))
1002                     (setq spec (list 'wl-set-string-width
1003                                      (string-to-number (match-string 1))
1004                                      spec
1005                                      (unless (string= "" (match-string 2))
1006                                        (string-to-char (match-string 2))))))
1007                   (replace-match "s" 'fixed)
1008                   (setq specs (append specs
1009                                       (list
1010                                        (list
1011                                         'setq 'wl-line-string
1012                                         spec)))))))))
1013             (buffer-string)))
1014     (append (list 'format f) specs)))
1015
1016 (defmacro wl-line-formatter-setup (formatter format alist)
1017   (` (let (byte-compile-warnings)
1018        (setq (, formatter)
1019              (byte-compile
1020               (list 'lambda ()
1021                     (wl-line-parse-format (, format) (, alist)))))
1022        (when (get-buffer "*Compile-Log*")
1023          (bury-buffer "*Compile-Log*"))
1024        (when (get-buffer "*Compile-Log-Show*")
1025          (bury-buffer "*Compile-Log-Show*")))))
1026
1027 (defsubst wl-copy-local-variables (src dst local-variables)
1028   "Copy value of LOCAL-VARIABLES from SRC buffer to DST buffer."
1029   (with-current-buffer dst
1030     (dolist (variable local-variables)
1031       (set (make-local-variable variable)
1032            (with-current-buffer src
1033              (symbol-value variable))))))
1034
1035 ;;; Search Condition
1036 (defun wl-search-condition-fields ()
1037   (let ((denial-fields
1038          (nconc (mapcar 'capitalize elmo-msgdb-extra-fields)
1039                 (mapcar 'capitalize wl-additional-search-condition-fields)
1040                 '("Flag" "Since" "Before"
1041                   "From" "Subject" "To" "Cc" "Body" "ToCc"
1042                   "Larger" "Smaller"))))
1043     (append '("Last" "First")
1044             denial-fields
1045             (mapcar (lambda (f) (concat "!" f))
1046                     denial-fields))))
1047
1048 (defun wl-read-search-condition (default)
1049   "Read search condition string interactively."
1050   (wl-read-search-condition-internal "Search by" default))
1051
1052 (defun wl-read-search-condition-internal (prompt default &optional paren)
1053   (let* ((completion-ignore-case t)
1054          (field (completing-read
1055                  (format "%s (%s): " prompt default)
1056                  (mapcar #'list
1057                          (append '("AND" "OR") (wl-search-condition-fields)))))
1058          value)
1059     (setq field (if (string= field "")
1060                     (setq field default)
1061                   field))
1062     (cond
1063      ((or (string= field "AND") (string= field "OR"))
1064       (concat (if paren "(" "")
1065               (wl-read-search-condition-internal
1066                (concat field "(1) Search by") default 'paren)
1067               (if (string= field "AND") "&" "|")
1068               (wl-read-search-condition-internal
1069                (concat field "(2) Search by") default 'paren)
1070               (if paren ")" "")))
1071      ((string-match "Since\\|Before" field)
1072       (let ((default (format-time-string "%Y-%m-%d")))
1073         (setq value (completing-read
1074                      (format "Value for '%s' [%s]: " field default)
1075                      (mapcar (function
1076                               (lambda (x)
1077                                 (list (format "%s" (car x)))))
1078                              elmo-date-descriptions)))
1079         (concat (downcase field) ":"
1080                 (if (equal value "") default value))))
1081      ((string-match "!?Flag" field)
1082       (while (null value)
1083         (setq value (downcase
1084                      (completing-read
1085                       (format "Value for '%s': " field)
1086                       (mapcar (lambda (f) (list (capitalize (symbol-name f))))
1087                               (elmo-uniq-list
1088                                (append
1089                                 '(unread answered forwarded digest any)
1090                                 (copy-sequence elmo-global-flags))
1091                                #'delq)))))
1092         (unless (elmo-flag-valid-p value)
1093           (message "Invalid char in `%s'" value)
1094           (setq value nil)
1095           (sit-for 1)))
1096       (unless (string-match (concat "^" elmo-condition-atom-regexp "$")
1097                             value)
1098         (setq value (prin1-to-string value)))
1099       (concat (downcase field) ":" value))
1100      (t
1101       (setq value (read-from-minibuffer (format "Value for '%s': " field)))
1102       (unless (string-match (concat "^" elmo-condition-atom-regexp "$")
1103                             value)
1104         (setq value (prin1-to-string value)))
1105       (concat (downcase field) ":" value)))))
1106
1107 (defun wl-y-or-n-p-with-scroll (prompt &optional scroll-by-SPC)
1108   (let ((prompt (concat prompt (if scroll-by-SPC
1109                                    "<y/n/SPC(down)/BS(up)> "
1110                                  "<y/n/j(down)/k(up)> "))))
1111     (catch 'done
1112       (while t
1113         (discard-input)
1114         (case (let ((cursor-in-echo-area t))
1115                 (cdr (wl-read-event-char prompt)))
1116           ((?y ?Y)
1117            (throw 'done t))
1118           (?\ 
1119            (if scroll-by-SPC
1120                (ignore-errors (scroll-up))
1121              (throw 'done t)))
1122           ((?v ?j ?J next)
1123            (ignore-errors (scroll-up)))
1124           ((?^ ?k ?K prior backspace)
1125            (ignore-errors (scroll-down)))
1126           (t
1127            (throw 'done nil)))))))
1128
1129 (defun wl-find-region (beg-regexp end-regexp)
1130   (if (or (re-search-forward end-regexp nil t)
1131           (re-search-backward end-regexp nil t))
1132       (let ((end (match-end 0))
1133             (beg (re-search-backward beg-regexp nil t)))
1134         (if beg
1135             (cons beg end)))))
1136
1137 (defun wl-simple-display-progress (label action current total)
1138   (message "%s... %d%%"
1139            action
1140            (if (> total 0) (floor (* (/ current (float total)) 100)) 0)))
1141
1142 (when (fboundp 'progress-feedback-with-label)
1143   (defun wl-display-progress-with-gauge (label action current total)
1144     (progress-feedback-with-label
1145      label
1146      "%s..."
1147      (if (> total 0) (floor (* (/ current (float total)) 100)) 0)
1148      action)))
1149
1150 (defun wl-progress-callback-function (label action current total)
1151   (case current
1152     (query
1153      (let ((threshold (if (consp wl-display-progress-threshold)
1154                           (cdr (or (assq label wl-display-progress-threshold)
1155                                    (assq t wl-display-progress-threshold)))
1156                         wl-display-progress-threshold)))
1157        (and threshold
1158             (>= total threshold))))
1159     (start
1160      (message "%s..." action))
1161     (done
1162      (message "%s...done" action))
1163     (t
1164      (when wl-display-progress-function
1165        (funcall wl-display-progress-function label action current total)))))
1166
1167 ;; read multiple strings with completion
1168 (defun wl-completing-read-multiple-1 (prompt
1169                                       table
1170                                       &optional predicate
1171                                       require-match initial-input
1172                                       hist def inherit-input-method)
1173     "Read multiple strings in the minibuffer"
1174     (split-string
1175      (completing-read prompt table predicate nil
1176                       initial-input hist def inherit-input-method)
1177      ","))
1178
1179 (static-when (fboundp 'completing-read-multiple)
1180   (eval-when-compile
1181     (require 'crm))
1182   (defun wl-completing-read-multiple-2 (prompt
1183                                         table
1184                                         &optional predicate
1185                                         require-match initial-input
1186                                         hist def inherit-input-method)
1187     "Read multiple strings in the minibuffer"
1188     (let ((ret (completing-read-multiple prompt table predicate
1189                                          require-match initial-input
1190                                          hist def inherit-input-method)))
1191       (if (and def (equal ret '("")))
1192           (split-string def crm-separator)
1193         ret))))
1194
1195 (static-cond
1196  ((not (fboundp 'completing-read-multiple))
1197   (defalias 'wl-completing-read-multiple 'wl-completing-read-multiple-1))
1198  ((< emacs-major-version 22)
1199   (defun wl-completing-read-multiple (prompt
1200                                       table
1201                                       &optional predicate
1202                                       require-match initial-input
1203                                       hist def inherit-input-method)
1204     "Read multiple strings in the minibuffer"
1205     (if require-match
1206         (wl-completing-read-multiple-1 prompt table predicate
1207                                        nil initial-input
1208                                        hist def inherit-input-method)
1209       (wl-completing-read-multiple-2 prompt table predicate
1210                                      nil initial-input
1211                                      hist def inherit-input-method))))
1212  (t
1213   (defalias 'wl-completing-read-multiple 'completing-read-multiple)))
1214
1215
1216 (require 'product)
1217 (product-provide (provide 'wl-util) (require 'wl-version))
1218
1219 ;;; wl-util.el ends here