-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmi-libc.el
110 lines (87 loc) · 3.39 KB
/
mi-libc.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
104
105
106
107
108
109
110
;;; mi-libc.el --- Mode-info backend for Info of libc
;; Copyright (C) 2001,2002 TSUCHIYA Masatoshi <[email protected]>
;; Author: TSUCHIYA Masatoshi <[email protected]>
;; Keywords: libc 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 GNU C Library
;; Reference Manual. It is included in the source package of GNU C
;; Library, which can be downloaded from:
;;
;; ftp://sourceware.cygnus.com/pub/glibc/releases/
;;; Code:
(require 'mode-info)
(eval-when-compile
(require 'cl)
(require 'mi-index))
(defgroup mode-info-libc nil
"Various sorts of imporved help system for Libc."
:group 'mode-info)
(defcustom mode-info-libc-index-file
(expand-file-name "mi-libc.idx" mode-info-index-directory)
"*Index file of functions and variables described in Info about libc."
:group 'mode-info-libc
:type 'file)
(defcustom mode-info-libc-titles
'("libc")
"*Info titles about libc."
:group 'mode-info-libc
:type mode-info-titles-type)
(defconst mode-info-libc-entry-regexp
(eval-when-compile
(concat
"^[ \t]+-+[ \t]+\\(\\("
(mapconcat
'identity
'("\\(\\(Obsolete\\|Deprecated\\|POSIX\\.1\\|BSD\\|System[ \t]+V\\)[ \t]+\\)?Function"
"Macro" "Variable")
"\\|")
"\\):\\([ \t]+\\(\\(const\\|static\\|extern\\)[ \t]+\\)?"
"\\(\\(struct\\|union\\|enum\\)[ \t]+[^ \t]+\\|[^ \t]+_t\\|"
"\\(\\(\\(unsigned\\|complex\\)[ \t]+\\)?"
"\\(\\(\\(long[ \t]+\\)?long\\|short\\)[ \t]+\\)?\\("
(mapconcat
'identity
'("void" "char" "short" "int" "long" "double" "float"
"FILE" "TYPE" "DIR" "ENTRY" "nl_catd")
"\\|")
"\\)\\)\\)\\([ \t]+\\*+\\)?\\)?[ \t]+\\([^ \t\n(]+\\)[ \t]*(?\\)")))
(defconst mode-info-libc-entry-pos 18)
(mode-info-defclass libc)
(defun mode-info-libc-word-at-point (alist)
(save-excursion
(mode-info-save-syntax-table
(let (word)
(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-defmethod function-at-point ((class libc))
(mode-info-load-index class)
(mode-info-libc-word-at-point (mode-info-function-alist class)))
(mode-info-defmethod variable-at-point ((class libc))
(mode-info-load-index class)
(mode-info-libc-word-at-point (mode-info-variable-alist class)))
(defun mode-info-libc-make-index ()
"Make index of Info files listed in `mode-info-libc-titles'."
(interactive)
(mode-info-make-index 'libc
mode-info-libc-titles
mode-info-libc-entry-regexp
mode-info-libc-entry-pos))
(provide 'mi-libc)
;;; mi-libc.el ends here