Thursday, June 03, 2004

php-completion-table

I did solve the problem of getting the right table and solved a another problem. The right completion table is now computed by etags-tags-completion-buffer and the other problem was that I didn't join the right tables, not having thought about how it was done, the incorret code would do nothing because (mapatoms (lambda ...) nil) should do nothing.

(defun php-completion-table ()
  (or php-completion-table
      (let ((table (make-vector 1022 0))
            (php-completion-buffer (find-file-noselect php-completion-buffer-file))
            (my-tags-table (if (functionp 'etags-tags-completion-table)
                               (with-current-buffer (get-file-buffer tags-file-name)
                                 (etags-tags-completion-table))
                               nil)))
        (save-excursion
          (set-buffer php-completion-buffer)
          (goto-char (point-min))
          (while (re-search-forward
                  "^\\([-a-zA-Z0-9_.]+\\)\n"
                  nil t)
            (intern (buffer-substring (match-beginning 1) (match-end 1))
                    table)))
        (when my-tags-table
          ;; Combine the tables.
          (mapatoms (lambda (sym) (intern (symbol-name sym) table))
                    my-tags-table))
        (setq php-completion-table table))))

No comments: