Skip to content

Commit 1c3c41c

Browse files
committed
Merge branch 'release/2.0.0'
2 parents dfb5464 + 00cf842 commit 1c3c41c

File tree

5 files changed

+67
-62
lines changed

5 files changed

+67
-62
lines changed

Cask

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
(package-file "php-extras.el")
22

33
(source marmalade)
4-
5-
(development
6-
(depends-on "php-mode" "1.5.0"))

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
CASK?=cask
44
EMACS?=emacs
5-
TAR?=bsdtar
5+
TAR?=COPYFILE_DISABLE=1 bsdtar
66
PANDOC?=pandoc --atx-headers
77

88
VERSION?=$(shell $(CASK) version)
@@ -19,6 +19,7 @@ README: README.md
1919
$(PANDOC) -t plain -o $@ $^
2020

2121
php-extras-eldoc-functions.el: php-extras-gen-eldoc.el
22+
$(CASK) install
2223
$(CASK) exec $(EMACS) --batch -l php-extras.el -l php-extras-gen-eldoc.el -f php-extras-generate-eldoc-1
2324

2425
$(ARCHIVE_NAME)-pkg.el: $(ARCHIVE_NAME).el

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ to look up the function definition.
4343
`php-extras` provides such a function for looking up all the core PHP
4444
functions.
4545

