~vm/vm/vmpc-prompt

528 by Robert Widhopf-Fenk
Improved text/html handling.
1
;;; vm-w3.el --- additional functions to make VM use w3 for HTML mails
904 by Uday S Reddy
Resolved circular requires in the byte compiler by moving provides to the top.
2
;;
3
;; This file is part of VM
695 by udr
Added a note in each file indicating whether it is part of VM.
4
;;
528 by Robert Widhopf-Fenk
Improved text/html handling.
5
;; Copyright (C) 2008 Robert Widhopf-Fenk
695 by udr
Added a note in each file indicating whether it is part of VM.
6
;;
528 by Robert Widhopf-Fenk
Improved text/html handling.
7
;; This program is free software; you can redistribute it and/or modify
8
;; it under the terms of the GNU General Public License as published by
9
;; the Free Software Foundation; either version 2, or (at your option)
10
;; any later version.
11
12
;; This program is distributed in the hope that it will be useful,
13
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
15
;; GNU General Public License for more details.
16
17
;; You should have received a copy of the GNU General Public License
18
;; along with this program; if not, write to the Free Software
19
;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20
;; 02110-1301, USA.
21
22
;;; Commentary:
23
24
;; You need to have w3 installed for this module to work.
25
26
;;; Code:
27
28
(eval-when-compile
29
  (require 'cl)
30
  (require 'advice)
31
  (require 'vm-mime)
932 by Uday S Reddy
More updates to info. Removed reduandant requires for files already loaded via vm-build.el.
32
)
528 by Robert Widhopf-Fenk
Improved text/html handling.
33
538 by Robert Widhopf-Fenk
Added new function `vm-load-features' which tries loading of features.
34
(eval-and-compile
35
  (vm-load-features '(w3)))
528 by Robert Widhopf-Fenk
Improved text/html handling.
36
904 by Uday S Reddy
Resolved circular requires in the byte compiler by moving provides to the top.
37
(declare-function w3-region "ext:w3-display.el" (st nd))
38
528 by Robert Widhopf-Fenk
Improved text/html handling.
39
(defvar vm-w3-text/html-message nil
40
  "The currently displayed message.")
41
653.1.48 by udr
Further supression of compiler warnings
42
(defvar url-working-buffer)
43
(defvar url-current-content-length)
44
(defvar url-current-mime-encoding)
45
(defvar url-current-mime-type)
46
(defvar url-current-mime-headers)
47
528 by Robert Widhopf-Fenk
Improved text/html handling.
48
(defun vm-w3-cid-retrieve (url)
49
  "Insert content of URL."
50
  (set-buffer (get-buffer-create url-working-buffer))
51
  (let ((part (vm-mime-cid-retrieve url vm-w3-text/html-message))
52
        type encoding)
53
    (setq type (car (vm-mm-layout-type part)))
54
    (setq encoding (vm-mm-layout-encoding part))
55
    (if (= 0 (length type)) (setq type "text/plain"))
56
    (if (= 0 (length encoding)) (setq encoding "8bit"))
57
    (setq url-current-content-length (point-max)
58
          url-current-mime-type type
59
          url-current-mime-encoding encoding
60
          url-current-mime-headers (list (cons "content-type" type)
61
                                         (cons "content-encoding" encoding)))))
62
63
(defadvice url-cid (around vm-w3 activate)
64
  (if nil;(not vm-w3-text/html-message)
65
      ad-do-it
66
    (vm-w3-cid-retrieve (ad-get-arg 0))))
67
68
;;;###autoload
1332 by Uday S Reddy
Fixed some bugs in the use of emacs-w3 for html handling. Added ANSI_X3.4 to vm-mime-default-face-charsets.
69
(defun vm-mime-display-internal-emacs-w3-text/html (start end layout)
528 by Robert Widhopf-Fenk
Improved text/html handling.
70
  (setq vm-w3-text/html-message (vm-mm-layout-message layout))
71
  (let nil;((vm-w3-text/html-message (vm-mm-layout-message layout)))
72
    (w3-region start (1- end)))
73
  ;; remove read-only text properties
74
  (let ((inhibit-read-only t))
75
    (remove-text-properties start end '(read-only nil))))