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
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)
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.
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/
37 (require 'w3m-perldoc
)
40 (defun w3m-about-buffer-perldoc (url &optional no-decode no-cache
&rest args
)
41 (when (string-match "\\`about://perldoc-buffer/" url
)
42 (let ((buf (get-buffer (w3m-url-decode-string
43 (substring url
(match-end 0)))))
44 (default-directory w3m-profile-directory
)
45 (process-environment (copy-sequence process-environment
)))
46 ;; To specify the place in which pod2html generates its cache files.
47 (setenv "HOME" (expand-file-name w3m-profile-directory
))
49 (when (zerop (apply #'call-process-region
50 (point-min) (point-max)
51 w3m-perldoc-pod2html-command
53 (append w3m-perldoc-pod2html-arguments
54 '("--htmlroot=about://perldoc-buffer"))))
55 (let ((case-fold-search t
))
56 (goto-char (point-min))
57 (while (re-search-forward
58 "<a href=\"about://perldoc\\(-buffer\\)?/\\([^\"]*\\)\\(\\.html\\)\">" nil t
)
59 (delete-region (match-beginning 3) (match-end 3))
61 (narrow-to-region (match-beginning 2) (match-end 2))
62 (while (search-backward "/" nil t
)
65 (goto-char (point-max))))
69 (defun sepia-w3m-view-pod (&optional buffer
)
70 "View POD for the current buffer."
72 (w3m-goto-url (concat "about://perldoc-buffer/"
73 (w3m-url-encode-string (buffer-name buffer
)))))
76 (defun sepia-w3m-perldoc-this (obj &optional mod type
)
77 "View perldoc for module at point."
78 (interactive (multiple-value-list (sepia-ident-at-point)))
79 (let ((mod (if (eq type
'module
)
82 (if (eq type
'variable
)
84 (xref-defs obj mod
))))))))
87 (when (and obj
(not (eq type
'module
))
89 (concat "^\\Sw*\\<" obj
"\\>") nil t
))
93 (defun sepia-module-list ()
95 (let ((file "/tmp/modlist.html"))
96 (unless (file-exists-p file
)
98 (insert "use ExtUtils::Installed;
100 print \"<html><body><ul>\";
101 for (sort ExtUtils::Installed->new->modules) {
102 print qq{<li><a href=\"about://perldoc/$_\">$_</a>};
104 print \"</ul></body></html>\n\";
106 (shell-command-on-region (point-min) (point-max)
107 (concat "perl > " file
))))
108 (w3m-find-file file
)))
112 ;;; sepia-w3m.el ends here.