8

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. (characterp ?\C-q) t (characterp ?\M-q) nil Both are represented as integers, but there's a limit to the ints which are valid for characterp. See the following for details: C-hig (...


4

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. ...


3

You can simply map the keys - and _ to do what you want in python mode: (defun insert-underscore () "Guess what!" (interactive) (insert "_")) (defun insert-hyphen () "You know it!" (interactive) (insert "-")) (defun python-remap-hyphen-and-underscore () (define-key python-mode-map "-" 'insert-underscore) (define-key python-mode-map "_" '...


3

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 lisp/repeat.el.~0a8cbe6881^~. 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, ...


2

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." (interactive "P") (let ((cmd (completing-read ...


1

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)


1

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 () (interactive) (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)))))) I ...


1

you can achieve this with evil-swap-keys.el (which is not tied to evil): (global-evil-swap-keys-mode) (add-hook 'python-mode-hook #'evil-swap-keys-swap-underscore-dash)


1

What I actually implemented is a modification of @JeanPierre's solution: (defun my-remap-dash-and-underscore () (interactive) (define-key python-mode-map "-" #'(lambda () (interactive) (insert "_"))) (define-key python-mode-map "_" #'(lambda () (interactive) (insert "-")))) (defun my-undo-remap-dash-and-underscore () (interactive) (define-key ...


1

When you say X, are you referring to the help output such as X - read only in buffer X. There X is referring to the Ediff buffer names, for example A or B.


1

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 ...


1

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 ...


Only top voted, non community-wiki answers of a minimum length are eligible