annotate lisp/help.el @ 826:6728e641994e

[xemacs-hg @ 2002-05-05 11:30:15 by ben] syntax cache, 8-bit-format, lots of code cleanup README.packages: Update info about --package-path. i.c: Create an inheritable event and pass it on to XEmacs, so that ^C can be handled properly. Intercept ^C and signal the event. "Stop Build" in VC++ now works. bytecomp-runtime.el: Doc string changes. compat.el: Some attempts to redo this to make it truly useful and fix the "multiple versions interacting with each other" problem. Not yet done. Currently doesn't work. files.el: Use with-obsolete-variable to avoid warnings in new revert-buffer code. xemacs.mak: Split up CFLAGS into a version without flags specifying the C library. The problem seems to be that minitar depends on zlib, which depends specifically on libc.lib, not on any of the other C libraries. Unless you compile with libc.lib, you get errors -- specifically, no _errno in the other libraries, which must make it something other than an int. (#### But this doesn't seem to obtain in XEmacs, which also uses zlib, and can be linked with any of the C libraries. Maybe zlib is used differently and doesn't need errno, or maybe XEmacs provides an int errno; ... I don't understand. Makefile.in.in: Fix so that packages are around when testing. abbrev.c, alloc.c, buffer.c, buffer.h, bytecode.c, callint.c, casefiddle.c, casetab.c, casetab.h, charset.h, chartab.c, chartab.h, cmds.c, console-msw.h, console-stream.c, console-x.c, console.c, console.h, data.c, device-msw.c, device.c, device.h, dialog-msw.c, dialog-x.c, dired-msw.c, dired.c, doc.c, doprnt.c, dumper.c, editfns.c, elhash.c, emacs.c, eval.c, event-Xt.c, event-gtk.c, event-msw.c, event-stream.c, events.c, events.h, extents.c, extents.h, faces.c, file-coding.c, file-coding.h, fileio.c, fns.c, font-lock.c, frame-gtk.c, frame-msw.c, frame-x.c, frame.c, frame.h, glade.c, glyphs-gtk.c, glyphs-msw.c, glyphs-msw.h, glyphs-x.c, glyphs.c, glyphs.h, gui-msw.c, gui-x.c, gui.h, gutter.h, hash.h, indent.c, insdel.c, intl-win32.c, intl.c, keymap.c, lisp-disunion.h, lisp-union.h, lisp.h, lread.c, lrecord.h, lstream.c, lstream.h, marker.c, menubar-gtk.c, menubar-msw.c, menubar-x.c, menubar.c, minibuf.c, mule-ccl.c, mule-charset.c, mule-coding.c, mule-wnnfns.c, nas.c, objects-msw.c, objects-x.c, opaque.c, postgresql.c, print.c, process-nt.c, process-unix.c, process.c, process.h, profile.c, rangetab.c, redisplay-gtk.c, redisplay-msw.c, redisplay-output.c, redisplay-x.c, redisplay.c, redisplay.h, regex.c, regex.h, scrollbar-msw.c, search.c, select-x.c, specifier.c, specifier.h, symbols.c, symsinit.h, syntax.c, syntax.h, syswindows.h, tests.c, text.c, text.h, tooltalk.c, ui-byhand.c, ui-gtk.c, unicode.c, win32.c, window.c: Another big Ben patch. -- FUNCTIONALITY CHANGES: add partial support for 8-bit-fixed, 16-bit-fixed, and 32-bit-fixed formats. not quite done yet. (in particular, needs functions to actually convert the buffer.) NOTE: lots of changes to regex.c here. also, many new *_fmt() inline funs that take an Internal_Format argument. redo syntax cache code. make the cache per-buffer; keep the cache valid across calls to functions that use it. also keep it valid across insertions/deletions and extent changes, as much as is possible. eliminate the junky regex-reentrancy code by passing in the relevant lisp info to the regex routines as local vars. add general mechanism in extents code for signalling extent changes. fix numerous problems with the case-table implementation; yoshiki never properly transferred many algorithms from old-style to new-style case tables. redo char tables to support a default argument, so that mapping only occurs over changed args. change many chartab functions to accept Lisp_Object instead of Lisp_Char_Table *. comment out the code in font-lock.c by default, because font-lock.el no longer uses it. we should consider eliminating it entirely. Don't output bell as ^G in console-stream when not a TTY. add -mswindows-termination-handle to interface with i.c, so we can properly kill a build. add more error-checking to buffer/string macros. add some additional buffer_or_string_() funs. -- INTERFACE CHANGES AFFECTING MORE CODE: switch the arguments of write_c_string and friends to be consistent with write_fmt_string, which must have printcharfun first. change BI_* macros to BYTE_* for increased clarity; similarly for bi_* local vars. change VOID_TO_LISP to be a one-argument function. eliminate no-longer-needed CVOID_TO_LISP. -- char/string macro changes: rename MAKE_CHAR() to make_emchar() for slightly less confusion with make_char(). (The former generates an Emchar, the latter a Lisp object. Conceivably we should rename make_char() -> wrap_char() and similarly for make_int(), make_float().) Similar changes for other *CHAR* macros -- we now consistently use names with `emchar' whenever we are working with Emchars. Any remaining name with just `char' always refers to a Lisp object. rename macros with XSTRING_* to string_* except for those that reference actual fields in the Lisp_String object, following conventions used elsewhere. rename set_string_{data,length} macros (the only ones to work with a Lisp_String_* instead of a Lisp_Object) to set_lispstringp_* to make the difference clear. try to be consistent about caps vs. lowercase in macro/inline-fun names for chars and such, which wasn't the case before. we now reserve caps either for XFOO_ macros that reference object fields (e.g. XSTRING_DATA) or for things that have non-function semantics, e.g. directly modifying an arg (BREAKUP_EMCHAR) or evaluating an arg (any arg) more than once. otherwise, use lowercase. here is a summary of most of the macros/inline funs changed by all of the above changes: BYTE_*_P -> byte_*_p XSTRING_BYTE -> string_byte set_string_data/length -> set_lispstringp_data/length XSTRING_CHAR_LENGTH -> string_char_length XSTRING_CHAR -> string_emchar INTBYTE_FIRST_BYTE_P -> intbyte_first_byte_p INTBYTE_LEADING_BYTE_P -> intbyte_leading_byte_p charptr_copy_char -> charptr_copy_emchar LEADING_BYTE_* -> leading_byte_* CHAR_* -> EMCHAR_* *_CHAR_* -> *_EMCHAR_* *_CHAR -> *_EMCHAR CHARSET_BY_ -> charset_by_* BYTE_SHIFT_JIS* -> byte_shift_jis* BYTE_BIG5* -> byte_big5* REP_BYTES_BY_FIRST_BYTE -> rep_bytes_by_first_byte char_to_unicode -> emchar_to_unicode valid_char_p -> valid_emchar_p Change intbyte_strcmp -> qxestrcmp_c (duplicated functionality). -- INTERFACE CHANGES AFFECTING LESS CODE: use DECLARE_INLINE_HEADER in various places. remove '#ifdef emacs' from XEmacs-only files. eliminate CHAR_TABLE_VALUE(), which duplicated the functionality of get_char_table(). add BUFFER_TEXT_LOOP to simplify iterations over buffer text. define typedefs for signed and unsigned types of fixed sizes (INT_32_BIT, UINT_32_BIT, etc.). create ALIGN_FOR_TYPE as a higher-level interface onto ALIGN_SIZE; fix code to use it. add charptr_emchar_len to return the text length of the character pointed to by a ptr; use it in place of charcount_to_bytecount(..., 1). add emchar_len to return the text length of a given character. add types Bytexpos and Charxpos to generalize Bytebpos/Bytecount and Charbpos/Charcount, in code (particularly, the extents code and redisplay code) that works with either kind of index. rename redisplay struct params with names such as `charbpos' to e.g. `charpos' when they are e.g. a Charxpos, not a Charbpos. eliminate xxDEFUN in place of DEFUN; no longer necessary with changes awhile back to doc.c. split up big ugly combined list of EXFUNs in lisp.h on a file-by-file basis, since other prototypes are similarly split. rewrite some "*_UNSAFE" macros as inline funs and eliminate the _UNSAFE suffix. move most string code from lisp.h to text.h; the string code and text.h code is now intertwined in such a fashion that they need to be in the same place and partially interleaved. (you can't create forward references for inline funs) automated/lisp-tests.el, automated/symbol-tests.el, automated/test-harness.el: Fix test harness to output FAIL messages to stderr when in batch mode. Fix up some problems in lisp-tests/symbol-tests that were causing spurious failures.
author ben
date Sun, 05 May 2002 11:33:57 +0000
parents e38acbeb1cae
children 42375619fa45
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 ;;; help.el --- help commands for XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 ;; Copyright (C) 1985, 1986, 1992-4, 1997 Free Software Foundation, Inc.
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
4 ;; Copyright (C) 2001, 2002 Ben Wing.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 ;; Maintainer: FSF
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 ;; Keywords: help, internal, dumped
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 ;; This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 ;; XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 ;; under the terms of the GNU General Public License as published by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 ;; any later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 ;; XEmacs is distributed in the hope that it will be useful, but
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 ;; General Public License for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 ;; along with XEmacs; see the file COPYING. If not, write to the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 ;; Free Software Foundation, 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 ;; Boston, MA 02111-1307, USA.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 ;;; Synched up with: FSF 19.30.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 ;;; Commentary:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 ;; This file is dumped with XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 ;; This code implements XEmacs's on-line help system, the one invoked by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 ;;`M-x help-for-help'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 ;; 06/11/1997 -- Converted to use char-after instead of broken
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 ;; following-char. -slb
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 ;;; Code:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 ;; Get the macro make-help-screen when this is compiled,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 ;; or run interpreted, but not when the compiled code is loaded.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 (eval-when-compile (require 'help-macro))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 (defgroup help nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 "Support for on-line help systems."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 :group 'emacs)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 (defgroup help-appearance nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 "Appearance of help buffers."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 :group 'help)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 (defvar help-map (let ((map (make-sparse-keymap)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 (set-keymap-name map 'help-map)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 (set-keymap-prompt
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
55 map (gettext "(Type ? for further options)"))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 map)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 "Keymap for characters following the Help key.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 ;; global-map definitions moved to keydefs.el
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 (fset 'help-command help-map)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 (define-key help-map (vector help-char) 'help-for-help)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 (define-key help-map "?" 'help-for-help)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 (define-key help-map 'help 'help-for-help)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 (define-key help-map '(f1) 'help-for-help)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 (define-key help-map "a" 'hyper-apropos) ; 'command-apropos in FSFmacs
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
68 (define-key help-map "A" 'command-hyper-apropos)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
69 ;; #### should be hyper-apropos-documentation, once that's written.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
70 (define-key help-map "\C-a" 'apropos-documentation)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 (define-key help-map "b" 'describe-bindings)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 (define-key help-map "B" 'describe-beta)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
75 (define-key help-map "c" 'describe-key-briefly)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 (define-key help-map "C" 'customize)
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
77 ;; FSFmacs has Info-goto-emacs-command-node on C-f, no binding
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
78 ;; for Info-elisp-ref
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
79 (define-key help-map "\C-c" 'Info-goto-emacs-command-node)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 (define-key help-map "d" 'describe-function)
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
82 (define-key help-map "\C-d" 'describe-distribution)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
83
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
84 (define-key help-map "e" (if (fboundp 'view-last-error) 'view-last-error
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
85 'describe-last-error))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
86
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 (define-key help-map "f" 'describe-function)
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
88 ;; #### not a good interface. no way to specify that C-h is preferred
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
89 ;; as a prefix and not BS. should instead be specified as part of
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
90 ;; `define-key'.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
91 ;; (put 'describe-function 'preferred-key-sequence "\C-hf")
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 (define-key help-map "F" 'xemacs-local-faq)
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
93 (define-key help-map "\C-f" 'Info-elisp-ref)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 (define-key help-map "i" 'info)
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
96 (define-key help-map "I" 'Info-search-index-in-xemacs-and-lispref)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
97 (define-key help-map "\C-i" 'Info-query)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
98
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
99 (define-key help-map "k" 'describe-key)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
100 (define-key help-map "\C-k" 'Info-goto-emacs-key-command-node)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 (define-key help-map "l" 'view-lossage)
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
103 (define-key help-map "\C-l" 'describe-copying) ; on \C-c in FSFmacs
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 (define-key help-map "m" 'describe-mode)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
107 (define-key help-map "n" 'view-emacs-news)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 (define-key help-map "\C-n" 'view-emacs-news)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 (define-key help-map "p" 'finder-by-keyword)
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
111 (define-key help-map "\C-p" 'describe-pointer)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
112
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
113 (define-key help-map "q" 'help-quit)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 ;; Do this right with an autoload cookie in finder.el.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 ;;(autoload 'finder-by-keyword "finder"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 ;; "Find packages matching a given keyword." t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 (define-key help-map "s" 'describe-syntax)
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
120 (define-key help-map "S" 'view-sample-init-el)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 (define-key help-map "t" 'help-with-tutorial)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 (define-key help-map "v" 'describe-variable)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
126 (define-key help-map "w" 'where-is)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
127 (define-key help-map "\C-w" 'describe-no-warranty)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
129 ;; #### It would be nice if the code below to add hyperlinks was
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
130 ;; generalized. We would probably need a "hyperlink mode" from which
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
131 ;; help-mode is derived. This means we probably need multiple
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
132 ;; inheritance of modes! Thankfully this is not hard to implement; we
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
133 ;; already have the ability for a keymap to have multiple parents.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
134 ;; However, we'd have to define any multiply-inherited-from modes using
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
135 ;; a standard `define-mode' construction instead of manually doing it,
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
136 ;; because we don't want each guy calling `kill-all-local-variables' and
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
137 ;; messing up the previous one.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 (define-derived-mode help-mode view-major-mode "Help"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 "Major mode for viewing help text.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 Entry to this mode runs the normal hook `help-mode-hook'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 Commands:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 \\{help-mode-map}"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 (define-key help-mode-map "q" 'help-mode-quit)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 (define-key help-mode-map "Q" 'help-mode-bury)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 (define-key help-mode-map "f" 'find-function-at-point)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 (define-key help-mode-map "d" 'describe-function-at-point)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 (define-key help-mode-map "v" 'describe-variable-at-point)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 (define-key help-mode-map "i" 'Info-elisp-ref)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 (define-key help-mode-map "c" 'customize-variable)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 (define-key help-mode-map [tab] 'help-next-symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 (define-key help-mode-map [(shift tab)] 'help-prev-symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 (define-key help-mode-map "n" 'help-next-section)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 (define-key help-mode-map "p" 'help-prev-section)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 (defun describe-function-at-point ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 "Describe directly the function at point in the other window."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 (let ((symb (function-at-point)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 (when symb
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 (describe-function symb))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 (defun describe-variable-at-point ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 "Describe directly the variable at point in the other window."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 (let ((symb (variable-at-point)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 (when symb
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 (describe-variable symb))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 (defun help-next-symbol ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 "Move point to the next quoted symbol."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 (search-forward "`" nil t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 (defun help-prev-symbol ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 "Move point to the previous quoted symbol."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 (search-backward "'" nil t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 (defun help-next-section ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 "Move point to the next quoted symbol."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 (search-forward-regexp "^\\w+:" nil t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 (defun help-prev-section ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 "Move point to the previous quoted symbol."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 (search-backward-regexp "^\\w+:" nil t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 (defun help-mode-bury ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 "Bury the help buffer, possibly restoring the previous window configuration."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 (help-mode-quit t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 (defun help-mode-quit (&optional bury)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 "Exit from help mode, possibly restoring the previous window configuration.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 If the optional argument BURY is non-nil, the help buffer is buried,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 otherwise it is killed."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 (let ((buf (current-buffer)))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
203 (cond (help-window-config
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
204 (set-window-configuration help-window-config))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 ((not (one-window-p))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 (delete-window)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 (if bury
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 (bury-buffer buf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 (kill-buffer buf))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 (defun help-quit ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
215 (define-obsolete-function-alias 'deprecated-help-command 'help-for-help)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 ;;(define-key global-map 'backspace 'deprecated-help-command)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
219 (defconst tutorial-supported-languages
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
220 '(
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
221 ("Croatian" hr iso-8859-2)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
222 ("Czech" cs iso-8859-2)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
223 ("Dutch" nl iso-8859-1)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
224 ("English" nil raw-text)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
225 ("French" fr iso-8859-1)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
226 ("German" de iso-8859-1)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
227 ("Norwegian" no iso-8859-1)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
228 ("Polish" pl iso-8859-2)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
229 ("Romanian" ro iso-8859-2)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
230 ("Slovak" sk iso-8859-2)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
231 ("Slovenian" sl iso-8859-2)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
232 ("Spanish" es iso-8859-1)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
233 ("Swedish" se iso-8859-1)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
234 )
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
235 "Alist of supported languages in TUTORIAL files.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
236 Add languages here, as more are translated.")
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
237
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
238 ;; TUTORIAL arg is XEmacs addition
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
239 (defun help-with-tutorial (&optional tutorial language)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
240 "Select the XEmacs learn-by-doing tutorial.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
241 Optional arg TUTORIAL specifies the tutorial file; if not specified or
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
242 if this command is invoked interactively, the tutorial appropriate to
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
243 the current language environment is used. If there is no tutorial
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
244 written in that language, or if this version of XEmacs has no
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
245 international (Mule) support, the English-language tutorial is used.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
246 With a prefix argument, you are asked to select which language."
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
247 (interactive "i\nP")
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
248 (when (and language (consp language))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
249 (setq language
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
250 (if (featurep 'mule)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
251 (or (declare-fboundp (read-language-name 'tutorial "Language: "))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
252 (error "No tutorial file of the specified language"))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
253 (let ((completion-ignore-case t))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
254 (completing-read "Language: "
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
255 tutorial-supported-languages nil t)))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
256 (or language
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
257 (setq language
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
258 (if (featurep 'mule) (declare-boundp current-language-environment)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
259 "English")))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
260 (or tutorial
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
261 (setq tutorial
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
262 (cond ((featurep 'mule)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
263 (or (declare-fboundp (get-language-info language 'tutorial))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
264 "TUTORIAL"))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
265 ((equal language "English") "TUTORIAL")
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
266 (t (format "TUTORIAL.%s"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
267 (cadr (assoc language
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
268 tutorial-supported-languages)))))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
269 (let ((file (expand-file-name tutorial "~")))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
270 (delete-other-windows)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
271 (let ((buffer (or (get-file-buffer file)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
272 (create-file-buffer file)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
273 (window-configuration (current-window-configuration)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
274 (condition-case error-data
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
275 (progn
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
276 (switch-to-buffer buffer)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
277 (setq buffer-file-name file)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
278 (setq default-directory (expand-file-name "~/"))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
279 (setq buffer-auto-save-file-name nil)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
280 ;; Because of non-Mule users, TUTORIALs are not coded
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
281 ;; independently, so we must guess the coding according to
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
282 ;; the language.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
283 (let ((coding-system-for-read
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
284 (if (featurep 'mule)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
285 (with-fboundp 'get-language-info
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
286 (or (get-language-info language
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
287 'tutorial-coding-system)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
288 (car (get-language-info language
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
289 'coding-system))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
290 (nth 2 (assoc language tutorial-supported-languages)))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
291 (insert-file-contents (locate-data-file tutorial)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
292 (goto-char (point-min))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
293 ;; [The 'didactic' blank lines: possibly insert blank lines
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
294 ;; around <<nya nya nya>> and replace << >> with [ ].] No more
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
295 ;; didactic blank lines. It was just a bad idea, anyway. I
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
296 ;; rewrote the TUTORIAL so it doesn't need them. However, some
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
297 ;; tutorials in other languages haven't yet been updated. ####
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
298 ;; Delete this code when they're all updated.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
299 (if (re-search-forward "^<<.+>>" nil t)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
300 (let ((n (- (window-height (selected-window))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
301 (count-lines (point-min) (point-at-bol))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
302 6)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
303 (if (< n 12)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
304 (progn (beginning-of-line) (kill-line))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
305 ;; Some people get confused by the large gap
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
306 (delete-backward-char 2)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
307 (insert "]")
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
308 (beginning-of-line)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
309 (save-excursion
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
310 (delete-char 2)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
311 (insert "["))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
312 (newline (/ n 2))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
313 (next-line 1)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
314 (newline (- n (/ n 2))))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
315 (goto-char (point-min))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
316 (set-buffer-modified-p nil))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
317 ;; TUTORIAL was not found: kill the buffer and restore the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
318 ;; window configuration.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
319 (file-error (kill-buffer buffer)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
320 (set-window-configuration window-configuration)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
321 ;; Now, signal the error
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
322 (signal (car error-data) (cdr error-data)))))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 ;; used by describe-key, describe-key-briefly, insert-key-binding, etc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 (defun key-or-menu-binding (key &optional menu-flag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 "Return the command invoked by KEY.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 Like `key-binding', but handles menu events and toolbar presses correctly.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 KEY is any value returned by `next-command-event'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 MENU-FLAG is a symbol that should be set to t if KEY is a menu event,
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
330 or nil otherwise."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 (let (defn)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 (and menu-flag (set menu-flag nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 ;; If the key typed was really a menu selection, grab the form out
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 ;; of the event object and intuit the function that would be called,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 ;; and describe that instead.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 (if (and (vectorp key) (= 1 (length key))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 (or (misc-user-event-p (aref key 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 (eq (car-safe (aref key 0)) 'menu-selection)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 (let ((event (aref key 0)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 (setq defn (if (eventp event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 (list (event-function event) (event-object event))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 (cdr event)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 (and menu-flag (set menu-flag t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 (when (eq (car defn) 'eval)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 (setq defn (car (cdr defn))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 (when (eq (car-safe defn) 'call-interactively)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 (setq defn (car (cdr defn))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 (when (and (consp defn) (null (cdr defn)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 (setq defn (car defn))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 ;; else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 (setq defn (key-binding key)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 ;; kludge: if a toolbar button was pressed on, try to find the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 ;; binding of the toolbar button.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 (if (and (eq defn 'press-toolbar-button)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 (vectorp key)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 (button-press-event-p (aref key (1- (length key)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 ;; wait for the button release. We're on shaky ground here ...
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 (let ((event (next-command-event))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 button)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 (if (and (button-release-event-p event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 (event-over-toolbar-p event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 (eq 'release-and-activate-toolbar-button
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 (key-binding (vector event)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 (setq button (event-toolbar-button event)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 (toolbar-button-callback button)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 ;; if anything went wrong, try returning the binding of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 ;; the button-up event, of the original binding
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 (or (key-or-menu-binding (vector event))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 defn)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 ;; no toolbar kludge
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 defn)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 ))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 (defun describe-key-briefly (key &optional insert)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 "Print the name of the function KEY invokes. KEY is a string.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 If INSERT (the prefix arg) is non-nil, insert the message in the buffer."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 (interactive "kDescribe key briefly: \nP")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 (let ((standard-output (if insert (current-buffer) t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 defn menup)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 (setq defn (key-or-menu-binding key 'menup))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 (if (or (null defn) (integerp defn))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 (princ (format "%s is undefined" (key-description key)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 ;; If it's a keyboard macro which trivially invokes another command,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 ;; document that instead.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 (if (or (stringp defn) (vectorp defn))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 (setq defn (or (key-binding defn)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 defn)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 (let ((last-event (and (vectorp key)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 (aref key (1- (length key))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390 (princ (format (cond (insert
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 "%s (%s)")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 ((or (button-press-event-p last-event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 (button-release-event-p last-event))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 (gettext "%s at that spot runs the command %s"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 (gettext "%s runs the command %s")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 ;; This used to say 'This menu item' but it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 ;; could also be a scrollbar event. We can't
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 ;; distinguish at the moment.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 (if menup
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 (if insert "item" "This item")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 (key-description key))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 (if (symbolp defn) defn (prin1-to-string defn))))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 ;; #### this is a horrible piece of shit function that should
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 ;; not exist. In FSF 19.30 this function has gotten three times
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 ;; as long and has tons and tons of dumb shit checking
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 ;; special-display-buffer-names and such crap. I absolutely
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 ;; refuse to insert that Ebolification here. I wanted to delete
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 ;; this function entirely but Mly bitched.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 ;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 ;; If your user-land code calls this function, rewrite it to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 ;; call with-displaying-help-buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 (defun print-help-return-message (&optional function)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 "Display or return message saying how to restore windows after help command.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 Computes a message and applies the optional argument FUNCTION to it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 If FUNCTION is nil, applies `message' to it, thus printing it."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 (and (not (get-buffer-window standard-output))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 (funcall
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 (or function 'message)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 (concat
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 (substitute-command-keys
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 (if (one-window-p t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 (if pop-up-windows
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 (gettext "Type \\[delete-other-windows] to remove help window.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 (gettext "Type \\[switch-to-buffer] RET to remove help window."))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 (gettext "Type \\[switch-to-buffer-other-window] RET to restore the other window.")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 (substitute-command-keys
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 (gettext " \\[scroll-other-window] to scroll the help."))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 (defcustom help-selects-help-window t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 "*If nil, use the \"old Emacs\" behavior for Help buffers.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 This just displays the buffer in another window, rather than selecting
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 the window."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 :type 'boolean
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 :group 'help-appearance)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 (defcustom help-max-help-buffers 10
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 "*Maximum help buffers to allow before they start getting killed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 If this is a positive integer, before a help buffer is displayed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 by `with-displaying-help-buffer', any excess help buffers which
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 are not being displayed are first killed. Otherwise, if it is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 zero or nil, only one help buffer, \"*Help*\" is ever used."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 :type '(choice integer (const :tag "None" nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 :group 'help-appearance)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 (defvar help-buffer-list nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 "List of help buffers used by `help-register-and-maybe-prune-excess'")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 (defun help-register-and-maybe-prune-excess (newbuf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 "Register use of a help buffer and possibly kill any excess ones."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 ;; remove new buffer from list
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 (setq help-buffer-list (remove newbuf help-buffer-list))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 ;; maybe kill excess help buffers
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 (if (and (integerp help-max-help-buffers)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 (> (length help-buffer-list) help-max-help-buffers))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 (let ((keep-list nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 (num-kill (- (length help-buffer-list)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 help-max-help-buffers)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 (while help-buffer-list
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 (let ((buf (car help-buffer-list)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 (if (and (or (equal buf newbuf) (get-buffer buf))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 (string-match "^*Help" buf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 (save-excursion (set-buffer buf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 (eq major-mode 'help-mode)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 (if (and (>= num-kill (length help-buffer-list))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 (not (get-buffer-window buf t t)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 (kill-buffer buf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470 (setq keep-list (cons buf keep-list)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 (setq help-buffer-list (cdr help-buffer-list)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 (setq help-buffer-list (nreverse keep-list))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 ;; push new buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 (setq help-buffer-list (cons newbuf help-buffer-list)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 (defvar help-buffer-prefix-string "Help"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 "Initial string to use in constructing help buffer names.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 You should never set this directory, only let-bind it.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480 (defun help-buffer-name (name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 "Return a name for a Help buffer using string NAME for context."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 (if (and (integerp help-max-help-buffers)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 (> help-max-help-buffers 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 (stringp name))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 (if help-buffer-prefix-string
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 (format "*%s: %s*" help-buffer-prefix-string name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 (format "*%s*" name))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 (format "*%s*" help-buffer-prefix-string)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 ;; Use this function for displaying help when C-h something is pressed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 ;; or in similar situations. Do *not* use it when you are displaying
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 ;; a help message and then prompting for input in the minibuffer --
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 ;; this macro usually selects the help buffer, which is not what you
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 ;; want in those situations.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 ;; #### Should really be a macro to eliminate the requirement of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 ;; caller to code a lambda form in THUNK -- mrb
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 ;; #### BEFORE you rush to make this a macro, think about backward
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 ;; compatibility. The right way would be to create a macro with
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 ;; another name (which is a shame, because w-d-h-b is a perfect name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 ;; for a macro) that uses with-displaying-help-buffer internally.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
504 (defcustom mode-for-help 'help-mode
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
505 "*Mode that help buffers are put into.")
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
506
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
507 (defvar help-sticky-window nil
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
508 ;; Window into which help buffers will be displayed, rather than
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
509 ;; always searching for a new one. This is INTERNAL and liable to
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
510 ;; change its interface and/or name at any moment. It should be
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
511 ;; bound, not set.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
512 )
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
513
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
514 (defvar help-window-config nil)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
515
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
516 (make-variable-buffer-local 'help-window-config)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
517 (put 'help-window-config 'permanent-local t)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
518
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 (defun with-displaying-help-buffer (thunk &optional name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 "Form which makes a help buffer with given NAME and evaluates BODY there.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 The actual name of the buffer is generated by the function `help-buffer-name'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 (let* ((winconfig (current-window-configuration))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 (was-one-window (one-window-p))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 (buffer-name (help-buffer-name name))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525 (help-not-visible
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 (not (and (windows-of-buffer buffer-name) ;shortcut
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 (memq (selected-frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 (mapcar 'window-frame
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 (windows-of-buffer buffer-name)))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530 (help-register-and-maybe-prune-excess buffer-name)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
531 ;; if help-sticky-window is bogus or deleted, get rid of it.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
532 (if (and help-sticky-window (or (not (windowp help-sticky-window))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
533 (not (window-live-p help-sticky-window))))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
534 (setq help-sticky-window nil))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
535 (prog1
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
536 (let ((temp-buffer-show-function
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
537 (if help-sticky-window
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
538 #'(lambda (buffer)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
539 (set-window-buffer help-sticky-window buffer))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
540 temp-buffer-show-function)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
541 (with-output-to-temp-buffer buffer-name
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
542 (prog1 (funcall thunk)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
543 (save-excursion
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
544 (set-buffer standard-output)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
545 (funcall mode-for-help)))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 (let ((helpwin (get-buffer-window buffer-name)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 (when helpwin
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
548 ;; If the *Help* buffer is already displayed on this
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
549 ;; frame, don't override the previous configuration
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
550 (when help-not-visible
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
551 (with-current-buffer (window-buffer helpwin)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
552 (setq help-window-config winconfig)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 (when help-selects-help-window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 (select-window helpwin))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 (cond ((eq helpwin (selected-window))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 (display-message 'command
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 (substitute-command-keys "Type \\[help-mode-quit] to remove help window, \\[scroll-up] to scroll the help.")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 (was-one-window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559 (display-message 'command
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 (substitute-command-keys "Type \\[delete-other-windows] to remove help window, \\[scroll-other-window] to scroll the help.")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 (display-message 'command
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 (substitute-command-keys "Type \\[switch-to-buffer-other-window] to restore the other window, \\[scroll-other-window] to scroll the help.")))))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 (defun describe-key (key)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 "Display documentation of the function invoked by KEY.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 KEY is a string, or vector of events.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 When called interactively, KEY may also be a menu selection."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 (interactive "kDescribe key: ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 (let ((defn (key-or-menu-binding key))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 (key-string (key-description key)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572 (if (or (null defn) (integerp defn))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
573 (message "%s is undefined" key-string)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574 (with-displaying-help-buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575 (lambda ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576 (princ key-string)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 (princ " runs ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578 (if (symbolp defn)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579 (princ (format "`%s'" defn))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580 (princ defn))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 (princ "\n\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582 (cond ((or (stringp defn) (vectorp defn))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 (let ((cmd (key-binding defn)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 (if (not cmd)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 (princ "a keyboard macro")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 (princ "a keyboard macro which runs the command ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 (princ cmd)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 (princ ":\n\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 (if (documentation cmd) (princ (documentation cmd)))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 ((and (consp defn) (not (eq 'lambda (car-safe defn))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 (let ((describe-function-show-arglist nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 (describe-function-1 (car defn))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 ((symbolp defn)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 (describe-function-1 defn))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 ((documentation defn)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 (princ (documentation defn)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 (princ "not documented"))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 (format "key `%s'" key-string)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 (defun describe-mode ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 "Display documentation of current major mode and minor modes.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 For this to work correctly for a minor mode, the mode's indicator variable
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 \(listed in `minor-mode-alist') must also be a function whose documentation
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606 describes the minor mode."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608 (with-displaying-help-buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 (lambda ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610 ;; XEmacs change: print the major-mode documentation before
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 ;; the minor modes.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612 (princ mode-name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613 (princ " mode:\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 (princ (documentation major-mode))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615 (princ "\n\n----\n\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616 (let ((minor-modes minor-mode-alist))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617 (while minor-modes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618 (let* ((minor-mode (car (car minor-modes)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619 (indicator (car (cdr (car minor-modes)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620 ;; Document a minor mode if it is listed in minor-mode-alist,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621 ;; bound locally in this buffer, non-nil, and has a function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622 ;; definition.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623 (if (and (boundp minor-mode)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624 (symbol-value minor-mode)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625 (fboundp minor-mode))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626 (let ((pretty-minor-mode minor-mode))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627 (if (string-match "-mode\\'" (symbol-name minor-mode))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
628 (setq pretty-minor-mode
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
629 (capitalize
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
630 (substring (symbol-name minor-mode)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
631 0 (match-beginning 0)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632 (while (and (consp indicator) (extentp (car indicator)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
633 (setq indicator (cdr indicator)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634 (while (and indicator (symbolp indicator))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635 (setq indicator (symbol-value indicator)))
732
b9b8621c2439 [xemacs-hg @ 2002-01-22 14:16:38 by youngs]
youngs
parents: 622
diff changeset
636 (princ (format "%s minor mode (%s):\n"
b9b8621c2439 [xemacs-hg @ 2002-01-22 14:16:38 by youngs]
youngs
parents: 622
diff changeset
637 pretty-minor-mode
b9b8621c2439 [xemacs-hg @ 2002-01-22 14:16:38 by youngs]
youngs
parents: 622
diff changeset
638 (if indicator
b9b8621c2439 [xemacs-hg @ 2002-01-22 14:16:38 by youngs]
youngs
parents: 622
diff changeset
639 (format "indicator%s" indicator)
b9b8621c2439 [xemacs-hg @ 2002-01-22 14:16:38 by youngs]
youngs
parents: 622
diff changeset
640 "no indicator")))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 (princ (documentation minor-mode))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 (princ "\n\n----\n\n"))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 (setq minor-modes (cdr minor-modes)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 (format "%s mode" mode-name)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646 ;; So keyboard macro definitions are documented correctly
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 (fset 'defining-kbd-macro (symbol-function 'start-kbd-macro))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
649 ;; view a read-only file intelligently
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
650 (defun Help-find-file (file)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
651 (if (fboundp 'view-file)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
652 (view-file file)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
653 (find-file-read-only file)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
654 (goto-char (point-min))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
655
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 (defun describe-distribution ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 "Display info on how to obtain the latest version of XEmacs."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658 (interactive)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
659 (Help-find-file (locate-data-file "DISTRIB")))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661 (defun describe-beta ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 "Display info on how to deal with Beta versions of XEmacs."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 (interactive)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
664 (Help-find-file (locate-data-file "BETA")))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666 (defun describe-copying ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667 "Display info on how you may redistribute copies of XEmacs."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
668 (interactive)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
669 (Help-find-file (locate-data-file "COPYING")))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
670
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671 (defun describe-pointer ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672 "Show a list of all defined mouse buttons, and their definitions."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
674 (describe-bindings nil t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676 (defun describe-project ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677 "Display info on the GNU project."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678 (interactive)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
679 (Help-find-file (locate-data-file "GNU")))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681 (defun describe-no-warranty ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682 "Display info on all the kinds of warranty XEmacs does NOT have."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
683 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
684 (describe-copying)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
685 (let (case-fold-search)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
686 (search-forward "NO WARRANTY")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
687 (recenter 0)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
689 (defun describe-bindings (&optional prefix mouse-only-p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690 "Show a list of all defined keys, and their definitions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691 The list is put in a buffer, which is displayed.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
692 If optional first argument PREFIX is supplied, only commands
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
693 which start with that sequence of keys are described.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
694 If optional second argument MOUSE-ONLY-P (prefix arg, interactively)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
695 is non-nil then only the mouse bindings are displayed."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
696 (interactive (list nil current-prefix-arg))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
697 (with-displaying-help-buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
698 (lambda ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
699 (describe-bindings-1 prefix mouse-only-p))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
700 (format "bindings for %s" major-mode)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
701
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
702 (defun describe-bindings-1 (&optional prefix mouse-only-p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
703 (let ((heading (if mouse-only-p
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
704 (gettext "button binding\n------ -------\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
705 (gettext "key binding\n--- -------\n")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
706 (buffer (current-buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
707 (minor minor-mode-map-alist)
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
708 (extent-maps (mapcar-extents
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
709 'extent-keymap
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
710 nil (current-buffer) (point) (point) nil 'keymap))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711 (local (current-local-map))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712 (shadow '()))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713 (set-buffer standard-output)
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
714 (while extent-maps
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
715 (insert "Bindings for Text Region:\n"
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
716 heading)
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
717 (describe-bindings-internal
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
718 (car extent-maps) nil shadow prefix mouse-only-p)
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
719 (insert "\n")
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
720 (setq shadow (cons (car extent-maps) shadow)
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
721 extent-maps (cdr extent-maps)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722 (while minor
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723 (let ((sym (car (car minor)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
724 (map (cdr (car minor))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725 (if (symbol-value-in-buffer sym buffer nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727 (insert (format "Minor Mode Bindings for `%s':\n"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
728 sym)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729 heading)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730 (describe-bindings-internal map nil shadow prefix mouse-only-p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731 (insert "\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
732 (setq shadow (cons map shadow))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
733 (setq minor (cdr minor))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
734 (if local
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
735 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
736 (insert "Local Bindings:\n" heading)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737 (describe-bindings-internal local nil shadow prefix mouse-only-p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738 (insert "\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
739 (setq shadow (cons local shadow))))
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
740 (if (console-on-window-system-p)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
741 (progn
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
742 (insert "Global Window-System-Only Bindings:\n" heading)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
743 (describe-bindings-internal global-window-system-map nil
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
744 shadow prefix mouse-only-p)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
745 (push global-window-system-map shadow))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
746 (insert "Global TTY-Only Bindings:\n" heading)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
747 (describe-bindings-internal global-tty-map nil
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
748 shadow prefix mouse-only-p)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
749 (push global-tty-map shadow))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
750 (insert "\nGlobal Bindings:\n" heading)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
751 (describe-bindings-internal (current-global-map)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
752 nil shadow prefix mouse-only-p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
753 (when (and prefix function-key-map (not mouse-only-p))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
754 (insert "\nFunction key map translations:\n" heading)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
755 (describe-bindings-internal function-key-map nil nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
756 prefix mouse-only-p))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
757 (set-buffer buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
758 standard-output))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
759
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
760 (defun describe-prefix-bindings ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
761 "Describe the bindings of the prefix used to reach this command.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
762 The prefix described consists of all but the last event
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
763 of the key sequence that ran this command."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
764 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
765 (let* ((key (this-command-keys))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
766 (prefix (make-vector (1- (length key)) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
767 i)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
768 (setq i 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
769 (while (< i (length prefix))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
770 (aset prefix i (aref key i))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
771 (setq i (1+ i)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
772 (with-displaying-help-buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
773 (lambda ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
774 (princ "Key bindings starting with ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
775 (princ (key-description prefix))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
776 (princ ":\n\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
777 (describe-bindings-1 prefix nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
778 (format "%s prefix" (key-description prefix)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
779
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
780 ;; Make C-h after a prefix, when not specifically bound,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
781 ;; run describe-prefix-bindings.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
782 (setq prefix-help-command 'describe-prefix-bindings)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
783
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
784 (defun describe-installation ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
785 "Display a buffer showing information about this XEmacs was compiled."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
786 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
787 (if (and (boundp 'Installation-string)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
788 (stringp Installation-string))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
789 (with-displaying-help-buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
790 (lambda ()
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
791 (princ
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
792 (if (fboundp 'decode-coding-string)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
793 (decode-coding-string Installation-string 'automatic-conversion)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
794 Installation-string)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
795 "Installation")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
796 (error "No Installation information available.")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
797
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
798 (defun view-emacs-news ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
799 "Display info on recent changes to XEmacs."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
800 (interactive)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
801 (Help-find-file (locate-data-file "NEWS")))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
802
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
803 (defun xemacs-www-page ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
804 "Go to the XEmacs World Wide Web page."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
805 (interactive)
776
79940b592197 [xemacs-hg @ 2002-03-15 07:43:14 by ben]
ben
parents: 771
diff changeset
806 (if-fboundp 'browse-url
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
807 (browse-url "http://www.xemacs.org/")
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
808 (error "xemacs-www-page requires browse-url")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
809
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
810 (defun xemacs-www-faq ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
811 "View the latest and greatest XEmacs FAQ using the World Wide Web."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
812 (interactive)
776
79940b592197 [xemacs-hg @ 2002-03-15 07:43:14 by ben]
ben
parents: 771
diff changeset
813 (if-fboundp 'browse-url
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
814 (browse-url "http://www.xemacs.org/faq/index.html")
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
815 (error "xemacs-www-faq requires browse-url")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
816
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
817 (defun xemacs-local-faq ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
818 "View the local copy of the XEmacs FAQ.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
819 If you have access to the World Wide Web, you should use `xemacs-www-faq'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
820 instead, to ensure that you get the most up-to-date information."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
821 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
822 (save-window-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
823 (info)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
824 (Info-find-node "xemacs-faq" "Top"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
825 (switch-to-buffer "*info*"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
826
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
827 (defun view-sample-init-el ()
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
828 "Display the sample init.el file."
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
829 (interactive)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
830 (Help-find-file (locate-data-file "sample.init.el")))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
831
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
832 (defcustom view-lossage-key-count 100
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
833 "*Number of keys `view-lossage' shows.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
834 The maximum number of available keys is governed by `recent-keys-ring-size'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
835 :type 'integer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
836 :group 'help)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
837
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
838 (defcustom view-lossage-message-count 100
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
839 "*Number of minibuffer messages `view-lossage' shows."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
840 :type 'integer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
841 :group 'help)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
842
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
843 (defun print-recent-messages (n)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
844 "Print N most recent messages to standard-output, most recent first.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
845 If N is nil, all messages will be printed."
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
846 (clear-message) ;; make sure current message goes into log
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
847 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
848 (let ((buffer (get-buffer-create " *Message-Log*"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
849 oldpoint extent)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
850 (goto-char (point-max buffer) buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
851 (set-buffer standard-output)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
852 (while (and (not (bobp buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
853 (or (null n) (>= (decf n) 0)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
854 (setq oldpoint (point buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
855 (setq extent (extent-at oldpoint buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
856 'message-multiline nil 'before))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
857 ;; If the message was multiline, move all the way to the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
858 ;; beginning.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
859 (if extent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
860 (goto-char (extent-start-position extent) buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
861 (forward-line -1 buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
862 (insert-buffer-substring buffer (point buffer) oldpoint)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
863
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
864 (defun view-warnings ()
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
865 "Display warnings issued."
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
866 (interactive)
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
867 (with-displaying-help-buffer
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
868 (lambda ()
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
869 (let ((buf (get-buffer "*Warnings*")))
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
870 (when buf
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
871 (save-excursion
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
872 (set-buffer standard-output)
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
873 (map-extents
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
874 #'(lambda (extent arg)
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
875 (goto-char (point-min))
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
876 (insert (extent-string extent)))
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
877 buf)))))
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
878 "warnings"))
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
879
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
880 (defun view-lossage (&optional no-keys)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
881 "Display recent input keystrokes and recent minibuffer messages.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
882 The number of keys shown is controlled by `view-lossage-key-count'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
883 The number of messages shown is controlled by `view-lossage-message-count'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
884 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
885 (with-displaying-help-buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
886 (lambda ()
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
887 (unless no-keys
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
888 (princ (key-description (recent-keys view-lossage-key-count)))
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
889 (save-excursion
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
890 (set-buffer standard-output)
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
891 (goto-char (point-min))
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
892 (insert "Recent keystrokes:\n\n")
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
893 (while (progn (move-to-column 50) (not (eobp)))
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
894 (search-forward " " nil t)
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
895 (insert "\n")))
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
896 (princ "\n\n\n"))
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
897 ;; Copy the messages from " *Message-Log*", reversing their order and
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
898 ;; handling multiline messages correctly.
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
899 (princ "Recent minibuffer messages (most recent first):\n\n")
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
900 (print-recent-messages view-lossage-message-count))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
901 "lossage"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
902
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
903 (define-function 'help 'help-for-help)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
904
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
905 (make-help-screen help-for-help
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
906 "A B C F I K L M N P S T V W C-c C-d C-f C-i C-k C-n C-w; ? for more help:"
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
907 (concat
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
908 "Type a Help option:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
909 \(Use SPC or DEL to scroll through this text. Type \\<help-map>\\[help-quit] to exit the Help command.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
910
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
911 Help on key bindings:
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
912
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
913 \\[describe-bindings] Table of all key bindings.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
914 \\[describe-key-briefly] Type a key sequence or select a menu item;
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
915 it displays the corresponding command name.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
916 \\[describe-key] Type a key sequence or select a menu item;
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
917 it displays the documentation for the command bound to that key.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
918 (Terser but more up-to-date than what's in the manual.)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
919 \\[Info-goto-emacs-key-command-node] Type a key sequence or select a menu item;
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
920 it jumps to the full documentation in the XEmacs User's Manual
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
921 for the corresponding command.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
922 \\[view-lossage] Recent input keystrokes and minibuffer messages.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
923 \\[describe-mode] Documentation of current major and minor modes.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
924 \\[describe-pointer] Table of all mouse-button bindings.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
925 \\[where-is] Type a command name; it displays which keystrokes invoke that command.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
926
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
927 Help on functions and variables:
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
928
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
929 \\[hyper-apropos] Type a substring; it shows a hypertext list of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
930 functions and variables that contain that substring.
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
931 \\[command-apropos] Older version of apropos; superseded by previous command.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
932 \\[apropos-documentation] Type a substring; it shows a hypertext list of
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
933 functions and variables containing that substring anywhere
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
934 in their documentation.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
935 \\[Info-goto-emacs-command-node] Type a command name; it jumps to the full documentation
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
936 in the XEmacs User's Manual.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
937 \\[describe-function] Type a command or function name; it shows its documentation.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
938 (Terser but more up-to-date than what's in the manual.)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
939 \\[Info-elisp-ref] Type a function name; it jumps to the full documentation
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
940 in the XEmacs Lisp Reference Manual.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
941 \\[Info-search-index-in-xemacs-and-lispref] Type a substring; it looks it up in the indices of both
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
942 the XEmacs User's Manual and the XEmacs Lisp Reference Manual.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
943 It jumps to the first match (preferring an exact match); you
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
944 can use `\\<Info-mode-map>\\[Info-index-next]\\<help-map>' to successively visit other matches.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
945 \\[describe-variable] Type a variable name; it displays its documentation and value.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
946
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
947 Miscellaneous:
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
948
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
949 "
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
950 (if (string-match "beta" emacs-version)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
951 "\\[describe-beta] Special considerations about running a beta version of XEmacs.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
952 "
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
953 "")
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
954 "
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
955 \\[customize] Customize Emacs options.
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
956 \\[describe-distribution] How to obtain XEmacs.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
957 \\[describe-last-error] Information about the most recent error.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
958 \\[xemacs-local-faq] Local copy of the XEmacs FAQ.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
959 \\[info] Info documentation reader.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
960 \\[Info-query] Type an Info file name; it displays it in Info reader.
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
961 \\[describe-copying] XEmacs copying permission (General Public License).
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
962 \\[view-emacs-news] News of recent XEmacs changes.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
963 \\[finder-by-keyword] Type a topic keyword; it finds matching packages.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
964 \\[describe-syntax] Contents of syntax table with explanations.
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
965 \\[view-sample-init-el] View the sample init.el that comes with XEmacs.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
966 \\[help-with-tutorial] XEmacs learn-by-doing tutorial.
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
967 \\[describe-no-warranty] Information on absence of warranty for XEmacs."
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
968 )
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
969 help-map)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
970
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
971 (defmacro with-syntax-table (syntab &rest body)
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
972 "Evaluate BODY with the SYNTAB as the current syntax table."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
973 `(let ((stab (syntax-table)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
974 (unwind-protect
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
975 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
976 (set-syntax-table (copy-syntax-table ,syntab))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
977 ,@body)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
978 (set-syntax-table stab))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
979 (put 'with-syntax-table 'lisp-indent-function 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
980 (put 'with-syntax-table 'edebug-form-spec '(form body))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
981
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
982 (defun function-called-at-point ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
983 "Return the function which is called by the list containing point.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
984 If that gives no function, return the function whose name is around point.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
985 If that doesn't give a function, return nil."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
986 (or (ignore-errors
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
987 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
988 (save-restriction
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
989 (narrow-to-region (max (point-min) (- (point) 1000))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
990 (point-max))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
991 (backward-up-list 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
992 (forward-char 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
993 (let (obj)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
994 (setq obj (read (current-buffer)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
995 (and (symbolp obj) (fboundp obj) obj)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
996 (ignore-errors
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
997 (with-syntax-table emacs-lisp-mode-syntax-table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
998 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
999 (or (not (zerop (skip-syntax-backward "_w")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1000 (eq (char-syntax (char-after (point))) ?w)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1001 (eq (char-syntax (char-after (point))) ?_)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1002 (forward-sexp -1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1003 (skip-chars-forward "`'")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1004 (let ((obj (read (current-buffer))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1005 (and (symbolp obj) (fboundp obj) obj)))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1006
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1007 (defun function-at-point ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1008 "Return the function whose name is around point.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1009 If that gives no function, return the function which is called by the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1010 list containing point. If that doesn't give a function, return nil."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1011 (or (ignore-errors
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1012 (with-syntax-table emacs-lisp-mode-syntax-table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1013 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1014 (or (not (zerop (skip-syntax-backward "_w")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1015 (eq (char-syntax (char-after (point))) ?w)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1016 (eq (char-syntax (char-after (point))) ?_)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1017 (forward-sexp -1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1018 (skip-chars-forward "`'")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1019 (let ((obj (read (current-buffer))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1020 (and (symbolp obj) (fboundp obj) obj)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1021 (ignore-errors
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1022 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1023 (save-restriction
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1024 (narrow-to-region (max (point-min) (- (point) 1000))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1025 (point-max))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1026 (backward-up-list 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1027 (forward-char 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1028 (let (obj)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1029 (setq obj (read (current-buffer)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1030 (and (symbolp obj) (fboundp obj) obj)))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1031
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1032 (defun function-at-event (event)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1033 "Return the function whose name is around the position of EVENT.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1034 EVENT should be a mouse event. When calling from a popup or context menu,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1035 use `last-popup-menu-event' to find out where the mouse was clicked.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1036 \(You cannot use (interactive \"e\"), unfortunately. This returns a
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1037 misc-user event.)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1038
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1039 If the event contains no position, or the position is not over text, or
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1040 there is no function around that point, nil is returned."
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1041 (if (and event (event-buffer event) (event-point event))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1042 (save-excursion
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1043 (set-buffer (event-buffer event))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1044 (goto-char (event-point event))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1045 (function-at-point))))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1046
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1047 ;; Default to nil for the non-hackers? Not until we find a way to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1048 ;; distinguish hackers from non-hackers automatically!
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1049 (defcustom describe-function-show-arglist t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1050 "*If non-nil, describe-function will show its arglist,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1051 unless the function is autoloaded."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1052 :type 'boolean
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1053 :group 'help-appearance)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1054
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1055 (defun describe-symbol-find-file (symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1056 (loop for (file . load-data) in load-history
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1057 do (when (memq symbol load-data)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1058 (return file))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1059
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1060 (define-obsolete-function-alias
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1061 'describe-function-find-file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1062 'describe-symbol-find-file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1063
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1064 (defun describe-function (function)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1065 "Display the full documentation of FUNCTION (a symbol).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1066 When run interactively, it defaults to any function found by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1067 `function-at-point'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1068 (interactive
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1069 (let* ((fn (function-at-point))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1070 (val (let ((enable-recursive-minibuffers t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1071 (completing-read
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1072 (if fn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1073 (format (gettext "Describe function (default %s): ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1074 fn)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1075 (gettext "Describe function: "))
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
1076 obarray 'fboundp t nil 'function-history
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
1077 (symbol-name fn)))))
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
1078 (list (intern val))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1079 (with-displaying-help-buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1080 (lambda ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1081 (describe-function-1 function)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1082 ;; Return the text we displayed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1083 (buffer-string nil nil standard-output))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1084 (format "function `%s'" function)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1085
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1086 (defun function-obsolete-p (function)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1087 "Return non-nil if FUNCTION is obsolete."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1088 (not (null (get function 'byte-obsolete-info))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1089
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1090 (defun function-obsoleteness-doc (function)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1091 "If FUNCTION is obsolete, return a string describing this."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1092 (let ((obsolete (get function 'byte-obsolete-info)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1093 (if obsolete
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1094 (format "Obsolete; %s"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1095 (if (stringp (car obsolete))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1096 (car obsolete)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1097 (format "use `%s' instead." (car obsolete)))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1098
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1099 (defun function-compatible-p (function)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1100 "Return non-nil if FUNCTION is present for Emacs compatibility."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1101 (not (null (get function 'byte-compatible-info))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1102
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1103 (defun function-compatibility-doc (function)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1104 "If FUNCTION is Emacs compatible, return a string describing this."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1105 (let ((compatible (get function 'byte-compatible-info)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1106 (if compatible
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1107 (format "Emacs Compatible; %s"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1108 (if (stringp (car compatible))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1109 (car compatible)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1110 (format "use `%s' instead." (car compatible)))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1111
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1112 ;Here are all the possibilities below spelled out, for the benefit
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1113 ;of the I18N3 snarfer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1114 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1115 ;(gettext "a built-in function")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1116 ;(gettext "an interactive built-in function")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1117 ;(gettext "a built-in macro")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1118 ;(gettext "an interactive built-in macro")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1119 ;(gettext "a compiled Lisp function")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1120 ;(gettext "an interactive compiled Lisp function")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1121 ;(gettext "a compiled Lisp macro")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1122 ;(gettext "an interactive compiled Lisp macro")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1123 ;(gettext "a Lisp function")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1124 ;(gettext "an interactive Lisp function")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1125 ;(gettext "a Lisp macro")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1126 ;(gettext "an interactive Lisp macro")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1127 ;(gettext "a mocklisp function")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1128 ;(gettext "an interactive mocklisp function")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1129 ;(gettext "a mocklisp macro")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1130 ;(gettext "an interactive mocklisp macro")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1131 ;(gettext "an autoloaded Lisp function")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1132 ;(gettext "an interactive autoloaded Lisp function")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1133 ;(gettext "an autoloaded Lisp macro")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1134 ;(gettext "an interactive autoloaded Lisp macro")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1135
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1136 ;; taken out of `describe-function-1'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1137 (defun function-arglist (function)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1138 "Return a string giving the argument list of FUNCTION.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1139 For example:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1140
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1141 (function-arglist 'function-arglist)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1142 => (function-arglist FUNCTION)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1143
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1144 This function is used by `describe-function-1' to list function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1145 arguments in the standard Lisp style."
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 430
diff changeset
1146 (let* ((fnc (indirect-function function))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 430
diff changeset
1147 (fndef (if (eq (car-safe fnc) 'macro)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 430
diff changeset
1148 (cdr fnc)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 430
diff changeset
1149 fnc))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1150 (arglist
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 430
diff changeset
1151 (cond ((compiled-function-p fndef)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 430
diff changeset
1152 (compiled-function-arglist fndef))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 430
diff changeset
1153 ((eq (car-safe fndef) 'lambda)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 430
diff changeset
1154 (nth 1 fndef))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 430
diff changeset
1155 ((subrp fndef)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 430
diff changeset
1156 (let* ((doc (documentation function))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 430
diff changeset
1157 (args (and (string-match
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 430
diff changeset
1158 "[\n\t ]*\narguments: ?(\\(.*\\))\n?\\'"
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 430
diff changeset
1159 doc)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 430
diff changeset
1160 (match-string 1 doc))))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 430
diff changeset
1161 ;; If there are no arguments documented for the
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 430
diff changeset
1162 ;; subr, rather don't print anything.
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 430
diff changeset
1163 (cond ((null args) t)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 430
diff changeset
1164 ((equal args "") nil)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 430
diff changeset
1165 (args))))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 430
diff changeset
1166 (t t))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1167 (cond ((listp arglist)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1168 (prin1-to-string
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1169 (cons function (mapcar (lambda (arg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1170 (if (memq arg '(&optional &rest))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1171 arg
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1172 (intern (upcase (symbol-name arg)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1173 arglist))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1174 t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1175 ((stringp arglist)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1176 (format "(%s %s)" function arglist)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1177
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1178 (defun function-documentation (function &optional strip-arglist)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1179 "Return a string giving the documentation for FUNCTION, if any.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1180 If the optional argument STRIP-ARGLIST is non-nil, remove the arglist
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1181 part of the documentation of internal subroutines."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1182 (let ((doc (condition-case nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1183 (or (documentation function)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1184 (gettext "not documented"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1185 (void-function ""))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1186 (if (and strip-arglist
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1187 (string-match "[\n\t ]*\narguments: ?(\\(.*\\))\n?\\'" doc))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1188 (setq doc (substring doc 0 (match-beginning 0))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1189 doc))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1190
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1191 ;; replacement for `princ' that puts the text in the specified face,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1192 ;; if possible
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1193 (defun Help-princ-face (object face)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1194 (cond ((bufferp standard-output)
464
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1195 (let ((opoint (point standard-output)))
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1196 (princ object)
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1197 (put-nonduplicable-text-property opoint (point standard-output)
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1198 'face face standard-output)))
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1199 ((markerp standard-output)
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1200 (let ((buf (marker-buffer standard-output))
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1201 (pos (marker-position standard-output)))
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1202 (princ object)
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1203 (put-nonduplicable-text-property
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1204 pos (marker-position standard-output) 'face face buf)))
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1205 (t princ object)))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1206
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1207 ;; replacement for `prin1' that puts the text in the specified face,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1208 ;; if possible
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1209 (defun Help-prin1-face (object face)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1210 (cond ((bufferp standard-output)
464
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1211 (let ((opoint (point standard-output)))
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1212 (prin1 object)
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1213 (put-nonduplicable-text-property opoint (point standard-output)
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1214 'face face standard-output)))
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1215 ((markerp standard-output)
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1216 (let ((buf (marker-buffer standard-output))
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1217 (pos (marker-position standard-output)))
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1218 (prin1 object)
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1219 (put-nonduplicable-text-property
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1220 pos (marker-position standard-output) 'face face buf)))
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1221 (t prin1 object)))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1222
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1223 (defvar help-symbol-regexp
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1224 (let ((sym-char "[+a-zA-Z0-9_:*]")
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1225 (sym-char-no-dash "[-+a-zA-Z0-9_:*]"))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1226 (concat "\\("
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1227 ;; a symbol with a - in it.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1228 "\\<\\(" sym-char-no-dash "+\\(-" sym-char-no-dash "+\\)+\\)\\>"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1229 "\\|"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1230 "`\\(" sym-char "+\\)'"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1231 "\\)")))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1232
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1233 (defun help-symbol-run-function-1 (ev ex fun)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1234 (let ((help-sticky-window
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1235 ;; if we were called from a help buffer, make sure the new help
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1236 ;; goes in the same window.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1237 (if (and (event-buffer ev)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1238 (symbol-value-in-buffer 'help-window-config
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1239 (event-buffer ev)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1240 (event-window ev)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1241 help-sticky-window)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1242 (funcall fun (extent-property ex 'help-symbol))))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1243
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1244 (defun help-symbol-run-function (fun)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1245 (let ((ex (extent-at-event last-popup-menu-event 'help-symbol)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1246 (when ex
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1247 (help-symbol-run-function-1 last-popup-menu-event ex fun))))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1248
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1249 (defvar help-symbol-function-context-menu
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1250 '(["View %_Documentation" (help-symbol-run-function 'describe-function)]
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1251 ["Find %_Function Source" (help-symbol-run-function 'find-function)]
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1252 ["Find %_Tag" (help-symbol-run-function 'find-tag)]
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1253 ))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1254
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1255 (defvar help-symbol-variable-context-menu
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1256 '(["View %_Documentation" (help-symbol-run-function 'describe-variable)]
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1257 ["Find %_Variable Source" (help-symbol-run-function 'find-variable)]
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1258 ["Find %_Tag" (help-symbol-run-function 'find-tag)]
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1259 ))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1260
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1261 (defvar help-symbol-function-and-variable-context-menu
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1262 '(["View Function %_Documentation" (help-symbol-run-function
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1263 'describe-function)]
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1264 ["View Variable D%_ocumentation" (help-symbol-run-function
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1265 'describe-variable)]
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1266 ["Find %_Function Source" (help-symbol-run-function 'find-function)]
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1267 ["Find %_Variable Source" (help-symbol-run-function 'find-variable)]
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1268 ["Find %_Tag" (help-symbol-run-function 'find-tag)]
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1269 ))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1270
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1271 (defun frob-help-extents (buffer)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1272 ;; Look through BUFFER, starting at the buffer's point and continuing
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1273 ;; till end of file, and find documented functions and variables.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1274 ;; any such symbol found is tagged with an extent, that sets up these
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1275 ;; properties:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1276 ;; 1. mouse-face is 'highlight (so the extent gets highlighted on mouse over)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1277 ;; 2. help-symbol is the name of the symbol.
464
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1278 ;; 3. face is 'hyper-apropos-hyperlink.
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1279 ;; 4. context-menu is a list of context menu items, specific to whether
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1280 ;; the symbol is a function, variable, or both.
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1281 ;; 5. activate-function will cause the function or variable to be described,
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1282 ;; replacing the existing help contents.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1283 (save-excursion
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1284 (set-buffer buffer)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1285 (let (b e name)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1286 (while (re-search-forward help-symbol-regexp nil t)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1287 (setq b (or (match-beginning 2) (match-beginning 4)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1288 (setq e (or (match-end 2) (match-end 4)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1289 (setq name (buffer-substring b e))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1290 (let* ((sym (intern-soft name))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1291 (var (and sym (boundp sym)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1292 (documentation-property sym
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1293 'variable-documentation t)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1294 (fun (and sym (fboundp sym)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1295 (documentation sym t))))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1296 (when (or var fun)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1297 (let ((ex (make-extent b e)))
622
11502791fc1c [xemacs-hg @ 2001-06-22 01:49:57 by ben]
ben
parents: 502
diff changeset
1298 (require 'hyper-apropos)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1299 (set-extent-property ex 'mouse-face 'highlight)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1300 (set-extent-property ex 'help-symbol sym)
464
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1301 (set-extent-property ex 'face 'hyper-apropos-hyperlink)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1302 (set-extent-property
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1303 ex 'context-menu
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1304 (cond ((and var fun)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1305 help-symbol-function-and-variable-context-menu)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1306 (var help-symbol-variable-context-menu)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1307 (fun help-symbol-function-context-menu)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1308 (set-extent-property
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1309 ex 'activate-function
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1310 (if fun
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1311 #'(lambda (ev ex)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1312 (help-symbol-run-function-1 ev ex 'describe-function))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1313 #'(lambda (ev ex)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1314 (help-symbol-run-function-1 ev ex 'describe-variable))))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1315 ))))))) ;; 11 parentheses!
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1316
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1317 (defun describe-function-1 (function &optional nodoc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1318 "This function does the work for `describe-function'."
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1319 (princ "`")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1320 ;; (Help-princ-face function 'font-lock-function-name-face) overkill
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1321 (princ function)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1322 (princ "' is ")
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1323 (let* ((def function)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1324 aliases file-name autoload-file kbd-macro-p fndef macrop)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1325 (while (and (symbolp def) (fboundp def))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1326 (when (not (eq def function))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1327 (setq aliases
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1328 (if aliases
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1329 ;; I18N3 Need gettext due to concat
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1330 (concat aliases
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1331 (format
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1332 "\n which is an alias for `%s', "
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1333 (symbol-name def)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1334 (format "an alias for `%s', " (symbol-name def)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1335 (setq def (symbol-function def)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1336 (if (and (fboundp 'compiled-function-annotation)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1337 (compiled-function-p def))
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
1338 (setq file-name (declare-fboundp (compiled-function-annotation def))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1339 (if (eq 'macro (car-safe def))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1340 (setq fndef (cdr def)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1341 file-name (and (compiled-function-p (cdr def))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1342 (fboundp 'compiled-function-annotation)
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
1343 (declare-fboundp
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
1344 (compiled-function-annotation (cdr def))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1345 macrop t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1346 (setq fndef def))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1347 (if aliases (princ aliases))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1348 (let ((int #'(lambda (string an-p macro-p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1349 (princ (format
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1350 (gettext (concat
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1351 (cond ((commandp def)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1352 "an interactive ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1353 (an-p "an ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1354 (t "a "))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1355 "%s"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1356 (if macro-p " macro" " function")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1357 string)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1358 (cond ((or (stringp def) (vectorp def))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1359 (princ "a keyboard macro.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1360 (setq kbd-macro-p t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1361 ((subrp fndef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1362 (funcall int "built-in" nil macrop))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1363 ((compiled-function-p fndef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1364 (funcall int "compiled Lisp" nil macrop))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1365 ((eq (car-safe fndef) 'lambda)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1366 (funcall int "Lisp" nil macrop))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1367 ((eq (car-safe fndef) 'mocklisp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1368 (funcall int "mocklisp" nil macrop))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1369 ((eq (car-safe def) 'autoload)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1370 (setq autoload-file (elt def 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1371 (funcall int "autoloaded Lisp" t (elt def 4)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1372 ((and (symbolp def) (not (fboundp def)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1373 (princ "a symbol with a void (unbound) function definition."))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1374 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1375 nil)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1376 (princ "\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1377 (if autoload-file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1378 (princ (format " -- autoloads from \"%s\"\n" autoload-file)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1379 (or file-name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1380 (setq file-name (describe-symbol-find-file function)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1381 (if file-name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1382 (princ (format " -- loaded from \"%s\"\n" file-name)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1383 ;; (terpri)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1384 (if describe-function-show-arglist
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1385 (let ((arglist (function-arglist function)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1386 (when arglist
464
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1387 (require 'hyper-apropos)
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1388 (Help-princ-face arglist 'hyper-apropos-documentation)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1389 (terpri))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1390 (terpri)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1391 (cond (kbd-macro-p
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1392 (princ "These characters are executed:\n\n\t")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1393 (princ (key-description def))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1394 (cond ((setq def (key-binding def))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1395 (princ (format "\n\nwhich executes the command `%s'.\n\n"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1396 def))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1397 (describe-function-1 def))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1398 (nodoc nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1399 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1400 ;; tell the user about obsoleteness.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1401 ;; If the function is obsolete and is aliased, don't
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1402 ;; even bother to report the documentation, as a further
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1403 ;; encouragement to use the new function.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1404 (let ((obsolete (function-obsoleteness-doc function))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1405 (compatible (function-compatibility-doc function)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1406 (when obsolete
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1407 (princ obsolete)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1408 (terpri)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1409 (terpri))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1410 (when compatible
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1411 (princ compatible)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1412 (terpri)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1413 (terpri))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1414 (unless (and obsolete aliases)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1415 (let ((doc (function-documentation function t)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1416 (princ "Documentation:\n")
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1417 (let ((oldp (point standard-output))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1418 newp)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1419 (princ doc)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1420 (setq newp (point standard-output))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1421 (goto-char oldp standard-output)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1422 (frob-help-extents standard-output)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1423 (goto-char newp standard-output))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1424 (unless (or (equal doc "")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1425 (eq ?\n (aref doc (1- (length doc)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1426 (terpri)))))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1427
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1429 ;;; [Obnoxious, whining people who complain very LOUDLY on Usenet
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1430 ;;; are binding this to keys.]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1431 (defun describe-function-arglist (function)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1432 (interactive (list (or (function-at-point)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1433 (error "no function call at point"))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1434 (message nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1435 (message (function-arglist function)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1436
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1437 (defun variable-at-point ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1438 (ignore-errors
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1439 (with-syntax-table emacs-lisp-mode-syntax-table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1440 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1441 (or (not (zerop (skip-syntax-backward "_w")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1442 (eq (char-syntax (char-after (point))) ?w)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1443 (eq (char-syntax (char-after (point))) ?_)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1444 (forward-sexp -1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1445 (skip-chars-forward "'")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1446 (let ((obj (read (current-buffer))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1447 (and (symbolp obj) (boundp obj) obj))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1448
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1449 (defun variable-at-event (event)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1450 "Return the variable whose name is around the position of EVENT.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1451 EVENT should be a mouse event. When calling from a popup or context menu,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1452 use `last-popup-menu-event' to find out where the mouse was clicked.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1453 \(You cannot use (interactive \"e\"), unfortunately. This returns a
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1454 misc-user event.)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1455
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1456 If the event contains no position, or the position is not over text, or
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1457 there is no variable around that point, nil is returned."
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1458 (if (and event (event-buffer event) (event-point event))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1459 (save-excursion
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1460 (set-buffer (event-buffer event))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1461 (goto-char (event-point event))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1462 (variable-at-point))))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1463
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1464 (defun variable-obsolete-p (variable)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1465 "Return non-nil if VARIABLE is obsolete."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1466 (not (null (get variable 'byte-obsolete-variable))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1467
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1468 (defun variable-obsoleteness-doc (variable)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1469 "If VARIABLE is obsolete, return a string describing this."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1470 (let ((obsolete (get variable 'byte-obsolete-variable)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1471 (if obsolete
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1472 (format "Obsolete; %s"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1473 (if (stringp obsolete)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1474 obsolete
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1475 (format "use `%s' instead." obsolete))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1476
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1477 (defun variable-compatible-p (variable)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1478 "Return non-nil if VARIABLE is Emacs compatible."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1479 (not (null (get variable 'byte-compatible-variable))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1480
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1481 (defun variable-compatibility-doc (variable)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1482 "If VARIABLE is Emacs compatible, return a string describing this."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1483 (let ((compatible (get variable 'byte-compatible-variable)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1484 (if compatible
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1485 (format "Emacs Compatible; %s"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1486 (if (stringp compatible)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1487 compatible
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1488 (format "use `%s' instead." compatible))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1489
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1490 (defun built-in-variable-doc (variable)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1491 "Return a string describing whether VARIABLE is built-in."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1492 (let ((type (built-in-variable-type variable)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1493 (case type
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1494 (integer "a built-in integer variable")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1495 (const-integer "a built-in constant integer variable")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1496 (boolean "a built-in boolean variable")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1497 (const-boolean "a built-in constant boolean variable")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1498 (object "a simple built-in variable")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1499 (const-object "a simple built-in constant variable")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1500 (const-specifier "a built-in constant specifier variable")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1501 (current-buffer "a built-in buffer-local variable")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1502 (const-current-buffer "a built-in constant buffer-local variable")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1503 (default-buffer "a built-in default buffer-local variable")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1504 (selected-console "a built-in console-local variable")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1505 (const-selected-console "a built-in constant console-local variable")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1506 (default-console "a built-in default console-local variable")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1507 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1508 (if type "an unknown type of built-in variable?"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1509 "a variable declared in Lisp")))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1510
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1511 (defun describe-variable (variable)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1512 "Display the full documentation of VARIABLE (a symbol)."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1513 (interactive
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1514 (let* ((v (variable-at-point))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1515 (val (let ((enable-recursive-minibuffers t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1516 (completing-read
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1517 (if v
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1518 (format "Describe variable (default %s): " v)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1519 (gettext "Describe variable: "))
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
1520 obarray 'boundp t nil 'variable-history
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
1521 (symbol-name v)))))
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
1522 (list (intern val))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1523 (with-displaying-help-buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1524 (lambda ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1525 (let ((origvar variable)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1526 aliases)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1527 (let ((print-escape-newlines t))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1528 (princ "`")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1529 ;; (Help-princ-face (symbol-name variable)
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
1530 ;; 'font-lock-variable-name-face) overkill
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1531 (princ (symbol-name variable))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1532 (princ "' is ")
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1533 (while (variable-alias variable)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1534 (let ((newvar (variable-alias variable)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1535 (if aliases
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1536 ;; I18N3 Need gettext due to concat
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1537 (setq aliases
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1538 (concat aliases
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1539 (format "\n which is an alias for `%s',"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1540 (symbol-name newvar))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1541 (setq aliases
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1542 (format "an alias for `%s',"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1543 (symbol-name newvar))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1544 (setq variable newvar)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1545 (if aliases
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1546 (princ (format "%s" aliases)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1547 (princ (built-in-variable-doc variable))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1548 (princ ".\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1549 (let ((file-name (describe-symbol-find-file variable)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1550 (if file-name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1551 (princ (format " -- loaded from \"%s\"\n" file-name))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1552 (princ "\nValue: ")
464
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1553 (require 'hyper-apropos)
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1554 (if (not (boundp variable))
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1555 (Help-princ-face "void\n" 'hyper-apropos-documentation)
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1556 (Help-prin1-face (symbol-value variable)
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1557 'hyper-apropos-documentation)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1558 (terpri))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1559 (terpri)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1560 (cond ((local-variable-p variable (current-buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1561 (let* ((void (cons nil nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1562 (def (condition-case nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1563 (default-value variable)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1564 (error void))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1565 (princ "This value is specific to the current buffer.\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1566 (if (local-variable-p variable nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1567 (princ "(Its value is local to each buffer.)\n"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1568 (terpri)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1569 (if (if (eq def void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1570 (boundp variable)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1571 (not (eq (symbol-value variable) def)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1572 ;; #### I18N3 doesn't localize properly!
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1573 (progn (princ "Default-value: ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1574 (if (eq def void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1575 (princ "void\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1576 (prin1 def)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1577 (terpri))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1578 (terpri)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1579 ((local-variable-p variable (current-buffer) t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1580 (princ "Setting it would make its value buffer-local.\n\n"))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1581 (princ "Documentation:")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1582 (terpri)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1583 (let ((doc (documentation-property variable 'variable-documentation))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1584 (obsolete (variable-obsoleteness-doc origvar))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1585 (compatible (variable-compatibility-doc origvar)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1586 (when obsolete
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1587 (princ obsolete)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1588 (terpri)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1589 (terpri))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1590 (when compatible
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1591 (princ compatible)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1592 (terpri)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1593 (terpri))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1594 ;; don't bother to print anything if variable is obsolete and aliased.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1595 (when (or (not obsolete) (not aliases))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1596 (if doc
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1597 ;; note: documentation-property calls substitute-command-keys.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1598 (let ((oldp (point standard-output))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1599 newp)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1600 (princ doc)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1601 (setq newp (point standard-output))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1602 (goto-char oldp standard-output)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1603 (frob-help-extents standard-output)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1604 (goto-char newp standard-output))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1605 (princ "not documented as a variable."))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1606 (terpri)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1607 (format "variable `%s'" variable)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1608
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1609 (defun sorted-key-descriptions (keys &optional separator)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1610 "Sort and separate the key descriptions for KEYS.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1611 The sorting is done by length (shortest bindings first), and the bindings
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1612 are separated with SEPARATOR (\", \" by default)."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1613 (mapconcat 'key-description
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1614 (sort keys #'(lambda (x y)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1615 (< (length x) (length y))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1616 (or separator ", ")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1617
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1618 (defun where-is (definition &optional insert)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1619 "Print message listing key sequences that invoke specified command.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1620 Argument is a command definition, usually a symbol with a function definition.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1621 When run interactively, it defaults to any function found by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1622 `function-at-point'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1623 If INSERT (the prefix arg) is non-nil, insert the message in the buffer."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1624 (interactive
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1625 (let ((fn (function-at-point))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1626 (enable-recursive-minibuffers t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1627 val)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1628 (setq val (read-command
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1629 (if fn (format "Where is command (default %s): " fn)
456
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 444
diff changeset
1630 "Where is command: ")
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 444
diff changeset
1631 (and fn (symbol-name fn))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1632 (list (if (equal (symbol-name val) "")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1633 fn val)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1634 current-prefix-arg)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1635 (let ((keys (where-is-internal definition)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1636 (if keys
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1637 (if insert
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1638 (princ (format "%s (%s)" (sorted-key-descriptions keys)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1639 definition) (current-buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1640 (message "%s is on %s" definition (sorted-key-descriptions keys)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1641 (if insert
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1642 (princ (format (if (commandp definition) "M-x %s RET"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1643 "M-: (%s ...)") definition) (current-buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1644 (message "%s is not on any keys" definition))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1645 nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1646
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1647 ;; `locate-library' moved to "packages.el"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1648
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1649
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1650 ;; Functions ported from C into Lisp in XEmacs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1651
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1652 (defun describe-syntax ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1653 "Describe the syntax specifications in the syntax table.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1654 The descriptions are inserted in a buffer, which is then displayed."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1655 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1656 (with-displaying-help-buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1657 (lambda ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1658 ;; defined in syntax.el
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1659 (describe-syntax-table (syntax-table) standard-output))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1660 (format "syntax-table for %s" major-mode)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1661
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1662 (defun list-processes ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1663 "Display a list of all processes.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1664 \(Any processes listed as Exited or Signaled are actually eliminated
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1665 after the listing is made.)"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1666 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1667 (with-output-to-temp-buffer "*Process List*"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1668 (set-buffer standard-output)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1669 (buffer-disable-undo standard-output)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1670 (make-local-variable 'truncate-lines)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1671 (setq truncate-lines t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1672 ;; 00000000001111111111222222222233333333334444444444
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1673 ;; 01234567890123456789012345678901234567890123456789
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1674 ;; rewritten for I18N3. This one should stay rewritten
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1675 ;; so that the dashes will line up properly.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1676 (princ "Proc Status Buffer Tty Command\n---- ------ ------ --- -------\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1677 (let ((tail (process-list)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1678 (while tail
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1679 (let* ((p (car tail))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1680 (pid (process-id p))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1681 (s (process-status p)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1682 (setq tail (cdr tail))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1683 (princ (format "%-13s" (process-name p)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1684 (princ s)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1685 (if (and (eq s 'exit) (/= (process-exit-status p) 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1686 (princ (format " %d" (process-exit-status p))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1687 (if (memq s '(signal exit closed))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1688 ;; Do delete-exited-processes' work
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1689 (delete-process p))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1690 (indent-to 22 1) ;####
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1691 (let ((b (process-buffer p)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1692 (cond ((not b)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1693 (princ "(none)"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1694 ((not (buffer-name b))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1695 (princ "(killed)"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1696 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1697 (princ (buffer-name b)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1698 (indent-to 37 1) ;####
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1699 (let ((tn (process-tty-name p)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1700 (cond ((not tn)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1701 (princ "(none)"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1702 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1703 (princ (format "%s" tn)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1704 (indent-to 49 1) ;####
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1705 (if (not (integerp pid))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1706 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1707 (princ "network stream connection ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1708 (princ (car pid))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1709 (princ "@")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1710 (princ (cdr pid)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1711 (let ((cmd (process-command p)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1712 (while cmd
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1713 (princ (car cmd))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1714 (setq cmd (cdr cmd))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1715 (if cmd (princ " ")))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1716 (terpri))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1717
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 430
diff changeset
1718 ;; Stop gap for 21.0 until we do help-char etc properly.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1719 (defun help-keymap-with-help-key (keymap form)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1720 "Return a copy of KEYMAP with an help-key binding according to help-char
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1721 invoking FORM like help-form. An existing binding is not overridden.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1722 If FORM is nil then no binding is made."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1723 (let ((map (copy-keymap keymap))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1724 (key (if (characterp help-char)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1725 (vector (character-to-event help-char))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1726 help-char)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1727 (when (and form key (not (lookup-key map key)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1728 (define-key map key
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1729 `(lambda () (interactive) (help-print-help-form ,form))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1730 map))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1731
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1732 (defun help-print-help-form (form)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1733 (let ((string (eval form)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1734 (if (stringp string)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1735 (with-displaying-help-buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1736 (insert string)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1737
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1738 ;;; help.el ends here