X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/3a801d0c71755fad1c33585e7ed54d9dc240999c..3d24868836b773b9a698eb1f34e3903462f14843:/lisp/help.el diff --git a/lisp/help.el b/lisp/help.el index 81c1e42608..b832ffb6c7 100644 --- a/lisp/help.el +++ b/lisp/help.el @@ -1,6 +1,6 @@ ;;; 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 @@ -21,15 +21,24 @@ ;; 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: +;; 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 global-map "\C-h" 'help-command) +(define-key global-map (char-to-string help-char) 'help-command) (fset 'help-command help-map) -(define-key help-map "\C-h" 'help-for-help) +(define-key help-map (char-to-string help-char) 'help-for-help) (define-key help-map "?" 'help-for-help) (define-key help-map "\C-c" 'describe-copying) @@ -56,6 +65,9 @@ (define-key help-map "\C-n" 'view-emacs-news) (define-key help-map "n" 'view-emacs-news) +(define-key help-map "p" 'finder-by-keyword) +(autoload 'finder-by-keyword "finder.el") + (define-key help-map "s" 'describe-syntax) (define-key help-map "t" 'help-with-tutorial) @@ -199,57 +211,36 @@ describes the minor mode." (insert "\n"))) (print-help-return-message))) -(defun help-for-help () - "You have typed C-h, the help character. Type a Help option: +(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: " + "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 +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; +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; +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, +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. -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; +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 +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. C-w print information on absence of warranty for GNU Emacs." - (interactive) - (message - "A B C F I K L M N S T V W C-c C-d C-n C-w. Type C-h again for more help: ") - (let ((char (read-char))) - (if (or (= char ?\C-h) (= char ??)) - (save-window-excursion - (switch-to-buffer "*Help*") - (delete-other-windows) - (erase-buffer) - (insert (documentation 'help-for-help)) - (goto-char (point-min)) - (while (memq char '(?\C-h ?? ?\C-v ?\ ?\177 ?\M-v)) - (if (memq char '(?\C-v ?\ )) - (scroll-up)) - (if (memq char '(?\177 ?\M-v)) - (scroll-down)) - (message "A B C F I K L M N S T V W C-c C-d C-n C-w%s: " - (if (pos-visible-in-window-p (point-max)) - "" " or Space to scroll")) - (let ((cursor-in-echo-area t)) - (setq char (read-char)))))) - (let ((defn (cdr (assq (downcase char) (cdr help-map))))) - (if defn (call-interactively defn) (ding))))) - + help-map) ;; Return a function which is called by the list containing point. ;; If that gives no function, return a function whose name is around point. @@ -290,10 +281,12 @@ C-w print information on absence of warranty for GNU Emacs." (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.")) - ((compiled-function-p def) + ((byte-code-function-p def) (concat beg "compiled Lisp function.")) ((symbolp def) (format "alias for `%s'." def)) @@ -304,15 +297,33 @@ C-w print information on absence of warranty for GNU Emacs." ((eq (car-safe def) 'mocklisp) "a mocklisp function.") ((eq (car-safe def) 'autoload) - (format "%sLisp %s to autoload from `%s'." - beg + (format "%s autoloaded Lisp %s." + (if (commandp def) "an interactive" "an") (if (nth 4 def) "macro" "function") - (nth 1 def))) +;;; Including the file name made this line too long. +;;; (nth 1 def) + )) (t ""))) - (terpri)) - (if (documentation function) - (princ (documentation function)) - (princ "not documented")) + (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) + (progn (terpri) + (princ (documentation function))) + (princ "not documented")) + ) (print-help-return-message) ;; Return the text we displayed. (save-excursion (set-buffer standard-output) (buffer-string)))) @@ -365,8 +376,8 @@ documentation found." (let ((message (let ((standard-output (get-buffer-create "*Help*"))) (print-help-return-message 'identity)))) - (apropos string 'commandp) - (and message (message message)))) + (if (apropos string t 'commandp) + (and message (message message))))) (defun locate-library (library &optional nosuffix) "Show the full path name of Emacs library LIBRARY.