;; ぼくの場合 w3m-namazu は mew-nmz からしか使わないので、"-r" オプションを追加 (setq w3m-namazu-arguments '("-r" "-h" "-H" "-n" w3m-namazu-page-max "-w" whence)) ;; M-m を押すと、Mew と emacs-w3m の間を行き来する。 ;; mew-nmz-namazu の結果上だと、その message までジャンプ。 (add-hook 'w3m-mode-hook (lambda () (define-key w3m-mode-map "\M-m" 'mew-nmz-namazu-return-mew))) (add-hook 'mew-summary-mode-hook (lambda () (define-key mew-summary-mode-map "\M-m" 'w3m))) (defun mew-nmz-namazu-return-mew (&optional arg) (interactive "P") (when (and (boundp 'mew-init-p) mew-init-p (stringp w3m-current-url)) (let ((url (w3m-anchor)) (mailregex (concat "^\\(" (regexp-quote (expand-file-name mew-mail-path)) "/.+\\)/\\([0-9]+\\)$")) (nmz-p (and arg (boundp 'mew-nmz-namazu-index-alias) (stringp w3m-current-url) (string-match (concat "^" (regexp-quote (concat "about://namazu/?index=" mew-nmz-namazu-index-alias))) w3m-current-url) (> (length mew-nmz-namazu-miss-folders) 0))) fld msg) (when (and url (w3m-url-local-p url)) (setq url (expand-file-name (w3m-url-to-file-name url))) (when (string-match mailregex url) (setq msg (match-string 2 url)) (setq fld (mew-nmz-url-to-folder (match-string 1 url))))) (or (when (and (boundp 'mew-init-p) mew-init-p) (let ((buflst (buffer-list)) buf frame) (setq buf (catch 'loop (save-excursion (while (setq buf (car buflst)) (set-buffer buf) (when (and (memq major-mode '(mew-summary-mode mew-virtual-mode)) (get-buffer-window buf t)) (throw 'loop buf)) (setq buflst (cdr buflst)))))) (when buf (setq frame (window-frame (get-buffer-window buf t))) (if (fboundp 'select-frame-set-input-focus) (select-frame-set-input-focus frame) (raise-frame frame) (select-frame frame) (focus-frame frame)) (pop-to-buffer buf)))) (mew)) (when (and fld msg (not nmz-p)) (mew-nmz-goto-folder-msg fld msg)) (when nmz-p (let ((current-prefix-arg t)) (mew-nmz-namazu nil nil)))))) ;; 未検索の index が残っているときはメッセージを表示。 (add-hook 'w3m-fontify-before-hook 'mew-nmz-namazu-warning) (defun mew-nmz-namazu-warning () "Insert mew-nmz warning." (let (len) (when (and (boundp 'mew-nmz-namazu-index-alias) (stringp w3m-current-url) (string-match (concat "^" (regexp-quote (concat "about://namazu/?index=" mew-nmz-namazu-index-alias))) w3m-current-url) (> (setq len (length mew-nmz-namazu-miss-folders)) 0)) (goto-char (point-min)) (when (search-forward "</b>" nil t) (insert "\n \n <b>Warning: mew-nmz の検索で " (format "%s個" (japanese-zenkaku (number-to-string len))) "の index が残っています。</b><br>\n" " 検索を続けるときは " "<b>\"C-u M-m\"</b> を押すか、Mew に戻って " "<b>\"C-u kN\"</b> を押してください。\n"))))) ;; 新しい window で Mew の message を開いたときの表示位置修正 (defadvice w3m-view-this-url (after set-window-start activate) (mew-nmz-set-window-start (ad-get-arg 1) (ad-get-arg 2))) (defun mew-nmz-set-window-start (arg new-session) "Set window start for mew-nmz-namazu." (unless (or arg new-session) (when (and w3m-current-url (w3m-url-local-p w3m-current-url) (boundp 'mew-mail-path) (string-match (concat "^" (regexp-quote (expand-file-name mew-mail-path)) "/.+/[0-9]+$") (w3m-url-to-file-name w3m-current-url)) (get-text-property (point-min) 'mew-invisible)) (set-window-start (selected-window) (if (get-text-property (point-min) 'mew-visible) (point-min) (or (next-single-property-change (point-min) 'mew-visible) (point-min)))))))