15
15
;;; along with this program; if not, write to the Free Software
16
16
;;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
20
(defun vm-delete-non-matching-strings (regexp list &optional destructively)
21
21
"Delete strings matching REGEXP from LIST.
36
36
(setq curr (cdr curr)))))
39
(defun vm-parse (string regexp &optional matchn)
39
(defun vm-parse (string regexp &optional matchn matches)
40
40
(or matchn (setq matchn 1))
42
42
(store-match-data nil)
43
(while (string-match regexp string (match-end 0))
43
(while (and (not (eq matches 0))
44
(string-match regexp string (match-end 0)))
45
(and (integerp matches) (setq matches (1- matches)))
44
46
(if (not (consp matchn))
45
47
(setq list (cons (substring string (match-beginning matchn)
46
48
(match-end matchn)) list))
52
54
(match-end (car tem))) list)
54
56
(setq tem (cdr tem))))))
57
(if (and (integerp matches) (match-end 0)
58
(not (eq (match-end 0) (length string))))
59
(setq list (cons (substring string (match-end 0) (length string))
57
63
(defun vm-parse-addresses (string)
201
206
;; correct for VM's uses of this function---
202
207
;; writing out message separators
203
208
(setq buffer-file-type nil)
204
;; Tell MULE to pick the correct newline conversion.
205
(if (fboundp 'set-buffer-file-coding-system)
206
(set-buffer-file-coding-system
207
(vm-line-ending-coding-system) nil))
208
209
(write-region (point-min) (point-max) where t 'quiet))
209
210
(and temp-buffer (kill-buffer temp-buffer))))))
605
606
(vm-set-extent-property ee (car props) (car (cdr props)))
606
607
(setq props (cdr (cdr props))))))
608
(defun vm-make-tempfile (&optional filename-suffix)
609
(defun vm-make-tempfile (&optional filename-suffix proposed-filename)
609
610
(let ((modes (default-file-modes))
610
(file (vm-make-tempfile-name filename-suffix)))
611
(file (vm-make-tempfile-name filename-suffix proposed-filename)))
614
(set-default-file-modes (* 6 8 8))
614
(set-default-file-modes (vm-octal 600))
615
615
(vm-error-free-call 'delete-file file)
616
616
(write-region (point) (point) file nil 0))
617
617
(set-default-file-modes modes))
620
(defun vm-make-tempfile-name (&optional filename-suffix)
621
(let ((done nil) filename)
623
(setq filename (convert-standard-filename
624
(expand-file-name (format "vm%d%d%s"
627
(or filename-suffix ""))
628
vm-temp-file-directory))
629
vm-tempfile-counter (1+ vm-tempfile-counter)
630
done (not (file-exists-p filename))))
620
(defun vm-make-tempfile-name (&optional filename-suffix proposed-filename)
622
(cond ((and (stringp proposed-filename)
624
(setq filename (convert-standard-filename
627
vm-temp-file-directory))))))
629
((stringp proposed-filename)
632
(setq filename (convert-standard-filename
637
vm-temp-file-directory))
638
vm-tempfile-counter (1+ vm-tempfile-counter)
639
done (not (file-exists-p filename))))))
643
(setq filename (convert-standard-filename
648
(or filename-suffix ""))
649
vm-temp-file-directory))
650
vm-tempfile-counter (1+ vm-tempfile-counter)
651
done (not (file-exists-p filename)))))))
633
654
(defun vm-make-work-buffer (&optional name)
764
785
(fset 'vm-coding-system-name 'symbol-name)))
787
(defun vm-get-file-line-ending-coding-system (file)
788
(if (not (or vm-fsfemacs-mule-p vm-xemacs-mule-p vm-xemacs-file-coding-p))
790
(let ((coding-system-for-read (vm-binary-coding-system))
794
(setq work-buffer (vm-make-work-buffer))
795
(set-buffer work-buffer)
797
(insert-file-contents file nil 0 4096)
799
(goto-char (point-min))
800
(cond ((re-search-forward "[^\r]\n" nil t)
801
(if vm-fsfemacs-mule-p 'raw-text-unix 'no-conversion-unix))
802
((re-search-forward "\r[^\n]" nil t)
803
(if vm-fsfemacs-mule-p 'raw-text-mac 'no-conversion-mac))
804
((search-forward "\r\n" nil t)
805
(if vm-fsfemacs-mule-p 'raw-text-dos 'no-conversion-dos))
806
(t (vm-line-ending-coding-system))))
807
(and work-buffer (kill-buffer work-buffer))))))
809
(defun vm-new-folder-line-ending-coding-system ()
810
(cond ((eq vm-default-new-folder-line-ending-type nil)
811
(vm-line-ending-coding-system))
812
((eq vm-default-new-folder-line-ending-type 'lf)
813
(if vm-fsfemacs-mule-p 'raw-text-unix 'no-conversion-unix))
814
((eq vm-default-new-folder-line-ending-type 'crlf)
815
(if vm-fsfemacs-mule-p 'raw-text-dos 'no-conversion-dos))
816
((eq vm-default-new-folder-line-ending-type 'cr)
817
(if vm-fsfemacs-mule-p 'raw-text-mac 'no-conversion-mac))
819
(vm-line-ending-coding-system))))
766
821
(defun vm-collapse-whitespace ()
767
822
(goto-char (point-min))
768
823
(while (re-search-forward "[ \t\n]+" nil 0)
849
904
(vm-with-string-as-temp-buffer string 'vm-url-decode-buffer))
851
906
(defun vm-url-decode-buffer ()
852
(let ((case-fold-search nil)
907
(let ((case-fold-search t)
853
908
(hex-digit-alist '((?0 . 0) (?1 . 1) (?2 . 2) (?3 . 3)
854
909
(?4 . 4) (?5 . 5) (?6 . 6) (?7 . 7)
855
910
(?8 . 8) (?9 . 9) (?A . 10) (?B . 11)