Fetching contributors…
Cannot retrieve contributors at this time
11068 lines (10406 sloc) 402 KB
;;; w3m.el --- an Emacs interface to w3m -*- coding: iso-2022-7bit; -*-
;; Copyright (C) 2000-2012 TSUCHIYA Masatoshi <>
;; Authors: TSUCHIYA Masatoshi <>,
;; Shun-ichi GOTO <>,
;; Satoru Takabayashi <>,
;; Hideyuki SHIRAI <>,
;; Keisuke Nishida <>,
;; Yuuichi Teranishi <>,
;; Akihiro Arisawa <>,
;; Katsumi Yamaoka <>,
;; Tsuyoshi CHO <>
;; Keywords: w3m, WWW, hypermedia
;; This file is the main part of emacs-w3m.
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Commentary:
;; Emacs-w3m is an Emacs interface to the w3m program. For more
;; detail about w3m, see:
;;; How to install:
;; See the README file in any case. We also recommend you check
;; whether a newer version of w3m is released.
;; The outline of installation is: run the `configure' script and type
;; `make install' in the top directory of the emacs-w3m distribution.
;;; Code:
;; Developers, you must not use the cl functions (e.g., `coerce',
;; `equalp', `merge', etc.) in any emacs-w3m or shimbun modules. To
;; exclude run-time cl is the policy of emacs-w3m. However, XEmacs
;; employs the cl package for all time, or those functions are
;; possibly provided in the other modules like APEL, so you may use
;; them only in w3m-xmas.el. Note that `caaaar', for example, is not
;; a cl function if it is byte compiled; see cl-macs.el.
(require 'cl))
(unless (dolist (var nil t))
;; Override the `dolist' macro which may be faultily provided by
;; old egg.el.
(load "cl-macs" nil t)))
;; The following variables will be referred to by the external modules
;; which bind such variables only when compiling themselves. And also
;; some modules have the `defadvice' forms including them and run
;; `byte-compile' at run-time.
(defvar w3m-current-title nil
"Title of a page visiting in the current buffer.")
(defvar w3m-current-url nil
"A url of a page visiting in the current buffer."))
(require 'w3m-util)
(require 'w3m-proc)
;; Silence the Emacs's byte-compiler that says ``might not be defined''.
(defalias 'w3m-setup-menu 'ignore))
((featurep 'xemacs)
(require 'w3m-xmas))
((>= emacs-major-version 21)
(require 'w3m-ems))
(error "Emacs-w3m of this version no longer supports Emacs %s"
(mapconcat 'identity
(nbutlast (split-string emacs-version "\\."))
(unless (or (featurep 'xemacs) (< emacs-major-version 23))
(require 'bookmark-w3m))
(require 'w3m-fb)
(require 'w3m-hist)
(require 'timezone)
(require 'image-mode nil t)
;; Add-on programs:
(autoload 'w3m-bookmark-view "w3m-bookmark"
"Display the bookmark" t)
(autoload 'w3m-bookmark-view-new-session "w3m-bookmark"
"Display the bookmark on a new session" t)
(autoload 'w3m-bookmark-add-this-url "w3m-bookmark"
"Add a link under point to the bookmark." t)
(autoload 'w3m-bookmark-add-current-url "w3m-bookmark"
"Add a url of the current page to the bookmark." t)
(autoload 'w3m-bookmark-add-all-urls "w3m-bookmark"
"Add urls of all pages being visited to the bookmark." t)
(autoload 'w3m-bookmark-add "w3m-bookmark" "Add URL to bookmark.")
(autoload 'w3m-search "w3m-search"
"Search a word using search engines." t)
(autoload 'w3m-search-new-session "w3m-search"
"Search a word using search engines in a new session." t)
(autoload 'w3m-search-uri-replace "w3m-search")
(autoload 'w3m-weather "w3m-weather"
"Display a weather report." t)
(autoload 'w3m-about-weather "w3m-weather")
(autoload 'w3m-antenna "w3m-antenna"
"Report changes of web sites." t)
(autoload 'w3m-antenna-add-current-url "w3m-antenna"
"Add a link address of the current page to the antenna database." t)
(autoload 'w3m-about-antenna "w3m-antenna")
(autoload 'w3m-dtree "w3m-dtree"
"Display a directory tree." t)
(autoload 'w3m-about-dtree "w3m-dtree")
(autoload 'w3m-namazu "w3m-namazu"
"Search files with Namazu." t)
(autoload 'w3m-about-namazu "w3m-namazu")
(autoload 'w3m-perldoc "w3m-perldoc"
"View Perl documents" t)
(autoload 'w3m-about-perldoc "w3m-perldoc")
(autoload 'w3m-fontify-forms "w3m-form")
(autoload 'w3m-fontify-textareas "w3m-form")
(autoload 'w3m-form-textarea-file-cleanup "w3m-form")
(autoload 'w3m-form-textarea-files-remove "w3m-form")
(autoload 'w3m-form-kill-buffer "w3m-form")
(autoload 'w3m-form-set-number "w3m-form")
(autoload 'w3m-filter "w3m-filter")
(autoload 'w3m-setup-tab-menu "w3m-tabmenu")
(autoload 'w3m-setup-bookmark-menu "w3m-bookmark")
(autoload 'w3m-switch-buffer "w3m-tabmenu")
(autoload 'w3m-cookie-set "w3m-cookie")
(autoload 'w3m-cookie-get "w3m-cookie")
(autoload 'w3m-cookie "w3m-cookie")
(autoload 'w3m-about-cookie "w3m-cookie")
(autoload 'w3m-cookie-shutdown "w3m-cookie" nil t)
(autoload 'report-emacs-w3m-bug "w3m-bug" nil t)
(autoload 'w3m-replace-symbol "w3m-symbol" nil t)
(autoload 'w3m-mail "w3m-mail" nil t)
(autoload 'w3m-lnum-mode "w3m-lnum" nil t)
(autoload 'w3m-lnum-follow "w3m-lnum" nil t)
(autoload 'w3m-lnum-goto "w3m-lnum" nil t)
(autoload 'w3m-lnum-universal "w3m-lnum" nil t)
(autoload 'w3m-lnum-toggle-inline-image "w3m-lnum" nil t)
(autoload 'w3m-lnum-view-image "w3m-lnum" nil t)
(autoload 'w3m-lnum-external-view-this-url "w3m-lnum" nil t)
(autoload 'w3m-lnum-edit-this-url "w3m-lnum" nil t)
(autoload 'w3m-lnum-print-this-url "w3m-lnum" nil t)
(autoload 'w3m-lnum-download-this-url "w3m-lnum" nil t)
(autoload 'w3m-lnum-bookmark-add-this-url "w3m-lnum" nil t)
(autoload 'w3m-lnum-zoom-in-image "w3m-lnum" nil t)
(autoload 'w3m-lnum-zoom-out-image "w3m-lnum" nil t)
(autoload 'w3m-session-select "w3m-session"
"Select session from session list." t)
(autoload 'w3m-session-save "w3m-session"
"Save list of displayed session." t)
(autoload 'w3m-setup-session-menu "w3m-session")
(autoload 'w3m-session-automatic-save "w3m-session")
(autoload 'w3m-session-deleted-save "w3m-session")
(autoload 'w3m-session-last-autosave-session "w3m-session")
(autoload 'w3m-session-goto-session "w3m-session")
(autoload 'w3m-session-crash-recovery-save "w3m-session")
(autoload 'w3m-session-last-crashed-session "w3m-session"))
;; Avoid byte-compile warnings.
(autoload 'doc-view-mode "doc-view" nil t)
(autoload 'doc-view-mode-p "doc-view")
(autoload 'image-backward-hscroll "image-mode" nil t)
(autoload 'image-bol "image-mode" nil t)
(autoload 'image-eol "image-mode" nil t)
(autoload 'image-forward-hscroll "image-mode" nil t)
(autoload 'image-mode-setup-winprops "image-mode")
(autoload 'image-scroll-down "image-mode" nil t)
(autoload 'image-scroll-up "image-mode" nil t)
(autoload 'quit-window "window" nil t)
(autoload 'rfc2368-parse-mailto-url "rfc2368")
(autoload 'widget-convert-button "wid-edit")
(autoload 'widget-forward "wid-edit" nil t)
(autoload 'widget-get "wid-edit")
(unless (fboundp 'char-to-int)
(defalias 'char-to-int 'identity))
(defvar bidi-paragraph-direction)
(defvar doc-view-mode-map)
(defvar w3m-bookmark-mode)
(defvar w3m-bookmark-menu-items)
(defvar w3m-bookmark-menu-items-pre)
(defvar w3m-tab-menubar-make-items-preitems)
(defvar w3m-session-menu-items-pre)
(defvar w3m-session-menu-items))
(defconst emacs-w3m-version
(let ((rev "$Revision$"))
(and (string-match "\\.\\([0-9]+\\) \\$\\'" rev)
(setq rev (- (string-to-number (match-string 1 rev)) 1136))
(format "1.4.%d" (+ rev 50)))))
"Version number of this package.")
(defgroup w3m nil
"Emacs-w3m - the web browser of choice."
:group 'hypermedia)
(defgroup w3m-face nil
"Faces used for emacs-w3m."
:group 'w3m
:prefix "w3m-")
(defcustom w3m-command nil
"*Name of the executable file of the w3m command.
You normally don't have to specify the value, since emacs-w3m looks
for the existing commands in order of w3m, w3mmee and w3m-m17n in the
`exec-path' directories in order if it is nil in the beginning.
If you want to use the other w3m command, specify the value of this
variable explicitly in the .emacs file or customize the value and save
it. In this case, you need to restart Emacs and emacs-w3m. That is,
there is currently no way to apply the changing of the w3m command to
all the emacs-w3m programs safely after loading the w3m.elc module."
:group 'w3m
:type '(radio (const :format "Not specified " nil)
(string :format "Command: %v\n" :size 0)))
(defcustom w3m-display-ins-del 'auto
"*Value of `display_ins_del' option."
:group 'w3m
:type '(radio (const :format "Delect automatically" auto)
(const :format "Use fontify" fontify)
(const :format "Use tag" tag)
(const :format "No have option" nil)))
(defvar w3m-type nil
"Type of the w3m command.
The valid values include `w3m', `w3mmee', and `w3m-m17n'.")
(defvar w3m-compile-options nil
"Compile options that the w3m command was built with.")
(defvar w3m-version nil
"Version string of the w3m command.")
;; Set w3m-command, w3m-type, w3m-version and w3m-compile-options
(if noninteractive ;; Don't call the external command when compiling.
(unless w3m-command
(setq w3m-command "w3m"))
(when (or (null w3m-command)
(null w3m-type)
(null w3m-version)
(null w3m-compile-options))
(let ((command (or w3m-command
(w3m-which-command "w3m")
(w3m-which-command "w3mmee")
(w3m-which-command "w3m-m17n"))))
(when command
(setq w3m-command command)
(call-process command nil t nil "-version")
(goto-char (point-min))
(when (re-search-forward "version \\(w3m/0\\.[3-9]\
\\(?:-inu\\|\\(-m17n\\|\\(\\+mee\\)\\)\\)?[^,]*\\)" nil t)
(setq w3m-version (match-string 1))
(setq w3m-type
((match-beginning 3) 'w3mmee)
((match-beginning 2) 'w3m-m17n)
((match-beginning 1) 'w3m)
(t 'other))))
(when (re-search-forward "options +" nil t)
(setq w3m-compile-options
(or (split-string (buffer-substring (match-end 0)
(list nil)))
(when (member "m17n" w3m-compile-options)
(setq w3m-type 'w3m-m17n))))))))
(when (not (stringp w3m-command))
(error "\
Install w3m command in `exec-path' or set `w3m-command' variable correctly"))
(defcustom w3m-user-agent (concat "Emacs-w3m/" emacs-w3m-version
" " w3m-version)
"String used for the User-Agent field. See also `w3m-add-user-agent'."
:group 'w3m
:type '(string :size 0))
(defcustom w3m-add-user-agent t
"Non-nil means add the User-Agent field to the request header.
The value of `w3m-user-agent' is used for the field body."
:group 'w3m
:type 'boolean)
(defcustom w3m-language
(if (and (boundp 'current-language-environment)
;; In XEmacs 21.5 it may be the one like "Japanese (UTF-8)".
(string-match "\\`Japanese"
(symbol-value 'current-language-environment)))
"*Your preferred language used in emacs-w3m sessions."
:group 'w3m
:type '(radio (const :format "%v " "Japanese")
(const :tag "Other" nil))
:get (lambda (symbol)
(let ((value (format "%s" (default-value symbol)))
(case-fold-search t))
(setq value (if (string-match "\\`japan" value) "Japanese"))
(custom-set-default symbol value))))
:set (lambda (symbol value)
(custom-set-default symbol (if (equal value "Japanese") "Japanese"))))
(defcustom w3m-command-arguments
(if (eq w3m-type 'w3mmee) '("-o" "concurrent=0" "-F") nil)
"*List of the default arguments passed to the w3m command.
See also `w3m-command-arguments-alist'."
:group 'w3m
:type '(repeat (string :format "Argument: %v\n" :size 0)))
(defcustom w3m-command-arguments-alist nil
"*Alist of regexps matching urls and additional arguments passed to w3m.
A typical usage of this variable is to specify whether to use the proxy
server for the particular hosts. The first match made will be used.
Here is an example of how to set this variable:
\(setq w3m-command-arguments-alist
'(;; Don't use the proxy server to visit local web pages.
;; Use the proxy server to visit any foreign urls.
\"-o\" \"http_proxy=\")))
Where the first element matches the url that the scheme is \"http\" and
the hostname is either \"\" or a name ended with
\"\", and the proxy server is not used for those hosts.
If you are a novice on the regexps, you can use the
`w3m-no-proxy-domains' variable instead."
:group 'w3m
:type '(repeat (cons :format "%v" :indent 4
(regexp :format "%t: %v\n" :size 0)
(repeat :tag "Arguments passed to w3m command"
(string :format "Arg: %v\n" :size 0)))))
(defcustom w3m-no-proxy-domains nil
"*List of domain names with which emacs-w3m will not use a proxy server.
Each element should be exactly a domain name which means the latter
common part of the host names, not a regexp."
:group 'w3m
:type '(repeat (string :format "Domain name: %v\n" :size 0)))
(defcustom w3m-command-environment
(delq nil
(if (eq w3m-type 'w3mmee)
(cons "W3MLANG" "ja_JP.kterm"))
(if (eq system-type 'windows-nt)
(cons "CYGWIN" "binmode"))))
"*Alist of environment variables for subprocesses to inherit."
:group 'w3m
:type '(repeat
(cons :format "%v" :indent 4
(string :format "Name: %v\n" :size 0)
(string :format " Value: %v\n" :size 0))))
(defcustom w3m-fill-column -1
"*Integer used as the value for `fill-column' in emacs-w3m buffers.
If it is positive, pages will be displayed within the columns of that
number. If it is zero or negative, the number of columns which
subtracted that number from the window width is applied to the maximum
width of pages. Note that XEmacs does not always obey this setting."
:group 'w3m
:type '(integer :size 0))
(defcustom w3m-mailto-url-function nil
"*Function used to handle the `mailto' urls.
Function is called with one argument, just a url. If it is nil, a
function specified by the `mail-user-agent' variable will be used for
composing mail messages."
:group 'w3m
:type '(radio (const :tag "Not specified" nil)
(function :format "%t: %v\n" :size 0)))
(defcustom w3m-mailto-url-popup-function-alist
'((cmail-mail-mode . pop-to-buffer)
(mail-mode . pop-to-buffer)
(message-mode . pop-to-buffer)
(mew-draft-mode . pop-to-buffer)
(mh-letter-mode . pop-to-buffer)
(wl-draft-mode . pop-to-buffer))
"*Alist of (MAJOR-MODE . FUNCTION) pairs used to pop to a mail buffer up.
If a user clicks on a `mailto' url and a mail buffer is composed by
`mail-user-agent' with the MAJOR-MODE, FUNCTION will be called with a
mail buffer as an argument. Note that the variables
`special-display-buffer-names', `special-display-regexps',
`same-window-buffer-names' and `same-window-regexps' will be bound to
nil while popping to a buffer up."
:group 'w3m
:type '(repeat (cons :format "%v" :indent 11
(symbol :format "Major-mode: %v\n" :size 0)
(function :format "%t: %v\n" :size 0))))
(defcustom w3m-use-mule-ucs
(and (eq w3m-type 'w3m) (featurep 'un-define))
"*Non-nil means use the multi-script support with Mule-UCS."
:group 'w3m
:type 'boolean
:require 'w3m-ucs)
(when w3m-use-mule-ucs
(condition-case nil
(require 'w3m-ucs)
(error (setq w3m-use-mule-ucs nil))))
(defcustom w3m-use-ange-ftp nil
"*Non-nil means that `ange-ftp' or `efs' is used to access FTP servers."
:group 'w3m
:type 'boolean)
(defcustom w3m-doc-view-content-types
(condition-case nil
(delq nil (mapcar (lambda (type)
(if (doc-view-mode-p type)
(format "application/%s" type)))
'(dvi postscript pdf)))
(error nil))
"List of content types for which to use `doc-view-mode' to view contents.
This overrides `w3m-content-type-alist'."
:group 'w3m
:type '(repeat (string :tag "Type" :value "application/")))
(defcustom w3m-imitate-widget-button '(eq major-mode 'gnus-article-mode)
"*If non-nil, imitate the widget buttons on link (anchor) buttons.
It is useful for moving about in a Gnus article buffer using TAB key.
It can also be any Lisp form that should return a boolean value."
:group 'w3m
:type '(sexp :size 0))
(defcustom w3m-treat-image-size t
"*Non-nil means let w3m mind the ratio of the size of images and text.
If it is non-nil, the w3m command will make a halfdump which reserves
rectangle spaces in which images will be put, and also `alt' texts
will be truncated or padded with spaces so that their display width
will be the same as the width of images.
See also `w3m-pixels-per-character' and `w3m-pixels-per-line'. Those
values will be passed to the w3m command in order to compute columns
and lines which images occupy."
:group 'w3m
:type 'boolean)
(defcustom w3m-pixels-per-line 64
"*Integer used for the `-ppl' argument of the w3m command.
If nil, the height of the default face is used. It is valid only when
`w3m-treat-image-size' is non-nil. Note that a small value may not
induce a good result. If you want to use emacs-w3m in a character
terminal and make `w3m-treat-image-size' effective, you need to set
this variable properly."
:group 'w3m
:type '(choice (const :tag "Auto Detect" nil)
(integer :tag "Specify Pixels")))
(defcustom w3m-pixels-per-character nil
"*Integer used for the `-ppc' argument of the w3m command.
If nil, the width of the default face is used. It is valid only when
`w3m-treat-image-size' is non-nil. If you want to use emacs-w3m in a
character terminal and make `w3m-treat-image-size' effective, you need
to set this variable properly."
:group 'w3m
:type '(radio (const :tag "Auto Detect" nil)
(integer :format "Specify Pixels: %v\n" :size 0)))
(defcustom w3m-image-default-background nil
"Color name used as transparent color of image.
Nil means to use the background color of the Emacs frame. Note that
this value is effective only to xbm and monochrome pbm images in Emacs
22 and greater."
:group 'w3m
:type '(radio (string :format "Color: %v\n" :size 0
:match (lambda (widget value)
(and (stringp value) (> (length value) 0))))
(const :tag "Use the background color of the Emacs frame" nil)
(const :tag "Null string" "")))
(defvar w3m-accept-japanese-characters
(and (not noninteractive)
(featurep 'mule)
(or (memq w3m-type '(w3mmee w3m-m17n))
;; Examine whether the w3m command specified by `w3m-command'
;; uses `euc-japan' for the internal character set.
(let ((str
"<!doctype html public \"-//W3C//DTD HTML 3.2//EN\">"
"<html><head><meta http-equiv=\"Content-Type\" "
"content=\"text/html; charset=ISO-2022-JP\">"
(string 27 36 66 52 65 59 122 27 40 66)))))
(set-buffer-multibyte nil)
(insert str)
(let ((coding-system-for-write 'binary)
(coding-system-for-read 'binary)
(default-process-coding-system (cons 'binary 'binary)))
(call-process-region (point-min) (point-max) w3m-command
t t nil "-T" "text/html" "-halfdump")
(goto-char (point-min))
(and (re-search-forward (string ?\264 ?\301 ?\273 ?\372)
nil t)
"Non-nil means that the w3m command accepts Japanese characters.")
(defcustom w3m-coding-system (if (featurep 'mule)
(if (eq w3m-type 'w3mmee)
"*Default coding system used to communicate with the w3m command."
:group 'w3m
:type '(coding-system :size 0))
(defcustom w3m-terminal-coding-system
(if w3m-accept-japanese-characters
'euc-japan 'iso-8859-1)
"*Default coding system used when writing to w3m processes.
It is just a default value to set process' coding system initially.
\(This variable name is analogically derived from the behavior of the
w3m command which accepts data from Emacs just like reads from the
:group 'w3m
:type '(coding-system :size 0))
(defcustom w3m-output-coding-system
((not (featurep 'mule)) 'iso-8859-1)
((eq w3m-type 'w3mmee) 'ctext)
((eq w3m-type 'w3m-m17n)
(if (and (w3m-find-coding-system 'utf-8)
(not (and (equal "Japanese" w3m-language)
(featurep 'w3m-ems)
(= emacs-major-version 21))))
(w3m-accept-japanese-characters 'w3m-euc-japan)
(t 'w3m-iso-latin-1))
"*Coding system used when reading from w3m processes."
:group 'w3m
:type '(coding-system :size 0))
(defcustom w3m-input-coding-system
(if (memq w3m-type '(w3mmee w3m-m17n))
(if w3m-accept-japanese-characters
(if w3m-use-mule-ucs
(if (featurep 'w3m-ems)
(if w3m-use-mule-ucs
(if (featurep 'w3m-ems)
"*Coding system used when writing to w3m processes.
It overrides `coding-system-for-write' if it is not `binary'.
Otherwise, the value of the `w3m-current-coding-system' variable is
used instead."
:group 'w3m
:type '(coding-system :size 0))
(defcustom w3m-file-coding-system (if (featurep 'mule)
"*Coding system used when writing configuration files.
This value will be referred to by the `w3m-save-list' function."
:group 'w3m
:type '(coding-system :size 0))
(defvar w3m-file-coding-system-for-read nil
"*Coding system used when reading configuration files.
It is strongly recommended that you do not set this variable if there
is no particular reason. The value will be referred to by the
`w3m-load-list' function.")
(defcustom w3m-file-name-coding-system
(if (memq system-type '(windows-nt OS/2 emx))
'shift_jis 'euc-japan)
"*Coding system used to convert pathnames when emacs-w3m accesses files."
:group 'w3m
:type '(coding-system :size 0))
(defcustom w3m-default-coding-system
(if (equal "Japanese" w3m-language) 'shift_jis 'iso-8859-1)
"*Default coding system used to encode url strings and post-data."
:group 'w3m
:type '(coding-system :size 0))
(defcustom w3m-coding-system-priority-list
(if (equal "Japanese" w3m-language) '(shift_jis))
"*Coding systems in order of priority used for emacs-w3m sessions."
:group 'w3m
:type '(repeat (coding-system :format "%t: %v\n" :size 0)))
(defcustom w3m-url-coding-system-alist
. (lambda (url)
(if (string-match "&ie=\\([^&]+\\)" url)
(w3m-charset-to-coding-system (match-string 1 url)))))
(nil . utf-8))
"Alist of url regexps and coding systems used to encode url to retrieve.
The form looks like:
((\"REGEXP\" . CODING) (\"REGEXP\" . CODING)...(nil . CODING))
Where REGEXP is a regular expression that matches a url. REGEXP nil
means any url; element of which the car is nil, that is the default,
has to be the last item of this alist.
CODING is a coding system used to encode a url that REGEXP matches.
CODING nil means using the coding system corresponding to a charset
used to encode the current page. CODING may also be a function that
takes one argument URL and returns a coding system.
If the site requires a browser to use `shift_jis' to encode
url for example, you can add it to this variable as follows:
'(\"\\\\`https?://\\\\(?:[^./?#]+\\\\.\\\\)*example\\\\.com/\" . shift_jis))"
:group 'w3m
:type '(repeat (cons :format "%v" :indent 2
(radio :format "%v"
(const :format "Any " nil)
(radio :format "%v"
(const :format "Page's coding system " nil)
(defcustom w3m-key-binding nil
"*Type of key binding set used in emacs-w3m sessions.
The valid values include `info' which provides Info-like keys, and
nil which provides Lynx-like keys."
:group 'w3m
:type '(choice
(const :tag "Use Info-like key mapping." info)
(const :tag "Use Lynx-like key mapping." nil))
;; Since the following form won't be byte-compiled, you developers
;; should never use CL macros like `caaaar', `when', `unless' ...
:set (lambda (symbol value)
(custom-set-default symbol value)
(if (or noninteractive
;; Loading w3m.elc is just in progress...
(not (featurep 'w3m)))
(if (and;; Gnus binds `w3m-mode-map' for compiling.
(boundp 'w3m-mode-map)
(boundp 'w3m-info-like-map)
(boundp 'w3m-lynx-like-map))
;; It won't be bound at the first time.
'(setq w3m-mode-map (if (eq value 'info)
w3m-minor-mode-map (w3m-make-minor-mode-keymap))))
(let ((buffers (buffer-list)))
(while buffers
(set-buffer (car buffers))
(if (eq major-mode 'w3m-mode)
(condition-case nil
(use-local-map (symbol-value 'w3m-mode-map))
(setq buffers (cdr buffers)))))))))
(defcustom w3m-use-cygdrive (eq system-type 'windows-nt)
"*If non-nil, use the /cygdrive/ rule when performing `expand-file-name'."
:group 'w3m
:type 'boolean)
(defconst w3m-treat-drive-letter (memq system-type '(windows-nt OS/2 emx))
"Say whether the system uses drive letters."))
(defcustom w3m-profile-directory
(concat "~/." (file-name-sans-extension
(file-name-nondirectory w3m-command)))
"*Directory where emacs-w3m config files are loaded from or saved to."
:group 'w3m
:type '(directory :size 0))
(defcustom w3m-init-file "~/.emacs-w3m"
"*Your emacs-w3m startup file name.
If a file with the `.el' or `.elc' suffixes exists, it will be read
instead. Nil means no init file will be loaded.
Note: This file is used as the startup configuration *NOT* for the w3m
command but for emacs-w3m. In order to modify configurations for the
w3m command, edit the file named \"~/.w3m/config\" normally."
:group 'w3m
:type '(radio file (const :format "None " nil)))
(defcustom w3m-default-save-directory
(concat "~/." (file-name-sans-extension
(file-name-nondirectory w3m-command)))
"*Default directory where downloaded files will be saved to."
:group 'w3m
:type '(directory :size 0))
(defcustom w3m-default-directory nil
"*Directory used as the current directory in emacs-w3m buffers.
The valid values include a string specifying an existing directory,
a symbol of which the value specifies an existing directory,
a function which takes a url as an argument and returns a directory,
and nil. If the specified directory does not exist or it is nil,
the value of `w3m-profile-directory' is used.
Note that there is an exception: if a page visits a local file or
visits a remote file using ftp, the directory in which the file exists
is used as the current directory instead."
:group 'w3m
:type '(radio (directory :format "%{%t%}: %v\n" :size 0 :value "~/")
(symbol :format "%{%t%}: %v\n"
:match (lambda (widget value) value)
:size 0
:value default-directory)
(function :format "%{%t%}: %v\n"
:size 0)
(const nil)))
(defcustom w3m-accept-languages
(let ((file (expand-file-name "config" w3m-profile-directory)))
(or (when (file-readable-p file)
(insert-file-contents file)
(goto-char (point-min))
(when (re-search-forward "^accept_language[\t ]+\\(.+\\)$" nil t)
(delete "" (split-string (match-string 1)
"[ \t\r\f\n]*,[ \t\r\f\n]*")))))
(when (string= w3m-language "Japanese")
'("ja" "en"))))
"*List of acceptable languages in descending order of priority.
The default value is set according to the accept_language entry of the
w3m configuration file (normally \"~/.w3m/config\")."
:group 'w3m
:type '(repeat (string :format "Lang: %v\n" :size 0)))
(defcustom w3m-delete-duplicated-empty-lines t
"*Non-nil means display two or more continuous empty lines into single."
:group 'w3m
:type 'boolean)
(defvar w3m-display-inline-images nil
"Internal variable controls whether to show images in emacs-w3m buffers.
This variable is buffer-local which defaults to the value of
`w3m-default-display-inline-images'. Don't set it directly; modify
the `w3m-default-display-inline-images' variable or use the\
`\\<w3m-mode-map>\\[w3m-toggle-inline-images]' command
to change the appearance of images.
See also `w3m-toggle-inline-images-permanently'.")
(make-variable-buffer-local 'w3m-display-inline-images)
(defcustom w3m-default-display-inline-images nil
"*Non-nil means display images inline in emacs-w3m buffers.
You can toggle the visibility of images by the\
`\\<w3m-mode-map>\\[w3m-toggle-inline-images]' command.
See also `w3m-toggle-inline-images-permanently'."
:group 'w3m
:type 'boolean)
(defcustom w3m-toggle-inline-images-permanently t
"*Non-nil means let the visibility of images continue permanently.
The visibility of images is initialized according to
`w3m-default-display-inline-images' at the first time, and except that
it may be toggled by the `\\<w3m-mode-map>\\[w3m-toggle-inline-images]'\
command, it does not change hereafter, if
it is non-nil. Otherwise, whether images are visible is initialized
according to `w3m-default-display-inline-images' whenever you visit a
new page or reload the current page in an emacs-w3m buffer."
:group 'w3m
:type 'boolean)
(defcustom w3m-icon-directory
(let (dir)
(catch 'found-dir
(let* ((path (locate-library "w3m"))
(paths (if path
(cons (file-name-directory path) load-path)
(while paths
(setq path (car paths)
paths (cdr paths))
(if path
(if (file-directory-p
(setq dir
(expand-file-name "../../etc/images/w3m/" path)))
(throw 'found-dir dir))
(if (file-directory-p
(setq dir
(expand-file-name "../etc/images/w3m/" path)))
(throw 'found-dir dir))
(if (file-directory-p
(setq dir
(expand-file-name "../../etc/w3m/icons/" path)))
(throw 'found-dir dir))
(if (file-directory-p
(setq dir
(expand-file-name "../etc/w3m/icons/" path)))
(throw 'found-dir dir)))))))
(and (fboundp 'locate-data-directory)
(or (locate-data-directory "images/w3m")
(locate-data-directory "w3m")))
(and (file-directory-p
(setq dir (expand-file-name "images/w3m/" data-directory)))
(and (file-directory-p
(setq dir (expand-file-name "w3m/icons/" data-directory)))
"*Directory where emacs-w3m should find icon files."
:group 'w3m
:type '(radio (const :tag "Not specified")
(directory :format "%t: %v\n" :size 0)))
(defcustom w3m-broken-proxy-cache nil
"*Set it to t if the proxy server seems not to work properly in caching.
Note that this may be the double-edged sword; setting it to t will
likely be harmful if the proxy server sends bad requests (e.g., not
including the Host header, see RFC2616 section 14.23) to foreign
servers when the w3m command specifies the \"no-cache\" directive. Also
note that it may not be effective if you are using old w3m command."
:group 'w3m
:type 'boolean)
(defcustom w3m-quick-start t
"*Non-nil means let emacs-w3m start quickly w/o requiring confirmation.
When you invoke the `w3m' command, it attempts to visit the page of a
string like url around the cursor or the value of `w3m-home-page'.
You won't be asked for the confirmation then if this value is non-nil.
Otherwise, you will be prompted for that url with the editing form."
:group 'w3m
:type 'boolean)
(defcustom w3m-home-page
(or (getenv "HTTP_HOME")
(getenv "WWW_HOME")
"*This variable specifies the url string to open when emacs-w3m starts.
Don't say HP, which is the abbreviated name of a certain company. ;-)"
:group 'w3m
:type '(radio
:convert-widget w3m-widget-type-convert-widget
`(,@(if (getenv "HTTP_HOME")
`((const :format "HTTP_HOME: \"%v\"\n"
,(getenv "HTTP_HOME"))))
,@(if (getenv "WWW_HOME")
`((const :format "WWW_HOME: \"%v\"\n"
(getenv "WWW_HOME"))))
(const :tag "About emacs-w3m" "about:")
(const :tag "Blank page" "about:blank")
(string :format "URL: %v\n" :size 0))))
(defcustom w3m-arrived-file
(expand-file-name ".arrived" w3m-profile-directory)
"*Name of the file to keep the arrived URLs database."
:group 'w3m
:type '(file :size 0))
(defcustom w3m-keep-arrived-urls 500
"*Maximum number of URLs which the arrived URLs database keeps."
:group 'w3m
:type '(integer :size 0))
(defcustom w3m-prefer-cache nil
"*Non-nil means that cached contents are used without checking headers."
:group 'w3m
:type 'boolean)
(defcustom w3m-keep-cache-size 300
"*Maximum number of pages to be cached in emacs-w3m."
:group 'w3m
:type '(integer :size 0))
(defcustom w3m-follow-redirection 9
"*Maximum number of redirections which emacs-w3m honors and follows.
If nil, redirections are followed by the w3m command. Don't set it to
nil if you allow to use cookies (i.e., you have set `w3m-use-cookies'
to non-nil) since cookies may be shared among many redirected pages."
:group 'w3m
:type '(radio (const :format "Ignore redirections " nil)
(integer :size 0)))
(defcustom w3m-redirect-with-get t
"*If non-nil, use the GET method after redirection.
It controls how emacs-w3m works when a server responds the code 301 or
302. Here is an extract from RFC2616:
Note: RFC 1945 and RFC 2068 specify that the client is not allowed
to change the method on the redirected request. However, most
existing user agent implementations treat 302 as if it were a 303
response, performing a GET on the Location field-value regardless
of the original request method."
:group 'w3m
:type 'boolean)
(defcustom w3m-resize-image-scale 50
"*Number of steps in percent used when resizing images."
:group 'w3m
:type '(integer :size 0))
(defface w3m-anchor
'((((class color) (background light)) (:foreground "blue"))
(((class color) (background dark)) (:foreground "cyan"))
(t (:underline t)))
"Face used for displaying anchors."
:group 'w3m-face)
;; backward-compatibility alias
(put 'w3m-anchor-face 'face-alias 'w3m-anchor)
(defface w3m-arrived-anchor
'((((class color) (background light)) (:foreground "navy"))
(((class color) (background dark)) (:foreground "LightSkyBlue"))
(t (:underline t)))
"Face used for displaying anchors which have already arrived."
:group 'w3m-face)
;; backward-compatibility alias
(put 'w3m-arrived-anchor-face 'face-alias 'w3m-arrived-anchor)
(defface w3m-current-anchor
'((t (:underline t :bold t)))
"Face used to highlight the current anchor."
:group 'w3m-face)
;; backward-compatibility alias
(put 'w3m-current-anchor-face 'face-alias 'w3m-current-anchor)
(defface w3m-image
'((((class color) (background light)) (:foreground "ForestGreen"))
(((class color) (background dark)) (:foreground "PaleGreen"))
(t (:underline t)))
"Face used for displaying alternate strings of images."
:group 'w3m-face)
;; backward-compatibility alias
(put 'w3m-image-face 'face-alias 'w3m-image)
(defface w3m-image-anchor
'((((class color) (background light)) (:background "light yellow"))
(((class color) (background dark)) (:background "dark green"))
(t (:underline t)))
"Face used for displaying alternate strings of images which are in anchors."
:group 'w3m-face)
;; backward-compatibility alias
(put 'w3m-image-anchor-face 'face-alias 'w3m-image-anchor)
(defface w3m-history-current-url
;; The following strange code compounds the attributes of the
;; `secondary-selection' face and the `w3m-arrived-anchor' face,
;; and generates the new attributes for this face.
(let ((base 'secondary-selection)
(fn (if (featurep 'xemacs)
'custom-face-attributes-get));; What a perverseness it is.
;; Both `face-custom-attributes-get' in XEmacs and
;; `custom-face-attributes-get' in CUSTOM 1.9962 attempt to
;; require `font' in Emacs/w3 and `cl' arbitrarily. :-/
(features (cons 'font features))
base-attributes attributes attribute)
(setq base-attributes (funcall fn base nil)
attributes (funcall fn 'w3m-arrived-anchor nil))
(while base-attributes
(setq attribute (car base-attributes))
(unless (memq attribute '(:foreground :underline))
(setq attributes (plist-put attributes attribute
(cadr base-attributes))))
(setq base-attributes (cddr base-attributes)))
(list (list t attributes)))
"Face used to highlight the current url in the \"about://history/\" page."
:group 'w3m-face)
;; backward-compatibility alias
(put 'w3m-history-current-url-face 'face-alias 'w3m-history-current-url)
(defface w3m-bold '((t (:bold t)))
"Face used for displaying bold text."
:group 'w3m-face)
;; backward-compatibility alias
(put 'w3m-bold-face 'face-alias 'w3m-bold)
(defface w3m-italic '((((type tty)) (:underline t))
(t (:italic t)))
"Face used for displaying italic text.
By default it will be a underline face on a non-window system."
:group 'w3m-face)
;; backward-compatibility alias
(put 'w3m-italic-face 'face-alias 'w3m-italic)
(defface w3m-underline '((t (:underline t)))
"Face used for displaying underlined text."
:group 'w3m-face)
;; backward-compatibility alias
(put 'w3m-underline-face 'face-alias 'w3m-underline)
(defface w3m-strike-through
`((((class color))
,(if (featurep 'xemacs)
'(:strikethru t)
'(:strike-through t)))
(t (:underline t)))
"Face used for displaying strike-through text."
:group 'w3m-face)
;; backward-compatibility alias
(put 'w3m-strike-through-face 'face-alias 'w3m-strike-through)
(defface w3m-insert
'((((class color) (background light))
(:foreground "purple"))
(((class color) (background dark))
(:foreground "orchid"))
(t (:underline t)))
"Face used for displaying insert text."
:group 'w3m-face)
;; backward-compatibility alias
(put 'w3m-insert-face 'face-alias 'w3m-insert)
(defcustom w3m-mode-hook nil
"*Hook run after `w3m-mode' initialization.
This hook is evaluated by the `w3m-mode' function."
:group 'w3m
:type 'hook)
(defcustom w3m-fontify-before-hook nil
"*Hook run when starting to fontify emacs-w3m buffers.
This hook is evaluated by the `w3m-fontify' function."
:group 'w3m
:type 'hook)
(defcustom w3m-fontify-after-hook nil
"*Hook run after fontifying emacs-w3m buffers.
This hook is evaluated by the `w3m-fontify' function."
:group 'w3m
:type 'hook)
(defcustom w3m-display-hook
"*Hook run after displaying pages in emacs-w3m buffers.
Each function is called with a url string as the argument. This hook
is evaluated by the `w3m-goto-url' function."
:group 'w3m
:type 'hook
:initialize 'w3m-custom-hook-initialize)
(defcustom w3m-after-cursor-move-hook
"*Hook run each time after the cursor moves in emacs-w3m buffers.
This hook is called by the `w3m-check-current-position' function by
way of `post-command-hook'."
:group 'w3m
:type 'hook
:initialize 'w3m-custom-hook-initialize)
(defcustom w3m-delete-buffer-hook
"*Hook run when every emacs-w3m buffer is deleted."
:group 'w3m
:type 'hook
:initialize 'w3m-custom-hook-initialize)
(defcustom w3m-select-buffer-hook nil
"*Hook run when a different emacs-w3m buffer is selected."
:group 'w3m
:type 'hook)
(defcustom w3m-async-exec t
"*Non-nil means execute the w3m command asynchronously in Emacs process."
:group 'w3m
:type 'boolean)
;; As far as we know, Emacs 21 under Mac OS X[1] and XEmacs under
;; Solaris[2] won't run the asynchronous operations correctly when
;; both `w3m-async-exec' and `w3m-process-connection-type' are non-nil;
;; [1]the final kilobyte or so might get lost from raw data downloaded
;; from a web site; [2]XEmacs hangs up.
(defcustom w3m-process-connection-type
(not (or (and (memq system-type '(darwin macos))
(let ((ver (shell-command-to-string "uname -r")))
(and (string-match "^\\([0-9]+\\)\\." ver)
(< (string-to-number (match-string 1 ver)) 7))))
(and (featurep 'xemacs)
(string-match "solaris" system-configuration))))
"*Value for `process-connection-type' used when communicating with w3m."
:group 'w3m
:type 'boolean)
(defcustom w3m-async-exec-with-many-urls
;; XEmacs 21.5 tends to freeze when retrieving many urls at a time. :-<
(not (and (featurep 'xemacs) (not (featurep 'sxemacs))
(= emacs-major-version 21) (= emacs-minor-version 5)))
"Non-nil means allow retrieving many urls asynchronously.
The value affects how emacs-w3m will work with group:* urls and the
`w3m-session-select' feature. If it is nil, the asynchronous operation
is inhibited in those cases even if `w3m-async-exec' is non-nil."
:group 'w3m
:type 'boolean)
(defcustom w3m-default-content-type "text/html"
"*Default value assumed as the content type of local files."
:group 'w3m
:type '(string :size 0))
(defvar w3m-image-viewer
(or (w3m-which-command "display")
(w3m-which-command "eeyes")
(w3m-which-command "xloadimage")
(w3m-which-command "xv"))
"*Command used to view image files externally.
Note that this option is installed temporally. It will be abolished
when we implement the mailcap parser to set `w3m-content-type-alist'.")
;; FIXME: we need to improve so that to set up the value of this
;; variable may be performed by parsing the mailcap file.
(defcustom w3m-content-type-alist
(let* ((fiber-viewer (when (and (eq system-type 'windows-nt)
(w3m-which-command "fiber"))
(list "fiber.exe" "-s" 'file)))
(if (and (eq system-type 'windows-nt) (w3m-which-command "fiber"))
(or (when (condition-case nil (require 'browse-url) (error nil))
(let ((default
((and (memq system-type '(windows-nt ms-dos cygwin))
(fboundp 'browse-url-default-windows-browser))
((and (memq system-type '(darwin))
(fboundp 'browse-url-default-macosx-browser))
((fboundp 'browse-url-default-browser)
((fboundp 'browse-url-netscape)
(if (or (not (boundp 'browse-url-browser-function))
(eq 'w3m-browse-url
(symbol-value 'browse-url-browser-function)))
(if (functionp browse-url-browser-function)
(symbol-value 'browse-url-browser-function)
(catch 'browser
(let ((alist browse-url-browser-function))
(while alist
(when (string-match (caar alist) "index.html")
(throw 'browser (cdar alist)))
(setq alist (cdr alist)))
(message "Found no html handler in \
browse-url-browser-function to put in w3m-content-type-alist.")
(when (w3m-which-command "netscape")
(list "netscape" 'url)))))
(image-viewer (or fiber-viewer
(when w3m-image-viewer
(list w3m-image-viewer 'file))))
(video-viewer (or fiber-viewer
(when (w3m-which-command "mpeg_play")
(list "mpeg_play" 'file))))
(dvi-viewer (or fiber-viewer
(cond ((w3m-which-command "xdvi") (list "xdvi" 'file))
((w3m-which-command "dvitty")
(list "dvitty" 'file)))))
(ps-viewer (or fiber-viewer
((w3m-which-command "gv") (list "gv" 'file))
((w3m-which-command "gs") (list "gs" 'file)))))
(pdf-viewer (or fiber-viewer
((w3m-which-command "xpdf") (list "xpdf" 'file))
((w3m-which-command "acroread")
(list "acroread" 'file))))))
`(("text/plain" "\\.\\(?:txt\\|tex\\|el\\)\\'" nil nil)
("text/html" "\\.s?html?\\'" ,external-browser nil)
("text/sgml" "\\.sgml?\\'" nil "text/plain")
("text/xml" "\\.xml\\'" nil "text/plain")
("image/jpeg" "\\.jpe?g\\'" ,image-viewer nil)
("image/png" "\\.png\\'" ,image-viewer nil)
("image/gif" "\\.gif\\'" ,image-viewer nil)
("image/tiff" "\\.tif?f\\'" ,image-viewer nil)
("image/x-xwd" "\\.xwd\\'" ,image-viewer nil)
("image/x-xbm" "\\.xbm\\'" ,image-viewer nil)
("image/x-xpm" "\\.xpm\\'" ,image-viewer nil)
("image/x-bmp" "\\.bmp\\'" ,image-viewer nil)
("video/mpeg" "\\.mpe?g\\'" ,video-viewer nil)
("video/quicktime" "\\.mov\\'" ,video-viewer nil)
("application/dvi" "\\.dvi\\'" ,dvi-viewer nil)
("application/postscript" "\\.e?ps\\'" ,ps-viewer nil)
("application/pdf" "\\.pdf\\'" ,pdf-viewer nil)
("application/x-pdf" "\\.pdf\\'" ,pdf-viewer nil)
("application/xml" "\\.xml\\'" nil w3m-detect-xml-type)
("application/rdf+xml" "\\.rdf\\'" nil "text/plain")
("application/rss+xml" "\\.rss\\'" nil "text/plain")
("application/xhtml+xml" nil nil "text/html")))
"*Alist of content types, regexps, commands to view, and filters.
Each element is a list which consists of the following data:
1. Content type.
2. Regexp matching a url or a file name.
3. Method to view contents. The following three types may be used:
a. Lisp function which takes the url to view as an argument.
b. (\"COMMAND\" [ARG...]) -- where \"COMMAND\" is the external command
and ARG's are the arguments passed to the command if any. The
symbols `file' and `url' that appear in ARG's will be replaced
respectively with the name of a temporary file which contains
the contents and the string of the url to view.
c. nil which means to download the url into the local file.
4. Content type that overrides the one specified by `1. Content type'.
Valid values include:
a. Lisp function that takes three arguments URL, CONTENT-TYPE, and
CHARSET, and returns a content type.
b. String that specifies a content type.
c. nil that means not to override the content type."
:group 'w3m
:type '(repeat
:indent 2
(string :format "Type: %v\n" :size 0)
(radio :format "%{Regexp%}: %v" :extra-offset 8
:sample-face underline
(const :tag "Not specified" nil)
(regexp :format "String: %v\n" :size 0))
(radio :format "%{Viewer%}: %v" :extra-offset 8
:sample-face underline
(const :tag "Not specified" nil)
(cons :tag "External viewer" :extra-offset 2
(string :format "Command: %v\n" :size 0)
(repeat :format "Arguments:\n%v%i\n" :extra-offset 2
:format "%v\n"
:match-alternatives (stringp 'file 'url)
:size 0)))
(function :format "%t: %v\n" :size 0))
(radio :format "%{Filter%}: %v" :extra-offset 8
:sample-face underline
(const :tag "Not specified" nil)
(string :format "Equivalent type: %v\n" :size 0)
(function :format "Function: %v\n" :size 0)))))
;; FIXME: we need to rearrange the complicated and redundant relation of
;; `w3m-encoding-type-alist', `w3m-decoder-alist', and `w3m-encoding-alist'.
(defcustom w3m-encoding-type-alist
'(("\\.gz\\'" . "gzip")
("\\.bz2?\\'" . "bzip"))
"*Alist of file suffixes and content encoding types."
:group 'w3m
:type '(repeat
(cons :format "%v" :indent 14
(string :format "Regexp of Suffixes: %v\n" :size 0)
(string :format "Encoding Type: %v\n" :size 0))))
(defcustom w3m-decoder-alist
`((gzip "gzip" ("-d")) ;; Don't use "gunzip" and "bunzip2"
(bzip "bzip2" ("-d")) ;; for broken OS and implementations.
,(if (not noninteractive)
(let ((exec-path
(let ((prefix (file-name-directory
(w3m-which-command w3m-command))))))
(list (expand-file-name "libexec/w3m" prefix)
(expand-file-name "lib/w3m" prefix)))))
(w3m-which-command "inflate")))
"Alist of encoding types, decoder commands, and arguments."
:group 'w3m
:type '(repeat
(group :indent 4
(radio :format "Encoding: %v"
(const :format "%v " gzip)
(const :format "%v " bzip)
(const deflate))
(string :format "Command: %v\n" :size 0)
(repeat :tag "Arguments" :extra-offset 2
(string :format "%v\n" :size 0)))))
(defcustom w3m-charset-coding-system-alist
(let ((rest
'((us_ascii . raw-text)
(us-ascii . raw-text)
(gb2312 . cn-gb-2312)
(cn-gb . cn-gb-2312)
(iso-2022-jp-2 . iso-2022-7bit-ss2)
(iso-2022-jp-3 . iso-2022-7bit-ss2)
(tis-620 . tis620)
(windows-874 . tis-620)
(cp874 . tis-620)
(x-ctext . ctext)
(unknown . undecided)
(x-unknown . undecided)
(windows-1250 . cp1250)
(windows-1251 . cp1251)
(windows-1252 . cp1252)
(windows-1253 . cp1253)
(windows-1254 . cp1254)
(windows-1255 . cp1255)
(windows-1256 . cp1256)
(windows-1257 . cp1257)
(windows-1258 . cp1258)
(euc-jp . euc-japan)
(shift-jis . shift_jis)
(shift_jis . shift_jis)
(sjis . shift_jis)
(x-euc-jp . euc-japan)
(x-shift-jis . shift_jis)
(x-shift_jis . shift_jis)
(x-sjis . shift_jis)))
(while rest
(or (w3m-find-coding-system (car (car rest)))
(setq dest (cons (car rest) dest)))
(setq rest (cdr rest)))
"Alist of MIME charsets and coding systems.
Both charsets and coding systems must be symbols."
:group 'w3m
:type '(repeat (cons :format "%v" :indent 2
(symbol :format "%t: %v\n" :size 0)
(coding-system :format "%t: %v\n" :size 0))))
(defcustom w3m-correct-charset-alist
'(("windows-874" . "tis-620")
("cp874" . "tis-620")
("cp1250" . "windows-1250")
("cp1251" . "windows-1251")
("cp1252" . "windows-1252")
("cp1253" . "windows-1253")
("cp1254" . "windows-1254")
("cp1255" . "windows-1255")
("cp1256" . "windows-1256")
("cp1257" . "windows-1257")
("cp1258" . "windows-1258")
("shift-jis" . "shift_jis")
("sjis" . "shift_jis")
("x-euc-jp" . "euc-jp")
("x-shift-jis" . "shift_jis")
("x-shift_jis" . "shift_jis")
("x-sjis" . "shift_jis"))
"Alist of MIME charsets; strange ones and standard ones."
:group 'w3m
:type '(repeat (cons :format "%v" :indent 11
(string :format "From: %v\n" :size 0)
(string :format "To: %v\n" :size 0))))
(defcustom w3m-horizontal-scroll-columns 10
"*Number of steps in columns used when scrolling a window horizontally."
:group 'w3m
:type '(integer :size 0))
(defcustom w3m-horizontal-shift-columns 2
"*Number of steps in columns used when shifting a window horizontally.
The term `shifting' means a fine level scrolling."
:group 'w3m
:type '(integer :size 0))
(defcustom w3m-view-recenter 1
"Recenter window contents when going to an anchor.
An integer is passed to `recenter', for instance the default 1
means put the anchor on the second line of the screen.
t means `recenter' with no arguments, which puts it in the middle
of the screen.
nil means don't recenter, let the display follow point in the
usual way."
:group 'w3m
;; radio items in the same order as in the docstring, and `integer' first
;; because it's the default
:type '(radio (integer :format "%{%t%}: %v\n" :value 1 :size 1)
(const :format "%t\n" t)
(const :format "%t\n" nil)))
(defcustom w3m-use-form t
"*Non-nil means make it possible to use form extensions. (EXPERIMENTAL)"
:group 'w3m
:type 'boolean
:require 'w3m-form)
(defcustom w3m-submit-form-safety-check nil
"Non-nil means ask you for confirmation when submitting a form."
:group 'w3m
:type 'boolean)
(defcustom w3m-use-cookies nil
"*Non-nil means enable emacs-w3m to use cookies. (EXPERIMENTAL)"
:group 'w3m
:type 'boolean)
(defcustom w3m-use-filter nil
"*Non-nil means use filter programs to convert web contents.
See also `w3m-filter-configuration'."
:group 'w3m
:type 'boolean
:require 'w3m-filter)
(defcustom w3m-use-symbol
(when (and (featurep 'mule)
(eq w3m-type 'w3m-m17n))
(if (eq w3m-output-coding-system 'utf-8)
(and (w3m-mule-unicode-p)
(or (featurep 'xemacs)
(< emacs-major-version 23))
"*Non-nil means replace symbols that the <_SYMBOL> tags lead into.
It is meaningful only when the w3m-m17n command is used and (X)Emacs
handles unicode charsets."
:group 'w3m
:type 'boolean
:require 'w3m-symbol)
(defcustom w3m-edit-function 'find-file
"*Function used for editing local files.
It is used when either `w3m-edit-current-url' or `w3m-edit-this-url'
is invoked for local pages."
:group 'w3m
:type '(radio
(const :tag "Edit it in the current window" find-file)
(const :tag "Edit it in another window" find-file-other-window)
(const :tag "Edit it in another frame" find-file-other-frame)
(const :tag "View it in another window" view-file-other-window)
(function :format "Other function: %v\n" :size 0
:value view-file)))
(defcustom w3m-edit-function-alist
'(("\\`[^?]+/hiki\\.cgi\\?" . hiki-edit-url))
"*Alist of functions used for editing pages.
This option is referred to decide which function should be used to
edit a specified page, when either `w3m-edit-current-url' or
`w3m-edit-this-url' is invoked. When no suitable function is found
from this alist, `w3m-edit-function' is used."
:group 'w3m
:type '(repeat (cons :format "%v" :indent 3
(regexp :format "URL: %v\n" :size 0)
(defcustom w3m-url-local-directory-alist
(when (boundp 'yahtml-path-url-alist)
(lambda (pair)
(cons (cdr pair) (car pair)))
(symbol-value 'yahtml-path-url-alist)))
"*Alist of URLs and local directories.
If directory names of a given URL and the car of an element are the
same, emacs-w3m assumes that the file exists in the local directory
where the cdr of an element points to. The default value will be set
to a value of the `yahtml-path-url-alist' variable which exchanged the
car and the cdr in each element if it is available."
:type '(repeat
(cons :format "%v" :indent 3
(string :format "URL: %v\n" :size 0)
(directory :format "%t: %v\n" :size 0)))
:group 'w3m)
(defcustom w3m-track-mouse t
"*Whether to track the mouse and message the url under the mouse.
See also `show-help-function' if you are using GNU Emacs.
A tip for XEmacs users:
You can also use the `balloon-help' feature by the
`M-x balloon-help-mode' command with arg 1. If the window manager
decorates the balloon-help frame, and that is not to your taste, you
may strip it off with the following directives:
For ol[v]wm use this in .Xdefaults:
olvwm.NoDecor: balloon-help
olwm.MinimalDecor: balloon-help
For fvwm version 1 use this in your .fvwmrc:
NoTitle balloon-help
Style \"balloon-help\" NoTitle, NoHandles, BorderWidth 0
For twm use this in your .twmrc:
NoTitle { \"balloon-help\" }
See the balloon-help.el file for more information."
:group 'w3m
:type 'boolean)
(defcustom w3m-use-title-buffer-name nil
"Non-nil means use name of buffer included current title."
:group 'w3m
:type 'boolean)
(defcustom w3m-use-japanese-menu
(and (equal "Japanese" w3m-language)
;; Emacs 21, XEmacs 21.4 and SXEmacs don't seem to support
;; non-ASCII text in the popup menu.
(not (featurep 'sxemacs))
(if (featurep 'xemacs)
(or (> emacs-major-version 21)
(and (= emacs-major-version 21)
(>= emacs-minor-version 5)))
(or (>= emacs-major-version 22)
(featurep 'meadow))))
"Non-nil means use Japanese characters for Menu if possible."
:group 'w3m
:type 'boolean)
(defcustom w3m-menu-on-forefront nil
"Non-nil means place the emacs-w3m menus on the forefront of the menu bar."
:group 'w3m
:type 'boolean
:set (lambda (symbol value)
(custom-set-default symbol value)
(unless noninteractive
(w3m-menu-on-forefront value)))))
(defcustom w3m-use-tab t
"Non-nil means make emacs-w3m a tab browser.
It makes it possible to show all emacs-w3m buffers in a single window
with the tabs line, and you can choose one by clicking a mouse on it.
See also `w3m-use-tab-menubar'."
:group 'w3m
:type 'boolean)
(defcustom w3m-add-tab-number nil
"Non-nil means put sequential number to a title on tab."
:group 'w3m
:type 'boolean)
(defcustom w3m-use-tab-menubar t
"Non-nil means use the TAB pull-down menu in the menubar.
It makes it possible to show all emacs-w3m buffers in a single window,
and you can choose one by clicking a mouse on it. This feature
requires that Emacs has been built to be able to display multilingual
text in the menubar if you often visit web sites written in non-ascii
text. See also `w3m-use-tab'."
:group 'w3m
:type 'boolean)
(defcustom w3m-new-session-url "about:blank"
"*Default url to be opened in a tab or a session which is created newly."
:group 'w3m
:type '(radio
:convert-widget w3m-widget-type-convert-widget
`((const :tag "About emacs-w3m" "about:")
(const :tag "Blank page" "about:blank")
(const :tag "Bookmark" "about://bookmark/")
(const :tag ,(format "Home page (%s)" w3m-home-page)
(string :format "URL: %v\n" :size 0
:value ""))))
(defcustom w3m-make-new-session nil
"*Non-nil means making new emacs-w3m buffers when visiting new pages.
If it is non-nil and there are already emacs-w3m buffers, the `w3m'
command makes a new emacs-w3m buffer if a user specifies a url string
in the minibuffer, and the `w3m-safe-view-this-url' command also makes
a new buffer if a user invokes it in a buffer not being running the
:group 'w3m
:type 'boolean)
(defcustom w3m-use-favicon t
"*Non-nil means show favicon images if they are available.
It will be set to nil automatically if ImageMagick's `convert' program
does not support the ico format."
:get (lambda (symbol)
(and (not noninteractive)
(default-value symbol)
:set (lambda (symbol value)
(custom-set-default symbol (and (not noninteractive)
:group 'w3m
:type 'boolean)
(defcustom w3m-show-graphic-icons-in-mode-line t
"Non-nil means show graphic status indicators in the mode-line.
If it is nil, also the favicon won't be shown in the mode-line even if
`w3m-use-favicon' is non-nil."
:set (lambda (symbol value)
(custom-set-default symbol value)
(if (and (not noninteractive)
;; Make sure it is not the first time.
(featurep 'w3m)
(fboundp 'w3m-initialize-graphic-icons))
:group 'w3m
:type 'boolean)
(defcustom w3m-show-graphic-icons-in-header-line t
"Non-nil means show graphic status indicators in the header-line.
If it is nil, also the favicon won't be shown in the header-line even
if `w3m-use-favicon' is non-nil. This variable is currently
meaningless under XEmacs."
:group 'w3m
:type 'boolean)
(defcustom w3m-pop-up-windows t
"Non-nil means split the windows when a new emacs-w3m session is created.
This variable is similar to `pop-up-windows' and quite overridden by
`w3m-pop-up-frames' as if `pop-up-frames' influences. Furthermore, if
`w3m-use-tab' is non-nil or there is the buffers selection window (for
the `w3m-select-buffer' feature), this variable is ignored when
creating the second or more emacs-w3m session."
:group 'w3m
:type 'boolean)
(defcustom w3m-pop-up-frames nil
"Non-nil means pop to a new frame up for an emacs-w3m session.
This variable is similar to `pop-up-frames' and does override
`w3m-pop-up-windows'. If `w3m-use-tab' is non-nil or there is the
buffers selection window (for the `w3m-select-buffer' feature), this
variable is ignored when creating the second or more emacs-w3m session."
:group 'w3m
:type 'boolean)
(defcustom w3m-view-this-url-new-session-in-background nil
:group 'w3m
:type 'boolean)
(defcustom w3m-new-session-in-background
"*Say whether not to focus on a new tab or a new session in target.
It influences only when a new emacs-w3m buffer is created."
:group 'w3m
:type 'boolean)
(defcustom w3m-popup-frame-parameters nil
"Alist of frame parameters used when creating a new emacs-w3m frame.
It allows not only the alist form but also XEmacs's plist form."
:group 'w3m
:type '(choice (group :inline t :tag "Frame Parameters (Emacs)"
(repeat :inline t :tag "Frame Parameters (Emacs)"
(cons :format "%v" :indent 3
(symbol :format "Parameter: %v\n"
:size 0)
(sexp :format "%t: %v\n" :size 0))))
(group :inline t :tag "Frame Plist (XEmacs)"
(repeat :inline t :tag "Frame Plist (XEmacs)"
(group :indent 2 :inline t
(symbol :format "Property: %v\n"
:size 0)
(sexp :format "%t: %v\n" :size 0))))))
(defcustom w3m-auto-show t
"*Non-nil means provide the ability to horizontally scroll the window.
Automatic horizontal scrolling is made when the point gets away from
both ends of the window, but nothing occurs if `truncate-lines' is set
to nil.
This feature works with the specially made program in emacs-w3m; usual
`auto-hscroll-mode', `automatic-hscrolling', `auto-show-mode' or
`hscroll-mode' will all be invalidated in emacs-w3m buffers."
:group 'w3m
:type 'boolean)
(defcustom w3m-horizontal-scroll-division 4
"*Integer used by the program making the point certainly visible.
The cursor definitely does not go missing even when it has been driven
out of the window while wandering around anchors and forms in an
emacs-w3m buffer.
Suppose that the value of this variable is N. When the point is
outside the left of the window, emacs-w3m scrolls the window so that
the point may be displayed on the position within 1/N of the width of
the window from the left. Similarly, when the point is outside the
right of the window, emacs-w3m scrolls the window so that the point
may be displayed on the position of 1/N of the width of the window
from the right.
This feature doesn't work if `w3m-auto-show' is nil. The value must
be a larger integer than 1."
:group 'w3m
:type '(integer :size 0)
:set (lambda (symbol value)
(custom-set-default symbol (if (and (integerp value) (> value 1))
(defcustom w3m-show-error-information t
"*Non-nil means show an error information as a web page.
Page is made when the foreign server doesn't respond to a request to
retrieve data."
:group 'w3m
:type 'boolean)
(defcustom w3m-use-refresh t
"*Non-nil means honor the REFRESH attribute in META tags.
Emacs-w3m arbitrarily takes you to a url specified by that attribute.
Note that they may be malicious traps."
:group 'w3m
:type 'boolean)
(defcustom w3m-mbconv-command "mbconv"
"*Name of the \"mbconv\" command provided by the \"libmoe\" package.
The \"libmoe\" package is used when you use the w3mmee command instead
of the w3m command. See also `w3m-command'."
:group 'w3m
:type '(string :size 0))
(defcustom w3m-local-find-file-regexps
(cons nil
(concat "\\."
(regexp-opt (append '("htm"
(and (w3m-image-type-available-p 'jpeg)
'("jpeg" "jpg"))
(and (w3m-image-type-available-p 'gif)
(and (w3m-image-type-available-p 'png)
(and (w3m-image-type-available-p 'xbm)
(and (w3m-image-type-available-p 'xpm)
t) ;; with surrounding parens (for old Emacsen).
"*Cons of two regexps matching and not matching with local file names.
If a url of the `file:' scheme in which you entered matches the first
form and does not match the latter form, it will be opened by the
function specified by the `w3m-local-find-file-function' variable.
Nil for the regexp matches any file names.
For instance, the value `(nil . \"\\\\.[sx]?html?\\\\'\")' allows
\"file:///some/where/w3m.el\", not \"file:///any/where/index.html\", to
open by the function specified by `w3m-local-find-file-function'. The
latter will be opened as a normal web page. Furthermore, if you would
like to view some types of contents in the local system using the
viewers specified by the `w3m-content-type-alist' variable, you can
add regexps matching those file names to the second element of this
variable. For example:
\(setq w3m-local-find-file-regexps
'(nil . \"\\\\.\\\\(?:[sx]?html?\\\\|dvi\\\\|ps\\\\|pdf\\\\)\\\\'\"))
It is effective only when the `w3m-local-find-file-function' variable
is set properly."
:group 'w3m
:type '(cons (radio :tag "Match"
(const :format "All " nil)
(regexp :format "%t: %v\n" :size 0))
(radio :tag "Nomatch"
(const :format "All " nil)
(regexp :format "%t: %v\n" :size 0))))
(defcustom w3m-local-find-file-function
'(if (w3m-popup-frame-p)
"*Function used to open local files.
If a url of the `file:' scheme in which you entered agrees with the
rule of the `w3m-local-find-file-regexps' variable (which see), it is
used to open the file.
Function should take one argument, the string naming the local file.
It can also be any Lisp form returning a function. Set this to nil if
you want to always use emacs-w3m to see local files."
:group 'w3m
:type '(sexp :size 0))
(defcustom w3m-local-directory-view-method 'w3m-cgi
"*Symbol of the method to view a local directory tree.
The valid values include `w3m-cgi' using the CGI program specified by
the `w3m-dirlist-cgi-program' variable (which see), and `w3m-dtree'
using the w3m-dtree Lisp module."
:group 'w3m
:type '(radio (const :format "Dirlist CGI " w3m-cgi)
(const :tag "Directory tree" w3m-dtree)))
(defcustom w3m-dirlist-cgi-program
(cond ((eq system-type 'windows-nt)
((memq system-type '(OS/2 emx))
(expand-file-name "dirlist.cmd" (getenv "W3M_LIB_DIR")))
(t nil))
"*Name of the CGI program to list a local directory.
If it is nil, the dirlist.cgi module of the w3m command will be used."
:group 'w3m
:type `(radio
(const :tag "w3m internal CGI" nil)
(file :format "path of 'dirlist.cgi': %v\n"
:size 0
:value ,(if (not noninteractive)
(concat "../lib/"
(file-name-nondirectory w3m-command)
(w3m-which-command w3m-command)))))))
(defcustom w3m-add-referer
(if (boundp 'w3m-add-referer-regexps)
(symbol-value 'w3m-add-referer-regexps)
(cons "\\`http:" "\\`http://\\(?:localhost\\|127\\.0\\.0\\.1\\)/"))
"*Rule of sending referers.
There are five choices as the valid values of this option.
\(1\) nil: this means that emacs-w3m never send referers.
\(2\) t: this means that emacs-w3m always send referers.
\(3\) lambda: this means that emacs-w3m send referers only when both
the current page and the target page are provided by the same
\(4\) a cons cell keeping two regular expressions: this means that
emacs-w3m send referers when the url of the current page matches
the first regular expression and does not match the second regular
expression. Nil for the regexp matches any url.
\(5\) a function: emacs-w3m send referers when this function which has
two arguments, URL and REFERER, returns non-nil.
If you become nervous about leak of your private WEB browsing history,
set `nil' or `lambda' to this option. When your computer belongs to a
secret network, you may set a pair of regular expressions to inhibit
sending referers which will disclose your private informations, as
\(setq w3m-add-referer
. \"\\\\`http://\\\\(?:[^./]+\\\\.\\\\)*example\\\\.net/\")\)
:group 'w3m
:type '(choice
(const :tag "Never send referers" nil)
(const :tag "Always send referers" t)
(const :tag "Send referers when accessing the same server" lambda)
(cons :tag "Send referers when URI matches:"
(list :inline t :format "%v"
(radio :indent 2 :sample-face underline
:tag "Allow"
(regexp :format "%t: %v\n" :size 0)
(const :tag "Don't allow all" nil))
(radio :indent 2 :sample-face underline
:tag "Don't allow"
(regexp :format "%t: %v\n" :size 0)
(const :tag "Allow all" nil))))
(function :tag "Send referers when your function returns non-nil")))
(defcustom w3m-touch-command (w3m-which-command "touch")
"*Name of the executable file of the touch command.
Note that the command is required to be able to modify file's
timestamp with the `-t' option."
:group 'w3m
:type '(string :size 0))
(defcustom w3m-puny-utf-16be
((w3m-find-coding-system 'utf-16-be-no-signature)
((w3m-find-coding-system 'utf-16be)
(t nil))
"*Coding system for PUNY coding. if nil, don't use PUNY code."
:group 'w3m
:type '(radio (coding-system :tag "UTF-16BE without BOM")
(const "Don't use" nil)))
(defcustom w3m-uri-replace-alist
'(("\\`gg:" w3m-search-uri-replace "google")
("\\`ggg:" w3m-search-uri-replace "google groups")
("\\`ya:" w3m-search-uri-replace "yahoo")
("\\`al:" w3m-search-uri-replace "altavista")
("\\`bts:" w3m-search-uri-replace "debian-bts")
("\\`dpkg:" w3m-search-uri-replace "debian-pkg")
("\\`archie:" w3m-search-uri-replace "iij-archie")
("\\`alc:" w3m-search-uri-replace "alc")
("\\`urn:ietf:rfc:\\([0-9]+\\)" w3m-pattern-uri-replace
"*Alist of regexps matching URIs, and some types of replacements.
It can be used universally to replace URI strings in the local rule to
the valid forms in the Internet.
Each element looks like the `(REGEXP FUNCTION OPTIONS...)' form.
FUNCTION takes one or more arguments, a uri and OPTIONS. You can use
the grouping constructs \"\\\\(...\\\\)\" in REGEXP, and they can be
referred by the \"\\N\" forms in a replacement (which is one of OPTIONS).
Here are some predefined functions which can be used for those ways:
Replace a URI using PATTERN (which is just an OPTION). It is
allowed that PATTERN contains the \"\\N\" forms in the same manner
of `replace-match'.
Generate the valid forms to query words to some specified search
engines. For example, the element
(\"\\\\`gg:\" w3m-search-uri-replace \"google\")
makes it possible to replace the URI \"gg:emacs\" to the form to
query the word \"emacs\" to the Google site.\
:group 'w3m
:type '(repeat
:convert-widget w3m-widget-type-convert-widget
:format "%[Value Menu%] %v" :tag "Replacing URI with"
(list :indent 4 :tag "Replacement Using Pattern"
(regexp :format "%t: %v\n" :size 0)
(function-item :format "" w3m-pattern-uri-replace)
(string :format "Pattern: %v\n" :size 0))
(list :format "%t:\n%v" :indent 4 :tag "Quick Search"
(regexp :format "Prefix URI %t: %v\n"
:size 0 :value "")
(function-item :format "" w3m-search-uri-replace)
(string :format "Quick Search Engine: %v\n"
:size 0 :value ""))
(require 'w3m-search)
(lambda (elem)
(let* ((engine (car elem))
(prefix (mapconcat 'identity
(split-string (downcase engine))
:format "Quick Search:\n%v"
:indent 4
:tag ,(concat "Quick Search: " prefix)
(regexp :tag "Prefix URL Regexp"
,(concat "\\`" (regexp-quote prefix) ":"))
(function-item :format "" w3m-search-uri-replace)
(string :tag "Quick Search Engine" ,engine))))
(list :indent 4 :tag "User Defined Function"
(regexp :format "%t: %v\n" :size 0)
:format "%t: %v\n" :size 0
;; Fix a bug in Emacs versions prior to 22.
(lambda (widget value)
(if (stringp value)
(if (string-match "\\`\".*\"\\'" value)
(substring value 1 -1)
(prin1-to-string value))))
(repeat :extra-offset 2 :tag "Options"
(sexp :format "%t: %v\n" :size 0)))))))
(defcustom w3m-relationship-estimate-rules
,(concat "<a[^>]+?href=" w3m-html-string-regexp "[^>]*>[\t\n ]*"
"\\(?:\\(?:</?span[^>]*>[\t\n ]*\\)*<span[^>]+>Next</span>"
"\\|\\(?:</?span[^>]*>[\t\n ]*\\)*"
,(concat "<a[^>]+?href=" w3m-html-string-regexp "[^>]*>[\t\n ]*"
"\\(?:\\(?:</?span[^>]*>[\t\n ]*\\)*<span[^>]+>Previous</span>"
"\\|\\(?:</?span[^>]*>[\t\n ]*\\)*"
nil nil)
,(concat "<a[^>]+?href=" w3m-html-string-regexp
"[ \t\n]+accesskey=\"3\">")
,(concat "<a[^>]+?href=" w3m-html-string-regexp
"[ \t\n]+accesskey=\"1\">")
nil nil)
,(concat "<a href=" w3m-html-string-regexp
"><img src=http://i\\.yimg\\.jp/images/common/ar_next\\.gif")
,(concat "<a href=" w3m-html-string-regexp
"><img src=http://i\\.yimg\\.jp/images/common/ar_prev\\.gif")
nil nil)
,(concat "<a href=" w3m-html-string-regexp ">$B<!$N%Z!<%8(B</a>")
,(concat "<a href=" w3m-html-string-regexp ">$BA0$N%Z!<%8(B</a>")
nil nil)
,(concat "<A HREF=" w3m-html-string-regexp ">\\[&raquo;\\]</A>")
,(concat "<A HREF=" w3m-html-string-regexp ">\\[&laquo;\\]</A>")
nil nil)
"*Rules to estimate relationships between a retrieved page and others."
:group 'w3m
:type '(repeat
:format "%[Value Menu%] %v"
(list :tag "Estimate relationships from anchors matching"
:indent 1
(const :format "Function: %v\n"
(regexp :tag "URL")
(regexp :tag "Next")
(regexp :tag "Prev")
(radio :format "Start: %v"
(const :format "%v " nil) regexp)
(radio :format "Contents: %v"
(const :format "%v " nil) regexp))
(list :tag "Estimate with a user defined function"
:indent 1
(repeat :tag "Args" :extra-offset 1 (sexp :format "%v"))))))
(defcustom w3m-enable-google-feeling-lucky t
"Non-nil enables you to enter any words as well as a url when prompted.
In that case, emacs-w3m uses Google to search for the words."
:group 'w3m
:type 'boolean)
(defconst w3m-entity-table
(let ((table (make-hash-table :test 'equal)))
(dolist (entity '(("nbsp" . " ")
("gt" . ">")
("lt" . "<")
("amp" . "&")
("quot" . "\"")
("apos" . "'")
("circ" . "^")
("tilde" . "~")))
(puthash (car entity) (cdr entity) table))
(dolist (entity
'(;("nbsp" . 160)
("iexcl" . 161) ("cent" . 162) ("pound" . 163) ("curren" . 164)
("yen" . 165) ("brvbar" . 166) ("sect" . 167) ("uml" . 168)
("copy" . 169) ("ordf" . 170) ("laquo" . 171) ("not" . 172)
("shy" . 173) ("reg" . 174) ("macr" . 175) ("deg" . 176)
("plusmn" . 177) ("sup2" . 178) ("sup3" . 179) ("acute" . 180)
("micro" . 181) ("para" . 182) ("middot" . 183) ("cedil" . 184)
("sup1" . 185) ("ordm" . 186) ("raquo" . 187) ("frac14" . 188)
("frac12" . 189) ("frac34" . 190) ("iquest" . 191)
("Agrave" . 192) ("Aacute" . 193) ("Acirc" . 194)
("Atilde" . 195) ("Auml" . 196) ("Aring" . 197) ("AElig" . 198)
("Ccedil" . 199) ("Egrave" . 200) ("Eacute" . 201)
("Ecirc" . 202) ("Euml" . 203) ("Igrave" . 204) ("Iacute" . 205)
("Icirc" . 206) ("Iuml" . 207) ("ETH" . 208) ("Ntilde" . 209)
("Ograve" . 210) ("Oacute" . 211) ("Ocirc" . 212)
("Otilde" . 213) ("Ouml" . 214) ("times" . 215) ("Oslash" . 216)
("Ugrave" . 217) ("Uacute" . 218) ("Ucirc" . 219) ("Uuml" . 220)
("Yacute" . 221) ("THORN" . 222) ("szlig" . 223) ("agrave" . 224)
("aacute" . 225) ("acirc" . 226) ("atilde" . 227) ("auml" . 228)
("aring" . 229) ("aelig" . 230) ("ccedil" . 231) ("egrave" . 232)
("eacute" . 233) ("ecirc" . 234) ("euml" . 235) ("igrave" . 236)
("iacute" . 237) ("icirc" . 238) ("iuml" . 239) ("eth" . 240)
("ntilde" . 241) ("ograve" . 242) ("oacute" . 243)
("ocirc" . 244) ("otilde" . 245) ("ouml" . 246) ("divide" . 247)
("oslash" . 248) ("ugrave" . 249) ("uacute" . 250)
("ucirc" . 251) ("uuml" . 252) ("yacute" . 253) ("thorn" . 254)
("yuml" . 255)))
(puthash (car entity)
(char-to-string (make-char 'latin-iso8859-1 (cdr entity)))
(dolist (entity
'(("Alpha" . 65) ("Beta" . 66) ("Gamma" . 67) ("Delta" . 68)
("Epsilon" . 69) ("Zeta" . 70) ("Eta" . 71) ("Theta" . 72)
("Iota" . 73) ("Kappa" . 74) ("Lambda" . 75) ("Mu" . 76)
("Nu" . 77) ("Xi" . 78) ("Omicron" . 79) ("Pi" . 80)
("Rho" . 81) ; No ("Sigmaf" . 82)
("Sigma" . 83) ("Tau" . 84) ("Upsilon" . 85) ("Phi" . 86)
("Chi" . 87) ("Psi" . 88) ("Omega" . 89)
("alpha" . 97) ("beta" . 98) ("gamma" . 99) ("delta" . 100)
("epsilon" . 101) ("zeta" . 102) ("eta" . 103) ("theta" . 104)
("iota" . 105) ("kappa" . 106) ("lambda" . 107) ("mu" . 108)
("nu" . 109) ("xi" . 110) ("omicron" . 111) ("pi" . 112)
("rho" . 113) ("sigmaf" . 114) ("sigma" . 115) ("tau" . 116)
("upsilon" . 117) ("phi" . 118) ("chi" . 119) ("psi" . 120)
("omega" . 121)))
(puthash (car entity)
(char-to-string (make-char 'greek-iso8859-7 (cdr entity)))
(when (w3m-mule-unicode-p)
(let ((latin-extended-a
'((32 . (("OElig" . 114) ("oelig" . 115)))
(33 . (("Scaron" . 32) ("scaron" . 33) ("Yuml" . 56)))))
(latin-extended-b '((33 . (("fnof" . 82)))))
;;(spacing-modifier-letters '(36 . (("circ" . 120) ("tilde" . 124))))
'((114 .
(("ensp" . 98) ("emsp" . 99) ("thinsp" . 105) ("zwnj" . 108)
("zwj" . 109) ("lrm" . 110) ("rlm" . 111) ("ndash" . 115)
("mdash" . 116) ("lsquo" . 120) ("rsquo" . 121)
("sbquo" . 122) ("ldquo" . 124) ("rdquo" . 125)
("bdquo" . 126)))
(115 .
(("dagger" . 32) ("Dagger" . 33) ("permil" . 48)
("lsaquo" . 57) ("rsaquo" . 58)
("bull" . 34) ("hellip" . 38) ("prime" . 50) ("Prime" . 51)
("oline" . 62) ("frasl" . 68)))
(116 .
(("euro" . 76)))))
(greek '((39 . (("thetasym" . 81) ("upsih" . 82) ("piv" . 86)))))
'((117 .
(("weierp" . 88) ("image" . 81) ("real" . 92)
("trade" . 98) ("alefsym" . 117)))))
'((118 .
(("larr" . 112) ("uarr" . 113) ("rarr" . 114) ("darr" . 115)
("harr" . 116)))
(119 .
(("crarr" . 53) ("lArr" . 80) ("uArr" . 81) ("rArr" . 81)
("dArr" . 83) ("hArr" . 84)))))
'((120 .
(("forall" . 32) ("part" . 34) ("exist" . 35) ("empty" . 37)
("nabla" . 39) ("isin" . 40) ("notin" . 41) ("ni" . 43)
("prod" . 47) ("sum" . 49) ("minus" . 50) ("lowast" . 55)
("radic" . 58) ("prop" . 61) ("infin" . 62) ("ang" . 64)
("and" . 71) ("or" . 72) ("cap" . 73) ("cup" . 74)
("int" . 75) ("there4" . 84) ("sim" . 92) ("cong" . 101)
("asymp" . 104)))
(121 .
(("ne" . 32) ("equiv" . 33) ("le" . 36) ("ge" . 37)
("sub" . 66) ("sup" . 67) ("nsub" . 68) ("sube" . 70)
("supe" . 71) ("oplus" . 85) ("otimes" . 87)
("perp" . 101)))
(122 . (("sdot" . 37)))))
'((122 . (("lceil" . 104) ("rceil" . 105) ("lfloor" . 106)
("rfloor" . 107)))
(123 . (("lang" . 41) ("rang" . 42)))))
'(("loz" . (34 . 42)) ("spades" . (35 . 96)) ("clubs" . (35 . 99))
("hearts" . (35 . 101)) ("diams" . (35 . 102)))))
(dolist (entities `(,@latin-extended-a
,@greek ,@letterlike-symbols ,@arrows
(let ((code1 (car entities)))
(dolist (entity (cdr entities))
(puthash (car entity)
(make-char 'mule-unicode-0100-24ff
code1 (cdr entity)))
(dolist (entity suit)
(puthash (car entity)
(make-char 'mule-unicode-2500-33ff
(car (cdr entity)) (cdr (cdr entity))))
"Table of html character entities and values.")
(defvar w3m-extra-numeric-character-reference
(lambda (item)
(cons (car item) (string (w3m-ucs-to-char (cdr item)))))
'((#x80 . #x20AC) (#x82 . #x201A) (#x83 . #x0192) (#x84 . #x201E)
(#x85 . #x2026) (#x86 . #x2020) (#x87 . #x2021) (#x88 . #x02C6)
(#x89 . #x2030) (#x8A . #x0160) (#x8B . #x2039) (#x8C . #x0152)
(#x8E . #x017D) (#x91 . #x2018) (#x92 . #x2019) (#x93 . #x201C)
(#x94 . #x201D) (#x95 . #x2022) (#x96 . #x2013) (#x97 . #x2014)
(#x98 . #x02DC) (#x99 . #x2122) (#x9A . #x0161) (#x9B . #x203A)
(#x9C . #x0153) (#x9E . #x017E) (#x9F . #x0178)))
"*Alist of (numeric . string) pairs for numeric character reference
other than ISO 10646.")
(defconst w3m-entity-reverse-table
(let ((table (make-hash-table :test 'equal)))
(maphash (lambda (key val) (puthash val key table))
"Revision table of html character entities and values.")
(defconst w3m-entity-regexp
(let (buf)
(maphash (lambda (key val) (push key buf))
(concat "&\\("
(let ((max-specpdl-size (* 1024 1024))) ;; For old Emacsen.
(regexp-opt buf))
"Regexp matching html character entities.")
(defconst w3m-encoding-alist
(apply 'nconc
(mapcar (lambda (elem)
(mapcar (lambda (x) (cons x (car elem)))
(cdr elem)))
'((gzip . ("gzip" "x-gzip" "compress" "x-compress"))
(bzip . ("x-bzip" "bzip" "bzip2"))
(deflate . ("x-deflate" "deflate"))))))
"Alist of content encoding types and decoder symbols.
Decoders are specified by `w3m-decoder-alist' (which see).")
(defconst w3m-emacs-w3m-icon "\
"A small image to be displayed in the about: page.
It is encoded in the optimized interlaced endlessly animated gif format
and base64. Emacs can display only the 1st frame of an animation, but
XEmacs can fully display it with the help of the gifsicle program.")
(defcustom w3m-process-modeline-format " loaded: %s"
"*Format used when displaying the progress of the external w3m process.
It shows a percentage of the data loaded from the web server."
:group 'w3m
:type '(choice (string :tag "Format") function))
(defcustom w3m-ignored-image-url-regexp nil
"*Regexp matching image urls which you don't want to view.
It is effective even if `w3m-display-inline-images' is non-nil.
For instance, the value \"^https?://www\\.google\\.com/\" conceals
Google's logo and navigation images, but display YouTube's
:group 'w3m
:type '(radio (const :format "Accept any image\n" nil)
(regexp :format "URL regexp: %v\n" :size 0)))
(defcustom w3m-refresh-minimum-interval 60
"*Minimum seconds to wait for refresh, when visiting a page by
history-back or history-next."
:group 'w3m
:type '(integer :size 0))
(defvar w3m-modeline-process-status-on "<PRC>"
"Modeline control for displaying the status when the process is running.
The value will be modified for displaying the graphic icon.")
(defvar w3m-modeline-image-status-on "[IMG]"
"Modeline control to display the status when inline images are turned on.
The value will be modified for displaying the graphic icon.")
(defvar w3m-modeline-status-off "[ - ]"
"Modeline control for displaying the status for the default.
The value will be modified for displaying the graphic icon.")
(defvar w3m-modeline-ssl-image-status-on "[IMG(SSL)]"
"Modeline control for displaying the status when images and SSL are on.
The value will be modified for displaying the graphic icon.")
(defvar w3m-modeline-ssl-status-off "[SSL]"
"Modeline control for displaying the status when SSL is turned on.
The value will be modified for displaying the graphic icon.")
(defvar w3m-modeline-separator " / "
"String used to separate a status and a title in the modeline.")
(defvar w3m-modeline-favicon nil
"Modeline control for displaying a favicon.
This variable will be made buffer-local.")
(defvar w3m-favicon-image nil
"Favicon image of the page.
This variable will be made buffer-local")
(defvar w3m-current-process nil
"Flag used to say whether the external process is running in the buffer.
This variable will be made buffer-local.")
(make-variable-buffer-local 'w3m-current-process)
(defvar w3m-refresh-timer nil
"Variable used to keep a timer object for refreshing a page.
It will be supplied by the REFRESH attribute in the META tag, and made
buffer-local in each emacs-w3m buffer.")
(make-variable-buffer-local 'w3m-refresh-timer)
(defvar w3m-mail-user-agents '(gnus-user-agent
"List of mail user agents that `w3m-mail' supports.
See also w3m-mail.el.")
(defvar w3m-current-base-url nil
"URL specified by <base...> tag in <head> element of the page source.")
(defvar w3m-current-forms nil
"Variable used to keep forms data for the current emacs-w3m buffer.")
(defvar w3m-current-coding-system nil
"Coding system used when decoding the current emacs-w3m buffer.")
(defvar w3m-current-content-charset nil
"Content charset of the page specified by the server or the META tag.")
(defvar w3m-icon-data nil
"Cons of icon data and its image-type for the current emacs-w3m buffer.
It is used for favicon data. The type is often `ico'.")
(defvar w3m-next-url nil
"URL as the next document in the author-defined sequence.")
(defvar w3m-previous-url nil
"URL as the previous document in the author-defined sequence.")
(defvar w3m-start-url nil
"URL as the first document in the author-defined sequence.")
(defvar w3m-contents-url nil
"URL as the table of contents for the current page.")
(defvar w3m-max-anchor-sequence nil
"Maximum number of the anchor sequence in the current page.")
(defvar w3m-current-refresh nil
"Cons of number of seconds and a url specified by the REFRESH attribute.")
(defvar w3m-current-ssl nil
"SSL certification indicator for the current emacs-w3m buffer.")
(defvar w3m-name-anchor-from-hist nil
"List of the points of where `w3m-search-name-anchor' come from.")
(make-variable-buffer-local 'w3m-current-url)
(make-variable-buffer-local 'w3m-current-base-url)
(make-variable-buffer-local 'w3m-current-title)
(make-variable-buffer-local 'w3m-current-forms)
(make-variable-buffer-local 'w3m-current-coding-system)
(make-variable-buffer-local 'w3m-current-content-charset)
(make-variable-buffer-local 'w3m-icon-data)
(make-variable-buffer-local 'w3m-next-url)
(make-variable-buffer-local 'w3m-previous-url)
(make-variable-buffer-local 'w3m-start-url)
(make-variable-buffer-local 'w3m-contents-url)
(make-variable-buffer-local 'w3m-max-anchor-sequence)
(make-variable-buffer-local 'w3m-current-refresh)
(make-variable-buffer-local 'w3m-current-ssl)
(make-variable-buffer-local 'w3m-name-anchor-from-hist)
(defun w3m-clear-local-variables ()
(setq w3m-current-url nil
w3m-current-base-url nil
w3m-current-title nil
w3m-current-coding-system nil
w3m-current-content-charset nil
w3m-icon-data nil
w3m-next-url nil
w3m-previous-url nil
w3m-start-url nil
w3m-contents-url nil
w3m-max-anchor-sequence nil
w3m-current-refresh nil
w3m-current-ssl nil
w3m-name-anchor-from-hist nil))
(defun w3m-copy-local-variables (from-buffer)
(let (url base title cs char icon next prev start toc hseq refresh ssl)
(with-current-buffer from-buffer
(setq url w3m-current-url
base w3m-current-base-url
title w3m-current-title
cs w3m-current-coding-system
char w3m-current-content-charset
icon w3m-icon-data
next w3m-next-url
prev w3m-previous-url
start w3m-start-url
toc w3m-contents-url
hseq w3m-max-anchor-sequence
refresh w3m-current-refresh
ssl w3m-current-ssl))
(setq w3m-current-url url
w3m-current-base-url base
w3m-current-title title
w3m-current-coding-system cs
w3m-current-content-charset char
w3m-icon-data icon
w3m-next-url next
w3m-previous-url prev
w3m-start-url start
w3m-contents-url toc
w3m-max-anchor-sequence hseq
w3m-current-refresh refresh
w3m-current-ssl ssl)))
(defvar w3m-verbose nil
"*Flag controls whether to log messages in the *Messages* buffer.
If it is nil, a lot of messages issued by emacs-w3m will be displayed
only in the echo area.")
(defvar w3m-safe-url-regexp nil
"Regexp matching urls which are considered to be safe.
The nil value means all urls are considered to be safe.
Note: The value, that might be bound to a certain value while rendering
contents, will be held by the `w3m-safe-url-regexp' text property that
is set over the rendered contents in a buffer. So, programs that use
the value to test whether a url of a link in a buffer is safe should
use the value of the text property, not the value of this variable.
See the function definitions of `w3m-toggle-inline-image',
`w3m-toggle-inline-images', `w3m-safe-view-this-url', and
(defvar w3m-current-buffer nil)
(defvar w3m-cache-buffer nil)
(defvar w3m-cache-articles nil)
(defvar w3m-cache-hashtb nil)
(defvar w3m-input-url-history nil)
(defvar w3m-http-status-alist
'((400 . "Bad Request")
(401 . "Unauthorized")
(402 . "Payment Required")
(403 . "Forbidden")
(404 . "Not Found")
(405 . "Method Not Allowed")
(406 . "Not Acceptable")
(407 . "Proxy Authentication Required")
(408 . "Request Time-out")
(409 . "Conflict")
(410 . "Gone")
(411 . "Length Required")
(412 . "Precondition Failed")
(413 . "Request Entity Too Large")
(414 . "Request-URI Too Large")
(415 . "Unsupported Media Type")
(500 . "Internal Server Error")
(501 . "Not Implemented")
(502 . "Bad Gateway")
(503 . "Service Unavailable")
(504 . "Gateway Time-out")
(505 . "HTTP Version not supported"))
"Alist of HTTP status codes.")
(defvar w3m-http-status nil)
(defconst w3m-arrived-db-size 1023)
(defvar w3m-arrived-db nil
"Hash table, the arrived URLs database.
The name of each symbol represents a url, the arrival time in the
Emacs style (a list of three integers) is stored as the value, and
informations including a title, a modification time, a content charset
and a content type are stored as the properties of the symbol. The
nil value means it has not been initialized.")
(defvar w3m-arrived-setup-functions nil
"Hook functions run after setting up the arrived URLs database.")
(defvar w3m-arrived-shutdown-functions nil
"Hook functions run after saving the arrived URLs database.")
(defconst w3m-image-type-alist
'(("image/jpeg" . jpeg)
("image/gif" . gif)
("image/png" . png)
("image/tiff" . tiff)
("image/x-xbm" . xbm)
("image/x-xpm" . xpm))
"Alist of content types and image types defined as the Emacs's features.")
(defconst w3m-toolbar-buttons
'("back" "parent" "forward" "reload" "open" "home" "search" "image"
"copy" "weather" "antenna" "history" "db-history")
"List of prefix strings for the toolbar buttons.")
(defconst w3m-toolbar
(if (equal "Japanese" w3m-language)
(let ((a (decode-coding-string "\e$B%\"\e(B" 'iso-2022-jp))) ;; $B%"(B
`([w3m-toolbar-back-icon w3m-view-previous-page
[w3m-toolbar-parent-icon w3m-view-parent-page
[w3m-toolbar-forward-icon w3m-view-next-page
[w3m-toolbar-reload-icon w3m-reload-this-page
[w3m-toolbar-open-icon w3m-goto-url t "URL $B$rF~NO$7$F%Z!<%8$r3+$/(B"]
[w3m-toolbar-home-icon w3m-gohome w3m-home-page
[w3m-toolbar-search-icon w3m-search t "$B%$%s%?!<%M%C%H>e$r8!:w(B"]
[w3m-toolbar-image-icon w3m-toggle-inline-images t
[w3m-toolbar-copy-icon w3m-copy-buffer t
[w3m-toolbar-weather-icon w3m-weather t "$BE75$M=Js$r8+$k(B"]
[w3m-toolbar-antenna-icon w3m-antenna t
,(concat a "$B%s%F%J$G<u?.$9$k(B")]
[w3m-toolbar-history-icon w3m-history t "$B%R%9%H%j!<(B"]
[w3m-toolbar-db-history-icon w3m-db-history t
"$B2a5n$KK,Ld$7$?(B URL $B$NMzNr$r8+$k(B"]))
'([w3m-toolbar-back-icon w3m-view-previous-page
"Back to Previous Page"]
[w3m-toolbar-parent-icon w3m-view-parent-page
"View the parent page"]
[w3m-toolbar-forward-icon w3m-view-next-page
"Forward to Next Page"]
[w3m-toolbar-reload-icon w3m-reload-this-page
"Reload This Page"]
[w3m-toolbar-open-icon w3m-goto-url t "Go to..."]
[w3m-toolbar-home-icon w3m-gohome w3m-home-page "Go to Home Page"]
[w3m-toolbar-search-icon w3m-search t "Search the Internet"]
[w3m-toolbar-image-icon w3m-toggle-inline-images t "Toggle Images"]
[w3m-toolbar-copy-icon w3m-copy-buffer t "Make a Copy of This Session"]
[w3m-toolbar-weather-icon w3m-weather t "Weather Forecast"]
[w3m-toolbar-antenna-icon w3m-antenna t "Investigate with Antenna"]
[w3m-toolbar-history-icon w3m-history t "Show a History"]
[w3m-toolbar-db-history-icon w3m-db-history t "View Arrived URLs"]))
"Toolbar definition for emacs-w3m.")
;; "View" is page viewing
;; "Show" is link list showing
(defconst w3m-menubar
(let ((a (when w3m-use-japanese-menu
(decode-coding-string "\e$B%\"\e(B" 'iso-2022-jp)))) ;; $B%"(B
[,(w3m-make-menu-item "$B$3$N(B URL $B$r?7$7$$%;%C%7%g%s$G3+$/(B"
"Open This URL in a new session")
w3m-view-this-url-new-session (or (w3m-anchor) (w3m-image))]
[,(w3m-make-menu-item "$B$3$N(B URL $B$r%@%&%s%m!<%I$9$k(B" "Download This URL")
w3m-download-this-url (or (w3m-anchor) (w3m-image))]
[,(w3m-make-menu-item "$B%@%&%s%m!<%I(B..." "Download to...")
w3m-download t]
"----" ;; separator
[,(w3m-make-menu-item "$BA0$N%Z!<%8$KLa$k(B" "Back to Previous Page")
[,(w3m-make-menu-item "$B<!$N%Z!<%8$K0\F0$9$k(B" "Forward to Next Page")
[,(w3m-make-menu-item "$B>e$N3,AX$K0\F0$9$k(B" "Up to Parent Page")
"----" ;; separator
[,(w3m-make-menu-item "$B$3$N%Z!<%8$r30It%V%i%&%6$G3+$/(B"
"Open This Page in an External Browser")
w3m-external-view-current-url w3m-current-url]
[,(w3m-make-menu-item "$B$3$N(B URL $B$r30It%V%i%&%6$G3+$/(B"
"Open This URL in an External Browser")
w3m-external-view-this-url (or (w3m-anchor) (w3m-image))]
[,(w3m-make-menu-item "$B$3$N%Z!<%8$N%=!<%9$r%3%^%s%I$KAw$k(B..."
"Pipe Page Source to Command...")
w3m-pipe-source w3m-current-url]
"----" ;; separator
(,(w3m-make-menu-item "$B:FI=<((B" "Redisplay")
[,(w3m-make-menu-item "$B$3$N%Z!<%8$r:F<hF@$9$k(B" "Reload This Page")
w3m-reload-this-page w3m-current-url]
[,(w3m-make-menu-item "$B$9$Y$F$N%Z!<%8$r:F<hF@$9$k(B" "Reload All Pages")
w3m-reload-all-pages (cdr (w3m-list-buffers))]
"----" ;; separator
[,(w3m-make-menu-item "$B2hA|I=<($N@ZBX(B($BA4It(B)" "Toggle Images")
w3m-toggle-inline-images (w3m-display-graphic-p)]
[,(w3m-make-menu-item "$B2hA|I=<($N@ZBX(B($B$3$N2hA|(B)" "Toggle This Image")
w3m-toggle-inline-image (w3m-image)]
[,(w3m-make-menu-item "$B2hA|I=<($r;_$a$k(B" "Turn off Images")
w3m-turnoff-inline-images (w3m-display-graphic-p)]
"----" ;; separator
[,(w3m-make-menu-item "$B:FIA2h$9$k(B" "Redisplay This Page")
w3m-redisplay-this-page w3m-current-url]
[,(w3m-make-menu-item "Charset $B$r;XDj$7$F:FIA2h$9$k(B"
"Redisplay This Page with Charset")
w3m-redisplay-with-charset w3m-current-url]
[,(w3m-make-menu-item "Content-type $B$r;XDj$7$F:FIA2h$9$k(B"
"Redisplay This Page with Content-type")
w3m-redisplay-with-content-type w3m-current-url]
[,(w3m-make-menu-item "$B;XDj$7$?(B Charset $B$H(B Content-type $B$rGK4~$9$k(B"
"Reset Charset and Content-type")
w3m-redisplay-and-reset w3m-current-url]
) ;; end redisplay
[,(w3m-make-menu-item "$B%[!<%`%Z!<%8$X0\F0(B" "Go to Home Page")
w3m-gohome w3m-home-page]
(,(w3m-make-menu-item "$B%V%C%/%^!<%/(B" "Bookmark")
[,(w3m-make-menu-item "$B%V%C%/%^!<%/$rI=<((B" "View Bookmark")
w3m-bookmark-view t]
[,(w3m-make-menu-item "$B?7$7$$%;%C%7%g%s$G%V%C%/%^!<%/$rI=<((B"
"View Bookmark in a New Session")
w3m-bookmark-view-new-session t])
[,(w3m-make-menu-item "$B0\F0(B..." "Go to...")
w3m-goto-url t]
"----" ;; separator
(,(w3m-make-menu-item "$BMzNr(B" "History")
[,(w3m-make-menu-item "$BLZ9=B$$GMzNr$rI=<((B" "Show a Visited URLs Tree")
w3m-history t]
[,(w3m-make-menu-item "$B%j%9%H$GMzNr$rI=<((B" "Show an Arrived URLs List")
w3m-db-history t]
) ;; end history
[,(w3m-make-menu-item "$B%$%s%?!<%M%C%H$G$N8!:w(B..."
"Search the Internet...")
w3m-search t]
[,(w3m-make-menu-item "$B?7$7$$%;%C%7%g%s$G8!:w(B..."
"Search the Internet in a New Session...")
w3m-search-new-session t]
[,(w3m-make-menu-item "$BE75$M=Js(B" "Weather Forecast")
w3m-weather t]
[,(w3m-make-menu-item (concat a "$B%s%F%J$G<hF@(B")
"Investigate with Antenna")
w3m-antenna t]
(,(w3m-make-menu-item "$B%X%k%W(B" "Resource")
[,(w3m-make-menu-item "$B%W%m%;%9$rCf;_$9$k(B" "Cancel Process")
w3m-process-stop w3m-current-process]
[,(w3m-make-menu-item "$B%=!<%9$r8+$k(B" "View Source")
w3m-view-source t]
[,(w3m-make-menu-item "$B%X%C%@!<$r8+$k(B" "View Header")
w3m-view-header t]
) ;; end resource
"----" ;; separator
[,(w3m-make-menu-item "$B$3$N%Z!<%8$r%a!<%k$GAw$k(B" "Mail this page")
w3m-mail (memq mail-user-agent w3m-mail-user-agents)]
"----" ;; separator
[,(w3m-make-menu-item "$B%P%0%l%]!<%H$rAw$k(B" "Send a Bug Report")
report-emacs-w3m-bug t]
"----" ;; separator
[,(w3m-make-menu-item "$B$3$N(B URL $B$rI=<($9$k(B" "Print the Current URL")
w3m-print-current-url t]
[,(w3m-make-menu-item "w3m $B$rJD$8$k(B" "Close w3m")
w3m-close-window t]
[,(w3m-make-menu-item "w3m $B$r=*N;$9$k(B" "Quit w3m")
w3m-quit t]
)) ;; end w3m
"Menubar definition for emacs-w3m.")
(defvar w3m-rmouse-menubar
[,(w3m-make-menu-item "$BA0$N%Z!<%8$KLa$k(B" "Back to Previous Page")
[,(w3m-make-menu-item "$B<!$N%Z!<%8$K0\F0$9$k(B" "Forward to Next Page")
[,(w3m-make-menu-item "$B>e$N3,AX$K0\F0$9$k(B" "Up to Parent Page")
"----" ;; separator
[,(w3m-make-menu-item "$B$3$N%Z!<%8$r:F<hF@$9$k(B" "Reload This Page")
w3m-reload-this-page w3m-current-url]
[,(w3m-make-menu-item "$B$9$Y$F$N%Z!<%8$r:F<hF@$9$k(B" "Reload All Pages")
w3m-reload-all-pages (cdr (w3m-list-buffers))]
[,(w3m-make-menu-item "$B%W%m%;%9$rCf;_$9$k(B" "Cancel Process")
w3m-process-stop w3m-current-process])
"*Menubar for click the right mouse button.")
(defvar w3m-cid-retrieve-function-alist nil)
(defvar w3m-force-redisplay t)
(defvar w3m-work-buffer-list nil)
(defconst w3m-work-buffer-name " *w3m-work*")
(defconst w3m-select-buffer-name " *w3m buffers*")
(defconst w3m-dump-head-source-command-arguments
(cond ((eq w3m-type 'w3mmee)
(list "-dump=extra,head,source"))
'(if w3m-accept-languages
(concat "accept_language="
(mapconcat 'identity w3m-accept-languages ","))))
"Arguments passed to the w3m command to run \"dump_extra\".")
(defvar w3m-halfdump-command nil
"Alternative w3m command used to run \"halfdump\".
If it is nil, the command specified to `w3m-command' is used.")
(defconst w3m-halfdump-command-arguments
(cond ((eq w3m-type 'w3mmee)
(list '(if w3m-treat-image-size
'(if (eq w3m-input-coding-system 'ctext)
(list "-I" "x-ctext")
(when (and (eq w3m-input-coding-system 'binary)
(list "-I" 'charset)))
"-o" "concurrent=0"))
((eq w3m-type 'w3m-m17n)
(list "-halfdump"
"-o" "ext_halfdump=1"
"-o" "strict_iso2022=0"
"-o" "fix_width_conv=1"
"-o" "use_jisx0201=0"
"-o" "ucs_conv=1"
'(if (eq w3m-input-coding-system 'binary)
(if charset (list "-I" 'charset))
(list "-I" (cond
((eq w3m-input-coding-system 'utf-8)
((eq w3m-input-coding-system 'iso-8859-1)
((eq w3m-output-coding-system 'utf-8)
((eq w3m-output-coding-system 'iso-8859-1)
((eq w3m-input-coding-system 'w3m-euc-japan)
(list "-halfdump" "-I" "e"))
(t (list "-halfdump")))
"Arguments passed to the w3m command to run \"halfdump\".")
(defconst w3m-halfdump-command-common-arguments
(list "-T" "text/html" "-t" tab-width "-cols" '(w3m-display-width)
((and (eq w3m-display-ins-del 'fontify)
(list "-o" "display_ins_del=2"))
((or (eq w3m-display-ins-del 'tag)
(and (eq w3m-display-ins-del 'fontify)
(not (w3m-device-on-window-system-p))))
(list "-o" "display_ins_del=1"))))
"Arguments used in common by the w3m command variants to run \"halfdump\".")
(defconst w3m-arrived-ignored-regexp
"Regexp matching urls which aren't stored in the arrived URLs database.")
(defconst w3m-history-ignored-regexp
"Regexp matching urls which aren't stored in the history.")
(defvar w3m-mode-map nil "Keymap for emacs-w3m buffers.")
(defvar w3m-link-map nil "Keymap used on links.")
(defvar w3m-doc-view-map nil
"Keymap used in `doc-view-mode' that emacs-w3m launches.
`doc-view-mode-map' gets to be its parent keymap.")
(defvar w3m-mode-setup-functions nil
"Hook functions run after setting up the `w3m-mode'.")
(defvar w3m-display-functions nil
"Hook functions run after displaying pages in emacs-w3m buffers.
Each function is called with a url string as the argument. This hook
is evaluated just before evaluating `w3m-display-hook'.")
(defvar w3m-load-hook nil
"*Hook run after loading the w3m.elc module.
It is not recommended that you use this hook instead of writing into
`w3m-init-file' for customization.")
;; Generic functions:
(defun w3m-url-to-file-name (url)
"Return the file name which is pointed to by URL.
When URL does not point to any local files, it returns nil. The
actual performance of this function is to strip off the scheme part
and the net_loc part from URL. It is meaningless to give an argument
whose net_loc part is not empty, a null string or the localhost name
to this function."
((string-match "\\`\\(\\(file:/\\{0,2\\}\\)\\|about://dtree\\)/" url)
(setq url (substring url (match-end 1)))
(when (and (match-beginning 2) ;; file:
(< (match-end 2) 7) ;; file:// or file:/
(string-match "\\`\\(/[^/]+[^/:|]\\)/" url))
(cond ((file-directory-p (match-string 0 url))
) ;; The directory "/hostname/" exists.
((string-match (concat "\\`/\\(localhost\\|127\\.0\\.0\\.1\\|"
(regexp-quote (system-name)) "\\)/")
;; Strip the localhost name.
(setq url (substring url (match-end 1))))
;; Make it a Tramp url: /hostname:/...
;; See `tramp-default-method' and `tramp-default-method-alist'.
(setq url (concat (substring url 0 (match-end 1))
(substring url (match-end 1)))))))
;; Process abs_path part in Windows.
(when (and w3m-treat-drive-letter
(setq url (concat (or (match-string 1 url) (match-string 2 url))
(substring url (match-end 0)))))
(if (string-match "\\`/[^/:]\\{2,\\}:/" url)
;; Don't check for a Tramp url.
(if (file-exists-p url)
(let ((x (w3m-url-decode-string url w3m-file-name-coding-system)))
(if (file-exists-p x) x url)))))
((string-match "\\`\\(?:[~/]\\|[a-zA-Z]:/\\|\\.\\.?/\\)" url) url)
(catch 'found-file
(dolist (pair w3m-url-local-directory-alist)
(and (string-match (concat "\\`"
(file-name-as-directory (car pair))))
(let ((file (expand-file-name (substring url (match-end 0))
(cdr pair))))
(when (or (file-exists-p file)
(setq file (w3m-url-decode-string
file w3m-file-name-coding-system))))
(throw 'found-file file)))))))))
(defun w3m-expand-file-name-as-url (file &optional directory)
"Return a url string which points to the FILE.
Optional DIRECTORY is a directory to start with if FILE is relative
\(i.e., FILE doesn't start with slash). It defaults to the current
(setq file (expand-file-name file directory))
(concat "file://"
(if (string-match "\\`\\([a-zA-Z]\\):" file)
(format (if w3m-use-cygdrive "/cygdrive/%s%s" "/%s|%s")
(match-string 1 file)
(substring file (match-end 0)))
;;; Managing the arrived URLs database:
(defmacro w3m-arrived-intern (url &optional soft)
"Normalize URL by stripping last / and intern it into `w3m-arrived-db'.
If SOFT is non-nil, use `intern-soft' instead."
(let ((fn (if soft 'intern-soft 'intern))
(str (if (consp url)
`(let* ((url ,url)
(len (length url)))
(if (and (not (zerop len))
(eq (aref url (1- len)) ?/))
(substring url 0 -1)
`(if (let ((len (length ,url)))
(and (not (zerop len))
(eq (aref ,url (1- len)) ?/)))
(substring ,url 0 -1)
`(,fn ,str w3m-arrived-db)))
(defun w3m-arrived-add (url &optional title modification-time
arrival-time content-charset content-type)
"Add URL to the arrived URLs database.
CONTENT-TYPE are also be added."
(unless (string-match w3m-arrived-ignored-regexp url)
(let ((ident (w3m-arrived-intern url)))
(if (string-match "\\`\\([^#]+\\)#" url)
(w3m-arrived-add (substring url 0 (match-end 1))
title modification-time arrival-time
content-charset content-type)
(when title
(put ident 'title title))
(when modification-time
(put ident 'last-modified modification-time))
(when content-charset
(put ident 'content-charset content-charset))
(when content-type
(put ident 'content-type content-type)))
(set ident arrival-time))))
(defun w3m-arrived-p (url)
"Return non-nil if a page of URL has arrived."
(or (string-match w3m-arrived-ignored-regexp url)
(w3m-arrived-intern url t)))
(defun w3m-arrived-time (url)
"Return the arrival time of a page of URL if it has arrived.
Otherwise return nil."
(let ((v (w3m-arrived-intern url t)))
(and v (boundp v) (symbol-value v))))
(defsetf w3m-arrived-time (url) (value)
(list 'w3m-arrived-add url nil nil value))
(defun w3m-arrived-put (url property value)
"Store VALUE in the arrived URLs database as the PROPERTY of URL.
Return VALUE if a page of URL has arrived. Otherwise, VALUE is
ignored and return nil."
(let ((symbol (w3m-arrived-intern url t)))
(and symbol (put symbol property value))))
(defun w3m-arrived-get (url property)
"Return the value of URL's PROPERTY stored in the arrived URLs database.
If a page of URL has not arrived, return nil."
(let ((symbol (w3m-arrived-intern url t)))
(and symbol (get symbol property))))
(defsetf w3m-arrived-get w3m-arrived-put)
(defmacro w3m-arrived-title (url)
"Return the title of URL having stored in the arrived URLs database."
`(w3m-arrived-get ,url 'title))
(defmacro w3m-arrived-last-modified (url)
"Return the mod time of URL having stored in the arrived URLs database.
If a page of URL has not arrived yet, return nil."
`(w3m-arrived-get ,url 'last-modified))
(defmacro w3m-arrived-content-charset (url)
"Return the content charset of URL stored in the arrived URLs database.
If it has not been specified or a page of URL has not arrived yet,
return nil."
`(w3m-arrived-get ,url 'content-charset))
(defmacro w3m-arrived-content-type (url)
"Return the content type of URL stored in the arrived URLs database.
If it has not been specified or a page of URL has not arrived yet,
return nil."
`(w3m-arrived-get ,url 'content-type))
(defun w3m-arrived-load-list ()
"Load the arrived URLs database file.
The file is specified by `w3m-arrived-file'. If the data is in old
format, they will simply be ignored."
(let ((list (w3m-load-list w3m-arrived-file)))
(when (or
;; Before the revision 1.120, every element of the list was
;; a string that represented an arrived URL.
(stringp (car list))
;; Before the revision 1.135, every element was a cons
;; cell: its car kept a URL, and its cdr kept a time when
;; the URL was arrived.
;; Before the revision 1.178, every element was a 4-tuple
;; that consisted of a URL, a title, a modification time,
;; and an arrival time.
;; An element of the modern database is a 6-tuple that
;; consisted of a URL, a title, a modification time, an
;; arrival time, a charset, and a content type.
;; Thus, the following condition eliminates the revision
;; 1.177 and olders.
(<= (length (car list)) 4))
(setq list nil)
(when (file-exists-p w3m-arrived-file)
(delete-file w3m-arrived-file)))
(defun w3m-arrived-setup ()
"Load the arrived URLs database file and set up the hashed database.
It is performed only when `w3m-arrived-db' has not been initialize yet.
The file is specified by `w3m-arrived-file'."
(unless w3m-arrived-db
(setq w3m-arrived-db (make-vector w3m-arrived-db-size 0))
(let ((list (w3m-arrived-load-list)))
(dolist (elem list)
;; Ignore an element that lacks an arrival time information.
(when (nth 3 elem)
(w3m-arrived-add (if (string-match "\\`/" (car elem))
(w3m-expand-file-name-as-url (car elem))
(car elem))
(nth 1 elem)
(nth 2 elem)
(nth 3 elem)
(when (stringp (nth 4 elem)) (nth 4 elem))
(nth 5 elem))))
(unless w3m-input-url-history
(setq w3m-input-url-history (mapcar (function car) list))))
(run-hooks 'w3m-arrived-setup-functions)))
(defun w3m-arrived-shutdown ()
"Save the arrived URLs database in the file.
The database `w3m-arrived-db' will be cleared after saving. The file
is specified by `w3m-arrived-file'."
(when w3m-arrived-db
;; Re-read the database file, and if there are data which another
;; Emacs process registered, merge them to the current database.
(dolist (elem (w3m-arrived-load-list))
(when (w3m-time-newer-p (nth 3 elem) (w3m-arrived-time (car elem)))
(w3m-arrived-add (if (string-match "\\`/" (car elem))
(w3m-expand-file-name-as-url (car elem))
(car elem))
(nth 1 elem)
(nth 2 elem)
(nth 3 elem)
(when (stringp (nth 4 elem)) (nth 4 elem))
(nth 5 elem))))
;; Convert current database to a list.
(let (list)
(lambda (sym)
(and sym
(boundp sym)
(symbol-value sym) ; Ignore an entry lacks an arrival time.
(push (list (symbol-name sym)
(get sym 'title)
(get sym 'last-modified)
(symbol-value sym)
(get sym 'content-charset)
(get sym 'content-type))
(w3m-save-list w3m-arrived-file
(sort list
(lambda (a b)
(if (equal (nth 3 a) (nth 3 b))
(string< (car a) (car b))
(w3m-time-newer-p (nth 3 a) (nth 3 b)))))
nil t))
(setq w3m-arrived-db nil)
(run-hooks 'w3m-arrived-shutdown-functions)))
(add-hook 'kill-emacs-hook 'w3m-arrived-shutdown)
(add-hook 'kill-emacs-hook 'w3m-cookie-shutdown)
(add-hook 'w3m-arrived-shutdown-functions 'w3m-session-automatic-save)
(add-hook 'w3m-arrived-shutdown-functions 'w3m-session-crash-recovery-remove)
(add-hook 'w3m-arrived-shutdown-functions 'w3m-cleanup-temp-files)
;;; Generic macros and inline functions:
(defun w3m-attributes (url &optional no-cache handler)
"Return a list of attributes corresponding to URL.
Return nil if it failed in retrieving of the header.
Otherwise, return a list which includes the following elements:
0. Type of contents.
1. Charset of contents.
2. Size in bytes.
3. Encoding of contents.
4. Last modification time.
5. Real URL.
If the optional argument NO-CACHE is non-nil, cache is not used."
(if (not handler)
(condition-case nil
(w3m-attributes url no-cache handler))
(w3m-process-timeout nil))
(setq url (w3m-url-strip-fragment url))
((string= "about://emacs-w3m.gif" url)
(list "image/gif" nil nil nil nil url url))
((string-match "\\`about://source/" url)
(lexical-let ((src (substring url (match-end 0))))
(attrs (w3m-attributes src no-cache handler))
(list "text/plain"
(or (w3m-arrived-content-charset (w3m-url-strip-authinfo src))
(cadr attrs))
(nth 2 attrs)
(nth 3 attrs)
(nth 4 attrs)
(concat "about://source/" (nth 5 attrs))))))
((string-match "\\`about:" url)
(list "text/html" w3m-coding-system nil nil nil url))
((string-match "\\`cid:" url)
(let ((w3m-current-buffer (current-buffer)))
(type (w3m-cid-retrieve url nil nil))
(list type nil nil nil nil url url))))
((string-match "\\`data:" url)
(let ((w3m-current-buffer (current-buffer)))
(type (w3m-data-retrieve url nil nil))
(list type nil nil nil nil url url))))
((w3m-url-local-p url)
(w3m-local-attributes url))
(w3m-w3m-attributes url no-cache handler)))))
(defmacro w3m-content-type (url &optional no-cache handler)
(if handler
`(let ((handler ,handler))
(attrs (w3m-attributes ,url ,no-cache handler))
(car attrs)))
`(car (w3m-attributes ,url ,no-cache))))
(defmacro w3m-content-charset (url &optional no-cache handler)
(if handler
`(let ((handler ,handler))
(attrs (w3m-attributes ,url ,no-cache handler))
(nth 1 attrs)))
`(nth 1 (w3m-attributes ,url ,no-cache))))
(defmacro w3m-content-length (url &optional no-cache handler)
(if handler
`(let ((handler ,handler))
(attrs (w3m-attributes ,url ,no-cache handler))
(nth 2 attrs)))
`(nth 2 (w3m-attributes ,url ,no-cache))))
(defmacro w3m-content-encoding (url &optional no-cache handler)
(if handler
`(let ((handler ,handler))
(attrs (w3m-attributes ,url ,no-cache handler))
(nth 3 attrs)))
`(nth 3 (w3m-attributes ,url ,no-cache))))
(defmacro w3m-last-modified (url &optional no-cache handler)
(if handler
`(let ((handler ,handler))
(attrs (w3m-attributes ,url ,no-cache handler))
(nth 4 attrs)))
`(nth 4 (w3m-attributes ,url ,no-cache))))
(defmacro w3m-real-url (url &optional no-cache handler)
(if handler
`(let ((handler ,handler))
(attrs (w3m-attributes ,url ,no-cache handler))
(nth 5 attrs)))
`(nth 5 (w3m-attributes ,url ,no-cache))))
(defmacro w3m-make-help-echo (property)
"Make a function returning a string used for the `help-echo' message.
PROPERTY is a symbol (which doesn't need to be quoted) of a text
property (in XEmacs, it is an extent) with the value of a string which
should be in the place where having to show a help message. If you
need to know what function will be made, use `macroexpand'."
(if (featurep 'xemacs)
(let ((str `(get-text-property (extent-start-position extent)
`(lambda (extent)
(if (and w3m-track-mouse
(eq (extent-object extent) (current-buffer)))
(w3m-url-readable-string ,str))))
`(lambda (window object pos)
(if w3m-track-mouse
(let ((deactivate-mark nil))
(message nil) ; Clear the echo area.
(get-text-property pos ',property
(window-buffer window))))))))
(defmacro w3m-make-balloon-help (property)
"Make a function returning a string used for the `balloon-help' message.
Functions made are used only when emacs-w3m is running under XEmacs.
It returns an interned symbol of a function. PROPERTY is a symbol
\(which doesn't need to be quoted) of an extent with the value of a
string which should be in the place where having to show a help
(when (featurep 'xemacs)
(let ((str `(get-text-property (extent-start-position extent)
`(let ((fn (intern (format "w3m-balloon-help-for-%s"
(unless (fboundp fn)
(defalias fn
(lambda (extent)
(if (and w3m-track-mouse
(eq (extent-object extent) (current-buffer)))
(w3m-url-readable-string ,str)))))
(when (and (featurep 'bytecomp)
(not (compiled-function-p (symbol-function fn))))
(byte-compile fn)))))))
(defvar w3m-current-message nil
"The string currently displayed by `w3m-message' in the echo area.")
(defvar w3m-message-silent nil
"When set to `t', w3m-message is just ignored.")
(defun w3m-message (&rest args)
"Print a one-line message at the bottom of the screen.
It displays a given message without logging, when the cursor is
neither in the minibuffer or in the echo area and `w3m-verbose' is
nil. When the cursor is either in the minibuffer or in the echo area
and `w3m-verbose' is nil, it behaves as `format' and simply returns a
string. When `w3m-verbose' is non-nil, it behaves identically as
`message', that displays a given message with logging."
;; Always clear previous message in order to shrink the window height
;; for the echo area.
(unless (or (featurep 'xemacs)
(< emacs-major-version 22)
(< (string-width (or (current-message) "")) (window-width)))
(message nil))
(unless w3m-message-silent
(if w3m-verbose
(apply (function message) args)
(if (when w3m-process-background
(or (window-minibuffer-p (selected-window))
(when (current-message)
(not (equal (current-message) w3m-current-message)))))
(apply (function format) args)
(w3m-static-if (featurep 'xemacs)
(setq w3m-current-message (apply (function format) args))
(display-message 'no-log w3m-current-message))
(let (message-log-max)
(setq w3m-current-message (apply (function message) args))))))))
(defun w3m-time-parse-string (string)
"Parse the time-string STRING into a time in the Emacs style."
(let ((x (timezone-fix-time string nil nil)))
(encode-time (aref x 5) (aref x 4) (aref x 3)
(aref x 2) (aref x 1) (aref x 0)
(aref x 6)))))
;; When a buggy timezone.el is loaded, we use parse-time.el instead.
(unless (equal (w3m-time-parse-string "Thursday, 01-Jan-1970 00:00:00 GMT")
'(0 0))
(require 'parse-time))
(defun w3m-time-parse-string (string)
"Parse the time-string STRING and return its time as Emacs style."
(let ((fn (when (fboundp 'parse-time-string)
(when fn
(apply (function encode-time) (funcall fn string)))))))
(defun w3m-sub-list (list n)
"Return a list of the first N elements of LIST.
If N is negative, return a list of the last N elements of LIST."
(if (integerp n)
(if (< n 0)
;; N is negative, extract the last items
(if (>= (- n) (length list))
(copy-sequence list)
(nthcdr (+ (length list) n) (copy-sequence list)))
;; N is positive, extract the first items
(if (>= n (length list))
(copy-sequence list)
(nreverse (nthcdr (- (length list) n) (reverse list)))))
(copy-sequence list)))
(defun w3m-load-list (file &optional coding-system)
"Read an emacs-w3m data file FILE and return contents as a list.
It is used for loading `w3m-arrived-file', `w3m-cookie-file',
`w3m-favicon-cache-file' and `w3m-antenna-file' (which see).
CODING-SYSTEM is used to read FILE which defaults to the value of
(when (and (file-readable-p file)
;; XEmacs 21.4 might crash when inserting a directory.
(not (file-directory-p file)))
(when (condition-case nil
(let ((coding-system-for-read
(or coding-system w3m-file-coding-system-for-read)))
(insert-file-contents file))
(message "Error while loading %s" file)
;; point is not always moved to the beginning of the buffer
;; after `insert-file-contents' is done.
(goto-char (point-min))
(condition-case err
(read (current-buffer))
(message "Error while reading %s; %s"
file (error-message-string err))
(defun w3m-save-list (file list &optional coding-system escape-ctl-chars)
"Save a LIST form into the emacs-w3m data file FILE.
Contents will be encoded with CODING-SYSTEM which defaults to the
value of `w3m-file-coding-system'. Optional ESCAPE-CTL-CHARS if it is
non-nil, control chars will be represented with ^ as `cat -v' does."
(when (and list (file-writable-p file))
(let ((coding-system-for-write (or coding-system w3m-file-coding-system))
(standard-output (current-buffer))