annotate lisp/vm/vm-misc.el @ 98:0d2f883870bc r20-1b1

Import from CVS: tag r20-1b1
author cvs
date Mon, 13 Aug 2007 09:13:56 +0200
parents c0c698873ce1
children 4be1180a9e89
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
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2 ;;; Copyright (C) 1989-1997 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
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
134 (defun vm-check-for-killed-presentation ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
135 (and (bufferp vm-presentation-buffer-handle)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
136 (null (buffer-name vm-presentation-buffer-handle))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
137 (progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
138 (setq vm-presentation-buffer-handle nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
139 vm-presentation-buffer nil))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
140
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (defun vm-check-for-killed-folder ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (and (bufferp vm-mail-buffer) (null (buffer-name vm-mail-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (setq vm-mail-buffer nil)))
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-folder-read-only ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 '(while vm-folder-read-only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (signal 'folder-read-only (list (current-buffer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
149 (put 'folder-read-only 'error-conditions '(folder-read-only error))
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
150 (put 'folder-read-only 'error-message "Folder is read-only")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (defmacro vm-error-if-virtual-folder ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 '(and (eq major-mode 'vm-virtual-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (error "%s cannot be applied to virtual folders." this-command)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (defmacro vm-build-threads-if-unbuilt ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 '(if (null vm-thread-obarray)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (vm-build-threads nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (defun vm-abs (n) (if (< n 0) (- n) n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 ;; save-restriction flubs restoring the clipping region if you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 ;; (widen) and modify text outside the old region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 ;; This should do it right.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (defmacro vm-save-restriction (&rest forms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (let ((vm-sr-clip (make-symbol "vm-sr-clip"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (vm-sr-min (make-symbol "vm-sr-min"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (vm-sr-max (make-symbol "vm-sr-max")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (list 'let (list (list vm-sr-clip '(> (buffer-size)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (- (point-max) (point-min))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 ;; this shouldn't be necessary but the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 ;; byte-compiler turns these into interned symbols
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 ;; which utterly defeats the purpose of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 ;; make-symbol calls above. Soooo, until the compiler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 ;; is fixed, these must be made into (let ...)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 ;; temporaries so that nested calls to this macros
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 ;; won't misbehave.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 vm-sr-min vm-sr-max)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (list 'and vm-sr-clip
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (list 'setq vm-sr-min '(set-marker (make-marker) (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (list 'setq vm-sr-max '(set-marker (make-marker) (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (list 'unwind-protect (cons 'progn forms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 '(widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (list 'and vm-sr-clip
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (list 'progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (list 'narrow-to-region vm-sr-min vm-sr-max)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (list 'set-marker vm-sr-min nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (list 'set-marker vm-sr-max nil)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (defmacro vm-save-buffer-excursion (&rest forms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (list 'let '((vm-sbe-buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (list 'unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (cons 'progn forms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 '(and (not (eq vm-sbe-buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (buffer-name vm-sbe-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (set-buffer vm-sbe-buffer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (defun vm-last (list) (while (cdr-safe list) (setq list (cdr list))) list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (defun vm-vector-to-list (vector)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (let ((i (1- (length vector)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (while (>= i 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (setq list (cons (aref vector i) list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (vm-decrement i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 list ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (defun vm-extend-vector (vector length &optional fill)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (let ((vlength (length vector)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (if (< vlength length)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (apply 'vector (nconc (vm-vector-to-list vector)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (make-list (- length vlength) fill)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 vector )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
215 (defun vm-obarray-to-string-list (obarray)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (let ((list nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (mapatoms (function (lambda (s) (setq list (cons (symbol-name s) list))))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
218 obarray)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 list ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (defun vm-mapcar (function &rest lists)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (let (arglist result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (while (car lists)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (setq arglist (mapcar 'car lists))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (setq result (cons (apply function arglist) result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (setq lists (mapcar 'cdr lists)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (nreverse result)))
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-mapc (function &rest lists)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (let (arglist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (while (car lists)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (setq arglist (mapcar 'car lists))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (apply function arglist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (setq lists (mapcar 'cdr lists)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (defun vm-delete (predicate list &optional reverse)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (let ((p list) (reverse (if reverse 'not 'identity)) prev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (while p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (if (funcall reverse (funcall predicate (car p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (if (null prev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (setq list (cdr list) p list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (setcdr prev (cdr p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (setq p (cdr p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (setq prev p p (cdr p))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 list ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
247 (defun vm-delete-directory-file-names (list)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
248 (vm-delete 'file-directory-p list))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
249
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
250 (defun vm-delete-backup-file-names (list)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
251 (vm-delete 'backup-file-name-p list))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
252
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
253 (defun vm-delete-auto-save-file-names (list)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
254 (vm-delete 'auto-save-file-name-p list))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
255
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (defun vm-delete-duplicates (list &optional all hack-addresses)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 "Delete duplicate equivalent strings from the list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 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
259 then all occurrences of it are removed instead of just the subsequent ones.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 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
261 and only the address part is compared (so that \"Name <foo>\" and \"foo\"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 would be considered to be equivalent.)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (let ((hashtable vm-delete-duplicates-obarray)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (new-list nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 sym-string sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (fillarray hashtable 0)
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 (setq sym-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (if hack-addresses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (nth 1 (funcall vm-chop-full-name-function (car list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (car list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 sym (intern sym-string hashtable))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (if (boundp sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (and all (setcar (symbol-value sym) nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (setq new-list (cons (car list) new-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (set sym new-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (setq list (cdr list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (delq nil (nreverse new-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (defun vm-member-0 (thing list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (catch 'done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (while list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (and (equal (car list) thing)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (throw 'done list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (setq list (cdr list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 nil ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (fset 'vm-member (symbol-function (if (fboundp 'member) 'member 'vm-member-0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (defun vm-delqual (ob list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (let ((prev nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (curr list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (while curr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (if (not (equal ob (car curr)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (setq prev curr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 curr (cdr curr))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (if (null prev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (setq list (cdr list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 curr list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (setq curr (cdr curr))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (setcdr prev curr))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 list ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (defun vm-copy-local-variables (buffer &rest variables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (let ((values (mapcar 'symbol-value variables)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (vm-mapc 'set variables values))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
310 (put 'folder-empty 'error-conditions '(folder-empty error))
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
311 (put 'folder-empty 'error-message "Folder is empty")
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
312 (put 'unrecognized-folder-type 'error-conditions
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
313 '(unrecognized-folder-type error))
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
314 (put 'unrecognized-folder-type 'error-message "Unrecognized folder type")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (defun vm-error-if-folder-empty ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (while (null vm-message-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (if vm-folder-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (signal 'unrecognized-folder-type nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (signal 'folder-empty nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (defun vm-copy (object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (cond ((consp object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (let (return-value cons)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (setq return-value (cons (vm-copy (car object)) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 cons return-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 object (cdr object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (while (consp object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (setcdr cons (cons (vm-copy (car object)) nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (setq cons (cdr cons)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 object (cdr object)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (setcdr cons object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 return-value ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 ((vectorp object) (apply 'vector (mapcar 'vm-copy object)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 ((stringp object) (copy-sequence object))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
336 ((markerp object) (copy-marker object))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (t object)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
339 (defun vm-xemacs-p ()
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
340 (let ((case-fold-search nil))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
341 (string-match "XEmacs" emacs-version)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
342
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
343 (defun vm-xemacs-mule-p ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
344 (and (vm-xemacs-p)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
345 (fboundp 'set-file-coding-system)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
346 (fboundp 'decode-coding-region)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
347
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
348 (defun vm-fsfemacs-19-p ()
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
349 (and (string-match "^19" emacs-version)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
350 (not (string-match "XEmacs\\|Lucid" emacs-version))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
351
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
352 ;; make-frame might be defined and still not work. This would
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
353 ;; 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
354 ;; 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
355 ;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
356 ;; 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
357 ;; 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
358 ;; test for it without just running make-frame. I'll just
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
359 ;; let it not work for now... someone will complain eventually
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
360 ;; and I'll think of something.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
361 (defun vm-multiple-frames-possible-p ()
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
362 (or (and (boundp 'window-system) (not (eq window-system nil)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
363 (and (fboundp 'device-type) (eq (device-type) 'x))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
364
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
365 (defun vm-mouse-support-possible-p ()
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
366 (vm-multiple-frames-possible-p))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (defun vm-menu-support-possible-p ()
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
369 (or (and (boundp 'window-system)
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
370 (or (eq window-system 'x)
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
371 (eq window-system 'win32)))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
372 (and (fboundp 'device-type) (eq (device-type) 'x))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
373
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (defun vm-toolbar-support-possible-p ()
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
375 (and (vm-xemacs-p)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
376 (vm-multiple-frames-possible-p)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
377 (featurep 'toolbar)))
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
378
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (defun vm-run-message-hook (message &optional hook-variable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (set-buffer (vm-buffer-of message))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (vm-save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (narrow-to-region (vm-headers-of message) (vm-text-end-of message))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (run-hooks hook-variable)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (defun vm-error-free-call (function &rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (apply function args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (error nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
393 (put 'beginning-of-folder 'error-conditions '(beginning-of-folder error))
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
394 (put 'beginning-of-folder 'error-message "Beginning of folder")
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
395 (put 'end-of-folder 'error-conditions '(end-of-folder error))
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
396 (put 'end-of-folder 'error-message "End of folder")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (defun vm-trace (&rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (set-buffer (get-buffer-create "*vm-trace*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (apply 'insert args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (defun vm-timezone-make-date-sortable (string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (or (cdr (assq string vm-sortable-date-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (let ((vect (vm-parse-date string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (date (vm-parse (current-time-string) " *\\([^ ]+\\)")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 ;; if specified date is incomplete fill in the holes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 ;; with useful information, defaulting to the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 ;; date and timezone for everything except hh:mm:ss which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 ;; defaults to midnight.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (if (equal (aref vect 1) "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (aset vect 1 (nth 2 date)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (if (equal (aref vect 2) "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (aset vect 2 (nth 1 date)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (if (equal (aref vect 3) "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (aset vect 3 (nth 4 date)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (if (equal (aref vect 4) "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (aset vect 4 "00:00:00"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (if (equal (aref vect 5) "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (aset vect 5 (vm-current-time-zone)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 ;; save this work so we won't have to do it again
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (setq vm-sortable-date-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (cons (cons string
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
424 (timezone-make-date-sortable
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
425 (format "%s %s %s %s %s"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
426 (aref vect 1)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
427 (aref vect 2)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
428 (aref vect 3)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
429 (aref vect 4)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
430 (aref vect 5))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 vm-sortable-date-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 ;; return result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (cdr (car vm-sortable-date-alist)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (defun vm-current-time-zone ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (or (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (let* ((zone (car (current-time-zone)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (absmin (/ (vm-abs zone) 60)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (format "%c%02d%02d" (if (< zone 0) ?- ?+)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (/ absmin 60) (% absmin 60)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (let ((temp-buffer nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (setq temp-buffer (generate-new-buffer "*vm-work*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (set-buffer temp-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (call-process "date" nil temp-buffer nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (nth 4 (vm-parse (vm-buffer-string-no-properties)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 " *\\([^ ]+\\)")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 (and temp-buffer (kill-buffer temp-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (error nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (defun vm-should-generate-summary ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (cond ((eq vm-startup-with-summary t) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 ((integerp vm-startup-with-summary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (let ((n vm-startup-with-summary))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (cond ((< n 0) (null (nth (vm-abs n) vm-message-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (t (nth (1- n) vm-message-list)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (vm-startup-with-summary t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (t nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (defun vm-find-composition-buffer (&optional not-picky)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (let ((b-list (buffer-list)) choice alternate)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (while b-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (set-buffer (car b-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (if (eq major-mode 'mail-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (if (buffer-modified-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (setq choice (current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 b-list nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (and not-picky (null alternate)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (setq alternate (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (setq b-list (cdr b-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (setq b-list (cdr b-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (or choice alternate))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (defun vm-get-file-buffer (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 "Like get-file-buffer, but also checks buffers against FILE's truename"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (or (get-file-buffer file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (and (fboundp 'file-truename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (get-file-buffer (file-truename file)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (defun vm-set-region-face (start end face)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
486 (cond ((fboundp 'make-overlay)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
487 (let ((o (make-overlay start end)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
488 (overlay-put o 'face face)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
489 ((fboundp 'make-extent)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
490 (let ((o (make-extent start end)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
491 (set-extent-property o 'face face)))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
492
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
493 (defun vm-unsaved-message (&rest args)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
494 (let ((message-log-max nil))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
495 (apply (function message) args)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (defun vm-default-buffer-substring-no-properties (beg end &optional buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (let ((s (if buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (buffer-substring beg end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (buffer-substring beg end))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (set-text-properties 0 (length s) nil s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (copy-sequence s)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (fset 'vm-buffer-substring-no-properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (cond ((fboundp 'buffer-substring-no-properties)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (function buffer-substring-no-properties))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
509 ((vm-xemacs-p)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (function buffer-substring))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (t (function vm-default-buffer-substring-no-properties))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (defun vm-buffer-string-no-properties ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (vm-buffer-substring-no-properties (point-min) (point-max)))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
515
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
516 (defun vm-insert-region-from-buffer (buffer &optional start end)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
517 (let ((target-buffer (current-buffer)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
518 (set-buffer buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
519 (save-restriction
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
520 (widen)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
521 (or start (setq start (point-min)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
522 (or end (setq end (point-max)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
523 (set-buffer target-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
524 (insert-buffer-substring buffer start end)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
525 (set-buffer buffer))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
526 (set-buffer target-buffer)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
527
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
528 (if (fboundp 'overlay-get)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
529 (fset 'vm-extent-property 'overlay-get)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
530 (fset 'vm-extent-property 'extent-property))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
531
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
532 (if (fboundp 'overlay-put)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
533 (fset 'vm-set-extent-property 'overlay-put)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
534 (fset 'vm-set-extent-property 'set-extent-property))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
535
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
536 (if (fboundp 'make-overlay)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
537 (fset 'vm-make-extent 'make-overlay)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
538 (fset 'vm-make-extent 'make-extent))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
539
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
540 (if (fboundp 'overlay-end)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
541 (fset 'vm-extent-end-position 'overlay-end)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
542 (fset 'vm-extent-end-position 'extent-end-position))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
543
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
544 (if (fboundp 'overlay-start)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
545 (fset 'vm-extent-start-position 'overlay-start)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
546 (fset 'vm-extent-start-position 'extent-start-position))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
547
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
548 (if (fboundp 'delete-overlay)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
549 (fset 'vm-detach-extent 'delete-overlay)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
550 (fset 'vm-detach-extent 'detach-extent))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
551
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
552 (if (fboundp 'overlay-properties)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
553 (fset 'vm-extent-properties 'overlay-properties)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
554 (fset 'vm-extent-properties 'extent-properties))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
555
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
556 (defun vm-copy-extent (e)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
557 (let ((props (vm-extent-properties e))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
558 (ee (vm-make-extent (vm-extent-start-position e)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
559 (vm-extent-end-position e))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
560 (while props
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
561 (vm-set-extent-property ee (car props) (car (cdr props)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
562 (setq props (cdr props)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
563
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
564 (defun vm-make-tempfile-name ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
565 (let ((done nil) (pid (emacs-pid)) filename)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
566 (while (not done)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
567 (setq filename (format "%s/vm%d.%d" vm-temp-file-directory pid
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
568 vm-tempfile-counter)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
569 vm-tempfile-counter (1+ vm-tempfile-counter)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
570 done (not (file-exists-p filename))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
571 filename ))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
572
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
573 (defun vm-insert-char (char &optional count ignored buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
574 (condition-case nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
575 (progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
576 (insert-char char count ignored buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
577 (fset 'vm-insert-char 'insert-char))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
578 (wrong-number-of-arguments
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
579 (fset 'vm-insert-char 'vm-xemacs-compatible-insert-char)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
580 (vm-insert-char char count ignored buffer))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
581
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
582 (defun vm-xemacs-compatible-insert-char (char &optional count ignored buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
583 (if (and buffer (eq buffer (current-buffer)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
584 (insert-char char count)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
585 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
586 (set-buffer buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
587 (insert-char char count))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
588
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
589 (defun vm-symbol-lists-intersect-p (list1 list2)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
590 (catch 'done
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
591 (while list1
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
592 (and (memq (car list1) list2)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
593 (throw 'done t))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
594 (setq list1 (cdr list1)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
595 nil ))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
596
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
597 (defun vm-set-buffer-variable (buffer var value)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
598 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
599 (set-buffer buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
600 (set var value)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
601
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
602 (defsubst vm-with-string-as-temp-buffer (string function)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
603 (let ((work-buffer nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
604 (unwind-protect
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
605 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
606 (setq work-buffer (generate-new-buffer " *work*"))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
607 (set-buffer work-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
608 (insert string)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
609 (funcall function)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
610 (buffer-string))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
611 (and work-buffer (kill-buffer work-buffer)))))