forked from emacs-w3m/emacs-w3m
/
TIPS
188 lines (147 loc) · 5.77 KB
/
TIPS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
** browse-url
By following setting, "C-x m" on URL like string calls emacs-w3m. And
you can preview HTML file by "C-c C-v" on html-mode which is
distributed with Emacs21.
(setq browse-url-browser-function 'w3m-browse-url)
(autoload 'w3m-browse-url "w3m" "Ask a WWW browser to show a URL." t)
(global-set-key "\C-xm" 'browse-url-at-point)
If you want to use the other browser than emacs-w3m when "C-x m" is
typed in w3m-mode buffers, you can put the following setting to your
~/.emacs.
(defadvice browse-url-at-point
(around change-browse-url-browser-function activate compile)
(let ((browse-url-browser-function
(if (eq major-mode 'w3m-mode)
'browse-url-netscape
'w3m-browse-url)))
ad-do-it))
** dired
By "C-x m" on a html file in dired-mode, you can open it by
emacs-w3m.
(add-hook 'dired-mode-hook
(lambda ()
(define-key dired-mode-map "\C-xm" 'dired-w3m-find-file)))
(defun dired-w3m-find-file ()
(interactive)
(require 'w3m)
(let ((file (dired-get-filename)))
(if (y-or-n-p (format "Open 'w3m' %s " (file-name-nondirectory file)))
(w3m-find-file file))))
** hnf-mode
With the following setting, you can see the newest diary via
emacs-w3m by "C-c C-b" in hnf-mode.
(autoload 'w3m-browse-url "w3m" nil t)
(defun w3m-hnf-browse-url-w3m (url &optional new-window)
(interactive (browse-url-interactive-arg "URL: "))
(save-selected-window
(pop-to-buffer (get-buffer-create "*w3m*"))
(w3m-browse-url url new-window)))
(setq hnf-browse-url-browser-function (function w3m-hnf-browse-url-w3m))
** Gnus
Even if you are using Oort Gnus, Gnus v5.8.8 or v5.9, you may read
some news articles using nnshimbun. To do that, copy nnshimbun.el
from the newest T-gnus 6.15 to Gnus' lisp/ directory and then simply
invoke "make install". In addition, fortunately, if you are using
Oort Gnus v0.06 or later, you only have to add the following line in
your .gnus file to make Gnus show text/html contents using emacs-w3m
instead of Emacs/w3.
(setq mm-text-html-renderer 'w3m)
Otherwise, try the following. They aren't as good as Oort Gnus v0.06
or later will do, though.
;; From: greg@visiontech-dml.com
;; Newsgroups: gnu.emacs.help
;; Subject: Re: w3m-mode and images
;; Date: 19 Jul 2001 10:59:19 +0300
;; Message-ID: <2fasnftcpt4.fsf@broadcom.com>
;; Modified to make it work even if w3 has not installed in the system
;; based on the diary of SHIMADA Mitsunobu, 09 Jan 2002.
(defvar gnus-w3m-minor-mode nil)
(defvar mm-inline-text-html-with-images nil
"*If non-nil, Gnus will allow retrieving images in the HTML contents
with <img> tags.")
(make-variable-buffer-local 'gnus-w3m-minor-mode)
(add-to-list 'minor-mode-alist '(gnus-w3m-minor-mode " w3m"))
(eval-after-load "w3m"
'(add-to-list 'minor-mode-map-alist
(cons 'gnus-w3m-minor-mode w3m-mode-map)))
(eval-after-load "mm-decode"
'(let ((test (nthcdr 2 (assoc "text/html" mm-inline-media-tests))))
(if test
(setcar test (lambda (handle) (locate-library "w3m"))))))
(defadvice mm-inline-text (around use-w3m-instead (handle) activate)
(let ((type (mm-handle-media-subtype handle)))
(if (not (equal type "html"))
ad-do-it
(require 'w3m)
(let ((text (mm-get-part handle))
(b (point))
(charset (mail-content-type-get (mm-handle-type handle)
'charset)))
(save-excursion
(insert text)
(save-restriction
(narrow-to-region b (point))
(goto-char (point-min))
(if (re-search-forward w3m-meta-content-type-charset-regexp
nil t)
(setq charset
(or (w3m-charset-to-coding-system (match-string 2))
charset)))
(if charset
(progn
(delete-region (point-min) (point-max))
(insert (mm-decode-string text charset))))
(let ((w3m-safe-url-regexp "\\`cid:")
(w3m-display-inline-images mm-inline-text-html-with-images))
(w3m-region (point-min) (point-max)))
(setq gnus-w3m-minor-mode t))
(mm-handle-set-undisplayer
handle
`(lambda ()
(let (buffer-read-only)
(setq gnus-w3m-minor-mode nil)
(if (functionp 'remove-specifier)
(mapcar (lambda (prop)
(remove-specifier
(face-property 'default prop)
(current-buffer)))
'(background background-pixmap foreground)))
(delete-region ,(point-min-marker)
,(point-max-marker))))))))))
By default, Gnus will not apply the treatment variables, for instance
`gnus-treat-strip-banner', to text/html parts. To have them applied
to text/html parts automatically, there are two ways to do that:
;; Apply all the treatments to text/html parts.
(eval-after-load "gnus-art"
'(add-to-list 'gnus-article-treat-types "text/html"))
;; Apply a certain treatment to text/html parts.
(setq gnus-treat-strip-banner '(or t (typep "text/html")))
See info ``Customizing Articles'' for details.
In additon, the experimental code below is used to display
multipart/related pictures. The place might be something wrong :-<
;; Date: Fri, 27 Jul 2001 12:51:12 +0900
;; Message-ID: <yosuwv4v3u8f.fsf@jpl.org>
;; From: Katsumi Yamaoka <yamaoka@jpl.org>
;; To: semi-gnus-ja@meadowy.org
;; Subject: [nnshimbun] toggle inline images
(eval-after-load "gnus-art"
'(or (assoc "multipart/related" gnus-mime-multipart-functions)
(setq gnus-mime-multipart-functions
(cons
(cons
"multipart/related"
(byte-compile
(lambda (handle)
(gnus-mime-display-mixed (cdr handle)))))
gnus-mime-multipart-functions))))
** yahtml-mode
You can preview the html file with emacs-w3m, which you are editing
in yahtml-mode.
(autoload 'w3m-goto-url "w3m")
(defadvice yahtml-browse-html
(around w3m-yahtml-browse-html activate compile)
(w3m-goto-url (ad-get-arg 0) t))
Local Variables:
mode: indented-text
fill-column: 72
End: