[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Tab shuffling in emacs-w3m
>>>>> In [emacs-w3m : No.09255] Leo wrote:
> Do you think it is useful to include such feature as in this article:
> http://emacs.wordpress.com/2007/02/22/tab-shuffling-in-emacs-w3m/
That's very good. But I think it is better to make those
commands behave symmetrically. How about this one?
--8<---------------cut here---------------start------------->8---
(defun w3m-tab-move-right (&optional n)
"Move this tab N times to the right (to the left if N is negative)."
(interactive "p")
(when (and w3m-use-tab (eq major-mode 'w3m-mode) (not (featurep 'xemacs)))
(unless n (setq n 1))
(let* ((buffers (if (> n 0)
(w3m-list-buffers)
(setq n (- n))
(nreverse (w3m-list-buffers))))
(dest (or (nth n (memq (current-buffer) buffers))
(car (last buffers))))
(next (w3m-buffer-number dest))
(cur (w3m-buffer-number (current-buffer))))
(rename-buffer "*w3m*<0>")
(w3m-buffer-set-number dest cur)
(w3m-buffer-set-number (current-buffer) next))
(w3m-pack-buffer-numbers)))
(defun w3m-tab-move-left (&optional n)
"Move this tab N times to the left (to the right if N is negative)."
(interactive "p")
(when (and w3m-use-tab (eq major-mode 'w3m-mode) (not (featurep 'xemacs)))
(unless n (setq n 1))
(w3m-tab-move-right (- n))))
(define-key w3m-mode-map [?\C-c ?\C-.] 'w3m-tab-move-right)
(define-key w3m-mode-map [?\C-c ?\C->] 'w3m-tab-move-right)
(define-key w3m-mode-map [?\C-c ?\C-,] 'w3m-tab-move-left)
(define-key w3m-mode-map [?\C-c ?\C-<] 'w3m-tab-move-left)
--8<---------------cut here---------------end--------------->8---