~ubuntu-branches/ubuntu/karmic/mew-beta/karmic

« back to all changes in this revision

Viewing changes to mew-addrbook.el

  • Committer: Bazaar Package Importer
  • Author(s): Tatsuya Kinoshita
  • Date: 2008-04-24 00:28:17 UTC
  • mfrom: (1.1.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20080424002817-68vgq5lfqr8z0795
Tags: 6.0.51~0.20080421-1
New upstream release. (CVS trunk on 2008-04-21)

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
(defvar mew-addrbook-orig-alist nil
29
29
  "(key (addr1, addr2) nickname name) or (key addr)")
30
30
 
31
 
(defsubst mew-adbkorigent-by-shortname (user)
 
31
(defun mew-adbkorigent-by-shortname (user)
32
32
  (mew-addrbook-alias-hit user mew-addrbook-orig-alist))
33
33
 
34
34
;;
36
36
(defvar mew-addrbook-alist nil ;; mew-alias-auto-alist is appended
37
37
  "(key addr) or (key (addr1, addr2) nickname name)")
38
38
 
39
 
(defsubst mew-adbkent-by-addr-with-alist (addr alist)
 
39
(defun mew-adbkent-by-addr-with-alist (addr alist)
40
40
  (mew-assoc-member-case-equal addr alist 1))
41
41
 
42
 
(defsubst mew-adbkent-by-addr (addr)
 
42
(defun mew-adbkent-by-addr (addr)
43
43
  (mew-adbkent-by-addr-with-alist addr mew-addrbook-alist))
44
44
 
45
 
(defsubst mew-adbkent-by-addr2 (addr)
 
45
(defun mew-adbkent-by-addr2 (addr)
46
46
  ;; for nickname and name, mew-addrbook-orig-alist is enough and fast
47
47
  (mew-adbkent-by-addr-with-alist addr mew-addrbook-orig-alist))
48
48
 
49
 
(defsubst mew-adbkent-shortname (adbkent)
 
49
(defun mew-adbkent-shortname (adbkent)
50
50
  (nth 0 adbkent))
51
51
 
52
 
(defsubst mew-adbkent-addrs (adbkent)
 
52
(defun mew-adbkent-addrs (adbkent)
53
53
  (nth 1 adbkent))
54
54
 
55
 
(defsubst mew-adbkent-nickname (adbkent)
 
55
(defun mew-adbkent-nickname (adbkent)
56
56
  (nth 2 adbkent))
57
57
 
58
 
(defsubst mew-adbkent-name (adbkent)
 
58
(defun mew-adbkent-name (adbkent)
59
59
  (nth 3 adbkent))
60
60
 
61
 
(defsubst mew-addrbook-shortname-get (addr)
 
61
(defun mew-addrbook-shortname-get (addr)
62
62
  (mew-adbkent-shortname (mew-adbkent-by-addr addr)))
63
63
 
64
64
(defun mew-addrbook-addrs-get (addr)
78
78
(defvar mew-alias-auto-alist nil
79
79
  "(key addr)")
80
80
 
81
 
(defsubst mew-autoent-by-shortname (user)
 
81
(defun mew-autoent-by-shortname (user)
82
82
  (assoc user mew-alias-auto-alist))
83
83
 
84
 
(defsubst mew-autoent-shortname (autoent)
 
84
(defun mew-autoent-shortname (autoent)
85
85
  (nth 0 autoent))
86
86
 
87
 
(defsubst mew-autoent-addr (autoent)
 
87
(defun mew-autoent-addr (autoent)
88
88
  (nth 1 autoent))
89
89
 
90
90
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
93
93
;;;
94
94
 
95
95
(defun mew-alias-short-to-full (alist)
96
 
  (let (ret)
97
 
    (while alist
98
 
      (setq ret (cons (cdr (car alist)) ret))
99
 
      (setq alist (cdr alist)))
100
 
    (nreverse ret)))
 
96
  (mapcar (lambda (x) (cdr x)) alist))
101
97
 
102
98
;; duplicated?
103
99
(defun mew-alias-full-to-short (alist)
104
 
  (let (ret ent user)
105
 
    (while alist
106
 
      (setq ent (car alist))
107
 
      (setq alist (cdr alist))
108
 
      (setq user (downcase (mew-addrstr-extract-user (car ent))))
109
 
      (setq ret (cons (cons user ent) ret)))
110
 
    (nreverse ret)))
 
100
  (mapcar (lambda (x) (cons (downcase (mew-addrstr-extract-user x)) x)) alist))
111
101
 
112
102
(defun mew-addrbook-setup ()
113
103
  (if (and mew-alias-auto-file (null mew-alias-auto-alist))
155
145
      ret)))
156
146
 
157
147
(defun mew-alias-expand-addrs (key alist count)
158
 
  (let ((keys (mew-split key ?,))
 
148
  (let ((keys (delete "" (mapcar 'mew-chop (mew-split key ?,))))
159
149
        ret)
160
 
    (setq keys (mapcar 'mew-chop keys))
161
 
    (setq keys (delete "" keys))
162
 
    (while keys
163
 
      (setq ret (nconc ret (mew-alias-expand (car keys) alist count)))
164
 
      (setq keys (cdr keys)))
165
 
    ret))
 
150
   (dolist (key keys)
 
151
     (setq ret (nconc ret (mew-alias-expand key alist count))))
 
152
   ret))
166
153
 
167
154
(defun mew-alias-expand (key alist count)
168
155
  "Expand KEY to a list of addresses according to ALIST.
265
252
         (files pars) ;; included
266
253
         par chr path beg end qchar ret)
267
254
    ;; include parents files
268
 
    (while pars
269
 
      (setq par (expand-file-name (car pars) mew-conf-path))
270
 
      (setq pars (cdr pars))
 
255
    (dolist (ent pars)
 
256
      (setq par (expand-file-name ent mew-conf-path))
271
257
      (when (file-readable-p par)
272
258
        (setq ret t)
273
259
        (mew-insert-file-contents par)
428
414
     (insert "\n"))))
429
415
 
430
416
(defun mew-addrbook-mode (mname)
431
 
  "\\<mew-addrbook-mode-map>
432
 
Mew Addrbook mode:: major mode to register Addrbook.
433
 
The keys that are defined for this mode are:
 
417
  "A major mode to register Addrbook.
434
418
 
435
 
\\[mew-addrbook-register]       Register information in Addrbook mode to Addrbook.
436
 
\\[mew-addrbook-kill]   Kill Addrbook mode.
437
 
"
 
419
\\{mew-addrbook-mode-map}"
438
420
  (interactive)
439
421
  (setq major-mode 'mew-addrbook-mode)
440
422
  (setq mode-name mname)
563
545
 
564
546
;;; Copyright Notice:
565
547
 
566
 
;; Copyright (C) 1999-2007 Mew developing team.
 
548
;; Copyright (C) 1999-2008 Mew developing team.
567
549
;; All rights reserved.
568
550
 
569
551
;; Redistribution and use in source and binary forms, with or without
570
552
;; modification, are permitted provided that the following conditions
571
553
;; are met:
572
 
;; 
 
554
;;
573
555
;; 1. Redistributions of source code must retain the above copyright
574
556
;;    notice, this list of conditions and the following disclaimer.
575
557
;; 2. Redistributions in binary form must reproduce the above copyright
578
560
;; 3. Neither the name of the team nor the names of its contributors
579
561
;;    may be used to endorse or promote products derived from this software
580
562
;;    without specific prior written permission.
581
 
;; 
 
563
;;
582
564
;; THIS SOFTWARE IS PROVIDED BY THE TEAM AND CONTRIBUTORS ``AS IS'' AND
583
565
;; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
584
566
;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR