annotate lisp/=libc.el @ 36450:a5ae1f49b2ee

Document the problems with "Text file busy" due to buggy NFS servers.
author Eli Zaretskii <eliz@gnu.org>
date Thu, 01 Mar 2001 13:50:51 +0000
parents 06f81684d7ea
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17935
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 ;;; libc.el -- lookup C symbols in the GNU C Library Reference Manual.
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2
17957
06f81684d7ea Change copyright years.
Richard M. Stallman <rms@gnu.org>
parents: 17936
diff changeset
3 ;; Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
17935
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5 ;;; Author: Ralph Schleicher <rs@purple.UL.BaWue.DE>
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 ;;; Keywords: local c info
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; any later version.
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 ;; Boston, MA 02111-1307, USA.
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 ;;; Commentary:
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 ;; This code has a long history. It started as a minor
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 ;; mode for C mode. This era ended with the release of version 2
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;; of the GNU C Library in 1997. The code was therefore rewritten
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 ;; more or less from scratch so that all lookups are performed via
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 ;; indices. Not finding an existing symbol in an index means that
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 ;; there is an error in the manual. Long missed features like a
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 ;; separate input history, symbol name completion in the mini-buffer,
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 ;; highlighting of looked up symbol names in the Info buffer, and
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 ;; implicitly prepending `struct', `union' or `enum' to data types
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 ;; were added in this phase too.
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 ;;; Code:
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 (require 'info)
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 (defvar libc-info-file-name "libc"
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 "Basename of the Info file of the GNU C Library Reference Manual.")
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 (defvar libc-highlight-face 'highlight
17936
9402fa70b738 (libc-highlight-overlay): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17935
diff changeset
47 "*Face for highlighting looked up symbol names in the Info buffer.
17935
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 `nil' disables highlighting.")
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49
17936
9402fa70b738 (libc-highlight-overlay): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17935
diff changeset
50 (defvar libc-highlight-overlay nil
9402fa70b738 (libc-highlight-overlay): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17935
diff changeset
51 "Overlay object used for highlighting.")
9402fa70b738 (libc-highlight-overlay): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17935
diff changeset
52
17935
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 (defconst libc-symbol-completions nil
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 "Alist of documented C symbols.")
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 (defconst libc-file-completions nil
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 "Alist of documented programs or files.")
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 (defvar libc-history nil
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 "History of previous input lines.")
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 ;;;###autoload
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 (defun libc-describe-symbol (symbol-name)
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 "Display the documentation of a C symbol in another window.
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 SYMBOL-NAME must be documented in the GNU C Library Reference Manual.
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 If called interactively, SYMBOL-NAME will be read from the mini-buffer.
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 Optional prefix argument means insert the default symbol (if any) into
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 the mini-buffer so that it can be edited. The default symbol is the
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 one found at point.
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 If SYMBOL-NAME is a public function, variable, or data type of the GNU
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 C Library but `libc-describe-symbol' fails to display it's documentation,
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 then you have found a bug in the manual. Please report that to the mail
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 address `bug-glibc-manual@prep.ai.mit.edu' so that it can be fixed."
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 (interactive
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 (let* ((completion-ignore-case nil)
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 (enable-recursive-minibuffers t)
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 (symbol (libc-symbol-at-point))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 (value (completing-read
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 (if symbol
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 (format "Describe symbol (default %s): " symbol)
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 (format "Describe symbol: "))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 libc-symbol-completions nil nil
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 (and current-prefix-arg symbol) 'libc-history)))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 (list (if (equal value "") symbol value))))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 (or (assoc symbol-name libc-symbol-completions)
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 (error "Not documented as a C symbol: %s" (or symbol-name "")))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 (or (libc-lookup-function symbol-name)
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 (libc-lookup-variable symbol-name)
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 (libc-lookup-type symbol-name)))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 ;;;###autoload
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 (defun libc-describe-file (file-name)
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 "Display the documentation of a program or file in another window.
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 FILE-NAME must be documented in the GNU C Library Reference Manual."
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 (interactive
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 (let* ((completion-ignore-case nil)
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 (enable-recursive-minibuffers t))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 (list (completing-read
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 "Describe program or file: "
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 libc-file-completions nil nil nil 'libc-history))))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 (or (assoc file-name libc-file-completions)
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 (error "Not documented as a program or file: %s" (or file-name "")))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 (libc-lookup-file file-name))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 ;;;###autoload
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 (defun libc-search (regexp &optional arg)
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 "Search in the GNU C Library Reference Manual for REGEXP.
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 Prefix argument means search should ignore case."
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 (interactive "sSearch `libc.info' for regexp: \nP")
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 (or (get-buffer "*info*")
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 (save-window-excursion
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 (info)))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 (switch-to-buffer-other-window "*info*")
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 (Info-goto-node (concat "(" libc-info-file-name ")"))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 (let ((case-fold-search arg))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 (Info-search regexp)))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 (defun libc-make-completion-alist (info-nodes &optional regexp)
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 "Create a unique alist from all menu items in the Info nodes INFO-NODES
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 of the GNU C Reference Manual.
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 Optional second argument REGEXP means include only menu items matching the
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 regular expression REGEXP."
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 (condition-case nil
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 (let (completions item)
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 (save-window-excursion
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 (info libc-info-file-name)
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 (while info-nodes
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 (Info-goto-node (car info-nodes))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 (goto-char (point-min))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 (and (search-forward "\n* Menu:" nil t)
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 (while (re-search-forward "\n\\* \\([^:\t\n]*\\):" nil t)
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 (setq item (buffer-substring
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 (match-beginning 1) (match-end 1)))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 (and (not (assoc item completions))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 (if regexp (string-match regexp item) t)
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 (setq completions (cons (cons item nil)
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 completions)))))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 (setq info-nodes (cdr info-nodes)))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 (Info-directory))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 completions)
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 (error nil)))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 (defun libc-after-manual-update ()
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 "This function must only be called after a new version of the
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 GNU C Library Reference Manual was installed on your system."
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 (setq libc-symbol-completions (libc-make-completion-alist
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 '("Function Index"
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 "Variable Index"
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 "Type Index"))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154 libc-file-completions (libc-make-completion-alist
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 '("File Index") "^[^ \t]+$")))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 (or (and libc-symbol-completions
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 libc-file-completions)
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 (libc-after-manual-update))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 (defun libc-symbol-at-point ()
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162 "Get the C symbol at point."
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163 (condition-case nil
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 (save-excursion
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 (backward-sexp)
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166 (let ((start (point))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167 prefix name)
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 ;; Test for a leading `struct', `union', or `enum' keyword
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169 ;; but ignore names like `foo_struct'.
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 (setq prefix (and (< (skip-chars-backward " \t\n") 0)
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 (< (skip-chars-backward "_a-zA-Z0-9") 0)
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172 (looking-at "\\(struct\\|union\\|enum\\)\\s ")
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 (concat (buffer-substring
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174 (match-beginning 1) (match-end 1))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 " ")))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 (goto-char start)
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 (and (looking-at "[_a-zA-Z][_a-zA-Z0-9]*")
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 (setq name (buffer-substring
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 (match-beginning 0) (match-end 0))))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180 ;; Caveat! Look forward if point is at `struct' etc.
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 (and (not prefix)
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 (or (string-equal name "struct")
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 (string-equal name "union")
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 (string-equal name "enum"))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 (looking-at "[a-z]+\\s +\\([_a-zA-Z][_a-zA-Z0-9]*\\)")
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 (setq prefix (concat name " ")
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 name (buffer-substring
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 (match-beginning 1) (match-end 1))))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 (and (or prefix name)
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 (concat prefix name))))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 (error nil)))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 (defun libc-lookup-function (function)
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 (libc-search-index "Function Index" function
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 "^[ \t]+- \\(Function\\|Macro\\): .*\\<" "\\>"))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 (defun libc-lookup-variable (variable)
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 (libc-search-index "Variable Index" variable
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 "^[ \t]+- \\(Variable\\|Macro\\): .*\\<" "\\>"))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 (defun libc-lookup-type (data-type)
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 (libc-search-index "Type Index" data-type
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 "^[ \t]+- Data Type: \\<" "\\>"))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205 (defun libc-lookup-file (file-name)
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206 (libc-search-index "File Index" file-name))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 (defun libc-search-index (index item &optional prefix suffix)
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 "Search ITEM in the Info index INDEX and go to that Info node.
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211 Value is ITEM or `nil' if an error occurs.
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213 If PREFIX and/or SUFFIX are non-`nil', then search the Info node for
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214 the first occurrence of the regular expression `PREFIX ITEM SUFFIX' and
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215 leave point at the beginning of the first line of the match. ITEM will
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216 be highlighted with `libc-highlight-face' iff `libc-highlight-face' is
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 not `nil'."
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 (condition-case nil
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 (save-selected-window
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 (or (get-buffer "*info*")
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 (save-window-excursion
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222 (info)))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 (switch-to-buffer-other-window "*info*")
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 (Info-goto-node (concat "(" libc-info-file-name ")" index))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 (Info-menu item)
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 (if (or prefix suffix)
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 (let ((case-fold-search nil)
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228 (buffer-read-only nil))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229 (goto-char (point-min))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 (re-search-forward
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231 (concat prefix (regexp-quote item) suffix))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232 (goto-char (match-beginning 0))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233 (and window-system libc-highlight-face
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 ;; Search again for ITEM so that the first
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235 ;; occurence of ITEM will be highlighted.
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236 (save-excursion
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 (re-search-forward (regexp-quote item))
17936
9402fa70b738 (libc-highlight-overlay): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17935
diff changeset
238 (let ((start (match-beginning 0))
9402fa70b738 (libc-highlight-overlay): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17935
diff changeset
239 (end (match-end 0)))
9402fa70b738 (libc-highlight-overlay): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17935
diff changeset
240 (if (overlayp libc-highlight-overlay)
9402fa70b738 (libc-highlight-overlay): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17935
diff changeset
241 (move-overlay libc-highlight-overlay
9402fa70b738 (libc-highlight-overlay): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17935
diff changeset
242 start end (current-buffer))
9402fa70b738 (libc-highlight-overlay): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17935
diff changeset
243 (setq libc-highlight-overlay
9402fa70b738 (libc-highlight-overlay): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17935
diff changeset
244 (make-overlay start end))))
9402fa70b738 (libc-highlight-overlay): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17935
diff changeset
245 (overlay-put libc-highlight-overlay
9402fa70b738 (libc-highlight-overlay): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17935
diff changeset
246 'face libc-highlight-face)))
17935
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247 (beginning-of-line)))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
248 item)
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
249 (error nil)))
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252 (provide 'libc)
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253
5dbdaeeba3fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254 ;;; libc.el ends here