blob: 8101fea087550a9a105e47d170841116b85b505d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
(require 'xml)
(provide 'eldoc-php)
(setq my-php-function-doc-hash (make-hash-table :test 'equal))
(defun my-php-fetch-function-doc (function)
(let ((doc (gethash function my-php-function-doc-hash 'nope)))
(when (eq doc 'nope)
(setq doc nil)
(let ((buf (url-retrieve-synchronously (concat "http://uk3.php.net/manual-lookup.php?pattern=" function))))
(with-current-buffer buf
(goto-char (point-min))
(let (desc)
(when (re-search-forward "<div class=\"methodsynopsis dc-description\">\\(\\(.\\|\n\\)*?\\)</div>" nil t)
(setq desc
(replace-regexp-in-string
" +" " "
(replace-regexp-in-string
"\n" ""
(replace-regexp-in-string "<.*?>" "" (match-string-no-properties 1)))))
;; Don't show the function description
;; (when (re-search-forward "<p class=\"para rdfs-comment\">\\(\\(.\\|\n\\)*?\\)</p>" nil t)
;; (setq desc
;; (concat desc "\n\n"
;; (replace-regexp-in-string
;; " +" " "
;; (replace-regexp-in-string
;; "\n" ""
;; (replace-regexp-in-string "<.*?>" "" (match-string-no-properties 1)))))))
)
(if desc
(setq doc (xml-substitute-special desc)))))
(kill-buffer buf))
(puthash function doc my-php-function-doc-hash))
doc))
(defun my-php-eldoc-function ()
(let ((symbol (thing-at-point 'symbol)))
(if (and symbol
(not (eq (elt symbol 0) ?$)))
(my-php-fetch-function-doc symbol))))
|