diff --git a/php-mode.el b/php-mode.el index ff9fefd0..b4084114 100644 --- a/php-mode.el +++ b/php-mode.el @@ -1346,11 +1346,12 @@ for \\[find-tag] (which see)." (delete-region beg (point)) (insert completion)) (t - (message "Making completion list...") - (with-output-to-temp-buffer "*Completions*" - (display-completion-list - (all-completions pattern php-functions))) - (message "Making completion list...%s" "done"))))))) + (let ((selected (completing-read + "Select completion: " + (all-completions pattern php-functions) + nil t pattern))) + (delete-region beg (point)) + (insert selected)))))))) (defun php-completion-table () "Build variable `php-completion-table' on demand. @@ -1367,7 +1368,8 @@ current `tags-file-name'." (cond ((and (not (string= "" php-completion-file)) (file-readable-p php-completion-file)) (php-build-table-from-file php-completion-file)) - (php-manual-path + ((and (not (string= "" php-manual-path)) + (file-directory-p php-manual-path)) (php-build-table-from-path php-manual-path)) (t nil)))) (unless (or php-table tags-table) @@ -1376,8 +1378,10 @@ current `tags-file-name'." "`php-completion-file' or `php-manual-path' set"))) (when tags-table ;; Combine the tables. - (mapatoms (lambda (sym) (intern (symbol-name sym) php-table)) - tags-table)) + (if (obarrayp tags-table) + (mapatoms (lambda (sym) (intern (symbol-name sym) php-table)) + tags-table) + (setq php-table (append tags-table php-table)))) (setq php-completion-table php-table)))) (defun php-build-table-from-file (filename) @@ -1394,19 +1398,11 @@ current `tags-file-name'." table)) (defun php-build-table-from-path (path) - (let ((table (make-vector 1022 0)) - (files (directory-files - path - nil - "^function\\..+\\.html$"))) - (mapc (lambda (file) - (string-match "\\.\\([-a-zA-Z_0-9]+\\)\\.html$" file) - (intern - (replace-regexp-in-string - "-" "_" (substring file (match-beginning 1) (match-end 1)) t) - table)) - files) - table)) + "Return list of PHP function name from `PATH' directory." + (cl-loop for file in (directory-files path nil "^function\\..+\\.html$") + if (string-match "\\.\\([-a-zA-Z_0-9]+\\)\\.html$" file) + collect (replace-regexp-in-string + "-" "_" (substring file (match-beginning 1) (match-end 1)) t))) ;; Find the pattern we want to complete ;; find-tag-default from GNU Emacs etags.el