diff options
author | Alan Pearce | 2013-04-28 20:54:18 +0100 |
---|---|---|
committer | Alan Pearce | 2013-04-28 20:54:18 +0100 |
commit | e7657d6ba54ad5714657cff9be86ec416d342a4c (patch) | |
tree | 50a2fada14e8d5f76ef890c4b860fbdd4faf812f /emacs/elisp/eldoc-php.el | |
parent | 6bec14c2d18c915a3510aba36a37e78a8b83170f (diff) | |
download | nixfiles-e7657d6ba54ad5714657cff9be86ec416d342a4c.tar.lz nixfiles-e7657d6ba54ad5714657cff9be86ec416d342a4c.tar.zst nixfiles-e7657d6ba54ad5714657cff9be86ec416d342a4c.zip |
Migrate repository from mercurial without history
Diffstat (limited to 'emacs/elisp/eldoc-php.el')
-rw-r--r-- | emacs/elisp/eldoc-php.el | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/emacs/elisp/eldoc-php.el b/emacs/elisp/eldoc-php.el new file mode 100644 index 00000000..8101fea0 --- /dev/null +++ b/emacs/elisp/eldoc-php.el @@ -0,0 +1,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)))) |