public
Created

  • Download Gist
auto-complete-google-suggest.el
Emacs Lisp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
;; 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))))

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.