Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PHP completion #454

Merged
merged 4 commits into from
Apr 8, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 17 additions & 21 deletions php-mode.el
Original file line number Diff line number Diff line change
@@ -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