(U+884E): Unify JC3-99A9.
[chise/xemacs-chise.git-] / lisp / help.el
index cb09d8a..a337b13 100644 (file)
@@ -1,7 +1,6 @@
 ;;; help.el --- help commands for XEmacs.
 
 ;; Copyright (C) 1985, 1986, 1992-4, 1997 Free Software Foundation, Inc.
-;; Copyright (C) 2001 Ben Wing.
 
 ;; Maintainer: FSF
 ;; Keywords: help, internal, dumped
@@ -265,9 +264,41 @@ otherwise it is killed."
 
 ;;(define-key global-map 'backspace 'deprecated-help-command)
 
-;; help-with-tutorial moved to help-nomule.el and mule-help.el.
+;; This function has been moved to help-nomule.el and mule-help.el.
+;; TUTORIAL arg is XEmacs addition
+;(defun help-with-tutorial (&optional tutorial)
+;  "Select the XEmacs learn-by-doing tutorial.
+;Optional arg TUTORIAL specifies the tutorial file; default is \"TUTORIAL\"."
+;  (interactive)
+;  (if (null tutorial)
+;      (setq tutorial "TUTORIAL"))
+;  (let ((file (expand-file-name (concat "~/" tutorial))))
+;    (delete-other-windows)
+;    (if (get-file-buffer file)
+;      (switch-to-buffer (get-file-buffer file))
+;      (switch-to-buffer (create-file-buffer file))
+;      (setq buffer-file-name file)
+;      (setq default-directory (expand-file-name "~/"))
+;      (setq buffer-auto-save-file-name nil)
+;      (insert-file-contents (expand-file-name tutorial data-directory))
+;      (goto-char (point-min))
+;      (search-forward "\n<<")
+;      (delete-region (point-at-bol) (point-at-eol))
+;      (let ((n (- (window-height (selected-window))
+;                (count-lines (point-min) (point))
+;                6)))
+;      (if (< n 12)
+;          (newline n)
+;        ;; Some people get confused by the large gap.
+;        (newline (/ n 2))
+;        (insert "[Middle of page left blank for didactic purposes.  "
+;                "Text continues below]")
+;        (newline (- n (/ n 2)))))
+;      (goto-char (point-min))
+;      (set-buffer-modified-p nil))))
 
 ;; used by describe-key, describe-key-briefly, insert-key-binding, etc.
+
 (defun key-or-menu-binding (key &optional menu-flag)
   "Return the command invoked by KEY.
 Like `key-binding', but handles menu events and toolbar presses correctly.
@@ -589,27 +620,25 @@ describes the minor mode."
 ;; So keyboard macro definitions are documented correctly
 (fset 'defining-kbd-macro (symbol-function 'start-kbd-macro))
 
-;; view a read-only file intelligently
-(defun Help-find-file (file)
-  (if (fboundp 'view-file)
-      (view-file file)
-    (find-file-read-only file)
-    (goto-char (point-min))))
-
 (defun describe-distribution ()
   "Display info on how to obtain the latest version of XEmacs."
   (interactive)
-  (Help-find-file (locate-data-file "DISTRIB")))
+  (find-file-read-only
+   (locate-data-file "DISTRIB")))
 
 (defun describe-beta ()
   "Display info on how to deal with Beta versions of XEmacs."
   (interactive)
-  (Help-find-file (locate-data-file "BETA")))
+  (find-file-read-only
+   (locate-data-file "BETA"))
+  (goto-char (point-min)))
 
 (defun describe-copying ()
   "Display info on how you may redistribute copies of XEmacs."
   (interactive)
-  (Help-find-file (locate-data-file "COPYING")))
+  (find-file-read-only
+   (locate-data-file "COPYING"))
+  (goto-char (point-min)))
 
 (defun describe-pointer ()
   "Show a list of all defined mouse buttons, and their definitions."
@@ -619,7 +648,9 @@ describes the minor mode."
 (defun describe-project ()
   "Display info on the GNU project."
   (interactive)
-  (Help-find-file (locate-data-file "GNU")))
+  (find-file-read-only
+   (locate-data-file "GNU"))
+  (goto-char (point-min)))
 
 (defun describe-no-warranty ()
   "Display info on all the kinds of warranty XEmacs does NOT have."
@@ -731,7 +762,7 @@ of the key sequence that ran this command."
 (defun view-emacs-news ()
   "Display info on recent changes to XEmacs."
   (interactive)
-  (Help-find-file (locate-data-file "NEWS")))
+  (find-file (locate-data-file "NEWS")))
 
 (defun xemacs-www-page ()
   "Go to the XEmacs World Wide Web page."
@@ -757,11 +788,6 @@ instead, to ensure that you get the most up-to-date information."
     (Info-find-node "xemacs-faq" "Top"))
   (switch-to-buffer "*info*"))
 
-(defun view-sample-init-el ()
-  "Display the sample init.el file."
-  (interactive)
-  (Help-find-file (locate-data-file "sample.init.el")))
-
 (defcustom view-lossage-key-count 100
   "*Number of keys `view-lossage' shows.
 The maximum number of available keys is governed by `recent-keys-ring-size'."
@@ -1075,38 +1101,28 @@ part of the documentation of internal subroutines."
             (string-match "[\n\t ]*\narguments: ?(\\(.*\\))\n?\\'" doc))
        (setq doc (substring doc 0 (match-beginning 0))))
     doc))
-
-;; replacement for `princ' that puts the text in the specified face,
-;; if possible
-(defun Help-princ-face (object face)
-  (cond ((bufferp standard-output)
-        (let ((opoint (point standard-output)))
-          (princ object)
-          (put-nonduplicable-text-property opoint (point standard-output)
-                                           'face face standard-output)))
-       ((markerp standard-output)
-        (let ((buf (marker-buffer standard-output))
-              (pos (marker-position standard-output)))
-          (princ object)
-          (put-nonduplicable-text-property
-           pos (marker-position standard-output) 'face face buf)))
-       (t princ object)))
-
-;; replacement for `prin1' that puts the text in the specified face,
-;; if possible
-(defun Help-prin1-face (object face)
-  (cond ((bufferp standard-output)
-        (let ((opoint (point standard-output)))
-          (prin1 object)
-          (put-nonduplicable-text-property opoint (point standard-output)
-                                           'face face standard-output)))
-       ((markerp standard-output)
-        (let ((buf (marker-buffer standard-output))
-              (pos (marker-position standard-output)))
-          (prin1 object)
-          (put-nonduplicable-text-property
-           pos (marker-position standard-output) 'face face buf)))
-       (t prin1 object)))
+;  (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 '(prog1
+;                'font-lock-reference-face
+;              (add-list-mode-item (match-beginning 1)
+;                             (match-end 1)
+;                             nil
+;                             'help-follow-reference))
+;         t)
+;     ;;
+;     ;; CLisp `:' keywords as references.
+;     (list (concat "\\<:" sym-char "+\\>") 0 'font-lock-reference-face t)))
 
 (defvar help-symbol-regexp
   (let ((sym-char "[+a-zA-Z0-9_:*]")
@@ -1135,25 +1151,25 @@ part of the documentation of internal subroutines."
       (help-symbol-run-function-1 last-popup-menu-event ex fun))))
 
 (defvar help-symbol-function-context-menu
-  '(["View %_Documentation" (help-symbol-run-function 'describe-function)]
+  '("---"
+    ["View %_Documentation" (help-symbol-run-function 'describe-function)]
     ["Find %_Function Source" (help-symbol-run-function 'find-function)]
-    ["Find %_Tag" (help-symbol-run-function 'find-tag)]
     ))
 
 (defvar help-symbol-variable-context-menu
-  '(["View %_Documentation" (help-symbol-run-function 'describe-variable)]
+  '("---"
+    ["View %_Documentation" (help-symbol-run-function 'describe-variable)]
     ["Find %_Variable Source" (help-symbol-run-function 'find-variable)]
-    ["Find %_Tag" (help-symbol-run-function 'find-tag)]
     ))
 
 (defvar help-symbol-function-and-variable-context-menu
-  '(["View Function %_Documentation" (help-symbol-run-function
+  '("---"
+    ["View Function %_Documentation" (help-symbol-run-function
                                      'describe-function)]
     ["View Variable D%_ocumentation" (help-symbol-run-function
                                      'describe-variable)]
     ["Find %_Function Source" (help-symbol-run-function 'find-function)]
     ["Find %_Variable Source" (help-symbol-run-function 'find-variable)]
-    ["Find %_Tag" (help-symbol-run-function 'find-tag)]
     ))
 
 (defun frob-help-extents (buffer)
@@ -1163,10 +1179,9 @@ part of the documentation of internal subroutines."
   ;; properties:
   ;; 1. mouse-face is 'highlight (so the extent gets highlighted on mouse over)
   ;; 2. help-symbol is the name of the symbol.
-  ;; 3. face is 'hyper-apropos-hyperlink.
-  ;; 4. context-menu is a list of context menu items, specific to whether
+  ;; 3. context-menu is a list of context menu items, specific to whether
   ;;    the symbol is a function, variable, or both.
-  ;; 5. activate-function will cause the function or variable to be described,
+  ;; 4. activate-function will cause the function or variable to be described,
   ;;    replacing the existing help contents.
   (save-excursion
     (set-buffer buffer)
@@ -1183,10 +1198,8 @@ part of the documentation of internal subroutines."
                         (documentation sym t))))
          (when (or var fun)
            (let ((ex (make-extent b e)))
-             (require 'hyper-apropos)
              (set-extent-property ex 'mouse-face 'highlight)
              (set-extent-property ex 'help-symbol sym)
-             (set-extent-property ex 'face 'hyper-apropos-hyperlink)
              (set-extent-property
               ex 'context-menu
               (cond ((and var fun)
@@ -1204,10 +1217,7 @@ part of the documentation of internal subroutines."
 
 (defun describe-function-1 (function &optional nodoc)
   "This function does the work for `describe-function'."
-  (princ "`")
-  ;; (Help-princ-face function 'font-lock-function-name-face) overkill
-  (princ function)
-  (princ "' is ")
+  (princ (format "`%s' is " function))
   (let* ((def function)
         aliases file-name autoload-file kbd-macro-p fndef macrop)
     (while (and (symbolp def) (fboundp def))
@@ -1271,8 +1281,7 @@ part of the documentation of internal subroutines."
     (if describe-function-show-arglist
        (let ((arglist (function-arglist function)))
          (when arglist
-           (require 'hyper-apropos)
-           (Help-princ-face arglist 'hyper-apropos-documentation)
+           (princ arglist)
            (terpri))))
     (terpri)
     (cond (kbd-macro-p
@@ -1412,11 +1421,7 @@ there is no variable around that point, nil is returned."
      (let ((origvar variable)
           aliases)
        (let ((print-escape-newlines t))
-        (princ "`")
-        ;; (Help-princ-face (symbol-name variable)
-        ;;               'font-lock-variable-name-face) overkill
-        (princ (symbol-name variable))
-        (princ "' is ")
+        (princ (format "`%s' is " (symbol-name variable)))
         (while (variable-alias variable)
           (let ((newvar (variable-alias variable)))
             (if aliases
@@ -1437,11 +1442,9 @@ there is no variable around that point, nil is returned."
           (if file-name
               (princ (format "  -- loaded from \"%s\"\n" file-name))))
         (princ "\nValue: ")
-        (require 'hyper-apropos)
-        (if (not (boundp variable))
-            (Help-princ-face "void\n" 'hyper-apropos-documentation)
-          (Help-prin1-face (symbol-value variable)
-                           'hyper-apropos-documentation)
+        (if (not (boundp variable))
+            (princ "void\n")
+          (prin1 (symbol-value variable))
           (terpri))
         (terpri)
         (cond ((local-variable-p variable (current-buffer))