eww: machinery to list browser history
[bpt/emacs.git] / lisp / net / eww.el
1 ;;; eww.el --- Emacs Web Wowser
2
3 ;; Copyright (C) 2013 Free Software Foundation, Inc.
4
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; Keywords: html
7
8 ;; This file is part of GNU Emacs.
9
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
14
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
22
23 ;;; Commentary:
24
25 ;;; Code:
26
27 (eval-when-compile (require 'cl))
28 (require 'format-spec)
29 (require 'shr)
30 (require 'url)
31 (require 'mm-url)
32
33 (defgroup eww nil
34 "Emacs Web Wowser"
35 :version "24.4"
36 :group 'hypermedia
37 :prefix "eww-")
38
39 (defcustom eww-header-line-format "%t: %u"
40 "Header line format.
41 - %t is replaced by the title.
42 - %u is replaced by the URL."
43 :version "24.4"
44 :group 'eww
45 :type 'string)
46
47 (defcustom eww-search-prefix "https://duckduckgo.com/html/?q="
48 "Prefix URL to search engine"
49 :version "24.4"
50 :group 'eww
51 :type 'string)
52
53 (defcustom eww-download-path "~/Downloads/"
54 "Path where files will downloaded."
55 :version "24.4"
56 :group 'eww
57 :type 'string)
58
59 (defcustom eww-use-external-browser-for-content-type
60 "\\`\\(video/\\|audio/\\|application/ogg\\)"
61 "Always use external browser for specified content-type."
62 :version "24.4"
63 :group 'eww
64 :type '(choice (const :tag "Never" nil)
65 regexp))
66
67 (defcustom eww-form-checkbox-selected-symbol "[X]"
68 "Symbol used to represent a selected checkbox.
69 See also `eww-form-checkbox-symbol'."
70 :version "24.4"
71 :group 'eww
72 :type '(choice (const "[X]")
73 (const "☒") ; Unicode BALLOT BOX WITH X
74 (const "☑") ; Unicode BALLOT BOX WITH CHECK
75 string))
76
77 (defcustom eww-form-checkbox-symbol "[ ]"
78 "Symbol used to represent a checkbox.
79 See also `eww-form-checkbox-selected-symbol'."
80 :version "24.4"
81 :group 'eww
82 :type '(choice (const "[ ]")
83 (const "☐") ; Unicode BALLOT BOX
84 string))
85
86 (defface eww-form-submit
87 '((((type x w32 ns) (class color)) ; Like default mode line
88 :box (:line-width 2 :style released-button)
89 :background "#808080" :foreground "black"))
90 "Face for eww buffer buttons."
91 :version "24.4"
92 :group 'eww)
93
94 (defface eww-form-checkbox
95 '((((type x w32 ns) (class color)) ; Like default mode line
96 :box (:line-width 2 :style released-button)
97 :background "lightgrey" :foreground "black"))
98 "Face for eww buffer buttons."
99 :version "24.4"
100 :group 'eww)
101
102 (defface eww-form-select
103 '((((type x w32 ns) (class color)) ; Like default mode line
104 :box (:line-width 2 :style released-button)
105 :background "lightgrey" :foreground "black"))
106 "Face for eww buffer buttons."
107 :version "24.4"
108 :group 'eww)
109
110 (defface eww-form-text
111 '((t (:background "#505050"
112 :foreground "white"
113 :box (:line-width 1))))
114 "Face for eww text inputs."
115 :version "24.4"
116 :group 'eww)
117
118 (defvar eww-current-url nil)
119 (defvar eww-current-dom nil)
120 (defvar eww-current-source nil)
121 (defvar eww-current-title ""
122 "Title of current page.")
123 (defvar eww-history nil)
124 (defvar eww-history-position 0)
125
126 (defvar eww-next-url nil)
127 (defvar eww-previous-url nil)
128 (defvar eww-up-url nil)
129 (defvar eww-home-url nil)
130 (defvar eww-start-url nil)
131 (defvar eww-contents-url nil)
132
133 (defvar eww-local-regex "localhost"
134 "When this regex is found in the URL, it's not a keyword but an address.")
135
136 (defvar eww-link-keymap
137 (let ((map (copy-keymap shr-map)))
138 (define-key map "\r" 'eww-follow-link)
139 map))
140
141 ;;;###autoload
142 (defun eww (url)
143 "Fetch URL and render the page.
144 If the input doesn't look like an URL or a domain name, the
145 word(s) will be searched for via `eww-search-prefix'."
146 (interactive "sEnter URL or keywords: ")
147 (cond ((string-match-p "\\`file:" url))
148 (t
149 (if (and (= (length (split-string url)) 1)
150 (or (> (length (split-string url "\\.")) 1)
151 (string-match eww-local-regex url)))
152 (progn
153 (unless (string-match-p "\\`[a-zA-Z][-a-zA-Z0-9+.]*://" url)
154 (setq url (concat "http://" url)))
155 ;; some site don't redirect final /
156 (when (string= (url-filename (url-generic-parse-url url)) "")
157 (setq url (concat url "/"))))
158 (setq url (concat eww-search-prefix
159 (replace-regexp-in-string " " "+" url))))))
160 (url-retrieve url 'eww-render (list url)))
161
162 ;;;###autoload (defalias 'browse-web 'eww)
163
164 ;;;###autoload
165 (defun eww-open-file (file)
166 "Render a file using EWW."
167 (interactive "fFile: ")
168 (eww (concat "file://" (expand-file-name file))))
169
170 (defun eww-render (status url &optional point)
171 (let ((redirect (plist-get status :redirect)))
172 (when redirect
173 (setq url redirect)))
174 (setq-local eww-next-url nil)
175 (setq-local eww-previous-url nil)
176 (setq-local eww-up-url nil)
177 (setq-local eww-home-url nil)
178 (setq-local eww-start-url nil)
179 (setq-local eww-contents-url nil)
180 (let* ((headers (eww-parse-headers))
181 (content-type
182 (mail-header-parse-content-type
183 (or (cdr (assoc "content-type" headers))
184 "text/plain")))
185 (charset (intern
186 (downcase
187 (or (cdr (assq 'charset (cdr content-type)))
188 (eww-detect-charset (equal (car content-type)
189 "text/html"))
190 "utf8"))))
191 (data-buffer (current-buffer)))
192 (unwind-protect
193 (progn
194 (setq eww-current-title "")
195 (cond
196 ((and eww-use-external-browser-for-content-type
197 (string-match-p eww-use-external-browser-for-content-type
198 (car content-type)))
199 (eww-browse-with-external-browser url))
200 ((equal (car content-type) "text/html")
201 (eww-display-html charset url nil point))
202 ((string-match-p "\\`image/" (car content-type))
203 (eww-display-image)
204 (eww-update-header-line-format))
205 (t
206 (eww-display-raw)
207 (eww-update-header-line-format)))
208 (setq eww-current-url url
209 eww-history-position 0))
210 (kill-buffer data-buffer))))
211
212 (defun eww-parse-headers ()
213 (let ((headers nil))
214 (goto-char (point-min))
215 (while (and (not (eobp))
216 (not (eolp)))
217 (when (looking-at "\\([^:]+\\): *\\(.*\\)")
218 (push (cons (downcase (match-string 1))
219 (match-string 2))
220 headers))
221 (forward-line 1))
222 (unless (eobp)
223 (forward-line 1))
224 headers))
225
226 (defun eww-detect-charset (html-p)
227 (let ((case-fold-search t)
228 (pt (point)))
229 (or (and html-p
230 (re-search-forward
231 "<meta[\t\n\r ]+[^>]*charset=\"?\\([^\t\n\r \"/>]+\\)[\\\"'.*]" nil t)
232 (goto-char pt)
233 (match-string 1))
234 (and (looking-at
235 "[\t\n\r ]*<\\?xml[\t\n\r ]+[^>]*encoding=\"\\([^\"]+\\)")
236 (match-string 1)))))
237
238 (declare-function libxml-parse-html-region "xml.c"
239 (start end &optional base-url))
240
241 (defun eww-display-html (charset url &optional document point)
242 (or (fboundp 'libxml-parse-html-region)
243 (error "This function requires Emacs to be compiled with libxml2"))
244 (unless (eq charset 'utf8)
245 (condition-case nil
246 (decode-coding-region (point) (point-max) charset)
247 (coding-system-error nil)))
248 (let ((document
249 (or document
250 (list
251 'base (list (cons 'href url))
252 (libxml-parse-html-region (point) (point-max))))))
253 (setq eww-current-source (buffer-substring (point) (point-max)))
254 (eww-setup-buffer)
255 (setq eww-current-dom document)
256 (let ((inhibit-read-only t)
257 (after-change-functions nil)
258 (shr-width nil)
259 (shr-target-id (url-target (url-generic-parse-url url)))
260 (shr-external-rendering-functions
261 '((title . eww-tag-title)
262 (form . eww-tag-form)
263 (input . eww-tag-input)
264 (textarea . eww-tag-textarea)
265 (body . eww-tag-body)
266 (select . eww-tag-select)
267 (link . eww-tag-link)
268 (a . eww-tag-a))))
269 (shr-insert-document document)
270 (cond
271 (point
272 (goto-char point))
273 (shr-target-id
274 (goto-char (point-min))
275 (let ((point (next-single-property-change
276 (point-min) 'shr-target-id)))
277 (when point
278 (goto-char point))))
279 (t
280 (goto-char (point-min)))))
281 (setq eww-current-url url
282 eww-history-position 0)
283 (eww-update-header-line-format)))
284
285 (defun eww-handle-link (cont)
286 (let* ((rel (assq :rel cont))
287 (href (assq :href cont))
288 (where (assoc
289 ;; The text associated with :rel is case-insensitive.
290 (if rel (downcase (cdr rel)))
291 '(("next" . eww-next-url)
292 ;; Texinfo uses "previous", but HTML specifies
293 ;; "prev", so recognize both.
294 ("previous" . eww-previous-url)
295 ("prev" . eww-previous-url)
296 ;; HTML specifies "start" but also "contents",
297 ;; and Gtk seems to use "home". Recognize
298 ;; them all; but store them in different
299 ;; variables so that we can readily choose the
300 ;; "best" one.
301 ("start" . eww-start-url)
302 ("home" . eww-home-url)
303 ("contents" . eww-contents-url)
304 ("up" . eww-up-url)))))
305 (and href
306 where
307 (set (cdr where) (cdr href)))))
308
309 (defun eww-tag-link (cont)
310 (eww-handle-link cont)
311 (shr-generic cont))
312
313 (defun eww-tag-a (cont)
314 (eww-handle-link cont)
315 (let ((start (point)))
316 (shr-tag-a cont)
317 (put-text-property start (point) 'keymap eww-link-keymap)))
318
319 (defun eww-update-header-line-format ()
320 (if eww-header-line-format
321 (setq header-line-format
322 (replace-regexp-in-string
323 "%" "%%"
324 ;; FIXME? Title can be blank. Default to, eg, last component
325 ;; of url?
326 (format-spec eww-header-line-format
327 `((?u . ,eww-current-url)
328 (?t . ,eww-current-title)))))
329 (setq header-line-format nil)))
330
331 (defun eww-tag-title (cont)
332 (setq eww-current-title "")
333 (dolist (sub cont)
334 (when (eq (car sub) 'text)
335 (setq eww-current-title (concat eww-current-title (cdr sub)))))
336 (eww-update-header-line-format))
337
338 (defun eww-tag-body (cont)
339 (let* ((start (point))
340 (fgcolor (cdr (or (assq :fgcolor cont)
341 (assq :text cont))))
342 (bgcolor (cdr (assq :bgcolor cont)))
343 (shr-stylesheet (list (cons 'color fgcolor)
344 (cons 'background-color bgcolor))))
345 (shr-generic cont)
346 (eww-colorize-region start (point) fgcolor bgcolor)))
347
348 (defun eww-colorize-region (start end fg &optional bg)
349 (when (or fg bg)
350 (let ((new-colors (shr-color-check fg bg)))
351 (when new-colors
352 (when fg
353 (add-face-text-property start end
354 (list :foreground (cadr new-colors))
355 t))
356 (when bg
357 (add-face-text-property start end
358 (list :background (car new-colors))
359 t))))))
360
361 (defun eww-display-raw ()
362 (let ((data (buffer-substring (point) (point-max))))
363 (eww-setup-buffer)
364 (let ((inhibit-read-only t))
365 (insert data))
366 (goto-char (point-min))))
367
368 (defun eww-display-image ()
369 (let ((data (shr-parse-image-data)))
370 (eww-setup-buffer)
371 (let ((inhibit-read-only t))
372 (shr-put-image data nil))
373 (goto-char (point-min))))
374
375 (defun eww-setup-buffer ()
376 (switch-to-buffer (get-buffer-create "*eww*"))
377 (let ((inhibit-read-only t))
378 (remove-overlays)
379 (erase-buffer))
380 (unless (eq major-mode 'eww-mode)
381 (eww-mode)))
382
383 (defun eww-view-source ()
384 (interactive)
385 (let ((buf (get-buffer-create "*eww-source*"))
386 (source eww-current-source))
387 (with-current-buffer buf
388 (delete-region (point-min) (point-max))
389 (insert (or eww-current-source "no source"))
390 (goto-char (point-min))
391 (when (fboundp 'html-mode)
392 (html-mode)))
393 (view-buffer buf)))
394
395 (defvar eww-mode-map
396 (let ((map (make-sparse-keymap)))
397 (suppress-keymap map)
398 (define-key map "q" 'quit-window)
399 (define-key map "g" 'eww-reload)
400 (define-key map [tab] 'shr-next-link)
401 (define-key map [backtab] 'shr-previous-link)
402 (define-key map [delete] 'scroll-down-command)
403 (define-key map [?\S-\ ] 'scroll-down-command)
404 (define-key map "\177" 'scroll-down-command)
405 (define-key map " " 'scroll-up-command)
406 (define-key map "l" 'eww-back-url)
407 (define-key map "r" 'eww-forward-url)
408 (define-key map "n" 'eww-next-url)
409 (define-key map "p" 'eww-previous-url)
410 (define-key map "u" 'eww-up-url)
411 (define-key map "t" 'eww-top-url)
412 (define-key map "&" 'eww-browse-with-external-browser)
413 (define-key map "d" 'eww-download)
414 (define-key map "w" 'eww-copy-page-url)
415 (define-key map "C" 'url-cookie-list)
416 (define-key map "v" 'eww-view-source)
417 (define-key map "H" 'eww-list-histories)
418
419 (define-key map "b" 'eww-add-bookmark)
420 (define-key map "B" 'eww-list-bookmarks)
421 (define-key map [(meta n)] 'eww-next-bookmark)
422 (define-key map [(meta p)] 'eww-previous-bookmark)
423
424 (easy-menu-define nil map ""
425 '("Eww"
426 ["Exit" eww-quit t]
427 ["Close browser" quit-window t]
428 ["Reload" eww-reload t]
429 ["Back to previous page" eww-back-url
430 :active (not (zerop (length eww-history)))]
431 ["Forward to next page" eww-forward-url
432 :active (not (zerop eww-history-position))]
433 ["Browse with external browser" eww-browse-with-external-browser t]
434 ["Download" eww-download t]
435 ["View page source" eww-view-source]
436 ["Copy page URL" eww-copy-page-url t]
437 ["List histories" eww-list-histories t]
438 ["Add bookmark" eww-add-bookmark t]
439 ["List bookmarks" eww-list-bookmarks t]
440 ["List cookies" url-cookie-list t]))
441 map))
442
443 (defvar eww-tool-bar-map
444 (let ((map (make-sparse-keymap)))
445 (dolist (tool-bar-item
446 '((eww-quit . "close")
447 (eww-reload . "refresh")
448 (eww-back-url . "left-arrow")
449 (eww-forward-url . "right-arrow")
450 (eww-view-source . "show")
451 (eww-copy-page-url . "copy")
452 (eww-add-bookmark . "bookmark_add"))) ;; ...
453 (tool-bar-local-item-from-menu
454 (car tool-bar-item) (cdr tool-bar-item) map eww-mode-map))
455 map)
456 "Tool bar for `eww-mode'.")
457
458 (define-derived-mode eww-mode nil "eww"
459 "Mode for browsing the web.
460
461 \\{eww-mode-map}"
462 ;; FIXME? This seems a strange default.
463 (setq-local eww-current-url 'author)
464 (setq-local eww-current-dom nil)
465 (setq-local eww-current-source nil)
466 (setq-local browse-url-browser-function 'eww-browse-url)
467 (setq-local after-change-functions 'eww-process-text-input)
468 (setq-local eww-history nil)
469 (setq-local eww-history-position 0)
470 (when (boundp 'tool-bar-map)
471 (setq-local tool-bar-map eww-tool-bar-map))
472 (buffer-disable-undo)
473 ;;(setq buffer-read-only t)
474 )
475
476 ;;;###autoload
477 (defun eww-browse-url (url &optional _new-window)
478 (when (and (equal major-mode 'eww-mode)
479 eww-current-url)
480 (eww-save-history))
481 (eww url))
482
483 (defun eww-back-url ()
484 "Go to the previously displayed page."
485 (interactive)
486 (when (>= eww-history-position (length eww-history))
487 (user-error "No previous page"))
488 (eww-save-history)
489 (setq eww-history-position (+ eww-history-position 2))
490 (eww-restore-history (elt eww-history (1- eww-history-position))))
491
492 (defun eww-forward-url ()
493 "Go to the next displayed page."
494 (interactive)
495 (when (zerop eww-history-position)
496 (user-error "No next page"))
497 (eww-save-history)
498 (eww-restore-history (elt eww-history (1- eww-history-position))))
499
500 (defun eww-restore-history (elem)
501 (let ((inhibit-read-only t))
502 (erase-buffer)
503 (insert (plist-get elem :text))
504 (setq eww-current-source (plist-get elem :source))
505 (setq eww-current-dom (plist-get elem :dom))
506 (goto-char (plist-get elem :point))
507 (setq eww-current-url (plist-get elem :url)
508 eww-current-title (plist-get elem :title))
509 (eww-update-header-line-format)))
510
511 (defun eww-next-url ()
512 "Go to the page marked `next'.
513 A page is marked `next' if rel=\"next\" appears in a <link>
514 or <a> tag."
515 (interactive)
516 (if eww-next-url
517 (eww-browse-url (shr-expand-url eww-next-url eww-current-url))
518 (user-error "No `next' on this page")))
519
520 (defun eww-previous-url ()
521 "Go to the page marked `previous'.
522 A page is marked `previous' if rel=\"previous\" appears in a <link>
523 or <a> tag."
524 (interactive)
525 (if eww-previous-url
526 (eww-browse-url (shr-expand-url eww-previous-url eww-current-url))
527 (user-error "No `previous' on this page")))
528
529 (defun eww-up-url ()
530 "Go to the page marked `up'.
531 A page is marked `up' if rel=\"up\" appears in a <link>
532 or <a> tag."
533 (interactive)
534 (if eww-up-url
535 (eww-browse-url (shr-expand-url eww-up-url eww-current-url))
536 (user-error "No `up' on this page")))
537
538 (defun eww-top-url ()
539 "Go to the page marked `top'.
540 A page is marked `top' if rel=\"start\", rel=\"home\", or rel=\"contents\"
541 appears in a <link> or <a> tag."
542 (interactive)
543 (let ((best-url (or eww-start-url
544 eww-contents-url
545 eww-home-url)))
546 (if best-url
547 (eww-browse-url (shr-expand-url best-url eww-current-url))
548 (user-error "No `top' for this page"))))
549
550 (defun eww-reload ()
551 "Reload the current page."
552 (interactive)
553 (url-retrieve eww-current-url 'eww-render
554 (list eww-current-url (point))))
555
556 ;; Form support.
557
558 (defvar eww-form nil)
559
560 (defvar eww-submit-map
561 (let ((map (make-sparse-keymap)))
562 (define-key map "\r" 'eww-submit)
563 (define-key map [(control c) (control c)] 'eww-submit)
564 map))
565
566 (defvar eww-checkbox-map
567 (let ((map (make-sparse-keymap)))
568 (define-key map [space] 'eww-toggle-checkbox)
569 (define-key map "\r" 'eww-toggle-checkbox)
570 (define-key map [(control c) (control c)] 'eww-submit)
571 map))
572
573 (defvar eww-text-map
574 (let ((map (make-keymap)))
575 (set-keymap-parent map text-mode-map)
576 (define-key map "\r" 'eww-submit)
577 (define-key map [(control a)] 'eww-beginning-of-text)
578 (define-key map [(control c) (control c)] 'eww-submit)
579 (define-key map [(control e)] 'eww-end-of-text)
580 (define-key map [tab] 'shr-next-link)
581 (define-key map [backtab] 'shr-previous-link)
582 map))
583
584 (defvar eww-textarea-map
585 (let ((map (make-keymap)))
586 (set-keymap-parent map text-mode-map)
587 (define-key map "\r" 'forward-line)
588 (define-key map [(control c) (control c)] 'eww-submit)
589 (define-key map [tab] 'shr-next-link)
590 (define-key map [backtab] 'shr-previous-link)
591 map))
592
593 (defvar eww-select-map
594 (let ((map (make-sparse-keymap)))
595 (define-key map "\r" 'eww-change-select)
596 (define-key map [(control c) (control c)] 'eww-submit)
597 map))
598
599 (defun eww-beginning-of-text ()
600 "Move to the start of the input field."
601 (interactive)
602 (goto-char (eww-beginning-of-field)))
603
604 (defun eww-end-of-text ()
605 "Move to the end of the text in the input field."
606 (interactive)
607 (goto-char (eww-end-of-field))
608 (let ((start (eww-beginning-of-field)))
609 (while (and (equal (following-char) ? )
610 (> (point) start))
611 (forward-char -1))
612 (when (> (point) start)
613 (forward-char 1))))
614
615 (defun eww-beginning-of-field ()
616 (cond
617 ((bobp)
618 (point))
619 ((not (eq (get-text-property (point) 'eww-form)
620 (get-text-property (1- (point)) 'eww-form)))
621 (point))
622 (t
623 (previous-single-property-change
624 (point) 'eww-form nil (point-min)))))
625
626 (defun eww-end-of-field ()
627 (1- (next-single-property-change
628 (point) 'eww-form nil (point-max))))
629
630 (defun eww-tag-form (cont)
631 (let ((eww-form
632 (list (assq :method cont)
633 (assq :action cont)))
634 (start (point)))
635 (shr-ensure-paragraph)
636 (shr-generic cont)
637 (unless (bolp)
638 (insert "\n"))
639 (insert "\n")
640 (when (> (point) start)
641 (put-text-property start (1+ start)
642 'eww-form eww-form))))
643
644 (defun eww-form-submit (cont)
645 (let ((start (point))
646 (value (cdr (assq :value cont))))
647 (setq value
648 (if (zerop (length value))
649 "Submit"
650 value))
651 (insert value)
652 (add-face-text-property start (point) 'eww-form-submit)
653 (put-text-property start (point) 'eww-form
654 (list :eww-form eww-form
655 :value value
656 :type "submit"
657 :name (cdr (assq :name cont))))
658 (put-text-property start (point) 'keymap eww-submit-map)
659 (insert " ")))
660
661 (defun eww-form-checkbox (cont)
662 (let ((start (point)))
663 (if (cdr (assq :checked cont))
664 (insert eww-form-checkbox-selected-symbol)
665 (insert eww-form-checkbox-symbol))
666 (add-face-text-property start (point) 'eww-form-checkbox)
667 (put-text-property start (point) 'eww-form
668 (list :eww-form eww-form
669 :value (cdr (assq :value cont))
670 :type (downcase (cdr (assq :type cont)))
671 :checked (cdr (assq :checked cont))
672 :name (cdr (assq :name cont))))
673 (put-text-property start (point) 'keymap eww-checkbox-map)
674 (insert " ")))
675
676 (defun eww-form-text (cont)
677 (let ((start (point))
678 (type (downcase (or (cdr (assq :type cont))
679 "text")))
680 (value (or (cdr (assq :value cont)) ""))
681 (width (string-to-number
682 (or (cdr (assq :size cont))
683 "40"))))
684 (insert value)
685 (when (< (length value) width)
686 (insert (make-string (- width (length value)) ? )))
687 (put-text-property start (point) 'face 'eww-form-text)
688 (put-text-property start (point) 'local-map eww-text-map)
689 (put-text-property start (point) 'inhibit-read-only t)
690 (put-text-property start (point) 'eww-form
691 (list :eww-form eww-form
692 :value value
693 :type type
694 :name (cdr (assq :name cont))))
695 (insert " ")))
696
697 (defconst eww-text-input-types '("text" "password" "textarea"
698 "color" "date" "datetime" "datetime-local"
699 "email" "month" "number" "search" "tel"
700 "time" "url" "week")
701 "List of input types which represent a text input.
702 See URL `https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input'.")
703
704 (defun eww-process-text-input (beg end length)
705 (let* ((form (get-text-property (min (1+ end) (point-max)) 'eww-form))
706 (properties (text-properties-at end))
707 (type (plist-get form :type)))
708 (when (and form
709 (member type eww-text-input-types))
710 (cond
711 ((zerop length)
712 ;; Delete some space at the end.
713 (save-excursion
714 (goto-char
715 (if (equal type "textarea")
716 (1- (line-end-position))
717 (eww-end-of-field)))
718 (let ((new (- end beg)))
719 (while (and (> new 0)
720 (eql (following-char) ? ))
721 (delete-region (point) (1+ (point)))
722 (setq new (1- new))))
723 (set-text-properties beg end properties)))
724 ((> length 0)
725 ;; Add padding.
726 (save-excursion
727 (goto-char
728 (if (equal type "textarea")
729 (1- (line-end-position))
730 (eww-end-of-field)))
731 (let ((start (point)))
732 (insert (make-string length ? ))
733 (set-text-properties start (point) properties)))))
734 (let ((value (buffer-substring-no-properties
735 (eww-beginning-of-field)
736 (eww-end-of-field))))
737 (when (string-match " +\\'" value)
738 (setq value (substring value 0 (match-beginning 0))))
739 (plist-put form :value value)
740 (when (equal type "password")
741 ;; Display passwords as asterisks.
742 (let ((start (eww-beginning-of-field)))
743 (put-text-property start (+ start (length value))
744 'display (make-string (length value) ?*))))))))
745
746 (defun eww-tag-textarea (cont)
747 (let ((start (point))
748 (value (or (cdr (assq :value cont)) ""))
749 (lines (string-to-number
750 (or (cdr (assq :rows cont))
751 "10")))
752 (width (string-to-number
753 (or (cdr (assq :cols cont))
754 "10")))
755 end)
756 (shr-ensure-newline)
757 (insert value)
758 (shr-ensure-newline)
759 (when (< (count-lines start (point)) lines)
760 (dotimes (i (- lines (count-lines start (point))))
761 (insert "\n")))
762 (setq end (point-marker))
763 (goto-char start)
764 (while (< (point) end)
765 (end-of-line)
766 (let ((pad (- width (- (point) (line-beginning-position)))))
767 (when (> pad 0)
768 (insert (make-string pad ? ))))
769 (add-face-text-property (line-beginning-position)
770 (point) 'eww-form-text)
771 (put-text-property (line-beginning-position) (point)
772 'local-map eww-textarea-map)
773 (forward-line 1))
774 (put-text-property start (point) 'eww-form
775 (list :eww-form eww-form
776 :value value
777 :type "textarea"
778 :name (cdr (assq :name cont))))))
779
780 (defun eww-tag-input (cont)
781 (let ((type (downcase (or (cdr (assq :type cont))
782 "text")))
783 (start (point)))
784 (cond
785 ((or (equal type "checkbox")
786 (equal type "radio"))
787 (eww-form-checkbox cont))
788 ((equal type "submit")
789 (eww-form-submit cont))
790 ((equal type "hidden")
791 (let ((form eww-form)
792 (name (cdr (assq :name cont))))
793 ;; Don't add <input type=hidden> elements repeatedly.
794 (while (and form
795 (or (not (consp (car form)))
796 (not (eq (caar form) 'hidden))
797 (not (equal (plist-get (cdr (car form)) :name)
798 name))))
799 (setq form (cdr form)))
800 (unless form
801 (nconc eww-form (list
802 (list 'hidden
803 :name name
804 :value (cdr (assq :value cont))))))))
805 (t
806 (eww-form-text cont)))
807 (unless (= start (point))
808 (put-text-property start (1+ start) 'help-echo "Input field"))))
809
810 (defun eww-tag-select (cont)
811 (shr-ensure-paragraph)
812 (let ((menu (list :name (cdr (assq :name cont))
813 :eww-form eww-form))
814 (options nil)
815 (start (point))
816 (max 0)
817 opelem)
818 (if (eq (car (car cont)) 'optgroup)
819 (dolist (groupelem cont)
820 (unless (cdr (assq :disabled (cdr groupelem)))
821 (setq opelem (append opelem (cdr (cdr groupelem))))))
822 (setq opelem cont))
823 (dolist (elem opelem)
824 (when (eq (car elem) 'option)
825 (when (cdr (assq :selected (cdr elem)))
826 (nconc menu (list :value
827 (cdr (assq :value (cdr elem))))))
828 (let ((display (or (cdr (assq 'text (cdr elem))) "")))
829 (setq max (max max (length display)))
830 (push (list 'item
831 :value (cdr (assq :value (cdr elem)))
832 :display display)
833 options))))
834 (when options
835 (setq options (nreverse options))
836 ;; If we have no selected values, default to the first value.
837 (unless (plist-get menu :value)
838 (nconc menu (list :value (nth 2 (car options)))))
839 (nconc menu options)
840 (let ((selected (eww-select-display menu)))
841 (insert selected
842 (make-string (- max (length selected)) ? )))
843 (put-text-property start (point) 'eww-form menu)
844 (add-face-text-property start (point) 'eww-form-select)
845 (put-text-property start (point) 'keymap eww-select-map)
846 (shr-ensure-paragraph))))
847
848 (defun eww-select-display (select)
849 (let ((value (plist-get select :value))
850 display)
851 (dolist (elem select)
852 (when (and (consp elem)
853 (eq (car elem) 'item)
854 (equal value (plist-get (cdr elem) :value)))
855 (setq display (plist-get (cdr elem) :display))))
856 display))
857
858 (defun eww-change-select ()
859 "Change the value of the select drop-down menu under point."
860 (interactive)
861 (let* ((input (get-text-property (point) 'eww-form))
862 (completion-ignore-case t)
863 (options
864 (delq nil
865 (mapcar (lambda (elem)
866 (and (consp elem)
867 (eq (car elem) 'item)
868 (cons (plist-get (cdr elem) :display)
869 (plist-get (cdr elem) :value))))
870 input)))
871 (display
872 (completing-read "Change value: " options nil 'require-match))
873 (inhibit-read-only t))
874 (plist-put input :value (cdr (assoc-string display options t)))
875 (goto-char
876 (eww-update-field display))))
877
878 (defun eww-update-field (string)
879 (let ((properties (text-properties-at (point)))
880 (start (eww-beginning-of-field))
881 (end (1+ (eww-end-of-field))))
882 (delete-region start end)
883 (insert string
884 (make-string (- (- end start) (length string)) ? ))
885 (set-text-properties start end properties)
886 start))
887
888 (defun eww-toggle-checkbox ()
889 "Toggle the value of the checkbox under point."
890 (interactive)
891 (let* ((input (get-text-property (point) 'eww-form))
892 (type (plist-get input :type)))
893 (if (equal type "checkbox")
894 (goto-char
895 (1+
896 (if (plist-get input :checked)
897 (progn
898 (plist-put input :checked nil)
899 (eww-update-field eww-form-checkbox-symbol))
900 (plist-put input :checked t)
901 (eww-update-field eww-form-checkbox-selected-symbol))))
902 ;; Radio button. Switch all other buttons off.
903 (let ((name (plist-get input :name)))
904 (save-excursion
905 (dolist (elem (eww-inputs (plist-get input :eww-form)))
906 (when (equal (plist-get (cdr elem) :name) name)
907 (goto-char (car elem))
908 (if (not (eq (cdr elem) input))
909 (progn
910 (plist-put input :checked nil)
911 (eww-update-field eww-form-checkbox-symbol))
912 (plist-put input :checked t)
913 (eww-update-field eww-form-checkbox-selected-symbol)))))
914 (forward-char 1)))))
915
916 (defun eww-inputs (form)
917 (let ((start (point-min))
918 (inputs nil))
919 (while (and start
920 (< start (point-max)))
921 (when (or (get-text-property start 'eww-form)
922 (setq start (next-single-property-change start 'eww-form)))
923 (when (eq (plist-get (get-text-property start 'eww-form) :eww-form)
924 form)
925 (push (cons start (get-text-property start 'eww-form))
926 inputs))
927 (setq start (next-single-property-change start 'eww-form))))
928 (nreverse inputs)))
929
930 (defun eww-input-value (input)
931 (let ((type (plist-get input :type))
932 (value (plist-get input :value)))
933 (cond
934 ((equal type "textarea")
935 (with-temp-buffer
936 (insert value)
937 (goto-char (point-min))
938 (while (re-search-forward "^ +\n\\| +$" nil t)
939 (replace-match "" t t))
940 (buffer-string)))
941 (t
942 (if (string-match " +\\'" value)
943 (substring value 0 (match-beginning 0))
944 value)))))
945
946 (defun eww-submit ()
947 "Submit the current form."
948 (interactive)
949 (let* ((this-input (get-text-property (point) 'eww-form))
950 (form (plist-get this-input :eww-form))
951 values next-submit)
952 (dolist (elem (sort (eww-inputs form)
953 (lambda (o1 o2)
954 (< (car o1) (car o2)))))
955 (let* ((input (cdr elem))
956 (input-start (car elem))
957 (name (plist-get input :name)))
958 (when name
959 (cond
960 ((member (plist-get input :type) '("checkbox" "radio"))
961 (when (plist-get input :checked)
962 (push (cons name (plist-get input :value))
963 values)))
964 ((equal (plist-get input :type) "submit")
965 ;; We want the values from buttons if we hit a button if
966 ;; we hit enter on it, or if it's the first button after
967 ;; the field we did hit return on.
968 (when (or (eq input this-input)
969 (and (not (eq input this-input))
970 (null next-submit)
971 (> input-start (point))))
972 (setq next-submit t)
973 (push (cons name (plist-get input :value))
974 values)))
975 (t
976 (push (cons name (eww-input-value input))
977 values))))))
978 (dolist (elem form)
979 (when (and (consp elem)
980 (eq (car elem) 'hidden))
981 (push (cons (plist-get (cdr elem) :name)
982 (plist-get (cdr elem) :value))
983 values)))
984 (if (and (stringp (cdr (assq :method form)))
985 (equal (downcase (cdr (assq :method form))) "post"))
986 (let ((url-request-method "POST")
987 (url-request-extra-headers
988 '(("Content-Type" . "application/x-www-form-urlencoded")))
989 (url-request-data (mm-url-encode-www-form-urlencoded values)))
990 (eww-browse-url (shr-expand-url (cdr (assq :action form))
991 eww-current-url)))
992 (eww-browse-url
993 (concat
994 (if (cdr (assq :action form))
995 (shr-expand-url (cdr (assq :action form))
996 eww-current-url)
997 eww-current-url)
998 "?"
999 (mm-url-encode-www-form-urlencoded values))))))
1000
1001 (defun eww-browse-with-external-browser (&optional url)
1002 "Browse the current URL with an external browser.
1003 The browser to used is specified by the `shr-external-browser' variable."
1004 (interactive)
1005 (funcall shr-external-browser (or url eww-current-url)))
1006
1007 (defun eww-follow-link (&optional external mouse-event)
1008 "Browse the URL under point.
1009 If EXTERNAL, browse the URL using `shr-external-browser'."
1010 (interactive (list current-prefix-arg last-nonmenu-event))
1011 (mouse-set-point mouse-event)
1012 (let ((url (get-text-property (point) 'shr-url)))
1013 (cond
1014 ((not url)
1015 (message "No link under point"))
1016 ((string-match "^mailto:" url)
1017 (browse-url-mail url))
1018 (external
1019 (funcall shr-external-browser url))
1020 ;; This is a #target url in the same page as the current one.
1021 ((and (url-target (url-generic-parse-url url))
1022 (eww-same-page-p url eww-current-url))
1023 (eww-save-history)
1024 (eww-display-html 'utf8 url eww-current-dom))
1025 (t
1026 (eww-browse-url url)))))
1027
1028 (defun eww-same-page-p (url1 url2)
1029 "Return non-nil if both URLs represent the same page.
1030 Differences in #targets are ignored."
1031 (let ((obj1 (url-generic-parse-url url1))
1032 (obj2 (url-generic-parse-url url2)))
1033 (setf (url-target obj1) nil)
1034 (setf (url-target obj2) nil)
1035 (equal (url-recreate-url obj1) (url-recreate-url obj2))))
1036
1037 (defun eww-copy-page-url ()
1038 (interactive)
1039 (message "%s" eww-current-url)
1040 (kill-new eww-current-url))
1041
1042 (defun eww-download ()
1043 "Download URL under point to `eww-download-directory'."
1044 (interactive)
1045 (let ((url (get-text-property (point) 'shr-url)))
1046 (if (not url)
1047 (message "No URL under point")
1048 (url-retrieve url 'eww-download-callback (list url)))))
1049
1050 (defun eww-download-callback (status url)
1051 (unless (plist-get status :error)
1052 (let* ((obj (url-generic-parse-url url))
1053 (path (car (url-path-and-query obj)))
1054 (file (eww-make-unique-file-name (file-name-nondirectory path)
1055 eww-download-path)))
1056 (write-file file)
1057 (message "Saved %s" file))))
1058
1059 (defun eww-make-unique-file-name (file directory)
1060 (cond
1061 ((zerop (length file))
1062 (setq file "!"))
1063 ((string-match "\\`[.]" file)
1064 (setq file (concat "!" file))))
1065 (let ((count 1))
1066 (while (file-exists-p (expand-file-name file directory))
1067 (setq file
1068 (if (string-match "\\`\\(.*\\)\\([.][^.]+\\)" file)
1069 (format "%s(%d)%s" (match-string 1 file)
1070 count (match-string 2 file))
1071 (format "%s(%d)" file count)))
1072 (setq count (1+ count)))
1073 (expand-file-name file directory)))
1074
1075 ;;; Bookmarks code
1076
1077 (defvar eww-bookmarks nil)
1078
1079 (defun eww-add-bookmark ()
1080 "Add the current page to the bookmarks."
1081 (interactive)
1082 (eww-read-bookmarks)
1083 (dolist (bookmark eww-bookmarks)
1084 (when (equal eww-current-url
1085 (plist-get bookmark :url))
1086 (user-error "Already bookmarked")))
1087 (if (y-or-n-p "bookmark this page? ")
1088 (progn
1089 (let ((title (replace-regexp-in-string "[\n\t\r]" " " eww-current-title)))
1090 (setq title (replace-regexp-in-string "\\` +\\| +\\'" "" title))
1091 (push (list :url eww-current-url
1092 :title title
1093 :time (current-time-string))
1094 eww-bookmarks))
1095 (eww-write-bookmarks)
1096 (message "Bookmarked %s (%s)" eww-current-url eww-current-title))))
1097
1098 (defun eww-write-bookmarks ()
1099 (with-temp-file (expand-file-name "eww-bookmarks" user-emacs-directory)
1100 (insert ";; Auto-generated file; don't edit\n")
1101 (pp eww-bookmarks (current-buffer))))
1102
1103 (defun eww-read-bookmarks ()
1104 (let ((file (expand-file-name "eww-bookmarks" user-emacs-directory)))
1105 (setq eww-bookmarks
1106 (unless (zerop (or (nth 7 (file-attributes file)) 0))
1107 (with-temp-buffer
1108 (insert-file-contents file)
1109 (read (current-buffer)))))))
1110
1111 (defun eww-list-bookmarks ()
1112 "Display the bookmarks."
1113 (interactive)
1114 (eww-bookmark-prepare)
1115 (pop-to-buffer "*eww bookmarks*"))
1116
1117 (defun eww-bookmark-prepare ()
1118 (eww-read-bookmarks)
1119 (unless eww-bookmarks
1120 (user-error "No bookmarks are defined"))
1121 (set-buffer (get-buffer-create "*eww bookmarks*"))
1122 (eww-bookmark-mode)
1123 (let ((format "%-40s %s")
1124 (inhibit-read-only t)
1125 start url)
1126 (erase-buffer)
1127 (setq header-line-format (concat " " (format format "URL" "Title")))
1128 (dolist (bookmark eww-bookmarks)
1129 (setq start (point))
1130 (setq url (plist-get bookmark :url))
1131 (when (> (length url) 40)
1132 (setq url (substring url 0 40)))
1133 (insert (format format url
1134 (plist-get bookmark :title))
1135 "\n")
1136 (put-text-property start (1+ start) 'eww-bookmark bookmark))
1137 (goto-char (point-min))))
1138
1139 (defvar eww-bookmark-kill-ring nil)
1140
1141 (defun eww-bookmark-kill ()
1142 "Kill the current bookmark."
1143 (interactive)
1144 (let* ((start (line-beginning-position))
1145 (bookmark (get-text-property start 'eww-bookmark))
1146 (inhibit-read-only t))
1147 (unless bookmark
1148 (user-error "No bookmark on the current line"))
1149 (forward-line 1)
1150 (push (buffer-substring start (point)) eww-bookmark-kill-ring)
1151 (delete-region start (point))
1152 (setq eww-bookmarks (delq bookmark eww-bookmarks))
1153 (eww-write-bookmarks)))
1154
1155 (defun eww-bookmark-yank ()
1156 "Yank a previously killed bookmark to the current line."
1157 (interactive)
1158 (unless eww-bookmark-kill-ring
1159 (user-error "No previously killed bookmark"))
1160 (beginning-of-line)
1161 (let ((inhibit-read-only t)
1162 (start (point))
1163 bookmark)
1164 (insert (pop eww-bookmark-kill-ring))
1165 (setq bookmark (get-text-property start 'eww-bookmark))
1166 (if (= start (point-min))
1167 (push bookmark eww-bookmarks)
1168 (let ((line (count-lines start (point))))
1169 (setcdr (nthcdr (1- line) eww-bookmarks)
1170 (cons bookmark (nthcdr line eww-bookmarks)))))
1171 (eww-write-bookmarks)))
1172
1173 (defun eww-bookmark-quit ()
1174 "Kill the current buffer."
1175 (interactive)
1176 (kill-buffer (current-buffer)))
1177
1178 (defun eww-bookmark-browse ()
1179 "Browse the bookmark under point in eww."
1180 (interactive)
1181 (let ((bookmark (get-text-property (line-beginning-position) 'eww-bookmark)))
1182 (unless bookmark
1183 (user-error "No bookmark on the current line"))
1184 ;; We wish to leave this window, but if it's the only window here,
1185 ;; just let it remain.
1186 (ignore-errors
1187 (delete-window))
1188 (eww-browse-url (plist-get bookmark :url))))
1189
1190 (defun eww-next-bookmark ()
1191 "Go to the next bookmark in the list."
1192 (interactive)
1193 (let ((first nil)
1194 bookmark)
1195 (unless (get-buffer "*eww bookmarks*")
1196 (setq first t)
1197 (eww-bookmark-prepare))
1198 (with-current-buffer (get-buffer "*eww bookmarks*")
1199 (when (and (not first)
1200 (not (eobp)))
1201 (forward-line 1))
1202 (setq bookmark (get-text-property (line-beginning-position)
1203 'eww-bookmark))
1204 (unless bookmark
1205 (user-error "No next bookmark")))
1206 (eww-browse-url (plist-get bookmark :url))))
1207
1208 (defun eww-previous-bookmark ()
1209 "Go to the previous bookmark in the list."
1210 (interactive)
1211 (let ((first nil)
1212 bookmark)
1213 (unless (get-buffer "*eww bookmarks*")
1214 (setq first t)
1215 (eww-bookmark-prepare))
1216 (with-current-buffer (get-buffer "*eww bookmarks*")
1217 (if first
1218 (goto-char (point-max))
1219 (beginning-of-line))
1220 ;; On the final line.
1221 (when (eolp)
1222 (forward-line -1))
1223 (if (bobp)
1224 (user-error "No previous bookmark")
1225 (forward-line -1))
1226 (setq bookmark (get-text-property (line-beginning-position)
1227 'eww-bookmark)))
1228 (eww-browse-url (plist-get bookmark :url))))
1229
1230 (defvar eww-bookmark-mode-map
1231 (let ((map (make-sparse-keymap)))
1232 (suppress-keymap map)
1233 (define-key map "q" 'eww-bookmark-quit)
1234 (define-key map [(control k)] 'eww-bookmark-kill)
1235 (define-key map [(control y)] 'eww-bookmark-yank)
1236 (define-key map "\r" 'eww-bookmark-browse)
1237
1238 (easy-menu-define nil map
1239 "Menu for `eww-bookmark-mode-map'."
1240 '("Eww Bookmark"
1241 ["Exit" eww-bookmark-quit t]
1242 ["Browse" eww-bookmark-browse
1243 :active (get-text-property (line-beginning-position) 'eww-bookmark)]
1244 ["Kill" eww-bookmark-kill
1245 :active (get-text-property (line-beginning-position) 'eww-bookmark)]
1246 ["Yank" eww-bookmark-yank
1247 :active eww-bookmark-kill-ring]))
1248 map))
1249
1250 (define-derived-mode eww-bookmark-mode nil "eww bookmarks"
1251 "Mode for listing bookmarks.
1252
1253 \\{eww-bookmark-mode-map}"
1254 (buffer-disable-undo)
1255 (setq buffer-read-only t
1256 truncate-lines t))
1257
1258 ;;; History code
1259
1260 (defun eww-save-history ()
1261 (push (list :url eww-current-url
1262 :title eww-current-title
1263 :point (point)
1264 :dom eww-current-dom
1265 :source eww-current-source
1266 :text (buffer-string))
1267 eww-history))
1268
1269 (defun eww-list-histories ()
1270 "List the eww-histories."
1271 (interactive)
1272 (when (null eww-history)
1273 (error "No eww-histories are defined"))
1274 (set-buffer (get-buffer-create "*eww history*"))
1275 (eww-history-mode)
1276 (let ((inhibit-read-only t)
1277 (domain-length 0)
1278 (title-length 0)
1279 url title format start)
1280 (erase-buffer)
1281 (dolist (history eww-history)
1282 (setq start (point))
1283 (setq domain-length (max domain-length (length (plist-get history :url))))
1284 (setq title-length (max title-length (length (plist-get history :title))))
1285 )
1286 (setq format (format "%%-%ds %%-%ds" title-length domain-length)
1287 header-line-format
1288 (concat " " (format format "Title" "URL")))
1289
1290 (dolist (history eww-history)
1291 (setq url (plist-get history :url))
1292 (setq title (plist-get history :title))
1293 (insert (format format title url))
1294 (insert "\n")
1295 (put-text-property start (point) 'eww-history history)
1296 )
1297 (goto-char (point-min)))
1298 (pop-to-buffer "*eww history*")
1299 )
1300
1301 (defun eww-history-browse ()
1302 "Browse the history under point in eww."
1303 (interactive)
1304 (let ((history (get-text-property (line-beginning-position) 'eww-history)))
1305 (unless history
1306 (error "No history on the current line"))
1307 (eww-history-quit)
1308 (pop-to-buffer "*eww*")
1309 (eww-browse-url (plist-get history :url))))
1310
1311 (defun eww-history-quit ()
1312 "Kill the current buffer."
1313 (interactive)
1314 (kill-buffer (current-buffer)))
1315
1316 (defvar eww-history-kill-ring nil)
1317
1318 (defun eww-history-kill ()
1319 "Kill the current history."
1320 (interactive)
1321 (let* ((start (line-beginning-position))
1322 (history (get-text-property start 'eww-history))
1323 (inhibit-read-only t))
1324 (unless history
1325 (error "No history on the current line"))
1326 (forward-line 1)
1327 (push (buffer-substring start (point)) eww-history-kill-ring)
1328 (delete-region start (point))
1329 (setq eww-history (delq history eww-history))
1330 ))
1331
1332 (defvar eww-history-mode-map
1333 (let ((map (make-sparse-keymap)))
1334 (suppress-keymap map)
1335 (define-key map "q" 'eww-history-quit)
1336 (define-key map [(control k)] 'eww-history-kill)
1337 (define-key map "\r" 'eww-history-browse)
1338 (define-key map "n" 'next-error-no-select)
1339 (define-key map "p" 'previous-error-no-select)
1340 map))
1341
1342 (define-derived-mode eww-history-mode nil "eww history"
1343 "Mode for listing eww-histories.
1344
1345 \\{eww-history-mode-map}"
1346 (buffer-disable-undo)
1347 (setq buffer-read-only t
1348 truncate-lines t))
1349
1350 (provide 'eww)
1351
1352 ;;; eww.el ends here