开发者

Setting shortcuts keys in specific modes in Emacs (e.g. ido)

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