Mercurial > emacs
annotate lisp/help-fns.el @ 46476:2b7a72428d13
(set_file_times): Declaration updated.
author | Ken Raeburn <raeburn@raeburn.org> |
---|---|
date | Tue, 16 Jul 2002 19:49:04 +0000 |
parents | 255c2fbbad1f |
children | 521c1e2e7512 |
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 |
45975
7ea38f55545b
(describe-variable): Only use `buffer' is still live.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45193
diff
changeset
|
3 ;; Copyright (C) 1985, 1986, 1993, 1994, 1998, 1999, 2000, 2001, 2002 |
41583
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 |
46334
3b9bda9aa32d
(help-with-tutorial): Display completion list right away.
Richard M. Stallman <rms@gnu.org>
parents:
46321
diff
changeset
|
48 (progn |
3b9bda9aa32d
(help-with-tutorial): Display completion list right away.
Richard M. Stallman <rms@gnu.org>
parents:
46321
diff
changeset
|
49 ;; Display a completion list right away |
3b9bda9aa32d
(help-with-tutorial): Display completion list right away.
Richard M. Stallman <rms@gnu.org>
parents:
46321
diff
changeset
|
50 ;; to guide the user. |
3b9bda9aa32d
(help-with-tutorial): Display completion list right away.
Richard M. Stallman <rms@gnu.org>
parents:
46321
diff
changeset
|
51 (with-output-to-temp-buffer "*Completions*" |
3b9bda9aa32d
(help-with-tutorial): Display completion list right away.
Richard M. Stallman <rms@gnu.org>
parents:
46321
diff
changeset
|
52 (display-completion-list |
3b9bda9aa32d
(help-with-tutorial): Display completion list right away.
Richard M. Stallman <rms@gnu.org>
parents:
46321
diff
changeset
|
53 (all-completions "" language-info-alist |
3b9bda9aa32d
(help-with-tutorial): Display completion list right away.
Richard M. Stallman <rms@gnu.org>
parents:
46321
diff
changeset
|
54 (lambda (elm) |
3b9bda9aa32d
(help-with-tutorial): Display completion list right away.
Richard M. Stallman <rms@gnu.org>
parents:
46321
diff
changeset
|
55 (and (listp elm) (assq 'tutorial elm)))))) |
3b9bda9aa32d
(help-with-tutorial): Display completion list right away.
Richard M. Stallman <rms@gnu.org>
parents:
46321
diff
changeset
|
56 (read-language-name 'tutorial "Language: " "English")) |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
57 (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
|
58 current-language-environment |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
59 "English"))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
60 file filename) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
61 (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
|
62 (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
|
63 (delete-other-windows) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
64 (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
|
65 (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
|
66 (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
|
67 (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
|
68 (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
|
69 (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
|
70 (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
|
71 (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
|
72 (search-forward "\n<<") |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
73 (beginning-of-line) |
44291
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
74 ;; Convert the <<...>> line to the proper [...] line, |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
75 ;; 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
|
76 (cond ((save-excursion |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
77 (forward-line 1) |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
78 (looking-at "\\[")) |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
79 (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
|
80 ((looking-at "<<Blank lines inserted.*>>") |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
81 (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
|
82 (t |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
83 (looking-at "<<") |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
84 (replace-match "[") |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
85 (search-forward ">>") |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
86 (replace-match "]"))) |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
87 (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
|
88 (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
|
89 (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
|
90 6))) |
44291
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
91 (if (< n 8) |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
92 (progn |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
93 ;; 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
|
94 ;; so delete it. |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
95 (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
|
96 (newline n)) |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
97 ;; 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
|
98 (newline (/ n 2)) |
44291
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
99 |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
100 ;; Skip the [...] line (don't delete it). |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
101 (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
|
102 (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
|
103 (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
|
104 (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
|
105 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
106 ;;;###autoload |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
107 (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
|
108 "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
|
109 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
|
110 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
|
111 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
|
112 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
|
113 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
114 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
|
115 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
|
116 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
117 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
|
118 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
|
119 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
|
120 (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
|
121 nil nil |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
122 t)) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
123 (catch 'answer |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
124 (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
|
125 (dolist (suf (append (unless nosuffix load-suffixes) '(""))) |
45975
7ea38f55545b
(describe-variable): Only use `buffer' is still live.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45193
diff
changeset
|
126 (let ((try (expand-file-name (concat library suf) dir))) |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
127 (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
|
128 (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
|
129 (progn |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
130 (if interactive-call |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
131 (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
|
132 (throw 'answer try)))))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
133 (if interactive-call |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
134 (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
|
135 nil)) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
136 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
137 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
138 ;; Functions |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
139 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
140 ;;;###autoload |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
141 (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
|
142 "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
|
143 (interactive |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
144 (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
|
145 (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
|
146 val) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
147 (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
|
148 (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
|
149 "Describe function: ") |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
150 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
|
151 (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
|
152 fn (intern val))))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
153 (if (null function) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
154 (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
|
155 (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
|
156 (save-excursion |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
157 (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
|
158 (prin1 function) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
159 ;; 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
|
160 ;; 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
|
161 (princ " is ") |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
162 (describe-function-1 function) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
163 (print-help-return-message) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
164 (with-current-buffer standard-output |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
165 ;; Return the text we displayed. |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
166 (buffer-string)))))) |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
167 |
46439
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
168 (defun help-split-fundoc (doc &optional def) |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
169 "Split a function docstring DOC into the actual doc and the usage info. |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
170 Return (USAGE . DOC) or nil if there's no usage info." |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
171 ;; Builtins get the calling sequence at the end of the doc string. |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
172 ;; In cases where `function' has been fset to a subr we can't search for |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
173 ;; function's name in the doc string. Kluge round that using the printed |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
174 ;; representation. The arg list then shows the wrong function name, but |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
175 ;; that might be a useful hint. |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
176 (let* ((rep (prin1-to-string def)) |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
177 (name (if (string-match " \\([^ ]+\\)>$" rep) |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
178 (match-string 1 rep) "fun"))) |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
179 (if (string-match (format "^(%s[ )].*\\'" (regexp-quote name)) doc) |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
180 (cons (match-string 0 doc) |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
181 (substring doc 0 (match-beginning 0)))))) |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
182 |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
183 (defun help-function-arglist (def) |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
184 (cond |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
185 ((byte-code-function-p def) (aref def 0)) |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
186 ((eq (car-safe def) 'lambda) (nth 1 def)) |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
187 ((and (eq (car-safe def) 'autoload) (not (eq (nth 4 def) 'keymap))) |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
188 "[Arg list not available until function definition is loaded.]") |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
189 (t t))) |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
190 |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
191 (defun help-make-usage (function arglist) |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
192 (cons (if (symbolp function) function 'anonymous) |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
193 (mapcar (lambda (arg) |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
194 (if (not (symbolp arg)) arg |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
195 (let ((name (symbol-name arg))) |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
196 (if (string-match "\\`&" name) arg |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
197 (intern (upcase name)))))) |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
198 arglist))) |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
199 |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
200 ;;;###autoload |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
201 (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
|
202 (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
|
203 (symbol-function function) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
204 function)) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
205 file-name string |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
206 (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
|
207 (setq string |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
208 (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
|
209 (vectorp def)) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
210 "a keyboard macro") |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
211 ((subrp def) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
212 (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
|
213 (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
|
214 (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
|
215 ((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
|
216 (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
|
217 ((symbolp def) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
218 (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
|
219 (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
|
220 (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
|
221 ((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
|
222 (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
|
223 ((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
|
224 "a Lisp macro") |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
225 ((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
|
226 (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
|
227 (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
|
228 (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
|
229 (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
|
230 (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
|
231 )) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
232 ;; 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
|
233 ((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
|
234 (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
|
235 (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
|
236 (while elts |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
237 (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
|
238 (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
|
239 elts nil)) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
240 (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
|
241 (if is-full |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
242 "a full keymap" |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
243 "a sparse keymap"))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
244 (t ""))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
245 (princ string) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
246 (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
|
247 (save-excursion |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
248 (save-match-data |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
249 (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
|
250 (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
|
251 (or file-name |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
252 (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
|
253 (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
|
254 ;; 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
|
255 ;; 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
|
256 (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
|
257 (condition-case nil |
45975
7ea38f55545b
(describe-variable): Only use `buffer' is still live.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45193
diff
changeset
|
258 (find-function-search-for-symbol function nil "loaddefs.el") |
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
|
259 (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
|
260 (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
|
261 (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
|
262 (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
|
263 (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
|
264 "^;;; 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
|
265 (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
|
266 (cond |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
267 (file-name |
42591
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
268 (princ " in `") |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
269 ;; 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
|
270 ;; 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
|
271 (princ file-name) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
272 (princ "'") |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
273 ;; 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
|
274 (with-current-buffer standard-output |
42591
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
275 (save-excursion |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
276 (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
|
277 (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
|
278 (princ ".") |
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 (when (commandp function) |
43499
5f7255c11791
(describe-function-1): Use remap-command.
Kim F. Storm <storm@cua.dk>
parents:
43157
diff
changeset
|
281 (let* ((remapped (remap-command function)) |
43157
c72ba425c038
(describe-function-1): Report remapped commands.
Kim F. Storm <storm@cua.dk>
parents:
42591
diff
changeset
|
282 (keys (where-is-internal |
46439
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
283 (or remapped function) overriding-local-map nil nil))) |
43157
c72ba425c038
(describe-function-1): Report remapped commands.
Kim F. Storm <storm@cua.dk>
parents:
42591
diff
changeset
|
284 (when remapped |
c72ba425c038
(describe-function-1): Report remapped commands.
Kim F. Storm <storm@cua.dk>
parents:
42591
diff
changeset
|
285 (princ "It is remapped to `") |
c72ba425c038
(describe-function-1): Report remapped commands.
Kim F. Storm <storm@cua.dk>
parents:
42591
diff
changeset
|
286 (princ (symbol-name remapped)) |
c72ba425c038
(describe-function-1): Report remapped commands.
Kim F. Storm <storm@cua.dk>
parents:
42591
diff
changeset
|
287 (princ "'")) |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
288 (when keys |
43157
c72ba425c038
(describe-function-1): Report remapped commands.
Kim F. Storm <storm@cua.dk>
parents:
42591
diff
changeset
|
289 (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
|
290 ;; 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
|
291 (princ (mapconcat 'key-description keys ", "))) |
c72ba425c038
(describe-function-1): Report remapped commands.
Kim F. Storm <storm@cua.dk>
parents:
42591
diff
changeset
|
292 (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
|
293 (princ ".") |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
294 (terpri)))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
295 ;; 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
|
296 (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
|
297 ;; 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
|
298 (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
|
299 (setq def (cdr def))) |
46439
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
300 (let* ((arglist (help-function-arglist def)) |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
301 (doc (documentation function)) |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
302 usage) |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
303 (princ (cond |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
304 ((listp arglist) (help-make-usage function arglist)) |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
305 ((stringp arglist) arglist) |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
306 ((and doc (subrp def) (setq usage (help-split-fundoc doc def))) |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
307 (setq doc (cdr usage)) (car usage)) |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
308 (t "[Missing arglist. Please make a bug report.]"))) |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
309 (terpri) |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
310 (let ((obsolete (get function 'byte-obsolete-info))) |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
311 (when obsolete |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
312 (terpri) |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
313 (princ "This function is obsolete") |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
314 (if (nth 2 obsolete) (princ (format " since %s" (nth 2 obsolete)))) |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
315 (princ ";") (terpri) |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
316 (princ (if (stringp (car obsolete)) (car obsolete) |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
317 (format "use `%s' instead." (car obsolete)))) |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
318 (terpri))) |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
319 (if doc |
46439
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
320 (progn (terpri) (princ doc)) |
46042
0e4c329e9ab6
(describe-variable): Capitalize "not documented" message.
Juanma Barranquero <lekktu@gmail.com>
parents:
45975
diff
changeset
|
321 (princ "Not documented."))))) |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
322 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
323 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
324 ;; Variables |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
325 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
326 ;;;###autoload |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
327 (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
|
328 "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
|
329 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
|
330 (condition-case () |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
331 (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
|
332 (save-excursion |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
333 (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
|
334 (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
|
335 (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
|
336 (forward-sexp -1)) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
337 (skip-chars-forward "'") |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
338 (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
|
339 (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
|
340 0)))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
341 (error 0))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
342 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
343 ;;;###autoload |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
344 (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
|
345 "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
|
346 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
|
347 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
|
348 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
|
349 (interactive |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
350 (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
|
351 (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
|
352 val) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
353 (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
|
354 (format |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
355 "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
|
356 "Describe variable: ") |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
357 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
|
358 (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
|
359 (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
|
360 v (intern val))))) |
45975
7ea38f55545b
(describe-variable): Only use `buffer' is still live.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45193
diff
changeset
|
361 (unless (buffer-live-p buffer) (setq buffer (current-buffer))) |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
362 (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
|
363 (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
|
364 (save-excursion |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
365 (let (valvoid) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
366 (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
|
367 (interactive-p)) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
368 (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
|
369 (with-current-buffer buffer |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
370 (prin1 variable) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
371 (if (not (boundp variable)) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
372 (progn |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
373 (princ " is void") |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
374 (setq valvoid t)) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
375 (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
|
376 (with-current-buffer standard-output |
42591
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
377 (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
|
378 (terpri) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
379 (let ((from (point))) |
42591
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
380 (pp val) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
381 (help-xref-on-pp from (point)) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
382 (if (< (point) (+ from 20)) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
383 (save-excursion |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
384 (goto-char from) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
385 (delete-char -1))))))) |
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 (when (local-variable-p variable) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
388 (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
|
389 (if (not (default-boundp variable)) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
390 (princ "globally void") |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
391 (let ((val (default-value variable))) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
392 (with-current-buffer standard-output |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
393 (princ "global value is ") |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
394 (terpri) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
395 ;; 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
|
396 ;; 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
|
397 ;; 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
|
398 ;; sensible size before prettyprinting. -- fx |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
399 (let ((from (point))) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
400 (pp val) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
401 (help-xref-on-pp from (point)) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
402 (if (< (point) (+ from 20)) |
45975
7ea38f55545b
(describe-variable): Only use `buffer' is still live.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45193
diff
changeset
|
403 (delete-region (1- from) from)))))) |
42591
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
404 (terpri)) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
405 (terpri) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
406 (with-current-buffer standard-output |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
407 (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
|
408 ;; 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
|
409 ;; 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
|
410 ;; of a symbol. |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
411 (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
|
412 (goto-char (point-min)) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
413 (if valvoid |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
414 (forward-line 1) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
415 (forward-sexp 1) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
416 (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
|
417 (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
|
418 (save-excursion |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
419 (insert "\n\nValue:")))) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
420 ;; 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
|
421 (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
|
422 (or (not (local-variable-p variable)) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
423 (with-temp-buffer |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
424 (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
|
425 (save-excursion |
42591
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
426 (forward-line -1) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
427 (insert "Automatically becomes buffer-local when set in any fashion.\n")))) |
46321
1d8304aae3cc
(describe-variable): Put `defvaralias' info before the documentation (patch from
Juanma Barranquero <lekktu@gmail.com>
parents:
46312
diff
changeset
|
428 ;; Mention if it's an alias |
46389
51248f96252a
(describe-variable): Show documentation for aliased variable if alias does not
Juanma Barranquero <lekktu@gmail.com>
parents:
46334
diff
changeset
|
429 (let* ((alias (condition-case nil |
46321
1d8304aae3cc
(describe-variable): Put `defvaralias' info before the documentation (patch from
Juanma Barranquero <lekktu@gmail.com>
parents:
46312
diff
changeset
|
430 (indirect-variable variable) |
46389
51248f96252a
(describe-variable): Show documentation for aliased variable if alias does not
Juanma Barranquero <lekktu@gmail.com>
parents:
46334
diff
changeset
|
431 (error variable))) |
51248f96252a
(describe-variable): Show documentation for aliased variable if alias does not
Juanma Barranquero <lekktu@gmail.com>
parents:
46334
diff
changeset
|
432 (obsolete (get variable 'byte-obsolete-variable)) |
51248f96252a
(describe-variable): Show documentation for aliased variable if alias does not
Juanma Barranquero <lekktu@gmail.com>
parents:
46334
diff
changeset
|
433 (doc (or (documentation-property variable 'variable-documentation) |
51248f96252a
(describe-variable): Show documentation for aliased variable if alias does not
Juanma Barranquero <lekktu@gmail.com>
parents:
46334
diff
changeset
|
434 (documentation-property alias 'variable-documentation)))) |
46321
1d8304aae3cc
(describe-variable): Put `defvaralias' info before the documentation (patch from
Juanma Barranquero <lekktu@gmail.com>
parents:
46312
diff
changeset
|
435 (unless (eq alias variable) |
1d8304aae3cc
(describe-variable): Put `defvaralias' info before the documentation (patch from
Juanma Barranquero <lekktu@gmail.com>
parents:
46312
diff
changeset
|
436 (princ (format "This variable is an alias for `%s'." alias)) |
1d8304aae3cc
(describe-variable): Put `defvaralias' info before the documentation (patch from
Juanma Barranquero <lekktu@gmail.com>
parents:
46312
diff
changeset
|
437 (terpri) |
46389
51248f96252a
(describe-variable): Show documentation for aliased variable if alias does not
Juanma Barranquero <lekktu@gmail.com>
parents:
46334
diff
changeset
|
438 (terpri)) |
51248f96252a
(describe-variable): Show documentation for aliased variable if alias does not
Juanma Barranquero <lekktu@gmail.com>
parents:
46334
diff
changeset
|
439 (when obsolete |
51248f96252a
(describe-variable): Show documentation for aliased variable if alias does not
Juanma Barranquero <lekktu@gmail.com>
parents:
46334
diff
changeset
|
440 (princ "This variable is obsolete") |
51248f96252a
(describe-variable): Show documentation for aliased variable if alias does not
Juanma Barranquero <lekktu@gmail.com>
parents:
46334
diff
changeset
|
441 (if (cdr obsolete) (princ (format " since %s" (cdr obsolete)))) |
46393
4f6ec0250812
(describe-variable): Remove useless trailing whitespace.
Juanma Barranquero <lekktu@gmail.com>
parents:
46389
diff
changeset
|
442 (princ ";") (terpri) |
46389
51248f96252a
(describe-variable): Show documentation for aliased variable if alias does not
Juanma Barranquero <lekktu@gmail.com>
parents:
46334
diff
changeset
|
443 (princ (if (stringp (car obsolete)) (car obsolete) |
51248f96252a
(describe-variable): Show documentation for aliased variable if alias does not
Juanma Barranquero <lekktu@gmail.com>
parents:
46334
diff
changeset
|
444 (format "use `%s' instead." (car obsolete)))) |
51248f96252a
(describe-variable): Show documentation for aliased variable if alias does not
Juanma Barranquero <lekktu@gmail.com>
parents:
46334
diff
changeset
|
445 (terpri) |
51248f96252a
(describe-variable): Show documentation for aliased variable if alias does not
Juanma Barranquero <lekktu@gmail.com>
parents:
46334
diff
changeset
|
446 (terpri)) |
51248f96252a
(describe-variable): Show documentation for aliased variable if alias does not
Juanma Barranquero <lekktu@gmail.com>
parents:
46334
diff
changeset
|
447 (princ (or doc "Not documented as a variable."))) |
42591
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
448 ;; 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
|
449 ;; 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
|
450 ;; 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
|
451 ;; has been loaded. |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
452 (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
|
453 (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
|
454 (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
|
455 (let ((customize-label "customize")) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
456 (terpri) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
457 (terpri) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
458 (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
|
459 (with-current-buffer standard-output |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
460 (save-excursion |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
461 (re-search-backward |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
462 (concat "\\(" customize-label "\\)") nil t) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
463 (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
|
464 ;; 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
|
465 ;; 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
|
466 ;; anything expects the current format.) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
467 (let ((file-name (symbol-file variable))) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
468 (when (equal file-name "loaddefs.el") |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
469 ;; 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
|
470 (let ((location |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
471 (condition-case nil |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
472 (find-variable-noselect variable file-name) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
473 (error nil)))) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
474 (when location |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
475 (with-current-buffer (car location) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
476 (goto-char (cdr location)) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
477 (when (re-search-backward |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
478 "^;;; Generated autoloads from \\(.*\\)" nil t) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
479 (setq file-name (match-string 1))))))) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
480 (when file-name |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
481 (princ "\n\nDefined in `") |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
482 (princ file-name) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
483 (princ "'.") |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
484 (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
|
485 (save-excursion |
42591
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
486 (re-search-backward "`\\([^`']+\\)'" nil t) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
487 (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
|
488 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
|
489 |
42591
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
490 (print-help-return-message) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
491 (save-excursion |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
492 (set-buffer standard-output) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
493 ;; Return the text we displayed. |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
494 (buffer-string)))))))) |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
495 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
496 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
497 ;;;###autoload |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
498 (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
|
499 "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
|
500 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
|
501 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
|
502 (interactive) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
503 (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
|
504 (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
|
505 (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
|
506 (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
|
507 (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
|
508 (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
|
509 (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
|
510 (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
|
511 (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
|
512 |
41600
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
513 (defun help-describe-category-set (value) |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
514 (insert (cond |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
515 ((null value) "default") |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
516 ((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
|
517 (t (condition-case err |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
518 (category-set-mnemonics value) |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
519 (error "invalid")))))) |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
520 |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
521 ;;;###autoload |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
522 (defun describe-categories (&optional buffer) |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
523 "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
|
524 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
|
525 (interactive) |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
526 (setq buffer (or buffer (current-buffer))) |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
527 (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
|
528 (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
|
529 (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
|
530 (with-current-buffer standard-output |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
531 (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
|
532 (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
|
533 (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
|
534 (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
|
535 (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
|
536 (dotimes (i 95) |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
537 (let ((elt (aref docs i))) |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
538 (when elt |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
539 (insert (+ i ?\ ) ": " elt "\n")))) |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
540 (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
|
541 (insert "\nThe parent category table is:") |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
542 (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
|
543 |
41584
8b64dc23e305
Change the provide and the header as per the renaming.
Eli Zaretskii <eliz@gnu.org>
parents:
41583
diff
changeset
|
544 (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
|
545 |
41584
8b64dc23e305
Change the provide and the header as per the renaming.
Eli Zaretskii <eliz@gnu.org>
parents:
41583
diff
changeset
|
546 ;;; help-fns.el ends here |