;;; help.el --- help commands for Emacs
-;; Copyright (C) 1985, 1986 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1986, 1993 Free Software Foundation, Inc.
;; Maintainer: FSF
;; Keywords: help, internal
;; along with GNU Emacs; see the file COPYING. If not, write to
;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+;;; Commentary:
+
+;; This code implements GNU Emac's on-line help system, the one invoked by
+;;`M-x help-for-help'.
+
;;; Code:
-(require 'help-screen)
+;; Get the macro make-help-screen when this is compiled,
+;; or run interpreted, but not when the compiled code is loaded.
+(eval-when-compile (require 'help-macro))
(defvar help-map (make-sparse-keymap)
"Keymap for characters following the Help key.")
(define-key help-map "n" 'view-emacs-news)
(define-key help-map "p" 'finder-by-keyword)
-(autoload 'finder-by-keyword "finder.el")
+(autoload 'finder-by-keyword "finder")
(define-key help-map "s" 'describe-syntax)
(defun describe-key-briefly (key)
"Print the name of the function KEY invokes. KEY is a string."
(interactive "kDescribe key briefly: ")
+ ;; If this key seq ends with a down event, discard the
+ ;; following click or drag event. Otherwise that would
+ ;; erase the message.
+ (let ((type (aref key (1- (length key)))))
+ (if (listp type) (setq type (car type)))
+ (and (symbolp type)
+ (memq 'down (event-modifiers type))
+ (read-event)))
(let ((defn (key-binding key)))
(if (or (null defn) (integerp defn))
(message "%s is undefined" (key-description key))
(defun describe-key (key)
"Display documentation of the function invoked by KEY. KEY is a string."
(interactive "kDescribe key: ")
+ ;; If this key seq ends with a down event, discard the
+ ;; following click or drag event. Otherwise that would
+ ;; erase the message.
+ (let ((type (aref key (1- (length key)))))
+ (if (listp type) (setq type (car type)))
+ (and (symbolp type)
+ (memq 'down (event-modifiers type))
+ (read-event)))
(let ((defn (key-binding key)))
(if (or (null defn) (integerp defn))
(message "%s is undefined" (key-description key))
If optional MINOR is non-nil (or prefix argument is given if interactive),
display documentation of active minor modes as well.
For this to work correctly for a minor mode, the mode's indicator variable
-(listed in `minor-mode-alist') must also be a function whose documentation
+\(listed in `minor-mode-alist') must also be a function whose documentation
describes the minor mode."
(interactive)
(with-output-to-temp-buffer "*Help*"
(search-forward "NO WARRANTY")
(recenter 0)))
+(defun describe-prefix-bindings ()
+ "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."
+ (interactive)
+ (let* ((key (this-command-keys))
+ (prefix (make-vector (1- (length key)) nil))
+ i)
+ (setq i 0)
+ (while (< i (length prefix))
+ (aset prefix i (aref key i))
+ (setq i (1+ i)))
+ (describe-bindings prefix)))
+;; Make C-h after a prefix, when not specifically bound,
+;; run describe-prefix-bindings.
+(setq prefix-help-command 'describe-prefix-bindings)
+
(defun view-emacs-news ()
"Display info on recent changes to Emacs."
(interactive)
(print-help-return-message)))
(make-help-screen help-for-help
- "A B C F I K L M N P S T V W C-c C-d C-n C-w. Type \\[help-for-help] again for more help: "
+ "a b c f C-f i k C-k l m n p s t v w C-c C-d C-n C-w. Type \\[help-for-help] again for more help: "
"You have typed \\[help-for-help], the help character. Type a Help option:
-A command-apropos. Give a substring, and see a list of commands
- (functions interactively callable) that contain
- that substring. See also the apropos command.
-B describe-bindings. Display table of all key bindings.
-C describe-key-briefly. Type a command key sequence;
- it prints the function name that sequence runs.
-F describe-function. Type a function name and get documentation of it.
-I info. The info documentation reader.
-K describe-key. Type a command key sequence;
- it displays the full documentation.
-L view-lossage. Shows last 100 characters you typed.
-M describe-mode. Print documentation of current major mode,
- which describes the commands peculiar to it.
-N view-emacs-news. Shows emacs news file.
-P finder-by-keyword. Find packages matching a given topic keyword.
-S describe-syntax. Display contents of syntax table, plus explanations
-T help-with-tutorial. Select the Emacs learn-by-doing tutorial.
-V describe-variable. Type name of a variable;
- it displays the variable's documentation and value.
-W where-is. Type command name; it prints which keystrokes
- invoke that command.
+a command-apropos. Give a substring, and see a list of commands
+ (functions interactively callable) that contain
+ that substring. See also the apropos command.
+b describe-bindings. Display table of all key bindings.
+c describe-key-briefly. Type a command key sequence;
+ it prints the function name that sequence runs.
+f describe-function. Type a function name and get documentation of it.
+C-f Info-goto-emacs-command-node. Type a function name;
+ it takes you to the Info node for that command.
+i info. The info documentation reader.
+k describe-key. Type a command key sequence;
+ it displays the full documentation.
+C-k Info-goto-emacs-key-command-node. Type a command key sequence;
+ it takes you to the Info node for the command bound to that key.
+l view-lossage. Shows last 100 characters you typed.
+m describe-mode. Print documentation of current major mode,
+ which describes the commands peculiar to it.
+n view-emacs-news. Shows emacs news file.
+p finder-by-keyword. Find packages matching a given topic keyword.
+s describe-syntax. Display contents of syntax table, plus explanations
+t help-with-tutorial. Select the Emacs learn-by-doing tutorial.
+v describe-variable. Type name of a variable;
+ it displays the variable's documentation and value.
+w where-is. Type command name; it prints which keystrokes
+ invoke that command.
C-c print Emacs copying permission (General Public License).
C-d print Emacs ordering information.
C-n print news of recent Emacs changes.
(princ ": ")
(let* ((def (symbol-function function))
(beg (if (commandp def) "an interactive " "a ")))
- (princ (cond ((stringp def) "a keyboard macro.")
+ (princ (cond ((or (stringp def)
+ (vectorp def))
+ "a keyboard macro.")
((subrp def)
(concat beg "built-in function."))
((byte-code-function-p def)
))
(t "")))
(terpri)
+ (let ((arglist (cond ((byte-code-function-p def)
+ (car (append def nil)))
+ ((eq (car-safe def) 'lambda)
+ (nth 1 def))
+ (t t))))
+ (if (listp arglist)
+ (progn
+ (princ (cons function
+ (mapcar (lambda (arg)
+ (if (memq arg '(&optional &rest))
+ arg
+ (intern (upcase (symbol-name arg)))))
+ arglist)))
+ (terpri))))
(if (documentation function)
- (princ (documentation function))
+ (progn (terpri)
+ (princ (documentation function)))
(princ "not documented"))
- (cond ((byte-code-function-p def)
- (save-excursion
- (set-buffer standard-output)
- (or (eq (char-after (1- (point-max))) ?\n)
- (terpri)))
- (terpri)
- (princ (car (append def nil))))
- ((eq (car-safe def) 'lambda)
- (save-excursion
- (set-buffer standard-output)
- (or (eq (char-after (1- (point-max))) ?\n)
- (terpri)))
- (terpri)
- (princ (nth 1 def)))))
+ )
(print-help-return-message)
;; Return the text we displayed.
(save-excursion (set-buffer standard-output) (buffer-string))))