comparison lisp/utils/detached-minibuf.el @ 100:4be1180a9e89 r20-1b2

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