2009年7月24日金曜日

emacs-w3mのキーバインディングをw3mっぽくしたい

w3mを昔から使ってきたため、emacs-w3m独特のキーバインディングにどうしても馴染めず、自分はemacs-w3mをw3mっぽく設定して使っている。

といっても、中身はemacs-w3mのメーリングリストにあったものを少し変えただけ。

このキーバインディングのおかげでemacs-w3mを快適に使えるようになった。

;;
;; http://emacs-w3m.namazu.org/ml/msg05447.html
;;
(define-key w3m-mode-map "\C-@" 'set-mark-command) ; MARK
;;  (define-key w3m-mode-map "\C-a" 'beginning-of-line)
;;  (define-key w3m-mode-map "\C-b" 'backward-char)
;;  (define-key w3m-mode-map "\C-e" 'end-of-line)
;;  (define-key w3m-mode-map "\C-f" 'forward-char)
;;  (define-key w3m-mode-map "\C-g" 'what-line) ; LINE_INFO
(define-key w3m-mode-map "\C-h" 'w3m-db-history)
(define-key w3m-mode-map "\t" 'w3m-next-anchor)
(define-key w3m-mode-map "\C-j" 'w3m-view-this-url)
(define-key w3m-mode-map "\C-k" 'w3m-cookie)
;;  (define-key w3m-mode-map "\C-l" 'recenter)
(define-key w3m-mode-map "\C-m" 'w3m-view-this-url)
;;  (define-key w3m-mode-map "\C-n" 'next-line)
;;  (define-key w3m-mode-map "\C-p" 'previous-line)
;;  (define-key w3m-mode-map "\C-r" 'isearch-backward)
;;  (define-key w3m-mode-map "\C-s" 'isearch-forward)
(define-key w3m-mode-map "\C-u" 'w3m-previous-anchor)
;;  (define-key w3m-mode-map "\C-v" 'scroll-up)
;;  (define-key w3m-mode-map "\C-w" 'undefined)      ; WRAP_TOGGLE
(define-key w3m-mode-map "\C-z" 'w3m-close-window)

(define-key w3m-mode-map " " 'w3m-scroll-up-or-next-url)
(define-key w3m-mode-map "!" 'shell-command)
;;  (define-key w3m-mode-map "\"" 'undefined)        ; REG_MARK
;;  (define-key w3m-mode-map "#" 'undefined)         ; PIPE_SHELL
(define-key w3m-mode-map "$" 'end-of-line)
(define-key w3m-mode-map "," (lambda () (interactive) (w3m-scroll-right 1)))
(define-key w3m-mode-map "." (lambda () (interactive) (w3m-scroll-left 1)))
(define-key w3m-mode-map "/" 're-search-forward) ; SEARCH
;;  (define-key w3m-mode-map ":" 'undefined)         ; MARK_URL
;;  (define-key w3m-mode-map ";" 'undefined)         ; MARK_WORD
(define-key w3m-mode-map "<" 'w3m-scroll-right)
(define-key w3m-mode-map "=" 'w3m-view-header)
(define-key w3m-mode-map ">" 'w3m-scroll-left)
(define-key w3m-mode-map "?" 're-search-backward) ; SEARCH_BACK
;;  (define-key w3m-mode-map "@" 'undefined)         ; READ_SHELL
(define-key w3m-mode-map "B" 'w3m-view-previous-page)
(define-key w3m-mode-map "E" 'w3m-edit-this-url)
;;  (define-key w3m-mode-map "F" 'undefined)         ; FRAME
(define-key w3m-mode-map "G" 'end-of-buffer)
(define-key w3m-mode-map "H" 'describe-mode)
(define-key w3m-mode-map "I" 'w3m-view-image)
(define-key w3m-mode-map "J" (lambda () (interactive) (scroll-up 1)))
(define-key w3m-mode-map "K" (lambda () (interactive) (scroll-down 1)))
(define-key w3m-mode-map "M" 'w3m-view-url-with-external-browser)
(define-key w3m-mode-map "N" 're-search-backward) ; SEARCH_PREV
(define-key w3m-mode-map "Q" 'w3m-quit)
(define-key w3m-mode-map "R" 'w3m-reload-this-page)
;;  (define-key w3m-mode-map "S" 'undefined)         ; SAVE_SCREEN
(define-key w3m-mode-map "U" 'w3m-goto-url)
(define-key w3m-mode-map "V" 'w3m-find-file)
(define-key w3m-mode-map "W" 'backward-word)
(define-key w3m-mode-map "Z" 'w3m-horizontal-recenter)
(define-key w3m-mode-map "[" '(lambda () (interactive) (beginning-of-buffer)
                                (w3m-next-anchor)))
(define-key w3m-mode-map "]" '(lambda () (interactive) (end-of-buffer)
                                (w3m-previous-anchor)))
(define-key w3m-mode-map "^" '(lambda () (interactive) (beginning-of-buffer)
                                (w3m-next-anchor)))
(define-key w3m-mode-map "a" 'w3m-download-this-url)
(define-key w3m-mode-map "b" 'w3m-scroll-down-or-previous-url)
(define-key w3m-mode-map "c" 'w3m-print-current-url)
(define-key w3m-mode-map "g" 'beginning-of-buffer)
(define-key w3m-mode-map "h" 'backward-char)
;;  (define-key w3m-mode-map "i" 'undefined)         ; PEEK_IMG
(define-key w3m-mode-map "j" 'next-line)
(define-key w3m-mode-map "k" 'previous-line)
(define-key w3m-mode-map "l" 'forward-char)
(define-key w3m-mode-map "n" 're-search-forward) ; SEARCH_NEXT
(define-key w3m-mode-map "o" '(lambda () (interactive) (customize-group 'w3m)))
(define-key w3m-mode-map "q" 'w3m-close-window)
(define-key w3m-mode-map "s" 'w3m-switch-buffer)
(define-key w3m-mode-map "u" 'w3m-print-this-url)
(define-key w3m-mode-map "s" 'w3m-db-history)
(define-key w3m-mode-map "v" 'w3m-view-source)
(define-key w3m-mode-map "w" 'forward-word)
(define-key w3m-mode-map "z" 'recenter)

(define-key w3m-mode-map "\M-\t" 'w3m-previous-anchor)
(define-key w3m-mode-map "\C-\M-j" 'w3m-download-this-url)
(define-key w3m-mode-map "\C-\M-m" 'w3m-download-this-url)

;;  (define-key w3m-mode-map "\M-:" 'undefined)      ; MARK_MID
;;  (define-key w3m-mode-map "\M-<" 'beginning-of-buffer)
;;  (define-key w3m-mode-map "\M->" 'end-of-buffer)
(define-key w3m-mode-map "\M-I" 'w3m-save-image)
;;  (define-key w3m-mode-map "\M-M" 'undefined)      ; EXTERN_LINK
;;  (define-key w3m-mode-map "\M-W" 'undefined)      ; DICT_WORD_AT
(define-key w3m-mode-map "\M-a" 'w3m-bookmark-add-current-url)
(define-key w3m-mode-map "\M-b" 'w3m-bookmark-view)
;;  (define-key w3m-mode-map "\M-e" 'undefined)      ; EDIT_SCREEN
(define-key w3m-mode-map "\M-g" 'goto-line)
;;  (define-key w3m-mode-map "\M-n" 'undefined)      ; NEXT_MARK
;;  (define-key w3m-mode-map "\M-p" 'undefined)      ; PREV_MARK
;;  (define-key w3m-mode-map "\M-s" 'undefined)      ; SAVE
(define-key w3m-mode-map "\M-u" 'w3m-goto-url) ; GOTO_RELATIVE
(define-key w3m-mode-map "\M-v" 'scroll-down)
;;  (define-key w3m-mode-map "\M-w" 'undefined)      ; DICT_WORD

(define-key w3m-mode-map [up] 'previous-line)
(define-key w3m-mode-map [down] 'next-line)
(define-key w3m-mode-map [right] 'forward-char)
(define-key w3m-mode-map [left] 'backward-char)

(define-key w3m-mode-map [home] 'beginning-of-buffer)
;;  (define-key w3m-mode-map [insertchar] 'undefined) ; MENU
(define-key w3m-mode-map [end] 'end-of-buffer)
(define-key w3m-mode-map [prior] 'scroll-up)
(define-key w3m-mode-map [next] 'scroll-down)

;;
;; http://emacs-w3m.namazu.org/ml/msg05444.html
;;
(define-key w3m-mode-map [up] 'previous-line)
(define-key w3m-mode-map [down] 'next-line)
(define-key w3m-mode-map [right] 'forward-char)
(define-key w3m-mode-map [left] 'backward-char)
(define-key w3m-mode-map "H" 'describe-mode)
(define-key w3m-mode-map "w" 'forward-word)
(define-key w3m-mode-map "W" 'backward-word)
(define-key w3m-mode-map "z" 'recenter)
(define-key w3m-mode-map "Z" 'w3m-horizontal-recenter)
(define-key w3m-mode-map "\C-t" 'w3m-view-this-url-new-session)
(require 'vi)
(define-key w3m-mode-map "/" 'vi-search-forward)
(define-key w3m-mode-map "?"  'vi-search-backward)
(define-key w3m-mode-map "n" 'vi-repeat-last-search)
(define-key w3m-mode-map "N" 'vi-reverse-last-search)