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
(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.