1992-05-30 23:12:08 +00:00
|
|
|
|
;;; help.el --- help commands for Emacs
|
|
|
|
|
|
2012-02-28 08:17:21 +00:00
|
|
|
|
;; Copyright (C) 1985-1986, 1993-1994, 1998-2012 Free Software Foundation, Inc.
|
1992-07-22 04:22:42 +00:00
|
|
|
|
|
1992-07-16 21:47:34 +00:00
|
|
|
|
;; Maintainer: FSF
|
1992-07-17 08:15:29 +00:00
|
|
|
|
;; Keywords: help, internal
|
2010-08-29 16:17:13 +00:00
|
|
|
|
;; Package: emacs
|
1992-07-16 21:47:34 +00:00
|
|
|
|
|
1991-08-25 21:47:10 +00:00
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
2008-05-06 08:06:51 +00:00
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
1991-08-25 21:47:10 +00:00
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 08:06:51 +00:00
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
1991-08-25 21:47:10 +00:00
|
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2008-05-06 08:06:51 +00:00
|
|
|
|
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
1991-08-25 21:47:10 +00:00
|
|
|
|
|
1993-03-22 16:53:22 +00:00
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
2012-02-28 08:17:21 +00:00
|
|
|
|
;; This code implements GNU Emacs's on-line help system, the one invoked by
|
1999-08-31 17:17:18 +00:00
|
|
|
|
;; `M-x help-for-help'.
|
1993-03-22 16:53:22 +00:00
|
|
|
|
|
1992-07-16 21:47:34 +00:00
|
|
|
|
;;; Code:
|
|
|
|
|
|
1993-03-22 06:59:54 +00:00
|
|
|
|
;; Get the macro make-help-screen when this is compiled,
|
|
|
|
|
;; or run interpreted, but not when the compiled code is loaded.
|
1993-05-08 22:38:37 +00:00
|
|
|
|
(eval-when-compile (require 'help-macro))
|
Don't require `view' when compiling.
(help-with-tutorial, describe-function, describe-function-1)
(variable-at-point, describe-variable, locate-library):
Functions moved into `help-funs.el'.
(help-manyarg-func-alist): Variable moved into `help-funs.el'.
(help-mode, help-mode-setup, help-mode-finish, help-button-action)
(help-setup-xref, help-xref-following, help-make-xrefs)
(help-xref-button, help-insert-xref-button, help-xref-interned)
(help-xref-go-back, help-go-back, help-do-xref, help-follow)
(help-xref-on-pp): Functions moved into `help-mode.el'
(help-mode-map, help-xref-stack, help-xref-stack-item)
(help-highlight-p, help-highlight-face, help-back-label)
(help-xref-symbol-regexp, help-xref-mule-regexp)
(help-xref-info-regexp): Variables moved into `help-mode.el'.
(help-symbol, help-back, help-info, help-customize-variable)
(help-function-def, help-variable-def):
Button-types moved into `help-mode.el'.
(load-symbol-file-load-history, symbol-file):
Functions moved into `subr.el'.
(symbol-file-load-history-loaded): Variable moved into `subr.el'.
(view-lossage): Call `help-setup-xref' instead of doing it manually.
2001-10-09 11:17:39 +00:00
|
|
|
|
|
|
|
|
|
;; This makes `with-output-to-temp-buffer' buffers use `help-mode'.
|
|
|
|
|
(add-hook 'temp-buffer-setup-hook 'help-mode-setup)
|
|
|
|
|
(add-hook 'temp-buffer-show-hook 'help-mode-finish)
|
1993-03-17 22:20:57 +00:00
|
|
|
|
|
2007-11-10 09:53:22 +00:00
|
|
|
|
;; `help-window-point-marker' is a marker you can move to a valid
|
|
|
|
|
;; position of the buffer shown in the help window in order to override
|
|
|
|
|
;; the standard positioning mechanism (`point-min') chosen by
|
|
|
|
|
;; `with-output-to-temp-buffer'. `with-help-window' has this point
|
|
|
|
|
;; nowhere before exiting. Currently used by `view-lossage' to assert
|
|
|
|
|
;; that the last keystrokes are always visible.
|
2008-02-29 23:37:38 +00:00
|
|
|
|
(defvar help-window-point-marker (make-marker)
|
2011-06-13 13:14:42 +00:00
|
|
|
|
"Marker to override default `window-point' in help windows.")
|
2007-11-10 09:53:22 +00:00
|
|
|
|
|
2005-11-30 16:09:58 +00:00
|
|
|
|
(defvar help-map
|
|
|
|
|
(let ((map (make-sparse-keymap)))
|
|
|
|
|
(define-key map (char-to-string help-char) 'help-for-help)
|
|
|
|
|
(define-key map [help] 'help-for-help)
|
|
|
|
|
(define-key map [f1] 'help-for-help)
|
|
|
|
|
(define-key map "." 'display-local-help)
|
|
|
|
|
(define-key map "?" 'help-for-help)
|
|
|
|
|
|
2007-09-22 15:42:12 +00:00
|
|
|
|
(define-key map "\C-a" 'about-emacs)
|
2005-11-30 16:09:58 +00:00
|
|
|
|
(define-key map "\C-c" 'describe-copying)
|
2008-02-29 23:37:38 +00:00
|
|
|
|
(define-key map "\C-d" 'view-emacs-debugging)
|
|
|
|
|
(define-key map "\C-e" 'view-external-packages)
|
2005-11-30 16:09:58 +00:00
|
|
|
|
(define-key map "\C-f" 'view-emacs-FAQ)
|
|
|
|
|
(define-key map "\C-m" 'view-order-manuals)
|
|
|
|
|
(define-key map "\C-n" 'view-emacs-news)
|
2008-02-29 23:37:38 +00:00
|
|
|
|
(define-key map "\C-o" 'describe-distribution)
|
|
|
|
|
(define-key map "\C-p" 'view-emacs-problems)
|
|
|
|
|
(define-key map "\C-t" 'view-emacs-todo)
|
2005-11-30 16:09:58 +00:00
|
|
|
|
(define-key map "\C-w" 'describe-no-warranty)
|
|
|
|
|
|
|
|
|
|
;; This does not fit the pattern, but it is natural given the C-\ command.
|
|
|
|
|
(define-key map "\C-\\" 'describe-input-method)
|
|
|
|
|
|
|
|
|
|
(define-key map "C" 'describe-coding-system)
|
|
|
|
|
(define-key map "F" 'Info-goto-emacs-command-node)
|
|
|
|
|
(define-key map "I" 'describe-input-method)
|
|
|
|
|
(define-key map "K" 'Info-goto-emacs-key-command-node)
|
|
|
|
|
(define-key map "L" 'describe-language-environment)
|
|
|
|
|
(define-key map "S" 'info-lookup-symbol)
|
|
|
|
|
|
|
|
|
|
(define-key map "a" 'apropos-command)
|
|
|
|
|
(define-key map "b" 'describe-bindings)
|
|
|
|
|
(define-key map "c" 'describe-key-briefly)
|
|
|
|
|
(define-key map "d" 'apropos-documentation)
|
|
|
|
|
(define-key map "e" 'view-echo-area-messages)
|
|
|
|
|
(define-key map "f" 'describe-function)
|
2008-02-29 23:37:38 +00:00
|
|
|
|
(define-key map "g" 'describe-gnu-project)
|
2005-11-30 16:09:58 +00:00
|
|
|
|
(define-key map "h" 'view-hello-file)
|
|
|
|
|
|
|
|
|
|
(define-key map "i" 'info)
|
|
|
|
|
(define-key map "4i" 'info-other-window)
|
|
|
|
|
|
|
|
|
|
(define-key map "k" 'describe-key)
|
|
|
|
|
(define-key map "l" 'view-lossage)
|
|
|
|
|
(define-key map "m" 'describe-mode)
|
|
|
|
|
(define-key map "n" 'view-emacs-news)
|
|
|
|
|
(define-key map "p" 'finder-by-keyword)
|
2010-08-26 03:31:34 +00:00
|
|
|
|
(define-key map "P" 'describe-package)
|
2005-11-30 16:09:58 +00:00
|
|
|
|
(define-key map "r" 'info-emacs-manual)
|
|
|
|
|
(define-key map "s" 'describe-syntax)
|
|
|
|
|
(define-key map "t" 'help-with-tutorial)
|
|
|
|
|
(define-key map "w" 'where-is)
|
|
|
|
|
(define-key map "v" 'describe-variable)
|
|
|
|
|
(define-key map "q" 'help-quit)
|
|
|
|
|
map)
|
1991-08-25 21:47:10 +00:00
|
|
|
|
"Keymap for characters following the Help key.")
|
|
|
|
|
|
1992-08-03 22:07:34 +00:00
|
|
|
|
(define-key global-map (char-to-string help-char) 'help-command)
|
1995-06-29 02:50:52 +00:00
|
|
|
|
(define-key global-map [help] 'help-command)
|
|
|
|
|
(define-key global-map [f1] 'help-command)
|
1991-08-25 21:47:10 +00:00
|
|
|
|
(fset 'help-command help-map)
|
|
|
|
|
|
2004-10-13 19:01:01 +00:00
|
|
|
|
;; insert-button makes the action nil if it is not store somewhere
|
|
|
|
|
(defvar help-button-cache nil)
|
|
|
|
|
|
(help-mode-map): Make button-buffer-map our parent.
Don't bind mouse events or tab/backtab.
(help-function, help-variable, help-face, help-coding-system)
(help-input-method, help-character-set, help-back, help-info)
(help-customize-variable, help-function-def, help-variable-def):
New button types.
(help-button-action): New function.
(describe-function-1): Pass help button-types to `help-xref-button'
rather than help function and help-echo string. Don't put multiple
help-function args in a list to pass them to help-xref-button, just pass
them as multiple arguments. Use `help-insert-xref-button' to make
[back]-button, rather than `help-xref-button'.
(help-xref-button): Take a button-type TYPE as a parameter rather than a
function. Remove HELP-ECHO parameter. Remove DATA parameter and add a
&rest parameter ARGS to serve the same purpose. Use `make-text-button'
to add the button.
(help-insert-xref-button): Use `insert-text-button' to add the button.
(help-follow-mouse, help-next-ref, help-previous-ref): Functions removed.
(help-do-xref): New function.
(help-follow): Use `push-button' and `help-do-xref' to do most of the work.
2001-10-07 12:05:22 +00:00
|
|
|
|
|
1994-03-30 01:43:37 +00:00
|
|
|
|
(defun help-quit ()
|
1998-09-27 21:20:42 +00:00
|
|
|
|
"Just exit from the Help command's command loop."
|
1994-03-30 01:43:37 +00:00
|
|
|
|
(interactive)
|
|
|
|
|
nil)
|
|
|
|
|
|
1998-03-16 04:10:19 +00:00
|
|
|
|
(defvar help-return-method nil
|
|
|
|
|
"What to do to \"exit\" the help buffer.
|
|
|
|
|
This is a list
|
2005-12-03 11:52:23 +00:00
|
|
|
|
(WINDOW . t) delete the selected window (and possibly its frame,
|
2011-09-03 17:16:57 +00:00
|
|
|
|
see `quit-window'), go to WINDOW.
|
1998-03-16 04:10:19 +00:00
|
|
|
|
(WINDOW . quit-window) do quit-window, then select WINDOW.
|
|
|
|
|
(WINDOW BUF START POINT) display BUF at START, POINT, then select WINDOW.")
|
|
|
|
|
|
2009-08-19 18:07:07 +00:00
|
|
|
|
(define-obsolete-function-alias 'print-help-return-message 'help-print-return-message "23.2")
|
|
|
|
|
(defun help-print-return-message (&optional function)
|
1991-08-25 21:47:10 +00:00
|
|
|
|
"Display or return message saying how to restore windows after help command.
|
2002-07-12 22:57:11 +00:00
|
|
|
|
This function assumes that `standard-output' is the help buffer.
|
|
|
|
|
It computes a message, and applies the optional argument FUNCTION to it.
|
2005-12-03 11:52:23 +00:00
|
|
|
|
If FUNCTION is nil, it applies `message', thus displaying the message.
|
|
|
|
|
In addition, this function sets up `help-return-method', which see, that
|
|
|
|
|
specifies what to do when the user exits the help buffer."
|
1991-08-25 21:47:10 +00:00
|
|
|
|
(and (not (get-buffer-window standard-output))
|
1994-07-16 17:58:12 +00:00
|
|
|
|
(let ((first-message
|
2005-12-03 11:52:23 +00:00
|
|
|
|
(cond ((or
|
|
|
|
|
pop-up-frames
|
|
|
|
|
(special-display-p (buffer-name standard-output)))
|
1998-03-16 04:10:19 +00:00
|
|
|
|
(setq help-return-method (cons (selected-window) t))
|
1994-07-16 17:58:12 +00:00
|
|
|
|
;; If the help output buffer is a special display buffer,
|
|
|
|
|
;; don't say anything about how to get rid of it.
|
|
|
|
|
;; First of all, the user will do that with the window
|
|
|
|
|
;; manager, not with Emacs.
|
|
|
|
|
;; Secondly, the buffer has not been displayed yet,
|
|
|
|
|
;; so we don't know whether its frame will be selected.
|
|
|
|
|
nil)
|
2000-08-08 12:18:17 +00:00
|
|
|
|
(display-buffer-reuse-frames
|
|
|
|
|
(setq help-return-method (cons (selected-window)
|
|
|
|
|
'quit-window))
|
|
|
|
|
nil)
|
1994-07-16 17:58:12 +00:00
|
|
|
|
((not (one-window-p t))
|
1998-03-16 04:10:19 +00:00
|
|
|
|
(setq help-return-method
|
|
|
|
|
(cons (selected-window) 'quit-window))
|
2006-03-25 10:11:09 +00:00
|
|
|
|
"Type \\[display-buffer] RET to restore the other window.")
|
1994-07-16 17:58:12 +00:00
|
|
|
|
(pop-up-windows
|
1998-03-16 04:10:19 +00:00
|
|
|
|
(setq help-return-method (cons (selected-window) t))
|
1994-07-16 17:58:12 +00:00
|
|
|
|
"Type \\[delete-other-windows] to remove help window.")
|
|
|
|
|
(t
|
1998-03-16 04:10:19 +00:00
|
|
|
|
(setq help-return-method
|
|
|
|
|
(list (selected-window) (window-buffer)
|
|
|
|
|
(window-start) (window-point)))
|
1994-07-16 17:58:12 +00:00
|
|
|
|
"Type \\[switch-to-buffer] RET to remove help window."))))
|
|
|
|
|
(funcall (or function 'message)
|
|
|
|
|
(concat
|
|
|
|
|
(if first-message
|
2000-05-14 15:48:45 +00:00
|
|
|
|
(substitute-command-keys first-message))
|
|
|
|
|
(if first-message " ")
|
1995-04-24 15:13:20 +00:00
|
|
|
|
;; If the help buffer will go in a separate frame,
|
|
|
|
|
;; it's no use mentioning a command to scroll, so don't.
|
2005-12-03 12:07:03 +00:00
|
|
|
|
(if (or pop-up-windows
|
|
|
|
|
(special-display-p (buffer-name standard-output)))
|
1995-04-24 15:13:20 +00:00
|
|
|
|
nil
|
1996-10-06 16:27:39 +00:00
|
|
|
|
(if (same-window-p (buffer-name standard-output))
|
1995-04-24 15:13:20 +00:00
|
|
|
|
;; Say how to scroll this window.
|
|
|
|
|
(substitute-command-keys
|
|
|
|
|
"\\[scroll-up] to scroll the help.")
|
|
|
|
|
;; Say how to scroll some other window.
|
1995-04-13 18:15:01 +00:00
|
|
|
|
(substitute-command-keys
|
1995-04-24 15:13:20 +00:00
|
|
|
|
"\\[scroll-other-window] to scroll the help."))))))))
|
1991-08-25 21:47:10 +00:00
|
|
|
|
|
|
|
|
|
;; So keyboard macro definitions are documented correctly
|
|
|
|
|
(fset 'defining-kbd-macro (symbol-function 'start-kbd-macro))
|
|
|
|
|
|
2005-02-10 06:46:42 +00:00
|
|
|
|
(defalias 'help 'help-for-help-internal)
|
|
|
|
|
;; find-function can find this.
|
|
|
|
|
(defalias 'help-for-help 'help-for-help-internal)
|
|
|
|
|
;; It can't find this, but nobody will look.
|
|
|
|
|
(make-help-screen help-for-help-internal
|
2009-09-14 23:28:40 +00:00
|
|
|
|
(purecopy "Type a help option: [abcCdefFgiIkKlLmnprstvw.] C-[cdefmnoptw] or ?")
|
2009-09-27 00:27:21 +00:00
|
|
|
|
;; Don't purecopy this one, because it's not evaluated (it's
|
|
|
|
|
;; directly used as a docstring in a function definition, so it'll
|
|
|
|
|
;; be moved to the DOC file anyway: no need for purecopying it).
|
Don't require `view' when compiling.
(help-with-tutorial, describe-function, describe-function-1)
(variable-at-point, describe-variable, locate-library):
Functions moved into `help-funs.el'.
(help-manyarg-func-alist): Variable moved into `help-funs.el'.
(help-mode, help-mode-setup, help-mode-finish, help-button-action)
(help-setup-xref, help-xref-following, help-make-xrefs)
(help-xref-button, help-insert-xref-button, help-xref-interned)
(help-xref-go-back, help-go-back, help-do-xref, help-follow)
(help-xref-on-pp): Functions moved into `help-mode.el'
(help-mode-map, help-xref-stack, help-xref-stack-item)
(help-highlight-p, help-highlight-face, help-back-label)
(help-xref-symbol-regexp, help-xref-mule-regexp)
(help-xref-info-regexp): Variables moved into `help-mode.el'.
(help-symbol, help-back, help-info, help-customize-variable)
(help-function-def, help-variable-def):
Button-types moved into `help-mode.el'.
(load-symbol-file-load-history, symbol-file):
Functions moved into `subr.el'.
(symbol-file-load-history-loaded): Variable moved into `subr.el'.
(view-lossage): Call `help-setup-xref' instead of doing it manually.
2001-10-09 11:17:39 +00:00
|
|
|
|
"You have typed %THIS-KEY%, the help character. Type a Help option:
|
|
|
|
|
\(Use SPC or DEL to scroll through this text. Type \\<help-map>\\[help-quit] to exit the Help command.)
|
|
|
|
|
|
2008-02-29 23:37:38 +00:00
|
|
|
|
a PATTERN Show commands whose name matches the PATTERN (a list of words
|
|
|
|
|
or a regexp). See also the `apropos' command.
|
|
|
|
|
b Display all key bindings.
|
|
|
|
|
c KEYS Display the command name run by the given key sequence.
|
|
|
|
|
C CODING Describe the given coding system, or RET for current ones.
|
|
|
|
|
d PATTERN Show a list of functions, variables, and other items whose
|
|
|
|
|
documentation matches the PATTERN (a list of words or a regexp).
|
|
|
|
|
e Go to the *Messages* buffer which logs echo-area messages.
|
|
|
|
|
f FUNCTION Display documentation for the given function.
|
|
|
|
|
F COMMAND Show the on-line manual's section that describes the command.
|
|
|
|
|
g Display information about the GNU project.
|
|
|
|
|
h Display the HELLO file which illustrates various scripts.
|
|
|
|
|
i Start the Info documentation reader: read on-line manuals.
|
|
|
|
|
I METHOD Describe a specific input method, or RET for current.
|
|
|
|
|
k KEYS Display the full documentation for the key sequence.
|
|
|
|
|
K KEYS Show the on-line manual's section for the command bound to KEYS.
|
2008-12-25 13:49:52 +00:00
|
|
|
|
l Show last 300 input keystrokes (lossage).
|
2008-02-29 23:37:38 +00:00
|
|
|
|
L LANG-ENV Describes a specific language environment, or RET for current.
|
|
|
|
|
m Display documentation of current minor modes and current major mode,
|
|
|
|
|
including their special commands.
|
|
|
|
|
n Display news of recent Emacs changes.
|
|
|
|
|
p TOPIC Find packages matching a given topic keyword.
|
|
|
|
|
r Display the Emacs manual in Info mode.
|
|
|
|
|
s Display contents of current syntax table, plus explanations.
|
|
|
|
|
S SYMBOL Show the section for the given symbol in the on-line manual
|
|
|
|
|
for the programming language used in this buffer.
|
|
|
|
|
t Start the Emacs learn-by-doing tutorial.
|
|
|
|
|
v VARIABLE Display the given variable's documentation and value.
|
|
|
|
|
w COMMAND Display which keystrokes invoke the given command (where-is).
|
|
|
|
|
. Display any available local help at point in the echo area.
|
|
|
|
|
|
|
|
|
|
C-a Information about Emacs.
|
|
|
|
|
C-c Emacs copying permission (GNU General Public License).
|
|
|
|
|
C-d Instructions for debugging GNU Emacs.
|
|
|
|
|
C-e External packages and information about Emacs.
|
|
|
|
|
C-f Emacs FAQ.
|
|
|
|
|
C-m How to order printed Emacs manuals.
|
|
|
|
|
C-n News of recent Emacs changes.
|
|
|
|
|
C-o Emacs ordering and distribution information.
|
|
|
|
|
C-p Info about known Emacs problems.
|
|
|
|
|
C-t Emacs TODO list.
|
2009-09-27 00:27:21 +00:00
|
|
|
|
C-w Information on absence of warranty for GNU Emacs."
|
Don't require `view' when compiling.
(help-with-tutorial, describe-function, describe-function-1)
(variable-at-point, describe-variable, locate-library):
Functions moved into `help-funs.el'.
(help-manyarg-func-alist): Variable moved into `help-funs.el'.
(help-mode, help-mode-setup, help-mode-finish, help-button-action)
(help-setup-xref, help-xref-following, help-make-xrefs)
(help-xref-button, help-insert-xref-button, help-xref-interned)
(help-xref-go-back, help-go-back, help-do-xref, help-follow)
(help-xref-on-pp): Functions moved into `help-mode.el'
(help-mode-map, help-xref-stack, help-xref-stack-item)
(help-highlight-p, help-highlight-face, help-back-label)
(help-xref-symbol-regexp, help-xref-mule-regexp)
(help-xref-info-regexp): Variables moved into `help-mode.el'.
(help-symbol, help-back, help-info, help-customize-variable)
(help-function-def, help-variable-def):
Button-types moved into `help-mode.el'.
(load-symbol-file-load-history, symbol-file):
Functions moved into `subr.el'.
(symbol-file-load-history-loaded): Variable moved into `subr.el'.
(view-lossage): Call `help-setup-xref' instead of doing it manually.
2001-10-09 11:17:39 +00:00
|
|
|
|
help-map)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun function-called-at-point ()
|
|
|
|
|
"Return a function around point or else called by the list containing point.
|
|
|
|
|
If that doesn't give a function, return nil."
|
2008-06-06 20:02:42 +00:00
|
|
|
|
(with-syntax-table emacs-lisp-mode-syntax-table
|
|
|
|
|
(or (condition-case ()
|
|
|
|
|
(save-excursion
|
|
|
|
|
(or (not (zerop (skip-syntax-backward "_w")))
|
|
|
|
|
(eq (char-syntax (following-char)) ?w)
|
|
|
|
|
(eq (char-syntax (following-char)) ?_)
|
|
|
|
|
(forward-sexp -1))
|
|
|
|
|
(skip-chars-forward "'")
|
|
|
|
|
(let ((obj (read (current-buffer))))
|
|
|
|
|
(and (symbolp obj) (fboundp obj) obj)))
|
|
|
|
|
(error nil))
|
|
|
|
|
(condition-case ()
|
|
|
|
|
(save-excursion
|
|
|
|
|
(save-restriction
|
|
|
|
|
(narrow-to-region (max (point-min)
|
|
|
|
|
(- (point) 1000)) (point-max))
|
|
|
|
|
;; Move up to surrounding paren, then after the open.
|
|
|
|
|
(backward-up-list 1)
|
|
|
|
|
(forward-char 1)
|
|
|
|
|
;; If there is space here, this is probably something
|
|
|
|
|
;; other than a real Lisp function call, so ignore it.
|
|
|
|
|
(if (looking-at "[ \t]")
|
|
|
|
|
(error "Probably not a Lisp function call"))
|
|
|
|
|
(let ((obj (read (current-buffer))))
|
|
|
|
|
(and (symbolp obj) (fboundp obj) obj))))
|
|
|
|
|
(error nil))
|
|
|
|
|
(let* ((str (find-tag-default))
|
|
|
|
|
(sym (if str (intern-soft str))))
|
|
|
|
|
(if (and sym (fboundp sym))
|
|
|
|
|
sym
|
|
|
|
|
(save-match-data
|
|
|
|
|
(when (and str (string-match "\\`\\W*\\(.*?\\)\\W*\\'" str))
|
|
|
|
|
(setq sym (intern-soft (match-string 1 str)))
|
|
|
|
|
(and (fboundp sym) sym))))))))
|
Don't require `view' when compiling.
(help-with-tutorial, describe-function, describe-function-1)
(variable-at-point, describe-variable, locate-library):
Functions moved into `help-funs.el'.
(help-manyarg-func-alist): Variable moved into `help-funs.el'.
(help-mode, help-mode-setup, help-mode-finish, help-button-action)
(help-setup-xref, help-xref-following, help-make-xrefs)
(help-xref-button, help-insert-xref-button, help-xref-interned)
(help-xref-go-back, help-go-back, help-do-xref, help-follow)
(help-xref-on-pp): Functions moved into `help-mode.el'
(help-mode-map, help-xref-stack, help-xref-stack-item)
(help-highlight-p, help-highlight-face, help-back-label)
(help-xref-symbol-regexp, help-xref-mule-regexp)
(help-xref-info-regexp): Variables moved into `help-mode.el'.
(help-symbol, help-back, help-info, help-customize-variable)
(help-function-def, help-variable-def):
Button-types moved into `help-mode.el'.
(load-symbol-file-load-history, symbol-file):
Functions moved into `subr.el'.
(symbol-file-load-history-loaded): Variable moved into `subr.el'.
(view-lossage): Call `help-setup-xref' instead of doing it manually.
2001-10-09 11:17:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; `User' help functions
|
|
|
|
|
|
2008-02-29 23:37:38 +00:00
|
|
|
|
(defun view-help-file (file &optional dir)
|
|
|
|
|
(view-file (expand-file-name file (or dir data-directory)))
|
2009-01-14 23:10:54 +00:00
|
|
|
|
(goto-address-mode 1)
|
2008-02-29 23:37:38 +00:00
|
|
|
|
(goto-char (point-min)))
|
|
|
|
|
|
1991-08-25 21:47:10 +00:00
|
|
|
|
(defun describe-distribution ()
|
|
|
|
|
"Display info on how to obtain the latest version of GNU Emacs."
|
|
|
|
|
(interactive)
|
2008-02-29 23:37:38 +00:00
|
|
|
|
(view-help-file "DISTRIB"))
|
1991-08-25 21:47:10 +00:00
|
|
|
|
|
|
|
|
|
(defun describe-copying ()
|
|
|
|
|
"Display info on how you may redistribute copies of GNU Emacs."
|
|
|
|
|
(interactive)
|
2008-02-29 23:37:38 +00:00
|
|
|
|
(view-help-file "COPYING"))
|
1991-08-25 21:47:10 +00:00
|
|
|
|
|
2008-02-29 23:37:38 +00:00
|
|
|
|
(defun describe-gnu-project ()
|
1993-11-15 09:23:34 +00:00
|
|
|
|
"Display info on the GNU project."
|
|
|
|
|
(interactive)
|
2008-02-29 23:37:38 +00:00
|
|
|
|
(view-help-file "THE-GNU-PROJECT"))
|
1993-11-15 09:23:34 +00:00
|
|
|
|
|
2008-03-06 00:07:41 +00:00
|
|
|
|
(define-obsolete-function-alias 'describe-project 'describe-gnu-project "22.2")
|
|
|
|
|
|
1991-08-25 21:47:10 +00:00
|
|
|
|
(defun describe-no-warranty ()
|
|
|
|
|
"Display info on all the kinds of warranty Emacs does NOT have."
|
|
|
|
|
(interactive)
|
|
|
|
|
(describe-copying)
|
|
|
|
|
(let (case-fold-search)
|
2009-10-07 02:52:37 +00:00
|
|
|
|
(search-forward "Disclaimer of Warranty")
|
|
|
|
|
(forward-line 0)
|
1991-08-25 21:47:10 +00:00
|
|
|
|
(recenter 0)))
|
|
|
|
|
|
1993-07-04 18:53:24 +00:00
|
|
|
|
(defun describe-prefix-bindings ()
|
1993-07-04 18:55:54 +00:00
|
|
|
|
"Describe the bindings of the prefix used to reach this command.
|
|
|
|
|
The prefix described consists of all but the last event
|
|
|
|
|
of the key sequence that ran this command."
|
1993-07-04 18:53:24 +00:00
|
|
|
|
(interactive)
|
2006-09-16 10:45:38 +00:00
|
|
|
|
(let ((key (this-command-keys)))
|
1995-05-24 00:46:17 +00:00
|
|
|
|
(describe-bindings
|
|
|
|
|
(if (stringp key)
|
|
|
|
|
(substring key 0 (1- (length key)))
|
|
|
|
|
(let ((prefix (make-vector (1- (length key)) nil))
|
|
|
|
|
(i 0))
|
|
|
|
|
(while (< i (length prefix))
|
|
|
|
|
(aset prefix i (aref key i))
|
|
|
|
|
(setq i (1+ i)))
|
|
|
|
|
prefix)))))
|
Don't require `view' when compiling.
(help-with-tutorial, describe-function, describe-function-1)
(variable-at-point, describe-variable, locate-library):
Functions moved into `help-funs.el'.
(help-manyarg-func-alist): Variable moved into `help-funs.el'.
(help-mode, help-mode-setup, help-mode-finish, help-button-action)
(help-setup-xref, help-xref-following, help-make-xrefs)
(help-xref-button, help-insert-xref-button, help-xref-interned)
(help-xref-go-back, help-go-back, help-do-xref, help-follow)
(help-xref-on-pp): Functions moved into `help-mode.el'
(help-mode-map, help-xref-stack, help-xref-stack-item)
(help-highlight-p, help-highlight-face, help-back-label)
(help-xref-symbol-regexp, help-xref-mule-regexp)
(help-xref-info-regexp): Variables moved into `help-mode.el'.
(help-symbol, help-back, help-info, help-customize-variable)
(help-function-def, help-variable-def):
Button-types moved into `help-mode.el'.
(load-symbol-file-load-history, symbol-file):
Functions moved into `subr.el'.
(symbol-file-load-history-loaded): Variable moved into `subr.el'.
(view-lossage): Call `help-setup-xref' instead of doing it manually.
2001-10-09 11:17:39 +00:00
|
|
|
|
;; Make C-h after a prefix, when not specifically bound,
|
1993-07-04 18:55:54 +00:00
|
|
|
|
;; run describe-prefix-bindings.
|
1993-07-04 18:53:24 +00:00
|
|
|
|
(setq prefix-help-command 'describe-prefix-bindings)
|
|
|
|
|
|
2006-06-04 01:14:15 +00:00
|
|
|
|
(defun view-emacs-news (&optional version)
|
1998-03-18 01:59:58 +00:00
|
|
|
|
"Display info on recent changes to Emacs.
|
2004-04-27 06:35:25 +00:00
|
|
|
|
With argument, display info only for the selected version."
|
1998-03-18 01:59:58 +00:00
|
|
|
|
(interactive "P")
|
2006-06-04 01:14:15 +00:00
|
|
|
|
(unless version
|
|
|
|
|
(setq version emacs-major-version))
|
|
|
|
|
(when (consp version)
|
|
|
|
|
(let* ((all-versions
|
|
|
|
|
(let (res)
|
2007-09-25 11:07:06 +00:00
|
|
|
|
(mapc
|
2006-06-04 01:14:15 +00:00
|
|
|
|
(lambda (file)
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(insert-file-contents
|
|
|
|
|
(expand-file-name file data-directory))
|
|
|
|
|
(while (re-search-forward
|
|
|
|
|
(if (member file '("NEWS.18" "NEWS.1-17"))
|
|
|
|
|
"Changes in \\(?:Emacs\\|version\\)?[ \t]*\\([0-9]+\\(?:\\.[0-9]+\\)?\\)"
|
|
|
|
|
"^\* [^0-9\n]*\\([0-9]+\\.[0-9]+\\)") nil t)
|
|
|
|
|
(setq res (cons (match-string-no-properties 1) res)))))
|
|
|
|
|
(cons "NEWS"
|
|
|
|
|
(directory-files data-directory nil
|
|
|
|
|
"^NEWS\\.[0-9][-0-9]*$" nil)))
|
|
|
|
|
(sort (delete-dups res) (lambda (a b) (string< b a)))))
|
2006-06-25 22:41:40 +00:00
|
|
|
|
(current (car all-versions)))
|
2006-06-04 01:14:15 +00:00
|
|
|
|
(setq version (completing-read
|
|
|
|
|
(format "Read NEWS for the version (default %s): " current)
|
|
|
|
|
all-versions nil nil nil nil current))
|
|
|
|
|
(if (integerp (string-to-number version))
|
|
|
|
|
(setq version (string-to-number version))
|
|
|
|
|
(unless (or (member version all-versions)
|
|
|
|
|
(<= (string-to-number version) (string-to-number current)))
|
|
|
|
|
(error "No news about version %s" version)))))
|
|
|
|
|
(when (integerp version)
|
|
|
|
|
(cond ((<= version 12)
|
|
|
|
|
(setq version (format "1.%d" version)))
|
|
|
|
|
((<= version 18)
|
|
|
|
|
(setq version (format "%d" version)))
|
|
|
|
|
((> version emacs-major-version)
|
2006-11-06 02:46:23 +00:00
|
|
|
|
(error "No news about Emacs %d (yet)" version))))
|
2006-06-04 01:14:15 +00:00
|
|
|
|
(let* ((vn (if (stringp version)
|
|
|
|
|
(string-to-number version)
|
|
|
|
|
version))
|
|
|
|
|
(file (cond
|
|
|
|
|
((>= vn emacs-major-version) "NEWS")
|
|
|
|
|
((< vn 18) "NEWS.1-17")
|
2006-06-25 22:41:40 +00:00
|
|
|
|
(t (format "NEWS.%d" vn))))
|
|
|
|
|
res)
|
2006-06-04 01:14:15 +00:00
|
|
|
|
(view-file (expand-file-name file data-directory))
|
|
|
|
|
(widen)
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(when (stringp version)
|
|
|
|
|
(when (re-search-forward
|
|
|
|
|
(concat (if (< vn 19)
|
|
|
|
|
"Changes in Emacs[ \t]*"
|
|
|
|
|
"^\* [^0-9\n]*") version "$")
|
|
|
|
|
nil t)
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(narrow-to-region
|
|
|
|
|
(point)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(while (and (setq res
|
|
|
|
|
(re-search-forward
|
|
|
|
|
(if (< vn 19)
|
|
|
|
|
"Changes in \\(?:Emacs\\|version\\)?[ \t]*\\([0-9]+\\(?:\\.[0-9]+\\)?\\)"
|
|
|
|
|
"^\* [^0-9\n]*\\([0-9]+\\.[0-9]+\\)") nil t))
|
|
|
|
|
(equal (match-string-no-properties 1) version)))
|
|
|
|
|
(or res (goto-char (point-max)))
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(point)))))))
|
|
|
|
|
|
2011-04-19 13:44:55 +00:00
|
|
|
|
(defun view-emacs-todo (&optional _arg)
|
2002-05-01 16:41:52 +00:00
|
|
|
|
"Display the Emacs TODO list."
|
|
|
|
|
(interactive "P")
|
2008-02-29 23:37:38 +00:00
|
|
|
|
(view-help-file "TODO"))
|
2002-05-01 16:41:52 +00:00
|
|
|
|
|
2008-03-06 00:07:41 +00:00
|
|
|
|
(define-obsolete-function-alias 'view-todo 'view-emacs-todo "22.2")
|
|
|
|
|
|
|
|
|
|
|
2002-01-14 01:36:33 +00:00
|
|
|
|
(defun view-echo-area-messages ()
|
|
|
|
|
"View the log of recent echo-area messages: the `*Messages*' buffer.
|
|
|
|
|
The number of messages retained in that buffer
|
|
|
|
|
is specified by the variable `message-log-max'."
|
|
|
|
|
(interactive)
|
|
|
|
|
(switch-to-buffer (get-buffer-create "*Messages*")))
|
|
|
|
|
|
2001-02-22 11:18:03 +00:00
|
|
|
|
(defun view-order-manuals ()
|
|
|
|
|
"Display the Emacs ORDERS file."
|
|
|
|
|
(interactive)
|
2008-02-29 23:37:38 +00:00
|
|
|
|
(view-help-file "ORDERS"))
|
2001-02-22 11:18:03 +00:00
|
|
|
|
|
1995-03-06 05:16:14 +00:00
|
|
|
|
(defun view-emacs-FAQ ()
|
|
|
|
|
"Display the Emacs Frequently Asked Questions (FAQ) file."
|
|
|
|
|
(interactive)
|
2001-10-11 22:31:20 +00:00
|
|
|
|
;; (find-file-read-only (expand-file-name "FAQ" data-directory))
|
2000-05-16 14:31:26 +00:00
|
|
|
|
(info "(efaq)"))
|
1995-03-06 05:16:14 +00:00
|
|
|
|
|
1999-12-07 20:01:20 +00:00
|
|
|
|
(defun view-emacs-problems ()
|
|
|
|
|
"Display info on known problems with Emacs and possible workarounds."
|
|
|
|
|
(interactive)
|
2008-02-29 23:37:38 +00:00
|
|
|
|
(view-help-file "PROBLEMS"))
|
|
|
|
|
|
|
|
|
|
(defun view-emacs-debugging ()
|
|
|
|
|
"Display info on how to debug Emacs problems."
|
|
|
|
|
(interactive)
|
|
|
|
|
(view-help-file "DEBUG"))
|
|
|
|
|
|
|
|
|
|
(defun view-external-packages ()
|
|
|
|
|
"Display external packages and information about Emacs."
|
|
|
|
|
(interactive)
|
|
|
|
|
(view-help-file "MORE.STUFF"))
|
1999-12-07 20:01:20 +00:00
|
|
|
|
|
1991-08-25 21:47:10 +00:00
|
|
|
|
(defun view-lossage ()
|
2008-10-11 18:43:38 +00:00
|
|
|
|
"Display last 300 input keystrokes.
|
2001-03-25 14:02:09 +00:00
|
|
|
|
|
|
|
|
|
To record all your input on a file, use `open-dribble-file'."
|
1991-08-25 21:47:10 +00:00
|
|
|
|
(interactive)
|
2009-10-02 03:48:36 +00:00
|
|
|
|
(help-setup-xref (list #'view-lossage)
|
|
|
|
|
(called-interactively-p 'interactive))
|
2007-11-10 09:53:22 +00:00
|
|
|
|
(with-help-window (help-buffer)
|
2002-04-02 03:23:26 +00:00
|
|
|
|
(princ (mapconcat (lambda (key)
|
|
|
|
|
(if (or (integerp key) (symbolp key) (listp key))
|
|
|
|
|
(single-key-description key)
|
|
|
|
|
(prin1-to-string key nil)))
|
1994-08-10 04:08:26 +00:00
|
|
|
|
(recent-keys)
|
|
|
|
|
" "))
|
2001-10-08 00:19:58 +00:00
|
|
|
|
(with-current-buffer standard-output
|
1991-08-25 21:47:10 +00:00
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(while (progn (move-to-column 50) (not (eobp)))
|
2006-03-08 10:11:47 +00:00
|
|
|
|
(when (search-forward " " nil t)
|
|
|
|
|
(delete-char -1))
|
2007-11-10 09:53:22 +00:00
|
|
|
|
(insert "\n"))
|
|
|
|
|
;; jidanni wants to see the last keystrokes immediately.
|
|
|
|
|
(set-marker help-window-point-marker (point)))))
|
1991-08-25 21:47:10 +00:00
|
|
|
|
|
Don't require `view' when compiling.
(help-with-tutorial, describe-function, describe-function-1)
(variable-at-point, describe-variable, locate-library):
Functions moved into `help-funs.el'.
(help-manyarg-func-alist): Variable moved into `help-funs.el'.
(help-mode, help-mode-setup, help-mode-finish, help-button-action)
(help-setup-xref, help-xref-following, help-make-xrefs)
(help-xref-button, help-insert-xref-button, help-xref-interned)
(help-xref-go-back, help-go-back, help-do-xref, help-follow)
(help-xref-on-pp): Functions moved into `help-mode.el'
(help-mode-map, help-xref-stack, help-xref-stack-item)
(help-highlight-p, help-highlight-face, help-back-label)
(help-xref-symbol-regexp, help-xref-mule-regexp)
(help-xref-info-regexp): Variables moved into `help-mode.el'.
(help-symbol, help-back, help-info, help-customize-variable)
(help-function-def, help-variable-def):
Button-types moved into `help-mode.el'.
(load-symbol-file-load-history, symbol-file):
Functions moved into `subr.el'.
(symbol-file-load-history-loaded): Variable moved into `subr.el'.
(view-lossage): Call `help-setup-xref' instead of doing it manually.
2001-10-09 11:17:39 +00:00
|
|
|
|
|
|
|
|
|
;; Key bindings
|
1991-08-25 21:47:10 +00:00
|
|
|
|
|
1998-06-01 21:11:47 +00:00
|
|
|
|
(defun describe-bindings (&optional prefix buffer)
|
1998-02-05 03:26:45 +00:00
|
|
|
|
"Show a list of all defined keys, and their definitions.
|
|
|
|
|
We put that list in a buffer, and display the buffer.
|
|
|
|
|
|
|
|
|
|
The optional argument PREFIX, if non-nil, should be a key sequence;
|
1998-06-01 21:11:47 +00:00
|
|
|
|
then we display only bindings that start with that prefix.
|
|
|
|
|
The optional argument BUFFER specifies which buffer's bindings
|
2004-08-09 18:50:28 +00:00
|
|
|
|
to display (default, the current buffer). BUFFER can be a buffer
|
|
|
|
|
or a buffer name."
|
2001-10-11 23:34:17 +00:00
|
|
|
|
(interactive)
|
1998-06-01 21:11:47 +00:00
|
|
|
|
(or buffer (setq buffer (current-buffer)))
|
2009-10-02 03:48:36 +00:00
|
|
|
|
(help-setup-xref (list #'describe-bindings prefix buffer)
|
|
|
|
|
(called-interactively-p 'interactive))
|
1998-06-01 21:11:47 +00:00
|
|
|
|
(with-current-buffer buffer
|
2001-10-11 23:34:17 +00:00
|
|
|
|
(describe-bindings-internal nil prefix)))
|
1998-02-05 03:26:45 +00:00
|
|
|
|
|
2001-10-11 22:31:20 +00:00
|
|
|
|
;; This function used to be in keymap.c.
|
|
|
|
|
(defun describe-bindings-internal (&optional menus prefix)
|
|
|
|
|
"Show a list of all defined keys, and their definitions.
|
|
|
|
|
We put that list in a buffer, and display the buffer.
|
|
|
|
|
|
|
|
|
|
The optional argument MENUS, if non-nil, says to mention menu bindings.
|
|
|
|
|
\(Ordinarily these are omitted from the output.)
|
|
|
|
|
The optional argument PREFIX, if non-nil, should be a key sequence;
|
|
|
|
|
then we display only bindings that start with that prefix."
|
|
|
|
|
(let ((buf (current-buffer)))
|
2007-11-10 09:53:22 +00:00
|
|
|
|
(with-help-window "*Help*"
|
2001-10-11 22:31:20 +00:00
|
|
|
|
(with-current-buffer standard-output
|
|
|
|
|
(describe-buffer-bindings buf prefix menus)))))
|
|
|
|
|
|
1997-05-22 06:20:42 +00:00
|
|
|
|
(defun where-is (definition &optional insert)
|
1999-01-15 17:29:03 +00:00
|
|
|
|
"Print message listing key sequences that invoke the command DEFINITION.
|
1997-05-22 06:20:42 +00:00
|
|
|
|
Argument is a command definition, usually a symbol with a function definition.
|
|
|
|
|
If INSERT (the prefix arg) is non-nil, insert the message in the buffer."
|
1994-03-23 04:54:20 +00:00
|
|
|
|
(interactive
|
|
|
|
|
(let ((fn (function-called-at-point))
|
Don't require `view' when compiling.
(help-with-tutorial, describe-function, describe-function-1)
(variable-at-point, describe-variable, locate-library):
Functions moved into `help-funs.el'.
(help-manyarg-func-alist): Variable moved into `help-funs.el'.
(help-mode, help-mode-setup, help-mode-finish, help-button-action)
(help-setup-xref, help-xref-following, help-make-xrefs)
(help-xref-button, help-insert-xref-button, help-xref-interned)
(help-xref-go-back, help-go-back, help-do-xref, help-follow)
(help-xref-on-pp): Functions moved into `help-mode.el'
(help-mode-map, help-xref-stack, help-xref-stack-item)
(help-highlight-p, help-highlight-face, help-back-label)
(help-xref-symbol-regexp, help-xref-mule-regexp)
(help-xref-info-regexp): Variables moved into `help-mode.el'.
(help-symbol, help-back, help-info, help-customize-variable)
(help-function-def, help-variable-def):
Button-types moved into `help-mode.el'.
(load-symbol-file-load-history, symbol-file):
Functions moved into `subr.el'.
(symbol-file-load-history-loaded): Variable moved into `subr.el'.
(view-lossage): Call `help-setup-xref' instead of doing it manually.
2001-10-09 11:17:39 +00:00
|
|
|
|
(enable-recursive-minibuffers t)
|
1994-03-23 04:54:20 +00:00
|
|
|
|
val)
|
2002-11-07 18:28:09 +00:00
|
|
|
|
(setq val (completing-read
|
|
|
|
|
(if fn
|
|
|
|
|
(format "Where is command (default %s): " fn)
|
|
|
|
|
"Where is command: ")
|
|
|
|
|
obarray 'commandp t))
|
|
|
|
|
(list (if (equal val "") fn (intern val)) current-prefix-arg)))
|
2007-02-28 12:50:43 +00:00
|
|
|
|
(unless definition (error "No command"))
|
2002-11-07 16:46:11 +00:00
|
|
|
|
(let ((func (indirect-function definition))
|
2002-11-07 18:28:09 +00:00
|
|
|
|
(defs nil)
|
2011-09-13 07:18:13 +00:00
|
|
|
|
(standard-output (if insert (current-buffer) standard-output)))
|
2005-03-21 17:41:41 +00:00
|
|
|
|
;; In DEFS, find all symbols that are aliases for DEFINITION.
|
2002-11-07 18:28:09 +00:00
|
|
|
|
(mapatoms (lambda (symbol)
|
|
|
|
|
(and (fboundp symbol)
|
|
|
|
|
(not (eq symbol definition))
|
2003-01-13 08:04:46 +00:00
|
|
|
|
(eq func (condition-case ()
|
|
|
|
|
(indirect-function symbol)
|
|
|
|
|
(error symbol)))
|
2002-11-07 18:28:09 +00:00
|
|
|
|
(push symbol defs))))
|
2005-03-21 17:41:41 +00:00
|
|
|
|
;; Look at all the symbols--first DEFINITION,
|
|
|
|
|
;; then its aliases.
|
|
|
|
|
(dolist (symbol (cons definition defs))
|
|
|
|
|
(let* ((remapped (command-remapping symbol))
|
|
|
|
|
(keys (where-is-internal
|
|
|
|
|
symbol overriding-local-map nil nil remapped))
|
|
|
|
|
(keys (mapconcat 'key-description keys ", "))
|
|
|
|
|
string)
|
|
|
|
|
(setq string
|
|
|
|
|
(if insert
|
|
|
|
|
(if (> (length keys) 0)
|
|
|
|
|
(if remapped
|
|
|
|
|
(format "%s (%s) (remapped from %s)"
|
|
|
|
|
keys remapped symbol)
|
|
|
|
|
(format "%s (%s)" keys symbol))
|
|
|
|
|
(format "M-x %s RET" symbol))
|
|
|
|
|
(if (> (length keys) 0)
|
|
|
|
|
(if remapped
|
|
|
|
|
(format "%s is remapped to %s which is on %s"
|
2006-02-14 08:14:01 +00:00
|
|
|
|
symbol remapped keys)
|
2005-03-21 17:41:41 +00:00
|
|
|
|
(format "%s is on %s" symbol keys))
|
|
|
|
|
;; If this is the command the user asked about,
|
|
|
|
|
;; and it is not on any key, say so.
|
|
|
|
|
;; For other symbols, its aliases, say nothing
|
|
|
|
|
;; about them unless they are on keys.
|
|
|
|
|
(if (eq symbol definition)
|
|
|
|
|
(format "%s is not on any key" symbol)))))
|
|
|
|
|
(when string
|
|
|
|
|
(unless (eq symbol definition)
|
|
|
|
|
(princ ";\n its alias "))
|
|
|
|
|
(princ string)))))
|
1994-03-23 04:54:20 +00:00
|
|
|
|
nil)
|
|
|
|
|
|
2002-04-02 03:23:26 +00:00
|
|
|
|
(defun help-key-description (key untranslated)
|
|
|
|
|
(let ((string (key-description key)))
|
2002-07-16 16:08:44 +00:00
|
|
|
|
(if (or (not untranslated)
|
|
|
|
|
(and (eq (aref untranslated 0) ?\e) (not (eq (aref key 0) ?\e))))
|
2002-04-02 03:23:26 +00:00
|
|
|
|
string
|
|
|
|
|
(let ((otherstring (key-description untranslated)))
|
|
|
|
|
(if (equal string otherstring)
|
|
|
|
|
string
|
|
|
|
|
(format "%s (translated from %s)" string otherstring))))))
|
2003-02-04 11:26:42 +00:00
|
|
|
|
|
2006-02-11 13:55:42 +00:00
|
|
|
|
(defun describe-key-briefly (&optional key insert untranslated)
|
|
|
|
|
"Print the name of the function KEY invokes. KEY is a string.
|
|
|
|
|
If INSERT (the prefix arg) is non-nil, insert the message in the buffer.
|
|
|
|
|
If non-nil, UNTRANSLATED is a vector of the untranslated events.
|
|
|
|
|
It can also be a number in which case the untranslated events from
|
|
|
|
|
the last key hit are used.
|
|
|
|
|
|
|
|
|
|
If KEY is a menu item or a tool-bar button that is disabled, this command
|
2006-02-11 16:03:14 +00:00
|
|
|
|
temporarily enables it to allow getting help on disabled items and buttons."
|
2006-02-13 16:18:46 +00:00
|
|
|
|
(interactive
|
|
|
|
|
(let ((enable-disabled-menus-and-buttons t)
|
|
|
|
|
(cursor-in-echo-area t)
|
|
|
|
|
saved-yank-menu)
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(let (key)
|
|
|
|
|
;; If yank-menu is empty, populate it temporarily, so that
|
|
|
|
|
;; "Select and Paste" menu can generate a complete event.
|
|
|
|
|
(when (null (cdr yank-menu))
|
|
|
|
|
(setq saved-yank-menu (copy-sequence yank-menu))
|
|
|
|
|
(menu-bar-update-yank-menu "(any string)" nil))
|
|
|
|
|
(setq key (read-key-sequence "Describe key (or click or menu item): "))
|
2006-03-07 15:53:41 +00:00
|
|
|
|
;; If KEY is a down-event, read and discard the
|
2006-09-15 08:53:18 +00:00
|
|
|
|
;; corresponding up-event. Note that there are also
|
|
|
|
|
;; down-events on scroll bars and mode lines: the actual
|
|
|
|
|
;; event then is in the second element of the vector.
|
|
|
|
|
(and (vectorp key)
|
2006-09-24 20:43:32 +00:00
|
|
|
|
(let ((last-idx (1- (length key))))
|
|
|
|
|
(and (eventp (aref key last-idx))
|
|
|
|
|
(memq 'down (event-modifiers (aref key last-idx)))))
|
2006-09-15 08:53:18 +00:00
|
|
|
|
(read-event))
|
2006-02-13 16:18:46 +00:00
|
|
|
|
(list
|
|
|
|
|
key
|
2006-02-21 19:51:37 +00:00
|
|
|
|
(if current-prefix-arg (prefix-numeric-value current-prefix-arg))
|
|
|
|
|
1))
|
2006-02-13 16:18:46 +00:00
|
|
|
|
;; Put yank-menu back as it was, if we changed it.
|
|
|
|
|
(when saved-yank-menu
|
|
|
|
|
(setq yank-menu (copy-sequence saved-yank-menu))
|
|
|
|
|
(fset 'yank-menu (cons 'keymap yank-menu))))))
|
2002-04-02 03:23:26 +00:00
|
|
|
|
(if (numberp untranslated)
|
|
|
|
|
(setq untranslated (this-single-command-raw-keys)))
|
2006-09-15 08:53:18 +00:00
|
|
|
|
(let* ((event (if (and (symbolp (aref key 0))
|
|
|
|
|
(> (length key) 1)
|
|
|
|
|
(consp (aref key 1)))
|
|
|
|
|
(aref key 1)
|
|
|
|
|
(aref key 0)))
|
|
|
|
|
(modifiers (event-modifiers event))
|
2011-09-13 07:22:05 +00:00
|
|
|
|
(standard-output (if insert (current-buffer) standard-output))
|
2006-09-19 13:59:27 +00:00
|
|
|
|
(mouse-msg (if (or (memq 'click modifiers) (memq 'down modifiers)
|
|
|
|
|
(memq 'drag modifiers)) " at that spot" ""))
|
|
|
|
|
(defn (key-binding key t))
|
|
|
|
|
key-desc)
|
|
|
|
|
;; Handle the case where we faked an entry in "Select and Paste" menu.
|
|
|
|
|
(if (and (eq defn nil)
|
|
|
|
|
(stringp (aref key (1- (length key))))
|
|
|
|
|
(eq (key-binding (substring key 0 -1)) 'yank-menu))
|
|
|
|
|
(setq defn 'menu-bar-select-yank))
|
|
|
|
|
;; Don't bother user with strings from (e.g.) the select-paste menu.
|
|
|
|
|
(if (stringp (aref key (1- (length key))))
|
|
|
|
|
(aset key (1- (length key)) "(any string)"))
|
|
|
|
|
(if (and (> (length untranslated) 0)
|
|
|
|
|
(stringp (aref untranslated (1- (length untranslated)))))
|
|
|
|
|
(aset untranslated (1- (length untranslated)) "(any string)"))
|
|
|
|
|
;; Now describe the key, perhaps as changed.
|
|
|
|
|
(setq key-desc (help-key-description key untranslated))
|
|
|
|
|
(if (or (null defn) (integerp defn) (equal defn 'undefined))
|
|
|
|
|
(princ (format "%s%s is undefined" key-desc mouse-msg))
|
|
|
|
|
(princ (format "%s%s runs the command %S" key-desc mouse-msg defn)))))
|
2000-09-07 02:37:37 +00:00
|
|
|
|
|
2006-02-11 13:55:42 +00:00
|
|
|
|
(defun describe-key (&optional key untranslated up-event)
|
|
|
|
|
"Display documentation of the function invoked by KEY.
|
|
|
|
|
KEY can be any kind of a key sequence; it can include keyboard events,
|
|
|
|
|
mouse events, and/or menu events. When calling from a program,
|
|
|
|
|
pass KEY as a string or a vector.
|
|
|
|
|
|
|
|
|
|
If non-nil, UNTRANSLATED is a vector of the corresponding untranslated events.
|
|
|
|
|
It can also be a number, in which case the untranslated events from
|
|
|
|
|
the last key sequence entered are used.
|
|
|
|
|
UP-EVENT is the up-event that was discarded by reading KEY, or nil.
|
|
|
|
|
|
|
|
|
|
If KEY is a menu item or a tool-bar button that is disabled, this command
|
2006-02-11 16:03:14 +00:00
|
|
|
|
temporarily enables it to allow getting help on disabled items and buttons."
|
2006-02-13 16:18:46 +00:00
|
|
|
|
(interactive
|
|
|
|
|
(let ((enable-disabled-menus-and-buttons t)
|
|
|
|
|
(cursor-in-echo-area t)
|
|
|
|
|
saved-yank-menu)
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(let (key)
|
|
|
|
|
;; If yank-menu is empty, populate it temporarily, so that
|
|
|
|
|
;; "Select and Paste" menu can generate a complete event.
|
|
|
|
|
(when (null (cdr yank-menu))
|
|
|
|
|
(setq saved-yank-menu (copy-sequence yank-menu))
|
|
|
|
|
(menu-bar-update-yank-menu "(any string)" nil))
|
|
|
|
|
(setq key (read-key-sequence "Describe key (or click or menu item): "))
|
|
|
|
|
(list
|
|
|
|
|
key
|
|
|
|
|
(prefix-numeric-value current-prefix-arg)
|
2007-03-21 16:15:45 +00:00
|
|
|
|
;; If KEY is a down-event, read and include the
|
2006-09-24 20:43:32 +00:00
|
|
|
|
;; corresponding up-event. Note that there are also
|
|
|
|
|
;; down-events on scroll bars and mode lines: the actual
|
|
|
|
|
;; event then is in the second element of the vector.
|
2006-09-15 08:53:18 +00:00
|
|
|
|
(and (vectorp key)
|
2006-09-24 20:43:32 +00:00
|
|
|
|
(let ((last-idx (1- (length key))))
|
|
|
|
|
(and (eventp (aref key last-idx))
|
|
|
|
|
(memq 'down (event-modifiers (aref key last-idx)))))
|
2006-09-15 08:53:18 +00:00
|
|
|
|
(or (and (eventp (aref key 0))
|
2006-09-23 19:34:38 +00:00
|
|
|
|
(memq 'down (event-modifiers (aref key 0)))
|
|
|
|
|
;; However, for the C-down-mouse-2 popup
|
|
|
|
|
;; menu, there is no subsequent up-event. In
|
|
|
|
|
;; this case, the up-event is the next
|
|
|
|
|
;; element in the supplied vector.
|
|
|
|
|
(= (length key) 1))
|
2006-09-15 08:53:18 +00:00
|
|
|
|
(and (> (length key) 1)
|
|
|
|
|
(eventp (aref key 1))
|
|
|
|
|
(memq 'down (event-modifiers (aref key 1)))))
|
|
|
|
|
(read-event))))
|
2006-02-13 16:18:46 +00:00
|
|
|
|
;; Put yank-menu back as it was, if we changed it.
|
|
|
|
|
(when saved-yank-menu
|
|
|
|
|
(setq yank-menu (copy-sequence saved-yank-menu))
|
|
|
|
|
(fset 'yank-menu (cons 'keymap yank-menu))))))
|
2002-04-02 03:23:26 +00:00
|
|
|
|
(if (numberp untranslated)
|
|
|
|
|
(setq untranslated (this-single-command-raw-keys)))
|
2006-09-15 21:25:01 +00:00
|
|
|
|
(let* ((event (aref key (if (and (symbolp (aref key 0))
|
|
|
|
|
(> (length key) 1)
|
|
|
|
|
(consp (aref key 1)))
|
|
|
|
|
1
|
|
|
|
|
0)))
|
2006-09-15 08:53:18 +00:00
|
|
|
|
(modifiers (event-modifiers event))
|
2006-09-19 13:59:27 +00:00
|
|
|
|
(mouse-msg (if (or (memq 'click modifiers) (memq 'down modifiers)
|
|
|
|
|
(memq 'drag modifiers)) " at that spot" ""))
|
2006-09-15 21:25:01 +00:00
|
|
|
|
(defn (key-binding key t))
|
|
|
|
|
defn-up defn-up-tricky ev-type
|
|
|
|
|
mouse-1-remapped mouse-1-tricky)
|
2006-09-15 08:53:18 +00:00
|
|
|
|
|
2006-09-15 21:25:01 +00:00
|
|
|
|
;; Handle the case where we faked an entry in "Select and Paste" menu.
|
2006-09-19 13:59:27 +00:00
|
|
|
|
(when (and (eq defn nil)
|
2006-09-15 08:53:18 +00:00
|
|
|
|
(stringp (aref key (1- (length key))))
|
|
|
|
|
(eq (key-binding (substring key 0 -1)) 'yank-menu))
|
2006-09-19 13:59:27 +00:00
|
|
|
|
(setq defn 'menu-bar-select-yank))
|
|
|
|
|
(if (or (null defn) (integerp defn) (equal defn 'undefined))
|
|
|
|
|
(message "%s%s is undefined"
|
|
|
|
|
(help-key-description key untranslated) mouse-msg)
|
2009-10-02 03:48:36 +00:00
|
|
|
|
(help-setup-xref (list #'describe-function defn)
|
|
|
|
|
(called-interactively-p 'interactive))
|
2006-09-19 13:59:27 +00:00
|
|
|
|
;; Don't bother user with strings from (e.g.) the select-paste menu.
|
|
|
|
|
(when (stringp (aref key (1- (length key))))
|
|
|
|
|
(aset key (1- (length key)) "(any string)"))
|
|
|
|
|
(when (and untranslated
|
2006-09-15 08:53:18 +00:00
|
|
|
|
(stringp (aref untranslated (1- (length untranslated)))))
|
2006-09-19 13:59:27 +00:00
|
|
|
|
(aset untranslated (1- (length untranslated))
|
|
|
|
|
"(any string)"))
|
|
|
|
|
;; Need to do this before erasing *Help* buffer in case event
|
|
|
|
|
;; is a mouse click in an existing *Help* buffer.
|
|
|
|
|
(when up-event
|
|
|
|
|
(setq ev-type (event-basic-type up-event))
|
|
|
|
|
(let ((sequence (vector up-event)))
|
|
|
|
|
(when (and (eq ev-type 'mouse-1)
|
|
|
|
|
mouse-1-click-follows-link
|
|
|
|
|
(not (eq mouse-1-click-follows-link 'double))
|
|
|
|
|
(setq mouse-1-remapped
|
|
|
|
|
(mouse-on-link-p (event-start up-event))))
|
|
|
|
|
(setq mouse-1-tricky (and (integerp mouse-1-click-follows-link)
|
|
|
|
|
(> mouse-1-click-follows-link 0)))
|
|
|
|
|
(cond ((stringp mouse-1-remapped)
|
|
|
|
|
(setq sequence mouse-1-remapped))
|
|
|
|
|
((vectorp mouse-1-remapped)
|
|
|
|
|
(setcar up-event (elt mouse-1-remapped 0)))
|
|
|
|
|
(t (setcar up-event 'mouse-2))))
|
|
|
|
|
(setq defn-up (key-binding sequence nil nil (event-start up-event)))
|
|
|
|
|
(when mouse-1-tricky
|
|
|
|
|
(setq sequence (vector up-event))
|
|
|
|
|
(aset sequence 0 'mouse-1)
|
|
|
|
|
(setq defn-up-tricky (key-binding sequence nil nil (event-start up-event))))))
|
2007-11-10 09:53:22 +00:00
|
|
|
|
(with-help-window (help-buffer)
|
2006-09-19 13:59:27 +00:00
|
|
|
|
(princ (help-key-description key untranslated))
|
|
|
|
|
(princ (format "\
|
2008-02-12 07:10:49 +00:00
|
|
|
|
%s runs the command %S, which is "
|
2006-09-19 13:59:27 +00:00
|
|
|
|
mouse-msg defn))
|
|
|
|
|
(describe-function-1 defn)
|
2006-09-15 21:25:01 +00:00
|
|
|
|
(when up-event
|
2006-09-19 13:59:27 +00:00
|
|
|
|
(unless (or (null defn-up)
|
|
|
|
|
(integerp defn-up)
|
|
|
|
|
(equal defn-up 'undefined))
|
|
|
|
|
(princ (format "
|
|
|
|
|
|
|
|
|
|
----------------- up-event %s----------------
|
|
|
|
|
|
2010-07-06 19:42:46 +00:00
|
|
|
|
%s%s%s runs the command %S, which is "
|
2006-09-19 13:59:27 +00:00
|
|
|
|
(if mouse-1-tricky "(short click) " "")
|
2010-07-06 19:42:46 +00:00
|
|
|
|
(key-description (vector up-event))
|
|
|
|
|
mouse-msg
|
2006-09-19 13:59:27 +00:00
|
|
|
|
(if mouse-1-remapped
|
2008-02-12 07:10:49 +00:00
|
|
|
|
" is remapped to <mouse-2>, which" "")
|
2006-09-19 13:59:27 +00:00
|
|
|
|
defn-up))
|
|
|
|
|
(describe-function-1 defn-up))
|
|
|
|
|
(unless (or (null defn-up-tricky)
|
|
|
|
|
(integerp defn-up-tricky)
|
|
|
|
|
(eq defn-up-tricky 'undefined))
|
|
|
|
|
(princ (format "
|
|
|
|
|
|
|
|
|
|
----------------- up-event (long click) ----------------
|
|
|
|
|
|
|
|
|
|
Pressing <%S>%s for longer than %d milli-seconds
|
2008-02-12 07:10:49 +00:00
|
|
|
|
runs the command %S, which is "
|
2006-09-19 13:59:27 +00:00
|
|
|
|
ev-type mouse-msg
|
|
|
|
|
mouse-1-click-follows-link
|
|
|
|
|
defn-up-tricky))
|
2007-11-10 09:53:22 +00:00
|
|
|
|
(describe-function-1 defn-up-tricky)))))))
|
(help-highlight-face): Use underline.
(help-mode-maybe): Ensure read-only.
(help-xref-button): Obey help-highlight-p.
(help-follow): Remove check for args being a list.
(help-mode): Doc fix.
(help-highlight-p): Put in help group.
(help-make-xrefs): Insert button label in scope of
inhibit-read-only binding.
(help-mode-map, help-make-xrefs): Define TAB, RET correctly.
Make hyperlinks for cross-reference info intuited from *Help* buffer.
(help-font-lock-keywords): Removed.
(help-mode-map): Define keys for navigating hyperlinks.
(help-xref-stack, help-xref-stack-item): New permanent-local variables.
(help-mode): Set font-lock-defaults to nil.
(help-mode-maybe): Invoke help-make-xrefs in Help mode.
(help-setup-xref): New function.
(describe-key, describe-mode, describe-function,
describe-variable): Call it.
(view-lossage, describe-bindings): Nullify help-xref-stack,
help-xref-stack-item.
(help-highlight-p): New option.
(help-highlight-face): New variable.
(help-back-label, help-xref-symbol-regexp, help-xref-info-regexp):
New variables.
(help-setup-xref, help-make-xrefs, help-xref-button,
help-xref-interned, help-xref-mode, help-follow-mouse,
help-xref-go-back, help-go-back, help-follow, help-next-ref): New functions.
1998-04-05 19:10:02 +00:00
|
|
|
|
|
Don't require `view' when compiling.
(help-with-tutorial, describe-function, describe-function-1)
(variable-at-point, describe-variable, locate-library):
Functions moved into `help-funs.el'.
(help-manyarg-func-alist): Variable moved into `help-funs.el'.
(help-mode, help-mode-setup, help-mode-finish, help-button-action)
(help-setup-xref, help-xref-following, help-make-xrefs)
(help-xref-button, help-insert-xref-button, help-xref-interned)
(help-xref-go-back, help-go-back, help-do-xref, help-follow)
(help-xref-on-pp): Functions moved into `help-mode.el'
(help-mode-map, help-xref-stack, help-xref-stack-item)
(help-highlight-p, help-highlight-face, help-back-label)
(help-xref-symbol-regexp, help-xref-mule-regexp)
(help-xref-info-regexp): Variables moved into `help-mode.el'.
(help-symbol, help-back, help-info, help-customize-variable)
(help-function-def, help-variable-def):
Button-types moved into `help-mode.el'.
(load-symbol-file-load-history, symbol-file):
Functions moved into `subr.el'.
(symbol-file-load-history-loaded): Variable moved into `subr.el'.
(view-lossage): Call `help-setup-xref' instead of doing it manually.
2001-10-09 11:17:39 +00:00
|
|
|
|
(defun describe-mode (&optional buffer)
|
|
|
|
|
"Display documentation of current major mode and minor modes.
|
2004-04-12 10:25:33 +00:00
|
|
|
|
A brief summary of the minor modes comes first, followed by the
|
|
|
|
|
major mode description. This is followed by detailed
|
|
|
|
|
descriptions of the minor modes, each on a separate page.
|
|
|
|
|
|
|
|
|
|
For this to work correctly for a minor mode, the mode's indicator
|
|
|
|
|
variable \(listed in `minor-mode-alist') must also be a function
|
2012-05-15 15:43:06 +00:00
|
|
|
|
whose documentation describes the minor mode.
|
|
|
|
|
|
|
|
|
|
If called from Lisp with a non-nil BUFFER argument, display
|
|
|
|
|
documentation for the major and minor modes of that buffer."
|
2006-10-03 14:03:46 +00:00
|
|
|
|
(interactive "@")
|
2005-03-10 21:43:16 +00:00
|
|
|
|
(unless buffer (setq buffer (current-buffer)))
|
|
|
|
|
(help-setup-xref (list #'describe-mode buffer)
|
2009-10-02 03:48:36 +00:00
|
|
|
|
(called-interactively-p 'interactive))
|
2002-01-12 20:53:27 +00:00
|
|
|
|
;; For the sake of help-do-xref and help-xref-go-back,
|
|
|
|
|
;; don't switch buffers before calling `help-buffer'.
|
2007-11-10 09:53:22 +00:00
|
|
|
|
(with-help-window (help-buffer)
|
2005-03-10 21:43:16 +00:00
|
|
|
|
(with-current-buffer buffer
|
2003-09-30 12:50:44 +00:00
|
|
|
|
(let (minor-modes)
|
2005-03-10 21:43:16 +00:00
|
|
|
|
;; Older packages do not register in minor-mode-list but only in
|
|
|
|
|
;; minor-mode-alist.
|
|
|
|
|
(dolist (x minor-mode-alist)
|
|
|
|
|
(setq x (car x))
|
|
|
|
|
(unless (memq x minor-mode-list)
|
|
|
|
|
(push x minor-mode-list)))
|
2003-09-30 12:50:44 +00:00
|
|
|
|
;; Find enabled minor mode we will want to mention.
|
|
|
|
|
(dolist (mode minor-mode-list)
|
|
|
|
|
;; Document a minor mode if it is listed in minor-mode-alist,
|
|
|
|
|
;; non-nil, and has a function definition.
|
2005-03-16 13:08:15 +00:00
|
|
|
|
(let ((fmode (or (get mode :minor-mode-function) mode)))
|
|
|
|
|
(and (boundp mode) (symbol-value mode)
|
|
|
|
|
(fboundp fmode)
|
|
|
|
|
(let ((pretty-minor-mode
|
|
|
|
|
(if (string-match "\\(\\(-minor\\)?-mode\\)?\\'"
|
|
|
|
|
(symbol-name fmode))
|
|
|
|
|
(capitalize
|
|
|
|
|
(substring (symbol-name fmode)
|
|
|
|
|
0 (match-beginning 0)))
|
|
|
|
|
fmode)))
|
|
|
|
|
(push (list fmode pretty-minor-mode
|
|
|
|
|
(format-mode-line (assq mode minor-mode-alist)))
|
|
|
|
|
minor-modes)))))
|
2003-09-30 12:50:44 +00:00
|
|
|
|
(setq minor-modes
|
|
|
|
|
(sort minor-modes
|
2005-03-16 13:08:15 +00:00
|
|
|
|
(lambda (a b) (string-lessp (cadr a) (cadr b)))))
|
2003-09-30 12:50:44 +00:00
|
|
|
|
(when minor-modes
|
2006-08-06 04:31:58 +00:00
|
|
|
|
(princ "Enabled minor modes:\n")
|
2004-10-13 19:01:01 +00:00
|
|
|
|
(make-local-variable 'help-button-cache)
|
|
|
|
|
(with-current-buffer standard-output
|
|
|
|
|
(dolist (mode minor-modes)
|
2005-03-16 13:08:15 +00:00
|
|
|
|
(let ((mode-function (nth 0 mode))
|
|
|
|
|
(pretty-minor-mode (nth 1 mode))
|
2004-10-13 19:01:01 +00:00
|
|
|
|
(indicator (nth 2 mode)))
|
|
|
|
|
(add-text-properties 0 (length pretty-minor-mode)
|
|
|
|
|
'(face bold) pretty-minor-mode)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char (point-max))
|
|
|
|
|
(princ "\n\f\n")
|
|
|
|
|
(push (point-marker) help-button-cache)
|
|
|
|
|
;; Document the minor modes fully.
|
|
|
|
|
(insert pretty-minor-mode)
|
2006-08-06 04:31:58 +00:00
|
|
|
|
(princ (format " minor mode (%s):\n"
|
|
|
|
|
(if (zerop (length indicator))
|
|
|
|
|
"no indicator"
|
|
|
|
|
(format "indicator%s"
|
2006-08-08 20:53:10 +00:00
|
|
|
|
indicator))))
|
2004-10-13 19:01:01 +00:00
|
|
|
|
(princ (documentation mode-function)))
|
|
|
|
|
(insert-button pretty-minor-mode
|
|
|
|
|
'action (car help-button-cache)
|
2004-12-17 15:16:46 +00:00
|
|
|
|
'follow-link t
|
2004-10-13 19:01:01 +00:00
|
|
|
|
'help-echo "mouse-2, RET: show full information")
|
2006-08-06 04:31:58 +00:00
|
|
|
|
(newline)))
|
|
|
|
|
(forward-line -1)
|
|
|
|
|
(fill-paragraph nil)
|
|
|
|
|
(forward-line 1))
|
|
|
|
|
|
|
|
|
|
(princ "\n(Information about these minor modes follows the major mode info.)\n\n"))
|
2003-09-30 12:50:44 +00:00
|
|
|
|
;; Document the major mode.
|
2004-10-13 19:01:01 +00:00
|
|
|
|
(let ((mode mode-name))
|
|
|
|
|
(with-current-buffer standard-output
|
2006-02-23 16:39:24 +00:00
|
|
|
|
(let ((start (point)))
|
2008-01-16 15:55:15 +00:00
|
|
|
|
(insert (format-mode-line mode nil nil buffer))
|
2006-02-23 16:39:24 +00:00
|
|
|
|
(add-text-properties start (point) '(face bold)))))
|
2011-03-13 01:57:40 +00:00
|
|
|
|
(princ " mode")
|
|
|
|
|
(let* ((mode major-mode)
|
|
|
|
|
(file-name (find-lisp-object-file-name mode nil)))
|
|
|
|
|
(when file-name
|
|
|
|
|
(princ (concat " defined in `" (file-name-nondirectory file-name) "'"))
|
|
|
|
|
;; Make a hyperlink to the library.
|
|
|
|
|
(with-current-buffer standard-output
|
|
|
|
|
(save-excursion
|
|
|
|
|
(re-search-backward "`\\([^`']+\\)'" nil t)
|
|
|
|
|
(help-xref-button 1 'help-function-def mode file-name)))))
|
|
|
|
|
(princ ":\n")
|
2010-04-05 10:36:45 +00:00
|
|
|
|
(princ (documentation major-mode)))))
|
2010-04-05 20:05:47 +00:00
|
|
|
|
;; For the sake of IELM and maybe others
|
2010-04-05 10:36:45 +00:00
|
|
|
|
nil)
|
(help-highlight-face): Use underline.
(help-mode-maybe): Ensure read-only.
(help-xref-button): Obey help-highlight-p.
(help-follow): Remove check for args being a list.
(help-mode): Doc fix.
(help-highlight-p): Put in help group.
(help-make-xrefs): Insert button label in scope of
inhibit-read-only binding.
(help-mode-map, help-make-xrefs): Define TAB, RET correctly.
Make hyperlinks for cross-reference info intuited from *Help* buffer.
(help-font-lock-keywords): Removed.
(help-mode-map): Define keys for navigating hyperlinks.
(help-xref-stack, help-xref-stack-item): New permanent-local variables.
(help-mode): Set font-lock-defaults to nil.
(help-mode-maybe): Invoke help-make-xrefs in Help mode.
(help-setup-xref): New function.
(describe-key, describe-mode, describe-function,
describe-variable): Call it.
(view-lossage, describe-bindings): Nullify help-xref-stack,
help-xref-stack-item.
(help-highlight-p): New option.
(help-highlight-face): New variable.
(help-back-label, help-xref-symbol-regexp, help-xref-info-regexp):
New variables.
(help-setup-xref, help-make-xrefs, help-xref-button,
help-xref-interned, help-xref-mode, help-follow-mouse,
help-xref-go-back, help-go-back, help-follow, help-next-ref): New functions.
1998-04-05 19:10:02 +00:00
|
|
|
|
|
2003-09-30 12:50:44 +00:00
|
|
|
|
|
2003-03-31 20:22:58 +00:00
|
|
|
|
(defun describe-minor-mode (minor-mode)
|
2003-04-12 17:28:24 +00:00
|
|
|
|
"Display documentation of a minor mode given as MINOR-MODE.
|
|
|
|
|
MINOR-MODE can be a minor mode symbol or a minor mode indicator string
|
|
|
|
|
appeared on the mode-line."
|
2003-11-30 17:50:54 +00:00
|
|
|
|
(interactive (list (completing-read
|
2003-04-12 17:28:24 +00:00
|
|
|
|
"Minor mode: "
|
|
|
|
|
(nconc
|
|
|
|
|
(describe-minor-mode-completion-table-for-symbol)
|
|
|
|
|
(describe-minor-mode-completion-table-for-indicator)
|
|
|
|
|
))))
|
|
|
|
|
(if (symbolp minor-mode)
|
|
|
|
|
(setq minor-mode (symbol-name minor-mode)))
|
|
|
|
|
(let ((symbols (describe-minor-mode-completion-table-for-symbol))
|
|
|
|
|
(indicators (describe-minor-mode-completion-table-for-indicator)))
|
|
|
|
|
(cond
|
|
|
|
|
((member minor-mode symbols)
|
|
|
|
|
(describe-minor-mode-from-symbol (intern minor-mode)))
|
|
|
|
|
((member minor-mode indicators)
|
|
|
|
|
(describe-minor-mode-from-indicator minor-mode))
|
|
|
|
|
(t
|
|
|
|
|
(error "No such minor mode: %s" minor-mode)))))
|
|
|
|
|
|
2003-11-30 17:50:54 +00:00
|
|
|
|
;; symbol
|
2003-04-12 17:28:24 +00:00
|
|
|
|
(defun describe-minor-mode-completion-table-for-symbol ()
|
|
|
|
|
;; In order to list up all minor modes, minor-mode-list
|
|
|
|
|
;; is used here instead of minor-mode-alist.
|
|
|
|
|
(delq nil (mapcar 'symbol-name minor-mode-list)))
|
2011-06-13 13:14:42 +00:00
|
|
|
|
|
2003-04-12 17:28:24 +00:00
|
|
|
|
(defun describe-minor-mode-from-symbol (symbol)
|
|
|
|
|
"Display documentation of a minor mode given as a symbol, SYMBOL"
|
2003-11-30 17:50:54 +00:00
|
|
|
|
(interactive (list (intern (completing-read
|
2003-04-12 17:28:24 +00:00
|
|
|
|
"Minor mode symbol: "
|
|
|
|
|
(describe-minor-mode-completion-table-for-symbol)))))
|
|
|
|
|
(if (fboundp symbol)
|
|
|
|
|
(describe-function symbol)
|
|
|
|
|
(describe-variable symbol)))
|
|
|
|
|
|
|
|
|
|
;; indicator
|
|
|
|
|
(defun describe-minor-mode-completion-table-for-indicator ()
|
2003-11-30 17:50:54 +00:00
|
|
|
|
(delq nil
|
2003-04-12 17:28:24 +00:00
|
|
|
|
(mapcar (lambda (x)
|
|
|
|
|
(let ((i (format-mode-line x)))
|
|
|
|
|
;; remove first space if existed
|
|
|
|
|
(cond
|
|
|
|
|
((= 0 (length i))
|
|
|
|
|
nil)
|
2006-11-27 13:52:27 +00:00
|
|
|
|
((eq (aref i 0) ?\s)
|
2003-04-12 17:28:24 +00:00
|
|
|
|
(substring i 1))
|
2003-11-30 17:50:54 +00:00
|
|
|
|
(t
|
2003-04-12 17:28:24 +00:00
|
|
|
|
i))))
|
|
|
|
|
minor-mode-alist)))
|
2011-06-13 13:14:42 +00:00
|
|
|
|
|
2003-03-31 20:22:58 +00:00
|
|
|
|
(defun describe-minor-mode-from-indicator (indicator)
|
2003-04-12 17:28:24 +00:00
|
|
|
|
"Display documentation of a minor mode specified by INDICATOR.
|
|
|
|
|
If you call this function interactively, you can give indicator which
|
|
|
|
|
is currently activated with completion."
|
2003-11-30 17:50:54 +00:00
|
|
|
|
(interactive (list
|
|
|
|
|
(completing-read
|
2003-03-31 20:22:58 +00:00
|
|
|
|
"Minor mode indicator: "
|
2003-04-12 17:28:24 +00:00
|
|
|
|
(describe-minor-mode-completion-table-for-indicator))))
|
2003-03-31 20:22:58 +00:00
|
|
|
|
(let ((minor-mode (lookup-minor-mode-from-indicator indicator)))
|
|
|
|
|
(if minor-mode
|
2003-04-12 17:28:24 +00:00
|
|
|
|
(describe-minor-mode-from-symbol minor-mode)
|
2003-03-31 20:22:58 +00:00
|
|
|
|
(error "Cannot find minor mode for `%s'" indicator))))
|
|
|
|
|
|
|
|
|
|
(defun lookup-minor-mode-from-indicator (indicator)
|
2012-06-02 10:56:09 +00:00
|
|
|
|
"Return a minor mode symbol from its indicator on the mode line."
|
2003-04-12 17:28:24 +00:00
|
|
|
|
;; remove first space if existed
|
2003-11-30 17:50:54 +00:00
|
|
|
|
(if (and (< 0 (length indicator))
|
2006-11-27 13:52:27 +00:00
|
|
|
|
(eq (aref indicator 0) ?\s))
|
2003-04-12 17:28:24 +00:00
|
|
|
|
(setq indicator (substring indicator 1)))
|
2003-03-31 20:22:58 +00:00
|
|
|
|
(let ((minor-modes minor-mode-alist)
|
|
|
|
|
result)
|
|
|
|
|
(while minor-modes
|
|
|
|
|
(let* ((minor-mode (car (car minor-modes)))
|
2003-11-30 17:50:54 +00:00
|
|
|
|
(anindicator (format-mode-line
|
2003-04-12 17:28:24 +00:00
|
|
|
|
(car (cdr (car minor-modes))))))
|
|
|
|
|
;; remove first space if existed
|
2003-11-30 17:50:54 +00:00
|
|
|
|
(if (and (stringp anindicator)
|
2003-04-12 17:28:24 +00:00
|
|
|
|
(> (length anindicator) 0)
|
2006-11-27 13:52:27 +00:00
|
|
|
|
(eq (aref anindicator 0) ?\s))
|
2003-04-12 17:28:24 +00:00
|
|
|
|
(setq anindicator (substring anindicator 1)))
|
|
|
|
|
(if (equal indicator anindicator)
|
2003-03-31 20:22:58 +00:00
|
|
|
|
(setq result minor-mode
|
|
|
|
|
minor-modes nil)
|
|
|
|
|
(setq minor-modes (cdr minor-modes)))))
|
|
|
|
|
result))
|
1998-11-22 17:26:16 +00:00
|
|
|
|
|
|
|
|
|
;;; Automatic resizing of temporary buffers.
|
1998-11-22 17:31:55 +00:00
|
|
|
|
(defcustom temp-buffer-max-height (lambda (buffer) (/ (- (frame-height) 2) 2))
|
2006-02-23 16:39:24 +00:00
|
|
|
|
"Maximum height of a window displaying a temporary buffer.
|
2006-05-30 02:35:56 +00:00
|
|
|
|
This is effective only when Temp Buffer Resize mode is enabled.
|
2011-06-13 13:14:42 +00:00
|
|
|
|
The value is the maximum height (in lines) which
|
|
|
|
|
`resize-temp-buffer-window' will give to a window displaying a
|
|
|
|
|
temporary buffer. It can also be a function to be called to
|
2011-11-25 07:14:48 +00:00
|
|
|
|
choose the height for such a buffer. It gets one argument, the
|
2011-06-13 13:14:42 +00:00
|
|
|
|
buffer, and should return a positive integer. At the time the
|
|
|
|
|
function is called, the window to be resized is selected."
|
1998-11-22 17:26:16 +00:00
|
|
|
|
:type '(choice integer function)
|
|
|
|
|
:group 'help
|
|
|
|
|
:version "20.4")
|
|
|
|
|
|
2000-10-05 22:27:38 +00:00
|
|
|
|
(define-minor-mode temp-buffer-resize-mode
|
Fix minor mode docstrings for the new meaning of a nil ARG.
* abbrev.el (abbrev-mode):
* allout.el (allout-mode):
* autoinsert.el (auto-insert-mode):
* autoarg.el (autoarg-mode, autoarg-kp-mode):
* autorevert.el (auto-revert-mode, auto-revert-tail-mode)
(global-auto-revert-mode):
* battery.el (display-battery-mode):
* composite.el (global-auto-composition-mode)
(auto-composition-mode):
* delsel.el (delete-selection-mode):
* desktop.el (desktop-save-mode):
* dired-x.el (dired-omit-mode):
* dirtrack.el (dirtrack-mode):
* doc-view.el (doc-view-minor-mode):
* double.el (double-mode):
* electric.el (electric-indent-mode, electric-pair-mode):
* emacs-lock.el (emacs-lock-mode):
* epa-hook.el (auto-encryption-mode):
* follow.el (follow-mode):
* font-core.el (font-lock-mode):
* frame.el (auto-raise-mode, auto-lower-mode, blink-cursor-mode):
* help.el (temp-buffer-resize-mode):
* hilit-chg.el (highlight-changes-mode)
(highlight-changes-visible-mode):
* hi-lock.el (hi-lock-mode):
* hl-line.el (hl-line-mode, global-hl-line-mode):
* icomplete.el (icomplete-mode):
* ido.el (ido-everywhere):
* image-file.el (auto-image-file-mode):
* image-mode.el (image-minor-mode):
* iswitchb.el (iswitchb-mode):
* jka-cmpr-hook.el (auto-compression-mode):
* linum.el (linum-mode):
* longlines.el (longlines-mode):
* master.el (master-mode):
* mb-depth.el (minibuffer-depth-indicate-mode):
* menu-bar.el (menu-bar-mode):
* minibuf-eldef.el (minibuffer-electric-default-mode):
* mouse-sel.el (mouse-sel-mode):
* msb.el (msb-mode):
* mwheel.el (mouse-wheel-mode):
* outline.el (outline-minor-mode):
* paren.el (show-paren-mode):
* recentf.el (recentf-mode):
* reveal.el (reveal-mode, global-reveal-mode):
* rfn-eshadow.el (file-name-shadow-mode):
* ruler-mode.el (ruler-mode):
* savehist.el (savehist-mode):
* scroll-all.el (scroll-all-mode):
* scroll-bar.el (scroll-bar-mode):
* server.el (server-mode):
* shell.el (shell-dirtrack-mode):
* simple.el (auto-fill-mode, transient-mark-mode)
(visual-line-mode, overwrite-mode, binary-overwrite-mode)
(line-number-mode, column-number-mode, size-indication-mode)
(auto-save-mode, normal-erase-is-backspace-mode, visible-mode):
* strokes.el (strokes-mode):
* time.el (display-time-mode):
* t-mouse.el (gpm-mouse-mode):
* tool-bar.el (tool-bar-mode):
* tooltip.el (tooltip-mode):
* type-break.el (type-break-mode-line-message-mode)
(type-break-query-mode):
* view.el (view-mode):
* whitespace.el (whitespace-mode, whitespace-newline-mode)
(global-whitespace-mode, global-whitespace-newline-mode):
* xt-mouse.el (xterm-mouse-mode): Doc fix.
* emacs-lisp/easy-mmode.el (define-globalized-minor-mode): Fix
autogenerated docstring.
2011-10-19 12:54:24 +00:00
|
|
|
|
"Toggle auto-shrinking temp buffer windows (Temp Buffer Resize mode).
|
|
|
|
|
With a prefix argument ARG, enable Temp Buffer Resize mode if ARG
|
|
|
|
|
is positive, and disable it otherwise. If called from Lisp,
|
|
|
|
|
enable the mode if ARG is omitted or nil.
|
|
|
|
|
|
|
|
|
|
When Temp Buffer Resize mode is enabled, the windows in which we
|
|
|
|
|
show a temporary buffer are automatically reduced in height to
|
|
|
|
|
fit the buffer's contents, but never more than
|
|
|
|
|
`temp-buffer-max-height' nor less than `window-min-height'.
|
2011-06-13 13:14:42 +00:00
|
|
|
|
|
|
|
|
|
This mode is used by `help', `apropos' and `completion' buffers,
|
|
|
|
|
and some others."
|
2001-10-08 00:19:58 +00:00
|
|
|
|
:global t :group 'help
|
2000-10-05 22:27:38 +00:00
|
|
|
|
(if temp-buffer-resize-mode
|
2001-02-21 02:37:01 +00:00
|
|
|
|
;; `help-make-xrefs' may add a `back' button and thus increase the
|
2000-10-05 22:27:38 +00:00
|
|
|
|
;; text size, so `resize-temp-buffer-window' must be run *after* it.
|
|
|
|
|
(add-hook 'temp-buffer-show-hook 'resize-temp-buffer-window 'append)
|
2000-10-05 22:28:23 +00:00
|
|
|
|
(remove-hook 'temp-buffer-show-hook 'resize-temp-buffer-window)))
|
1998-11-22 17:26:16 +00:00
|
|
|
|
|
|
|
|
|
(defun resize-temp-buffer-window ()
|
2007-08-06 06:51:13 +00:00
|
|
|
|
"Resize the selected window to fit its contents.
|
2011-06-13 13:14:42 +00:00
|
|
|
|
Will not make it higher than `temp-buffer-max-height' nor smaller
|
|
|
|
|
than `window-min-height'. Do nothing if the selected window is
|
|
|
|
|
not vertically combined or some of its contents are scrolled out
|
|
|
|
|
of view."
|
|
|
|
|
(when (and (pos-visible-in-window-p (point-min))
|
2011-10-30 08:29:56 +00:00
|
|
|
|
(window-combined-p))
|
2000-10-21 05:40:19 +00:00
|
|
|
|
(fit-window-to-buffer
|
2011-06-13 13:14:42 +00:00
|
|
|
|
nil
|
2000-10-21 05:40:19 +00:00
|
|
|
|
(if (functionp temp-buffer-max-height)
|
2011-06-13 13:14:42 +00:00
|
|
|
|
(funcall temp-buffer-max-height (window-buffer))
|
2000-10-21 05:40:19 +00:00
|
|
|
|
temp-buffer-max-height))))
|
1998-11-22 17:26:16 +00:00
|
|
|
|
|
2011-06-13 13:14:42 +00:00
|
|
|
|
;;; Help windows.
|
2007-11-10 09:53:22 +00:00
|
|
|
|
(defcustom help-window-select 'other
|
|
|
|
|
"Non-nil means select help window for viewing.
|
|
|
|
|
Choices are:
|
|
|
|
|
never (nil) Select help window only if there is no other window
|
|
|
|
|
on its frame.
|
|
|
|
|
other Select help window unless the selected window is the
|
2011-06-13 13:14:42 +00:00
|
|
|
|
only other window on the help window's frame.
|
2007-11-10 09:53:22 +00:00
|
|
|
|
always (t) Always select the help window.
|
|
|
|
|
|
|
|
|
|
This option has effect if and only if the help window was created
|
|
|
|
|
by `with-help-window'"
|
|
|
|
|
:type '(choice (const :tag "never (nil)" nil)
|
|
|
|
|
(const :tag "other" other)
|
|
|
|
|
(const :tag "always (t)" t))
|
|
|
|
|
:group 'help
|
|
|
|
|
:version "23.1")
|
|
|
|
|
|
2012-06-27 05:47:14 +00:00
|
|
|
|
(defcustom help-enable-auto-load t
|
|
|
|
|
"Whether Help commands can perform autoloading.
|
|
|
|
|
If non-nil, whenever \\[describe-function] is called for an
|
|
|
|
|
autoloaded function whose docstring contains any key substitution
|
|
|
|
|
construct (see `substitute-command-keys'), the library is loaded,
|
|
|
|
|
so that the documentation can show the right key bindings."
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'help
|
|
|
|
|
:version "24.2")
|
|
|
|
|
|
2011-06-13 13:14:42 +00:00
|
|
|
|
(defun help-window-display-message (quit-part window &optional scroll)
|
2007-11-10 09:53:22 +00:00
|
|
|
|
"Display message telling how to quit and scroll help window.
|
|
|
|
|
QUIT-PART is a string telling how to quit the help window WINDOW.
|
2011-06-13 13:14:42 +00:00
|
|
|
|
Optional argument SCROLL non-nil means tell how to scroll WINDOW.
|
|
|
|
|
SCROLL equal `other' means tell how to scroll the \"other\"
|
|
|
|
|
window."
|
2007-11-10 09:53:22 +00:00
|
|
|
|
(let ((scroll-part
|
|
|
|
|
(cond
|
2011-06-13 13:14:42 +00:00
|
|
|
|
;; If we don't have QUIT-PART we probably reuse a window
|
|
|
|
|
;; showing the same buffer so we don't show any message.
|
|
|
|
|
((not quit-part) nil)
|
2007-11-10 09:53:22 +00:00
|
|
|
|
((pos-visible-in-window-p
|
|
|
|
|
(with-current-buffer (window-buffer window)
|
2011-06-13 13:14:42 +00:00
|
|
|
|
(point-max)) window t)
|
|
|
|
|
;; Buffer end is at least partially visible, no need to talk
|
|
|
|
|
;; about scrolling.
|
2007-11-10 09:53:22 +00:00
|
|
|
|
".")
|
2011-06-13 13:14:42 +00:00
|
|
|
|
((eq scroll 'other)
|
|
|
|
|
", \\[scroll-other-window] to scroll help.")
|
|
|
|
|
(scroll ", \\[scroll-up] to scroll help."))))
|
2007-12-06 00:17:56 +00:00
|
|
|
|
(message "%s"
|
2007-11-10 09:53:22 +00:00
|
|
|
|
(substitute-command-keys (concat quit-part scroll-part)))))
|
|
|
|
|
|
2011-09-14 09:17:30 +00:00
|
|
|
|
(defun help-window-setup (help-window)
|
2011-06-13 13:14:42 +00:00
|
|
|
|
"Set up help window for `with-help-window'.
|
2011-09-14 09:17:30 +00:00
|
|
|
|
HELP-WINDOW is the window used for displaying the help buffer."
|
|
|
|
|
(let* ((help-buffer (when (window-live-p help-window)
|
2011-06-13 13:14:42 +00:00
|
|
|
|
(window-buffer help-window)))
|
2011-09-14 09:17:30 +00:00
|
|
|
|
(help-setup (when (window-live-p help-window)
|
2011-09-21 08:20:21 +00:00
|
|
|
|
(car (window-parameter help-window 'quit-restore)))))
|
2011-06-13 13:14:42 +00:00
|
|
|
|
(when help-buffer
|
|
|
|
|
;; Handle `help-window-point-marker'.
|
|
|
|
|
(when (eq (marker-buffer help-window-point-marker) help-buffer)
|
|
|
|
|
(set-window-point help-window help-window-point-marker)
|
|
|
|
|
;; Reset `help-window-point-marker'.
|
|
|
|
|
(set-marker help-window-point-marker nil))
|
2007-11-10 09:53:22 +00:00
|
|
|
|
|
|
|
|
|
(cond
|
2011-06-13 13:14:42 +00:00
|
|
|
|
((or (eq help-window (selected-window))
|
|
|
|
|
(and (or (eq help-window-select t)
|
2011-09-21 08:20:21 +00:00
|
|
|
|
(eq help-setup 'frame)
|
2011-06-13 13:14:42 +00:00
|
|
|
|
(and (eq help-window-select 'other)
|
|
|
|
|
(eq (window-frame help-window) (selected-frame))
|
|
|
|
|
(> (length (window-list nil 'no-mini)) 2)))
|
|
|
|
|
(select-window help-window)))
|
|
|
|
|
;; The help window is or gets selected ...
|
|
|
|
|
(help-window-display-message
|
|
|
|
|
(cond
|
2011-09-21 08:20:21 +00:00
|
|
|
|
((eq help-setup 'window)
|
2011-06-13 13:14:42 +00:00
|
|
|
|
;; ... and is new, ...
|
2011-09-14 09:17:30 +00:00
|
|
|
|
"Type \"q\" to delete help window")
|
2011-09-21 08:20:21 +00:00
|
|
|
|
((eq help-setup 'frame)
|
2011-09-14 09:17:30 +00:00
|
|
|
|
"Type \"q\" to delete help frame")
|
2011-09-21 08:20:21 +00:00
|
|
|
|
((eq help-setup 'other)
|
2011-06-13 13:14:42 +00:00
|
|
|
|
;; ... or displayed some other buffer before.
|
|
|
|
|
"Type \"q\" to restore previous buffer"))
|
|
|
|
|
help-window t))
|
|
|
|
|
((and (eq (window-frame help-window) (selected-frame))
|
|
|
|
|
(= (length (window-list nil 'no-mini)) 2))
|
|
|
|
|
;; There are two windows on the help window's frame and the
|
|
|
|
|
;; other one is the selected one.
|
|
|
|
|
(help-window-display-message
|
|
|
|
|
(cond
|
2011-09-21 08:20:21 +00:00
|
|
|
|
((eq help-setup 'window)
|
2011-06-13 13:14:42 +00:00
|
|
|
|
"Type \\[delete-other-windows] to delete the help window")
|
2011-09-21 08:20:21 +00:00
|
|
|
|
((eq help-setup 'other)
|
2011-09-14 09:17:30 +00:00
|
|
|
|
"Type \"q\" in help window to restore its previous buffer"))
|
2011-06-13 13:14:42 +00:00
|
|
|
|
help-window 'other))
|
2007-11-10 09:53:22 +00:00
|
|
|
|
(t
|
2011-09-14 09:17:30 +00:00
|
|
|
|
;; The help window is not selected ...
|
2011-06-13 13:14:42 +00:00
|
|
|
|
(help-window-display-message
|
2011-09-14 09:17:30 +00:00
|
|
|
|
(cond
|
2011-09-21 08:20:21 +00:00
|
|
|
|
((eq help-setup 'window)
|
2011-09-14 09:17:30 +00:00
|
|
|
|
;; ... and is new, ...
|
|
|
|
|
"Type \"q\" in help window to delete it")
|
2011-09-21 08:20:21 +00:00
|
|
|
|
((eq help-setup 'other)
|
2011-09-14 09:17:30 +00:00
|
|
|
|
;; ... or displayed some other buffer before.
|
|
|
|
|
"Type \"q\" in help window to restore previous buffer"))
|
|
|
|
|
help-window))))))
|
2007-11-10 09:53:22 +00:00
|
|
|
|
|
|
|
|
|
;; `with-help-window' is a wrapper for `with-output-to-temp-buffer'
|
|
|
|
|
;; providing the following additional twists:
|
|
|
|
|
|
|
|
|
|
;; (1) Issue more accurate messages telling how to scroll and quit the
|
|
|
|
|
;; help window.
|
|
|
|
|
|
2011-06-13 13:14:42 +00:00
|
|
|
|
;; (2) An option (customizable via `help-window-select') to select the
|
2007-11-10 09:53:22 +00:00
|
|
|
|
;; help window automatically.
|
|
|
|
|
|
2011-06-13 13:14:42 +00:00
|
|
|
|
;; (3) A marker (`help-window-point-marker') to move point in the help
|
2007-11-10 09:53:22 +00:00
|
|
|
|
;; window to an arbitrary buffer position.
|
|
|
|
|
|
2009-08-19 18:07:07 +00:00
|
|
|
|
;; Note: It's usually always wrong to use `help-print-return-message' in
|
2007-11-10 09:53:22 +00:00
|
|
|
|
;; the body of `with-help-window'.
|
|
|
|
|
(defmacro with-help-window (buffer-name &rest body)
|
2011-06-13 13:14:42 +00:00
|
|
|
|
"Display buffer with name BUFFER-NAME in a help window evaluating BODY.
|
2007-11-10 09:53:22 +00:00
|
|
|
|
Select help window if the actual value of the user option
|
2011-11-01 16:21:41 +00:00
|
|
|
|
`help-window-select' says so. Return last value in BODY."
|
2007-11-10 09:53:22 +00:00
|
|
|
|
(declare (indent 1) (debug t))
|
2011-06-13 13:14:42 +00:00
|
|
|
|
`(progn
|
|
|
|
|
;; Make `help-window-point-marker' point nowhere. The only place
|
|
|
|
|
;; where this should be set to a buffer position is within BODY.
|
2007-11-10 09:53:22 +00:00
|
|
|
|
(set-marker help-window-point-marker nil)
|
2011-09-14 09:17:30 +00:00
|
|
|
|
(let* (help-window
|
|
|
|
|
(temp-buffer-show-hook
|
|
|
|
|
(cons (lambda () (setq help-window (selected-window)))
|
|
|
|
|
temp-buffer-show-hook)))
|
|
|
|
|
;; Return value returned by `with-output-to-temp-buffer'.
|
|
|
|
|
(prog1
|
|
|
|
|
(with-output-to-temp-buffer ,buffer-name
|
|
|
|
|
(progn ,@body))
|
|
|
|
|
(help-window-setup help-window)))))
|
2011-04-08 15:37:15 +00:00
|
|
|
|
|
|
|
|
|
;; Called from C, on encountering `help-char' when reading a char.
|
|
|
|
|
;; Don't print to *Help*; that would clobber Help history.
|
|
|
|
|
(defun help-form-show ()
|
|
|
|
|
"Display the output of a non-nil `help-form'."
|
|
|
|
|
(let ((msg (eval help-form)))
|
|
|
|
|
(if (stringp msg)
|
|
|
|
|
(with-output-to-temp-buffer " *Char Help*"
|
|
|
|
|
(princ msg)))))
|
2007-11-10 09:53:22 +00:00
|
|
|
|
|
2006-02-23 23:14:01 +00:00
|
|
|
|
(provide 'help)
|
|
|
|
|
|
1992-05-30 23:12:08 +00:00
|
|
|
|
;;; help.el ends here
|