* xyzzy lisp : へなちょこ補完その2
候補の絞込みしていなかったのを修正。
update : 2006-08-17 (Thu) 00:30:24
(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 abbrev case-fold match-table start matches) (let ((regexp (compile-regexp (concat (regexp-quote name) "\\(\\.\\|->\\)"))) (f (if *dabbrevs-case-fold* #'string-equal #'string=))) (save-excursion (goto-char (point-min)) (while (scan-buffer regexp :case-fold case-fold :tail t :left-bound :symbol :regexp t) (let ((from (point)) (text (buffer-substring (point) (save-excursion (skip-syntax-spec-forward "w_") (point))))) (unless (or (eql from start) (gethash text match-table) (and abbrev (not (funcall f abbrev text :end2 (length abbrev))))) (setf (gethash text match-table) from) (push text matches)))) 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 abbrev) (when (/= start end) (setq abbrev (buffer-substring start end)) (setf (gethash abbrev match-table) start)) (setq matches (dmc-find-all-candidates name abbrev *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 abbrev 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 "ないよん")))))
update : 2006-08-17 (Thu) 00:30:24