annotate lisp/utils/detached-minibuf.el @ 124:9b50b4588a93 r20-1b15

Import from CVS: tag r20-1b15
author cvs
date Mon, 13 Aug 2007 09:26:39 +0200
parents 4103f0995bd7
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1 ;;; detached-minibuf.el -- Support a detached minibuffer for XEmacs.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
3 ;; Copyright (C) 1997 Alvin C. Shelton
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
4
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
5 ;; Author: Alvin Shelton <acs@acm.org>
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
6 ;; Keywords: extensions
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
7
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
8 ;; This file is part of XEmacs.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
9
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
10 ;; XEmacs is free software; you can redistribute it and/or modify it
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
11 ;; under the terms of the GNU General Public License as published by
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
13 ;; option) any later version.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
14
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
18 ;; General Public License for more details.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
19
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
21 ;; along with XEmacs; if not, write to the Free Software Foundation,
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
22 ;; Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
23
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
24 ;;; Synched up with: not in FSF.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
25
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
26 ;;; Commentary:
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
27
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
28 ;; WARNING. DANGER. This file reportedly crashes 19.14, use it only with a
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
29 ;; recent XEmacs.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
30
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
31 ;; Version: 1.1
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
32
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
33 ;;; Code:
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
34
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
35 ;;
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
36 ;; Variable definitions
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
37
124
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 24
diff changeset
38 (defgroup detached-minibuf nil
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 24
diff changeset
39 "Support a detached minibuffer in XEmacs"
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 24
diff changeset
40 :group 'minibuffer
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 24
diff changeset
41 :prefix "minibuf-frame-"
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 24
diff changeset
42 :group 'frames)
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 24
diff changeset
43
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 24
diff changeset
44
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 24
diff changeset
45 (defcustom add-minibuf-options t
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
46 "*If nil, prevent minibuffer options from being added to the Options menu.\
124
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 24
diff changeset
47 This must be set before detached-minibuf is loaded."
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 24
diff changeset
48 :type 'boolean
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 24
diff changeset
49 :group 'detached-minibuf)
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 24
diff changeset
50 (defcustom minibuf-frame-height 1
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 24
diff changeset
51 "*The height in lines of the minibuffer frame created by make-detached-minibuf"
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 24
diff changeset
52 :type 'integer
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 24
diff changeset
53 :group 'detached-minibuf)
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 24
diff changeset
54 (defcustom minibuf-frame-width (frame-width (selected-frame))
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 24
diff changeset
55 "*The width in chars of the minibuffer frame created by make-detached-minibuf"
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 24
diff changeset
56 :type 'integer
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 24
diff changeset
57 :group 'detached-minibuf)
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 24
diff changeset
58 (defcustom minibuf-frame-pos-y -2
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 24
diff changeset
59 "*The y position of the minibuffer frame as created by make-detached-minibuf"
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 24
diff changeset
60 :type 'integer
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 24
diff changeset
61 :group 'detached-minibuf)
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 24
diff changeset
62 (defcustom minibuf-frame-pos-x -2
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 24
diff changeset
63 "*The x position of the minibuffer frame as created by make-detached-minibuf"
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 24
diff changeset
64 :type 'integer
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 24
diff changeset
65 :group 'detached-minibuf)
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
66
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
67 ;;
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
68 ;; Add minibuffer options to the Options menu
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
69 (if add-minibuf-options
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
70 (progn
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
71 (defun toggle-minibuf ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
72 (interactive)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
73 (if (equal (frame-property (selected-frame) 'minibuffer) t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
74
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
75 ;; This frame already has a minibuffer, so remove the minibuffer.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
76 ;; Unfortunately, we must delete and redraw the frame
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
77 (let ((fp (frame-properties (selected-frame)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
78 (buf (current-buffer))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
79 (orig (selected-frame)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
80
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
81 ;; Create and select the new frame;
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
82 ;; we have to do this before we delete the old frame.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
83 (setq fp (plist-remprop fp 'window-id)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
84 fp (plist-remprop fp 'minibuffer))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
85 (select-frame
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
86 (make-frame (plist-put fp 'minibuffer nil)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
87 (switch-to-buffer buf)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
88
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
89 (set-frame-properties
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
90 orig (list 'minibuffer default-minibuffer-frame))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
91 (delete-frame orig t))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
92
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
93 ;; This frame does not have a minibuffer, so add one
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
94 (set-frame-property (selected-frame) 'minibuffer t)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
95
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
96 (add-menu-button '("Options" "Frame Appearance")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
97 ["------" nil nil]
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
98 nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
99 (add-menu-button '("Options" "Frame Appearance")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
100 ["Toggle minibuffer"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
101 (toggle-minibuf)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
102 :style toggle
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
103 :active (not (equal (selected-frame)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
104 default-minibuffer-frame))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
105 :selected (equal
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
106 (frame-property (selected-frame) 'minibuffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
107 t)]
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
108 nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
109 (add-menu-button '("Options" "Frame Appearance")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
110 ["Default minibuffer here"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
111 (setq default-minibuffer-frame (selected-frame))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
112 :style toggle
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
113 :active (let ((mbf (frame-property
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
114 (selected-frame) 'minibuffer)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
115 (or (equal mbf (selected-frame))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
116 (equal mbf t)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
117 :selected (equal (selected-frame)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
118 default-minibuffer-frame)]
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
119 nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
120 (add-menu-button '("Options" "Frame Appearance")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
121 ["Make a detached minibuffer"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
122 (make-detached-minibuf)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
123 :style nil]
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
124 nil)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
125
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
126 ;;
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
127 ;; Create a minibuffer-only frame.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
128 ;;
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
129 ;; This function creates a frame named "minibuffer".
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
130 ;; You will likely want this frame not to have a titlebar.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
131 ;; In order to do this for gwm, uncomment the following line
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
132 ;; and add it to your .profile.gwm:
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
133 ;; (set-window Emacs.minibuffer no-frame)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
134 ;;
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
135 (defun make-detached-minibuf ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
136 "Create a standalone minibuffer"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
137 (interactive)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
138 (if (console-on-window-system-p)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
139 (progn
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
140 (setq initial-frame-plist
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
141 (list 'minibuffer nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
142 'width (frame-width (selected-frame))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
143 'height (frame-height (selected-frame))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
144 (setq default-minibuffer-frame
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
145 (make-frame
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
146 (list 'minibuffer 'only
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
147 'width minibuf-frame-width
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
148 'height minibuf-frame-height
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
149 'menubar-visible-p nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
150 'default-toolbar-visible-p nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
151 'name "minibuffer"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
152 'top minibuf-frame-pos-y
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
153 'left minibuf-frame-pos-x
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
154 'has-modeline-p nil)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
155
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
156 ;; Bogus! But it avoids annoying screen flash at startup
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
157 (if (not command-line-args-left)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
158 (frame-notice-user-settings)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
159
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
160 (provide 'detached-minibuf)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
161
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
162 ;;; detached-minibuf.el ends here