A control-modified letter character still results in a character, and hence character translation works for those; but most other modified keys do not result in a character.
Both are represented as integers, but there's a limit to the ints which are valid for characterp. See the following for details:
Key naming is messier than it ought to be. When you press the Tab key while the Shift modifier is held down, your operating system tells Emacs that you've pressed the ISO_Left_Tab key. I guess that you're using an X11-based system (I think that's the only platform with this particular key name) and you're using a standard XKB layout which specifies (e.g. ...
You can simply map the keys - and _ to do what you want in python mode:
(defun insert-underscore ()
(defun insert-hyphen ()
"You know it!"
(defun python-remap-hyphen-and-underscore ()
(define-key python-mode-map "-" 'insert-underscore)
(define-key python-mode-map "_" '...
Following from the excellent comment by @daveloyall, here's the key
quote from the Commentary of vi-dot.el by Will Mengarini (circa
March 1998, before vi-dot was renamed to repeat). This is from
Since the whole point of vi-dot is to let you repeat commands that are
bound to multiple keystrokes by leaning on a single key, ...
You can use the following command which is independent of the used completion framework because it uses completing-read:
(defun execute-binding+ (arg)
"Completing read a command and execute it.
With ARG non-nil only present commands without a key binding
otherwise only those which have one."
(let ((cmd (completing-read
Not too sure what you're asking. But it sounds like the answer is to bind your key in the major mode's keymap, not in the global-map.
For example, if the keymap for your Python mode is python-mode-map then do this:
(define-key python-mode-map (kbd "C-x C-e") 'python-shell-send-region)
You need to delete the remap alist entry from ido-minor-mode-map-entry. To do that, run the function below once after enabling ido-mode.
(defun disable-ido-find-file-remap ()
(dolist (elt ido-minor-mode-map-entry)
(when (and (listp elt) (eq (car elt) 'remap))
(setf (cddr elt) (assq-delete-all 'find-file (cddr elt))))))
Use define-prefix-command to define a named prefix
Bind C-c x to that prefix command
Bind s and r in the prefix command keymap
When you type C-c, which-key will then show you your chosen prefix name instead of just "prefix", which gives you better context for which commands you can expect to be bound underneath it.
Obviously you can type x (with or without ...
After using emacs for almost 10 years, I think the best way to avoid emacs pinky is to remember:
Bind the keys such that you never press two or more keys at the same time with one hand!
This completely eliminates any hand problems I used to have.
For example, C-x should always be pressed like this: C (right hand) - x(left hand)
Using space or caplock to ...