--- w3m.el~ 2010-01-13 00:59:40 +0000 +++ w3m.el 2010-01-14 11:47:57 +0000 @@ -2730,6 +2730,9 @@ (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'.") @@ -6621,7 +6624,7 @@ (defun w3m-view-this-url-1 (url reload new-session) (lexical-let ((url url) - pos buffer newbuffer wconfig) + pos buffer) (if new-session (let ((empty ;; If a new url has the #name portion, we simply copy @@ -6643,23 +6646,7 @@ (setq buffer (current-buffer))) (let (handler) (w3m-process-do - (success - (save-window-excursion - (prog1 - (w3m-goto-url url reload nil nil w3m-current-url handler) - (setq newbuffer (current-buffer) - wconfig (current-window-configuration))))) - ;; When the buffer's major mode has changed from the w3m-mode - ;; to another by visiting the new url (possibly a local file, - ;; a mailto url, etc.), we need to make the new buffer visible. - (when (and (eq (with-current-buffer buffer major-mode) - 'w3m-mode) - (not (eq (with-current-buffer newbuffer major-mode) - 'w3m-mode))) - ;; Empty buffer must delete before restore window configuration. - (when pos - (w3m-delete-buffer-if-empty buffer)) - (set-window-configuration wconfig)) + (success (w3m-goto-url url reload nil nil w3m-current-url handler)) ;; The new session is created. (when pos ;; Already empty buffer killed if the new url is not the w3m-mode. @@ -8691,6 +8678,10 @@ (copy-file ftp filename) (message "Wrote %s" filename))))) +(unless w3m-doc-view-map + (setq w3m-doc-view-map (make-sparse-keymap)) + (define-key w3m-doc-view-map "q" 'w3m-doc-view-quit)) + (defun w3m-doc-view (url) "View PDF/PostScript/DVI files using `doc-view-mode'. `w3m-pop-up-windows' and `w3m-pop-up-frames' control how the document @@ -8722,8 +8713,21 @@ (set-buffer-modified-p nil) (setq buffer-file-name url) (doc-view-mode) + (use-local-map w3m-doc-view-map) + (set-keymap-parent w3m-doc-view-map doc-view-mode-map) 'internal-view))) +(defun w3m-doc-view-quit (&optional kill) + "Quit the `doc-view-mode' window that emacs-w3m launches. +With the prefix argumentKILL, kill the buffer." + (interactive "P") + (cond (w3m-pop-up-frames + (when (prog1 (one-window-p t) (quit-window kill)) + (delete-frame (selected-frame)))) + (w3m-pop-up-windows + (quit-window kill) + (delete-window)))) + (eval-and-compile (unless (fboundp 'w3m-add-local-hook) ;; Silence the byte compiler; `w3m-add-local-hook' will be defined