annotate lisp/help.el @ 69310:270a2959d019

* help.el (describe-key): Properly handle the return value of read-key-sequence when grabbing an up-event. Cleanup mouse-1 remaps.
author Chong Yidong <cyd@stupidchicken.com>
date Mon, 06 Mar 2006 20:27:06 +0000
parents aa9f0a1e543f
children c3bd744c874c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
660
08eb386dd0f3 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 444
diff changeset
1 ;;; help.el --- help commands for Emacs
08eb386dd0f3 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 444
diff changeset
2
64762
41bb365f41c4 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64091
diff changeset
3 ;; Copyright (C) 1985, 1986, 1993, 1994, 1998, 1999, 2000, 2001, 2002,
68651
3bd95f4f2941 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 67521
diff changeset
4 ;; 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
846
20674ae6bf52 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 811
diff changeset
5
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 755
diff changeset
6 ;; Maintainer: FSF
811
e694e0879463 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 807
diff changeset
7 ;; Keywords: help, internal
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 755
diff changeset
8
409
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 755
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
409
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 ;; any later version.
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; GNU General Public License for more details.
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13358
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
64091
6fb026ad601f Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 62624
diff changeset
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
6fb026ad601f Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 62624
diff changeset
24 ;; Boston, MA 02110-1301, USA.
409
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25
2315
9e7ec92a4fdf Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2312
diff changeset
26 ;;; Commentary:
9e7ec92a4fdf Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2312
diff changeset
27
16391
5d64d742ccbb (print-help-return-message): Use new functions `special-display-p' and
Erik Naggum <erik@naggum.no>
parents: 16273
diff changeset
28 ;; This code implements GNU Emacs' on-line help system, the one invoked by
25473
1ad8606c8cc7 (help-make-xrefs): Don't lose on non-empty blank line after key table.
Dave Love <fx@gnu.org>
parents: 25047
diff changeset
29 ;; `M-x help-for-help'.
2315
9e7ec92a4fdf Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2312
diff changeset
30
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 755
diff changeset
31 ;;; Code:
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 755
diff changeset
32
2312
ad7b89a430df Don't load help-screen at run time if compiled.
Richard M. Stallman <rms@gnu.org>
parents: 2237
diff changeset
33 ;; Get the macro make-help-screen when this is compiled,
ad7b89a430df Don't load help-screen at run time if compiled.
Richard M. Stallman <rms@gnu.org>
parents: 2237
diff changeset
34 ;; or run interpreted, but not when the compiled code is loaded.
2697
05ff97695d32 Require help-macro, not help-screen.
Richard M. Stallman <rms@gnu.org>
parents: 2638
diff changeset
35 (eval-when-compile (require 'help-macro))
39728
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
36
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
37 ;; This makes `with-output-to-temp-buffer' buffers use `help-mode'.
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
38 (add-hook 'temp-buffer-setup-hook 'help-mode-setup)
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
39 (add-hook 'temp-buffer-show-hook 'help-mode-finish)
2237
2670a8f6a42e Teach this to use help-screen.el.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2134
diff changeset
40
67224
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
41 (defvar help-map
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
42 (let ((map (make-sparse-keymap)))
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
43 (define-key map (char-to-string help-char) 'help-for-help)
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
44 (define-key map [help] 'help-for-help)
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
45 (define-key map [f1] 'help-for-help)
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
46 (define-key map "." 'display-local-help)
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
47 (define-key map "?" 'help-for-help)
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
48
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
49 (define-key map "\C-c" 'describe-copying)
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
50 (define-key map "\C-d" 'describe-distribution)
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
51 (define-key map "\C-e" 'view-emacs-problems)
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
52 (define-key map "\C-f" 'view-emacs-FAQ)
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
53 (define-key map "\C-m" 'view-order-manuals)
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
54 (define-key map "\C-n" 'view-emacs-news)
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
55 (define-key map "\C-p" 'describe-project)
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
56 (define-key map "\C-t" 'view-todo)
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
57 (define-key map "\C-w" 'describe-no-warranty)
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
58
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
59 ;; This does not fit the pattern, but it is natural given the C-\ command.
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
60 (define-key map "\C-\\" 'describe-input-method)
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
61
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
62 (define-key map "C" 'describe-coding-system)
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
63 (define-key map "F" 'Info-goto-emacs-command-node)
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
64 (define-key map "I" 'describe-input-method)
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
65 (define-key map "K" 'Info-goto-emacs-key-command-node)
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
66 (define-key map "L" 'describe-language-environment)
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
67 (define-key map "S" 'info-lookup-symbol)
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
68
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
69 (define-key map "a" 'apropos-command)
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
70 (define-key map "b" 'describe-bindings)
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
71 (define-key map "c" 'describe-key-briefly)
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
72 (define-key map "d" 'apropos-documentation)
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
73 (define-key map "e" 'view-echo-area-messages)
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
74 (define-key map "f" 'describe-function)
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
75 (define-key map "h" 'view-hello-file)
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
76
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
77 (define-key map "i" 'info)
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
78 (define-key map "4i" 'info-other-window)
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
79
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
80 (define-key map "k" 'describe-key)
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
81 (define-key map "l" 'view-lossage)
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
82 (define-key map "m" 'describe-mode)
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
83 (define-key map "n" 'view-emacs-news)
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
84 (define-key map "p" 'finder-by-keyword)
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
85 (define-key map "r" 'info-emacs-manual)
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
86 (define-key map "s" 'describe-syntax)
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
87 (define-key map "t" 'help-with-tutorial)
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
88 (define-key map "w" 'where-is)
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
89 (define-key map "v" 'describe-variable)
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
90 (define-key map "q" 'help-quit)
1a4439fe2adc (help-map): Move initialization into declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67204
diff changeset
91 map)
409
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 "Keymap for characters following the Help key.")
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93
919
567b06901789 entered into RCS
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 918
diff changeset
94 (define-key global-map (char-to-string help-char) 'help-command)
12424
aa25c9b2e043 Bind f1 and help like C-h.
Richard M. Stallman <rms@gnu.org>
parents: 11890
diff changeset
95 (define-key global-map [help] 'help-command)
aa25c9b2e043 Bind f1 and help like C-h.
Richard M. Stallman <rms@gnu.org>
parents: 11890
diff changeset
96 (define-key global-map [f1] 'help-command)
409
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 (fset 'help-command help-map)
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98
7978
8356e992ddb6 (finder-by-keyword): Add doc string and t for interactive.
Richard M. Stallman <rms@gnu.org>
parents: 7298
diff changeset
99 (autoload 'finder-by-keyword "finder"
8356e992ddb6 (finder-by-keyword): Add doc string and t for interactive.
Richard M. Stallman <rms@gnu.org>
parents: 7298
diff changeset
100 "Find packages matching a given keyword." t)
2134
b275e1b50542 Added autoload, binding and menu line for new finder feature (P).
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2079
diff changeset
101
57485
32dab1aa8b9a (describe-mode): Use marker buttons to make minor mode list into hyperlinks.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 56883
diff changeset
102 ;; insert-button makes the action nil if it is not store somewhere
32dab1aa8b9a (describe-mode): Use marker buttons to make minor mode list into hyperlinks.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 56883
diff changeset
103 (defvar help-button-cache nil)
32dab1aa8b9a (describe-mode): Use marker buttons to make minor mode list into hyperlinks.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 56883
diff changeset
104
39651
444f50200adc (help-mode-map): Make button-buffer-map our parent.
Miles Bader <miles@gnu.org>
parents: 39512
diff changeset
105
6580
4c20c6b1d2c2 (help): New alias.
Richard M. Stallman <rms@gnu.org>
parents: 6476
diff changeset
106 (defun help-quit ()
23333
b8369b78f1ba (help-quit): Add doc.
Richard M. Stallman <rms@gnu.org>
parents: 23332
diff changeset
107 "Just exit from the Help command's command loop."
6580
4c20c6b1d2c2 (help): New alias.
Richard M. Stallman <rms@gnu.org>
parents: 6476
diff changeset
108 (interactive)
4c20c6b1d2c2 (help): New alias.
Richard M. Stallman <rms@gnu.org>
parents: 6476
diff changeset
109 nil)
4c20c6b1d2c2 (help): New alias.
Richard M. Stallman <rms@gnu.org>
parents: 6476
diff changeset
110
21188
607ce9d7cf53 (help-mode-maybe): Set view-return-to-alist.
Richard M. Stallman <rms@gnu.org>
parents: 20953
diff changeset
111 (defvar help-return-method nil
607ce9d7cf53 (help-mode-maybe): Set view-return-to-alist.
Richard M. Stallman <rms@gnu.org>
parents: 20953
diff changeset
112 "What to do to \"exit\" the help buffer.
607ce9d7cf53 (help-mode-maybe): Set view-return-to-alist.
Richard M. Stallman <rms@gnu.org>
parents: 20953
diff changeset
113 This is a list
67279
8cf27ba1d450 (print-help-return-message): If pop-up-frames is non-nil, set up
Eli Zaretskii <eliz@gnu.org>
parents: 67224
diff changeset
114 (WINDOW . t) delete the selected window (and possibly its frame,
8cf27ba1d450 (print-help-return-message): If pop-up-frames is non-nil, set up
Eli Zaretskii <eliz@gnu.org>
parents: 67224
diff changeset
115 see `quit-window' and `View-quit'), go to WINDOW.
21188
607ce9d7cf53 (help-mode-maybe): Set view-return-to-alist.
Richard M. Stallman <rms@gnu.org>
parents: 20953
diff changeset
116 (WINDOW . quit-window) do quit-window, then select WINDOW.
607ce9d7cf53 (help-mode-maybe): Set view-return-to-alist.
Richard M. Stallman <rms@gnu.org>
parents: 20953
diff changeset
117 (WINDOW BUF START POINT) display BUF at START, POINT, then select WINDOW.")
607ce9d7cf53 (help-mode-maybe): Set view-return-to-alist.
Richard M. Stallman <rms@gnu.org>
parents: 20953
diff changeset
118
409
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 (defun print-help-return-message (&optional function)
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 "Display or return message saying how to restore windows after help command.
46329
081502d6dd98 (help-map): Add binding for info-emacs-manual.
Richard M. Stallman <rms@gnu.org>
parents: 45070
diff changeset
121 This function assumes that `standard-output' is the help buffer.
081502d6dd98 (help-map): Add binding for info-emacs-manual.
Richard M. Stallman <rms@gnu.org>
parents: 45070
diff changeset
122 It computes a message, and applies the optional argument FUNCTION to it.
67279
8cf27ba1d450 (print-help-return-message): If pop-up-frames is non-nil, set up
Eli Zaretskii <eliz@gnu.org>
parents: 67224
diff changeset
123 If FUNCTION is nil, it applies `message', thus displaying the message.
8cf27ba1d450 (print-help-return-message): If pop-up-frames is non-nil, set up
Eli Zaretskii <eliz@gnu.org>
parents: 67224
diff changeset
124 In addition, this function sets up `help-return-method', which see, that
8cf27ba1d450 (print-help-return-message): If pop-up-frames is non-nil, set up
Eli Zaretskii <eliz@gnu.org>
parents: 67224
diff changeset
125 specifies what to do when the user exits the help buffer."
409
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 (and (not (get-buffer-window standard-output))
8259
604d89082229 (print-help-return-message): If help buffer is a
Richard M. Stallman <rms@gnu.org>
parents: 7978
diff changeset
127 (let ((first-message
67279
8cf27ba1d450 (print-help-return-message): If pop-up-frames is non-nil, set up
Eli Zaretskii <eliz@gnu.org>
parents: 67224
diff changeset
128 (cond ((or
8cf27ba1d450 (print-help-return-message): If pop-up-frames is non-nil, set up
Eli Zaretskii <eliz@gnu.org>
parents: 67224
diff changeset
129 pop-up-frames
8cf27ba1d450 (print-help-return-message): If pop-up-frames is non-nil, set up
Eli Zaretskii <eliz@gnu.org>
parents: 67224
diff changeset
130 (special-display-p (buffer-name standard-output)))
21188
607ce9d7cf53 (help-mode-maybe): Set view-return-to-alist.
Richard M. Stallman <rms@gnu.org>
parents: 20953
diff changeset
131 (setq help-return-method (cons (selected-window) t))
8259
604d89082229 (print-help-return-message): If help buffer is a
Richard M. Stallman <rms@gnu.org>
parents: 7978
diff changeset
132 ;; If the help output buffer is a special display buffer,
604d89082229 (print-help-return-message): If help buffer is a
Richard M. Stallman <rms@gnu.org>
parents: 7978
diff changeset
133 ;; don't say anything about how to get rid of it.
604d89082229 (print-help-return-message): If help buffer is a
Richard M. Stallman <rms@gnu.org>
parents: 7978
diff changeset
134 ;; First of all, the user will do that with the window
604d89082229 (print-help-return-message): If help buffer is a
Richard M. Stallman <rms@gnu.org>
parents: 7978
diff changeset
135 ;; manager, not with Emacs.
604d89082229 (print-help-return-message): If help buffer is a
Richard M. Stallman <rms@gnu.org>
parents: 7978
diff changeset
136 ;; Secondly, the buffer has not been displayed yet,
604d89082229 (print-help-return-message): If help buffer is a
Richard M. Stallman <rms@gnu.org>
parents: 7978
diff changeset
137 ;; so we don't know whether its frame will be selected.
604d89082229 (print-help-return-message): If help buffer is a
Richard M. Stallman <rms@gnu.org>
parents: 7978
diff changeset
138 nil)
30667
2bd60ea8076f (print-help-return-message): When
Gerd Moellmann <gerd@gnu.org>
parents: 30621
diff changeset
139 (display-buffer-reuse-frames
2bd60ea8076f (print-help-return-message): When
Gerd Moellmann <gerd@gnu.org>
parents: 30621
diff changeset
140 (setq help-return-method (cons (selected-window)
2bd60ea8076f (print-help-return-message): When
Gerd Moellmann <gerd@gnu.org>
parents: 30621
diff changeset
141 'quit-window))
2bd60ea8076f (print-help-return-message): When
Gerd Moellmann <gerd@gnu.org>
parents: 30621
diff changeset
142 nil)
8259
604d89082229 (print-help-return-message): If help buffer is a
Richard M. Stallman <rms@gnu.org>
parents: 7978
diff changeset
143 ((not (one-window-p t))
21188
607ce9d7cf53 (help-mode-maybe): Set view-return-to-alist.
Richard M. Stallman <rms@gnu.org>
parents: 20953
diff changeset
144 (setq help-return-method
607ce9d7cf53 (help-mode-maybe): Set view-return-to-alist.
Richard M. Stallman <rms@gnu.org>
parents: 20953
diff changeset
145 (cons (selected-window) 'quit-window))
8259
604d89082229 (print-help-return-message): If help buffer is a
Richard M. Stallman <rms@gnu.org>
parents: 7978
diff changeset
146 "Type \\[switch-to-buffer-other-window] RET to restore the other window.")
604d89082229 (print-help-return-message): If help buffer is a
Richard M. Stallman <rms@gnu.org>
parents: 7978
diff changeset
147 (pop-up-windows
21188
607ce9d7cf53 (help-mode-maybe): Set view-return-to-alist.
Richard M. Stallman <rms@gnu.org>
parents: 20953
diff changeset
148 (setq help-return-method (cons (selected-window) t))
8259
604d89082229 (print-help-return-message): If help buffer is a
Richard M. Stallman <rms@gnu.org>
parents: 7978
diff changeset
149 "Type \\[delete-other-windows] to remove help window.")
604d89082229 (print-help-return-message): If help buffer is a
Richard M. Stallman <rms@gnu.org>
parents: 7978
diff changeset
150 (t
21188
607ce9d7cf53 (help-mode-maybe): Set view-return-to-alist.
Richard M. Stallman <rms@gnu.org>
parents: 20953
diff changeset
151 (setq help-return-method
607ce9d7cf53 (help-mode-maybe): Set view-return-to-alist.
Richard M. Stallman <rms@gnu.org>
parents: 20953
diff changeset
152 (list (selected-window) (window-buffer)
607ce9d7cf53 (help-mode-maybe): Set view-return-to-alist.
Richard M. Stallman <rms@gnu.org>
parents: 20953
diff changeset
153 (window-start) (window-point)))
8259
604d89082229 (print-help-return-message): If help buffer is a
Richard M. Stallman <rms@gnu.org>
parents: 7978
diff changeset
154 "Type \\[switch-to-buffer] RET to remove help window."))))
604d89082229 (print-help-return-message): If help buffer is a
Richard M. Stallman <rms@gnu.org>
parents: 7978
diff changeset
155 (funcall (or function 'message)
604d89082229 (print-help-return-message): If help buffer is a
Richard M. Stallman <rms@gnu.org>
parents: 7978
diff changeset
156 (concat
604d89082229 (print-help-return-message): If help buffer is a
Richard M. Stallman <rms@gnu.org>
parents: 7978
diff changeset
157 (if first-message
28909
43d9eb93e1fb (help-xref-stack): Doc fix.
Dave Love <fx@gnu.org>
parents: 28841
diff changeset
158 (substitute-command-keys first-message))
43d9eb93e1fb (help-xref-stack): Doc fix.
Dave Love <fx@gnu.org>
parents: 28841
diff changeset
159 (if first-message " ")
11524
cafa503e806c (print-help-return-message): Check same-window-buffer-names
Richard M. Stallman <rms@gnu.org>
parents: 11428
diff changeset
160 ;; If the help buffer will go in a separate frame,
cafa503e806c (print-help-return-message): Check same-window-buffer-names
Richard M. Stallman <rms@gnu.org>
parents: 11428
diff changeset
161 ;; it's no use mentioning a command to scroll, so don't.
67281
409eae14f7d9 (print-help-return-message): If pop-up-frames is non-nil, don't display
Eli Zaretskii <eliz@gnu.org>
parents: 67279
diff changeset
162 (if (or pop-up-windows
409eae14f7d9 (print-help-return-message): If pop-up-frames is non-nil, don't display
Eli Zaretskii <eliz@gnu.org>
parents: 67279
diff changeset
163 (special-display-p (buffer-name standard-output)))
11524
cafa503e806c (print-help-return-message): Check same-window-buffer-names
Richard M. Stallman <rms@gnu.org>
parents: 11428
diff changeset
164 nil
16391
5d64d742ccbb (print-help-return-message): Use new functions `special-display-p' and
Erik Naggum <erik@naggum.no>
parents: 16273
diff changeset
165 (if (same-window-p (buffer-name standard-output))
11524
cafa503e806c (print-help-return-message): Check same-window-buffer-names
Richard M. Stallman <rms@gnu.org>
parents: 11428
diff changeset
166 ;; Say how to scroll this window.
cafa503e806c (print-help-return-message): Check same-window-buffer-names
Richard M. Stallman <rms@gnu.org>
parents: 11428
diff changeset
167 (substitute-command-keys
cafa503e806c (print-help-return-message): Check same-window-buffer-names
Richard M. Stallman <rms@gnu.org>
parents: 11428
diff changeset
168 "\\[scroll-up] to scroll the help.")
cafa503e806c (print-help-return-message): Check same-window-buffer-names
Richard M. Stallman <rms@gnu.org>
parents: 11428
diff changeset
169 ;; Say how to scroll some other window.
11428
d39d8e8b6d20 (print-help-return-message): Check same-window-buffer-names
Richard M. Stallman <rms@gnu.org>
parents: 10923
diff changeset
170 (substitute-command-keys
11524
cafa503e806c (print-help-return-message): Check same-window-buffer-names
Richard M. Stallman <rms@gnu.org>
parents: 11428
diff changeset
171 "\\[scroll-other-window] to scroll the help."))))))))
409
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 ;; So keyboard macro definitions are documented correctly
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174 (fset 'defining-kbd-macro (symbol-function 'start-kbd-macro))
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175
60006
dfc2b4718048 (help-for-help-internal): Renamed from help-for-help.
Richard M. Stallman <rms@gnu.org>
parents: 59926
diff changeset
176 (defalias 'help 'help-for-help-internal)
dfc2b4718048 (help-for-help-internal): Renamed from help-for-help.
Richard M. Stallman <rms@gnu.org>
parents: 59926
diff changeset
177 ;; find-function can find this.
dfc2b4718048 (help-for-help-internal): Renamed from help-for-help.
Richard M. Stallman <rms@gnu.org>
parents: 59926
diff changeset
178 (defalias 'help-for-help 'help-for-help-internal)
dfc2b4718048 (help-for-help-internal): Renamed from help-for-help.
Richard M. Stallman <rms@gnu.org>
parents: 59926
diff changeset
179 ;; It can't find this, but nobody will look.
dfc2b4718048 (help-for-help-internal): Renamed from help-for-help.
Richard M. Stallman <rms@gnu.org>
parents: 59926
diff changeset
180 (make-help-screen help-for-help-internal
67482
c91001adb561 (help-for-help-internal): Add `r' in doc string.
Romain Francoise <romain@orebokech.com>
parents: 67281
diff changeset
181 "a b c C e f F i I k C-k l L m p r s t v w C-c C-d C-f C-n C-p C-t C-w . or ? :"
39728
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
182 "You have typed %THIS-KEY%, the help character. Type a Help option:
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
183 \(Use SPC or DEL to scroll through this text. Type \\<help-map>\\[help-quit] to exit the Help command.)
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
184
66853
b33c167de495 (help-for-help-internal): Improve doc of C-h a.
Richard M. Stallman <rms@gnu.org>
parents: 66849
diff changeset
185 a command-apropos. Give a list of words or a regexp, to get a list of
67521
6dd56632b9c7 (help-for-help-internal): Simplify entry for `a'.
Richard M. Stallman <rms@gnu.org>
parents: 67482
diff changeset
186 commands whose names match. See also the apropos command.
39728
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
187 b describe-bindings. Display table of all key bindings.
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
188 c describe-key-briefly. Type a command key sequence;
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
189 it prints the function name that sequence runs.
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
190 C describe-coding-system. This describes either a specific coding system
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
191 (if you type its name) or the coding systems currently in use
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
192 (if you type just RET).
66849
47cf6ef66885 (help-for-help-internal): Fix `a' entry. Add `d' entry.
Kim F. Storm <storm@cua.dk>
parents: 66824
diff changeset
193 d apropos-documentation. Give a pattern (a list or words or a regexp), and
47cf6ef66885 (help-for-help-internal): Fix `a' entry. Add `d' entry.
Kim F. Storm <storm@cua.dk>
parents: 66824
diff changeset
194 see a list of functions, variables, and other items whose built-in
47cf6ef66885 (help-for-help-internal): Fix `a' entry. Add `d' entry.
Kim F. Storm <storm@cua.dk>
parents: 66824
diff changeset
195 doucmentation string matches that pattern. See also the apropos command.
59926
7c0a2065c3ee (help-for-help): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 59018
diff changeset
196 e view-echo-area-messages. Show the buffer where the echo-area messages
7c0a2065c3ee (help-for-help): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 59018
diff changeset
197 are stored.
7c0a2065c3ee (help-for-help): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 59018
diff changeset
198 f describe-function. Type a function name and get its documentation.
42735
86919cd01cdd (view-echo-area-messages): New function.
Richard M. Stallman <rms@gnu.org>
parents: 42679
diff changeset
199 F Info-goto-emacs-command-node. Type a function name;
59926
7c0a2065c3ee (help-for-help): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 59018
diff changeset
200 it takes you to the on-line manual's section that describes
7c0a2065c3ee (help-for-help): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 59018
diff changeset
201 the command.
42738
ffedbfc5d749 Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 42736
diff changeset
202 h Display the HELLO file which illustrates various scripts.
59926
7c0a2065c3ee (help-for-help): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 59018
diff changeset
203 i info. The Info documentation reader: read on-line manuals.
39728
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
204 I describe-input-method. Describe a specific input method (if you type
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
205 its name) or the current input method (if you type just RET).
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
206 k describe-key. Type a command key sequence;
59926
7c0a2065c3ee (help-for-help): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 59018
diff changeset
207 it displays the full documentation for that key sequence.
42735
86919cd01cdd (view-echo-area-messages): New function.
Richard M. Stallman <rms@gnu.org>
parents: 42679
diff changeset
208 K Info-goto-emacs-key-command-node. Type a command key sequence;
59926
7c0a2065c3ee (help-for-help): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 59018
diff changeset
209 it takes you to the on-line manual's section that describes
7c0a2065c3ee (help-for-help): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 59018
diff changeset
210 the command bound to that key.
39728
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
211 l view-lossage. Show last 100 characters you typed.
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
212 L describe-language-environment. This describes either a
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
213 specific language environment (if you type its name)
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
214 or the current language environment (if you type just RET).
59926
7c0a2065c3ee (help-for-help): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 59018
diff changeset
215 m describe-mode. Display documentation of current minor modes,
39728
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
216 and the current major mode, including their special commands.
59926
7c0a2065c3ee (help-for-help): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 59018
diff changeset
217 n view-emacs-news. Display news of recent Emacs changes.
39728
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
218 p finder-by-keyword. Find packages matching a given topic keyword.
67482
c91001adb561 (help-for-help-internal): Add `r' in doc string.
Romain Francoise <romain@orebokech.com>
parents: 67281
diff changeset
219 r info-emacs-manual. Display the Emacs manual in Info mode.
39728
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
220 s describe-syntax. Display contents of syntax table, plus explanations.
42735
86919cd01cdd (view-echo-area-messages): New function.
Richard M. Stallman <rms@gnu.org>
parents: 42679
diff changeset
221 S info-lookup-symbol. Display the definition of a specific symbol
86919cd01cdd (view-echo-area-messages): New function.
Richard M. Stallman <rms@gnu.org>
parents: 42679
diff changeset
222 as found in the manual for the language this buffer is written in.
39728
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
223 t help-with-tutorial. Select the Emacs learn-by-doing tutorial.
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
224 v describe-variable. Type name of a variable;
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
225 it displays the variable's documentation and value.
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
226 w where-is. Type command name; it prints which keystrokes
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
227 invoke that command.
53204
0fd777e399e3 (help-map): Bind `display-local-help' to `C-h .'.
Luc Teirlinck <teirllm@auburn.edu>
parents: 52690
diff changeset
228 . display-local-help. Display any available local help at point
0fd777e399e3 (help-map): Bind `display-local-help' to `C-h .'.
Luc Teirlinck <teirllm@auburn.edu>
parents: 52690
diff changeset
229 in the echo area.
39728
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
230
42735
86919cd01cdd (view-echo-area-messages): New function.
Richard M. Stallman <rms@gnu.org>
parents: 42679
diff changeset
231 C-c Display Emacs copying permission (GNU General Public License).
39728
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
232 C-d Display Emacs ordering information.
42735
86919cd01cdd (view-echo-area-messages): New function.
Richard M. Stallman <rms@gnu.org>
parents: 42679
diff changeset
233 C-e Display info about Emacs problems.
86919cd01cdd (view-echo-area-messages): New function.
Richard M. Stallman <rms@gnu.org>
parents: 42679
diff changeset
234 C-f Display the Emacs FAQ.
86919cd01cdd (view-echo-area-messages): New function.
Richard M. Stallman <rms@gnu.org>
parents: 42679
diff changeset
235 C-m Display how to order printed Emacs manuals.
39728
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
236 C-n Display news of recent Emacs changes.
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
237 C-p Display information about the GNU project.
45070
fbd816e9e27d (view-todo): New function.
Richard M. Stallman <rms@gnu.org>
parents: 44537
diff changeset
238 C-t Display the Emacs TODO list.
39728
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
239 C-w Display information on absence of warranty for GNU Emacs."
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
240 help-map)
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
241
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
242
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
243
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
244 (defun function-called-at-point ()
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
245 "Return a function around point or else called by the list containing point.
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
246 If that doesn't give a function, return nil."
56883
96649ac41424 (function-called-at-point): Try `find-tag-default' when other methods failed.
Juri Linkov <juri@jurta.org>
parents: 56637
diff changeset
247 (or (with-syntax-table emacs-lisp-mode-syntax-table
96649ac41424 (function-called-at-point): Try `find-tag-default' when other methods failed.
Juri Linkov <juri@jurta.org>
parents: 56637
diff changeset
248 (or (condition-case ()
96649ac41424 (function-called-at-point): Try `find-tag-default' when other methods failed.
Juri Linkov <juri@jurta.org>
parents: 56637
diff changeset
249 (save-excursion
96649ac41424 (function-called-at-point): Try `find-tag-default' when other methods failed.
Juri Linkov <juri@jurta.org>
parents: 56637
diff changeset
250 (or (not (zerop (skip-syntax-backward "_w")))
96649ac41424 (function-called-at-point): Try `find-tag-default' when other methods failed.
Juri Linkov <juri@jurta.org>
parents: 56637
diff changeset
251 (eq (char-syntax (following-char)) ?w)
96649ac41424 (function-called-at-point): Try `find-tag-default' when other methods failed.
Juri Linkov <juri@jurta.org>
parents: 56637
diff changeset
252 (eq (char-syntax (following-char)) ?_)
96649ac41424 (function-called-at-point): Try `find-tag-default' when other methods failed.
Juri Linkov <juri@jurta.org>
parents: 56637
diff changeset
253 (forward-sexp -1))
96649ac41424 (function-called-at-point): Try `find-tag-default' when other methods failed.
Juri Linkov <juri@jurta.org>
parents: 56637
diff changeset
254 (skip-chars-forward "'")
96649ac41424 (function-called-at-point): Try `find-tag-default' when other methods failed.
Juri Linkov <juri@jurta.org>
parents: 56637
diff changeset
255 (let ((obj (read (current-buffer))))
96649ac41424 (function-called-at-point): Try `find-tag-default' when other methods failed.
Juri Linkov <juri@jurta.org>
parents: 56637
diff changeset
256 (and (symbolp obj) (fboundp obj) obj)))
96649ac41424 (function-called-at-point): Try `find-tag-default' when other methods failed.
Juri Linkov <juri@jurta.org>
parents: 56637
diff changeset
257 (error nil))
96649ac41424 (function-called-at-point): Try `find-tag-default' when other methods failed.
Juri Linkov <juri@jurta.org>
parents: 56637
diff changeset
258 (condition-case ()
96649ac41424 (function-called-at-point): Try `find-tag-default' when other methods failed.
Juri Linkov <juri@jurta.org>
parents: 56637
diff changeset
259 (save-excursion
96649ac41424 (function-called-at-point): Try `find-tag-default' when other methods failed.
Juri Linkov <juri@jurta.org>
parents: 56637
diff changeset
260 (save-restriction
96649ac41424 (function-called-at-point): Try `find-tag-default' when other methods failed.
Juri Linkov <juri@jurta.org>
parents: 56637
diff changeset
261 (narrow-to-region (max (point-min)
96649ac41424 (function-called-at-point): Try `find-tag-default' when other methods failed.
Juri Linkov <juri@jurta.org>
parents: 56637
diff changeset
262 (- (point) 1000)) (point-max))
96649ac41424 (function-called-at-point): Try `find-tag-default' when other methods failed.
Juri Linkov <juri@jurta.org>
parents: 56637
diff changeset
263 ;; Move up to surrounding paren, then after the open.
96649ac41424 (function-called-at-point): Try `find-tag-default' when other methods failed.
Juri Linkov <juri@jurta.org>
parents: 56637
diff changeset
264 (backward-up-list 1)
96649ac41424 (function-called-at-point): Try `find-tag-default' when other methods failed.
Juri Linkov <juri@jurta.org>
parents: 56637
diff changeset
265 (forward-char 1)
96649ac41424 (function-called-at-point): Try `find-tag-default' when other methods failed.
Juri Linkov <juri@jurta.org>
parents: 56637
diff changeset
266 ;; If there is space here, this is probably something
96649ac41424 (function-called-at-point): Try `find-tag-default' when other methods failed.
Juri Linkov <juri@jurta.org>
parents: 56637
diff changeset
267 ;; other than a real Lisp function call, so ignore it.
96649ac41424 (function-called-at-point): Try `find-tag-default' when other methods failed.
Juri Linkov <juri@jurta.org>
parents: 56637
diff changeset
268 (if (looking-at "[ \t]")
96649ac41424 (function-called-at-point): Try `find-tag-default' when other methods failed.
Juri Linkov <juri@jurta.org>
parents: 56637
diff changeset
269 (error "Probably not a Lisp function call"))
96649ac41424 (function-called-at-point): Try `find-tag-default' when other methods failed.
Juri Linkov <juri@jurta.org>
parents: 56637
diff changeset
270 (let ((obj (read (current-buffer))))
96649ac41424 (function-called-at-point): Try `find-tag-default' when other methods failed.
Juri Linkov <juri@jurta.org>
parents: 56637
diff changeset
271 (and (symbolp obj) (fboundp obj) obj))))
96649ac41424 (function-called-at-point): Try `find-tag-default' when other methods failed.
Juri Linkov <juri@jurta.org>
parents: 56637
diff changeset
272 (error nil))))
96649ac41424 (function-called-at-point): Try `find-tag-default' when other methods failed.
Juri Linkov <juri@jurta.org>
parents: 56637
diff changeset
273 (let* ((str (find-tag-default))
58992
1a8bbdcb009f * help.el (function-called-at-point):
Juri Linkov <juri@jurta.org>
parents: 57795
diff changeset
274 (sym (if str (intern-soft str))))
1a8bbdcb009f * help.el (function-called-at-point):
Juri Linkov <juri@jurta.org>
parents: 57795
diff changeset
275 (if (and sym (fboundp sym))
1a8bbdcb009f * help.el (function-called-at-point):
Juri Linkov <juri@jurta.org>
parents: 57795
diff changeset
276 sym
1a8bbdcb009f * help.el (function-called-at-point):
Juri Linkov <juri@jurta.org>
parents: 57795
diff changeset
277 (save-match-data
1a8bbdcb009f * help.el (function-called-at-point):
Juri Linkov <juri@jurta.org>
parents: 57795
diff changeset
278 (when (and str (string-match "\\`\\W*\\(.*?\\)\\W*\\'" str))
1a8bbdcb009f * help.el (function-called-at-point):
Juri Linkov <juri@jurta.org>
parents: 57795
diff changeset
279 (setq sym (intern-soft (match-string 1 str)))
1a8bbdcb009f * help.el (function-called-at-point):
Juri Linkov <juri@jurta.org>
parents: 57795
diff changeset
280 (and (fboundp sym) sym)))))))
39728
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
281
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
282
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
283 ;;; `User' help functions
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
284
409
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285 (defun describe-distribution ()
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286 "Display info on how to obtain the latest version of GNU Emacs."
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287 (interactive)
42802
d72ace523825 (describe-distribution): Really call view-file.
Richard M. Stallman <rms@gnu.org>
parents: 42738
diff changeset
288 (view-file (expand-file-name "DISTRIB" data-directory)))
409
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
290 (defun describe-copying ()
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291 "Display info on how you may redistribute copies of GNU Emacs."
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
292 (interactive)
42254
ffef7ba0b65d (view-order-manuals, view-emacs-news, describe-copying)
Richard M. Stallman <rms@gnu.org>
parents: 39789
diff changeset
293 (view-file (expand-file-name "COPYING" data-directory))
409
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
294 (goto-char (point-min)))
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295
5025
0556b068e9ee (describe-project): New function, on C-h C-p.
Richard M. Stallman <rms@gnu.org>
parents: 4467
diff changeset
296 (defun describe-project ()
0556b068e9ee (describe-project): New function, on C-h C-p.
Richard M. Stallman <rms@gnu.org>
parents: 4467
diff changeset
297 "Display info on the GNU project."
0556b068e9ee (describe-project): New function, on C-h C-p.
Richard M. Stallman <rms@gnu.org>
parents: 4467
diff changeset
298 (interactive)
42254
ffef7ba0b65d (view-order-manuals, view-emacs-news, describe-copying)
Richard M. Stallman <rms@gnu.org>
parents: 39789
diff changeset
299 (view-file (expand-file-name "THE-GNU-PROJECT" data-directory))
5025
0556b068e9ee (describe-project): New function, on C-h C-p.
Richard M. Stallman <rms@gnu.org>
parents: 4467
diff changeset
300 (goto-char (point-min)))
0556b068e9ee (describe-project): New function, on C-h C-p.
Richard M. Stallman <rms@gnu.org>
parents: 4467
diff changeset
301
409
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
302 (defun describe-no-warranty ()
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
303 "Display info on all the kinds of warranty Emacs does NOT have."
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
304 (interactive)
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
305 (describe-copying)
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
306 (let (case-fold-search)
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307 (search-forward "NO WARRANTY")
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
308 (recenter 0)))
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
309
3980
bf2d4294a1dd (describe-prefix-bindings): New command.
Richard M. Stallman <rms@gnu.org>
parents: 3145
diff changeset
310 (defun describe-prefix-bindings ()
3982
e50f7b531c7f (describe-prefix-bindings): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 3980
diff changeset
311 "Describe the bindings of the prefix used to reach this command.
e50f7b531c7f (describe-prefix-bindings): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 3980
diff changeset
312 The prefix described consists of all but the last event
e50f7b531c7f (describe-prefix-bindings): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 3980
diff changeset
313 of the key sequence that ran this command."
3980
bf2d4294a1dd (describe-prefix-bindings): New command.
Richard M. Stallman <rms@gnu.org>
parents: 3145
diff changeset
314 (interactive)
11890
543a76aa50b9 (describe-prefix-bindings): If key is a string,
Karl Heuer <kwzh@gnu.org>
parents: 11524
diff changeset
315 (let* ((key (this-command-keys)))
543a76aa50b9 (describe-prefix-bindings): If key is a string,
Karl Heuer <kwzh@gnu.org>
parents: 11524
diff changeset
316 (describe-bindings
543a76aa50b9 (describe-prefix-bindings): If key is a string,
Karl Heuer <kwzh@gnu.org>
parents: 11524
diff changeset
317 (if (stringp key)
543a76aa50b9 (describe-prefix-bindings): If key is a string,
Karl Heuer <kwzh@gnu.org>
parents: 11524
diff changeset
318 (substring key 0 (1- (length key)))
543a76aa50b9 (describe-prefix-bindings): If key is a string,
Karl Heuer <kwzh@gnu.org>
parents: 11524
diff changeset
319 (let ((prefix (make-vector (1- (length key)) nil))
543a76aa50b9 (describe-prefix-bindings): If key is a string,
Karl Heuer <kwzh@gnu.org>
parents: 11524
diff changeset
320 (i 0))
543a76aa50b9 (describe-prefix-bindings): If key is a string,
Karl Heuer <kwzh@gnu.org>
parents: 11524
diff changeset
321 (while (< i (length prefix))
543a76aa50b9 (describe-prefix-bindings): If key is a string,
Karl Heuer <kwzh@gnu.org>
parents: 11524
diff changeset
322 (aset prefix i (aref key i))
543a76aa50b9 (describe-prefix-bindings): If key is a string,
Karl Heuer <kwzh@gnu.org>
parents: 11524
diff changeset
323 (setq i (1+ i)))
543a76aa50b9 (describe-prefix-bindings): If key is a string,
Karl Heuer <kwzh@gnu.org>
parents: 11524
diff changeset
324 prefix)))))
39728
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
325 ;; Make C-h after a prefix, when not specifically bound,
3982
e50f7b531c7f (describe-prefix-bindings): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 3980
diff changeset
326 ;; run describe-prefix-bindings.
3980
bf2d4294a1dd (describe-prefix-bindings): New command.
Richard M. Stallman <rms@gnu.org>
parents: 3145
diff changeset
327 (setq prefix-help-command 'describe-prefix-bindings)
bf2d4294a1dd (describe-prefix-bindings): New command.
Richard M. Stallman <rms@gnu.org>
parents: 3145
diff changeset
328
21210
2a51a4912199 (view-emacs-news): Handle prefix arg.
Richard M. Stallman <rms@gnu.org>
parents: 21188
diff changeset
329 (defun view-emacs-news (&optional arg)
2a51a4912199 (view-emacs-news): Handle prefix arg.
Richard M. Stallman <rms@gnu.org>
parents: 21188
diff changeset
330 "Display info on recent changes to Emacs.
55172
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
331 With argument, display info only for the selected version."
21210
2a51a4912199 (view-emacs-news): Handle prefix arg.
Richard M. Stallman <rms@gnu.org>
parents: 21188
diff changeset
332 (interactive "P")
55172
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
333 (if (not arg)
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
334 (view-file (expand-file-name "NEWS" data-directory))
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
335 (let* ((map (sort
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
336 (delete-dups
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
337 (apply
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
338 'nconc
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
339 (mapcar
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
340 (lambda (file)
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
341 (with-temp-buffer
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
342 (insert-file-contents
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
343 (expand-file-name file data-directory))
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
344 (let (res)
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
345 (while (re-search-forward
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
346 (if (string-match "^ONEWS\\.[0-9]+$" file)
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
347 "Changes in \\(?:Emacs\\|version\\)?[ \t]*\\([0-9]+\\(?:\\.[0-9]+\\)?\\)"
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
348 "^\* [^0-9\n]*\\([0-9]+\\.[0-9]+\\)") nil t)
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
349 (setq res (cons (list (match-string-no-properties 1)
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
350 file) res)))
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
351 res)))
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
352 (append '("NEWS" "ONEWS")
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
353 (directory-files data-directory nil
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
354 "^ONEWS\\.[0-9]+$" nil)))))
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
355 (lambda (a b)
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
356 (string< (car b) (car a)))))
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
357 (current (caar map))
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
358 (version (completing-read
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
359 (format "Read NEWS for the version (default %s): " current)
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
360 (mapcar 'car map) nil nil nil nil current))
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
361 (file (cadr (assoc version map)))
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
362 res)
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
363 (if (not file)
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
364 (error "No news is good news")
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
365 (view-file (expand-file-name file data-directory))
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
366 (widen)
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
367 (goto-char (point-min))
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
368 (when (re-search-forward
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
369 (concat (if (string-match "^ONEWS\\.[0-9]+$" file)
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
370 "Changes in \\(?:Emacs\\|version\\)?[ \t]*"
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
371 "^\* [^0-9\n]*") version)
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
372 nil t)
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
373 (beginning-of-line)
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
374 (narrow-to-region
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
375 (point)
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
376 (save-excursion
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
377 (while (and (setq res
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
378 (re-search-forward
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
379 (if (string-match "^ONEWS\\.[0-9]+$" file)
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
380 "Changes in \\(?:Emacs\\|version\\)?[ \t]*\\([0-9]+\\(?:\\.[0-9]+\\)?\\)"
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
381 "^\* [^0-9\n]*\\([0-9]+\\.[0-9]+\\)") nil t))
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
382 (equal (match-string-no-properties 1) version)))
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
383 (or res (goto-char (point-max)))
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
384 (beginning-of-line)
a1210c6fc77b (view-emacs-news): With argument, display info for the
Juri Linkov <juri@jurta.org>
parents: 54815
diff changeset
385 (point))))))))
409
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386
45070
fbd816e9e27d (view-todo): New function.
Richard M. Stallman <rms@gnu.org>
parents: 44537
diff changeset
387 (defun view-todo (&optional arg)
fbd816e9e27d (view-todo): New function.
Richard M. Stallman <rms@gnu.org>
parents: 44537
diff changeset
388 "Display the Emacs TODO list."
fbd816e9e27d (view-todo): New function.
Richard M. Stallman <rms@gnu.org>
parents: 44537
diff changeset
389 (interactive "P")
fbd816e9e27d (view-todo): New function.
Richard M. Stallman <rms@gnu.org>
parents: 44537
diff changeset
390 (view-file (expand-file-name "TODO" data-directory)))
fbd816e9e27d (view-todo): New function.
Richard M. Stallman <rms@gnu.org>
parents: 44537
diff changeset
391
42735
86919cd01cdd (view-echo-area-messages): New function.
Richard M. Stallman <rms@gnu.org>
parents: 42679
diff changeset
392 (defun view-echo-area-messages ()
86919cd01cdd (view-echo-area-messages): New function.
Richard M. Stallman <rms@gnu.org>
parents: 42679
diff changeset
393 "View the log of recent echo-area messages: the `*Messages*' buffer.
86919cd01cdd (view-echo-area-messages): New function.
Richard M. Stallman <rms@gnu.org>
parents: 42679
diff changeset
394 The number of messages retained in that buffer
86919cd01cdd (view-echo-area-messages): New function.
Richard M. Stallman <rms@gnu.org>
parents: 42679
diff changeset
395 is specified by the variable `message-log-max'."
86919cd01cdd (view-echo-area-messages): New function.
Richard M. Stallman <rms@gnu.org>
parents: 42679
diff changeset
396 (interactive)
86919cd01cdd (view-echo-area-messages): New function.
Richard M. Stallman <rms@gnu.org>
parents: 42679
diff changeset
397 (switch-to-buffer (get-buffer-create "*Messages*")))
86919cd01cdd (view-echo-area-messages): New function.
Richard M. Stallman <rms@gnu.org>
parents: 42679
diff changeset
398
36277
ab9c82e64020 (view-order-manuals): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 36249
diff changeset
399 (defun view-order-manuals ()
ab9c82e64020 (view-order-manuals): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 36249
diff changeset
400 "Display the Emacs ORDERS file."
ab9c82e64020 (view-order-manuals): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 36249
diff changeset
401 (interactive)
42254
ffef7ba0b65d (view-order-manuals, view-emacs-news, describe-copying)
Richard M. Stallman <rms@gnu.org>
parents: 39789
diff changeset
402 (view-file (expand-file-name "ORDERS" data-directory))
36398
f20c9b522f1d (view-order-manuals): Use goto-address.
Gerd Moellmann <gerd@gnu.org>
parents: 36277
diff changeset
403 (goto-address))
36277
ab9c82e64020 (view-order-manuals): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 36249
diff changeset
404
10923
fe008aef4cf1 (view-emacs-FAQ): New function. Bind to C-h F.
Richard M. Stallman <rms@gnu.org>
parents: 10622
diff changeset
405 (defun view-emacs-FAQ ()
fe008aef4cf1 (view-emacs-FAQ): New function. Bind to C-h F.
Richard M. Stallman <rms@gnu.org>
parents: 10622
diff changeset
406 "Display the Emacs Frequently Asked Questions (FAQ) file."
fe008aef4cf1 (view-emacs-FAQ): New function. Bind to C-h F.
Richard M. Stallman <rms@gnu.org>
parents: 10622
diff changeset
407 (interactive)
39786
f50214c096af (describe-bindings-internal): New fun moved from keymap.c.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39728
diff changeset
408 ;; (find-file-read-only (expand-file-name "FAQ" data-directory))
28935
0a2323529cff (view-emacs-FAQ): Change `emacs-faq' to `efaq'.
Gerd Moellmann <gerd@gnu.org>
parents: 28909
diff changeset
409 (info "(efaq)"))
10923
fe008aef4cf1 (view-emacs-FAQ): New function. Bind to C-h F.
Richard M. Stallman <rms@gnu.org>
parents: 10622
diff changeset
410
26757
6af9f1dc59c4 (view-emacs-problems): New command, bound to C-h P.
Dave Love <fx@gnu.org>
parents: 26650
diff changeset
411 (defun view-emacs-problems ()
6af9f1dc59c4 (view-emacs-problems): New command, bound to C-h P.
Dave Love <fx@gnu.org>
parents: 26650
diff changeset
412 "Display info on known problems with Emacs and possible workarounds."
6af9f1dc59c4 (view-emacs-problems): New command, bound to C-h P.
Dave Love <fx@gnu.org>
parents: 26650
diff changeset
413 (interactive)
6af9f1dc59c4 (view-emacs-problems): New command, bound to C-h P.
Dave Love <fx@gnu.org>
parents: 26650
diff changeset
414 (view-file (expand-file-name "PROBLEMS" data-directory)))
6af9f1dc59c4 (view-emacs-problems): New command, bound to C-h P.
Dave Love <fx@gnu.org>
parents: 26650
diff changeset
415
409
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
416 (defun view-lossage ()
36975
d0fab2f2af5a (view-lossage): Mention open-dribble-file in the doc
Eli Zaretskii <eliz@gnu.org>
parents: 36777
diff changeset
417 "Display last 100 input keystrokes.
d0fab2f2af5a (view-lossage): Mention open-dribble-file in the doc
Eli Zaretskii <eliz@gnu.org>
parents: 36777
diff changeset
418
d0fab2f2af5a (view-lossage): Mention open-dribble-file in the doc
Eli Zaretskii <eliz@gnu.org>
parents: 36777
diff changeset
419 To record all your input on a file, use `open-dribble-file'."
409
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420 (interactive)
39789
e511f555920c (view-lossage): Call help-setup-xref correctly and earlier.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39786
diff changeset
421 (help-setup-xref (list #'view-lossage) (interactive-p))
e511f555920c (view-lossage): Call help-setup-xref correctly and earlier.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39786
diff changeset
422 (with-output-to-temp-buffer (help-buffer)
44332
bdf6c2baa447 (help-key-description): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43697
diff changeset
423 (princ (mapconcat (lambda (key)
bdf6c2baa447 (help-key-description): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43697
diff changeset
424 (if (or (integerp key) (symbolp key) (listp key))
bdf6c2baa447 (help-key-description): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43697
diff changeset
425 (single-key-description key)
bdf6c2baa447 (help-key-description): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43697
diff changeset
426 (prin1-to-string key nil)))
8504
8c492f23ee28 (view-lossage): Handle buffers and frames in recent-keys.
Richard M. Stallman <rms@gnu.org>
parents: 8259
diff changeset
427 (recent-keys)
8c492f23ee28 (view-lossage): Handle buffers and frames in recent-keys.
Richard M. Stallman <rms@gnu.org>
parents: 8259
diff changeset
428 " "))
39659
4bd383bb2137 (help-mode): Use define-derived-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39651
diff changeset
429 (with-current-buffer standard-output
409
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
430 (goto-char (point-min))
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
431 (while (progn (move-to-column 50) (not (eobp)))
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
432 (search-forward " " nil t)
39789
e511f555920c (view-lossage): Call help-setup-xref correctly and earlier.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39786
diff changeset
433 (insert "\n")))
409
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
434 (print-help-return-message)))
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
435
39728
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
436
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
437 ;; Key bindings
409
671fceb3316b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
438
22325
baef082e5d6d (help-setup-xref): Change all callers to
Karl Heuer <kwzh@gnu.org>
parents: 22234
diff changeset
439 (defun describe-bindings (&optional prefix buffer)
20848
4c3e62fe8898 (describe-bindings): New command (formerly in keymap.c).
Richard M. Stallman <rms@gnu.org>
parents: 20290
diff changeset
440 "Show a list of all defined keys, and their definitions.
4c3e62fe8898 (describe-bindings): New command (formerly in keymap.c).
Richard M. Stallman <rms@gnu.org>
parents: 20290
diff changeset
441 We put that list in a buffer, and display the buffer.
4c3e62fe8898 (describe-bindings): New command (formerly in keymap.c).
Richard M. Stallman <rms@gnu.org>
parents: 20290
diff changeset
442
4c3e62fe8898 (describe-bindings): New command (formerly in keymap.c).
Richard M. Stallman <rms@gnu.org>
parents: 20290
diff changeset
443 The optional argument PREFIX, if non-nil, should be a key sequence;
22325
baef082e5d6d (help-setup-xref): Change all callers to
Karl Heuer <kwzh@gnu.org>
parents: 22234
diff changeset
444 then we display only bindings that start with that prefix.
baef082e5d6d (help-setup-xref): Change all callers to
Karl Heuer <kwzh@gnu.org>
parents: 22234
diff changeset
445 The optional argument BUFFER specifies which buffer's bindings
56637
4ea7f10f1b53 (describe-bindings): Doc fix.
Luc Teirlinck <teirllm@auburn.edu>
parents: 55172
diff changeset
446 to display (default, the current buffer). BUFFER can be a buffer
4ea7f10f1b53 (describe-bindings): Doc fix.
Luc Teirlinck <teirllm@auburn.edu>
parents: 55172
diff changeset
447 or a buffer name."
39789
e511f555920c (view-lossage): Call help-setup-xref correctly and earlier.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39786
diff changeset
448 (interactive)
22325
baef082e5d6d (help-setup-xref): Change all callers to
Karl Heuer <kwzh@gnu.org>
parents: 22234
diff changeset
449 (or buffer (setq buffer (current-buffer)))
39789
e511f555920c (view-lossage): Call help-setup-xref correctly and earlier.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39786
diff changeset
450 (help-setup-xref (list #'describe-bindings prefix buffer) (interactive-p))
22325
baef082e5d6d (help-setup-xref): Change all callers to
Karl Heuer <kwzh@gnu.org>
parents: 22234
diff changeset
451 (with-current-buffer buffer
39789
e511f555920c (view-lossage): Call help-setup-xref correctly and earlier.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39786
diff changeset
452 (describe-bindings-internal nil prefix)))
20848
4c3e62fe8898 (describe-bindings): New command (formerly in keymap.c).
Richard M. Stallman <rms@gnu.org>
parents: 20290
diff changeset
453
39786
f50214c096af (describe-bindings-internal): New fun moved from keymap.c.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39728
diff changeset
454 ;; This function used to be in keymap.c.
f50214c096af (describe-bindings-internal): New fun moved from keymap.c.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39728
diff changeset
455 (defun describe-bindings-internal (&optional menus prefix)
f50214c096af (describe-bindings-internal): New fun moved from keymap.c.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39728
diff changeset
456 "Show a list of all defined keys, and their definitions.
f50214c096af (describe-bindings-internal): New fun moved from keymap.c.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39728
diff changeset
457 We put that list in a buffer, and display the buffer.
f50214c096af (describe-bindings-internal): New fun moved from keymap.c.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39728
diff changeset
458
f50214c096af (describe-bindings-internal): New fun moved from keymap.c.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39728
diff changeset
459 The optional argument MENUS, if non-nil, says to mention menu bindings.
f50214c096af (describe-bindings-internal): New fun moved from keymap.c.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39728
diff changeset
460 \(Ordinarily these are omitted from the output.)
f50214c096af (describe-bindings-internal): New fun moved from keymap.c.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39728
diff changeset
461 The optional argument PREFIX, if non-nil, should be a key sequence;
f50214c096af (describe-bindings-internal): New fun moved from keymap.c.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39728
diff changeset
462 then we display only bindings that start with that prefix."
f50214c096af (describe-bindings-internal): New fun moved from keymap.c.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39728
diff changeset
463 (interactive)
f50214c096af (describe-bindings-internal): New fun moved from keymap.c.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39728
diff changeset
464 (let ((buf (current-buffer)))
f50214c096af (describe-bindings-internal): New fun moved from keymap.c.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39728
diff changeset
465 (with-output-to-temp-buffer "*Help*"
f50214c096af (describe-bindings-internal): New fun moved from keymap.c.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39728
diff changeset
466 (with-current-buffer standard-output
f50214c096af (describe-bindings-internal): New fun moved from keymap.c.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39728
diff changeset
467 (describe-buffer-bindings buf prefix menus)))))
f50214c096af (describe-bindings-internal): New fun moved from keymap.c.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39728
diff changeset
468
17917
2a41f677885f (describe-key-briefly, where-is): Prefix arg means
Richard M. Stallman <rms@gnu.org>
parents: 17756
diff changeset
469 (defun where-is (definition &optional insert)
24079
11e777f59a1f (help-make-xrefs): Avoid infloop in keymap substitutions
Dave Love <fx@gnu.org>
parents: 24055
diff changeset
470 "Print message listing key sequences that invoke the command DEFINITION.
17917
2a41f677885f (describe-key-briefly, where-is): Prefix arg means
Richard M. Stallman <rms@gnu.org>
parents: 17756
diff changeset
471 Argument is a command definition, usually a symbol with a function definition.
2a41f677885f (describe-key-briefly, where-is): Prefix arg means
Richard M. Stallman <rms@gnu.org>
parents: 17756
diff changeset
472 If INSERT (the prefix arg) is non-nil, insert the message in the buffer."
6476
2e28b96d5b64 (where-is): New function.
Richard M. Stallman <rms@gnu.org>
parents: 6433
diff changeset
473 (interactive
2e28b96d5b64 (where-is): New function.
Richard M. Stallman <rms@gnu.org>
parents: 6433
diff changeset
474 (let ((fn (function-called-at-point))
39728
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
475 (enable-recursive-minibuffers t)
6476
2e28b96d5b64 (where-is): New function.
Richard M. Stallman <rms@gnu.org>
parents: 6433
diff changeset
476 val)
48202
50c0685806fb (where-is): Rename map to defs (a list of syms is not a map).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48193
diff changeset
477 (setq val (completing-read
50c0685806fb (where-is): Rename map to defs (a list of syms is not a map).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48193
diff changeset
478 (if fn
50c0685806fb (where-is): Rename map to defs (a list of syms is not a map).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48193
diff changeset
479 (format "Where is command (default %s): " fn)
50c0685806fb (where-is): Rename map to defs (a list of syms is not a map).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48193
diff changeset
480 "Where is command: ")
50c0685806fb (where-is): Rename map to defs (a list of syms is not a map).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48193
diff changeset
481 obarray 'commandp t))
50c0685806fb (where-is): Rename map to defs (a list of syms is not a map).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48193
diff changeset
482 (list (if (equal val "") fn (intern val)) current-prefix-arg)))
48193
0afe1465ac57 (where-is): Repport also aliases of the passed command.
Juanma Barranquero <lekktu@gmail.com>
parents: 46438
diff changeset
483 (let ((func (indirect-function definition))
48202
50c0685806fb (where-is): Rename map to defs (a list of syms is not a map).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48193
diff changeset
484 (defs nil)
48193
0afe1465ac57 (where-is): Repport also aliases of the passed command.
Juanma Barranquero <lekktu@gmail.com>
parents: 46438
diff changeset
485 (standard-output (if insert (current-buffer) t)))
60779
456199ab7d27 (where-is): Don't mention aliases with no key bindings.
Richard M. Stallman <rms@gnu.org>
parents: 60644
diff changeset
486 ;; In DEFS, find all symbols that are aliases for DEFINITION.
48202
50c0685806fb (where-is): Rename map to defs (a list of syms is not a map).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48193
diff changeset
487 (mapatoms (lambda (symbol)
50c0685806fb (where-is): Rename map to defs (a list of syms is not a map).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48193
diff changeset
488 (and (fboundp symbol)
50c0685806fb (where-is): Rename map to defs (a list of syms is not a map).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48193
diff changeset
489 (not (eq symbol definition))
49188
4e3e9d5a3332 (where-is): Catch errors in indirect-function.
Richard M. Stallman <rms@gnu.org>
parents: 48202
diff changeset
490 (eq func (condition-case ()
4e3e9d5a3332 (where-is): Catch errors in indirect-function.
Richard M. Stallman <rms@gnu.org>
parents: 48202
diff changeset
491 (indirect-function symbol)
4e3e9d5a3332 (where-is): Catch errors in indirect-function.
Richard M. Stallman <rms@gnu.org>
parents: 48202
diff changeset
492 (error symbol)))
48202
50c0685806fb (where-is): Rename map to defs (a list of syms is not a map).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48193
diff changeset
493 (push symbol defs))))
60779
456199ab7d27 (where-is): Don't mention aliases with no key bindings.
Richard M. Stallman <rms@gnu.org>
parents: 60644
diff changeset
494 ;; Look at all the symbols--first DEFINITION,
456199ab7d27 (where-is): Don't mention aliases with no key bindings.
Richard M. Stallman <rms@gnu.org>
parents: 60644
diff changeset
495 ;; then its aliases.
456199ab7d27 (where-is): Don't mention aliases with no key bindings.
Richard M. Stallman <rms@gnu.org>
parents: 60644
diff changeset
496 (dolist (symbol (cons definition defs))
456199ab7d27 (where-is): Don't mention aliases with no key bindings.
Richard M. Stallman <rms@gnu.org>
parents: 60644
diff changeset
497 (let* ((remapped (command-remapping symbol))
456199ab7d27 (where-is): Don't mention aliases with no key bindings.
Richard M. Stallman <rms@gnu.org>
parents: 60644
diff changeset
498 (keys (where-is-internal
456199ab7d27 (where-is): Don't mention aliases with no key bindings.
Richard M. Stallman <rms@gnu.org>
parents: 60644
diff changeset
499 symbol overriding-local-map nil nil remapped))
456199ab7d27 (where-is): Don't mention aliases with no key bindings.
Richard M. Stallman <rms@gnu.org>
parents: 60644
diff changeset
500 (keys (mapconcat 'key-description keys ", "))
456199ab7d27 (where-is): Don't mention aliases with no key bindings.
Richard M. Stallman <rms@gnu.org>
parents: 60644
diff changeset
501 string)
456199ab7d27 (where-is): Don't mention aliases with no key bindings.
Richard M. Stallman <rms@gnu.org>
parents: 60644
diff changeset
502 (setq string
456199ab7d27 (where-is): Don't mention aliases with no key bindings.
Richard M. Stallman <rms@gnu.org>
parents: 60644
diff changeset
503 (if insert
456199ab7d27 (where-is): Don't mention aliases with no key bindings.
Richard M. Stallman <rms@gnu.org>
parents: 60644
diff changeset
504 (if (> (length keys) 0)
456199ab7d27 (where-is): Don't mention aliases with no key bindings.
Richard M. Stallman <rms@gnu.org>
parents: 60644
diff changeset
505 (if remapped
456199ab7d27 (where-is): Don't mention aliases with no key bindings.
Richard M. Stallman <rms@gnu.org>
parents: 60644
diff changeset
506 (format "%s (%s) (remapped from %s)"
456199ab7d27 (where-is): Don't mention aliases with no key bindings.
Richard M. Stallman <rms@gnu.org>
parents: 60644
diff changeset
507 keys remapped symbol)
456199ab7d27 (where-is): Don't mention aliases with no key bindings.
Richard M. Stallman <rms@gnu.org>
parents: 60644
diff changeset
508 (format "%s (%s)" keys symbol))
456199ab7d27 (where-is): Don't mention aliases with no key bindings.
Richard M. Stallman <rms@gnu.org>
parents: 60644
diff changeset
509 (format "M-x %s RET" symbol))
456199ab7d27 (where-is): Don't mention aliases with no key bindings.
Richard M. Stallman <rms@gnu.org>
parents: 60644
diff changeset
510 (if (> (length keys) 0)
456199ab7d27 (where-is): Don't mention aliases with no key bindings.
Richard M. Stallman <rms@gnu.org>
parents: 60644
diff changeset
511 (if remapped
456199ab7d27 (where-is): Don't mention aliases with no key bindings.
Richard M. Stallman <rms@gnu.org>
parents: 60644
diff changeset
512 (format "%s is remapped to %s which is on %s"
68870
9cc0a5b4b6e7 (where-is): Fix displaying of remappings.
Juanma Barranquero <lekktu@gmail.com>
parents: 68855
diff changeset
513 symbol remapped keys)
60779
456199ab7d27 (where-is): Don't mention aliases with no key bindings.
Richard M. Stallman <rms@gnu.org>
parents: 60644
diff changeset
514 (format "%s is on %s" symbol keys))
456199ab7d27 (where-is): Don't mention aliases with no key bindings.
Richard M. Stallman <rms@gnu.org>
parents: 60644
diff changeset
515 ;; If this is the command the user asked about,
456199ab7d27 (where-is): Don't mention aliases with no key bindings.
Richard M. Stallman <rms@gnu.org>
parents: 60644
diff changeset
516 ;; and it is not on any key, say so.
456199ab7d27 (where-is): Don't mention aliases with no key bindings.
Richard M. Stallman <rms@gnu.org>
parents: 60644
diff changeset
517 ;; For other symbols, its aliases, say nothing
456199ab7d27 (where-is): Don't mention aliases with no key bindings.
Richard M. Stallman <rms@gnu.org>
parents: 60644
diff changeset
518 ;; about them unless they are on keys.
456199ab7d27 (where-is): Don't mention aliases with no key bindings.
Richard M. Stallman <rms@gnu.org>
parents: 60644
diff changeset
519 (if (eq symbol definition)
456199ab7d27 (where-is): Don't mention aliases with no key bindings.
Richard M. Stallman <rms@gnu.org>
parents: 60644
diff changeset
520 (format "%s is not on any key" symbol)))))
456199ab7d27 (where-is): Don't mention aliases with no key bindings.
Richard M. Stallman <rms@gnu.org>
parents: 60644
diff changeset
521 (when string
456199ab7d27 (where-is): Don't mention aliases with no key bindings.
Richard M. Stallman <rms@gnu.org>
parents: 60644
diff changeset
522 (unless (eq symbol definition)
456199ab7d27 (where-is): Don't mention aliases with no key bindings.
Richard M. Stallman <rms@gnu.org>
parents: 60644
diff changeset
523 (princ ";\n its alias "))
456199ab7d27 (where-is): Don't mention aliases with no key bindings.
Richard M. Stallman <rms@gnu.org>
parents: 60644
diff changeset
524 (princ string)))))
6476
2e28b96d5b64 (where-is): New function.
Richard M. Stallman <rms@gnu.org>
parents: 6433
diff changeset
525 nil)
2e28b96d5b64 (where-is): New function.
Richard M. Stallman <rms@gnu.org>
parents: 6433
diff changeset
526
39728
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
527 (defun string-key-binding (key)
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
528 "Value is the binding of KEY in a string.
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
529 If KEY is an event on a string, and that string has a `local-map'
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
530 or `keymap' property, return the binding of KEY in the string's keymap."
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
531 (let* ((defn nil)
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
532 (start (when (vectorp key)
44537
a80baec69a4e (string-key-binding): Deal with margin events.
Gerd Moellmann <gerd@gnu.org>
parents: 44332
diff changeset
533 (if (memq (aref key 0)
a80baec69a4e (string-key-binding): Deal with margin events.
Gerd Moellmann <gerd@gnu.org>
parents: 44332
diff changeset
534 '(mode-line header-line left-margin right-margin))
39728
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
535 (event-start (aref key 1))
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
536 (and (consp (aref key 0))
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
537 (event-start (aref key 0))))))
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
538 (string-info (and (consp start) (nth 4 start))))
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
539 (when string-info
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
540 (let* ((string (car string-info))
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
541 (pos (cdr string-info))
44537
a80baec69a4e (string-key-binding): Deal with margin events.
Gerd Moellmann <gerd@gnu.org>
parents: 44332
diff changeset
542 (local-map (and (>= pos 0)
39728
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
543 (< pos (length string))
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
544 (or (get-text-property pos 'local-map string)
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
545 (get-text-property pos 'keymap string)))))
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
546 (setq defn (and local-map (lookup-key local-map key)))))
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
547 defn))
24079
11e777f59a1f (help-make-xrefs): Avoid infloop in keymap substitutions
Dave Love <fx@gnu.org>
parents: 24055
diff changeset
548
44332
bdf6c2baa447 (help-key-description): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43697
diff changeset
549 (defun help-key-description (key untranslated)
bdf6c2baa447 (help-key-description): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43697
diff changeset
550 (let ((string (key-description key)))
46438
fd2419f6c4d9 (help-key-description): Show the untranslated keys
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46329
diff changeset
551 (if (or (not untranslated)
fd2419f6c4d9 (help-key-description): Show the untranslated keys
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46329
diff changeset
552 (and (eq (aref untranslated 0) ?\e) (not (eq (aref key 0) ?\e))))
44332
bdf6c2baa447 (help-key-description): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43697
diff changeset
553 string
bdf6c2baa447 (help-key-description): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43697
diff changeset
554 (let ((otherstring (key-description untranslated)))
bdf6c2baa447 (help-key-description): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43697
diff changeset
555 (if (equal string otherstring)
bdf6c2baa447 (help-key-description): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43697
diff changeset
556 string
bdf6c2baa447 (help-key-description): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43697
diff changeset
557 (format "%s (translated from %s)" string otherstring))))))
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49188
diff changeset
558
68793
71c7af923901 (describe-key-briefly): Now a wrapper for describe-key-briefly-internal.
Eli Zaretskii <eliz@gnu.org>
parents: 68651
diff changeset
559 (defun describe-key-briefly (&optional key insert untranslated)
71c7af923901 (describe-key-briefly): Now a wrapper for describe-key-briefly-internal.
Eli Zaretskii <eliz@gnu.org>
parents: 68651
diff changeset
560 "Print the name of the function KEY invokes. KEY is a string.
71c7af923901 (describe-key-briefly): Now a wrapper for describe-key-briefly-internal.
Eli Zaretskii <eliz@gnu.org>
parents: 68651
diff changeset
561 If INSERT (the prefix arg) is non-nil, insert the message in the buffer.
71c7af923901 (describe-key-briefly): Now a wrapper for describe-key-briefly-internal.
Eli Zaretskii <eliz@gnu.org>
parents: 68651
diff changeset
562 If non-nil, UNTRANSLATED is a vector of the untranslated events.
71c7af923901 (describe-key-briefly): Now a wrapper for describe-key-briefly-internal.
Eli Zaretskii <eliz@gnu.org>
parents: 68651
diff changeset
563 It can also be a number in which case the untranslated events from
71c7af923901 (describe-key-briefly): Now a wrapper for describe-key-briefly-internal.
Eli Zaretskii <eliz@gnu.org>
parents: 68651
diff changeset
564 the last key hit are used.
71c7af923901 (describe-key-briefly): Now a wrapper for describe-key-briefly-internal.
Eli Zaretskii <eliz@gnu.org>
parents: 68651
diff changeset
565
71c7af923901 (describe-key-briefly): Now a wrapper for describe-key-briefly-internal.
Eli Zaretskii <eliz@gnu.org>
parents: 68651
diff changeset
566 If KEY is a menu item or a tool-bar button that is disabled, this command
68795
687ce2ace7b8 (describe-key-briefly, describe-key): Populate yank-menu if empty.
Eli Zaretskii <eliz@gnu.org>
parents: 68793
diff changeset
567 temporarily enables it to allow getting help on disabled items and buttons."
68855
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
568 (interactive
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
569 (let ((enable-disabled-menus-and-buttons t)
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
570 (cursor-in-echo-area t)
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
571 saved-yank-menu)
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
572 (unwind-protect
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
573 (let (key)
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
574 ;; If yank-menu is empty, populate it temporarily, so that
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
575 ;; "Select and Paste" menu can generate a complete event.
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
576 (when (null (cdr yank-menu))
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
577 (setq saved-yank-menu (copy-sequence yank-menu))
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
578 (menu-bar-update-yank-menu "(any string)" nil))
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
579 (setq key (read-key-sequence "Describe key (or click or menu item): "))
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
580 (list
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
581 key
69077
f8759a14f4cd (describe-key-briefly): Compute interactive args
Richard M. Stallman <rms@gnu.org>
parents: 68870
diff changeset
582 (if current-prefix-arg (prefix-numeric-value current-prefix-arg))
f8759a14f4cd (describe-key-briefly): Compute interactive args
Richard M. Stallman <rms@gnu.org>
parents: 68870
diff changeset
583 1))
68855
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
584 ;; Put yank-menu back as it was, if we changed it.
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
585 (when saved-yank-menu
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
586 (setq yank-menu (copy-sequence saved-yank-menu))
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
587 (fset 'yank-menu (cons 'keymap yank-menu))))))
44332
bdf6c2baa447 (help-key-description): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43697
diff changeset
588 (if (numberp untranslated)
bdf6c2baa447 (help-key-description): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43697
diff changeset
589 (setq untranslated (this-single-command-raw-keys)))
39728
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
590 (save-excursion
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
591 (let ((modifiers (event-modifiers (aref key 0)))
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
592 (standard-output (if insert (current-buffer) t))
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
593 window position)
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
594 ;; For a mouse button event, go to the button it applies to
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
595 ;; to get the right key bindings. And go to the right place
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
596 ;; in case the keymap depends on where you clicked.
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
597 (if (or (memq 'click modifiers) (memq 'down modifiers)
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
598 (memq 'drag modifiers))
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
599 (setq window (posn-window (event-start (aref key 0)))
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
600 position (posn-point (event-start (aref key 0)))))
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
601 (if (windowp window)
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
602 (progn
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
603 (set-buffer (window-buffer window))
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
604 (goto-char position)))
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
605 ;; Ok, now look up the key and name the command.
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
606 (let ((defn (or (string-key-binding key)
67204
0ae69a6a591d * help.el (describe-key-briefly, describe-key): Recognize default
Chong Yidong <cyd@stupidchicken.com>
parents: 67196
diff changeset
607 (key-binding key t)))
61423
f2d616f518a5 (describe-key-briefly, describe-key): Replace
Richard M. Stallman <rms@gnu.org>
parents: 60779
diff changeset
608 key-desc)
68855
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
609 ;; Handle the case where we faked an entry in "Select and Paste" menu.
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
610 (if (and (eq defn nil)
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
611 (stringp (aref key (1- (length key))))
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
612 (eq (key-binding (substring key 0 -1)) 'yank-menu))
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
613 (setq defn 'menu-bar-select-yank))
61423
f2d616f518a5 (describe-key-briefly, describe-key): Replace
Richard M. Stallman <rms@gnu.org>
parents: 60779
diff changeset
614 ;; Don't bother user with strings from (e.g.) the select-paste menu.
f2d616f518a5 (describe-key-briefly, describe-key): Replace
Richard M. Stallman <rms@gnu.org>
parents: 60779
diff changeset
615 (if (stringp (aref key (1- (length key))))
f2d616f518a5 (describe-key-briefly, describe-key): Replace
Richard M. Stallman <rms@gnu.org>
parents: 60779
diff changeset
616 (aset key (1- (length key)) "(any string)"))
61522
a5836c00c2ae (describe-key-briefly): UNTRANSLATED can be nil when called from lisp.
Lute Kamstra <lute@gnu.org>
parents: 61423
diff changeset
617 (if (and (> (length untranslated) 0)
a5836c00c2ae (describe-key-briefly): UNTRANSLATED can be nil when called from lisp.
Lute Kamstra <lute@gnu.org>
parents: 61423
diff changeset
618 (stringp (aref untranslated (1- (length untranslated)))))
61423
f2d616f518a5 (describe-key-briefly, describe-key): Replace
Richard M. Stallman <rms@gnu.org>
parents: 60779
diff changeset
619 (aset untranslated (1- (length untranslated))
f2d616f518a5 (describe-key-briefly, describe-key): Replace
Richard M. Stallman <rms@gnu.org>
parents: 60779
diff changeset
620 "(any string)"))
f2d616f518a5 (describe-key-briefly, describe-key): Replace
Richard M. Stallman <rms@gnu.org>
parents: 60779
diff changeset
621 ;; Now describe the key, perhaps as changed.
f2d616f518a5 (describe-key-briefly, describe-key): Replace
Richard M. Stallman <rms@gnu.org>
parents: 60779
diff changeset
622 (setq key-desc (help-key-description key untranslated))
43697
8dc5abd4533a (describe-key-briefly, describe-key): Interpret `undefined' like not
Pavel Janík <Pavel@Janik.cz>
parents: 43500
diff changeset
623 (if (or (null defn) (integerp defn) (equal defn 'undefined))
39728
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
624 (princ (format "%s is undefined" key-desc))
43309
63607f9209a0 (describe-key-briefly): Make output in INSERT case
Richard M. Stallman <rms@gnu.org>
parents: 43156
diff changeset
625 (princ (format (if (windowp window)
63607f9209a0 (describe-key-briefly): Make output in INSERT case
Richard M. Stallman <rms@gnu.org>
parents: 43156
diff changeset
626 "%s at that spot runs the command %s"
63607f9209a0 (describe-key-briefly): Make output in INSERT case
Richard M. Stallman <rms@gnu.org>
parents: 43156
diff changeset
627 "%s runs the command %s")
39728
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
628 key-desc
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
629 (if (symbolp defn) defn (prin1-to-string defn)))))))))
31243
30007aab98df (help-xref-mule-regexp): New variable
Kenichi Handa <handa@m17n.org>
parents: 30920
diff changeset
630
68793
71c7af923901 (describe-key-briefly): Now a wrapper for describe-key-briefly-internal.
Eli Zaretskii <eliz@gnu.org>
parents: 68651
diff changeset
631 (defun describe-key (&optional key untranslated up-event)
42357
253eec84f7d3 (describe-key): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 42254
diff changeset
632 "Display documentation of the function invoked by KEY.
66853
b33c167de495 (help-for-help-internal): Improve doc of C-h a.
Richard M. Stallman <rms@gnu.org>
parents: 66849
diff changeset
633 KEY can be any kind of a key sequence; it can include keyboard events,
b33c167de495 (help-for-help-internal): Improve doc of C-h a.
Richard M. Stallman <rms@gnu.org>
parents: 66849
diff changeset
634 mouse events, and/or menu events. When calling from a program,
b33c167de495 (help-for-help-internal): Improve doc of C-h a.
Richard M. Stallman <rms@gnu.org>
parents: 66849
diff changeset
635 pass KEY as a string or a vector.
b33c167de495 (help-for-help-internal): Improve doc of C-h a.
Richard M. Stallman <rms@gnu.org>
parents: 66849
diff changeset
636
67196
Chong Yidong <cyd@stupidchicken.com>
parents: 66853
diff changeset
637 If non-nil, UNTRANSLATED is a vector of the corresponding untranslated events.
66853
b33c167de495 (help-for-help-internal): Improve doc of C-h a.
Richard M. Stallman <rms@gnu.org>
parents: 66849
diff changeset
638 It can also be a number, in which case the untranslated events from
68793
71c7af923901 (describe-key-briefly): Now a wrapper for describe-key-briefly-internal.
Eli Zaretskii <eliz@gnu.org>
parents: 68651
diff changeset
639 the last key sequence entered are used.
71c7af923901 (describe-key-briefly): Now a wrapper for describe-key-briefly-internal.
Eli Zaretskii <eliz@gnu.org>
parents: 68651
diff changeset
640 UP-EVENT is the up-event that was discarded by reading KEY, or nil.
71c7af923901 (describe-key-briefly): Now a wrapper for describe-key-briefly-internal.
Eli Zaretskii <eliz@gnu.org>
parents: 68651
diff changeset
641
71c7af923901 (describe-key-briefly): Now a wrapper for describe-key-briefly-internal.
Eli Zaretskii <eliz@gnu.org>
parents: 68651
diff changeset
642 If KEY is a menu item or a tool-bar button that is disabled, this command
68795
687ce2ace7b8 (describe-key-briefly, describe-key): Populate yank-menu if empty.
Eli Zaretskii <eliz@gnu.org>
parents: 68793
diff changeset
643 temporarily enables it to allow getting help on disabled items and buttons."
68855
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
644 (interactive
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
645 (let ((enable-disabled-menus-and-buttons t)
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
646 (cursor-in-echo-area t)
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
647 saved-yank-menu)
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
648 (unwind-protect
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
649 (let (key)
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
650 ;; If yank-menu is empty, populate it temporarily, so that
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
651 ;; "Select and Paste" menu can generate a complete event.
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
652 (when (null (cdr yank-menu))
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
653 (setq saved-yank-menu (copy-sequence yank-menu))
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
654 (menu-bar-update-yank-menu "(any string)" nil))
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
655 (setq key (read-key-sequence "Describe key (or click or menu item): "))
69310
270a2959d019 * help.el (describe-key): Properly handle the return value of
Chong Yidong <cyd@stupidchicken.com>
parents: 69131
diff changeset
656 (setq foo key)
68855
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
657 (list
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
658 key
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
659 (prefix-numeric-value current-prefix-arg)
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
660 ;; If KEY is a down-event, read the corresponding up-event
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
661 ;; and use it as the third argument.
69310
270a2959d019 * help.el (describe-key): Properly handle the return value of
Chong Yidong <cyd@stupidchicken.com>
parents: 69131
diff changeset
662 (if (and (vectorp key)
270a2959d019 * help.el (describe-key): Properly handle the return value of
Chong Yidong <cyd@stupidchicken.com>
parents: 69131
diff changeset
663 (eventp (elt key 0))
270a2959d019 * help.el (describe-key): Properly handle the return value of
Chong Yidong <cyd@stupidchicken.com>
parents: 69131
diff changeset
664 (memq 'down (event-modifiers (elt key 0))))
68855
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
665 (read-event))))
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
666 ;; Put yank-menu back as it was, if we changed it.
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
667 (when saved-yank-menu
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
668 (setq yank-menu (copy-sequence saved-yank-menu))
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
669 (fset 'yank-menu (cons 'keymap yank-menu))))))
44332
bdf6c2baa447 (help-key-description): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43697
diff changeset
670 (if (numberp untranslated)
bdf6c2baa447 (help-key-description): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43697
diff changeset
671 (setq untranslated (this-single-command-raw-keys)))
21371
22a3be0ae9dc (help-highlight-face): Use underline.
Richard M. Stallman <rms@gnu.org>
parents: 21210
diff changeset
672 (save-excursion
39728
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
673 (let ((modifiers (event-modifiers (aref key 0)))
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
674 window position)
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
675 ;; For a mouse button event, go to the button it applies to
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
676 ;; to get the right key bindings. And go to the right place
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
677 ;; in case the keymap depends on where you clicked.
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
678 (if (or (memq 'click modifiers) (memq 'down modifiers)
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
679 (memq 'drag modifiers))
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
680 (setq window (posn-window (event-start (aref key 0)))
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
681 position (posn-point (event-start (aref key 0)))))
39786
f50214c096af (describe-bindings-internal): New fun moved from keymap.c.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39728
diff changeset
682 (when (windowp window)
39728
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
683 (set-buffer (window-buffer window))
39786
f50214c096af (describe-bindings-internal): New fun moved from keymap.c.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39728
diff changeset
684 (goto-char position))
67204
0ae69a6a591d * help.el (describe-key-briefly, describe-key): Recognize default
Chong Yidong <cyd@stupidchicken.com>
parents: 67196
diff changeset
685 (let ((defn (or (string-key-binding key) (key-binding key t))))
68855
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
686 ;; Handle the case where we faked an entry in "Select and Paste" menu.
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
687 (if (and (eq defn nil)
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
688 (stringp (aref key (1- (length key))))
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
689 (eq (key-binding (substring key 0 -1)) 'yank-menu))
284c53bcc6bf (describe-key-briefly, describe-key):
Richard M. Stallman <rms@gnu.org>
parents: 68795
diff changeset
690 (setq defn 'menu-bar-select-yank))
43697
8dc5abd4533a (describe-key-briefly, describe-key): Interpret `undefined' like not
Pavel Janík <Pavel@Janik.cz>
parents: 43500
diff changeset
691 (if (or (null defn) (integerp defn) (equal defn 'undefined))
44332
bdf6c2baa447 (help-key-description): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43697
diff changeset
692 (message "%s is undefined" (help-key-description key untranslated))
39789
e511f555920c (view-lossage): Call help-setup-xref correctly and earlier.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39786
diff changeset
693 (help-setup-xref (list #'describe-function defn) (interactive-p))
61423
f2d616f518a5 (describe-key-briefly, describe-key): Replace
Richard M. Stallman <rms@gnu.org>
parents: 60779
diff changeset
694 ;; Don't bother user with strings from (e.g.) the select-paste menu.
f2d616f518a5 (describe-key-briefly, describe-key): Replace
Richard M. Stallman <rms@gnu.org>
parents: 60779
diff changeset
695 (if (stringp (aref key (1- (length key))))
f2d616f518a5 (describe-key-briefly, describe-key): Replace
Richard M. Stallman <rms@gnu.org>
parents: 60779
diff changeset
696 (aset key (1- (length key)) "(any string)"))
62060
9f98f54d05d7 (describe-key): No error when UNTRANSLATED is nil.
Richard M. Stallman <rms@gnu.org>
parents: 61522
diff changeset
697 (if (and untranslated
9f98f54d05d7 (describe-key): No error when UNTRANSLATED is nil.
Richard M. Stallman <rms@gnu.org>
parents: 61522
diff changeset
698 (stringp (aref untranslated (1- (length untranslated)))))
61423
f2d616f518a5 (describe-key-briefly, describe-key): Replace
Richard M. Stallman <rms@gnu.org>
parents: 60779
diff changeset
699 (aset untranslated (1- (length untranslated))
f2d616f518a5 (describe-key-briefly, describe-key): Replace
Richard M. Stallman <rms@gnu.org>
parents: 60779
diff changeset
700 "(any string)"))
39789
e511f555920c (view-lossage): Call help-setup-xref correctly and earlier.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39786
diff changeset
701 (with-output-to-temp-buffer (help-buffer)
44332
bdf6c2baa447 (help-key-description): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43697
diff changeset
702 (princ (help-key-description key untranslated))
39728
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
703 (if (windowp window)
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
704 (princ " at that spot"))
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
705 (princ " runs the command ")
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
706 (prin1 defn)
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
707 (princ "\n which is ")
39789
e511f555920c (view-lossage): Call help-setup-xref correctly and earlier.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39786
diff changeset
708 (describe-function-1 defn)
69310
270a2959d019 * help.el (describe-key): Properly handle the return value of
Chong Yidong <cyd@stupidchicken.com>
parents: 69131
diff changeset
709 (setq foo up-event)
57709
fd2c192afcd3 (describe-key): Describe both down-event and up-event
Kim F. Storm <storm@cua.dk>
parents: 57678
diff changeset
710 (when up-event
69310
270a2959d019 * help.el (describe-key): Properly handle the return value of
Chong Yidong <cyd@stupidchicken.com>
parents: 69131
diff changeset
711 (let ((type (event-basic-type up-event))
59018
52e86589c83a (describe-key): Report effective and original binding
Kim F. Storm <storm@cua.dk>
parents: 58992
diff changeset
712 (hdr "\n\n-------------- up event ---------------\n\n")
52e86589c83a (describe-key): Report effective and original binding
Kim F. Storm <storm@cua.dk>
parents: 58992
diff changeset
713 defn
52e86589c83a (describe-key): Report effective and original binding
Kim F. Storm <storm@cua.dk>
parents: 58992
diff changeset
714 mouse-1-tricky mouse-1-remapped)
69310
270a2959d019 * help.el (describe-key): Properly handle the return value of
Chong Yidong <cyd@stupidchicken.com>
parents: 69131
diff changeset
715 (when (and (eq type 'mouse-1)
59018
52e86589c83a (describe-key): Report effective and original binding
Kim F. Storm <storm@cua.dk>
parents: 58992
diff changeset
716 (windowp window)
52e86589c83a (describe-key): Report effective and original binding
Kim F. Storm <storm@cua.dk>
parents: 58992
diff changeset
717 mouse-1-click-follows-link
52e86589c83a (describe-key): Report effective and original binding
Kim F. Storm <storm@cua.dk>
parents: 58992
diff changeset
718 (not (eq mouse-1-click-follows-link 'double))
52e86589c83a (describe-key): Report effective and original binding
Kim F. Storm <storm@cua.dk>
parents: 58992
diff changeset
719 (with-current-buffer (window-buffer window)
69310
270a2959d019 * help.el (describe-key): Properly handle the return value of
Chong Yidong <cyd@stupidchicken.com>
parents: 69131
diff changeset
720 (mouse-on-link-p (posn-point (event-start up-event)))))
270a2959d019 * help.el (describe-key): Properly handle the return value of
Chong Yidong <cyd@stupidchicken.com>
parents: 69131
diff changeset
721 (setq mouse-1-remapped t)
270a2959d019 * help.el (describe-key): Properly handle the return value of
Chong Yidong <cyd@stupidchicken.com>
parents: 69131
diff changeset
722 (setq mouse-1-tricky (and (integerp mouse-1-click-follows-link)
270a2959d019 * help.el (describe-key): Properly handle the return value of
Chong Yidong <cyd@stupidchicken.com>
parents: 69131
diff changeset
723 (> mouse-1-click-follows-link 0)))
270a2959d019 * help.el (describe-key): Properly handle the return value of
Chong Yidong <cyd@stupidchicken.com>
parents: 69131
diff changeset
724 (setcar up-event 'mouse-2))
270a2959d019 * help.el (describe-key): Properly handle the return value of
Chong Yidong <cyd@stupidchicken.com>
parents: 69131
diff changeset
725 (setq defn (key-binding (vector up-event)))
57709
fd2c192afcd3 (describe-key): Describe both down-event and up-event
Kim F. Storm <storm@cua.dk>
parents: 57678
diff changeset
726 (unless (or (null defn) (integerp defn) (equal defn 'undefined))
59018
52e86589c83a (describe-key): Report effective and original binding
Kim F. Storm <storm@cua.dk>
parents: 58992
diff changeset
727 (princ (if mouse-1-tricky
52e86589c83a (describe-key): Report effective and original binding
Kim F. Storm <storm@cua.dk>
parents: 58992
diff changeset
728 "\n\n----------------- up-event (short click) ----------------\n\n"
52e86589c83a (describe-key): Report effective and original binding
Kim F. Storm <storm@cua.dk>
parents: 58992
diff changeset
729 hdr))
52e86589c83a (describe-key): Report effective and original binding
Kim F. Storm <storm@cua.dk>
parents: 58992
diff changeset
730 (setq hdr nil)
69310
270a2959d019 * help.el (describe-key): Properly handle the return value of
Chong Yidong <cyd@stupidchicken.com>
parents: 69131
diff changeset
731 (princ (symbol-name type))
57709
fd2c192afcd3 (describe-key): Describe both down-event and up-event
Kim F. Storm <storm@cua.dk>
parents: 57678
diff changeset
732 (if (windowp window)
fd2c192afcd3 (describe-key): Describe both down-event and up-event
Kim F. Storm <storm@cua.dk>
parents: 57678
diff changeset
733 (princ " at that spot"))
59018
52e86589c83a (describe-key): Report effective and original binding
Kim F. Storm <storm@cua.dk>
parents: 58992
diff changeset
734 (if mouse-1-remapped
52e86589c83a (describe-key): Report effective and original binding
Kim F. Storm <storm@cua.dk>
parents: 58992
diff changeset
735 (princ " is remapped to <mouse-2>\n which" ))
57709
fd2c192afcd3 (describe-key): Describe both down-event and up-event
Kim F. Storm <storm@cua.dk>
parents: 57678
diff changeset
736 (princ " runs the command ")
fd2c192afcd3 (describe-key): Describe both down-event and up-event
Kim F. Storm <storm@cua.dk>
parents: 57678
diff changeset
737 (prin1 defn)
fd2c192afcd3 (describe-key): Describe both down-event and up-event
Kim F. Storm <storm@cua.dk>
parents: 57678
diff changeset
738 (princ "\n which is ")
59018
52e86589c83a (describe-key): Report effective and original binding
Kim F. Storm <storm@cua.dk>
parents: 58992
diff changeset
739 (describe-function-1 defn))
52e86589c83a (describe-key): Report effective and original binding
Kim F. Storm <storm@cua.dk>
parents: 58992
diff changeset
740 (when mouse-1-tricky
69310
270a2959d019 * help.el (describe-key): Properly handle the return value of
Chong Yidong <cyd@stupidchicken.com>
parents: 69131
diff changeset
741 (setcar up-event 'mouse-1)
270a2959d019 * help.el (describe-key): Properly handle the return value of
Chong Yidong <cyd@stupidchicken.com>
parents: 69131
diff changeset
742 (setq defn (key-binding (vector up-event)))
270a2959d019 * help.el (describe-key): Properly handle the return value of
Chong Yidong <cyd@stupidchicken.com>
parents: 69131
diff changeset
743 (unless (or (null defn) (integerp defn) (eq defn 'undefined))
59018
52e86589c83a (describe-key): Report effective and original binding
Kim F. Storm <storm@cua.dk>
parents: 58992
diff changeset
744 (princ (or hdr
52e86589c83a (describe-key): Report effective and original binding
Kim F. Storm <storm@cua.dk>
parents: 58992
diff changeset
745 "\n\n----------------- up-event (long click) ----------------\n\n"))
69310
270a2959d019 * help.el (describe-key): Properly handle the return value of
Chong Yidong <cyd@stupidchicken.com>
parents: 69131
diff changeset
746 (princ "Pressing mouse-1")
59018
52e86589c83a (describe-key): Report effective and original binding
Kim F. Storm <storm@cua.dk>
parents: 58992
diff changeset
747 (if (windowp window)
52e86589c83a (describe-key): Report effective and original binding
Kim F. Storm <storm@cua.dk>
parents: 58992
diff changeset
748 (princ " at that spot"))
52e86589c83a (describe-key): Report effective and original binding
Kim F. Storm <storm@cua.dk>
parents: 58992
diff changeset
749 (princ (format " for longer than %d milli-seconds\n"
69310
270a2959d019 * help.el (describe-key): Properly handle the return value of
Chong Yidong <cyd@stupidchicken.com>
parents: 69131
diff changeset
750 mouse-1-click-follows-link))
59018
52e86589c83a (describe-key): Report effective and original binding
Kim F. Storm <storm@cua.dk>
parents: 58992
diff changeset
751 (princ " runs the command ")
52e86589c83a (describe-key): Report effective and original binding
Kim F. Storm <storm@cua.dk>
parents: 58992
diff changeset
752 (prin1 defn)
52e86589c83a (describe-key): Report effective and original binding
Kim F. Storm <storm@cua.dk>
parents: 58992
diff changeset
753 (princ "\n which is ")
62624
519850fadc32 (describe-key): Move print-help-return-message call out of conditional.
Richard M. Stallman <rms@gnu.org>
parents: 62060
diff changeset
754 (describe-function-1 defn)))))
519850fadc32 (describe-key): Move print-help-return-message call out of conditional.
Richard M. Stallman <rms@gnu.org>
parents: 62060
diff changeset
755 (print-help-return-message)))))))
21371
22a3be0ae9dc (help-highlight-face): Use underline.
Richard M. Stallman <rms@gnu.org>
parents: 21210
diff changeset
756
39728
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
757 (defun describe-mode (&optional buffer)
570d86d34c32 Don't require `view' when compiling.
Miles Bader <miles@gnu.org>
parents: 39659
diff changeset
758 "Display documentation of current major mode and minor modes.
54815
d13dc0c5f80d (describe-mode): Doc fix.
John Paul Wallington <jpw@pobox.com>
parents: 53204
diff changeset
759 A brief summary of the minor modes comes first, followed by the
d13dc0c5f80d (describe-mode): Doc fix.
John Paul Wallington <jpw@pobox.com>
parents: 53204
diff changeset
760 major mode description. This is followed by detailed
d13dc0c5f80d (describe-mode): Doc fix.
John Paul Wallington <jpw@pobox.com>
parents: 53204
diff changeset
761 descriptions of the minor modes, each on a separate page.
d13dc0c5f80d (describe-mode): Doc fix.
John Paul Wallington <jpw@pobox.com>
parents: 53204
diff changeset
762
d13dc0c5f80d (describe-mode): Doc fix.
John Paul Wallington <jpw@pobox.com>
parents: 53204
diff changeset
763 For this to work correctly for a minor mode, the mode's indicator
d13dc0c5f80d (describe-mode): Doc fix.
John Paul Wallington <jpw@pobox.com>
parents: 53204
diff changeset
764 variable \(listed in `minor-mode-alist') must also be a function
d13dc0c5f80d (describe-mode): Doc fix.
John Paul Wallington <jpw@pobox.com>
parents: 53204
diff changeset
765 whose documentation describes the minor mode."
21371
22a3be0ae9dc (help-highlight-face): Use underline.
Richard M. Stallman <rms@gnu.org>
parents: 21210
diff changeset
766 (interactive)
60559
e886078cad44 (describe-mode): Properly handle non-trivial lighters.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60006
diff changeset
767 (unless buffer (setq buffer (current-buffer)))
e886078cad44 (describe-mode): Properly handle non-trivial lighters.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60006
diff changeset
768 (help-setup-xref (list #'describe-mode buffer)
42679
8e00fb340b95 (describe-mode): Call help-setup-xref in the help buffer.
Richard M. Stallman <rms@gnu.org>
parents: 42357
diff changeset
769 (interactive-p))
8e00fb340b95 (describe-mode): Call help-setup-xref in the help buffer.
Richard M. Stallman <rms@gnu.org>
parents: 42357
diff changeset
770 ;; For the sake of help-do-xref and help-xref-go-back,
8e00fb340b95 (describe-mode): Call help-setup-xref in the help buffer.
Richard M. Stallman <rms@gnu.org>
parents: 42357
diff changeset
771 ;; don't switch buffers before calling `help-buffer'.
39789
e511f555920c (view-lossage): Call help-setup-xref correctly and earlier.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39786
diff changeset
772 (with-output-to-temp-buffer (help-buffer)
60559
e886078cad44 (describe-mode): Properly handle non-trivial lighters.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60006
diff changeset
773 (with-current-buffer buffer
52690
212969e10f09 (describe-mode): Start with a brief list of minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
774 (let (minor-modes)
60559
e886078cad44 (describe-mode): Properly handle non-trivial lighters.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60006
diff changeset
775 ;; Older packages do not register in minor-mode-list but only in
e886078cad44 (describe-mode): Properly handle non-trivial lighters.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60006
diff changeset
776 ;; minor-mode-alist.
e886078cad44 (describe-mode): Properly handle non-trivial lighters.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60006
diff changeset
777 (dolist (x minor-mode-alist)
e886078cad44 (describe-mode): Properly handle non-trivial lighters.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60006
diff changeset
778 (setq x (car x))
e886078cad44 (describe-mode): Properly handle non-trivial lighters.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60006
diff changeset
779 (unless (memq x minor-mode-list)
e886078cad44 (describe-mode): Properly handle non-trivial lighters.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60006
diff changeset
780 (push x minor-mode-list)))
52690
212969e10f09 (describe-mode): Start with a brief list of minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
781 ;; Find enabled minor mode we will want to mention.
212969e10f09 (describe-mode): Start with a brief list of minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
782 (dolist (mode minor-mode-list)
212969e10f09 (describe-mode): Start with a brief list of minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
783 ;; Document a minor mode if it is listed in minor-mode-alist,
212969e10f09 (describe-mode): Start with a brief list of minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
784 ;; non-nil, and has a function definition.
60644
9b106d739bf9 (describe-mode): Allow minor mode toggles to use a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60559
diff changeset
785 (let ((fmode (or (get mode :minor-mode-function) mode)))
9b106d739bf9 (describe-mode): Allow minor mode toggles to use a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60559
diff changeset
786 (and (boundp mode) (symbol-value mode)
9b106d739bf9 (describe-mode): Allow minor mode toggles to use a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60559
diff changeset
787 (fboundp fmode)
9b106d739bf9 (describe-mode): Allow minor mode toggles to use a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60559
diff changeset
788 (let ((pretty-minor-mode
9b106d739bf9 (describe-mode): Allow minor mode toggles to use a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60559
diff changeset
789 (if (string-match "\\(\\(-minor\\)?-mode\\)?\\'"
9b106d739bf9 (describe-mode): Allow minor mode toggles to use a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60559
diff changeset
790 (symbol-name fmode))
9b106d739bf9 (describe-mode): Allow minor mode toggles to use a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60559
diff changeset
791 (capitalize
9b106d739bf9 (describe-mode): Allow minor mode toggles to use a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60559
diff changeset
792 (substring (symbol-name fmode)
9b106d739bf9 (describe-mode): Allow minor mode toggles to use a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60559
diff changeset
793 0 (match-beginning 0)))
9b106d739bf9 (describe-mode): Allow minor mode toggles to use a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60559
diff changeset
794 fmode)))
9b106d739bf9 (describe-mode): Allow minor mode toggles to use a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60559
diff changeset
795 (push (list fmode pretty-minor-mode
9b106d739bf9 (describe-mode): Allow minor mode toggles to use a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60559
diff changeset
796 (format-mode-line (assq mode minor-mode-alist)))
9b106d739bf9 (describe-mode): Allow minor mode toggles to use a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60559
diff changeset
797 minor-modes)))))
52690
212969e10f09 (describe-mode): Start with a brief list of minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
798 (setq minor-modes
212969e10f09 (describe-mode): Start with a brief list of minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
799 (sort minor-modes
60644
9b106d739bf9 (describe-mode): Allow minor mode toggles to use a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60559
diff changeset
800 (lambda (a b) (string-lessp (cadr a) (cadr b)))))
52690
212969e10f09 (describe-mode): Start with a brief list of minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
801 (when minor-modes
212969e10f09 (describe-mode): Start with a brief list of minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
802 (princ "Summary of minor modes:\n")
57485
32dab1aa8b9a (describe-mode): Use marker buttons to make minor mode list into hyperlinks.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 56883
diff changeset
803 (make-local-variable 'help-button-cache)
32dab1aa8b9a (describe-mode): Use marker buttons to make minor mode list into hyperlinks.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 56883
diff changeset
804 (with-current-buffer standard-output
32dab1aa8b9a (describe-mode): Use marker buttons to make minor mode list into hyperlinks.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 56883
diff changeset
805 (dolist (mode minor-modes)
60644
9b106d739bf9 (describe-mode): Allow minor mode toggles to use a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60559
diff changeset
806 (let ((mode-function (nth 0 mode))
9b106d739bf9 (describe-mode): Allow minor mode toggles to use a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60559
diff changeset
807 (pretty-minor-mode (nth 1 mode))
57485
32dab1aa8b9a (describe-mode): Use marker buttons to make minor mode list into hyperlinks.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 56883
diff changeset
808 (indicator (nth 2 mode)))
60559
e886078cad44 (describe-mode): Properly handle non-trivial lighters.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60006
diff changeset
809 (setq indicator (if (zerop (length indicator))
e886078cad44 (describe-mode): Properly handle non-trivial lighters.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60006
diff changeset
810 "no indicator"
e886078cad44 (describe-mode): Properly handle non-trivial lighters.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60006
diff changeset
811 (format "indicator%s" indicator)))
57485
32dab1aa8b9a (describe-mode): Use marker buttons to make minor mode list into hyperlinks.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 56883
diff changeset
812 (add-text-properties 0 (length pretty-minor-mode)
32dab1aa8b9a (describe-mode): Use marker buttons to make minor mode list into hyperlinks.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 56883
diff changeset
813 '(face bold) pretty-minor-mode)
32dab1aa8b9a (describe-mode): Use marker buttons to make minor mode list into hyperlinks.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 56883
diff changeset
814 (save-excursion
32dab1aa8b9a (describe-mode): Use marker buttons to make minor mode list into hyperlinks.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 56883
diff changeset
815 (goto-char (point-max))
32dab1aa8b9a (describe-mode): Use marker buttons to make minor mode list into hyperlinks.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 56883
diff changeset
816 (princ "\n\f\n")
32dab1aa8b9a (describe-mode): Use marker buttons to make minor mode list into hyperlinks.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 56883
diff changeset
817 (push (point-marker) help-button-cache)
32dab1aa8b9a (describe-mode): Use marker buttons to make minor mode list into hyperlinks.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 56883
diff changeset
818 ;; Document the minor modes fully.
32dab1aa8b9a (describe-mode): Use marker buttons to make minor mode list into hyperlinks.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 56883
diff changeset
819 (insert pretty-minor-mode)
60559
e886078cad44 (describe-mode): Properly handle non-trivial lighters.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60006
diff changeset
820 (princ (format " minor mode (%s):\n" indicator))
57485
32dab1aa8b9a (describe-mode): Use marker buttons to make minor mode list into hyperlinks.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 56883
diff changeset
821 (princ (documentation mode-function)))
32dab1aa8b9a (describe-mode): Use marker buttons to make minor mode list into hyperlinks.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 56883
diff changeset
822 (princ " ")
32dab1aa8b9a (describe-mode): Use marker buttons to make minor mode list into hyperlinks.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 56883
diff changeset
823 (insert-button pretty-minor-mode
32dab1aa8b9a (describe-mode): Use marker buttons to make minor mode list into hyperlinks.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 56883
diff changeset
824 'action (car help-button-cache)
59018
52e86589c83a (describe-key): Report effective and original binding
Kim F. Storm <storm@cua.dk>
parents: 58992
diff changeset
825 'follow-link t
57485
32dab1aa8b9a (describe-mode): Use marker buttons to make minor mode list into hyperlinks.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 56883
diff changeset
826 'help-echo "mouse-2, RET: show full information")
60559
e886078cad44 (describe-mode): Properly handle non-trivial lighters.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60006
diff changeset
827 (princ (format " minor mode (%s):\n" indicator)))))
52690
212969e10f09 (describe-mode): Start with a brief list of minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
828 (princ "\n(Full information about these minor modes
212969e10f09 (describe-mode): Start with a brief list of minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
829 follows the description of the major mode.)\n\n"))
212969e10f09 (describe-mode): Start with a brief list of minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
830 ;; Document the major mode.
57485
32dab1aa8b9a (describe-mode): Use marker buttons to make minor mode list into hyperlinks.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 56883
diff changeset
831 (let ((mode mode-name))
32dab1aa8b9a (describe-mode): Use marker buttons to make minor mode list into hyperlinks.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 56883
diff changeset
832 (with-current-buffer standard-output
69125
2d354b7c7fb4 (describe-mode): Pass `mode-name' to format-mode-line.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69077
diff changeset
833 (let ((start (point)))
2d354b7c7fb4 (describe-mode): Pass `mode-name' to format-mode-line.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69077
diff changeset
834 (insert (format-mode-line mode))
2d354b7c7fb4 (describe-mode): Pass `mode-name' to format-mode-line.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69077
diff changeset
835 (add-text-properties start (point) '(face bold)))))
52690
212969e10f09 (describe-mode): Start with a brief list of minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
836 (princ " mode:\n")
57485
32dab1aa8b9a (describe-mode): Use marker buttons to make minor mode list into hyperlinks.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 56883
diff changeset
837 (princ (documentation major-mode)))
42679
8e00fb340b95 (describe-mode): Call help-setup-xref in the help buffer.
Richard M. Stallman <rms@gnu.org>
parents: 42357
diff changeset
838 (print-help-return-message))))
21371
22a3be0ae9dc (help-highlight-face): Use underline.
Richard M. Stallman <rms@gnu.org>
parents: 21210
diff changeset
839
52690
212969e10f09 (describe-mode): Start with a brief list of minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
840
50353
e5761fbf195f (describe-minor-mode, describe-minor-mode-from-indicator,
Juanma Barranquero <lekktu@gmail.com>
parents: 49757
diff changeset
841 (defun describe-minor-mode (minor-mode)
50565
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
842 "Display documentation of a minor mode given as MINOR-MODE.
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
843 MINOR-MODE can be a minor mode symbol or a minor mode indicator string
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
844 appeared on the mode-line."
53204
0fd777e399e3 (help-map): Bind `display-local-help' to `C-h .'.
Luc Teirlinck <teirllm@auburn.edu>
parents: 52690
diff changeset
845 (interactive (list (completing-read
50565
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
846 "Minor mode: "
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
847 (nconc
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
848 (describe-minor-mode-completion-table-for-symbol)
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
849 (describe-minor-mode-completion-table-for-indicator)
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
850 ))))
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
851 (if (symbolp minor-mode)
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
852 (setq minor-mode (symbol-name minor-mode)))
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
853 (let ((symbols (describe-minor-mode-completion-table-for-symbol))
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
854 (indicators (describe-minor-mode-completion-table-for-indicator)))
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
855 (cond
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
856 ((member minor-mode symbols)
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
857 (describe-minor-mode-from-symbol (intern minor-mode)))
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
858 ((member minor-mode indicators)
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
859 (describe-minor-mode-from-indicator minor-mode))
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
860 (t
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
861 (error "No such minor mode: %s" minor-mode)))))
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
862
53204
0fd777e399e3 (help-map): Bind `display-local-help' to `C-h .'.
Luc Teirlinck <teirllm@auburn.edu>
parents: 52690
diff changeset
863 ;; symbol
50565
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
864 (defun describe-minor-mode-completion-table-for-symbol ()
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
865 ;; In order to list up all minor modes, minor-mode-list
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
866 ;; is used here instead of minor-mode-alist.
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
867 (delq nil (mapcar 'symbol-name minor-mode-list)))
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
868 (defun describe-minor-mode-from-symbol (symbol)
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
869 "Display documentation of a minor mode given as a symbol, SYMBOL"
53204
0fd777e399e3 (help-map): Bind `display-local-help' to `C-h .'.
Luc Teirlinck <teirllm@auburn.edu>
parents: 52690
diff changeset
870 (interactive (list (intern (completing-read
50565
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
871 "Minor mode symbol: "
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
872 (describe-minor-mode-completion-table-for-symbol)))))
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
873 (if (fboundp symbol)
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
874 (describe-function symbol)
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
875 (describe-variable symbol)))
50353
e5761fbf195f (describe-minor-mode, describe-minor-mode-from-indicator,
Juanma Barranquero <lekktu@gmail.com>
parents: 49757
diff changeset
876
50565
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
877 ;; indicator
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
878 (defun describe-minor-mode-completion-table-for-indicator ()
53204
0fd777e399e3 (help-map): Bind `display-local-help' to `C-h .'.
Luc Teirlinck <teirllm@auburn.edu>
parents: 52690
diff changeset
879 (delq nil
50565
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
880 (mapcar (lambda (x)
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
881 (let ((i (format-mode-line x)))
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
882 ;; remove first space if existed
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
883 (cond
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
884 ((= 0 (length i))
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
885 nil)
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
886 ((eq (aref i 0) ?\ )
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
887 (substring i 1))
53204
0fd777e399e3 (help-map): Bind `display-local-help' to `C-h .'.
Luc Teirlinck <teirllm@auburn.edu>
parents: 52690
diff changeset
888 (t
50565
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
889 i))))
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
890 minor-mode-alist)))
50353
e5761fbf195f (describe-minor-mode, describe-minor-mode-from-indicator,
Juanma Barranquero <lekktu@gmail.com>
parents: 49757
diff changeset
891 (defun describe-minor-mode-from-indicator (indicator)
50565
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
892 "Display documentation of a minor mode specified by INDICATOR.
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
893 If you call this function interactively, you can give indicator which
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
894 is currently activated with completion."
53204
0fd777e399e3 (help-map): Bind `display-local-help' to `C-h .'.
Luc Teirlinck <teirllm@auburn.edu>
parents: 52690
diff changeset
895 (interactive (list
0fd777e399e3 (help-map): Bind `display-local-help' to `C-h .'.
Luc Teirlinck <teirllm@auburn.edu>
parents: 52690
diff changeset
896 (completing-read
50353
e5761fbf195f (describe-minor-mode, describe-minor-mode-from-indicator,
Juanma Barranquero <lekktu@gmail.com>
parents: 49757
diff changeset
897 "Minor mode indicator: "
50565
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
898 (describe-minor-mode-completion-table-for-indicator))))
50353
e5761fbf195f (describe-minor-mode, describe-minor-mode-from-indicator,
Juanma Barranquero <lekktu@gmail.com>
parents: 49757
diff changeset
899 (let ((minor-mode (lookup-minor-mode-from-indicator indicator)))
e5761fbf195f (describe-minor-mode, describe-minor-mode-from-indicator,
Juanma Barranquero <lekktu@gmail.com>
parents: 49757
diff changeset
900 (if minor-mode
50565
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
901 (describe-minor-mode-from-symbol minor-mode)
50353
e5761fbf195f (describe-minor-mode, describe-minor-mode-from-indicator,
Juanma Barranquero <lekktu@gmail.com>
parents: 49757
diff changeset
902 (error "Cannot find minor mode for `%s'" indicator))))
e5761fbf195f (describe-minor-mode, describe-minor-mode-from-indicator,
Juanma Barranquero <lekktu@gmail.com>
parents: 49757
diff changeset
903
e5761fbf195f (describe-minor-mode, describe-minor-mode-from-indicator,
Juanma Barranquero <lekktu@gmail.com>
parents: 49757
diff changeset
904 (defun lookup-minor-mode-from-indicator (indicator)
e5761fbf195f (describe-minor-mode, describe-minor-mode-from-indicator,
Juanma Barranquero <lekktu@gmail.com>
parents: 49757
diff changeset
905 "Return a minor mode symbol from its indicator on the modeline."
50565
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
906 ;; remove first space if existed
53204
0fd777e399e3 (help-map): Bind `display-local-help' to `C-h .'.
Luc Teirlinck <teirllm@auburn.edu>
parents: 52690
diff changeset
907 (if (and (< 0 (length indicator))
50565
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
908 (eq (aref indicator 0) ?\ ))
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
909 (setq indicator (substring indicator 1)))
50353
e5761fbf195f (describe-minor-mode, describe-minor-mode-from-indicator,
Juanma Barranquero <lekktu@gmail.com>
parents: 49757
diff changeset
910 (let ((minor-modes minor-mode-alist)
e5761fbf195f (describe-minor-mode, describe-minor-mode-from-indicator,
Juanma Barranquero <lekktu@gmail.com>
parents: 49757
diff changeset
911 result)
e5761fbf195f (describe-minor-mode, describe-minor-mode-from-indicator,
Juanma Barranquero <lekktu@gmail.com>
parents: 49757
diff changeset
912 (while minor-modes
e5761fbf195f (describe-minor-mode, describe-minor-mode-from-indicator,
Juanma Barranquero <lekktu@gmail.com>
parents: 49757
diff changeset
913 (let* ((minor-mode (car (car minor-modes)))
53204
0fd777e399e3 (help-map): Bind `display-local-help' to `C-h .'.
Luc Teirlinck <teirllm@auburn.edu>
parents: 52690
diff changeset
914 (anindicator (format-mode-line
50565
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
915 (car (cdr (car minor-modes))))))
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
916 ;; remove first space if existed
53204
0fd777e399e3 (help-map): Bind `display-local-help' to `C-h .'.
Luc Teirlinck <teirllm@auburn.edu>
parents: 52690
diff changeset
917 (if (and (stringp anindicator)
50565
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
918 (> (length anindicator) 0)
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
919 (eq (aref anindicator 0) ?\ ))
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
920 (setq anindicator (substring anindicator 1)))
cd863af50ea1 * help.el (describe-minor-mode): New function implementation.
Masatake YAMATO <jet@gyve.org>
parents: 50353
diff changeset
921 (if (equal indicator anindicator)
50353
e5761fbf195f (describe-minor-mode, describe-minor-mode-from-indicator,
Juanma Barranquero <lekktu@gmail.com>
parents: 49757
diff changeset
922 (setq result minor-mode
e5761fbf195f (describe-minor-mode, describe-minor-mode-from-indicator,
Juanma Barranquero <lekktu@gmail.com>
parents: 49757
diff changeset
923 minor-modes nil)
e5761fbf195f (describe-minor-mode, describe-minor-mode-from-indicator,
Juanma Barranquero <lekktu@gmail.com>
parents: 49757
diff changeset
924 (setq minor-modes (cdr minor-modes)))))
e5761fbf195f (describe-minor-mode, describe-minor-mode-from-indicator,
Juanma Barranquero <lekktu@gmail.com>
parents: 49757
diff changeset
925 result))
e5761fbf195f (describe-minor-mode, describe-minor-mode-from-indicator,
Juanma Barranquero <lekktu@gmail.com>
parents: 49757
diff changeset
926
23747
fb3963445995 Add resizing of temporary buffers.
Richard M. Stallman <rms@gnu.org>
parents: 23742
diff changeset
927
fb3963445995 Add resizing of temporary buffers.
Richard M. Stallman <rms@gnu.org>
parents: 23742
diff changeset
928 ;;; Automatic resizing of temporary buffers.
fb3963445995 Add resizing of temporary buffers.
Richard M. Stallman <rms@gnu.org>
parents: 23742
diff changeset
929
23749
ea095fa15fb9 Rename function and variables added in previous change:
Richard M. Stallman <rms@gnu.org>
parents: 23747
diff changeset
930 (defcustom temp-buffer-max-height (lambda (buffer) (/ (- (frame-height) 2) 2))
69125
2d354b7c7fb4 (describe-mode): Pass `mode-name' to format-mode-line.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69077
diff changeset
931 "Maximum height of a window displaying a temporary buffer.
23747
fb3963445995 Add resizing of temporary buffers.
Richard M. Stallman <rms@gnu.org>
parents: 23742
diff changeset
932 This is the maximum height (in text lines) which `resize-temp-buffer-window'
fb3963445995 Add resizing of temporary buffers.
Richard M. Stallman <rms@gnu.org>
parents: 23742
diff changeset
933 will give to a window displaying a temporary buffer.
fb3963445995 Add resizing of temporary buffers.
Richard M. Stallman <rms@gnu.org>
parents: 23742
diff changeset
934 It can also be a function which will be called with the object corresponding
fb3963445995 Add resizing of temporary buffers.
Richard M. Stallman <rms@gnu.org>
parents: 23742
diff changeset
935 to the buffer to be displayed as argument and should return an integer
fb3963445995 Add resizing of temporary buffers.
Richard M. Stallman <rms@gnu.org>
parents: 23742
diff changeset
936 positive number."
fb3963445995 Add resizing of temporary buffers.
Richard M. Stallman <rms@gnu.org>
parents: 23742
diff changeset
937 :type '(choice integer function)
fb3963445995 Add resizing of temporary buffers.
Richard M. Stallman <rms@gnu.org>
parents: 23742
diff changeset
938 :group 'help
fb3963445995 Add resizing of temporary buffers.
Richard M. Stallman <rms@gnu.org>
parents: 23742
diff changeset
939 :version "20.4")
fb3963445995 Add resizing of temporary buffers.
Richard M. Stallman <rms@gnu.org>
parents: 23742
diff changeset
940
32183
3e4bdf7c90c4 (help-xref-on-pp): Use match-string.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31491
diff changeset
941 (define-minor-mode temp-buffer-resize-mode
3e4bdf7c90c4 (help-xref-on-pp): Use match-string.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31491
diff changeset
942 "Toggle the mode which makes windows smaller for temporary buffers.
23747
fb3963445995 Add resizing of temporary buffers.
Richard M. Stallman <rms@gnu.org>
parents: 23742
diff changeset
943 With prefix argument ARG, turn the resizing of windows displaying temporary
fb3963445995 Add resizing of temporary buffers.
Richard M. Stallman <rms@gnu.org>
parents: 23742
diff changeset
944 buffers on if ARG is positive or off otherwise.
32183
3e4bdf7c90c4 (help-xref-on-pp): Use match-string.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31491
diff changeset
945 This makes the window the right height for its contents, but never
3e4bdf7c90c4 (help-xref-on-pp): Use match-string.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31491
diff changeset
946 more than `temp-buffer-max-height' nor less than `window-min-height'.
3e4bdf7c90c4 (help-xref-on-pp): Use match-string.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31491
diff changeset
947 This applies to `help', `apropos' and `completion' buffers, and some others."
39659
4bd383bb2137 (help-mode): Use define-derived-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39651
diff changeset
948 :global t :group 'help
32183
3e4bdf7c90c4 (help-xref-on-pp): Use match-string.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31491
diff changeset
949 (if temp-buffer-resize-mode
36249
c96d6054a03e Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 35233
diff changeset
950 ;; `help-make-xrefs' may add a `back' button and thus increase the
32183
3e4bdf7c90c4 (help-xref-on-pp): Use match-string.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31491
diff changeset
951 ;; text size, so `resize-temp-buffer-window' must be run *after* it.
3e4bdf7c90c4 (help-xref-on-pp): Use match-string.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31491
diff changeset
952 (add-hook 'temp-buffer-show-hook 'resize-temp-buffer-window 'append)
32184
ab059a552fa2 Missing paren.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32183
diff changeset
953 (remove-hook 'temp-buffer-show-hook 'resize-temp-buffer-window)))
23747
fb3963445995 Add resizing of temporary buffers.
Richard M. Stallman <rms@gnu.org>
parents: 23742
diff changeset
954
fb3963445995 Add resizing of temporary buffers.
Richard M. Stallman <rms@gnu.org>
parents: 23742
diff changeset
955 (defun resize-temp-buffer-window ()
fb3963445995 Add resizing of temporary buffers.
Richard M. Stallman <rms@gnu.org>
parents: 23742
diff changeset
956 "Resize the current window to fit its contents.
23749
ea095fa15fb9 Rename function and variables added in previous change:
Richard M. Stallman <rms@gnu.org>
parents: 23747
diff changeset
957 Will not make it higher than `temp-buffer-max-height' nor smaller than
24079
11e777f59a1f (help-make-xrefs): Avoid infloop in keymap substitutions
Dave Love <fx@gnu.org>
parents: 24055
diff changeset
958 `window-min-height'. Do nothing if it is the only window on its frame, if it
23747
fb3963445995 Add resizing of temporary buffers.
Richard M. Stallman <rms@gnu.org>
parents: 23742
diff changeset
959 is not as wide as the frame or if some of the window's contents are scrolled
fb3963445995 Add resizing of temporary buffers.
Richard M. Stallman <rms@gnu.org>
parents: 23742
diff changeset
960 out of view."
fb3963445995 Add resizing of temporary buffers.
Richard M. Stallman <rms@gnu.org>
parents: 23742
diff changeset
961 (unless (or (one-window-p 'nomini)
fb3963445995 Add resizing of temporary buffers.
Richard M. Stallman <rms@gnu.org>
parents: 23742
diff changeset
962 (not (pos-visible-in-window-p (point-min)))
fb3963445995 Add resizing of temporary buffers.
Richard M. Stallman <rms@gnu.org>
parents: 23742
diff changeset
963 (/= (frame-width) (window-width)))
32706
605eabd04a57 (resize-temp-buffer-window): Use `fit-window-to-buffer'.
Miles Bader <miles@gnu.org>
parents: 32690
diff changeset
964 (fit-window-to-buffer
605eabd04a57 (resize-temp-buffer-window): Use `fit-window-to-buffer'.
Miles Bader <miles@gnu.org>
parents: 32690
diff changeset
965 (selected-window)
605eabd04a57 (resize-temp-buffer-window): Use `fit-window-to-buffer'.
Miles Bader <miles@gnu.org>
parents: 32690
diff changeset
966 (if (functionp temp-buffer-max-height)
605eabd04a57 (resize-temp-buffer-window): Use `fit-window-to-buffer'.
Miles Bader <miles@gnu.org>
parents: 32690
diff changeset
967 (funcall temp-buffer-max-height (current-buffer))
605eabd04a57 (resize-temp-buffer-window): Use `fit-window-to-buffer'.
Miles Bader <miles@gnu.org>
parents: 32690
diff changeset
968 temp-buffer-max-height))))
23747
fb3963445995 Add resizing of temporary buffers.
Richard M. Stallman <rms@gnu.org>
parents: 23742
diff changeset
969
69131
aa9f0a1e543f (help): Revert last part of 2006-02-23 change (deletion of the `provide' call).
Juanma Barranquero <lekktu@gmail.com>
parents: 69125
diff changeset
970
aa9f0a1e543f (help): Revert last part of 2006-02-23 change (deletion of the `provide' call).
Juanma Barranquero <lekktu@gmail.com>
parents: 69125
diff changeset
971 (provide 'help)
aa9f0a1e543f (help): Revert last part of 2006-02-23 change (deletion of the `provide' call).
Juanma Barranquero <lekktu@gmail.com>
parents: 69125
diff changeset
972
60559
e886078cad44 (describe-mode): Properly handle non-trivial lighters.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60006
diff changeset
973 ;; arch-tag: cf427352-27e9-49b7-9a6f-741ebab02423
660
08eb386dd0f3 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 444
diff changeset
974 ;;; help.el ends here