@kindex C-h
@kindex F1
-@kindex C-h C-h
-@findex help-for-help
- Emacs provides a wide variety of help commands, all accessible
-through the prefix key @kbd{C-h} (or, equivalently, the function key
-@key{F1}). These help commands are described in the following
-sections. You can also type @kbd{C-h C-h} to view a list of help
-commands (@code{help-for-help}). You can scroll the list with
-@key{SPC} and @key{DEL}, then type the help command you want. To
-cancel, type @kbd{C-g}.
-
@cindex help buffer
Many help commands display their information in a special @dfn{help
buffer}. In this buffer, you can type @key{SPC} and @key{DEL} to
@code{help-buffer}, @code{with-help-window}, and
@code{help-setup-xref}.
-@defmac make-help-screen fname help-line help-text help-map
-This macro defines a help command named @var{fname} that acts like a
-prefix key that shows a list of the subcommands it offers.
-
-When invoked, @var{fname} displays @var{help-text} in a window, then
-reads and executes a key sequence according to @var{help-map}. The
-string @var{help-text} should describe the bindings available in
-@var{help-map}.
-
-The command @var{fname} is defined to handle a few events itself, by
-scrolling the display of @var{help-text}. When @var{fname} reads one of
-those special events, it does the scrolling and then reads another
-event. When it reads an event that is not one of those few, and which
-has a binding in @var{help-map}, it executes that key's binding and
-then returns.
-
-The argument @var{help-line} should be a single-line summary of the
-alternatives in @var{help-map}. In the current version of Emacs, this
-argument is used only if you set the option @code{three-step-help} to
-@code{t}.
-
-This macro is used in the command @code{help-for-help} which is the
-binding of @kbd{C-h C-h}.
-@end defmac
-
-@defopt three-step-help
-If this variable is non-@code{nil}, commands defined with
-@code{make-help-screen} display their @var{help-line} strings in the
-echo area at first, and display the longer @var{help-text} strings only
-if the user types the help character again.
-@end defopt
-
-
@node Documentation Groups
@section Documentation Groups
@cindex documentation groups
@kbd{M-x help-with-tutorial-spec-language @key{RET}} to choose your
language and start the tutorial.
-Your system administrator may have changed @kbd{C-h} to act like
-@key{DEL} to deal with local keyboards. You can use @kbd{M-x
-help-for-help} instead to invoke help. To discover what key (if any)
-invokes help on your system, type @kbd{M-x where-is @key{RET}
-help-for-help @key{RET}}. This will print a comma-separated list of key
-sequences in the echo area. Ignore the last character in each key
-sequence listed. Each of the resulting key sequences (e.g., @key{F1} is
-common) invokes help.
-
Emacs help works best if it is invoked by a single key whose value
should be stored in the variable @code{help-char}.
The following files (and others) are available in the @file{etc}
directory of the Emacs distribution (@pxref{File-name conventions}, if
you're not sure where that is). Many of these files are available via
-the Emacs @samp{Help} menu, or by typing @kbd{C-h ?} (@kbd{M-x
-help-for-help}).
+the Emacs @samp{Help} menu.
@table @file
(interactive)
(electric-helpify 'view-lossage))
-;(defun electric-help-for-help ()
-; "See help-for-help"
-; (interactive)
-; )
-
(defun electric-describe-function ()
(interactive)
(electric-helpify 'describe-function))
;; GOLD bindings for a few keys.
(edt-bind-gold-key-default "\C-g" 'keyboard-quit); Just in case.
- (edt-bind-gold-key-default "\C-h" 'help-for-help); Just in case.
- (edt-bind-gold-key-default [f1] 'help-for-help)
- (edt-bind-gold-key-default [help] 'help-for-help)
(edt-bind-gold-key-default "\C-\\" 'split-window-below)
;; GOLD bindings for regular keys.
+++ /dev/null
-;;; help-macro.el --- makes command line help such as help-for-help -*- lexical-binding: t -*-
-
-;; Copyright (C) 1993-1994, 2001-2024 Free Software Foundation, Inc.
-
-;; Author: Lynn Slater <lrs@indetech.com>
-;; Maintainer: emacs-devel@gnu.org
-;; Created: Mon Oct 1 11:42:39 1990
-;; Adapted-By: ESR
-;; Package: emacs
-
-;; This file is part of GNU Emacs.
-
-;; GNU Emacs is free software: you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; 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
-;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
-
-;;; Commentary:
-
-;; This file supplies the macro `make-help-screen' which constructs
-;; single character dispatching with browsable help such as that
-;; provided by `help-for-help'. This can be used to make many modes
-;; easier to use; for example, the (long-since defunct) GNU Emacs
-;; Empire Tool used this for every "nested" mode map called from the
-;; main mode map.
-
-;; The name of this package was changed from help-screen.el to
-;; help-macro.el in order to fit in a 14-character limit.
-
-;;-> *********************** Example of use *********************************
-
-;;->(make-help-screen help-for-empire-redistribute-map
-;;-> "c:civ m:mil p:population f:food ?"
-;;-> "You have discovered the GEET redistribution commands
-;;-> From here, you can use the following options:
-;;->
-;;->c Redistribute civs from overfull sectors into connected underfull ones
-;;-> The functions typically named by empire-ideal-civ-fcn control
-;;-> based in part on empire-sector-civ-threshold
-;;->m Redistribute military using levels given by empire-ideal-mil-fcn
-;;->p Redistribute excess population to highways for max pop growth
-;;-> Excess is any sector so full babies will not be born.
-;;->f Even out food on highways to highway min and leave levels
-;;-> This is good to pump max food to all warehouses/dist pts
-;;->
-;;->
-;;->Use \\[help-for-empire-redistribute-map] for help on redistribution.
-;;->Use \\[help-for-empire-extract-map] for help on data extraction.
-;;->Please use \\[describe-key] to find out more about any of the other keys."
-;;-> empire-shell-redistribute-map)
-
-;;-> (define-key c-mp "\C-h" 'help-for-empire-redistribute-map)
-;;-> (define-key c-mp help-character 'help-for-empire-redistribute-map)
-
-;;; Code:
-
-(require 'backquote)
-
-;; This needs to be autoloaded because it is used in the
-;; make-help-screen macro. Using (bound-and-true-p three-step-help)
-;; is not an acceptable alternative, because nothing loads help-macro
-;; in a normal session, so any user customization would never be applied.
-;;;###autoload
-(defcustom three-step-help nil
- "Non-nil means give more info about Help command in three steps.
-The three steps are simple prompt, prompt with all options, and
-window listing and describing the options.
-A value of nil means skip the middle step, so that \\[help-command] \\[help-command]
-gives the window that lists the options."
- :type 'boolean
- :group 'help)
-
-(defmacro make-help-screen (fname help-line help-text helped-map
- &optional buffer-name)
- "Construct help-menu function name FNAME.
-When invoked, FNAME shows HELP-LINE and reads a command using HELPED-MAP.
-If the command is the help character, FNAME displays HELP-TEXT
-and continues trying to read a command using HELPED-MAP.
-If HELP-TEXT contains the sequence `%THIS-KEY%', that is replaced
-with the key sequence that invoked FNAME.
-When FNAME finally does get a command, it executes that command
-and then returns."
- (declare (indent defun))
- `(defun ,fname ()
- "Help command."
- (interactive)
- (help--help-screen ,help-line ,help-text ,helped-map ,buffer-name)))
-
-
-;;;###autoload
-(defun help--help-screen (help-line help-text helped-map buffer-name)
- (let ((line-prompt
- (substitute-command-keys help-line))
- (help-buffer-under-preparation t))
- (when three-step-help
- (message "%s" line-prompt))
- (let* ((help-screen help-text)
- ;; We bind overriding-local-map for very small
- ;; sections, *excluding* where we switch buffers
- ;; and where we execute the chosen help command.
- (local-map (make-sparse-keymap))
- (new-minor-mode-map-alist minor-mode-map-alist)
- (prev-frame (selected-frame))
- config new-frame key char)
- (when (string-match "%THIS-KEY%" help-screen)
- (setq help-screen
- (replace-match (help--key-description-fontified
- (substring (this-command-keys) 0 -1))
- t t help-screen)))
- (unwind-protect
- (let ((minor-mode-map-alist nil))
- (setcdr local-map helped-map)
- (define-key local-map [t] #'undefined)
- ;; Make the scroll bar keep working normally.
- (define-key local-map [vertical-scroll-bar]
- (lookup-key global-map [vertical-scroll-bar]))
- (if three-step-help
- (progn
- (setq key (let ((overriding-local-map local-map))
- (read-key-sequence nil)))
- ;; Make the HELP key translate to C-h.
- (if (lookup-key function-key-map key)
- (setq key (lookup-key function-key-map key)))
- (setq char (aref key 0)))
- (setq char ??))
- (when (or (eq char ??) (eq char help-char)
- (memq char help-event-list))
- (setq config (current-window-configuration))
- (pop-to-buffer (or buffer-name " *Metahelp*") nil t)
- (and (fboundp 'make-frame)
- (not (eq (window-frame)
- prev-frame))
- (setq new-frame (window-frame)
- config nil))
- (setq buffer-read-only nil)
- (let ((inhibit-read-only t))
- (erase-buffer)
- (insert (substitute-command-keys help-screen)))
- (let ((minor-mode-map-alist new-minor-mode-map-alist))
- (help-mode)
- (variable-pitch-mode)
- (setq new-minor-mode-map-alist minor-mode-map-alist))
- (goto-char (point-min))
- (while (or (memq char (append help-event-list
- (cons help-char '( ?? ?\C-v ?\s ?\177 ?\M-v ?\S-\s
- deletechar backspace vertical-scroll-bar
- home end next prior up down))))
- (eq (car-safe char) 'switch-frame)
- (equal key "\M-v"))
- (condition-case nil
- (cond
- ((eq (car-safe char) 'switch-frame)
- (handle-switch-frame char))
- ((memq char '(?\C-v ?\s next end))
- (scroll-up))
- ((or (memq char '(?\177 ?\M-v ?\S-\s deletechar backspace prior home))
- (equal key "\M-v"))
- (scroll-down))
- ((memq char '(down))
- (scroll-up 1))
- ((memq char '(up))
- (scroll-down 1)))
- (error nil))
- (let ((cursor-in-echo-area t)
- (overriding-local-map local-map))
- (frame-toggle-on-screen-keyboard (selected-frame) nil)
- (setq key (read-key-sequence
- (format "Type one of listed options%s: "
- (if (pos-visible-in-window-p
- (point-max))
- ""
- (concat ", or "
- (help--key-description-fontified (kbd "<PageDown>"))
- "/"
- (help--key-description-fontified (kbd "<PageUp>"))
- "/"
- (help--key-description-fontified (kbd "SPC"))
- "/"
- (help--key-description-fontified (kbd "DEL"))
- " to scroll")))
- nil nil nil nil
- ;; Disable ``text conversion''. OS
- ;; input methods might otherwise chose
- ;; to insert user input directly into
- ;; a buffer.
- t)
- char (aref key 0)))
-
- ;; If this is a scroll bar command, just run it.
- (when (eq char 'vertical-scroll-bar)
- (command-execute (lookup-key local-map key) nil key))))
- ;; We don't need the prompt any more.
- (message "")
- ;; Mouse clicks are not part of the help feature,
- ;; so reexecute them in the standard environment.
- (if (listp char)
- (setq unread-command-events
- (cons char unread-command-events)
- config nil)
- (let ((defn (lookup-key local-map key)))
- (if defn
- (progn
- (when config
- (set-window-configuration config)
- (setq config nil))
- ;; Temporarily rebind `minor-mode-map-alist'
- ;; to `new-minor-mode-map-alist' (Bug#10454).
- (let ((minor-mode-map-alist new-minor-mode-map-alist))
- ;; `defn' must make sure that its frame is
- ;; selected, so we won't iconify it below.
- (call-interactively defn))
- (when new-frame
- ;; Do not iconify the selected frame.
- (unless (eq new-frame (selected-frame))
- (iconify-frame new-frame))
- (setq new-frame nil)))
- (unless (equal (key-description key) "C-g")
- (message (substitute-command-keys
- (format "No help command is bound to `\\`%s''"
- (key-description key))))
- (ding))))))
- (when config
- (set-window-configuration config))
- (when new-frame
- (iconify-frame new-frame))
- (setq minor-mode-map-alist new-minor-mode-map-alist)))))
-
-(provide 'help-macro)
-
-;;; help-macro.el ends here
;;; Commentary:
-;; This code implements GNU Emacs's built-in help system, the one invoked by
-;; `M-x help-for-help'.
+;; This code implements GNU Emacs's built-in help system.
;;; 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))
-
;; 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)
(defvar-keymap help-map
:doc "Keymap for characters following the Help key."
- (help-key) #'help-for-help
- "<help>" #'help-for-help
- "<f1>" #'help-for-help
"." #'display-local-help
- "?" #'help-for-help
"C-a" #'about-emacs
"C-c" #'describe-copying
"C-o" #'describe-distribution
"C-p" #'view-emacs-problems
"C-q" #'help-quick-toggle
- "C-s" #'search-forward-help-for-help
"C-t" #'view-emacs-todo
"C-w" #'describe-no-warranty
"C-l" #'describe-library
;; So keyboard macro definitions are documented correctly
(fset 'defining-kbd-macro (symbol-function 'start-kbd-macro))
-\f
-;;; Help for help. (a.k.a. `C-h C-h')
-
-(defvar help-for-help-buffer-name " *Metahelp*"
- "Name of the `help-for-help' buffer.")
-
-(defface help-for-help-header '((t :height 1.26))
- "Face used for headers in the `help-for-help' buffer."
- :group 'help)
-
-(defun help--for-help-make-commands (commands)
- "Create commands for `help-for-help' screen from COMMANDS."
- (mapconcat
- (lambda (cmd)
- (if (listp cmd)
- (let ((name (car cmd)) (desc (cadr cmd)))
- (concat
- " "
- (if (string-match (rx string-start "C-" word string-end) name)
- ;; `help--key-description-fontified' would convert "C-m" to
- ;; "RET" so we can't use it here.
- (propertize name 'face 'help-key-binding)
- (concat "\\[" name "]"))
- " " ; ensure we have some whitespace before the description
- (propertize "\t" 'display '(space :align-to 8))
- desc))
- ""))
- commands "\n"))
-
-(defun help--for-help-make-sections (sections)
- "Create sections for `help-for-help' screen from SECTIONS."
- (mapconcat
- (lambda (section)
- (let ((title (car section)) (commands (cdr section)))
- (concat
- "\n\n"
- (propertize title 'face 'help-for-help-header)
- "\n\n"
- (help--for-help-make-commands commands))))
- sections))
-
-(defalias 'help #'help-for-help)
-(make-help-screen help-for-help
- (purecopy "Type a help option: [abcCdefFgiIkKlLmnprstvw.] C-[cdefmnoptw] or ?")
- (concat
- "(Type "
- (help--key-description-fontified (kbd "<PageDown>"))
- " or "
- (help--key-description-fontified (kbd "<PageUp>"))
- " to scroll, "
- (help--key-description-fontified "\C-s")
- " to search, or \\<help-map>\\[help-quit] to exit.)"
- (help--for-help-make-sections
- `(("Commands, Keys and Functions"
- ("describe-mode"
- "Show help for current major and minor modes and their commands")
- ("describe-bindings" "Show all key bindings")
- ("describe-key" "Show help for key")
- ("describe-key-briefly" "Show help for key briefly")
- ("where-is" "Show which key runs a specific command")
- ""
- ("apropos-command"
- "Search for commands (see also \\[apropos])")
- ("apropos-documentation"
- "Search documentation of functions, variables, and other items")
- ("describe-command" "Show help for command")
- ("describe-function" "Show help for function")
- ("describe-variable" "Show help for variable")
- ("describe-symbol" "Show help for function or variable"))
- ("Manuals"
- ("info-emacs-manual" "Show Emacs manual")
- ("Info-goto-emacs-command-node"
- "Show Emacs manual section for command")
- ("Info-goto-emacs-key-command-node"
- "Show Emacs manual section for a key sequence")
- ("info" "Show all installed manuals")
- ("info-display-manual" "Show a specific manual")
- ("info-lookup-symbol" "Show description of symbol in pertinent manual"))
- ("Other Help Commands"
- ("view-external-packages"
- "Extending Emacs with external packages")
- ("finder-by-keyword"
- "Search for Emacs packages (see also \\[list-packages])")
- ("describe-package" "Describe a specific Emacs package")
- ""
- ("help-with-tutorial" "Start the Emacs tutorial")
- ("help-quick-toggle" "Display the quick help buffer.")
- ("view-echo-area-messages"
- "Show recent messages (from echo area)")
- ("view-lossage" ,(format "Show last %d input keystrokes (lossage)"
- (lossage-size)))
- ("display-local-help" "Show local help at point"))
- ("Miscellaneous"
- ("about-emacs" "About Emacs")
- ("view-emacs-FAQ" "Emacs FAQ")
- ("C-n" "News of recent changes")
- ("view-emacs-problems" "Known problems")
- ("view-emacs-debugging" "Debugging Emacs")
- ""
- ("describe-gnu-project" "About the GNU project")
- ("describe-copying"
- "Emacs copying permission (GNU General Public License)")
- ("describe-distribution"
- "Emacs ordering and distribution information")
- ("C-m" "Order printed manuals")
- ("view-emacs-todo" "Emacs TODO")
- ("describe-no-warranty"
- "Information on absence of warranty"))
- ("Internationalization and Coding Systems"
- ("describe-input-method" "Describe input method")
- ("describe-coding-system" "Describe coding system")
- ("describe-language-environment"
- "Describe language environment")
- ("describe-syntax" "Show current syntax table")
- ("view-hello-file"
- "Display the HELLO file illustrating various scripts"))))
- "\n")
- help-map
- help-for-help-buffer-name)
-
\f
(defun function-called-at-point ()
(insert ", which is ")
(describe-function-1 defn)))))))
\f
-(defun search-forward-help-for-help ()
- "Search forward in the help-for-help window.
-This command is meant to be used after issuing the \\[help-for-help] command."
- (interactive)
- (unless (get-buffer help-for-help-buffer-name)
- (error (substitute-command-keys "No %s buffer; use \\[help-for-help] first")
- help-for-help-buffer-name))
- ;; Move cursor to the "help window".
- (pop-to-buffer help-for-help-buffer-name)
- ;; Do incremental search forward.
- (isearch-forward nil t))
(defun describe-minor-mode (minor-mode)
"Display documentation of a minor mode given as MINOR-MODE.
(setq command-error-function
#'help-command-error-confusable-suggestions))
-(define-obsolete-function-alias 'help-for-help-internal #'help-for-help "28.1")
(define-obsolete-function-alias 'describe-map-tree #'help--describe-map-tree "30.1")
\f
(dolist (elt input-method-alist)
(when (not (equal language (nth 1 elt)))
(setq language (nth 1 elt))
- (insert "\n" (propertize language 'face 'help-for-help-header) "\n\n"))
+ (insert "\n" language "\n\n"))
(insert (format-message
" %s (`%s' in mode line)\n %s\n"
(car elt)
(defvar isearch-help-map
(let ((map (make-sparse-keymap)))
- (define-key map (char-to-string help-char) 'isearch-help-for-help)
- (define-key map [help] 'isearch-help-for-help)
- (define-key map [f1] 'isearch-help-for-help)
- (define-key map "?" 'isearch-help-for-help)
(define-key map "b" 'isearch-describe-bindings)
(define-key map "k" 'isearch-describe-key)
(define-key map "m" 'isearch-describe-mode)
map)
"Keymap for characters following the Help key for Isearch mode.")
-(eval-when-compile (require 'help-macro))
-
-(make-help-screen isearch-help-for-help-internal
- (purecopy "Type a help option: [bkm] or ?")
- "You have typed %THIS-KEY%, the help character. Type a Help option:
-\(Type \\<isearch-help-map>\\[help-quit] to exit the Help command.)
-
- \\[isearch-describe-bindings] Display all Isearch key bindings.
- \\[isearch-describe-key] Display full documentation of Isearch key sequence.
- \\[isearch-describe-mode] Display documentation of Isearch mode.
-
-You can't type here other help keys available in the global help map,
-but outside of this help window when you type them in Isearch mode,
-they exit Isearch mode before displaying global help."
- isearch-help-map)
-
(defvar isearch--display-help-action '(nil (inhibit-same-window . t)))
-(defun isearch-help-for-help ()
- "Display Isearch help menu."
- (interactive)
- (let ((display-buffer-overriding-action isearch--display-help-action))
- (isearch-help-for-help-internal))
- (isearch-update))
-
(defun isearch-describe-bindings ()
"Show a list of all keys defined in Isearch mode, and their definitions.
This is like `describe-bindings', but displays only Isearch keys."
;; (define-key map [f20] nil) ; F20
(define-key map [kp-f1] #'keyboard-quit) ; PF1
- (define-key map [kp-f2] #'help-for-help) ; PF2
(define-key map [kp-f3] #'tpu-search) ; PF3
(define-key map [kp-f4] #'tpu-undelete-lines) ; PF4
(define-key map [kp-0] #'open-line) ; KP0
(set-buffer "Directions")
(tpu-map-key "PF1" " - The GOLD key" "tpu-gold-map" "'keyboard-quit")
- (tpu-map-key "PF2" " - The Keypad Help key" "'tpu-help" "'help-for-help")
(tpu-map-key "PF3" " - The Find/Find-Next key" "'tpu-search-again" "'tpu-search")
(tpu-map-key "PF4" " - The Del/Undelete Line key" "'tpu-delete-current-line" "'tpu-undelete-lines")
(define-key map "\C-g" #'delete-char)
(define-key map "\C-h" #'backward-char)
(define-key map "\C-i" #'indent-for-tab-command)
- (define-key map "\C-j" #'help-for-help)
(define-key map "\C-k" wordstar-C-k-map)
(define-key map "\C-l" #'ws-repeat-search)
(define-key map "\C-n" #'open-line)