English 中文(简体)
Mamacs 自动完成的钥匙装订不起作用
原标题:emacs auto-complete key binding didn t work

I downloaded an emacs configure file from here: https://github.com/redguardtoo/emacs.d
I install it and learning to use emacs.
When used YASnippet, I found auto-complete s key binding didn t work.
When writing C code, type "inc" and then press TAB, emacs pop up a menu to choose a snippet.
It works only when press uparrow and downarrow if I want to choose the a snippet, C-n and C-p didn t works.
I found that the emacs configure file has binding C-n and C-p. Here is init-auto-complete.el

(require  auto-complete)
(require  auto-complete-config)
(global-auto-complete-mode t)
(setq ac-auto-start nil)
(setq ac-dwim nil) ; To get pop-ups with docs even if a word is uniquely completed
(define-key ac-completing-map (kbd "C-n")  ac-next)
(define-key ac-completing-map (kbd "C-p")  ac-previous)

;;----------------------------------------------------------------------------
;; Use Emacs  built-in TAB completion hooks to trigger AC (Emacs >= 23.2)
;;----------------------------------------------------------------------------
(setq tab-always-indent  complete)  ;; use  complete when auto-complete is disabled
(add-to-list  completion-styles  initials t)

;; hook AC into completion-at-point
(defun set-auto-complete-as-completion-at-point-function ()
  (setq completion-at-point-functions  (auto-complete)))
(add-hook  auto-complete-mode-hook  set-auto-complete-as-completion-at-point-function)


(set-default  ac-sources
              (ac-source-dictionary
               ac-source-words-in-buffer
               ac-source-words-in-same-mode-buffers
               ac-source-words-in-all-buffer))

(dolist (mode  (magit-log-edit-mode log-edit-mode org-mode text-mode haml-mode
                sass-mode yaml-mode csv-mode espresso-mode haskell-mode
                html-mode nxml-mode sh-mode smarty-mode clojure-mode
                lisp-mode textile-mode markdown-mode tuareg-mode
                js3-mode css-mode less-css-mode))
  (add-to-list  ac-modes mode))


;; Exclude very large buffers from dabbrev
(defun sanityinc/dabbrev-friend-buffer (other-buffer)
  (< (buffer-size other-buffer) (* 1 1024 1024)))

(setq dabbrev-friend-buffer-function  sanityinc/dabbrev-friend-buffer)


(provide  init-auto-complete)

I think this two line should works but it didn t. That draws me crazy.
(define-key ac-completing-map (kbd "C-n") ac-next)
(define-key ac-completing-map (kbd "C-p") ac-previous)

我怎样才能把C -n和C -p绑在一起 来选择弹出菜单中的片段?

问题回答

我在http://www.emacswiki.org/emacs/auto-complete.el 中找到,http://www.emacswiki.org/emacs/aut-complete.el/a。

;; Use C-n/C-p to select candidates
;; --------------------------------
;;
;; Add following code to your .emacs.
;; 
;;     (define-key ac-complete-mode-map "C-n"  ac-next)
;;     (define-key ac-complete-mode-map "C-p"  ac-previous)

这对我管用

(define-key ac-menu-map (kbd "C-n")  ac-next)
(define-key ac-menu-map (kbd "C-p")  ac-previous)

上述代码如何





相关问题
suppress additional braces in emacs electric mode

I started using ruby-electric-mode. I like it except that I am used to closing open brackets myself (the other pairing are still useful to me). How can I make emacs suppress additional brackets when ...

Setting up an emacs environment in windows?

I am currently constrained to a windows dev box and I want to migrate my projects from eclipse to emacs. What are some good references on setting up an emacs dev environment for windows? Anything ...

Emacs Setting which-function-mode

I would like to have which-function-mode on by default when I open up Emacs. I ve added the following lines to my .emacs file. (setq which-func-mode t) (setq which-function-mode t) When I open ...

Enabling go mode for emacs

I don t seem to be able to enable a go mode for emacs. C mode doesn t work without semicolons. The best I have found is the JavaScript mode by Karl Landstrom, since JavaScript also doesn t require ...

Custom Emacs key bindings are not working

The key bindings I ve defined in my .emacs file aren t working. Here s the file: ;init modes (menu-bar-mode 0) (tool-bar-mode 0) (cua-mode) (column-number-mode) (fset perl-mode cperl-mode) (cperl-...

eval during emacs lisp macro expansion

How can I fix the simple macro foo in (elisp)Eval During Expansion? None of the followings work: (defmacro foo1 (a) `(setq (eval ,a) t)) (defmacro foo2 (a) `(setq ,(eval a) t)) (defmacro foo3 (...

Get local cvs comment history when committing file/s in emacs

I often commit files with similar cvs comment but not in a single operation. I would like to able to bring up previous comments I ve used in a previous commit when I am in the process of writing a ...

热门标签