auto-complete.el の ac-source-words-in-buffer の候補に日本語を含む単語が含まれないようにする
(require 'cl) (require 'auto-complete) (defadvice ac-candidate-words-in-buffer (after remove-word-contain-japanese activate) (let ((contain-japanese (lambda (s) (string-match (rx (category japanese)) s)))) (setq ad-return-value (remove-if contain-japanese ad-return-value))))
以下、テスト
(defmacro my-with-php-buffer (s &rest body) (declare (indent 1)) `(with-temp-buffer (php-mode) (insert ,s) (goto-char (point-min)) (when (re-search-forward (rx "`!!'") nil t) (replace-match "")) (progn ,@body))) (expectations (expect '("aaああああ" "aabbcc") (my-with-php-buffer "aaああああ `!!' \n aabbcc" (let ((ac-target "aa") (ac-point (point)) (ac-limit 20)) (ad-disable-advice 'ac-candidate-words-in-buffer 'after 'remove-word-contain-japanese) (ad-activate 'ac-candidate-words-in-buffer) (ac-candidate-words-in-buffer)))) (expect '("aabbcc") (my-with-php-buffer "aaああああ `!!' \n aabbcc" (let ((ac-target "aa") (ac-point (point)) (ac-limit 20)) (ad-enable-advice 'ac-candidate-words-in-buffer 'after 'remove-word-contain-japanese) (ad-activate 'ac-candidate-words-in-buffer) (ac-candidate-words-in-buffer)))))
Executing expectations in nil... 2 expectations, 0 failures, 0 errors Expectations finished at Thu Aug 13 11:34:44 2009 1 :OK 2 :OK 2 expectations, 0 failures, 0 errors Expectations finished at Thu Aug 13 11:34:44 2009
php-modeなのは特に意味ないです。