New answers tagged

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)


0

You can use key-translation-map: (define-key key-translation-map (kbd "M-q") (kbd "M-x")) (define-key key-translation-map (kbd "M-x") (kbd "M-q"))


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)


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


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


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


0

This appears to be a bug in emacs; M-{ should just automatically work, if we take the manual at face value. As a workaround, I took an [answer to a similar question](source: http://emacs.stackexchange.com/a/22166/93) and modified it: (global-set-key (kbd "M-[") 'backward-paragraph) (global-set-key (kbd "M-{") 'backward-paragraph-with-shift-select) (global-...


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 "_" '...


0

You need to define a key in the major mode map. It (define-key dired-mode-map (kbd "C-x C-q") #'dired-toggle-read-only) more examples and more information at various websites and the manual: http://ergoemacs.org/emacs/emacs_set_keys_for_major_mode.html https://www.gnu.org/software/emacs/manual/html_node/efaq/Binding-keys-to-commands.html


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


0

This is not a very elegant solution (since it uses macros instead of functions) and it does not answer how to jump to any buffer quickly, but only how to jump to buffers used recently. But it works very well for me: I have a series of macros using ido-switch-buffer to jump to the previous buffer, the buffer before that, the buffer before that, etc. And I ...


0

Have you tried using customize-group ns to interactively modify the keys to be as you want them? It's not possible change the role of FN in application settings, but Command and Control can be switched. Typically, one would set Ns Command Modifier to Meta, but to accomplish what you want, you could set it to Control and then set Ns Control Modifier to Meta. ...


0

Left alt (i.e., meta key in Emacs config) key can be pressed easily using your left thumb, and you can rebind all of your common functions (e.g., cursor movements) to meta-key-based shortcuts instead of the original ctrl-key-based shortcuts. I do that in my init.el file.


0

This problem is actually solved in year 2012 when EVIL is mature. Simple solution, Please use Spacemacs+Evil. Vim key bindings make sure you type less keys when dealing with text. Use space as leader key so you don't need move finger from its default position too frequently. In other words, if you don't use key like Ctrl/Alt/Shift/Win/Cmd/Esc, you solve ...


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


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

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.


0

From the documentation of previous-line (C-h f previous-line RET): This function is for interactive use only; in Lisp code use `forward-line' with negative argument instead. ... If the variable ‘line-move-visual’ is non-nil, this command moves by display lines. Otherwise, it moves by buffer lines, ... So the problem was trying to move over buffer lines ...


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


Top 50 recent answers are included