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绑在一起 来选择弹出菜单中的片段?