-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmi-perl.el
103 lines (80 loc) · 3.19 KB
/
mi-perl.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
;;; mi-perl.el --- Mode-info backend for Perl -*- coding: iso-2022-7bit; -*-
;; Copyright (C) 1998-2002 TSUCHIYA Masatoshi <[email protected]>
;; Author: TSUCHIYA Masatoshi <[email protected]>
;; Keywords: perl info
;; This file is a part of mode-info.
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, you can either send email to this
;; program's maintainer or write to: The Free Software Foundation,
;; Inc.; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
;;; Commentary:
;; This file provides mode-info backend stuffs to see the Info
;; document of Perl. It can be downloaded from:
;;
;; http://namazu.org/~tsuchiya/doc/perl5.000texi-j.tar.gz
;;; Code:
(require 'mode-info)
(eval-when-compile
(require 'cl)
(require 'mi-index))
(defgroup mode-info-perl nil
"Various sorts of imporved help system for perl-mode."
:group 'mode-info)
(defcustom mode-info-perl-index-file
(expand-file-name "mi-perl.idx" mode-info-index-directory)
"*Index file of functions and variables described in Info about Perl."
:group 'mode-info-perl
:type 'file)
(defcustom mode-info-perl-titles
'("perl-ja")
"*Info titles about Perl."
:group 'mode-info-perl
:type mode-info-titles-type)
(defconst mode-info-perl-entry-regexp "\
^[ \t]+-+[ \t]+\\(Function\\|Command\\|Prefix[ \t]+Command\\|$B%3%^%s%I(B\\|\
Special[ \t]+form\\|Macro\\|Method\\|Variable\\|Global[ \t]+Variable\\|\
Local[ \t]+Variable\\|User[ \t]+Option\\):[ \t]+\\([^ \t\n]+\\)[ \t\n]")
(defconst mode-info-perl-entry-pos 2)
(defun mode-info-perl-word-at-point (alist)
(save-excursion
(mode-info-save-syntax-table
(let (word)
(modify-syntax-entry ?$ "w")
(modify-syntax-entry ?@ "w")
(modify-syntax-entry ?% "w")
(modify-syntax-entry ?# "w")
(modify-syntax-entry ?_ "w")
(modify-syntax-entry ?^ "w")
(modify-syntax-entry ?: "w")
(modify-syntax-entry ?& "w")
(modify-syntax-entry ?/ "w")
(modify-syntax-entry ?! "w")
(or (looking-at "\\<") (forward-word -1))
(when (assoc (setq word (buffer-substring-no-properties
(point) (progn (forward-word 1) (point))))
alist)
word)))))
(mode-info-defclass perl)
(mode-info-defmethod function-at-point ((class perl))
(mode-info-load-index class)
(mode-info-perl-word-at-point (mode-info-function-alist class)))
(mode-info-defmethod variable-at-point ((class perl))
(mode-info-load-index class)
(mode-info-perl-word-at-point (mode-info-variable-alist class)))
(defun mode-info-perl-make-index ()
"Make index of Info files listed in `mode-info-perl-titles'."
(interactive)
(mode-info-make-index 'perl
mode-info-perl-titles
mode-info-perl-entry-regexp
mode-info-perl-entry-pos))
(provide 'mi-perl)
;;; mi-perl.el ends here