Version 0.63
[sepia.git] / sepia-w3m.el
blob2859033533fdef3132bb17e1da58644da6f89767
1 ;;; sepia-w3m.el --- The add-on program to view Perl documents.
3 ;; Copyright (C) 2001 TSUCHIYA Masatoshi <tsuchiya@namazu.org>
4 ;; Modified 2004 by Sean O'Rourke to work with Sepia and operate on
5 ;; buffer.
7 ;; Author: TSUCHIYA Masatoshi <tsuchiya@namazu.org>
8 ;; Keywords: w3m, perldoc
10 ;; This file is a part of emacs-w3m.
12 ;; This program is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; any later version.
17 ;; This program is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with this program; if not, you can either send email to this
24 ;; program's maintainer or write to: The Free Software Foundation,
25 ;; Inc.; 59 Temple Place, Suite 330; Boston, MA 02111-1307, USA.
28 ;;; Commentary:
30 ;; w3m-perldoc.el is the add-on program of emacs-w3m to view Perl
31 ;; documents. For more detail about emacs-w3m, see:
33 ;; http://emacs-w3m.namazu.org/
35 ;;; Code:
36 (require 'w3m-perldoc)
38 ;;;###autoload
39 (defun w3m-about-perldoc-buffer (url &optional no-decode no-cache &rest args)
40 (when (string-match "\\`about://perldoc-buffer/" url)
41 (let ((buf (get-buffer (w3m-url-decode-string
42 (substring url (match-end 0)))))
43 (default-directory w3m-profile-directory)
44 (process-environment (copy-sequence process-environment)))
45 ;; To specify the place in which pod2html generates its cache files.
46 (setenv "HOME" (expand-file-name w3m-profile-directory))
47 (insert-buffer buf)
48 (when (zerop (apply #'call-process-region
49 (point-min) (point-max)
50 w3m-perldoc-pod2html-command
51 t '(t nil) nil
52 (append w3m-perldoc-pod2html-arguments
53 '("--htmlroot=about://perldoc-buffer"))))
54 (let ((case-fold-search t))
55 (goto-char (point-min))
56 (while (re-search-forward
57 "<a href=\"about://perldoc\\(-buffer\\)?/\\([^\"]*\\)\\(\\.html\\)\">" nil t)
58 (delete-region (match-beginning 3) (match-end 3))
59 (save-restriction
60 (narrow-to-region (match-beginning 2) (match-end 2))
61 (while (search-backward "/" nil t)
62 (delete-char 1)
63 (insert "::"))
64 (goto-char (point-max))))
65 "text/html")))))
67 ;;;###autoload
68 (defun sepia-w3m-view-pod (&optional buffer)
69 "View POD for the current buffer."
70 (interactive)
71 (w3m-goto-url (concat "about://perldoc-buffer/"
72 (w3m-url-encode-string (buffer-name buffer)))))
74 ;;;###autoload
75 (defun sepia-w3m-perldoc-this (mod)
76 "View perldoc for module at point."
77 (interactive (list (sepia-interactive-arg 'module)))
78 (w3m-perldoc mod))
80 (defun sepia-module-list ()
81 (interactive)
82 (let ((file "/tmp/modlist.html"))
83 (unless (file-exists-p file)
84 (with-temp-buffer
85 (insert "use ExtUtils::Installed;
87 print \"<html><body><ul>\";
88 for (sort ExtUtils::Installed->new->modules) {
89 print qq{<li><a href=\"about://perldoc/$_\">$_</a>};
91 print \"</ul></body></html>\n\";
93 (shell-command-on-region (point-min) (point-max)
94 (concat "perl > " file))))
95 (w3m-find-file file)))
97 (provide 'sepia-w3m)
99 ;;; sepia-w3m.el ends here.