(unless (featurep 'xemacs) (add-hook 'w3m-mode-hook (lambda () (let ((key1 ?\C-0) (key2 ?\M-0) (ch 0)) (while (< ch 10) (define-key w3m-mode-map (vector (+ key1 ch)) 'w3m-goto-buffer) (define-key w3m-mode-map (vector (+ key2 ch)) 'w3m-goto-buffer) (setq ch (1+ ch)))) (define-key w3m-mode-map "\M-u" 'w3m-goto-unseen-buffer)))) (defun w3m-goto-unseen-buffer () "Goto next unseen w3m buffer." (interactive) (let* ((bufs (w3m-list-buffers)) (nowbuf (current-buffer)) current unseens0 unseens1 buf) (dolist (buf bufs) (when (w3m-unseen-buffer-p buf) (if current (setq unseens1 (cons buf unseens1)) (setq unseens0 (cons buf unseens0)))) (when (eq nowbuf buf) (setq current t))) (if unseens1 (setq buf (car (nreverse unseens1))) (setq buf (car (nreverse unseens0)))) (if buf (progn (w3m-history-store-position) (set-window-buffer (selected-window) buf) (run-hooks 'w3m-select-buffer-hook) (w3m-select-buffer-update)) (message "No unseen buffer.")))) (defun w3m-goto-buffer (&optional arg) "Goto w3m buffer to accompany inputed numbers like the following, C-2 => *w3m*<2> M-0 => *w3m*12M-3 => *w3m*<123>" (interactive "p") (let* ((num (+ (- (logand last-command-event ?\177) ?0) (if (not current-prefix-arg) 0 (* arg 10)))) (bufs (w3m-list-buffers)) (max (length bufs)) buf bufname win) (when (>= num 0) (setq buf (if (or (= num 0) (> num max)) (nth (1- max) bufs) (nth (1- num) bufs))) (setq bufname (when (and buf (buffer-live-p buf)) (buffer-name buf))) (if (not bufname) (message "No exist w3m buffer") (cond ((eq major-mode 'w3m-mode) (w3m-history-store-position) (set-window-buffer (selected-window) buf)) ((setq win (catch 'win (walk-windows (lambda (w) (save-excursion (set-buffer (window-buffer w)) (when (eq major-mode 'w3m-mode) (throw 'win w))))))) (select-window win) (set-window-buffer win buf)) (t (pop-to-buffer buf))) (w3m-history-restore-position) (run-hooks 'w3m-select-buffer-hook) (w3m-select-buffer-update) (message "Goto w3m buffer \"%s\"" bufname)))))
ブランクが4年近くあるので、なんだか気に入らないコードだ。。。