|
72 | 72 | (require 'etags)
|
73 | 73 | (require 'speedbar)
|
74 | 74 | (require 'imenu)
|
| 75 | +(require 'package) |
75 | 76 | (require 'nadvice nil t)
|
76 | 77 |
|
77 | 78 | (require 'cl-lib)
|
@@ -191,14 +192,6 @@ enabled."
|
191 | 192 | :tag "PHP Mode Do Not Use Semantic Imenu"
|
192 | 193 | :type 'boolean)
|
193 | 194 |
|
194 |
| -(defcustom php-completion-file "" |
195 |
| - "Path to the file which contains the function names known to PHP." |
196 |
| - :type 'string) |
197 |
| - |
198 |
| -(defcustom php-manual-path "" |
199 |
| - "Path to the directory which contains the PHP manual." |
200 |
| - :type 'string) |
201 |
| - |
202 | 195 | ;;;###autoload
|
203 | 196 | (if (version< emacs-version "24.4")
|
204 | 197 | (dolist (i '("php" "php5" "php7"))
|
@@ -1399,130 +1392,6 @@ current `tags-file-name'."
|
1399 | 1392 | (message "Arglist for %s: %s" tagname arglist)
|
1400 | 1393 | (message "Unknown function: %s" tagname))))
|
1401 | 1394 |
|
1402 |
| -(defcustom php-search-documentation-browser-function nil |
1403 |
| - "Function to display PHP documentation in a WWW browser. |
1404 |
| -
|
1405 |
| -If non-nil, this shadows the value of `browse-url-browser-function' when |
1406 |
| -calling `php-search-documentation' or `php-search-local-documentation'." |
1407 |
| - :group 'php |
1408 |
| - :tag "PHP Search Documentation Browser Function" |
1409 |
| - :type '(choice (const :tag "default" nil) function) |
1410 |
| - :link '(variable-link browse-url-browser-function)) |
1411 |
| - |
1412 |
| -(defun php-browse-documentation-url (url) |
1413 |
| - "Browse a documentation URL using the configured browser function. |
1414 |
| -
|
1415 |
| -See `php-search-documentation-browser-function'." |
1416 |
| - (let ((browse-url-browser-function |
1417 |
| - (or php-search-documentation-browser-function |
1418 |
| - browse-url-browser-function))) |
1419 |
| - (browse-url url))) |
1420 |
| - |
1421 |
| -(defvar php-search-local-documentation-types |
1422 |
| - (list "function" "control-structures" "class" "book") |
1423 |
| - ;; "intro" and "ref" also look interesting, but for all practical purposes |
1424 |
| - ;; their terms are sub-sets of the "book" terms (with the few exceptions |
1425 |
| - ;; being very unlikely search terms). |
1426 |
| - "The set (and priority sequence) of documentation file prefixes |
1427 |
| -under which to search for files in the local documentation directory.") |
1428 |
| - |
1429 |
| -(defvar php-search-local-documentation-words-cache nil) |
1430 |
| - |
1431 |
| -(defun php--search-documentation-read-arg () |
1432 |
| - "Obtain interactive argument for searching documentation." |
1433 |
| - ;; Cache the list of documentation words available for completion, |
1434 |
| - ;; based on the defined types-of-interest. |
1435 |
| - (let ((types-list php-search-local-documentation-types) |
1436 |
| - (words-cache php-search-local-documentation-words-cache) |
1437 |
| - (local-manual (and (stringp php-manual-path) |
1438 |
| - (not (string= php-manual-path ""))))) |
1439 |
| - (when (and local-manual |
1440 |
| - (not (assq types-list words-cache))) |
1441 |
| - ;; Generate the cache on the first run, or if the types changed. |
1442 |
| - ;; We read the filenames matching our types list in the local |
1443 |
| - ;; documentation directory, and extract the 'middle' component |
1444 |
| - ;; of each. e.g. "function.array-map.html" => "array_map". |
1445 |
| - (let* ((types-opt (regexp-opt types-list)) |
1446 |
| - (pattern (concat "\\`" types-opt "\\.\\(.+\\)\\.html\\'")) |
1447 |
| - (collection |
1448 |
| - (mapcar (lambda (filename) (subst-char-in-string |
1449 |
| - ?- ?_ (replace-regexp-in-string |
1450 |
| - pattern "\\1" filename))) |
1451 |
| - (directory-files php-manual-path nil pattern)))) |
1452 |
| - ;; Replace the entire cache. If the types changed, we don't need |
1453 |
| - ;; to retain the collection for the previous value. |
1454 |
| - (setq words-cache (list (cons types-list collection))) |
1455 |
| - (setq php-search-local-documentation-words-cache words-cache))) |
1456 |
| - ;; By default we search for (current-word) immediately, without prompting. |
1457 |
| - ;; With a prefix argument, or if there is no (current-word), we perform a |
1458 |
| - ;; completing read for a word from the cached collection. |
1459 |
| - (let* ((default (current-word)) |
1460 |
| - (prompt (if default |
1461 |
| - (format "Search PHP docs (%s): " default) |
1462 |
| - "Search PHP docs: ")) |
1463 |
| - (collection (and local-manual |
1464 |
| - (cdr (assq types-list words-cache)))) |
1465 |
| - (word (if (or current-prefix-arg (not default)) |
1466 |
| - (completing-read prompt collection nil nil nil nil default) |
1467 |
| - default))) |
1468 |
| - ;; Return interactive argument list. |
1469 |
| - (list word)))) |
1470 |
| - |
1471 |
| -(defun php-search-local-documentation (word) |
1472 |
| - "Search the local PHP documentation (i.e. in `php-manual-path') for |
1473 |
| -the word at point. The function returns t if the requested documentation |
1474 |
| -exists, and nil otherwise. |
1475 |
| -
|
1476 |
| -With a prefix argument, prompt (with completion) for a word to search for." |
1477 |
| - (interactive (php--search-documentation-read-arg)) |
1478 |
| - (let ((file (catch 'found |
1479 |
| - (cl-loop for type in php-search-local-documentation-types do |
1480 |
| - (let* ((doc-html (format "%s.%s.html" |
1481 |
| - type |
1482 |
| - (replace-regexp-in-string |
1483 |
| - "_" "-" (downcase word)))) |
1484 |
| - (file (expand-file-name doc-html php-manual-path))) |
1485 |
| - (when (file-exists-p file) |
1486 |
| - (throw 'found file))))))) |
1487 |
| - (when file |
1488 |
| - (let ((file-url (if (string-prefix-p "file://" file) |
1489 |
| - file |
1490 |
| - (concat "file://" file)))) |
1491 |
| - (php-browse-documentation-url file-url)) |
1492 |
| - t))) |
1493 |
| - |
1494 |
| -(defsubst php-search-web-documentation (word) |
1495 |
| - "Return URL to search PHP manual search by `WORD'." |
1496 |
| - (php-browse-documentation-url (concat (or php-search-url php-site-url) word))) |
1497 |
| - |
1498 |
| -;; Define function documentation function |
1499 |
| -(defun php-search-documentation (word) |
1500 |
| - "Search PHP documentation for the `WORD' at point. |
1501 |
| -
|
1502 |
| -If `php-manual-path' has a non-empty string value then the command |
1503 |
| -will first try searching the local documentation. If the requested |
1504 |
| -documentation does not exist it will fallback to searching the PHP |
1505 |
| -website. |
1506 |
| -
|
1507 |
| -With a prefix argument, prompt for a documentation word to search |
1508 |
| -for. If the local documentation is available, it is used to build |
1509 |
| -a completion list." |
1510 |
| - (interactive (php--search-documentation-read-arg)) |
1511 |
| - (if (and (stringp php-manual-path) |
1512 |
| - (not (string= php-manual-path ""))) |
1513 |
| - (or (php-search-local-documentation word) |
1514 |
| - (php-search-web-documentation word)) |
1515 |
| - (php-search-web-documentation word))) |
1516 |
| - |
1517 |
| -;; Define function for browsing manual |
1518 |
| -(defun php-browse-manual () |
1519 |
| - "Bring up manual for PHP." |
1520 |
| - (interactive) |
1521 |
| - (browse-url (if (stringp php-manual-url) |
1522 |
| - php-manual-url |
1523 |
| - (format "%smanual/%s/" php-site-url php-manual-url)))) |
1524 |
| - |
1525 |
| - |
1526 | 1395 | ;; Font Lock
|
1527 | 1396 | (defconst php-phpdoc-type-keywords
|
1528 | 1397 | (list "string" "integer" "int" "boolean" "bool" "float"
|
|
0 commit comments