Emacs-w3m comes with an excellent tab mode, which you can enable with (setq w3m-use-tab t) in your .emacs. C-cC-t creates new tabs, C-cC-w closes them and you can navigate then with C-cC-[np], or, my favourite, using a tab list via C-cC-s (if you didn’t know about this one, give it a try: it’s very useful).
But i quickly find myself with lots of open tabs that happen to be in the wrong order, and i wanted something akin to Firefox’s ability to move and reorder them around. I didn’t find a way change a tab’s position in a vanilla emacs-w3m, but it wasn’t that difficult to cook up my own solution. This function:
(defun jao-w3m-switch-buffers (dist)
(interactive "p")
(let* ((dist (if (zerop dist) 1 dist))
(current (current-buffer))
(current-no (w3m-buffer-number current))
(next (progn (w3m-next-buffer dist)
(current-buffer)))
(next-no (w3m-buffer-number next)))
(with-current-buffer current
(rename-buffer "*w3m*<*>")
(w3m-buffer-set-number next current-no)
(w3m-buffer-set-number current next-no)
(w3m-pack-buffer-numbers))
(switch-to-buffer current)))
switches the current tab with the one to its right (cyclically), or to the n-th to its right if you provide a numerical argument (e.g. M-3). I’ve got this function bound to C-cC-f:
(define-key w3m-mode-map (kbd "C-cC-f") 'jao-w3m-switch-buffers)
Alternatively, one could define a function that moves the current tab to the right a number of times. We can take advantage of the above function for a quick hack:
(defun jao-w3m-move-buffer (dist)
(interactive "p")
(let ((dist (if (zerop dist) 1 dist))
(while (> dist 0)
(jao-w3m-switch-buffers 1)
(setq dist (1- dist)))))
and bind that to a shortcut of your choice. There you go: easy tab shuffling.

February 22, 2007 at 9:40 am
Wow, great. Thanks!
Could something similar be done for tabbar.el? (Or extend w3m’s tab mode to Emacs in general, as it looks better
)
March 27, 2007 at 11:46 am
Leo suggested me to incorporate this great work into emacs-w3m and I’ve installed similar functions in the CVS trunk. Now you can use these keys:
`C-c C-,’, `C-c C-’, C-wheel-down. or C-mouse-5
Thank you very much for contributing this.
Best regards,
March 27, 2007 at 11:49 am
Oops. Some keys I wrote are missing in the publishing. Here they are:
`C-c C-,’, `C-c C-’, C-wheel-down. or C-mouse-5
March 27, 2007 at 11:51 am
This is the third try. :-’, C-wheel-down. or C-mouse-5