From e7657d6ba54ad5714657cff9be86ec416d342a4c Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Sun, 28 Apr 2013 20:54:18 +0100 Subject: Migrate repository from mercurial without history --- emacs/elisp/eldoc-php.el | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 emacs/elisp/eldoc-php.el (limited to 'emacs/elisp/eldoc-php.el') 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 "
\\(\\(.\\|\n\\)*?\\)
" 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 "

\\(\\(.\\|\n\\)*?\\)

" 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)))) -- cgit 1.4.1