home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 5 / FreshFish_July-August1994.bin / bbs / util / jade-3.0.lha / Jade / lisp / help.jl < prev    next >
Encoding:
Text File  |  1994-04-16  |  3.3 KB  |  110 lines

  1. ;;;; help.jl -- Online help system
  2. ;;;  Copyright (C) 1993, 1994 John Harper <jsh@ukc.ac.uk>
  3.  
  4. ;;; This file is part of Jade.
  5.  
  6. ;;; Jade is free software; you can redistribute it and/or modify it
  7. ;;; under the terms of the GNU General Public License as published by
  8. ;;; the Free Software Foundation; either version 2, or (at your option)
  9. ;;; any later version.
  10.  
  11. ;;; Jade is distributed in the hope that it will be useful, but
  12. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. ;;; GNU General Public License for more details.
  15.  
  16. ;;; You should have received a copy of the GNU General Public License
  17. ;;; along with Jade; see the file COPYING.  If not, write to
  18. ;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  
  20. (setq
  21.   help-buffer (make-buffer "*Help*")
  22.   help-keymap (make-keylist))
  23. (set-buffer-special help-buffer t)
  24.  
  25. (bind-keys help-keymap
  26.   "a" 'apropos-function
  27.   "e" 'apropos-variable
  28.   "f" 'describe-function
  29.   "h" 'help-help
  30.   "ctrl-h" 'help-help
  31.   "i" 'info
  32.   "ctrl-i" '(info t)
  33.   "m" 'describe-mode
  34.   "?" 'help-help
  35.   "v" 'describe-variable)
  36.  
  37. (defun help ()
  38.   (title "Type: a f h i m v -- h for more help")
  39.   (setq next-keymap-path (cons help-keymap nil)))
  40.  
  41. (defun help-help ()
  42.   (clear-buffer help-buffer)
  43.   (insert
  44.     "\nHelp mode -- Type one of the following:\n
  45. a   `apropos-function'
  46.     Search for functions which match a regular expression.
  47. f   `describe-function'
  48.     View the documentation for a particular function.
  49. h   `help-help'
  50.     Display this text.
  51. i   `info'
  52.     Enter the info hypertext viewer.
  53. m   `describe-mode'
  54.     Show the documentation for the edit mode of the current buffer.
  55. v   `describe-variable'
  56.     View the documentation and value of a variable."
  57.     (pos 1 1) help-buffer)
  58.     (goto-buffer help-buffer)
  59.     (goto (pos 1 1))
  60.     (help))
  61.  
  62. (defun apropos-function (&optional regexp)
  63.   (or regexp
  64.       (setq regexp (prompt "Regular Expression: "))
  65.       (return))
  66.   (clear-buffer help-buffer)
  67.   (format help-buffer "Apropos for expression %S:\n" regexp)
  68.   (print (apropos regexp 'fboundp) help-buffer)
  69.   (goto-buffer help-buffer)
  70.   (goto (pos 1 1)))
  71.  
  72. (defun apropos-variable (&optional regexp)
  73.   (or regexp
  74.       (setq regexp (prompt "Regular Expression: "))
  75.       (return))
  76.   (clear-buffer help-buffer)
  77.   (format help-buffer "Apropos for expression %S:\n" regexp)
  78.   (print (apropos regexp 'boundp) help-buffer)
  79.   (goto help-buffer)
  80.   (goto (pos 1 1)))
  81.  
  82. (defun describe-function (&optional fun &aux doc)
  83.   (or fun
  84.       (setq fun (prompt-for-function))
  85.       (return))
  86.   (setq doc (documentation fun))
  87.   (clear-buffer help-buffer)
  88.   (format help-buffer "\n%s\n" (or doc "undocumented."))
  89.   (goto-buffer help-buffer)
  90.   (goto (pos 1 1)))
  91.  
  92. (defun describe-variable (&optional var &aux doc)
  93.   (or var
  94.       (setq var (prompt-for-variable))
  95.       (return))
  96.   (setq doc (documentation var t))
  97.   (clear-buffer help-buffer)
  98.   (format (cons help-buffer t) "\nsymbol name: %s\ncurrent value: %S\n\n%s\n" (symbol-name var) (symbol-value var) (or doc "undocumented."))
  99.   (goto-buffer help-buffer)
  100.   (goto (pos 1 1)))
  101.  
  102. (defun describe-mode ()
  103.   (goto-buffer help-buffer)
  104.   (clear-buffer)
  105.   (let
  106.       ((doc (documentation major-mode)))
  107.     (when (stringp doc)
  108.       (format help-buffer "\n%s\n" mode-documentation)
  109.       (goto (pos 1 1)))))
  110.