Created
April 20, 2012 05:13
-
-
Save youpy/2426196 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Google Suggest で補完 | |
(defun google-suggest () | |
(setq ac-source-mysource1-point ac-point) | |
(let (result buf (case-fold-search nil)) | |
(setq buf (get-buffer-create "*google-suggest*")) | |
(if (string-match "^[A-Z]" ac-prefix) | |
(with-current-buffer buf | |
(erase-buffer) | |
;; https://gist.github.com/2425165 | |
(call-process "/Users/youpy/work/google_suggest.rb" nil buf nil ac-prefix) | |
(setq result (mapcar (lambda (str) | |
(concat ac-prefix ":" str)) | |
(split-string (buffer-string))))) | |
(append result (list ac-prefix)) | |
('())))) | |
(defun google-suggest-delte-prefix() | |
(let (cur) | |
(setq cur (point)) | |
(goto-char ac-source-mysource1-point) | |
(search-forward ":" nil t) | |
(goto-char cur) | |
(delete-region ac-source-mysource1-point (match-end 0)))) | |
(defvar ac-source-mysource1-point) | |
(defvar ac-source-mysource1 | |
'((candidates . (google-suggest)) | |
;;(cache) | |
(prefix . "[^a-z]\\(.*\\)") | |
(symbol . "g") | |
(action . google-suggest-delte-prefix))) | |
;; 全てのバッファの`ac-sources`の末尾に辞書情報源を追加 | |
(defun ac-common-setup () | |
(setq ac-sources (append ac-sources '(ac-source-mysource1)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment