This question already has an answer here:
Why does Ctrl+. not work when I bind it to a command in Emacs?
(1 answer)
Closed 2 years ago.
add a key-binding in emacs init file:
(global-set-key (kbd "C-:") 'avy-goto-char)
for avy-goto-char function.
When I press down Ctrl and :(with Shift pressed), nothing happens.
But when use Meta-x avy-goto-char, the commands list window shows C-: already bound to this function. And this function works well.
And if I replace char : to j (for example), it works fine.
Anyone met this problem before. Please help
Just like phils said, it is used in a terminal
Related
This question already has an answer here:
Why does Ctrl+. not work when I bind it to a command in Emacs?
(1 answer)
Closed 2 years ago.
I am using emacs26.3 with the major mode "Javascript-IDE" activated. When I type M-x comment-line the desired effects happen in the editor. However, when I type the shortcut C-x C-; I have this output:
Comment column set to 2
And the line is not commented/uncommented. C-h b shows that is the key binding is correct.
Here is my emacs configuration: https://github.com/Amine27/dotfiles/blob/master/emacs.el
Are you using emacs in a terminal? A terminal cannot transmit all combinations of keys and modifiers you could press. I can reproduce this behavior when I run emacs in my terminal (pressing C-; just produces an ordinary ;), but when run in my OS's windowing system emacs registers the C-; chord as desired.
This question already has an answer here:
Why the key binding M-S-t fails while C-S-t works?
(1 answer)
Closed 4 years ago.
By default, C-S-t and M-S-t are both unbound in my Emacs. Hence, when I press them, they are translated into C-t and M-t. Fine, but I want to use them for a tweak on the original function, and therefore put these lines in my .emacs:
(global-set-key (kbd "C-S-t") 'transpose-chars-backward)
(global-set-key (kbd "M-S-t") 'transpose-words-backward)
The functions there are my own, and work fine when called via M-x.
This works for C-S-t, but not for M-S-t which still gets translated to M-t. The message on C-h k M-S-t confirms this.
It's not that it's impossible to configure M-S- combinations in general, because M-q and M-S-q do different things.
What causes this inconsistency and how can I get around it?
I'm running Aquamacs on Mac OS X 10.9.5.
Here you have two different ways to do what you want:
(global-set-key (kbd "M-T") 'transpose-words-backwards)
(global-set-key [(meta shift t)] 'transpose-words-backwards)
I am not sure what causes the (kbd "M-S-t") working differently from (kbd "C-S-t"), btw. Time ago I became an adept to vector notation ([(meta shift t)]) as I find it more predictable (I always get it right the first time, and with kbd notation sometimes I needed a couple of tries).
This question already has answers here:
Emacs: help me understand file/buffer management
(6 answers)
Closed 8 years ago.
After having typed C-x C-b there will a new window showing currently opened buffers... that is easy. But how can I switch to one of them using only my keyboard? Now I have to move my mouse an click on the one of my interest, and that looks stupid:(
Thanks!
It's a standard read-only buffer with some special bindings. Switch to the window first with C-x o, then you can browse buffers with n, p. Open one in the new window with RET. You can even search the buffer if desired.
Check ido mode. Actually similar questions have been asked quite a few time.
I have just switched from using Emacs.app to emacs server and emacsclient in terminal mode using iterm2 as my terminal emulator. I am having some trouble with some keybindings though. Particularly M-left arrow prints the character D, M-right arrow prints C, M-up arrow prints A, and M-down arrow prints B. M-ret seems to work though, at least for org mode. I am using the xterm defaults for keys in iterm2 and have the left and right option keys bound to +Esc. I can get the M-left functionality in org-mode with Esc-left or Esc-right This is particularly annoying in org-mode. Am I going to have to just rebind the keys in my .emacs? How would I go about doing that?
I have looked at this http://orgmode.org/manual/TTY-keys.html#TTY-keys, but I don't understand why the arrow keys should be unavailable in the terminal.
edit:
Cat meta-up: ^[[1;9A
Cat meta-down: ^[[1;9B
Cat meta-right: ^[[1;9C
Cat meta-left: ^[[1;9D
Main problem solved, but I am now having trouble with shift-up. "<select> undefined". I tried a similar mapping with the escape sequence I got from cat: ^[[1;2A. Reluctant to create another question for a similar problem.
Solution 1
Based on the info you provided, here's one thing you can try. You tell emacs to map those escape sequences to the proper key sequences:
(add-hook 'term-setup-hook
(lambda ()
(define-key function-key-map "\e[1;9A" [M-up])
(define-key function-key-map "\e[1;9B" [M-down])
(define-key function-key-map "\e[1;9C" [M-right])
(define-key function-key-map "\e[1;9D" [M-left])))
Solution 2
I also found another possible solution with a little googling: redefine the iTerm bindings instead, to match what emacs is looking for.
http://offbytwo.com/2012/01/15/emacs-plus-paredit-under-terminal.html
Quote from the above page:
Go back to the profile key bindings under iTerm2 and add bindings for the following:
M-up : Esc-[1;4A
M-down : Esc-[1;4B
M-right : Esc-[1;4C
M-left : Esc-[1;4D
I'm answering in reply to your 'main problem solved, but new one' edit.
I found this guy's blog post on this issue:
- http://webframp.com/emacs/2013/02/22/fixing-emacs-bindings-on-the-in-iterm2/
Basically, you can use the 'run cat' and push buttons trick to see what escape codes are getting sent by your system/terminal, then add 'define-key' lines to define M-{up,down,right,left} and also M-S-{up,down,right,left}.
This question already has answers here:
Emacs: check for no-window-system in .emacs
(2 answers)
Closed 8 years ago.
there are portions of my .emacs file that I would like to behave differently depending if emacs was opened in a terminal (ie, emacs -nw) or in a window. How does one go about detecting this?
In my FSF .emacs, I have code like this:
(if (null window-system)
(global-set-key "\C-h" 'delete-backward-char))
It looks like this works under XEmacs as well, though the preferred XEmacs way is to use the console-type function instead. Do M-x describe-function on console-type for details.