I'm currently sshing from my mac to a CentOS box, where I run emacs. For whatever reason, the shift key doesn't seem to work when issuing a keyboard sequence. I suspect the wrong key code is being sent.
For example, I've remapped my help command to the following:
(global-set-key (kbd "C-?") 'help-command)
Executing this keyboard sequence in a typescript file reveals that it's invoking the delete-backward-char command, which is a compiled Lisp function from simple.el. (In order to even check what command the keyboard sequence was executing, I had to temporarily remap help to C-o.)
Similarly, I have the following key binding set up for typescript mode
(setq tss-popup-help-key "C-:")
Likewise, it looks like the SHIFT key hasn't registered because I get the following definition in the help manual when I reverse lookup the sequence:
; runs the command typescript-insert-and-indent, which is an
interactive compiled Lisp function in `typescript.el'.
It is bound to ,, ;, ), (, }, {.
(typescript-insert-and-indent KEY)
In other words, emacs registers the colon as a semi-colon.
This is a recurring problem with keyboard sequences that require me to use a SHIFT key. How do I get the SHIFT key to work properly when working on emacs through a mac?
For the record, when I use Emacs for OSX, the shift key works great.
Related
The "delete" key on my Macbook is broken. I am attempting to use the hidutil command to remap F1 as my new delete key. The command isn't performing as expected.
The command requires the hex ID's for the keys whose values I'd like to interchange. I've located a resource that provides these hex ID's as well as an overview of how to perform the remapping (https://developer.apple.com/library/archive/technotes/tn2450/_index.html).
I've posted my specific code below. It adheres to the suggested format, but my OS doesn't seem to register any change. Can someone help me identify the issue? I suspect my Hex ID's are wrong, but it may very well be another issue.
Input :
hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x2a,"HIDKeyboardModifierMappingDst":0x3a}, {"HIDKeyboardModifierMappingSrc":0x3a,"HIDKeyboardModifierMappingDst":0x2a}]}'
Output :
UserKeyMapping:(
{
HIDKeyboardModifierMappingDst = 58;
HIDKeyboardModifierMappingSrc = 42;
},
{
HIDKeyboardModifierMappingDst = 42;
HIDKeyboardModifierMappingSrc = 58;
})
There are no error objects. And judging by the output after the command is run some key remapping has occurred. However, my F1 key still retains functionality as F1 and doesn't delete I'd expected.
Your referenced link on apple.com says "The keys take a hexadecimal value that consists of 0x700000000 or’d with the desired keyboard usage value." So I think you should try e. g. HIDKeyboardModifierMappingSrc":0x70000002a ...
Thanks for the above information, I was able to remap the right Ctrl key to be the Command key on the mac with the following command.
% hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x7000000e4,"HIDKeyboardModifierMappingDst":0x7000000e3}]}'
This is because I am using a very old IBM original keyboard that does not have a windows key, just an empty space between the Ctrl and Alt keys on the left and right of the Space bar.
I had an idea (not sure whether it's original) that will force me to use the Shift keys correctly.
Is it possible for me to make the left hand shift key disable all other LH keys, and the right hand shift key disable all other RH keys, so that in order to get a !##$% or ASDF, etc, I am forced to use the RH shift key, while in order to get &*() or JKL:, etc, I am forced to use the LH shift key?
I have gotten in the habit of capitalizing EVERYTHING with the LH pinky, and it's starting to hurt. I need a profound and radical retraining!
There is a utility called Karabiner (KeyRemap4Macbook) which looks promising.
https://pqrs.org/osx/karabiner/index.html
Basically, I installed the latest Emacs 24.3 on my MAC OSX. I am completely new to Emacs.
Is there an equivalent of .vimrc in emacs? What is it called because I want to change the key bindings?
Problem 1: Instead of having Ctrl as C- key, I want to have CMD as C-. What is the code for this?
Problem 2: I notice that traditionally we have C- right arrow key as Slurp and C-left arrow key as barf. But on my mac, they don't work anymore and they are replaced by C-M-j and C-M-e. It took me a while to find out about this. I want to know why is it that a lot of the key bindings are so much different from Emacs on Windows? If I want the key bindings to be consistent with the ones on the Windows computer, is there a convenient way to do this or do I have to remap every single key manually?
The emacs equivalent of the .vimrc is the so called init file which can either be ~/.emacs, ~/_emacs, or ~/.emacs.d/init.el.
You can change keybindings using the define-key, local-set-key, and global-set-key commands, check the blog post Mastering Key Bindings in Emacs for a more complete introduction.
Basically, if you want to change the key Ctrl + f to open a file, you have to add
(global-set-key (kbd "C-f") 'find-file)
to your config.
You might want to check the SO question "Emacs on Mac OS X Leopard key bindings" for help on Problem 1 (using Command as Ctrl).
I'm not completely sure what your second problem is, but as far as I know, there is no way to tell emacs to gather system global keybindings and use them internally. Hence, if you OS has some set of keybindings which you'd like to mirror in emacs, you need to remap them manually.
Problem 2: I notice that traditionally we have C- right arrow key as Slurp and C-left arrow key as barf. But on my mac, they
don't work anymore
With emacsformacosx on OSX 10.10.5, I can slurp and barf with these key sequences:
C-) (slurp)
C-} (barf)
M-( (wrap)
Here's an example from "Clojure for the Brave and True":
Suppose you have this:
(+ 1 2 3 4)
and you want to get this:
(+ 1 (* 2 3) 4)
First, place the cursor("the point") here:
(+ 1 |2 3 4)
(The 2 will be highlighted.)
Then hit M-( (that's Option+Shift+9) to wrap the 2 in parentheses:
(+ 1 (|2) 3 4)
Then type the * and a space:
(+ 1 (* |2) 3 4)
To slurp the 3, hit C-) (that's Control+Shift+0):
(+ 1 (* |2 3) 4)
To barf the 3, place the cursor anywhere inside the inner parentheses and hit C-} (that's Control+Shift+] ):
(+ 1 (* 2) 3 4)
I lost my configuration or never had it.
I need to send shift+F1 and ctrl+F1, shift+F2 and ctrl+F2 and so on to the terminal since I'm connecting to a linux machine via ssh.
well, my current config is missing these string mappings as you can see in the image.
do you know what are the string mappings for those key combinations ?
thanks.
UPDATE:
in some stackexchange i found this command:
$>for x in {1..12}; do echo -n "F$x "; tput kf$x | cat -A; echo; done
can you help me to print the strings for shift + f1 ?
First: From this page http://invisible-island.net/xterm/xterm.faq.html, you will understand that shift-F1 maps to F11, shift-F2 maps to F12 and so on.(Search the page 'a summary of the keyboard mapping' without ', you will see the list).
Second: From this page http://aperiodic.net/phil/archives/Geekery/term-function-keys.html, you will know F1 or F11 or F20 maps to what string(at the bottom).
More to say:
If you want to send Shift-F1 to a program through Terminal, these will happen:
You hit Shift-F1, the Terminal will translate the Shift-F1 to a string sequence
The string sequence will be sent to the program
For example, you send a Shift-F1 to emacs through the Terminal,the Terminal translate it into string sequence and send the string sequence to emacs, emacs will recognise it as a key strokes then do something.
I'm not quite familiar about this, so this answer may be not right.
My MacBook has two enter keys.
One is return
Other is enter key placed right beside command key on right hand side.
I have recently started using Emacs24. I have noticed, whenever I am in viper-mode and I issue any command, for example
M-x toggle-viper-mode
Return key does not work. Instead I get an error.
Wrong type argument: characterp, return
I have to use fn+return or Ctrl+m or the enter.
If I disable viper-mode return works without any error.
I tried using a solution from Gnu Emacs mailing list archive but it didn't work.
(define-key function-key-map [return] [?\C-m])
How can I fix it so that return key works with commands in viper-mode too?
Update
The result of C-h k for return key when viper-mode is not loaded.
<return> runs the command autopair-newline, which is an interactive Lisp function in `autopair.el'.
It is bound to RET, <return>.
The result of C-h k for enter key when viper-mode is not loaded.
RET (translated from <kp-enter>) runs the command autopair-newline, which is an interactive Lisp function in `autopair.el'.
It is bound to RET, <return>
The result of C-h k for return key when viper-mode is loaded.
<return> runs the command autopair-newline, which is an interactive Lisp function in `autopair.el'.
It is bound to RET, <return>.
The result of C-h k for enter key when viper-mode is loaded.
RET (translated from <kp-enter>) runs the command autopair-newline, which is an interactive Lisp function in `autopair.el'.
It is bound to RET, <return>.
The problem is return key does not work in minibuffer when viper-mode is loaded, although the mappings are similar as you can see above.
So it appears that autopair-newline is not working correctly in viper-mode. The source for that function indicates is has some special handling of the "RET" keyboard binding.