[Date Prev][Date Next][Thread Prev][][Date Index][Thread Index]

Re: closing a tab

On Sun, 16 Jan 2005 15:00:35 -0500 Gary Lawrence Murphy wrote:

> just a usability note: 'q' would seem the obvious choice to close
> the current tab, but it instead switches all tabs out of the current
> frame -- restarting w2-browse-url will restore ALL tabs, including
> the one where 'q' was issued, and create a new one.

I don't think it's a bug but the doc string is a bit confusing.
`w3m-close-window' actually only buries the buffer and doesn't
kill it.

> Is there some way to close just the current tab?  Is there a way
> to open the URL at the point into a new tab?

Probably not the most elegant way but seems to work (put it in
your ~/.emacs):


(defun my-w3m-close-tab ()
  "Close current w3m buffer and go to the previous.

Does nothing if the current buffer is not a w3m buffer."
  (let ((buffers (w3m-list-buffers)) (current (current-buffer)) prev)
    (when buffers
      (while (if (eq (car buffers) current)
                   (if (and (not prev) (cdr buffers))
                       (setq prev (cadr buffers)))
                   (kill-buffer current)
                   (when prev
                     (switch-to-buffer prev)
                     (run-hooks 'w3m-select-buffer-hook)
                   ;; abort iteration
               (setq prev (car buffers))
               (setq buffers (cdr buffers)))))))

(add-hook 'w3m-mode-hook
          (lambda ()
            (define-key w3m-mode-map (kbd "S-RET")
            (define-key w3m-mode-map "q"


Now 'q' kills the current w3m buffer and S-RET opens the URL at
point in a new tab.