[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Patch for w3m variants
- From: Kiyokazu SUTO <suto@xxxxxxxxxxxxxxx>
- Date: 18 Apr 2001 20:57:59 +0900
- X-ml-name: emacs-w3m
- X-mail-count: 00555
w3mのvariant(e.g., w3mmee)でもemacs-w3mを使えるようにする作業を簡単に
するための(Revision: 1.206への)パッチを↓に添付します。
やっていることは
1. w3mから/への入出力の文字のencodingを固定する、
2. 起動コマンドのオプションを、一部だけ標準と変えられるようにする、
の2点です。
w3mmeeと共に使うためには、まずw3mmeeを
http://pub.ks-and-ks.ne.jp/prog/w3mmee/#working
から取れる最新の開発版:
w3mmee-devel.diff.gz (249KB, 2001-04-18 20:44:19)
(p19-pre29)までバージョンアップして
(setq w3m-command "w3mmee"
w3m-command-arguments '("-o" "concurrent=0")
w3m-mnc t
w3m-w3m-decode-all-to-this-charset 'euc-jp
w3m-input-coding-system 'euc-japan
w3m-output-coding-system 'euc-japan
w3m-w3m-dump-head-source-option "-dump=extra,head,decode"
w3m-halfdump-extra-options '("-I" "euc-jp" "-o" "concurrent=0")
w3m-halfdump-option "-dump=half-buffer"
w3m-coding-system 'euc-japan
w3m-profile-directory (expand-file-name "~/.w3mmee")
w3m-default-save-directory (expand-file-name "~/.w3mmee"))
という設定を、euc-jpとかeuc-japanとかをw3mmee側の端末出力コードに合わ
せて適当に変更の上、~/.emacs等に追加する必要があります。
--
須藤 清一 <suto@ks-and-ks.ne.jp>
http://pub.ks-and-ks.ne.jp/pgp-public-key.html
Index: w3m.el
===================================================================
RCS file: /usr/site/cvsroot/emacs-w3m/w3m.el,v
retrieving revision 1.1.1.3
retrieving revision 1.2
diff -u -r1.1.1.3 -r1.2
--- w3m.el 2001/04/18 04:50:16 1.1.1.3
+++ w3m.el 2001/04/18 06:39:01 1.2
@@ -650,8 +650,11 @@
"\\(\"\\([^\"]+\\)\"\\|'\\([^\']+\\)'\\|[^\"\'<> \t\r\f\n]*\\)"
"Regexp used in parsing to detect string."))
+(defvar w3m-halfdump-extra-options '())
+(defvar w3m-halfdump-option "-halfdump")
+
(defconst w3m-halfdump-command-arguments
- '("-T" "text/html" "-t" tab-width "-halfdump"
+ '("-T" "text/html" "-t" tab-width w3m-halfdump-option
"-cols" (if (< 0 w3m-fill-column)
w3m-fill-column ; fixed columns
(+ (frame-width) (or w3m-fill-column -1)))) ; fit for frame
@@ -1550,43 +1553,49 @@
(w3m-which-command (car x))
t '(t nil) nil (nth 1 x)))))))
+(defvar w3m-w3m-decode-all-to-this-charset nil)
+
(defun w3m-decode-buffer (url &optional cs)
- (let ((type (w3m-content-type url))
- (charset (w3m-content-charset url))
- (encoding (w3m-content-encoding url)))
- (unless (w3m-decode-encoded-buffer encoding)
- (error "Can't decode encoded contents: %s" url))
- (if (and (not charset) (string= type "text/html"))
- (setq charset
- (let ((case-fold-search t))
- (goto-char (point-min))
- (and (or (re-search-forward
- w3m-meta-content-type-charset-regexp nil t)
- (re-search-forward
- w3m-meta-charset-content-type-regexp nil t))
- (match-string-no-properties 2)))))
- (decode-coding-region
- (point-min) (point-max)
- (cond
- (cs cs)
- (charset
- (w3m-charset-to-coding-system charset))
- (t
- (let ((default (condition-case nil
- (coding-system-category w3m-coding-system)
- (error nil)))
- (candidate (detect-coding-region (point-min) (point-max))))
- (unless (listp candidate)
- (setq candidate (list candidate)))
- (catch 'coding
- (dolist (coding candidate)
- (if (eq default (coding-system-category coding))
- (throw 'coding coding)))
- (if (eq (coding-system-category 'binary)
- (coding-system-category (car candidate)))
- w3m-coding-system
- (car candidate)))))))
- (set-buffer-multibyte t)))
+ (if w3m-w3m-decode-all-to-this-charset
+ (decode-coding-region
+ (point-min) (point-max)
+ (w3m-charset-to-coding-system w3m-w3m-decode-all-to-this-charset))
+ (let ((type (w3m-content-type url))
+ (charset (w3m-content-charset url))
+ (encoding (w3m-content-encoding url)))
+ (unless (w3m-decode-encoded-buffer encoding)
+ (error "Can't decode encoded contents: %s" url))
+ (if (and (not charset) (string= type "text/html"))
+ (setq charset
+ (let ((case-fold-search t))
+ (goto-char (point-min))
+ (and (or (re-search-forward
+ w3m-meta-content-type-charset-regexp nil t)
+ (re-search-forward
+ w3m-meta-charset-content-type-regexp nil t))
+ (match-string-no-properties 2)))))
+ (decode-coding-region
+ (point-min) (point-max)
+ (cond
+ (cs cs)
+ (charset
+ (w3m-charset-to-coding-system charset))
+ (t
+ (let ((default (condition-case nil
+ (coding-system-category w3m-coding-system)
+ (error nil)))
+ (candidate (detect-coding-region (point-min) (point-max))))
+ (unless (listp candidate)
+ (setq candidate (list candidate)))
+ (catch 'coding
+ (dolist (coding candidate)
+ (if (eq default (coding-system-category coding))
+ (throw 'coding coding)))
+ (if (eq (coding-system-category 'binary)
+ (coding-system-category (car candidate)))
+ w3m-coding-system
+ (car candidate)))))))))
+ (set-buffer-multibyte t))
;;; Retrieve local data:
@@ -1723,11 +1732,13 @@
(while (search-forward "\r\n" nil t)
(delete-region (- (point) 2) (1- (point)))))))
+(defvar w3m-w3m-dump-head-source-option "-dump_extra")
+
(defun w3m-w3m-dump-head-source (url)
(and (let ((w3m-current-url url)
(w3m-w3m-retrieve-length))
(w3m-message "Reading...")
- (prog1 (zerop (w3m-exec-process "-dump_extra" url))
+ (prog1 (zerop (w3m-exec-process w3m-w3m-dump-head-source-option url))
(w3m-message "Reading... done")
(w3m-crlf-to-lf)))
(goto-char (point-min))
@@ -1869,8 +1880,12 @@
(mapcar (lambda (x)
(if (stringp x)
x
- (prin1-to-string (eval x))))
- w3m-halfdump-command-arguments))
+ (setq x (eval x))
+ (if (stringp x)
+ x
+ (prin1-to-string x))))
+ (append w3m-halfdump-command-arguments
+ w3m-halfdump-extra-options)))
(w3m-message "Rendering... done")
(goto-char (point-min))
(insert