* xyzzy lisp : へなちょこ補完
C/C++とかJavaとかのメンバをdabbrevライクに補完。
てきとー
TODO
update : 2006-08-16 (Wed) 01:27:47
てきとー
(defun dmc-instance-name () (save-excursion (let ((start (progn (skip-syntax-spec-backward "w_") (point)))) (cond ((char= #\. (char-before start)) (buffer-substring (progn (forward-char -1) (skip-syntax-spec-backward "w_") (point)) (1- start))) ((and (char= #\> (char-before start)) (char= #\- (char-before (1- start)))) (buffer-substring (progn (forward-char -2) (skip-syntax-spec-backward "w_") (point)) (- start 2))) (t nil))))) (defun dmc-find-all-candidates (name case-fold match-table start matches) (let ((no-dup nil) (regexp (compile-regexp (concat (regexp-quote name) "\\(\\.\\|->\\)\\([A-Za-z_][0-9A-Za-z_]+\\)")))) (save-excursion (goto-char (point-min)) (while (scan-buffer regexp :case-fold case-fold :no-dup no-dup :left-bound :symbol :regexp t) (let ((from (match-beginning 2)) (text (match-string 2))) (unless (or (eql from start) (gethash text match-table)) (setf (gethash text match-table) from) (push text matches))) (setq no-dup t)) matches))) (defun dmc-popup () (interactive "*") (let ((end (point)) (start (save-excursion (skip-syntax-spec-backward "w_") (point))) (name (dmc-instance-name))) (unless name (return-from dmc-popup nil)) (let ((match-table (make-hash-table :test (if *dabbrevs-case-fold* #'equalp #'equal))) matches) (when (/= start end) (setf (gethash (buffer-substring start end) match-table) start)) (setq matches (dmc-find-all-candidates name *dabbrevs-case-fold* match-table start nil)) (unless *dabbrev-popup-this-buffer-only* (let ((curbuf (selected-buffer)) (case-fold *dabbrevs-case-fold*) (syntax-table (syntax-table))) (with-set-buffer (with-interval-message (300) (save-excursion (dolist (buffer (buffer-list)) (unless (eq buffer curbuf) (message "Searching (~A)..." (buffer-name buffer)) (set-buffer buffer) (save-excursion (let ((osyntax-table (syntax-table))) (unwind-protect (progn (use-syntax-table syntax-table nil t) (setq matches (dmc-find-all-candidates name case-fold match-table nil matches))) (use-syntax-table osyntax-table nil t)))))))))) (clear-message)) (if matches (ed::popup-completion-list (sort matches #'string-lessp) start end) (plain-error "ないよん")))))
TODO
- 探すときはちゃんとシンタックステーブルをみるように
- 複雑な状況に対応
update : 2006-08-16 (Wed) 01:27:47