Is there a way to make Emacs' auto-complete package not trigger menu completion on return key but instead on some other key-combination say C-Return? For a fast typist having it bound to return often causes non-deterministic behaviour of return. This because its behaviour now depends on how fast I type the previous characters.
See https://github.com/auto-complete/auto-complete.
This code should do exactly what you want
(define-key ac-completing-map (kbd "RET") nil)
(define-key ac-completing-map [return] nil)
(define-key ac-completing-map [(control return)] 'ac-complete)
I didn't try it on the terminal as I'm on windows at the moment.
Related
Up and down arrow keys work but I was wondering if there was another option on the home row. If not, how do I set it to something else? (emacs noob)
emacs-jedi uses auto-complete under the hood
These are also supported (besides the default arrows):
M-n Next item
M-p Previous item
If you wanted to change them you could do something like this:
(define-key ac-completing-map (kbd "C-c j") 'ac-next)
(define-key ac-completing-map (kbd "C-c k") 'ac-previous)
I just updated the emacs package elpy, and it's set the following keybindings:
<M-down> elpy-nav-move-iblock-down
<M-left> elpy-nav-move-iblock-left
<M-right> elpy-nav-move-iblock-right
<M-up> elpy-nav-move-iblock-up
I usually have these keys bound to windmove-<direction> and I think this is a real pain. Following this github issue, I tried:
(load "python")
(define-key elpy-mode-map [remap windmove-left] nil)
(define-key elpy-mode-map [remap windmove-right] nil)
(define-key elpy-mode-map [remap windmove-down] nil)
(define-key elpy-mode-map [remap windmove-up] nil)
in my .emacs, but no luck. How can I stop elpy-mode from overriding these keys?
You can reset the offending mappings to nil in one fell swoop in the following way. UPDATE. As per lunaryorn's comment, the file parameter should be "elpy" rather than "python", which is now reflected in the answer.
(eval-after-load "elpy"
'(cl-dolist (key '("M-<up>" "M-<down>" "M-<left>" "M-<right>"))
(define-key elpy-mode-map (kbd key) nil)))
If you're not keen on the dolist, you could wrap four calls to define-key in a progn within the eval-after-load.
I have this little problem, I have some key bindings like so C-. C-x or C-. C-m. After I activate the flyspell-mode, I cannot use these commands. In my .emacs file I have the next 2 lines before
(global-unset-key (kbd "C-."))
(define-key (current-global-map) (kbd "C-.") nil)
(global-set-key (kbd "C-. C-l") 'global-linum-mode)
Then, my C-. C-l works, but it does not when the flyspell-mode is activated. The command bound to C-. is flyspell-auto-correct-word. I tried to deactivate it as follows:
;; first try
(defun flyspell-auto-correct-word-disable() (define-key (current-local-map) (kbd "C-.") nil))
(add-hook 'flyspell-mode-hook 'flyspell-auto-correct-word-disable)
;; second try
(define-key (current-global-map) [remap flyspell-auto-correct-word] nil)
None of the tries work, what can I do? I tried in Emacs 23 and 24 and I have the same issue.
What about:
(eval-after-load "flyspell"
'(define-key flyspell-mode-map (kbd "C-.") nil))
Your first solution is almost correct, but you have to remember that the current local map is set up by the major mode, not minor modes. The best option you have it to directly access flyspell-mode-map and modify it (another option would be to find it in minor-mode-map-alist but I think it would be needlessly complicated).
Also, I prefer putting such mode-specific settings within eval-after-load (which means they will be evaluated once) rather than in a hook (in which case the settings are evaluated multiple times: each time one buffer activates flyspell-mode). But this is a matter of preference and either way is fine.
I have two problems which are somewhat related I believe:
1) In IDO I'd like to change ido-restrict-to-matches to samething else than C-SPC or C-#. Unfortunately I do not know how to tell emacs that I want a different shortcut (say C-0).
2) I'd like to protect my C-; but whenever flyspell-mode is running it overtakes C-;. My definition is in .emacs as:
(global-set-key (kbd "C-;") 'mark-paragraph)
but apparently flyspell overwrites this... (although even then, if I look in the help M-h k C-; it does say mark-paragraph)
Could somebody please tell me how to bind/unbind keys in these conditions? It has to work without modifying ido.el and flyspell.el and re-building, right?
Thanks very much!
Flyspell provides a customization for the C-; binding, so you can either M-x customize RET flyspell-auto-correct-binding RET or put something like this in your ~/.emacs:
(setq flyspell-auto-correct-binding (kbd "C-~")) ; or a binding of your choice
As for ido, your question is slightly confusing, because it implies there are times when you're using ido outside the minibuffer...
The documentation in ido.el contains the following advice:
;; To modify the keybindings, use the ido-setup-hook. For example:
;;(add-hook 'ido-setup-hook 'ido-my-keys)
;;
;;(defun ido-my-keys ()
;; "Add my keybindings for ido."
;; (define-key ido-completion-map " " 'ido-next-match)
;; )
Using that knowledge, you can change the key bindings like this in your own "ido-my-keys" function:
(define-key ido-completion-map (kbd "C-SPC") nil)
(define-key ido-completion-map (kbd "C-#") nil)
(define-key ido-completion-map (kbd "C-0") 'ido-restrict-to-matches)
There's an additional ido hook specifically for the minibuffer, too, but it's not clear why you would need that: ido-minibuffer-setup-hook.
This is driving me nuts.
I've bound M-e to some useful stuff, but cc-mode is hogging it. I've tried adding c-mode-hooks, c-mode-commons and I've tried eval-after-load on c-mode, ie
(eval-after-load "c-mode"
'(define-key c-mode-map (kbd "M-e") nil))
but whenever I open a C file, M-e is still bound to c-end-of-statement. How do I disable it and replace it with my own bindings?
Maybe you could try this
(define-key c-mode-map [remap c-end-of-statement] 'your-useful-stuff)
or
(define-key cc-mode-map [remap c-end-of-statement] 'your-useful-stuff)