Mercurial > hg > xemacs-beta
comparison lisp/prim/help.el @ 70:131b0175ea99 r20-0b30
Import from CVS: tag r20-0b30
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:02:59 +0200 |
parents | 8d2a9b52c682 |
children | b9518feda344 |
comparison
equal
deleted
inserted
replaced
69:804d1389bcd6 | 70:131b0175ea99 |
---|---|
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
17 ;; General Public License for more details. | 17 ;; General Public License for more details. |
18 | 18 |
19 ;; You should have received a copy of the GNU General Public License | 19 ;; You should have received a copy of the GNU General Public License |
20 ;; along with XEmacs; see the file COPYING. If not, write to the | 20 ;; along with XEmacs; see the file COPYING. If not, write to the |
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 21 ;; Free Software Foundation, 59 Temple Place - Suite 330, |
22 ;; Boston, MA 02111-1307, USA. | 22 ;; Boston, MA 02111-1307, USA. |
23 | 23 |
24 ;;; Synched up with: FSF 19.30. | 24 ;;; Synched up with: FSF 19.30. |
25 | 25 |
26 ;;; Commentary: | 26 ;;; Commentary: |
44 | 44 |
45 ;; global-map definitions moved to keydefs.el | 45 ;; global-map definitions moved to keydefs.el |
46 (fset 'help-command help-map) | 46 (fset 'help-command help-map) |
47 | 47 |
48 (let ((ch help-char)) | 48 (let ((ch help-char)) |
49 (if (integerp ch) | 49 (if (or (characterp ch) (integerp ch)) |
50 (setq ch (char-to-string ch))) | 50 (setq ch (char-to-string ch))) |
51 (define-key help-map ch 'help-for-help)) | 51 (define-key help-map ch 'help-for-help)) |
52 (define-key help-map "?" 'help-for-help) | 52 (define-key help-map "?" 'help-for-help) |
53 (define-key help-map 'help 'help-for-help) | 53 (define-key help-map 'help 'help-for-help) |
54 | 54 |
57 (define-key help-map "\C-w" 'describe-no-warranty) | 57 (define-key help-map "\C-w" 'describe-no-warranty) |
58 (define-key help-map "a" 'hyper-apropos) ; 'command-apropos in FSFmacs | 58 (define-key help-map "a" 'hyper-apropos) ; 'command-apropos in FSFmacs |
59 (define-key help-map "A" 'command-apropos) | 59 (define-key help-map "A" 'command-apropos) |
60 | 60 |
61 (define-key help-map "b" 'describe-bindings) | 61 (define-key help-map "b" 'describe-bindings) |
62 (define-key help-map "B" 'describe-beta) | |
63 (define-key help-map "\C-p" 'describe-pointer) | 62 (define-key help-map "\C-p" 'describe-pointer) |
64 | 63 |
65 (define-key help-map "c" 'describe-key-briefly) | 64 (define-key help-map "c" 'describe-key-briefly) |
66 (define-key help-map "k" 'describe-key) | 65 (define-key help-map "k" 'describe-key) |
67 | 66 |
180 ) | 179 ) |
181 | 180 |
182 (define-key help-mode-map "q" 'help-mode-quit) | 181 (define-key help-mode-map "q" 'help-mode-quit) |
183 | 182 |
184 (defun help-mode-quit () | 183 (defun help-mode-quit () |
185 "Exits from help mode, possibly restoring the previous window configuration." | 184 "Exits from help mode, possiblely restoring the previous window configuration." |
186 (interactive) | 185 (interactive) |
187 (cond ((frame-property (selected-frame) 'help-window-config) | 186 (cond ((local-variable-p 'help-window-config (current-buffer)) |
188 (set-window-configuration | 187 (let ((config help-window-config)) |
189 (frame-property (selected-frame) 'help-window-config)) | 188 (kill-local-variable 'help-window-config) |
190 (set-frame-property (selected-frame) 'help-window-config nil)) | 189 (set-window-configuration config))) |
191 ((one-window-p) | 190 ((one-window-p) |
192 (bury-buffer)) | 191 (bury-buffer)) |
193 (t | 192 (t |
194 (delete-window)))) | 193 (delete-window)))) |
195 | 194 |
345 (defvar help-selects-help-window t | 344 (defvar help-selects-help-window t |
346 "*If nil, use the \"old Emacs\" behavior for Help buffers. | 345 "*If nil, use the \"old Emacs\" behavior for Help buffers. |
347 This just displays the buffer in another window, rather than selecting | 346 This just displays the buffer in another window, rather than selecting |
348 the window.") | 347 the window.") |
349 | 348 |
349 (defvar help-window-config nil) | |
350 | |
350 ;; Use this function for displaying help when C-h something is pressed | 351 ;; Use this function for displaying help when C-h something is pressed |
351 ;; or in similar situations. Do *not* use it when you are displaying | 352 ;; or in similar situations. Do *not* use it when you are displaying |
352 ;; a help message and then prompting for input in the minibuffer -- | 353 ;; a help message and then prompting for input in the minibuffer -- |
353 ;; this macro usually selects the help buffer, which is not what you | 354 ;; this macro usually selects the help buffer, which is not what you |
354 ;; want in those situations. | 355 ;; want in those situations. |
355 | 356 |
356 ;;; ### Should really be a macro (as suggested above) to eliminate the | 357 ;;; ### Should really be a macro (as suggested above) to eliminate the |
357 ;;; requirement of caller to code a lambda form in THUNK -- mrb | 358 ;;; requirement of caller to code a lambda form in THUNK -- mrb |
358 (defun with-displaying-help-buffer (thunk) | 359 (defun with-displaying-help-buffer (thunk) |
359 (let ((winconfig (current-window-configuration)) | 360 (let ((winconfig (current-window-configuration)) |
360 (was-one-window (one-window-p)) | 361 (was-one-window (one-window-p))) |
361 (help-not-visible | |
362 (not (and (windows-of-buffer "*Help*") ;shortcut | |
363 (member (selected-frame) | |
364 (mapcar 'window-frame | |
365 (windows-of-buffer "*Help*"))))))) | |
366 (prog1 (with-output-to-temp-buffer "*Help*" | 362 (prog1 (with-output-to-temp-buffer "*Help*" |
367 (prog1 (funcall thunk) | 363 (prog1 (funcall thunk) |
368 (save-excursion | 364 (save-excursion |
369 (set-buffer standard-output) | 365 (set-buffer standard-output) |
370 (help-mode)))) | 366 (help-mode)))) |
371 (let ((helpwin (get-buffer-window "*Help*"))) | 367 (let ((helpwin (get-buffer-window "*Help*"))) |
372 (if helpwin | 368 (if helpwin |
373 (progn | 369 (progn |
374 (save-excursion | 370 (save-excursion |
375 (set-buffer (window-buffer helpwin)) | 371 (set-buffer (window-buffer helpwin)) |
376 ;;If the *Help* buffer is already displayed on this | 372 (set (make-local-variable 'help-window-config) winconfig)) |
377 ;; frame, don't override the previous configuration | |
378 (if help-not-visible | |
379 (set-frame-property (selected-frame) | |
380 'help-window-config winconfig))) | |
381 (if help-selects-help-window | 373 (if help-selects-help-window |
382 (select-window helpwin)) | 374 (select-window helpwin)) |
383 (cond ((eq helpwin (selected-window)) | 375 (cond ((eq helpwin (selected-window)) |
384 (message | 376 (message |
385 (substitute-command-keys "Type \\[help-mode-quit] to remove help window, \\[scroll-up] to scroll the help."))) | 377 (substitute-command-keys "Type \\[help-mode-quit] to remove help window, \\[scroll-up] to scroll the help."))) |
391 (substitute-command-keys "Type \\[switch-to-buffer-other-window] to restore the other window, \\[scroll-other-window] to scroll the help.")))))))))) | 383 (substitute-command-keys "Type \\[switch-to-buffer-other-window] to restore the other window, \\[scroll-other-window] to scroll the help.")))))))))) |
392 | 384 |
393 (defun describe-key (key) | 385 (defun describe-key (key) |
394 "Display documentation of the function invoked by KEY. | 386 "Display documentation of the function invoked by KEY. |
395 KEY is a string, or vector of events. | 387 KEY is a string, or vector of events. |
396 When called interactively, KEY may also be a menu selection." | 388 When called interactvely, KEY may also be a menu selection." |
397 (interactive "kDescribe key: ") | 389 (interactive "kDescribe key: ") |
398 (let ((defn (key-or-menu-binding key))) | 390 (let ((defn (key-or-menu-binding key))) |
399 (if (or (null defn) (integerp defn)) | 391 (if (or (null defn) (integerp defn)) |
400 (message "%s is undefined" (key-description key)) | 392 (message "%s is undefined" (key-description key)) |
401 (with-displaying-help-buffer | 393 (with-displaying-help-buffer |
469 (defun describe-distribution () | 461 (defun describe-distribution () |
470 "Display info on how to obtain the latest version of XEmacs." | 462 "Display info on how to obtain the latest version of XEmacs." |
471 (interactive) | 463 (interactive) |
472 (find-file-read-only | 464 (find-file-read-only |
473 (expand-file-name "DISTRIB" data-directory))) | 465 (expand-file-name "DISTRIB" data-directory))) |
474 | |
475 (defun describe-beta () | |
476 "Display info on how to deal with Beta versions of XEmacs." | |
477 (interactive) | |
478 (find-file-read-only | |
479 (expand-file-name "BETA" data-directory)) | |
480 (goto-char (point-min))) | |
481 | 466 |
482 (defun describe-copying () | 467 (defun describe-copying () |
483 "Display info on how you may redistribute copies of XEmacs." | 468 "Display info on how you may redistribute copies of XEmacs." |
484 (interactive) | 469 (interactive) |
485 (find-file-read-only | 470 (find-file-read-only |
693 (eq char ??) | 678 (eq char ??) |
694 (eq 'help-command (key-binding event)) | 679 (eq 'help-command (key-binding event)) |
695 (eq char ? ) | 680 (eq char ? ) |
696 (eq 'scroll-up (key-binding event)) | 681 (eq 'scroll-up (key-binding event)) |
697 (eq char ?\177) | 682 (eq char ?\177) |
698 (and (not (eq char ?b)) | 683 (eq 'scroll-down (key-binding event))) |
699 (eq 'scroll-down (key-binding event)))) | |
700 (if (or (eq char ? ) | 684 (if (or (eq char ? ) |
701 (eq 'scroll-up (key-binding event))) | 685 (eq 'scroll-up (key-binding event))) |
702 (scroll-up)) | 686 (scroll-up)) |
703 (if (or (eq char ?\177) | 687 (if (or (eq char ?\177) |
704 (and (not (eq char ?b)) | 688 (eq 'scroll-down (key-binding event))) |
705 (eq 'scroll-down (key-binding event)))) | |
706 (scroll-down)) | 689 (scroll-down)) |
707 ;; write this way for I18N3 snarfing | 690 ;; write this way for I18N3 snarfing |
708 (if (pos-visible-in-window-p (point-max)) | 691 (if (pos-visible-in-window-p (point-max)) |
709 (message "A B C F I K L M N P S T V W C-c C-d C-n C-w C-i C-k C-f: ") | 692 (message "A B C F I K L M N P S T V W C-c C-d C-n C-w C-i C-k C-f: ") |
710 (message "A B C F I K L M N P S T V W C-c C-d C-n C-w C-i C-k C-f or Space to scroll: ")) | 693 (message "A B C F I K L M N P S T V W C-c C-d C-n C-w C-i C-k C-f or Space to scroll: ")) |
793 (format "Obsolete; %s" | 776 (format "Obsolete; %s" |
794 (if (stringp (car obsolete)) | 777 (if (stringp (car obsolete)) |
795 (car obsolete) | 778 (car obsolete) |
796 (format "use `%s' instead." (car obsolete))))))) | 779 (format "use `%s' instead." (car obsolete))))))) |
797 | 780 |
798 (defun function-compatible-p (function) | |
799 "Return non-nil if FUNCTION is present for Emacs compatibility." | |
800 (not (null (get function 'byte-compatible-info)))) | |
801 | |
802 (defun function-compatibility-doc (function) | |
803 "If FUNCTION is Emacs compatible, return a string describing this." | |
804 (let ((compatible (get function 'byte-compatible-info))) | |
805 (if compatible | |
806 (format "Emacs Compatible; %s" | |
807 (if (stringp (car compatible)) | |
808 (car compatible) | |
809 (format "use `%s' instead." (car compatible))))))) | |
810 | |
811 ;Here are all the possibilities below spelled out, for the benefit | 781 ;Here are all the possibilities below spelled out, for the benefit |
812 ;of the I18N3 snarfer. | 782 ;of the I18N3 snarfer. |
813 ; | 783 ; |
814 ;(gettext "a built-in function") | 784 ;(gettext "a built-in function") |
815 ;(gettext "an interactive built-in function") | 785 ;(gettext "an interactive built-in function") |
837 (princ ": " stream) | 807 (princ ": " stream) |
838 (let* ((def function) | 808 (let* ((def function) |
839 file-name | 809 file-name |
840 (doc (or (documentation function) | 810 (doc (or (documentation function) |
841 (gettext "not documented"))) | 811 (gettext "not documented"))) |
842 aliases home kbd-macro-p fndef macrop) | 812 aliases kbd-macro-p fndef macrop) |
843 (while (symbolp def) | 813 (while (symbolp def) |
844 (or (eq def function) | 814 (or (eq def function) |
845 (if aliases | 815 (if aliases |
846 ;; I18N3 Need gettext due to concat | 816 ;; I18N3 Need gettext due to concat |
847 (setq aliases (concat aliases | 817 (setq aliases (concat aliases |
848 (format "\n which is an alias for %s, " | 818 (format "\n which is an alias for %s, " |
849 (symbol-name def)))) | 819 (symbol-name def)))) |
850 (setq aliases (format "an alias for %s, " (symbol-name def))))) | 820 (setq aliases (format "an alias for %s, " (symbol-name def))))) |
851 (setq def (symbol-function def))) | 821 (setq def (symbol-function def))) |
852 (if (compiled-function-p def) | |
853 (setq home (compiled-function-annotation def))) | |
854 (if (eq 'macro (car-safe def)) | 822 (if (eq 'macro (car-safe def)) |
855 (setq fndef (cdr def) | 823 (setq fndef (cdr def) |
856 macrop t) | 824 macrop t) |
857 (setq fndef def)) | 825 (setq fndef def)) |
858 (if describe-function-show-arglist | 826 (if describe-function-show-arglist |
908 nil))) | 876 nil))) |
909 (or file-name | 877 (or file-name |
910 (setq file-name (describe-function-find-file function))) | 878 (setq file-name (describe-function-find-file function))) |
911 (if file-name | 879 (if file-name |
912 (princ (format ".\n -- loads from \"%s\"" file-name) stream)) | 880 (princ (format ".\n -- loads from \"%s\"" file-name) stream)) |
913 (if home | 881 (princ ".") |
914 (princ (format ".\n -- loaded from %s" home))) | 882 (terpri) |
915 (princ "." stream) | |
916 (terpri stream) | |
917 (cond (kbd-macro-p | 883 (cond (kbd-macro-p |
918 (princ "These characters are executed:\n\n\t" stream) | 884 (princ "These characters are executed:\n\n\t" stream) |
919 (princ (key-description def) stream) | 885 (princ (key-description def) stream) |
920 (cond ((setq def (key-binding def)) | 886 (cond ((setq def (key-binding def)) |
921 (princ (format "\n\nwhich executes the command %s.\n\n" def) stream) | 887 (princ (format "\n\nwhich executes the command %s.\n\n" def) stream) |
924 (t | 890 (t |
925 ;; tell the user about obsoleteness. | 891 ;; tell the user about obsoleteness. |
926 ;; If the function is obsolete and is aliased, don't | 892 ;; If the function is obsolete and is aliased, don't |
927 ;; even bother to report the documentation, as a further | 893 ;; even bother to report the documentation, as a further |
928 ;; encouragement to use the new function. | 894 ;; encouragement to use the new function. |
929 (let ((obsolete (function-obsoleteness-doc function)) | 895 (let ((obsolete (function-obsoleteness-doc function))) |
930 (compatible (function-compatibility-doc function))) | |
931 (if obsolete | 896 (if obsolete |
932 (progn | 897 (progn |
933 (princ obsolete stream) | 898 (princ obsolete stream) |
934 (terpri stream) | |
935 (terpri stream))) | |
936 (if compatible | |
937 (progn | |
938 (princ compatible stream) | |
939 (terpri stream) | 899 (terpri stream) |
940 (terpri stream))) | 900 (terpri stream))) |
941 (if (not (and obsolete aliases)) | 901 (if (not (and obsolete aliases)) |
942 (progn | 902 (progn |
943 (princ doc stream) | 903 (princ doc stream) |
944 (or (eq ?\n (aref doc (1- (length doc)))) | 904 (or (eq ?\n (aref doc (1- (length doc)))) |
945 (terpri stream))))))))) | 905 (terpri))))))))) |
946 | 906 |
947 | 907 |
948 (defun describe-function-arglist (function) | 908 (defun describe-function-arglist (function) |
949 (interactive (list (or (function-called-at-point) | 909 (interactive (list (or (function-called-at-point) |
950 (error "no function call at point")))) | 910 (error "no function call at point")))) |
990 (if obsolete | 950 (if obsolete |
991 (format "Obsolete; %s" | 951 (format "Obsolete; %s" |
992 (if (stringp obsolete) | 952 (if (stringp obsolete) |
993 obsolete | 953 obsolete |
994 (format "use `%s' instead." obsolete)))))) | 954 (format "use `%s' instead." obsolete)))))) |
995 | |
996 (defun variable-compatible-p (variable) | |
997 "Return non-nil if VARIABLE is Emacs compatible." | |
998 (not (null (get variable 'byte-compatible-variable)))) | |
999 | |
1000 (defun variable-compatibility-doc (variable) | |
1001 "If VARIABLE is Emacs compatible, return a string describing this." | |
1002 (let ((compatible (get variable 'byte-compatible-variable))) | |
1003 (if compatible | |
1004 (format "Emacs Compatible; %s" | |
1005 (if (stringp compatible) | |
1006 compatible | |
1007 (format "use `%s' instead." compatible)))))) | |
1008 | 955 |
1009 (defun built-in-variable-doc (variable) | 956 (defun built-in-variable-doc (variable) |
1010 "Return a string describing whether VARIABLE is built-in." | 957 "Return a string describing whether VARIABLE is built-in." |
1011 (let ((type (built-in-variable-type variable))) | 958 (let ((type (built-in-variable-type variable))) |
1012 (cond ((eq type 'integer) "a built-in integer variable") | 959 (cond ((eq type 'integer) "a built-in integer variable") |
1094 (terpri)))) | 1041 (terpri)))) |
1095 (terpri) | 1042 (terpri) |
1096 (princ "Documentation:") | 1043 (princ "Documentation:") |
1097 (terpri) | 1044 (terpri) |
1098 (let ((doc (documentation-property variable 'variable-documentation)) | 1045 (let ((doc (documentation-property variable 'variable-documentation)) |
1099 (obsolete (variable-obsoleteness-doc origvar)) | 1046 (obsolete (variable-obsoleteness-doc origvar))) |
1100 (compatible (variable-compatibility-doc origvar))) | |
1101 (if obsolete | 1047 (if obsolete |
1102 (progn | 1048 (progn |
1103 (princ obsolete) | 1049 (princ obsolete) |
1104 (terpri) | |
1105 (terpri))) | |
1106 (if compatible | |
1107 (progn | |
1108 (princ compatible) | |
1109 (terpri) | 1050 (terpri) |
1110 (terpri))) | 1051 (terpri))) |
1111 ;; don't bother to print anything if variable is obsolete and aliased. | 1052 ;; don't bother to print anything if variable is obsolete and aliased. |
1112 (if (or (not obsolete) (not aliases)) | 1053 (if (or (not obsolete) (not aliases)) |
1113 (if doc | 1054 (if doc |
1142 (< (length x) (length y)))) | 1083 (< (length x) (length y)))) |
1143 ", ")) | 1084 ", ")) |
1144 (message "%s is not on any keys" definition))) | 1085 (message "%s is not on any keys" definition))) |
1145 nil) | 1086 nil) |
1146 | 1087 |
1147 ;; Synched with Emacs 19.35 | 1088 (defun locate-library (library &optional nosuffix) |
1148 (defun locate-library (library &optional nosuffix path interactive-call) | 1089 "Show the full path name of XEmacs library LIBRARY. |
1149 "Show the precise file name of Emacs library LIBRARY. | |
1150 This command searches the directories in `load-path' like `M-x load-library' | 1090 This command searches the directories in `load-path' like `M-x load-library' |
1151 to find the file that `M-x load-library RET LIBRARY RET' would load. | 1091 to find the file that `M-x load-library RET LIBRARY RET' would load. |
1152 Optional second arg NOSUFFIX non-nil means don't add suffixes `.elc' or `.el' | 1092 Optional second arg NOSUFFIX non-nil means don't add suffixes `.elc' or `.el' |
1153 to the specified name LIBRARY. | 1093 to the specified name LIBRARY (a la calling `load' instead of `load-library')." |
1154 | 1094 (interactive "sLocate library: \nP") |
1155 If the optional third arg PATH is specified, that list of directories | 1095 ;; Let's accept both symbols and strings, since they're often equivalent |
1156 is used instead of `load-path'." | 1096 (when (symbolp library) |
1157 (interactive (list (read-string "Locate library: ") | 1097 (setq library (symbol-name library))) |
1158 nil nil | 1098 ;; XEmacs: We have the nifty `locate-file' so we use it. |
1159 t)) | 1099 (let ((file (locate-file library load-path (if nosuffix nil ".elc:.el:")))) |
1160 (let (result) | 1100 (if file |
1161 (catch 'answer | 1101 (message "Library is file %s" file) |
1162 (mapcar | 1102 (message "No library %s in search path" library)) |
1163 (lambda (dir) | 1103 file)) |
1164 (mapcar | |
1165 (lambda (suf) | |
1166 (let ((try (expand-file-name (concat library suf) dir))) | |
1167 (and (file-readable-p try) | |
1168 (null (file-directory-p try)) | |
1169 (progn | |
1170 (setq result try) | |
1171 (throw 'answer try))))) | |
1172 (if nosuffix | |
1173 '("") | |
1174 (let ((basic '(".elc" ".el" "")) | |
1175 (compressed '(".Z" ".gz" ""))) | |
1176 ;; If autocompression mode is on, | |
1177 ;; consider all combinations of library suffixes | |
1178 ;; and compression suffixes. | |
1179 (if (rassq 'jka-compr-handler file-name-handler-alist) | |
1180 (apply 'nconc | |
1181 (mapcar (lambda (compelt) | |
1182 (mapcar (lambda (baselt) | |
1183 (concat baselt compelt)) | |
1184 basic)) | |
1185 compressed)) | |
1186 basic))))) | |
1187 (or path load-path))) | |
1188 (and interactive-call | |
1189 (if result | |
1190 (message "Library is file %s" result) | |
1191 (message "No library %s in search path" library))) | |
1192 result)) | |
1193 | 1104 |
1194 ;; Functions ported from C into Lisp in XEmacs | 1105 ;; Functions ported from C into Lisp in XEmacs |
1195 | 1106 |
1196 (defun describe-syntax () | 1107 (defun describe-syntax () |
1197 "Describe the syntax specifications in the syntax table. | 1108 "Describe the syntax specifications in the syntax table. |