I want to be able to flip back and forwards between two buffers in Emacs in the same way I can flip between tabs in some other editors. The following Ctrl + TAB key binding works nicely in XEmacs:
(defun buffer-shimmy ()
"Back to the previous buffer"
(interactive)
(let ((buff (car (buffer-list))))
(message "Previous buffer: %s" buff)
(switch-to-buffer (other-buffer buff))
)
)
(global-set-key (kbd "<C-tab>") 'buffer-shimmy)
;; or (define-key global-map [(control tab)] 'buffer-shimmy)
However, it doesn't work when I open Emacs using "emacs -nw" (or if I'm using Emacs in an SSH session).
After finding this link - I think perhaps what I want is not possible?
Apparently, in the terminal (i.e. outside the Windowing system) adding a control modifier to the ASCII character for 'TAB' is nonsensical. Whereas, if going via a windowing system, Emacs can see you pressing Ctrl + TAB as <tab>
with a control modifier, which can be represented in the .emacs
file as C-<tab>
or <C-tab>
or [(control tab)]
.
Is there a workaround that fixes this issue?
Reference software: Emacs version: 22.2.1 on Ubuntu 9.04 using gnome-terminal with the default profile.