Skip to content

Instantly share code, notes, and snippets.

@youpy
Created April 20, 2012 05:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save youpy/2426196 to your computer and use it in GitHub Desktop.
Save youpy/2426196 to your computer and use it in GitHub Desktop.
;; 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