(途中経過)anythingで関数の補完

一応動いた。中のコードの意味とかよく分からないまま作っているので変なところがある気がします。*1

使用しているもの

(require 'gca)
(require 'anything-dabbrev-expand)

(unless (boundp 'anything-initial-input)
  (defvar anything-initial-input ""))

(defvar anything-gca-completion-source nil)

(defun anything-gca-insert-word (word)
  (delete-backward-char (length anything-initial-input))
  (insert word))
  
(defvar anything-gca-completion-c-source
      '((name . "Complete Word")
	(candidates . anything-gca-completion-source)
	(action . (("Insert" . anything-gca-insert-word)	
		   ("Show Info" . (lambda (topic)
				    (or (gca-info-topic topic)
					(error "No topic: %s" topic))))
		   ))))

(defvar anything-gca-dabbrev-c-source
  '((name . "dabbrev")
    (candidates . anything-dabbrev-candidates) 
    (action . (("Insert" . anything-gca-insert-word)))
    (volatile)))

(defun anything-gca-completion-current-word () (interactive)
  (let ((anything-candidate-number-limit anything-dabbrev-expand-candidate-number-limit)
        (anything-idle-delay anything-dabbrev-idle-delay)
        (anything-sources (list anything-gca-completion-c-source anything-gca-dabbrev-c-source)))
    (let* ((end (point))
	   (anything-initial-input
	    (save-excursion
	      (gca-backward-sexp)
	      (buffer-substring-no-properties (point) end))))
      (setq anything-dabbrev-candidates (anything-dabbrev-get-candidates anything-initial-input))
	(anything))))
;; ;;dabbrevを使わない場合
;; (defun anything-gca-completion-current-word () (interactive)
;;   (let* ((anything-sources (list anything-gca-completion-c-source))
;; 	 (end (point))
;; 	   (anything-initial-input
;; 	    (save-excursion
;; 	      (gca-backward-sexp)
;; 	      (buffer-substring-no-properties (point) end))))
;; 	(anything)))


(add-hook 'scheme-mode-hook
(lambda ()
  ;;anything用のsourceの作成
  (setq anything-gca-completion-source (mapcar #'car (gca-complete-alist "")))
  ;;key-bind
 (define-key scheme-mode-map "\C-c\C-." 'anything-gca-completion-current-word)
)

*1:特にdabbrevと組み合わせた部分とか