emacs-php / emacs-php/php-mode

Automatically download PHP documentation?

Open
#288 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
Emacs Lisp
Stars
602
Forks
117
Avg merge
12h 54m
Merged PRs (30d)
3

Description

I'm just dropping this in here as food for thought. The following is the code I wrote to ensure that all of my dev environments will have access to local PHP docs inside Emacs via the eww browser, without me needed to fetch them manually.

It would be pretty nice if one could configure php-mode to do something similar.

```
;; Find documentation (locally or online).
(define-key php-mode-map (kbd "") 'php-search-documentation)
(when (fboundp 'eww-browse-url)
(setq php-search-documentation-browser-function 'eww-browse-url))

;; Locate local documentation.
(let ((expected "/usr/local/share/php/php-chunked-xhtml"))
(if (file-directory-p expected)
(setq php-manual-path expected)
(setq expected (expand-file-name "~/php/php-chunked-xhtml"))
(if (file-directory-p expected)
(setq php-manual-path expected)
(message "PHP manual not found. Attempting download.")
;; Download and untar
(let ((download-directory (file-name-directory expected))
(url "http://php.net/get/php_manual_en.tar.gz/from/this/mirror")
(file "php_manual_en.tar.gz"))
(make-directory download-directory t)
(shell-command
(apply 'format
"cd %s && wget -q %s -O %s && tar -xf %s && rm %s"
(mapcar 'shell-quote-argument
(list download-directory url file file file)))))
;; Check the result
(if (file-directory-p expected)
(setq php-manual-path expected)
(message "Failed to download PHP manual.")))))
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.