I have set a key binding in Emacs using:
(global-set-key (kbd "<C-tab>") 'switch-view )
: It works in Windows but Emacs in Linux seems to ignore it. Any ideas why?
My version of Emacs is 23.2 running in text mode (.nw)
In text mode, Emacs depend upon the terminal or the console for keys combination. Terminals and consoles don't support as many keys combination as Xorg and windows do, and C-TAB is a combination that don't exist in text mode: TAB is already the same than C-i, and C-C-something don't exists.
The window manager you are using is most likely 'kidnapping' it.
On mine (which is KDE), C-tab cycles through applications on the current desktop. You can configure which keystrokes should be ignored though... but your best bet may be to map switch-view to another key sequence in your ~/.emacs file.
Related
I know there's some questions that are kind of related to this already, and I know you can do stuff like
(defun term-send-esc ()
"Send ESC in term mode."
(interactive)
(term-send-raw-string "\e"))
but it would be very convenient if there was kind of a univerisal override keybinding. For example, I just ssh:ed into a remote server and tried to nano a file and couldn't figure out how to exit because Ctl-x listens for emacs bindings. Is there such a thing?
There are two term sub modes, term-char-mode (C-x C-k) and term-line-mode (C-x C-j). Char mode is closer to a terminal, line mode is closer to a regular buffer. IIRC, multiterm starts in char mode, but it rebinds some keys to make it more Emacs-like. Look at the keys that multiterm rebinds; it has some alists that are used to modify the existing term-mode keymaps instead of using its own keymap. Or use sane-term, which is not much more than some commands to create new term buffers (no mucking with key bindings).
Ctl-x listens for emacs bindings.
Not in the default term-char-mode it doesn't, so your problem is most likely with your own config.
Run a terminal in emacs -Q to confirm the standard behaviour.
I am using Emacs 24.1 on windows XP/7.
TAB/RET key works for auto-completing in elisp mode,
scratch and even ESS mode.
When I write tex file using Auctex, hitting TAB key
jumps to the next line and doesn't auto-complete the
input. C-i could auto-complete the input in Auctex.
but it takes two keys. Any suggestions to solve this?
I am trying to set [Ctrl]-[;] as a keybinding in my .emacs like this
(global-set-key "\C-;" 'comment-or-uncomment-region)
however it doesn't work when I try (i don't get any error messages, it just has no effect). It will work though if i try a normal character (such as setting it to "\C-p").
I have also tried
(global-set-key (kbd "C-;") 'comment-or-uncomment-region)
but I don't like this option because for me it doesn't work when i run "emacs -nw". Any thoughts on how I can do this?
EDIT:
When I run C-hcC-; in emacs -nw I get the output:
; runs the command self-insert-command
which is exactly the same as when I run C-hc; in emacs -nw
So I believe phils is right, that it is a terminal problem, because emacs never actually sees C-;, it only sees ;
Indeed C-; is typically not something your terminal is able to send to an underlying application like Emacs (so it works under a GUI but not in a terminal). But I wonder: why do you need such a binding anyway, given that M-; is already bound to comment-dwim which does comment/uncomment the region when the region is selected, so it provides a superset of comment-or-uncomment-region.
Using (kbd "C-;") is absolutely fine and correct.
I suspect when you type C-; when running emacs -nw, your terminal is not actually sending anything to Emacs.
So your problem is more likely to be a question of how to get your terminal to send C-; to Emacs (or alternatively how to get Emacs to recognise the sequence which is sent).
If you run emacs -Q -nw and type C-hcC-;, do you get a "C-; is undefined" message?
Assuming that it is a terminal issue, here are some related Q&As which may point you in the right direction, but it's going to depend upon the particular terminal you are using.
Binding M-<up> / M-<down> in Emacs 23.1.1
Send "C-(" to Emacs in VT100/xterm terminal (Mac OS X's Terminal)?
How does one send S-RET to Emacs in a terminal?
emacs -nw issues with cscope and terminals
I load GNU emacs in it's own window by typing emacs in the terminal.
I like to use the keybindings from pc-selection-mode, which allows you to highlight characters using shift-right or shift-left, or entire lines by pressing shift-up or shift-down.
The problem is that when I run emacs in the terminal by typing emacs -nw, the latter 2 keybindings don't work. I can highlight characters using shift-left and shift-right, but pressing shift-up and shift-down doesn't do anything. The cursor stays where it is.
How do I fix this problem? Why is it even occurring? I'm using GNU Emacs 23.1.1, and I've confirmed that the same version is being used both when emacs is in it's own window and when emacs is running inside the terminal.
Thanks for any help
A lot of times the bindings just aren't listed, or are mapped wrong. You can try M-x show-lossage (or C-h l) to see if the escape sequences reach emacs or not. If they do, you might want to try xterm-extras -- it's always worked even as I migrate between different versions of linux and solaris, and as I ssh between them (which is often a source of problems).
I'm trying to teach Emacs standard shortcut keys. I use emacs23-nox version from Debian, often through SSH connection. One of those is CTRL+SHIFT+S for SaveAs. The relevant part of configuration looks like this:
(global-set-key (kbd "C-S") 'write-file)
(global-set-key (kbd "C-s") 'save-buffer)
but causes either both CTRL+SHIFT+S and CTRL+S invoke 'save-buffer (or 'write-file, depending on which line comes last). I also tried "C-S-s" instead of "C-S".
No Use of Shift Key section of Why Emacs's Keyboard Shortcuts Are Painful says it's not possible. I read this answer, but the accepted solution doesn't work for me (C-h k CTRL+SHIFT+S prints C-s).
Is there a way to make Emacs (the no GUI version) differentiate between CTRL+SHIFT+S and CTRL+S?
You can't, there isn't any provision in the character sets for uppercase control characters. The only way you can get shift and control is by going direct to the windowing system, so you need the GUI version.
To clarify a bit: If you are using Emacs with a window manager, then you can bind the key [(control shift ?s)], which is C-S-s (aka C-S, but not written this way in Emacs). This key is definitely different from the ASCII control character C-s, which has no lowercase/uppercase versions.
So the answer is (a) you have to be using a graphics terminal; (b) bind [(control shift ?s)] to get the uppercase version.