46-
The function `php-extras-generate-eldoc` will download the PHP
47-
function summary
48-
[PHP Subversion repository](http://svn.php.net/repository/phpdoc/doc-base/trunk/funcsummary.txt)
46+
The function `php-extras-generate-eldoc` will download the
47+
[PHP function list](http://doc.php.net/downloads/json/php_manual_en.json)
4948
and extract the function definitions (slow) and store them in a hash
5049
table on disk for you.
5150

52-
If you install `php-extras` as an ELPA package the hash table is
53-
already generated for you.
51+
If you install `php-extras` as an ELPA package from
52+
[Marmalade](http://marmalade-repo.org/packages/php-extras) the hash
53+
table is already generated for you.
5454

5555

5656
## Auto complete source for PHP functions based

php-extras-gen-eldoc.el

Lines changed: 51 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
;;; php-extras-gen-eldoc.el --- Extra features for `php-mode'
22

3-
;; Copyright (C) 2012, 2013 Arne Jørgensen
3+
;; Copyright (C) 2012, 2013, 2014 Arne Jørgensen
44

55
;; Author: Arne Jørgensen <[email protected]>
66

@@ -31,14 +31,13 @@
3131

3232
(require 'php-mode)
3333
(require 'php-extras)
34+
(require 'json)
3435

3536

3637

37-
(defvar php-extras-gen-eldoc-temp-methodname nil)
38-
39-
(defvar php-extras-php-funcsummary-url
40-
"http://svn.php.net/repository/phpdoc/doc-base/trunk/funcsummary.txt"
41-
"URL of the funcsummary.txt list of PHP functions.")
38+
(defvar php-extras-php-doc-url
39+
"http://doc.php.net/downloads/json/php_manual_en.json"
40+
"URL of the JSON list of PHP functions.")
4241

4342

4443

@@ -50,52 +49,55 @@
5049
(php-extras-generate-eldoc-1 t)))
5150

5251
(defun php-extras-generate-eldoc-1 (&optional byte-compile)
53-
(let ((function-arguments-temp (make-hash-table
54-
:size 5000
55-
:rehash-threshold 1.0
56-
:rehash-size 100
57-
:test 'equal)))
58-
(with-temp-buffer
59-
(url-insert-file-contents php-extras-php-funcsummary-url)
60-
(goto-char (point-min))
61-
(let ((line-count (count-lines (point-min) (point-max))))
62-
(with-syntax-table php-mode-syntax-table
63-
(while (not (eobp))
64-
(let ((current-line (buffer-substring (point-at-bol) (point-at-eol))))
65-
;; Skip methods for now: is there anything more intelligent
66-
;; we could do with them?
67-
(unless (string-match-p "::" current-line)
68-
(search-forward "(" (point-at-eol))
69-
(goto-char (match-beginning 0))
70-
(let ((function-name (thing-at-point 'symbol))
71-
(help-string (replace-regexp-in-string "[[:space:]]+" " "
72-
current-line))
73-
(progress (* 100 (/ (float (line-number-at-pos)) line-count))))
74-
(message "[%2d%%] Parsing %s..." progress function-name)
75-
(puthash function-name help-string function-arguments-temp))))
76-
;; Skip over function description
77-
(forward-line 2)))))
78-
(let* ((file (concat php-extras-eldoc-functions-file ".el"))
79-
(base-name (file-name-nondirectory php-extras-eldoc-functions-file)))
80-
(with-temp-file file
81-
(insert (format
82-
";;; %s.el -- file auto generated by `php-extras-generate-eldoc'
83-
84-
\(require 'php-extras)
85-
86-
\(setq php-extras-function-arguments %S)
87-
88-
\(provide 'php-extras-eldoc-functions)
52+
(with-current-buffer (url-retrieve-synchronously php-extras-php-doc-url)
53+
(search-forward-regexp "^$")
54+
(let* ((data (json-read))
55+
(count 0)
56+
(progress 0)
57+
(length (length data))
58+
(function-arguments-temp (make-hash-table
59+
:size length
60+
:rehash-threshold 1.0
61+
:rehash-size 100
62+
:test 'equal)))
63+
(dolist (elem data)
64+
(setq count (+ count 1))
65+
;; Skip methods for now: is there anything more intelligent we
66+
;; could do with them?
67+
(unless (string-match-p "::" (symbol-name (car elem)))
68+
(setq progress (* 100 (/ (float count) length)))
69+
(message "[%2d%%] Adding function: %s..." progress (car elem))
70+
(puthash (symbol-name (car elem)) (cdr elem) function-arguments-temp)))
71+
;; PHP control structures are not present in JSON list. We add
72+
;; them here (hard coded - there are not so many of them).
73+
(let ((php-control-structures '("if" "else" "elseif" "while" "do.while" "for" "foreach" "break" "continue" "switch" "declare" "return" "require" "include" "require_once" "include_once" "goto")))
74+
(dolist (php-control-structure php-control-structures)
75+
(message "Adding control structure: %s..." php-control-structure)
76+
(puthash php-control-structure
77+
'((purpose . "Control structure")
78+
(id . (concat "control-structures." php-control-structure)))
79+
function-arguments-temp)))
80+
(let* ((file (concat php-extras-eldoc-functions-file ".el"))
81+
(base-name (file-name-nondirectory php-extras-eldoc-functions-file)))
82+
(with-temp-file file
83+
(insert (format
84+
";;; %s.el -- file auto generated by `php-extras-generate-eldoc'
85+
86+
\(require 'php-extras)
87+
88+
\(setq php-extras-function-arguments %S)
89+
90+
\(provide 'php-extras-eldoc-functions)
8991
9092
;;; %s.el ends here
9193
"
92-
base-name
93-
function-arguments-temp
94-
base-name)))
95-
(when byte-compile
96-
(message "Byte compiling and loading %s ..." file)
97-
(byte-compile-file file t)
98-
(message "Byte compiling and loading %s ... done." file)))))
94+
base-name
95+
function-arguments-temp
96+
base-name)))
97+
(when byte-compile
98+
(message "Byte compiling and loading %s ..." file)
99+
(byte-compile-file file t)
100+
(message "Byte compiling and loading %s ... done." file))))))
99101

100102
(provide 'php-extras-gen-eldoc)
101103

php-extras.el

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
;;; php-extras.el --- Extra features for `php-mode'
22

3-
;; Copyright (C) 2012, 2013 Arne Jørgensen
3+
;; Copyright (C) 2012, 2013, 2014 Arne Jørgensen
44

55
;; Author: Arne Jørgensen <[email protected]>
66
;; URL: https://github.com/arnested/php-extras
77
;; Created: June 28, 2012
8-
;; Version: 1.0.0
8+
;; Version: 2.0.0
99
;; Package-Requires: ((php-mode "1.5.0"))
1010
;; Keywords: programming, php
1111

@@ -91,18 +91,23 @@ variable. If prefix argument is negative search forward."
9191
(insert (match-string-no-properties 1))
9292
(message "No variable to insert.")))
9393

94+
(defun php-extras-get-function-property (symbol property)
95+
"Get property of symbol.
96+
Property can be: 'versions, 'return, 'prototype, 'purpose, or 'id."
97+
(cdr (assoc property (gethash symbol php-extras-function-arguments))))
98+
9499
;;;###autoload
95100
(defun php-extras-eldoc-documentation-function ()
96101
"Get function arguments for core PHP function at point."
97102
(when (eq php-extras-function-arguments 'not-loaded)
98103
(php-extras-load-eldoc))
99104
(when (hash-table-p php-extras-function-arguments)
100105
(or
101-
(gethash (php-get-pattern) php-extras-function-arguments)
106+
(php-extras-get-function-property (php-get-pattern) 'prototype)
102107
(save-excursion
103108
(ignore-errors
104109
(backward-up-list)
105-
(gethash (php-get-pattern) php-extras-function-arguments))))))
110+
(php-extras-get-function-property (php-get-pattern) 'prototype))))))
106111

107112
;;;###autoload
108113
(add-hook 'php-mode-hook 'php-extras-eldoc-setup)

0 commit comments

Comments
 (0)