annotate lisp/vm/vm-misc.el @ 76:c0c698873ce1 r20-0b33

Import from CVS: tag r20-0b33
author cvs
date Mon, 13 Aug 2007 09:05:10 +0200
parents 131b0175ea99
children 0d2f883870bc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; Miscellaneous functions for VM
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
2 ;;; Copyright (C) 1989, 1990, 1991, 1993, 1994 Kyle E. Jones
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;;; This program is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;;; the Free Software Foundation; either version 1, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;;; This program is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;; along with this program; if not, write to the Free Software
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 (provide 'vm-misc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 (defun vm-delete-non-matching-strings (regexp list &optional destructively)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 "Delete strings matching REGEXP from LIST.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 Optional third arg non-nil means to destructively alter LIST, instead of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 working on a copy.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 The new version of the list, minus the deleted strings, is returned."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 (or destructively (setq list (copy-sequence list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 (let ((curr list) (prev nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 (while curr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 (if (string-match regexp (car curr))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 (setq prev curr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 curr (cdr curr))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 (if (null prev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 (setq list (cdr list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 curr list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (setcdr prev (cdr curr))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 (setq curr (cdr curr)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 list ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 (defun vm-parse (string regexp &optional matchn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (or matchn (setq matchn 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (let (list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (store-match-data nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (while (string-match regexp string (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (setq list (cons (substring string (match-beginning matchn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (match-end matchn)) list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (nreverse list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (defun vm-parse-addresses (string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (if (null string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (let (work-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (let (list start s char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (setq work-buffer (generate-new-buffer "*vm-work*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (set-buffer work-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (insert string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (skip-chars-forward "\t\f\n\r ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (setq start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (while (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (skip-chars-forward "^\"\\,(")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (setq char (following-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (cond ((= char ?\\)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (if (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (forward-char 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ((= char ?,)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (setq s (buffer-substring start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (if (or (null (string-match "^[\t\f\n\r ]+$" s))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (not (string= s "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (setq list (cons s list)))
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
73 (skip-chars-forward ",\t\f\n\r ")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (setq start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ((= char ?\")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (re-search-forward "[^\\]\"" nil 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ((= char ?\()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (let ((parens 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (while (and (not (eobp)) (not (zerop parens)))
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
81 (re-search-forward "[()]" nil 0)
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
82 (cond ((or (eobp)
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
83 (= (char-after (- (point) 2)) ?\\)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 ((= (preceding-char) ?\()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (setq parens (1+ parens)))
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
86 (t
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (setq parens (1- parens)))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (setq s (buffer-substring start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (if (and (null (string-match "^[\t\f\n\r ]+$" s))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (not (string= s "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (setq list (cons s list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (nreverse list)) ; jwz: fixed order
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (and work-buffer (kill-buffer work-buffer)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (defun vm-write-string (where string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (if (bufferp where)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (vm-save-buffer-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (set-buffer where)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (insert string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (let ((temp-buffer nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (setq temp-buffer (generate-new-buffer "*vm-work*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (set-buffer temp-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (insert string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (write-region (point-min) (point-max) where t 'quiet))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (and temp-buffer (kill-buffer temp-buffer))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (defmacro vm-marker (pos &optional buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (list 'set-marker '(make-marker) pos buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (defmacro vm-increment (variable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (list 'setq variable (list '1+ variable)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (defmacro vm-decrement (variable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (list 'setq variable (list '1- variable)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (defmacro vm-select-folder-buffer ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 '(and vm-mail-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (or (buffer-name vm-mail-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (error "Folder buffer has been killed."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (set-buffer vm-mail-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (defun vm-check-for-killed-summary ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (and (bufferp vm-summary-buffer) (null (buffer-name vm-summary-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (let ((mp vm-message-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (setq vm-summary-buffer nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (while mp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (vm-set-su-start-of (car mp) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (vm-set-su-end-of (car mp) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (setq mp (cdr mp))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (defun vm-check-for-killed-folder ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (and (bufferp vm-mail-buffer) (null (buffer-name vm-mail-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (setq vm-mail-buffer nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (defmacro vm-error-if-folder-read-only ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 '(while vm-folder-read-only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (signal 'folder-read-only (list (current-buffer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
142 (put 'folder-read-only 'error-conditions '(folder-read-only error))
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
143 (put 'folder-read-only 'error-message "Folder is read-only")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (defmacro vm-error-if-virtual-folder ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 '(and (eq major-mode 'vm-virtual-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (error "%s cannot be applied to virtual folders." this-command)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (defmacro vm-build-threads-if-unbuilt ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 '(if (null vm-thread-obarray)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (vm-build-threads nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (defun vm-abs (n) (if (< n 0) (- n) n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 ;; save-restriction flubs restoring the clipping region if you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 ;; (widen) and modify text outside the old region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 ;; This should do it right.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (defmacro vm-save-restriction (&rest forms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (let ((vm-sr-clip (make-symbol "vm-sr-clip"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (vm-sr-min (make-symbol "vm-sr-min"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (vm-sr-max (make-symbol "vm-sr-max")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (list 'let (list (list vm-sr-clip '(> (buffer-size)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (- (point-max) (point-min))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 ;; this shouldn't be necessary but the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 ;; byte-compiler turns these into interned symbols
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 ;; which utterly defeats the purpose of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 ;; make-symbol calls above. Soooo, until the compiler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 ;; is fixed, these must be made into (let ...)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 ;; temporaries so that nested calls to this macros
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 ;; won't misbehave.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 vm-sr-min vm-sr-max)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (list 'and vm-sr-clip
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (list 'setq vm-sr-min '(set-marker (make-marker) (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (list 'setq vm-sr-max '(set-marker (make-marker) (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (list 'unwind-protect (cons 'progn forms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 '(widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (list 'and vm-sr-clip
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (list 'progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (list 'narrow-to-region vm-sr-min vm-sr-max)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (list 'set-marker vm-sr-min nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (list 'set-marker vm-sr-max nil)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (defmacro vm-save-buffer-excursion (&rest forms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (list 'let '((vm-sbe-buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (list 'unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (cons 'progn forms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 '(and (not (eq vm-sbe-buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (buffer-name vm-sbe-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (set-buffer vm-sbe-buffer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (defun vm-last (list) (while (cdr-safe list) (setq list (cdr list))) list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (defun vm-vector-to-list (vector)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (let ((i (1- (length vector)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (while (>= i 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (setq list (cons (aref vector i) list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (vm-decrement i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 list ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (defun vm-extend-vector (vector length &optional fill)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (let ((vlength (length vector)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (if (< vlength length)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (apply 'vector (nconc (vm-vector-to-list vector)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (make-list (- length vlength) fill)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 vector )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
208 (defun vm-obarray-to-string-list (obarray)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (let ((list nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (mapatoms (function (lambda (s) (setq list (cons (symbol-name s) list))))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
211 obarray)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 list ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (defun vm-mapcar (function &rest lists)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (let (arglist result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (while (car lists)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (setq arglist (mapcar 'car lists))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (setq result (cons (apply function arglist) result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (setq lists (mapcar 'cdr lists)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (nreverse result)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (defun vm-mapc (function &rest lists)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (let (arglist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (while (car lists)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (setq arglist (mapcar 'car lists))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (apply function arglist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (setq lists (mapcar 'cdr lists)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (defun vm-delete (predicate list &optional reverse)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (let ((p list) (reverse (if reverse 'not 'identity)) prev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (while p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (if (funcall reverse (funcall predicate (car p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (if (null prev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (setq list (cdr list) p list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (setcdr prev (cdr p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (setq p (cdr p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (setq prev p p (cdr p))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 list ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (defun vm-delete-duplicates (list &optional all hack-addresses)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 "Delete duplicate equivalent strings from the list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 If ALL is t, then if there is more than one occurrence of a string in the list,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 then all occurrences of it are removed instead of just the subsequent ones.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 If HACK-ADDRESSES is t, then the strings are considered to be mail addresses,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 and only the address part is compared (so that \"Name <foo>\" and \"foo\"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 would be considered to be equivalent.)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (let ((hashtable vm-delete-duplicates-obarray)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (new-list nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 sym-string sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (fillarray hashtable 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (while list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (setq sym-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (if hack-addresses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (nth 1 (funcall vm-chop-full-name-function (car list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (car list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 sym (intern sym-string hashtable))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (if (boundp sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (and all (setcar (symbol-value sym) nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (setq new-list (cons (car list) new-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (set sym new-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (setq list (cdr list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (delq nil (nreverse new-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (defun vm-member-0 (thing list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (catch 'done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (while list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (and (equal (car list) thing)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (throw 'done list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (setq list (cdr list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 nil ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (fset 'vm-member (symbol-function (if (fboundp 'member) 'member 'vm-member-0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (defun vm-delqual (ob list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (let ((prev nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (curr list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (while curr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (if (not (equal ob (car curr)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (setq prev curr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 curr (cdr curr))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (if (null prev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (setq list (cdr list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 curr list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (setq curr (cdr curr))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (setcdr prev curr))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 list ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (defun vm-copy-local-variables (buffer &rest variables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (let ((values (mapcar 'symbol-value variables)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (vm-mapc 'set variables values))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
294 (put 'folder-empty 'error-conditions '(folder-empty error))
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
295 (put 'folder-empty 'error-message "Folder is empty")
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
296 (put 'unrecognized-folder-type 'error-conditions
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
297 '(unrecognized-folder-type error))
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
298 (put 'unrecognized-folder-type 'error-message "Unrecognized folder type")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (defun vm-error-if-folder-empty ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (while (null vm-message-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (if vm-folder-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (signal 'unrecognized-folder-type nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (signal 'folder-empty nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (defun vm-copy (object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (cond ((consp object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (let (return-value cons)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (setq return-value (cons (vm-copy (car object)) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 cons return-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 object (cdr object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (while (consp object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (setcdr cons (cons (vm-copy (car object)) nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (setq cons (cdr cons)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 object (cdr object)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (setcdr cons object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 return-value ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 ((vectorp object) (apply 'vector (mapcar 'vm-copy object)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 ((stringp object) (copy-sequence object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (t object)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
322 (defun vm-xemacs-p ()
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
323 (let ((case-fold-search nil))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
324 (string-match "XEmacs" emacs-version)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
325
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
326 (defun vm-fsfemacs-19-p ()
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
327 (and (string-match "^19" emacs-version)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
328 (not (string-match "XEmacs\\|Lucid" emacs-version))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
329
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
330 ;; make-frame might be defined and still not work. This would
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
331 ;; be true since the user could be running on a tty and using
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
332 ;; XEmacs 19.12, or using FSF Emacs 19.28 (or prior FSF Emacs versions).
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
333 ;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
334 ;; make-frame works on ttys in FSF Emacs 19.29, but other than
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
335 ;; looking at the version number I don't know a sane way to
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
336 ;; test for it without just running make-frame. I'll just
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
337 ;; let it not work for now... someone will complain eventually
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
338 ;; and I'll think of something.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
339 (defun vm-multiple-frames-possible-p ()
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
340 (or (and (boundp 'window-system) (not (eq window-system nil)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
341 (and (fboundp 'device-type) (eq (device-type) 'x))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
342
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
343 (defun vm-mouse-support-possible-p ()
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
344 (vm-multiple-frames-possible-p))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (defun vm-menu-support-possible-p ()
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
347 (or (and (boundp 'window-system)
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
348 (or (eq window-system 'x)
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
349 (eq window-system 'win32)))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
350 (and (fboundp 'device-type) (eq (device-type) 'x))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
351
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (defun vm-toolbar-support-possible-p ()
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
353 (and (vm-xemacs-p)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
354 (vm-multiple-frames-possible-p)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
355 (featurep 'toolbar)))
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
356
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (defun vm-run-message-hook (message &optional hook-variable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (set-buffer (vm-buffer-of message))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (vm-save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (narrow-to-region (vm-headers-of message) (vm-text-end-of message))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (run-hooks hook-variable)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (defun vm-error-free-call (function &rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (apply function args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (error nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
371 (put 'beginning-of-folder 'error-conditions '(beginning-of-folder error))
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
372 (put 'beginning-of-folder 'error-message "Beginning of folder")
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
373 (put 'end-of-folder 'error-conditions '(end-of-folder error))
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
374 (put 'end-of-folder 'error-message "End of folder")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (defun vm-trace (&rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (set-buffer (get-buffer-create "*vm-trace*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (apply 'insert args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (defun vm-timezone-make-date-sortable (string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (or (cdr (assq string vm-sortable-date-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (let ((vect (vm-parse-date string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (date (vm-parse (current-time-string) " *\\([^ ]+\\)")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 ;; if specified date is incomplete fill in the holes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 ;; with useful information, defaulting to the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 ;; date and timezone for everything except hh:mm:ss which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 ;; defaults to midnight.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (if (equal (aref vect 1) "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (aset vect 1 (nth 2 date)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (if (equal (aref vect 2) "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (aset vect 2 (nth 1 date)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (if (equal (aref vect 3) "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (aset vect 3 (nth 4 date)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (if (equal (aref vect 4) "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (aset vect 4 "00:00:00"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (if (equal (aref vect 5) "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (aset vect 5 (vm-current-time-zone)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 ;; save this work so we won't have to do it again
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (setq vm-sortable-date-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (cons (cons string
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
402 (timezone-make-date-sortable
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
403 (format "%s %s %s %s %s"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
404 (aref vect 1)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
405 (aref vect 2)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
406 (aref vect 3)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
407 (aref vect 4)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
408 (aref vect 5))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 vm-sortable-date-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 ;; return result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (cdr (car vm-sortable-date-alist)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (defun vm-current-time-zone ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (or (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (let* ((zone (car (current-time-zone)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (absmin (/ (vm-abs zone) 60)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (format "%c%02d%02d" (if (< zone 0) ?- ?+)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (/ absmin 60) (% absmin 60)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (let ((temp-buffer nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (setq temp-buffer (generate-new-buffer "*vm-work*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (set-buffer temp-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 (call-process "date" nil temp-buffer nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (nth 4 (vm-parse (vm-buffer-string-no-properties)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 " *\\([^ ]+\\)")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (and temp-buffer (kill-buffer temp-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (error nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (defun vm-should-generate-summary ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (cond ((eq vm-startup-with-summary t) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 ((integerp vm-startup-with-summary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (let ((n vm-startup-with-summary))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (cond ((< n 0) (null (nth (vm-abs n) vm-message-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (t (nth (1- n) vm-message-list)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (vm-startup-with-summary t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (t nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (defun vm-find-composition-buffer (&optional not-picky)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (let ((b-list (buffer-list)) choice alternate)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (while b-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (set-buffer (car b-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (if (eq major-mode 'mail-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (if (buffer-modified-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (setq choice (current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 b-list nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 (and not-picky (null alternate)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (setq alternate (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (setq b-list (cdr b-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (setq b-list (cdr b-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (or choice alternate))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (defun vm-get-file-buffer (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 "Like get-file-buffer, but also checks buffers against FILE's truename"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (or (get-file-buffer file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (and (fboundp 'file-truename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (get-file-buffer (file-truename file)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (defun vm-set-region-face (start end face)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
464 (cond ((fboundp 'make-overlay)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
465 (let ((o (make-overlay start end)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
466 (overlay-put o 'face face)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
467 ((fboundp 'make-extent)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
468 (let ((o (make-extent start end)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
469 (set-extent-property o 'face face)))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
470
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
471 (defun vm-unsaved-message (&rest args)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
472 (let ((message-log-max nil))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
473 (apply (function message) args)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (defun vm-default-buffer-substring-no-properties (beg end &optional buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (let ((s (if buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (buffer-substring beg end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (buffer-substring beg end))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (set-text-properties 0 (length s) nil s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (copy-sequence s)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (fset 'vm-buffer-substring-no-properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (cond ((fboundp 'buffer-substring-no-properties)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (function buffer-substring-no-properties))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
487 ((vm-xemacs-p)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (function buffer-substring))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (t (function vm-default-buffer-substring-no-properties))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (defun vm-buffer-string-no-properties ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 (vm-buffer-substring-no-properties (point-min) (point-max)))