annotate lisp/help-macro.el @ 110309:14a601b405fc

SQL Mode, Version 2.6 * progmodes/sql.el: Version 2.6 (sql-dialect): Synonym for "sql-product". (sql-find-sqli-buffer, sql-set-sqli-buffer-generally) (sql-set-sqli-buffer, sql-show-sqli-buffer, sql-interactive-mode): Set "sql-buffer" to buffer name not buffer object so multiple sql interactive buffers work properly. Reverts misguided changes in earlier work. (sql-comint): Make sure different buffer name is used if "*SQL*" buffer is for a different product. (sql-make-alternate-buffer-name): Fix bug with "sql-database" login param. (sql-oracle, sql-sybase, sql-informix, sql-sqlite, sql-mysql) (sql-solid, sql-ingres, sql-ms, sql-postgres, sql-interbase) (sql-db2, sql-linter, sql-product-interactive, sql-rename-buffer): Accept new buffer name or prompt for one. (sql-port): Default to zero. (sql-comint-mysql): Handle "sql-port" as a numeric. (sql-port-history): Delete unused variable. (sql-get-login): Default "sql-port" to a number. (sql-product-alist): Correct Postgres prompt and terminator regexp. (sql-sqlite-program): Dynamically detect presence of "sqlite" or "sqlite3" executables. (sql-sqlite-login-params): Add "*.sqlite[23]?" database name pattern. (sql-buffer-live-p): New function. (sql-mode-menu, sql-send-string): Use it. (sql-mode-oracle-font-lock-keywords): Improve SQL*Plus REMARK syntax pattern. (sql-mode-postgres-font-lock-keywords): Support Postgres V9. (sql-mode-sqlite-font-lock-keywords): Hilight sqlite commands.
author Michael Mauger <mmaug@yahoo.com>
date Fri, 10 Sep 2010 23:17:02 -0400
parents 280c8ae2476d
children 417b1e4d63cd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38412
253f761ad37b Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents: 25298
diff changeset
1 ;;; help-macro.el --- makes command line help such as help-for-help
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2
74442
b2e5081b9320 Update copyright years.
Glenn Morris <rgm@gnu.org>
parents: 74229
diff changeset
3 ;; Copyright (C) 1993, 1994, 2001, 2002, 2003, 2004,
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 105216
diff changeset
4 ;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
5
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
6 ;; Author: Lynn Slater <lrs@indetech.com>
17976
852464ce5d6a Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 14316
diff changeset
7 ;; Maintainer: FSF
38412
253f761ad37b Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents: 25298
diff changeset
8 ;; Created: Mon Oct 1 11:42:39 1990
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
9 ;; Adapted-By: ESR
110015
280c8ae2476d Add "Package:" file headers to denote built-in packages.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
10 ;; Package: emacs
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
11
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
12 ;; This file is part of GNU Emacs.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
13
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
14 ;; GNU Emacs is free software: you can redistribute it and/or modify
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
15 ;; it under the terms of the GNU General Public License as published by
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
16 ;; the Free Software Foundation, either version 3 of the License, or
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
17 ;; (at your option) any later version.
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
18
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
19 ;; GNU Emacs is distributed in the hope that it will be useful,
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
22 ;; GNU General Public License for more details.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
23
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
24 ;; You should have received a copy of the GNU General Public License
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
25 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
26
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
27 ;;; Commentary:
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12423
diff changeset
28
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12423
diff changeset
29 ;; This file supplies the macro make-help-screen which constructs
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
30 ;; single character dispatching with browsable help such as that provided
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
31 ;; by help-for-help. This can be used to make many modes easier to use; for
38412
253f761ad37b Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents: 25298
diff changeset
32 ;; example, the GNU Emacs Empire Tool uses this for every "nested" mode map
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
33 ;; called from the main mode map.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
34
2530
1e1a30d5d523 Name changed to fit in a 14-character limit.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2456
diff changeset
35 ;; The name of this package was changed from help-screen.el to
1e1a30d5d523 Name changed to fit in a 14-character limit.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2456
diff changeset
36 ;; help-macro.el in order to fit in a 14-character limit.
1e1a30d5d523 Name changed to fit in a 14-character limit.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2456
diff changeset
37
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
38 ;;-> *********************** Example of use *********************************
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
39
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
40 ;;->(make-help-screen help-for-empire-redistribute-map
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
41 ;;-> "c:civ m:mil p:population f:food ?"
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
42 ;;-> "You have discovered the GEET redistribution commands
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
43 ;;-> From here, you can use the following options:
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
44 ;;->
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
45 ;;->c Redistribute civs from overfull sectors into connected underfull ones
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
46 ;;-> The functions typically named by empire-ideal-civ-fcn control
25298
866b59632531 Move provide to end.
Dave Love <fx@gnu.org>
parents: 23331
diff changeset
47 ;;-> based in part on empire-sector-civ-threshold
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
48 ;;->m Redistribute military using levels given by empire-ideal-mil-fcn
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
49 ;;->p Redistribute excess population to highways for max pop growth
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
50 ;;-> Excess is any sector so full babies will not be born.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
51 ;;->f Even out food on highways to highway min and leave levels
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
52 ;;-> This is good to pump max food to all warehouses/dist pts
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
53 ;;->
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
54 ;;->
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
55 ;;->Use \\[help-for-empire-redistribute-map] for help on redistribution.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
56 ;;->Use \\[help-for-empire-extract-map] for help on data extraction.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
57 ;;->Please use \\[describe-key] to find out more about any of the other keys."
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
58 ;;-> empire-shell-redistribute-map)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
59
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
60 ;;-> (define-key c-mp "\C-h" 'help-for-empire-redistribute-map)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
61 ;;-> (define-key c-mp help-character 'help-for-empire-redistribute-map)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
62
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
63 ;;; Change Log:
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
64 ;;
25298
866b59632531 Move provide to end.
Dave Love <fx@gnu.org>
parents: 23331
diff changeset
65 ;; 22-Jan-1991 Lynn Slater x2048
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
66 ;; Last Modified: Mon Oct 1 11:43:52 1990 #3 (Lynn Slater)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
67 ;; documented better
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
68
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
69 ;;; Code:
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
70
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
71 (require 'backquote)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
72
5679
90ba98c692b5 (three-step-help): New option.
Richard M. Stallman <rms@gnu.org>
parents: 5640
diff changeset
73 ;;;###autoload
25298
866b59632531 Move provide to end.
Dave Love <fx@gnu.org>
parents: 23331
diff changeset
74 (defcustom three-step-help nil
99664
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
75 "Non-nil means give more info about Help command in three steps.
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
76 The three steps are simple prompt, prompt with all options, and
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
77 window listing and describing the options.
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
78 A value of nil means skip the middle step, so that \\[help-command] \\[help-command]
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
79 gives the window that lists the options."
25298
866b59632531 Move provide to end.
Dave Love <fx@gnu.org>
parents: 23331
diff changeset
80 :type 'boolean
866b59632531 Move provide to end.
Dave Love <fx@gnu.org>
parents: 23331
diff changeset
81 :group 'help)
5679
90ba98c692b5 (three-step-help): New option.
Richard M. Stallman <rms@gnu.org>
parents: 5640
diff changeset
82
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
83 (defmacro make-help-screen (fname help-line help-text helped-map)
5378
32a291ab0c5f (make-help-screen): Use read-key-sequence.
Richard M. Stallman <rms@gnu.org>
parents: 3128
diff changeset
84 "Construct help-menu function name FNAME.
32a291ab0c5f (make-help-screen): Use read-key-sequence.
Richard M. Stallman <rms@gnu.org>
parents: 3128
diff changeset
85 When invoked, FNAME shows HELP-LINE and reads a command using HELPED-MAP.
8709
258aaa4b66ed (make-help-screen): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 8661
diff changeset
86 If the command is the help character, FNAME displays HELP-TEXT
5378
32a291ab0c5f (make-help-screen): Use read-key-sequence.
Richard M. Stallman <rms@gnu.org>
parents: 3128
diff changeset
87 and continues trying to read a command using HELPED-MAP.
23331
8e860ff326de (make-help-screen): Keep HELP-TEXT
Richard M. Stallman <rms@gnu.org>
parents: 21120
diff changeset
88 If HELP-TEXT contains the sequence `%THIS-KEY%', that is replaced
8e860ff326de (make-help-screen): Keep HELP-TEXT
Richard M. Stallman <rms@gnu.org>
parents: 21120
diff changeset
89 with the key sequence that invoked FNAME.
5378
32a291ab0c5f (make-help-screen): Use read-key-sequence.
Richard M. Stallman <rms@gnu.org>
parents: 3128
diff changeset
90 When FNAME finally does get a command, it executes that command
32a291ab0c5f (make-help-screen): Use read-key-sequence.
Richard M. Stallman <rms@gnu.org>
parents: 3128
diff changeset
91 and then returns."
99664
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
92 (let ((doc-fn (intern (concat (symbol-name fname) "-doc"))))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
93 `(progn
105216
fb7e59394e9b * help.el (help-for-help-internal): Don't purecopy the text (bug#4560).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 100908
diff changeset
94 (defun ,doc-fn () ,help-text nil)
99664
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
95 (defun ,fname ()
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
96 "Help command."
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
97 (interactive)
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
98 (let ((line-prompt
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
99 (substitute-command-keys ,help-line)))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
100 (when three-step-help
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
101 (message "%s" line-prompt))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
102 (let* ((help-screen (documentation (quote ,doc-fn)))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
103 ;; We bind overriding-local-map for very small
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
104 ;; sections, *excluding* where we switch buffers
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
105 ;; and where we execute the chosen help command.
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
106 (local-map (make-sparse-keymap))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
107 (new-minor-mode-map-alist minor-mode-map-alist)
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
108 (prev-frame (selected-frame))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
109 config new-frame key char)
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
110 (when (string-match "%THIS-KEY%" help-screen)
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
111 (setq help-screen
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
112 (replace-match (key-description
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
113 (substring (this-command-keys) 0 -1))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
114 t t help-screen)))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
115 (unwind-protect
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
116 (let ((minor-mode-map-alist nil))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
117 (setcdr local-map ,helped-map)
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
118 (define-key local-map [t] 'undefined)
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
119 ;; Make the scroll bar keep working normally.
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
120 (define-key local-map [vertical-scroll-bar]
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
121 (lookup-key global-map [vertical-scroll-bar]))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
122 (if three-step-help
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
123 (progn
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
124 (setq key (let ((overriding-local-map local-map))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
125 (read-key-sequence nil)))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
126 ;; Make the HELP key translate to C-h.
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
127 (if (lookup-key function-key-map key)
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
128 (setq key (lookup-key function-key-map key)))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
129 (setq char (aref key 0)))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
130 (setq char ??))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
131 (when (or (eq char ??) (eq char help-char)
12423
ee433b44920d (make-help-screen): Handle help-event-list.
Richard M. Stallman <rms@gnu.org>
parents: 11424
diff changeset
132 (memq char help-event-list))
99664
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
133 (setq config (current-window-configuration))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
134 (switch-to-buffer-other-window "*Help*")
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
135 (and (fboundp 'make-frame)
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
136 (not (eq (window-frame (selected-window))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
137 prev-frame))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
138 (setq new-frame (window-frame (selected-window))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
139 config nil))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
140 (setq buffer-read-only nil)
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
141 (let ((inhibit-read-only t))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
142 (erase-buffer)
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
143 (insert help-screen))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
144 (let ((minor-mode-map-alist new-minor-mode-map-alist))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
145 (help-mode)
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
146 (setq new-minor-mode-map-alist minor-mode-map-alist))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
147 (goto-char (point-min))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
148 (while (or (memq char (append help-event-list
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
149 (cons help-char '(?? ?\C-v ?\s ?\177 delete backspace vertical-scroll-bar ?\M-v))))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
150 (eq (car-safe char) 'switch-frame)
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
151 (equal key "\M-v"))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
152 (condition-case nil
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
153 (cond
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
154 ((eq (car-safe char) 'switch-frame)
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
155 (handle-switch-frame char))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
156 ((memq char '(?\C-v ?\s))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
157 (scroll-up))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
158 ((or (memq char '(?\177 ?\M-v delete backspace))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
159 (equal key "\M-v"))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
160 (scroll-down)))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
161 (error nil))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
162 (let ((cursor-in-echo-area t)
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
163 (overriding-local-map local-map))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
164 (setq key (read-key-sequence
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
165 (format "Type one of the options listed%s: "
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
166 (if (pos-visible-in-window-p
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
167 (point-max))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
168 "" ", or SPACE or DEL to scroll")))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
169 char (aref key 0)))
20029
857e1ce3f14b (make-help-screen): Make scroll bar work normally.
Richard M. Stallman <rms@gnu.org>
parents: 18656
diff changeset
170
99664
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
171 ;; If this is a scroll bar command, just run it.
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
172 (when (eq char 'vertical-scroll-bar)
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
173 (command-execute (lookup-key local-map key) nil key))))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
174 ;; We don't need the prompt any more.
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
175 (message "")
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
176 ;; Mouse clicks are not part of the help feature,
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
177 ;; so reexecute them in the standard environment.
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
178 (if (listp char)
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
179 (setq unread-command-events
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
180 (cons char unread-command-events)
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
181 config nil)
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
182 (let ((defn (lookup-key local-map key)))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
183 (if defn
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
184 (progn
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
185 (when config
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
186 (set-window-configuration config)
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
187 (setq config nil))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
188 ;; `defn' must make sure that its frame is
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
189 ;; selected, so we won't iconify it below.
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
190 (call-interactively defn)
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
191 (when new-frame
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
192 ;; Do not iconify the selected frame.
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
193 (unless (eq new-frame (selected-frame))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
194 (iconify-frame new-frame))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
195 (setq new-frame nil)))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
196 (ding)))))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
197 (when config
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
198 (set-window-configuration config))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
199 (when new-frame
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
200 (iconify-frame new-frame))
77d381812b04 (three-step-help): Remove * from defcustom.
Martin Rudalics <rudalics@gmx.at>
parents: 98216
diff changeset
201 (setq minor-mode-map-alist new-minor-mode-map-alist))))))))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
202
25298
866b59632531 Move provide to end.
Dave Love <fx@gnu.org>
parents: 23331
diff changeset
203 (provide 'help-macro)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
204
93975
1e3a407766b9 Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 79721
diff changeset
205 ;; arch-tag: 59fee949-1686-485a-8a05-83418073e257
25298
866b59632531 Move provide to end.
Dave Love <fx@gnu.org>
parents: 23331
diff changeset
206 ;;; help-macro.el ends here