"Keymap for help mode.")
(define-key global-map (char-to-string help-char) 'help-command)
+(define-key global-map [help] 'help-command)
+(define-key global-map [f1] 'help-command)
(fset 'help-command help-map)
(define-key help-map (char-to-string help-char) 'help-for-help)
+(define-key help-map [help] 'help-for-help)
+(define-key help-map [f1] 'help-for-help)
(define-key help-map "?" 'help-for-help)
(define-key help-map "\C-c" 'describe-copying)
(define-key help-map "d" 'describe-function)
(define-key help-map "f" 'describe-function)
+(define-key help-map "F" 'view-emacs-FAQ)
+
(define-key help-map "i" 'info)
(define-key help-map "\C-f" 'Info-goto-emacs-command-node)
(define-key help-map "\C-k" 'Info-goto-emacs-key-command-node)
(define-key help-map "q" 'help-quit)
+(defvar help-font-lock-keywords
+ (let ((name-char "[-+a-zA-Z0-9_*]") (sym-char "[-+a-zA-Z0-9_:*]"))
+ (list
+ ;;
+ ;; The symbol itself.
+ (list (concat "\\`\\(" name-char "+\\)\\(:\\)?")
+ '(1 (if (match-beginning 2)
+ font-lock-function-name-face
+ font-lock-variable-name-face)
+ nil t))
+ ;;
+ ;; Words inside `' which tend to be symbol names.
+ (list (concat "`\\(" sym-char sym-char "+\\)'")
+ 1 'font-lock-reference-face t)
+ ;;
+ ;; CLisp `:' keywords as references.
+ (list (concat "\\<:" sym-char "+\\>") 0 'font-lock-reference-face t)))
+ "Default expressions to highlight in Help mode.")
+
(defun help-mode ()
"Major mode for viewing help text.
Entry to this mode runs the normal hook `help-mode-hook'.
(use-local-map help-mode-map)
(setq mode-name "Help")
(setq major-mode 'help-mode)
+ (make-local-variable 'font-lock-defaults)
+ (setq font-lock-defaults '(help-font-lock-keywords))
+ (view-mode)
(run-hooks 'help-mode-hook))
(defun help-quit ()
(substitute-command-keys first-message)
"")
(if first-message " " "")
- (substitute-command-keys
- "\\[scroll-other-window] to scroll the help."))))))
+ ;; If the help buffer will go in a separate frame,
+ ;; it's no use mentioning a command to scroll, so don't.
+ (if (or (member (buffer-name standard-output)
+ special-display-buffer-names)
+ (memq t (mapcar '(lambda (elt)
+ (string-match elt (buffer-name standard-output)))
+ special-display-regexps)))
+ nil
+ (if (or (member (buffer-name standard-output)
+ same-window-buffer-names)
+ (memq t (mapcar '(lambda (elt)
+ (string-match elt (buffer-name standard-output)))
+ same-window-regexps)))
+ ;; Say how to scroll this window.
+ (substitute-command-keys
+ "\\[scroll-up] to scroll the help.")
+ ;; Say how to scroll some other window.
+ (substitute-command-keys
+ "\\[scroll-other-window] to scroll the help."))))))))
(defun describe-key (key)
"Display documentation of the function invoked by KEY. KEY is a string."
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)))
+ (let* ((key (this-command-keys)))
+ (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)))))
;; Make C-h after a prefix, when not specifically bound,
;; run describe-prefix-bindings.
(setq prefix-help-command 'describe-prefix-bindings)
(interactive)
(find-file-read-only (expand-file-name "NEWS" data-directory)))
+(defun view-emacs-FAQ ()
+ "Display the Emacs Frequently Asked Questions (FAQ) file."
+ (interactive)
+ (find-file-read-only (expand-file-name "FAQ" data-directory)))
+
(defun view-lossage ()
"Display last 100 input keystrokes."
(interactive)
(make-help-screen help-for-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, or ? for more help:"
"You have typed \\[help-command], the help character. Type a Help option:
-\(Use \\<help-map>\\[scroll-up] or \\[scroll-down] to scroll through this text.
-Type \\<help-map>\\[help-quit] to exit the Help command.)
+\(Use SPC or DEL to scroll through this text. Type \\<help-map>\\[help-quit] to exit the Help command.)
a command-apropos. Give a substring, and see a list of commands
(functions interactively callable) that contain
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.
+F view-emacs-FAQ. Shows emacs frequently asked questions file.
i info. The info documentation reader.
k describe-key. Type a command key sequence;
it displays the full documentation.
(prin1 function)
(princ ": ")
(let* ((def (symbol-function function))
+ file-name
(beg (if (commandp def) "an interactive " "a ")))
(princ (cond ((or (stringp def)
(vectorp def))
((eq (car-safe def) 'mocklisp)
"a mocklisp function")
((eq (car-safe def) 'autoload)
+ (setq file-name (nth 1 def))
(format "%s autoloaded Lisp %s"
(if (commandp def) "an interactive" "an")
(if (nth 4 def) "macro" "function")
-;;; Including the file name made this line too long.
-;;; (nth 1 def)
))
(t "")))
- (let ((file (describe-function-find-file function)))
- (if file
- (progn
- (princ " in `")
- (princ file)
- (princ ".el'"))))
+ (or file-name
+ (setq file-name (describe-function-find-file function)))
+ (if file-name
+ (progn
+ (princ " in `")
+ ;; We used to add .el to the file name,
+ ;; but that's completely wrong when the user used load-file.
+ (princ file-name)
+ (princ "'")))
(princ ".")
(terpri)
(let ((arglist (cond ((byte-code-function-p def)
v (intern val)))))
(with-output-to-temp-buffer "*Help*"
(prin1 variable)
- (princ "'s value is ")
(if (not (boundp variable))
- (princ "void.")
+ (princ " is void")
+ (princ "'s value is ")
(prin1 (symbol-value variable)))
(terpri)
- (let ((locals (buffer-local-variables))
- is-local)
- (while locals
- (if (or (eq variable (car locals))
- (eq variable (car-safe (car locals))))
- (setq is-local t locals nil))
- (setq locals (cdr locals)))
- (if is-local
- (princ (format "Local in buffer %s\n" (buffer-name)))))
+ (if (local-variable-p variable)
+ (progn
+ (princ (format "Local in buffer %s; " (buffer-name)))
+ (if (not (default-boundp variable))
+ (princ "globally void")
+ (princ "global value is ")
+ (prin1 (default-value variable)))
+ (terpri)))
(terpri)
(princ "Documentation:")
(terpri)
(message "%s is not on any key" definition)))
nil)
-(defun command-apropos (string)
- "Like apropos but lists only symbols that are names of commands
-\(interactively callable functions). Argument REGEXP is a regular expression
-that is matched against command symbol names. Returns list of symbols and
-documentation found."
- (interactive "sCommand apropos (regexp): ")
- (let ((message
- (let ((standard-output (get-buffer-create "*Help*")))
- (print-help-return-message 'identity))))
- (if (apropos string t 'commandp t)
- (and message (message message)))))
-
(defun locate-library (library &optional nosuffix)
"Show the full path name of Emacs library LIBRARY.
This command searches the directories in `load-path' like `M-x load-library'