I'm trying to change the first keys row functionality. I want to press
a key (for instance: the '8' key) and emacs writte the symbol that
result of typing Shift+key (for instance: the '(' symbol ).
But I want to be able to writte numbers with the numeric keyboard.
To the moment I have not esitate so when I change the key '8' (for
instance) the other '8' key (from the numeric keyboard) is changed
too.
Does someone of you have the answer?
Thanks so much.
César BCN
cesarTMP (AT) gmail (DOT) com
I tried this for a few weeks sometimes in 2007 and find it not
satisfactory, partly because in other apps you then have to switch
your mental mode. A solution is to do it system-wide, but then when
you use other computers (library, coworker, etc), its still a problem.
Also, system-wide keymap change using default system technology do not
work satisfactorily under OSX for some technical complication reasons.
Namely, it is not possible to change certain basic keymaps. (in OS X
for example, certain key combination event is not seen by the system,
but other even/system take precedence)
(For technical detail, see bottom of:
“Mac OS X Keybinding and Unicode Tips” at http://xahlee.org/emacs/osx_keybinding.html
)
A solution is to use 3rd-party software that actually modify the OS
core in some way.
I haven't tried to do extensive keymapping under unix (xmodmap) or
Windows, but i'm pretty sure the situation is similar.
-------------------
But to do what you want, see:
How to Define Keyboard Shortcuts in Emacs
http://xahlee.org/emacs/keyboard_shortcuts.html
basically like this:
(global-set-key (kbd "1") (lambda () (insert "!")))
...
(global-set-key (kbd "<kp-1>") (lambda () (insert "1")))
...
again there are complications. Some mode will actually not respect it.
(a solution is either to modify each mode's keymap or use some other
complicated elisp mechanism to rebind or swap keys) Also, NeXT Emacs
(aka “Emacs.app”) on the Mac has a bug that it doesn't support any
keybindings using the numerical keypad.
In summary, my experiences is that when you modify keybinding in some
unusual way (such as in your case), you run into other misc problems,
limitations, complications,... so at the end i find it not worthwhile.
Another suggestion is to type numbers by turning the keys under your
right hand into a keypad, with a modifier down. (similar to notebook
computer keyboards) I've tried this scheme by using Ctrl+Shift as the
modifier key... but again after a few weeks didn't find this
satisfactory.
---------------------
Personally, regardless of typing in emacs or elsewhere, i've developed
a habit in the past maybe 4 years to always type the num keys using
the top row (as opposed to the keypad). The keypad i used as special
buttons bind to emacs functions. (i.e. like giving you extra 10 or so
function keys)
To insert any matching pairs such as (), [], {}, “”,«»,「」etc, i've
bound them to hyper key with keys right under my right hand's home
row. (and cursor movement keys are similar but bound to meta) Example:
;; make cursor movement keys under right hand's home-row.
(global-set-key (kbd "M-j") 'backward-char) ; was indent-new-comment-
line
(global-set-key (kbd "M-l") 'forward-char) ; was downcase-word
(global-set-key (kbd "M-i") 'previous-line) ; was tab-to-tab-stop
(global-set-key (kbd "M-k") 'next-line) ; was kill-sentence
(global-set-key (kbd "M-SPC") 'set-mark-command) ; was just-one-space
;; type parens in pairs with Hyper and right hands's home-row
(global-set-key (kbd "H-j") (lambda () (interactive) (insert "{}")
(backward-char 1)))
(global-set-key (kbd "H-k") (lambda () (interactive) (insert "()")
(backward-char 1)))
(global-set-key (kbd "H-l") (lambda () (interactive) (insert "[]")
(backward-char 1)))
Also, i've using dvorak since about 1993. Also, my emacs shortcuts set
is extensively modified. See:
A Ergonomic Keyboard Shortcut Layout For Emacs
http://xahlee.org/emacs/ergonomic_emacs_keybinding.html
Xah
x...@xahlee.org
∑ http://xahlee.org/
☄
1. Get a piece of paper(ya, like the white crinkly stuff you make spitballs with).
2. Get a pencil or pen, or prick yourself with a needle, or some other writing utensil.
3. Open up a terminal emulator in a window manager that's sane.
4. Type 'xev'.
5. Type '1', write down the KEYCODE(for '1' this is 10), that xev printed into the terminal emulator window, onto your piece of paper. Now press shift-1, and write down the KEYSYM on your sheet, for shift-1 this is exclam.
REPEAT for all numbers.
6. Kill the xev window.
7. Type "cd ~/; nano .xmodmap-numbershifter RET" into the terminal emulator window.
8. Type "keycode KEYCODE = KEYSYM NUMBER RET" into your terminal emulator window.
EXAMPLE: keycode 10 = exclam 1
REPEAT for the rest of your keys.
9. Save the file in nano.
10. Type xmodmap .xmodmap-numbershifter
11. Press some numbers on both the top and the keypad, using shift on the top as well to test it.
12. Type "nano .xsession RET"
13. Type "xmodmap /home/NAME/.xmodmap-numbershifter RET"
14. Restart X
15. Repeat step 11
OPTIONAL
16. If the key mappings went away... You should try steps 12 and 13 on .xinitrc instead of .xsession...
Hope this helps.
Timothy
Rupert