自動補全

semantic 的 navigation + 基於 Clang 的 auto complete 比 semantic 的 補全好用.


另外, 補全時 : 還是和 yassnippet 衝突 ( yas-expand-from-trigger-key ) , capitaomorte 的 issue list 中 也表示 暫時無能爲力.

雖然會自動彈出 imenu , 但用起來還是不順手. 可以考慮改成別的 key sequence .


### 工作流程

auto-complete 是 自動開啓的 , 輸入 n 個字符後 , 跳出 candidate的 imenu 讓你選擇 , 在 TAB 選擇了某個 candidate 之後 , 就 RET 來 ac-complete :

根據 candidate 的 數量  , TAB 會 呈現不同的功能.

  • Case that only one candidate remains

    If only on candidate remains, the candidate will be used to complete. 只有一個candidate 就是 ac-complete

  • Case that there is common part among candidates 多個 candidate , 補全 common part 

    For example, if all candidates start with "set", it means they have common part "set". So TAB completes "set" at first.

  • Otherwise, select candidates in cycle by typing TAB. 否則, 循環 多個 candidate .

### 一些設置

AC user manual 的 7.Tips 中 提到了一些. 其中 :

ac-dwin , ac-use-quick-help, ac-show-menu-immediately-on-auto-complete 和 ac-expand-on-auto-complete 都是實用的設置 .

然而 , 看了一下src,這些變量都是 defcustom option t , 也就是 默認打開. 所以, 就不再配置了. ( defcustom option standard doc [keyword value]... ).

至於 trigger key ( 開始 ac-expand ) , 只有當 ac-auto-start  爲 nil 時 纔有效 , 而 ac-auto-start  默認是打開的. trigger key 的 設置 於我,沒有意義.


另外, ac-sources 也是很重要的設置 . 具體參考 manual .

但是,我的host 上 ac-source-semantic 有 bug .


### 有意思的特性 ,

1. auto-complete 的 fuzzy matching 


### 做的幾個修改:

(1) 把 semantic 添加 include 文件的步驟作爲 hook 的一部分 , 放到 my-variables.el 中去 .

(2) 取消了 ac-clang-config , 放到 my-variables.el 中去 ; 講 屬於 auto-complete.el 的 配置 全部放入到 auto-complete-init.el , 這樣 , 這兩個措施使得 auto-complete-config.el 更加乾淨.


### more advanced : 

ref : http://www.emacswiki.org/emacs/AutoCompleteSources 給出了 python , semantic 等的配置.

http://cx4a.org/software/auto-complete/manual.html#Filtering_Completion_Candidates AC user manual 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章