Mercurial > emacs
annotate lisp/help-fns.el @ 45305:fc36105f5568
*** empty log message ***
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Wed, 15 May 2002 16:50:34 +0000 |
parents | 3431e29f1d9c |
children | 7ea38f55545b |
rev | line source |
---|---|
41584
8b64dc23e305
Change the provide and the header as per the renaming.
Eli Zaretskii <eliz@gnu.org>
parents:
41583
diff
changeset
|
1 ;;; help-fns.el --- Complex help functions |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
2 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
3 ;; Copyright (C) 1985, 1986, 1993, 1994, 1998, 1999, 2000, 2001 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
4 ;; Free Software Foundation, Inc. |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
5 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
6 ;; Maintainer: FSF |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
7 ;; Keywords: help, internal |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
8 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
9 ;; This file is part of GNU Emacs. |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
10 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
11 ;; GNU Emacs is free software; you can redistribute it and/or modify |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
12 ;; it under the terms of the GNU General Public License as published by |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
13 ;; the Free Software Foundation; either version 2, or (at your option) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
14 ;; any later version. |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
15 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
16 ;; GNU Emacs is distributed in the hope that it will be useful, |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
19 ;; GNU General Public License for more details. |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
20 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
21 ;; You should have received a copy of the GNU General Public License |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
24 ;; Boston, MA 02111-1307, USA. |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
25 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
26 ;;; Commentary: |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
27 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
28 ;; This file contains those help commands which are complicated, and |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
29 ;; which may not be used in every session. For example |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
30 ;; `describe-function' will probably be heavily used when doing elisp |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
31 ;; programming, but not if just editing C files. Simpler help commands |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
32 ;; are in help.el |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
33 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
34 ;;; Code: |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
35 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
36 (require 'help-mode) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
37 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
38 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
39 ;;;###autoload |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
40 (defun help-with-tutorial (&optional arg) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
41 "Select the Emacs learn-by-doing tutorial. |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
42 If there is a tutorial version written in the language |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
43 of the selected language environment, that version is used. |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
44 If there's no tutorial in that language, `TUTORIAL' is selected. |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
45 With arg, you are asked to choose which language." |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
46 (interactive "P") |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
47 (let ((lang (if arg |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
48 (read-language-name 'tutorial "Language: " "English") |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
49 (if (get-language-info current-language-environment 'tutorial) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
50 current-language-environment |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
51 "English"))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
52 file filename) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
53 (setq filename (get-language-info lang 'tutorial)) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
54 (setq file (expand-file-name (concat "~/" filename))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
55 (delete-other-windows) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
56 (if (get-file-buffer file) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
57 (switch-to-buffer (get-file-buffer file)) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
58 (switch-to-buffer (create-file-buffer file)) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
59 (setq buffer-file-name file) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
60 (setq default-directory (expand-file-name "~/")) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
61 (setq buffer-auto-save-file-name nil) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
62 (insert-file-contents (expand-file-name filename data-directory)) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
63 (goto-char (point-min)) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
64 (search-forward "\n<<") |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
65 (beginning-of-line) |
44291
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
66 ;; Convert the <<...>> line to the proper [...] line, |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
67 ;; or just delete the <<...>> line if a [...] line follows. |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
68 (cond ((save-excursion |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
69 (forward-line 1) |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
70 (looking-at "\\[")) |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
71 (delete-region (point) (progn (forward-line 1) (point)))) |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
72 ((looking-at "<<Blank lines inserted.*>>") |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
73 (replace-match "[Middle of page left blank for didactic purposes. Text continues below]")) |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
74 (t |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
75 (looking-at "<<") |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
76 (replace-match "[") |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
77 (search-forward ">>") |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
78 (replace-match "]"))) |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
79 (beginning-of-line) |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
80 (let ((n (- (window-height (selected-window)) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
81 (count-lines (point-min) (point)) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
82 6))) |
44291
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
83 (if (< n 8) |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
84 (progn |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
85 ;; For a short gap, we don't need the [...] line, |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
86 ;; so delete it. |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
87 (delete-region (point) (progn (end-of-line) (point))) |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
88 (newline n)) |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
89 ;; Some people get confused by the large gap. |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
90 (newline (/ n 2)) |
44291
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
91 |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
92 ;; Skip the [...] line (don't delete it). |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
93 (forward-line 1) |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
94 (newline (- n (/ n 2))))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
95 (goto-char (point-min)) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
96 (set-buffer-modified-p nil)))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
97 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
98 ;;;###autoload |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
99 (defun locate-library (library &optional nosuffix path interactive-call) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
100 "Show the precise file name of Emacs library LIBRARY. |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
101 This command searches the directories in `load-path' like `M-x load-library' |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
102 to find the file that `M-x load-library RET LIBRARY RET' would load. |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
103 Optional second arg NOSUFFIX non-nil means don't add suffixes `load-suffixes' |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
104 to the specified name LIBRARY. |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
105 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
106 If the optional third arg PATH is specified, that list of directories |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
107 is used instead of `load-path'. |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
108 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
109 When called from a program, the file name is normaly returned as a |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
110 string. When run interactively, the argument INTERACTIVE-CALL is t, |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
111 and the file name is displayed in the echo area." |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
112 (interactive (list (read-string "Locate library: ") |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
113 nil nil |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
114 t)) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
115 (catch 'answer |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
116 (dolist (dir (or path load-path)) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
117 (dolist (suf (append (unless nosuffix load-suffixes) '(""))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
118 (let ((try (expand-file-name (concat library suf) dir))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
119 (and (file-readable-p try) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
120 (null (file-directory-p try)) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
121 (progn |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
122 (if interactive-call |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
123 (message "Library is file %s" (abbreviate-file-name try))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
124 (throw 'answer try)))))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
125 (if interactive-call |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
126 (message "No library %s in search path" library)) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
127 nil)) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
128 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
129 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
130 ;; Functions |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
131 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
132 ;;;###autoload |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
133 (defun describe-function (function) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
134 "Display the full documentation of FUNCTION (a symbol)." |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
135 (interactive |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
136 (let ((fn (function-called-at-point)) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
137 (enable-recursive-minibuffers t) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
138 val) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
139 (setq val (completing-read (if fn |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
140 (format "Describe function (default %s): " fn) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
141 "Describe function: ") |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
142 obarray 'fboundp t nil nil (symbol-name fn))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
143 (list (if (equal val "") |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
144 fn (intern val))))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
145 (if (null function) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
146 (message "You didn't specify a function") |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
147 (help-setup-xref (list #'describe-function function) (interactive-p)) |
42591
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
148 (save-excursion |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
149 (with-output-to-temp-buffer (help-buffer) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
150 (prin1 function) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
151 ;; Use " is " instead of a colon so that |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
152 ;; it is easier to get out the function name using forward-sexp. |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
153 (princ " is ") |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
154 (describe-function-1 function) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
155 (print-help-return-message) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
156 (with-current-buffer standard-output |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
157 ;; Return the text we displayed. |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
158 (buffer-string)))))) |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
159 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
160 ;;;###autoload |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
161 (defun describe-function-1 (function) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
162 (let* ((def (if (symbolp function) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
163 (symbol-function function) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
164 function)) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
165 file-name string |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
166 (beg (if (commandp def) "an interactive " "a "))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
167 (setq string |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
168 (cond ((or (stringp def) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
169 (vectorp def)) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
170 "a keyboard macro") |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
171 ((subrp def) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
172 (if (eq 'unevalled (cdr (subr-arity def))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
173 (concat beg "special form") |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
174 (concat beg "built-in function"))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
175 ((byte-code-function-p def) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
176 (concat beg "compiled Lisp function")) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
177 ((symbolp def) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
178 (while (symbolp (symbol-function def)) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
179 (setq def (symbol-function def))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
180 (format "an alias for `%s'" def)) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
181 ((eq (car-safe def) 'lambda) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
182 (concat beg "Lisp function")) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
183 ((eq (car-safe def) 'macro) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
184 "a Lisp macro") |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
185 ((eq (car-safe def) 'autoload) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
186 (setq file-name (nth 1 def)) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
187 (format "%s autoloaded %s" |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
188 (if (commandp def) "an interactive" "an") |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
189 (if (eq (nth 4 def) 'keymap) "keymap" |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
190 (if (nth 4 def) "Lisp macro" "Lisp function")) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
191 )) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
192 ;; perhaps use keymapp here instead |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
193 ((eq (car-safe def) 'keymap) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
194 (let ((is-full nil) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
195 (elts (cdr-safe def))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
196 (while elts |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
197 (if (char-table-p (car-safe elts)) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
198 (setq is-full t |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
199 elts nil)) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
200 (setq elts (cdr-safe elts))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
201 (if is-full |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
202 "a full keymap" |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
203 "a sparse keymap"))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
204 (t ""))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
205 (princ string) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
206 (with-current-buffer standard-output |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
207 (save-excursion |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
208 (save-match-data |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
209 (if (re-search-backward "alias for `\\([^`']+\\)'" nil t) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
210 (help-xref-button 1 'help-function def))))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
211 (or file-name |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
212 (setq file-name (symbol-file function))) |
45193
3431e29f1d9c
(describe-function-1): If the source is `loaddefs.el', look for the
Markus Rost <rost@math.uni-bielefeld.de>
parents:
44291
diff
changeset
|
213 (when (equal file-name "loaddefs.el") |
3431e29f1d9c
(describe-function-1): If the source is `loaddefs.el', look for the
Markus Rost <rost@math.uni-bielefeld.de>
parents:
44291
diff
changeset
|
214 ;; Find the real def site of the preloaded function. |
3431e29f1d9c
(describe-function-1): If the source is `loaddefs.el', look for the
Markus Rost <rost@math.uni-bielefeld.de>
parents:
44291
diff
changeset
|
215 ;; This is necessary only for defaliases. |
3431e29f1d9c
(describe-function-1): If the source is `loaddefs.el', look for the
Markus Rost <rost@math.uni-bielefeld.de>
parents:
44291
diff
changeset
|
216 (let ((location |
3431e29f1d9c
(describe-function-1): If the source is `loaddefs.el', look for the
Markus Rost <rost@math.uni-bielefeld.de>
parents:
44291
diff
changeset
|
217 (condition-case nil |
3431e29f1d9c
(describe-function-1): If the source is `loaddefs.el', look for the
Markus Rost <rost@math.uni-bielefeld.de>
parents:
44291
diff
changeset
|
218 (find-function-search-for-symbol function nil "loaddefs.el") |
3431e29f1d9c
(describe-function-1): If the source is `loaddefs.el', look for the
Markus Rost <rost@math.uni-bielefeld.de>
parents:
44291
diff
changeset
|
219 (error nil)))) |
3431e29f1d9c
(describe-function-1): If the source is `loaddefs.el', look for the
Markus Rost <rost@math.uni-bielefeld.de>
parents:
44291
diff
changeset
|
220 (when location |
3431e29f1d9c
(describe-function-1): If the source is `loaddefs.el', look for the
Markus Rost <rost@math.uni-bielefeld.de>
parents:
44291
diff
changeset
|
221 (with-current-buffer (car location) |
3431e29f1d9c
(describe-function-1): If the source is `loaddefs.el', look for the
Markus Rost <rost@math.uni-bielefeld.de>
parents:
44291
diff
changeset
|
222 (goto-char (cdr location)) |
3431e29f1d9c
(describe-function-1): If the source is `loaddefs.el', look for the
Markus Rost <rost@math.uni-bielefeld.de>
parents:
44291
diff
changeset
|
223 (when (re-search-backward |
3431e29f1d9c
(describe-function-1): If the source is `loaddefs.el', look for the
Markus Rost <rost@math.uni-bielefeld.de>
parents:
44291
diff
changeset
|
224 "^;;; Generated autoloads from \\(.*\\)" nil t) |
3431e29f1d9c
(describe-function-1): If the source is `loaddefs.el', look for the
Markus Rost <rost@math.uni-bielefeld.de>
parents:
44291
diff
changeset
|
225 (setq file-name (match-string 1))))))) |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
226 (cond |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
227 (file-name |
42591
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
228 (princ " in `") |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
229 ;; We used to add .el to the file name, |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
230 ;; but that's completely wrong when the user used load-file. |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
231 (princ file-name) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
232 (princ "'") |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
233 ;; Make a hyperlink to the library. |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
234 (with-current-buffer standard-output |
42591
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
235 (save-excursion |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
236 (re-search-backward "`\\([^`']+\\)'" nil t) |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
237 (help-xref-button 1 'help-function-def function file-name))))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
238 (princ ".") |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
239 (terpri) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
240 (when (commandp function) |
43499
5f7255c11791
(describe-function-1): Use remap-command.
Kim F. Storm <storm@cua.dk>
parents:
43157
diff
changeset
|
241 (let* ((remapped (remap-command function)) |
43157
c72ba425c038
(describe-function-1): Report remapped commands.
Kim F. Storm <storm@cua.dk>
parents:
42591
diff
changeset
|
242 (keys (where-is-internal |
c72ba425c038
(describe-function-1): Report remapped commands.
Kim F. Storm <storm@cua.dk>
parents:
42591
diff
changeset
|
243 (or remapped function) overriding-local-map nil nil))) |
c72ba425c038
(describe-function-1): Report remapped commands.
Kim F. Storm <storm@cua.dk>
parents:
42591
diff
changeset
|
244 (when remapped |
c72ba425c038
(describe-function-1): Report remapped commands.
Kim F. Storm <storm@cua.dk>
parents:
42591
diff
changeset
|
245 (princ "It is remapped to `") |
c72ba425c038
(describe-function-1): Report remapped commands.
Kim F. Storm <storm@cua.dk>
parents:
42591
diff
changeset
|
246 (princ (symbol-name remapped)) |
c72ba425c038
(describe-function-1): Report remapped commands.
Kim F. Storm <storm@cua.dk>
parents:
42591
diff
changeset
|
247 (princ "'")) |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
248 (when keys |
43157
c72ba425c038
(describe-function-1): Report remapped commands.
Kim F. Storm <storm@cua.dk>
parents:
42591
diff
changeset
|
249 (princ (if remapped " which is bound to " "It is bound to ")) |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
250 ;; FIXME: This list can be very long (f.ex. for self-insert-command). |
43157
c72ba425c038
(describe-function-1): Report remapped commands.
Kim F. Storm <storm@cua.dk>
parents:
42591
diff
changeset
|
251 (princ (mapconcat 'key-description keys ", "))) |
c72ba425c038
(describe-function-1): Report remapped commands.
Kim F. Storm <storm@cua.dk>
parents:
42591
diff
changeset
|
252 (when (or remapped keys) |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
253 (princ ".") |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
254 (terpri)))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
255 ;; Handle symbols aliased to other symbols. |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
256 (setq def (indirect-function def)) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
257 ;; If definition is a macro, find the function inside it. |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
258 (if (eq (car-safe def) 'macro) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
259 (setq def (cdr def))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
260 (let ((arglist (cond ((byte-code-function-p def) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
261 (car (append def nil))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
262 ((eq (car-safe def) 'lambda) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
263 (nth 1 def)) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
264 ((and (eq (car-safe def) 'autoload) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
265 (not (eq (nth 4 def) 'keymap))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
266 (concat "[Arg list not available until " |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
267 "function definition is loaded.]")) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
268 (t t)))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
269 (cond ((listp arglist) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
270 (princ (cons (if (symbolp function) function "anonymous") |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
271 (mapcar (lambda (arg) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
272 (if (memq arg '(&optional &rest)) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
273 arg |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
274 (intern (upcase (symbol-name arg))))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
275 arglist))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
276 (terpri)) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
277 ((stringp arglist) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
278 (princ arglist) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
279 (terpri)))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
280 (let ((doc (documentation function))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
281 (if doc |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
282 (progn (terpri) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
283 (princ doc) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
284 (if (subrp def) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
285 (with-current-buffer standard-output |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
286 (beginning-of-line) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
287 ;; Builtins get the calling sequence at the end of |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
288 ;; the doc string. Move it to the same place as |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
289 ;; for other functions. |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
290 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
291 ;; In cases where `function' has been fset to a |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
292 ;; subr we can't search for function's name in |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
293 ;; the doc string. Kluge round that using the |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
294 ;; printed representation. The arg list then |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
295 ;; shows the wrong function name, but that |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
296 ;; might be a useful hint. |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
297 (let* ((rep (prin1-to-string def)) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
298 (name (progn |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
299 (string-match " \\([^ ]+\\)>$" rep) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
300 (match-string 1 rep)))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
301 (if (looking-at (format "(%s[ )]" (regexp-quote name))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
302 (let ((start (point-marker))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
303 (goto-char (point-min)) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
304 (forward-paragraph) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
305 (insert-buffer-substring (current-buffer) start) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
306 (insert ?\n) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
307 (delete-region (1- start) (point-max))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
308 (goto-char (point-min)) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
309 (forward-paragraph) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
310 (insert |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
311 "[Missing arglist. Please make a bug report.]\n"))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
312 (goto-char (point-max))))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
313 (princ "not documented"))))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
314 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
315 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
316 ;; Variables |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
317 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
318 ;;;###autoload |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
319 (defun variable-at-point () |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
320 "Return the bound variable symbol found around point. |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
321 Return 0 if there is no such symbol." |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
322 (condition-case () |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
323 (with-syntax-table emacs-lisp-mode-syntax-table |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
324 (save-excursion |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
325 (or (not (zerop (skip-syntax-backward "_w"))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
326 (eq (char-syntax (following-char)) ?w) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
327 (eq (char-syntax (following-char)) ?_) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
328 (forward-sexp -1)) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
329 (skip-chars-forward "'") |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
330 (let ((obj (read (current-buffer)))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
331 (or (and (symbolp obj) (boundp obj) obj) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
332 0)))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
333 (error 0))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
334 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
335 ;;;###autoload |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
336 (defun describe-variable (variable &optional buffer) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
337 "Display the full documentation of VARIABLE (a symbol). |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
338 Returns the documentation as a string, also. |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
339 If VARIABLE has a buffer-local value in BUFFER (default to the current buffer), |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
340 it is displayed along with the global value." |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
341 (interactive |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
342 (let ((v (variable-at-point)) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
343 (enable-recursive-minibuffers t) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
344 val) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
345 (setq val (completing-read (if (symbolp v) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
346 (format |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
347 "Describe variable (default %s): " v) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
348 "Describe variable: ") |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
349 obarray 'boundp t nil nil |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
350 (if (symbolp v) (symbol-name v)))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
351 (list (if (equal val "") |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
352 v (intern val))))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
353 (unless (bufferp buffer) (setq buffer (current-buffer))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
354 (if (not (symbolp variable)) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
355 (message "You did not specify a variable") |
42591
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
356 (save-excursion |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
357 (let (valvoid) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
358 (help-setup-xref (list #'describe-variable variable buffer) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
359 (interactive-p)) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
360 (with-output-to-temp-buffer (help-buffer) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
361 (with-current-buffer buffer |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
362 (prin1 variable) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
363 (if (not (boundp variable)) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
364 (progn |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
365 (princ " is void") |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
366 (setq valvoid t)) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
367 (let ((val (symbol-value variable))) |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
368 (with-current-buffer standard-output |
42591
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
369 (princ "'s value is ") |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
370 (terpri) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
371 (let ((from (point))) |
42591
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
372 (pp val) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
373 (help-xref-on-pp from (point)) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
374 (if (< (point) (+ from 20)) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
375 (save-excursion |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
376 (goto-char from) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
377 (delete-char -1))))))) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
378 (terpri) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
379 (when (local-variable-p variable) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
380 (princ (format "Local in buffer %s; " (buffer-name))) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
381 (if (not (default-boundp variable)) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
382 (princ "globally void") |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
383 (let ((val (default-value variable))) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
384 (with-current-buffer standard-output |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
385 (princ "global value is ") |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
386 (terpri) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
387 ;; Fixme: pp can take an age if you happen to |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
388 ;; ask for a very large expression. We should |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
389 ;; probably print it raw once and check it's a |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
390 ;; sensible size before prettyprinting. -- fx |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
391 (let ((from (point))) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
392 (pp val) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
393 (help-xref-on-pp from (point)) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
394 (if (< (point) (+ from 20)) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
395 (save-excursion |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
396 (goto-char from) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
397 (delete-char -1))))))) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
398 (terpri)) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
399 (terpri) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
400 (with-current-buffer standard-output |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
401 (when (> (count-lines (point-min) (point-max)) 10) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
402 ;; Note that setting the syntax table like below |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
403 ;; makes forward-sexp move over a `'s' at the end |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
404 ;; of a symbol. |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
405 (set-syntax-table emacs-lisp-mode-syntax-table) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
406 (goto-char (point-min)) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
407 (if valvoid |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
408 (forward-line 1) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
409 (forward-sexp 1) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
410 (delete-region (point) (progn (end-of-line) (point))) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
411 (insert " value is shown below.\n\n") |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
412 (save-excursion |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
413 (insert "\n\nValue:")))) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
414 ;; Add a note for variables that have been make-var-buffer-local. |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
415 (when (and (local-variable-if-set-p variable) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
416 (or (not (local-variable-p variable)) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
417 (with-temp-buffer |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
418 (local-variable-if-set-p variable)))) |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
419 (save-excursion |
42591
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
420 (forward-line -1) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
421 (insert "Automatically becomes buffer-local when set in any fashion.\n")))) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
422 (princ "Documentation:") |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
423 (terpri) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
424 (let ((doc (documentation-property variable 'variable-documentation))) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
425 (princ (or doc "not documented as a variable."))) |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
426 |
42591
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
427 ;; Make a link to customize if this variable can be customized. |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
428 ;; Note, it is not reliable to test only for a custom-type property |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
429 ;; because those are only present after the var's definition |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
430 ;; has been loaded. |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
431 (if (or (get variable 'custom-type) ; after defcustom |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
432 (get variable 'custom-loads) ; from loaddefs.el |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
433 (get variable 'standard-value)) ; from cus-start.el |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
434 (let ((customize-label "customize")) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
435 (terpri) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
436 (terpri) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
437 (princ (concat "You can " customize-label " this variable.")) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
438 (with-current-buffer standard-output |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
439 (save-excursion |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
440 (re-search-backward |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
441 (concat "\\(" customize-label "\\)") nil t) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
442 (help-xref-button 1 'help-customize-variable variable))))) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
443 ;; Make a hyperlink to the library if appropriate. (Don't |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
444 ;; change the format of the buffer's initial line in case |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
445 ;; anything expects the current format.) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
446 (let ((file-name (symbol-file variable))) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
447 (when (equal file-name "loaddefs.el") |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
448 ;; Find the real def site of the preloaded variable. |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
449 (let ((location |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
450 (condition-case nil |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
451 (find-variable-noselect variable file-name) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
452 (error nil)))) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
453 (when location |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
454 (with-current-buffer (car location) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
455 (goto-char (cdr location)) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
456 (when (re-search-backward |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
457 "^;;; Generated autoloads from \\(.*\\)" nil t) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
458 (setq file-name (match-string 1))))))) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
459 (when file-name |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
460 (princ "\n\nDefined in `") |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
461 (princ file-name) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
462 (princ "'.") |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
463 (with-current-buffer standard-output |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
464 (save-excursion |
42591
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
465 (re-search-backward "`\\([^`']+\\)'" nil t) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
466 (help-xref-button 1 'help-variable-def |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
467 variable file-name))))) |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
468 |
42591
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
469 (print-help-return-message) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
470 (save-excursion |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
471 (set-buffer standard-output) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
472 ;; Return the text we displayed. |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
473 (buffer-string)))))))) |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
474 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
475 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
476 ;;;###autoload |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
477 (defun describe-syntax (&optional buffer) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
478 "Describe the syntax specifications in the syntax table of BUFFER. |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
479 The descriptions are inserted in a help buffer, which is then displayed. |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
480 BUFFER defaults to the current buffer." |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
481 (interactive) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
482 (setq buffer (or buffer (current-buffer))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
483 (help-setup-xref (list #'describe-syntax buffer) (interactive-p)) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
484 (with-output-to-temp-buffer (help-buffer) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
485 (let ((table (with-current-buffer buffer (syntax-table)))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
486 (with-current-buffer standard-output |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
487 (describe-vector table 'internal-describe-syntax-value) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
488 (while (setq table (char-table-parent table)) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
489 (insert "\nThe parent syntax table is:") |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
490 (describe-vector table 'internal-describe-syntax-value)))))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
491 |
41600
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
492 (defun help-describe-category-set (value) |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
493 (insert (cond |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
494 ((null value) "default") |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
495 ((char-table-p value) "deeper char-table ...") |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
496 (t (condition-case err |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
497 (category-set-mnemonics value) |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
498 (error "invalid")))))) |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
499 |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
500 ;;;###autoload |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
501 (defun describe-categories (&optional buffer) |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
502 "Describe the category specifications in the current category table. |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
503 The descriptions are inserted in a buffer, which is then displayed." |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
504 (interactive) |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
505 (setq buffer (or buffer (current-buffer))) |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
506 (help-setup-xref (list #'describe-categories buffer) (interactive-p)) |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
507 (with-output-to-temp-buffer (help-buffer) |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
508 (let ((table (with-current-buffer buffer (category-table)))) |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
509 (with-current-buffer standard-output |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
510 (describe-vector table 'help-describe-category-set) |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
511 (let ((docs (char-table-extra-slot table 0))) |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
512 (if (or (not (vectorp docs)) (/= (length docs) 95)) |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
513 (insert "Invalid first extra slot in this char table\n") |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
514 (insert "Meanings of mnemonic characters are:\n") |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
515 (dotimes (i 95) |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
516 (let ((elt (aref docs i))) |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
517 (when elt |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
518 (insert (+ i ?\ ) ": " elt "\n")))) |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
519 (while (setq table (char-table-parent table)) |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
520 (insert "\nThe parent category table is:") |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
521 (describe-vector table 'help-describe-category-set)))))))) |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
522 |
41584
8b64dc23e305
Change the provide and the header as per the renaming.
Eli Zaretskii <eliz@gnu.org>
parents:
41583
diff
changeset
|
523 (provide 'help-fns) |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
524 |
41584
8b64dc23e305
Change the provide and the header as per the renaming.
Eli Zaretskii <eliz@gnu.org>
parents:
41583
diff
changeset
|
525 ;;; help-fns.el ends here |