annotate lisp/vm/vm-misc.el @ 0:376386a54a3c r19-14

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