Mercurial > emacs
annotate lisp/help-fns.el @ 88212:d78deb813644
Updated copyright year.
author | Alex Schroeder <alex@gnu.org> |
---|---|
date | Wed, 18 Jan 2006 22:15:21 +0000 |
parents | d7ddb3e565de |
children |
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 |
88155 | 3 ;; Copyright (C) 1985, 1986, 1993, 1994, 1998, 1999, 2000, 2001, |
4 ;; 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. | |
41583
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 |
88155 | 23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
24 ;; Boston, MA 02110-1301, USA. | |
41583
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. |
47663
e9121795960f
(help-with-tutorial): Use minibuffer-completion-help.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47236
diff
changeset
|
45 With ARG, you are asked to choose which language." |
41583
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 |
88155 | 48 (let ((minibuffer-setup-hook minibuffer-setup-hook)) |
49 (add-hook 'minibuffer-setup-hook | |
50 'minibuffer-completion-help) | |
51 (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
|
52 (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
|
53 current-language-environment |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
54 "English"))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
55 file filename) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
56 (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
|
57 (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
|
58 (delete-other-windows) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
59 (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
|
60 (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
|
61 (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
|
62 (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
|
63 (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
|
64 (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
|
65 (insert-file-contents (expand-file-name filename data-directory)) |
88155 | 66 (hack-local-variables) |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
67 (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
|
68 (search-forward "\n<<") |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
69 (beginning-of-line) |
44291
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
70 ;; Convert the <<...>> line to the proper [...] line, |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
71 ;; 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
|
72 (cond ((save-excursion |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
73 (forward-line 1) |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
74 (looking-at "\\[")) |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
75 (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
|
76 ((looking-at "<<Blank lines inserted.*>>") |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
77 (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
|
78 (t |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
79 (looking-at "<<") |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
80 (replace-match "[") |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
81 (search-forward ">>") |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
82 (replace-match "]"))) |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
83 (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
|
84 (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
|
85 (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
|
86 6))) |
44291
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
87 (if (< n 8) |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
88 (progn |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
89 ;; 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
|
90 ;; so delete it. |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
91 (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
|
92 (newline n)) |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
93 ;; 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
|
94 (newline (/ n 2)) |
49588
37645a051842
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49102
diff
changeset
|
95 |
44291
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
96 ;; Skip the [...] line (don't delete it). |
cf7a8ea9f88d
(help-with-tutorial): Allow various ways
Richard M. Stallman <rms@gnu.org>
parents:
43499
diff
changeset
|
97 (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
|
98 (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
|
99 (goto-char (point-min)) |
88155 | 100 (setq buffer-undo-list nil) |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
101 (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
|
102 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
103 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
104 ;; Functions |
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 describe-function (function) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
108 "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
|
109 (interactive |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
110 (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
|
111 (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
|
112 val) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
113 (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
|
114 (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
|
115 "Describe function: ") |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
116 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
|
117 (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
|
118 fn (intern val))))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
119 (if (null function) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
120 (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
|
121 (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
|
122 (save-excursion |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
123 (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
|
124 (prin1 function) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
125 ;; 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
|
126 ;; 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
|
127 (princ " is ") |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
128 (describe-function-1 function) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
129 (print-help-return-message) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
130 (with-current-buffer standard-output |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
131 ;; Return the text we displayed. |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
132 (buffer-string)))))) |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
133 |
88155 | 134 (defun help-split-fundoc (docstring def) |
135 "Split a function DOCSTRING into the actual doc and the usage info. | |
46957
ac5b720640e7
(help-split-fundoc): Replace the function name
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46901
diff
changeset
|
136 Return (USAGE . DOC) or nil if there's no usage info. |
88155 | 137 DEF is the function whose usage we're looking for in DOCSTRING." |
46957
ac5b720640e7
(help-split-fundoc): Replace the function name
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46901
diff
changeset
|
138 ;; Functions can get the calling sequence at the end of the doc string. |
46439
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
139 ;; In cases where `function' has been fset to a subr we can't search for |
46957
ac5b720640e7
(help-split-fundoc): Replace the function name
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46901
diff
changeset
|
140 ;; function's name in the doc string so we use `fn' as the anonymous |
ac5b720640e7
(help-split-fundoc): Replace the function name
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46901
diff
changeset
|
141 ;; function name instead. |
88155 | 142 (when (and docstring (string-match "\n\n(fn\\(\\( .*\\)?)\\)\\'" docstring)) |
47663
e9121795960f
(help-with-tutorial): Use minibuffer-completion-help.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47236
diff
changeset
|
143 (cons (format "(%s%s" |
e9121795960f
(help-with-tutorial): Use minibuffer-completion-help.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47236
diff
changeset
|
144 ;; Replace `fn' with the actual function name. |
e9121795960f
(help-with-tutorial): Use minibuffer-completion-help.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47236
diff
changeset
|
145 (if (consp def) "anonymous" def) |
88155 | 146 (match-string 1 docstring)) |
147 (substring docstring 0 (match-beginning 0))))) | |
47663
e9121795960f
(help-with-tutorial): Use minibuffer-completion-help.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47236
diff
changeset
|
148 |
88155 | 149 (defun help-add-fundoc-usage (docstring arglist) |
150 "Add the usage info to DOCSTRING. | |
151 If DOCSTRING already has a usage info, then just return it unchanged. | |
152 The usage info is built from ARGLIST. DOCSTRING can be nil. | |
153 ARGLIST can also be t or a string of the form \"(FUN ARG1 ARG2 ...)\"." | |
154 (unless (stringp docstring) (setq docstring "Not documented")) | |
155 (if (or (string-match "\n\n(fn\\(\\( .*\\)?)\\)\\'" docstring) (eq arglist t)) | |
156 docstring | |
157 (concat docstring | |
158 (if (string-match "\n?\n\\'" docstring) | |
159 (if (< (- (match-end 0) (match-beginning 0)) 2) "\n" "") | |
47663
e9121795960f
(help-with-tutorial): Use minibuffer-completion-help.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47236
diff
changeset
|
160 "\n\n") |
88155 | 161 (if (and (stringp arglist) |
162 (string-match "\\`([^ ]+\\(.*\\))\\'" arglist)) | |
163 (concat "(fn" (match-string 1 arglist) ")") | |
164 (format "%S" (help-make-usage 'fn arglist)))))) | |
46439
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
165 |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
166 (defun help-function-arglist (def) |
46901
3e733b163fd4
(locate-library): Use locate-file(-completion).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46827
diff
changeset
|
167 ;; Handle symbols aliased to other symbols. |
3e733b163fd4
(locate-library): Use locate-file(-completion).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46827
diff
changeset
|
168 (if (and (symbolp def) (fboundp def)) (setq def (indirect-function def))) |
3e733b163fd4
(locate-library): Use locate-file(-completion).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46827
diff
changeset
|
169 ;; If definition is a macro, find the function inside it. |
3e733b163fd4
(locate-library): Use locate-file(-completion).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46827
diff
changeset
|
170 (if (eq (car-safe def) 'macro) (setq def (cdr def))) |
46439
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
171 (cond |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
172 ((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
|
173 ((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
|
174 ((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
|
175 "[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
|
176 (t t))) |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
177 |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
178 (defun help-make-usage (function arglist) |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
179 (cons (if (symbolp function) function 'anonymous) |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
180 (mapcar (lambda (arg) |
46957
ac5b720640e7
(help-split-fundoc): Replace the function name
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46901
diff
changeset
|
181 (if (not (symbolp arg)) |
ac5b720640e7
(help-split-fundoc): Replace the function name
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46901
diff
changeset
|
182 (if (and (consp arg) (symbolp (car arg))) |
ac5b720640e7
(help-split-fundoc): Replace the function name
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46901
diff
changeset
|
183 ;; CL style default values for optional args. |
ac5b720640e7
(help-split-fundoc): Replace the function name
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46901
diff
changeset
|
184 (cons (intern (upcase (symbol-name (car arg)))) |
ac5b720640e7
(help-split-fundoc): Replace the function name
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46901
diff
changeset
|
185 (cdr arg)) |
ac5b720640e7
(help-split-fundoc): Replace the function name
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46901
diff
changeset
|
186 arg) |
46439
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
187 (let ((name (symbol-name arg))) |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
188 (if (string-match "\\`&" name) arg |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
189 (intern (upcase name)))))) |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
190 arglist))) |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
191 |
88155 | 192 ;; Could be this, if we make symbol-file do the work below. |
193 ;; (defun help-C-file-name (subr-or-var kind) | |
194 ;; "Return the name of the C file where SUBR-OR-VAR is defined. | |
195 ;; KIND should be `var' for a variable or `subr' for a subroutine." | |
196 ;; (symbol-file (if (symbolp subr-or-var) subr-or-var | |
197 ;; (subr-name subr-or-var)) | |
198 ;; (if (eq kind 'var) 'defvar 'defun))) | |
199 ;;;###autoload | |
200 (defun help-C-file-name (subr-or-var kind) | |
201 "Return the name of the C file where SUBR-OR-VAR is defined. | |
202 KIND should be `var' for a variable or `subr' for a subroutine." | |
203 (let ((docbuf (get-buffer-create " *DOC*")) | |
204 (name (if (eq 'var kind) | |
205 (concat "V" (symbol-name subr-or-var)) | |
206 (concat "F" (subr-name subr-or-var))))) | |
207 (with-current-buffer docbuf | |
208 (goto-char (point-min)) | |
209 (if (eobp) | |
210 (insert-file-contents-literally | |
211 (expand-file-name internal-doc-file-name doc-directory))) | |
212 (let ((file (catch 'loop | |
213 (while t | |
214 (let ((pnt (search-forward (concat "" name "\n")))) | |
215 (re-search-backward "S\\(.*\\)") | |
216 (let ((file (match-string 1))) | |
217 (if (member file build-files) | |
218 (throw 'loop file) | |
219 (goto-char pnt)))))))) | |
220 (if (string-match "\\.\\(o\\|obj\\)\\'" file) | |
221 (setq file (replace-match ".c" t t file))) | |
222 (if (string-match "\\.c\\'" file) | |
223 (concat "src/" file) | |
224 file))))) | |
225 | |
226 (defface help-argument-name '((((supports :slant italic)) :inherit italic)) | |
227 "Face to highlight argument names in *Help* buffers." | |
228 :group 'help) | |
229 | |
230 (defun help-default-arg-highlight (arg) | |
231 "Default function to highlight arguments in *Help* buffers. | |
232 It returns ARG in face `help-argument-name'; ARG is also | |
233 downcased if it displays differently than the default | |
234 face (according to `face-differs-from-default-p')." | |
235 (propertize (if (face-differs-from-default-p 'help-argument-name) | |
236 (downcase arg) | |
237 arg) | |
238 'face 'help-argument-name)) | |
239 | |
240 (defun help-do-arg-highlight (doc args) | |
241 (with-syntax-table (make-syntax-table emacs-lisp-mode-syntax-table) | |
242 (modify-syntax-entry ?\- "w") | |
243 (dolist (arg args doc) | |
244 (setq doc (replace-regexp-in-string | |
245 ;; This is heuristic, but covers all common cases | |
246 ;; except ARG1-ARG2 | |
247 (concat "\\<" ; beginning of word | |
248 "\\(?:[a-z-]*-\\)?" ; for xxx-ARG | |
249 "\\(" | |
250 (regexp-quote arg) | |
251 "\\)" | |
252 "\\(?:es\\|s\\|th\\)?" ; for ARGth, ARGs | |
253 "\\(?:-[a-z0-9-]+\\)?" ; for ARG-xxx, ARG-n | |
254 "\\>") ; end of word | |
255 (help-default-arg-highlight arg) | |
256 doc t t 1))))) | |
257 | |
258 (defun help-highlight-arguments (usage doc &rest args) | |
259 (when usage | |
260 (with-temp-buffer | |
261 (insert usage) | |
262 (goto-char (point-min)) | |
263 (let ((case-fold-search nil) | |
264 (next (not (or args (looking-at "\\[")))) | |
265 (opt nil)) | |
266 ;; Make a list of all arguments | |
267 (skip-chars-forward "^ ") | |
268 (while next | |
269 (or opt (not (looking-at " &")) (setq opt t)) | |
270 (if (not (re-search-forward " \\([\\[(]*\\)\\([^] &)\.]+\\)" nil t)) | |
271 (setq next nil) | |
272 (setq args (cons (match-string 2) args)) | |
273 (when (and opt (string= (match-string 1) "(")) | |
274 ;; A pesky CL-style optional argument with default value, | |
275 ;; so let's skip over it | |
276 (search-backward "(") | |
277 (goto-char (scan-sexps (point) 1))))) | |
278 ;; Highlight aguments in the USAGE string | |
279 (setq usage (help-do-arg-highlight (buffer-string) args)) | |
280 ;; Highlight arguments in the DOC string | |
281 (setq doc (and doc (help-do-arg-highlight doc args)))))) | |
282 ;; Return value is like the one from help-split-fundoc, but highlighted | |
283 (cons usage doc)) | |
284 | |
285 ;;;###autoload | |
286 (defun describe-simplify-lib-file-name (file) | |
287 "Simplify a library name FILE to a relative name, and make it a source file." | |
288 (if file | |
289 ;; Try converting the absolute file name to a library name. | |
290 (let ((libname (file-name-nondirectory file))) | |
291 ;; Now convert that back to a file name and see if we get | |
292 ;; the original one. If so, they are equivalent. | |
293 (if (equal file (locate-file libname load-path '(""))) | |
294 (if (string-match "[.]elc\\'" libname) | |
295 (substring libname 0 -1) | |
296 libname) | |
297 file)))) | |
298 | |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
299 ;;;###autoload |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
300 (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
|
301 (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
|
302 (symbol-function function) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
303 function)) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
304 file-name string |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
305 (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
|
306 (setq string |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
307 (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
|
308 (vectorp def)) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
309 "a keyboard macro") |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
310 ((subrp def) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
311 (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
|
312 (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
|
313 (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
|
314 ((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
|
315 (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
|
316 ((symbolp def) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
317 (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
|
318 (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
|
319 (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
|
320 ((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
|
321 (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
|
322 ((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
|
323 "a Lisp macro") |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
324 ((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
|
325 (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
|
326 (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
|
327 (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
|
328 (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
|
329 (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
|
330 )) |
46901
3e733b163fd4
(locate-library): Use locate-file(-completion).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46827
diff
changeset
|
331 ((keymapp def) |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
332 (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
|
333 (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
|
334 (while elts |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
335 (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
|
336 (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
|
337 elts nil)) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
338 (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
|
339 (if is-full |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
340 "a full keymap" |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
341 "a sparse keymap"))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
342 (t ""))) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
343 (princ string) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
344 (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
|
345 (save-excursion |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
346 (save-match-data |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
347 (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
|
348 (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
|
349 (or file-name |
88155 | 350 (setq file-name (symbol-file function 'defun))) |
351 (setq file-name (describe-simplify-lib-file-name file-name)) | |
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
|
352 (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
|
353 ;; 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
|
354 ;; 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
|
355 (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
|
356 (condition-case nil |
45975
7ea38f55545b
(describe-variable): Only use `buffer' is still live.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45193
diff
changeset
|
357 (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
|
358 (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
|
359 (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
|
360 (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
|
361 (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
|
362 (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
|
363 "^;;; 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
|
364 (setq file-name (match-string 1))))))) |
88155 | 365 (when (and (null file-name) (subrp def)) |
366 ;; Find the C source file name. | |
367 (setq file-name (if (get-buffer " *DOC*") | |
368 (help-C-file-name def 'subr) | |
369 'C-source))) | |
370 (when file-name | |
42591
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
371 (princ " in `") |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
372 ;; 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
|
373 ;; but that's completely wrong when the user used load-file. |
88155 | 374 (princ (if (eq file-name 'C-source) "C source code" file-name)) |
42591
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
375 (princ "'") |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
376 ;; 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
|
377 (with-current-buffer standard-output |
88155 | 378 (save-excursion |
42591
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
379 (re-search-backward "`\\([^`']+\\)'" nil t) |
88155 | 380 (help-xref-button 1 'help-function-def function file-name)))) |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
381 (princ ".") |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
382 (terpri) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
383 (when (commandp function) |
49757
9fe119b14379
Renamed remap-command to command-remapping. All uses changed.
Kim F. Storm <storm@cua.dk>
parents:
49747
diff
changeset
|
384 (let* ((remapped (command-remapping function)) |
43157
c72ba425c038
(describe-function-1): Report remapped commands.
Kim F. Storm <storm@cua.dk>
parents:
42591
diff
changeset
|
385 (keys (where-is-internal |
88155 | 386 (or remapped function) overriding-local-map nil nil)) |
387 non-modified-keys) | |
388 ;; Which non-control non-meta keys run this command? | |
389 (dolist (key keys) | |
390 (if (member (event-modifiers (aref key 0)) '(nil (shift))) | |
391 (push key non-modified-keys))) | |
43157
c72ba425c038
(describe-function-1): Report remapped commands.
Kim F. Storm <storm@cua.dk>
parents:
42591
diff
changeset
|
392 (when remapped |
c72ba425c038
(describe-function-1): Report remapped commands.
Kim F. Storm <storm@cua.dk>
parents:
42591
diff
changeset
|
393 (princ "It is remapped to `") |
c72ba425c038
(describe-function-1): Report remapped commands.
Kim F. Storm <storm@cua.dk>
parents:
42591
diff
changeset
|
394 (princ (symbol-name remapped)) |
c72ba425c038
(describe-function-1): Report remapped commands.
Kim F. Storm <storm@cua.dk>
parents:
42591
diff
changeset
|
395 (princ "'")) |
88155 | 396 |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
397 (when keys |
43157
c72ba425c038
(describe-function-1): Report remapped commands.
Kim F. Storm <storm@cua.dk>
parents:
42591
diff
changeset
|
398 (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
|
399 ;; FIXME: This list can be very long (f.ex. for self-insert-command). |
88155 | 400 ;; If there are many, remove them from KEYS. |
401 (if (< (length non-modified-keys) 10) | |
402 (princ (mapconcat 'key-description keys ", ")) | |
403 (dolist (key non-modified-keys) | |
404 (setq keys (delq key keys))) | |
405 (if keys | |
406 (progn | |
407 (princ (mapconcat 'key-description keys ", ")) | |
408 (princ ", and many ordinary text characters")) | |
409 (princ "many ordinary text characters")))) | |
410 (when (or remapped keys non-modified-keys) | |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
411 (princ ".") |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
412 (terpri)))) |
46439
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
413 (let* ((arglist (help-function-arglist def)) |
255c2fbbad1f
(help-split-fundoc, help-function-arglist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46393
diff
changeset
|
414 (doc (documentation function)) |
46957
ac5b720640e7
(help-split-fundoc): Replace the function name
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46901
diff
changeset
|
415 (usage (help-split-fundoc doc function))) |
88155 | 416 (with-current-buffer standard-output |
417 ;; If definition is a keymap, skip arglist note. | |
418 (unless (keymapp def) | |
419 (let* ((use (cond | |
420 (usage (setq doc (cdr usage)) (car usage)) | |
421 ((listp arglist) | |
422 (format "%S" (help-make-usage function arglist))) | |
423 ((stringp arglist) arglist) | |
424 ;; Maybe the arglist is in the docstring of the alias. | |
425 ((let ((fun function)) | |
426 (while (and (symbolp fun) | |
427 (setq fun (symbol-function fun)) | |
428 (not (setq usage (help-split-fundoc | |
429 (documentation fun) | |
430 function))))) | |
431 usage) | |
432 (car usage)) | |
433 ((or (stringp def) | |
434 (vectorp def)) | |
435 (format "\nMacro: %s" (format-kbd-macro def))) | |
436 (t "[Missing arglist. Please make a bug report.]"))) | |
437 (high (help-highlight-arguments use doc))) | |
438 (let ((fill-begin (point))) | |
439 (insert (car high) "\n") | |
440 (fill-region fill-begin (point))) | |
441 (setq doc (cdr high)))) | |
442 (let ((obsolete (and | |
443 ;; function might be a lambda construct. | |
444 (symbolp function) | |
445 (get function 'byte-obsolete-info)))) | |
446 (when obsolete | |
447 (princ "\nThis function is obsolete") | |
448 (when (nth 2 obsolete) | |
449 (insert (format " since %s" (nth 2 obsolete)))) | |
450 (insert ";\n" | |
451 (if (stringp (car obsolete)) (car obsolete) | |
452 (format "use `%s' instead." (car obsolete))) | |
453 "\n")) | |
454 (insert "\n" | |
455 (or doc "Not documented."))))))) | |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
456 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
457 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
458 ;; Variables |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
459 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
460 ;;;###autoload |
88155 | 461 (defun variable-at-point (&optional any-symbol) |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
462 "Return the bound variable symbol found around point. |
88155 | 463 Return 0 if there is no such symbol. |
464 If ANY-SYMBOL is non-nil, don't insist the symbol be bound." | |
465 (or (condition-case () | |
466 (with-syntax-table emacs-lisp-mode-syntax-table | |
467 (save-excursion | |
468 (or (not (zerop (skip-syntax-backward "_w"))) | |
469 (eq (char-syntax (following-char)) ?w) | |
470 (eq (char-syntax (following-char)) ?_) | |
471 (forward-sexp -1)) | |
472 (skip-chars-forward "'") | |
473 (let ((obj (read (current-buffer)))) | |
474 (and (symbolp obj) (boundp obj) obj)))) | |
475 (error nil)) | |
476 (let* ((str (find-tag-default)) | |
477 (sym (if str (intern-soft str)))) | |
478 (if (and sym (or any-symbol (boundp sym))) | |
479 sym | |
480 (save-match-data | |
481 (when (and str (string-match "\\`\\W*\\(.*?\\)\\W*\\'" str)) | |
482 (setq sym (intern-soft (match-string 1 str))) | |
483 (and (or any-symbol (boundp sym)) sym))))) | |
484 0)) | |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
485 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
486 ;;;###autoload |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
487 (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
|
488 "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
|
489 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
|
490 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
|
491 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
|
492 (interactive |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
493 (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
|
494 (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
|
495 val) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
496 (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
|
497 (format |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
498 "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
|
499 "Describe variable: ") |
88155 | 500 obarray |
501 '(lambda (vv) | |
502 (or (boundp vv) | |
503 (get vv 'variable-documentation))) | |
504 t nil nil | |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
505 (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
|
506 (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
|
507 v (intern val))))) |
45975
7ea38f55545b
(describe-variable): Only use `buffer' is still live.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45193
diff
changeset
|
508 (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
|
509 (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
|
510 (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
|
511 (save-excursion |
46901
3e733b163fd4
(locate-library): Use locate-file(-completion).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46827
diff
changeset
|
512 (let* ((valvoid (not (with-current-buffer buffer (boundp variable)))) |
3e733b163fd4
(locate-library): Use locate-file(-completion).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46827
diff
changeset
|
513 ;; Extract the value before setting up the output buffer, |
3e733b163fd4
(locate-library): Use locate-file(-completion).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46827
diff
changeset
|
514 ;; in case `buffer' *is* the output buffer. |
88155 | 515 (val (unless valvoid (buffer-local-value variable buffer))) |
516 val-start-pos) | |
42591
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
517 (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
|
518 (interactive-p)) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
519 (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
|
520 (with-current-buffer buffer |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
521 (prin1 variable) |
88155 | 522 ;; Make a hyperlink to the library if appropriate. (Don't |
523 ;; change the format of the buffer's initial line in case | |
524 ;; anything expects the current format.) | |
525 (let ((file-name (symbol-file variable 'defvar))) | |
526 (setq file-name (describe-simplify-lib-file-name file-name)) | |
527 (when (equal file-name "loaddefs.el") | |
528 ;; Find the real def site of the preloaded variable. | |
529 (let ((location | |
530 (condition-case nil | |
531 (find-variable-noselect variable file-name) | |
532 (error nil)))) | |
533 (when location | |
534 (with-current-buffer (car location) | |
535 (goto-char (cdr location)) | |
536 (when (re-search-backward | |
537 "^;;; Generated autoloads from \\(.*\\)" nil t) | |
538 (setq file-name (match-string 1))))))) | |
539 (when (and (null file-name) | |
540 (integerp (get variable 'variable-documentation))) | |
541 ;; It's a variable not defined in Elisp but in C. | |
542 (setq file-name | |
543 (if (get-buffer " *DOC*") | |
544 (help-C-file-name variable 'var) | |
545 'C-source))) | |
546 (if file-name | |
547 (progn | |
548 (princ " is a variable defined in `") | |
549 (princ (if (eq file-name 'C-source) "C source code" file-name)) | |
550 (princ "'.\n") | |
551 (with-current-buffer standard-output | |
552 (save-excursion | |
553 (re-search-backward "`\\([^`']+\\)'" nil t) | |
554 (help-xref-button 1 'help-variable-def | |
555 variable file-name))) | |
556 (if valvoid | |
557 (princ "It is void as a variable.") | |
558 (princ "Its "))) | |
559 (if valvoid | |
560 (princ " is void as a variable.") | |
561 (princ "'s ")))) | |
46901
3e733b163fd4
(locate-library): Use locate-file(-completion).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46827
diff
changeset
|
562 (if valvoid |
88155 | 563 nil |
46901
3e733b163fd4
(locate-library): Use locate-file(-completion).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46827
diff
changeset
|
564 (with-current-buffer standard-output |
88155 | 565 (setq val-start-pos (point)) |
566 (princ "value is ") | |
46901
3e733b163fd4
(locate-library): Use locate-file(-completion).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46827
diff
changeset
|
567 (terpri) |
3e733b163fd4
(locate-library): Use locate-file(-completion).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46827
diff
changeset
|
568 (let ((from (point))) |
3e733b163fd4
(locate-library): Use locate-file(-completion).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46827
diff
changeset
|
569 (pp val) |
88155 | 570 ;; Hyperlinks in variable's value are quite frequently |
571 ;; inappropriate e.g C-h v <RET> features <RET> | |
572 ;; (help-xref-on-pp from (point)) | |
46901
3e733b163fd4
(locate-library): Use locate-file(-completion).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46827
diff
changeset
|
573 (if (< (point) (+ from 20)) |
46957
ac5b720640e7
(help-split-fundoc): Replace the function name
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46901
diff
changeset
|
574 (delete-region (1- from) from))))) |
42591
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
575 (terpri) |
88155 | 576 |
42591
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
577 (when (local-variable-p variable) |
88155 | 578 (princ (format "%socal in buffer %s; " |
579 (if (get variable 'permanent-local) | |
580 "Permanently l" "L") | |
581 (buffer-name))) | |
42591
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
582 (if (not (default-boundp variable)) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
583 (princ "globally void") |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
584 (let ((val (default-value variable))) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
585 (with-current-buffer standard-output |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
586 (princ "global value is ") |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
587 (terpri) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
588 ;; 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
|
589 ;; 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
|
590 ;; 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
|
591 ;; sensible size before prettyprinting. -- fx |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
592 (let ((from (point))) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
593 (pp val) |
88155 | 594 ;; See previous comment for this function. |
595 ;; (help-xref-on-pp from (point)) | |
42591
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
596 (if (< (point) (+ from 20)) |
88155 | 597 (delete-region (1- from) from))))))) |
598 ;; Add a note for variables that have been make-var-buffer-local. | |
599 (when (and (local-variable-if-set-p variable) | |
600 (or (not (local-variable-p variable)) | |
601 (with-temp-buffer | |
602 (local-variable-if-set-p variable)))) | |
603 (princ "\nAutomatically becomes buffer-local when set in any fashion.\n")) | |
42591
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
604 (terpri) |
88155 | 605 |
606 ;; If the value is large, move it to the end. | |
42591
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
607 (with-current-buffer standard-output |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
608 (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
|
609 ;; 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
|
610 ;; 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
|
611 ;; of a symbol. |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
612 (set-syntax-table emacs-lisp-mode-syntax-table) |
88155 | 613 (goto-char val-start-pos) |
614 (delete-region (point) (progn (end-of-line) (point))) | |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
615 (save-excursion |
88155 | 616 (insert "\n\nValue:") |
617 (set (make-local-variable 'help-button-cache) | |
618 (point-marker))) | |
619 (insert "value is shown ") | |
620 (insert-button "below" | |
621 'action help-button-cache | |
622 'follow-link t | |
623 'help-echo "mouse-2, RET: show value") | |
624 (insert ".\n\n"))) | |
625 | |
46321
1d8304aae3cc
(describe-variable): Put `defvaralias' info before the documentation (patch from
Juanma Barranquero <lekktu@gmail.com>
parents:
46312
diff
changeset
|
626 ;; 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
|
627 (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
|
628 (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
|
629 (error variable))) |
51248f96252a
(describe-variable): Show documentation for aliased variable if alias does not
Juanma Barranquero <lekktu@gmail.com>
parents:
46334
diff
changeset
|
630 (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
|
631 (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
|
632 (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
|
633 (unless (eq alias variable) |
88155 | 634 (princ (format "\nThis variable is an alias for `%s'.\n" alias))) |
46389
51248f96252a
(describe-variable): Show documentation for aliased variable if alias does not
Juanma Barranquero <lekktu@gmail.com>
parents:
46334
diff
changeset
|
635 (when obsolete |
88155 | 636 (princ "\nThis variable is obsolete") |
46389
51248f96252a
(describe-variable): Show documentation for aliased variable if alias does not
Juanma Barranquero <lekktu@gmail.com>
parents:
46334
diff
changeset
|
637 (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
|
638 (princ ";") (terpri) |
46389
51248f96252a
(describe-variable): Show documentation for aliased variable if alias does not
Juanma Barranquero <lekktu@gmail.com>
parents:
46334
diff
changeset
|
639 (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
|
640 (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
|
641 (terpri)) |
88155 | 642 (princ "Documentation:\n") |
46389
51248f96252a
(describe-variable): Show documentation for aliased variable if alias does not
Juanma Barranquero <lekktu@gmail.com>
parents:
46334
diff
changeset
|
643 (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
|
644 ;; Make a link to customize if this variable can be customized. |
49102
8f2b5f65ebd1
(describe-variable): Use custom-variable-p.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
48477
diff
changeset
|
645 (if (custom-variable-p variable) |
42591
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
646 (let ((customize-label "customize")) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
647 (terpri) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
648 (terpri) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
649 (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
|
650 (with-current-buffer standard-output |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
651 (save-excursion |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
652 (re-search-backward |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
653 (concat "\\(" customize-label "\\)") nil t) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
654 (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
|
655 (print-help-return-message) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
656 (save-excursion |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
657 (set-buffer standard-output) |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
658 ;; Return the text we displayed. |
668b6361c3c4
(describe-variable, describe-function): Do save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
42265
diff
changeset
|
659 (buffer-string)))))))) |
41583
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
660 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
661 |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
662 ;;;###autoload |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
663 (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
|
664 "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
|
665 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
|
666 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
|
667 (interactive) |
fbe606fb3351
Renamed help-funs.el into help-fns.el, at RMS's request.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
668 (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
|
669 (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
|
670 (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
|
671 (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
|
672 (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
|
673 (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
|
674 (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
|
675 (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
|
676 (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
|
677 |
41600
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
678 (defun help-describe-category-set (value) |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
679 (insert (cond |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
680 ((null value) "default") |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
681 ((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
|
682 (t (condition-case err |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
683 (category-set-mnemonics value) |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
684 (error "invalid")))))) |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
685 |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
686 ;;;###autoload |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
687 (defun describe-categories (&optional buffer) |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
688 "Describe the category specifications in the current category table. |
88155 | 689 The descriptions are inserted in a buffer, which is then displayed. |
690 If BUFFER is non-nil, then describe BUFFER's category table instead. | |
691 BUFFER should be a buffer or a buffer name." | |
41600
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
692 (interactive) |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
693 (setq buffer (or buffer (current-buffer))) |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
694 (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
|
695 (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
|
696 (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
|
697 (with-current-buffer standard-output |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
698 (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
|
699 (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
|
700 (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
|
701 (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
|
702 (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
|
703 (dotimes (i 95) |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
704 (let ((elt (aref docs i))) |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
705 (when elt |
88155 | 706 (insert (+ i ?\s) ": " elt "\n")))) |
41600
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
707 (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
|
708 (insert "\nThe parent category table is:") |
037ba6ecc02a
(describe-categories, help-describe-category-set): New.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41584
diff
changeset
|
709 (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
|
710 |
41584
8b64dc23e305
Change the provide and the header as per the renaming.
Eli Zaretskii <eliz@gnu.org>
parents:
41583
diff
changeset
|
711 (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
|
712 |
88155 | 713 ;; arch-tag: 9e10331c-ae81-4d13-965d-c4819aaab0b3 |
41584
8b64dc23e305
Change the provide and the header as per the renaming.
Eli Zaretskii <eliz@gnu.org>
parents:
41583
diff
changeset
|
714 ;;; help-fns.el ends here |