Good evening,
I have a problem using Emacs in Terminal.app the last 9 hours but wasn't able to solve it on my own.
The workarounds I have found on Stackoverflow etc. didn't persuade me.
I didn't want to use the Option 'Wahltaste als Metataste verwenden' (alt/option as meta), because I have to type for example {}[] with my alt-key. Keybinding of these Charakters in Emacs is no solution for me, because outside of Emacs in nano I want to use []{}..., too.
I also didn't want to use iTerm2.app, I think it should be possible in Terminal too.
Because sometimes I use Emacs over SSH, it is not possible to choose an GUI-based Emacs either.
A possibilty I would accept is to use the left alt/option key for meta and the right one for typing []{}... Or the Fn-Key for meta...
But I wasn't able to do it the last 9 hours...
I already ported 'emulate-mac-keybord-mode.el' from Aquamacs, but I didn't get it work as expected.
Does anybody have an idea?
Thanks in advance,
Zappel
If you insist on a TTY Emacs within Terminal.app, you may probably have some success with kernel level remappings of modifier keys, using KeyRemap4MacBook. I do not know, because I never used it for such things, and since the key codes, Terminal.app sends to the TTY process when a modifier is pressed, are ultimately hard-coded in Terminal.app, this is neither easy nor particularly pretty.
iTerm2 probably provides means to customize modifiers individually, and is generally a superior terminal emulator (with the notable exception of color management), but frankly, do yourself a favor, and use a GUI Emacs.
A GUI Emacs provides a much nicer expierence on OS X. You are not only able to map each modifier key individually with mac-option-modifier and friends, you also more modifiers available, namely Super and Hyper.
For instance, the following setting uses the Command keys as Meta, the function key has Hyper, and keeps the Option keys for OS X, so that you can still use the alternate layout level:
(setq mac-option-modifier 'none
mac-command-modifier 'meta
mac-function-modifier 'hyper)
To edit files on remote systems, you'd just use Tramp then.
Related
It is my first time to use emacs -nw. But I have problem at the first when I type M-x. In the minibuffer, it shows "Mark set" instead of M-x
I don't know why it happens. How can I deal with it?
PS: My os is Macosx and I connect remote by using ssh and then I type emacs -nw but I cannot use M-x
Update:08/30/2015
When I see the options under M-x customize-group ns, it seems that Alt is actually used as Meta? Why it didn’t works.
14Hide Ns Alternate Modifier: [Value Menu] meta |
15 [ State ]: STANDARD. |
16 This variable describes the behavior of the alternate or option key. More |
37Hide Ns Right Alternate Modifier: [Value Menu] Use the value of ns-alternate-modifier |
38 [ State ]: STANDARD. |
39 This variable describes the behavior of the right alternate or option key. More |
When using Emacs in the terminal (switch -nw), you might not have a Meta key, depending on your platform etc. In particular, the Alt keyboard key might not function as the Meta key. You might find some information (e.g. here, or by googling) about how to get it working as Meta for your context (platform etc.), but you might not.
You can always use ESC (the Escape key) followed by a key to act the same as the Meta modifier applied to that key. For example, instead of M-x, you can use ESC x.
(You press and release ESC, and then do the same for x. ESC is not a modifier key -- you do not hold it pressed while hitting x.)
Your problem is that OSX is stealing the key. There are a few things which will make your life easier
Install emacs using homebrew. The version which comes with OSX is old
Use iterm2 instead of the default term.app - much better and feature rich
In iterm2, you can set a key override for either the left or right option as +ESC, which will make it all work.
This will all work on a local machine, but you may run into additional problems if your connecting to a remote machine and running emacs there. It is a similar problem, your key settings may no be getting stolen/dropped by the ssh session - all depends on your terminal, your ssh config and the remote system.
Note that with emacs, you often don't need to run remote. Emacs comes with a built-in system called Tramp, which is very powerful. Using tramp, you can open remote directories and edit the files as if they were local files. You run emacs locally and tramp uses ssh to open the remote files, read the contents into the local emacs buffer and then write the changes back tot he remote file. Helps to have ssh keys setup so you don't have to worry about passwords (but you will need an ssh-agent to make this work easily).
In general, when you find emads does not respond to a key press, especailly if you try C-h k and nothing happens when you hit the key bindings you can't get to work, it is almost certain that something in-between you and emacs is stealing the keys - this is often the window manager or OS, but it can also be due to terminal emulators etc. In over 20 years of using emacs, I've never had emacs 'do nothing' when you hit a key combination - if emacs recieves the key input, it will respond with something, even if that something is to tell you there is no key binding for the keys you pressed. If emacs does absolutely nothing, you know the message just isn't get through!
Open Terminal Preferences
Select Profiles
Keyboard
Check the box for "Use Option as Meta Key"
I recently found out that Mac has system wide keybindings based on Emacs, but have had difficulty finding a complete list of them. Anyone know of any resources for this?
I've been learning Vim, but might start with Emacs instead if the OSX functionality is greater than just the arrow key style navigation I've found so far.
For the full monty of key bindings in Emacs, you can start with C-h b (or, equivalently, M-x describe-bindings). You can also check out this terrifyingly long table of default bindings. That's probably way more than you want or need right now, though.
Here's a list of default OSX system key bindings. The ones you're probably interested in are the ^ + LETTER keys, many of which are analogous to Emacs bindings.
A post on Irreal about Emacs Keybindings for Mac OS X talks about this system, and points out that the Cocoa Text System is customizable, which would allow you to add additional Emacs bindings (or whatever else you like). There's a link in the post that points to a keybindings file that creates a lot of those bindings.
I'm trying to make Firefox keybindings work for tabs in vim (ssh'd into a server through OSX Terminal), however I'm running into issues.
Its basically the same as this Stack Overflow question except for Terminal in Mac not xterm:
Mapping <C-Tab> in my vimrc fails in Ubuntu
From my research, it seems some terminals don't differentiate between <C+Tab> and <Tab>, so I'm wondering if there's some way to hack around this in the Terminal app so vim can understand it. (Maybe escape sequences or something...)
Any ideas?
Long story short: Ctrl-Tab doesn't exist, because Tab is really already a Control key, Ctrl-i.
Short story longer: There is a way to do it, but it requires a sufficiently large amount of hackery at both the terminal and the vim level that you may or may not consider it worth it. I'm working on a much better more generic solution to it but currently I'm not quite sure the world seems to want it.
http://www.leonerd.org.uk/hacks/fixterms/ if you are interested.
In Terminal.app's preferences, you can set some keybindings to send specific character sequences. In your case, you could set <C-Tab to send gt or whatever Vim shortcut you want.
Anyway, you'd better learn the right shortcuts.
I am trying to override Control-Meta-Down Arrow and Control-Meta-Up Arrow in emacs.
I've tried all sorts of combinations of: (global-set-key [C-M-down] 'function) and: "\C-\M-<down>" etc... but it always says: ESC undefined. This means it is only taking into account the M-<down>. Why is it ignoring the Control?? I've been working on this for 3 hours and emacs online documentation with regards to key bindings is surprisingly absolutely terrible.
When using Emacs in the terminal (which you mentioned in a comment), you are limited to the key sequences that the terminal is capable of. Unfortunately, C-down is not one of them...
Some versions of Emacs on Mac OS X have had problems with the qualifier keys. Try to update it to a newer version.
I tested this on an Emacs built from the source archive, and it works as intended. (In this case, it simply says that function is not defined, which is what expected.)
When I am running Emacs (in GUI mode) in GNOME, the meta key works fine i.e. alt-v jumps back one page.
But when I remove the line: "gnome-enable" from rc.conf and reboot FreeBSD then alt-v does not work in Emacs (although ctrl-v works). Doing alt-v in Emacs without GNOME simply prints v at the cursor. Yea... i can of course use esc as the meta key... but I would really love to use the alt / option key of my MacBook as the meta key.
I am running FreeBSD 8.1 on a MacBook.
Please help.
Thanks.
http://www.emacswiki.org/emacs/MetaKeyProblems goes into all (or most) of the ways that this can go wrong, and how to fix them. I don't have a gnome-enable locally, but I imagine that one of the things it does is (setq x-alt-keysym 'meta).