Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
;;; xwem-interactive.el --- XWEM interactive interface.
;; Copyright (C) 2003 by Free Software Foundation, Inc.
;; Author: Zajcev Evgeny <zevlg@yandex.ru>
;; Created: Thu Dec 18 05:49:52 MSK 2003
;; Keywords: xwem, xlib
;; X-CVS: $Id$
;; This file is part of XWEM.
;; XWEM is free software; you can redistribute it and/or modify it
;; under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; XWEM is distributed in the hope that it will be useful, but WITHOUT
;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
;; License for more details.
;; You should have received a copy of the GNU General Public License
;; along with XEmacs; see the file COPYING. If not, write to the Free
;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
;; 02111-1307, USA.
;;; Synched up with: Not in FSF
;;; Commentary:
;;
;;; Code:
;;;###autoload
(defvar xwem-interactively nil
"Non-nil when xwem in interactive mode.
Internal variabel, do not modify.")
;;;###autoload
(fset 'read-from-minibuffer-for-xwem (symbol-function 'read-from-minibuffer))
;;;###autoload
(defun xwem-interactive-p ()
"Return non-nil when xwem in interactive mode."
xwem-interactively)
(defun xwem-interactive-itimer ()
"Itimer used by `xwem-read-from-minibuffer'."
(when xwem-executing-kbd-macro
(xwem-key-send-ekeys
(vector (aref xwem-executing-kbd-macro (incf xwem-executing-kbd-macro-index))))
))
;;; Keymacros safe variant of `read-from-minibuffer', i.e. does not
;; block if we are executing keyboard macro.
;;;###autoload
(defun xwem-read-from-minibuffer (prompt &optional initial-contents keymap readp history abbrev-table)
"Read data from xwem minibuffer.
Arguments PROMPT, INITIAL-CONTENTS, KEYMAP, READP, HISTORY and
ABBREV-TABLE are same as for `read-from-minibuffer'."
(let (ret)
(xwem-under-minib-focus
(xwem-kbd-stop-grabbing)
(when xwem-executing-kbd-macro
(start-itimer "xwem-macro-itimer" 'xwem-interactive-itimer 0.01 0.01 t))
(unwind-protect
(setq ret (read-from-minibuffer-for-xwem prompt initial-contents keymap readp history abbrev-table))
(when xwem-executing-kbd-macro
(delete-itimer "xwem-macro-itimer")))
ret)))
;;;###autoload
(defun xwem-completing-read (prompt table &optional predicate require-match initial-contents history)
"XWEM awared varian of `completing-read'."
(flet ((read-from-minibuffer (&rest args) nil))
(fset 'read-from-minibuffer (symbol-function 'xwem-read-from-minibuffer))
(completing-read prompt table predicate require-match initial-contents history)))
;;;###autoload
(defun xwem-read-command (prompt)
"Just like `read-command', but for XWEM.
Argument PROMPT is same as for `read-command'."
;; Temporary redefine `read-from-minibuffer'
(flet ((read-from-minibuffer (&rest args) nil))
(fset 'read-from-minibuffer (symbol-function 'xwem-read-from-minibuffer))
(read-command prompt)))
;;;###autoload
(defun xwem-read-filename (prompt &optional dir default must-match initial-contents history)
"Just like `read-file-name', but for XWEM.
PROMPT, DIR, DEFAULT, MUST-MATCH, INITIAL-CONTENTS and HISTORY are
same as for `read-file-name'."
;; Temporary redefine `read-from-minibuffer'
(flet ((read-from-minibuffer (&rest args) nil))
(fset 'read-from-minibuffer (symbol-function 'xwem-read-from-minibuffer))
(read-file-name prompt dir default must-match initial-contents history)))
;;;###autoload
(defun xwem-read-shell-command (prompt &optional initial-input history)
"Just like `read-shell-command', but for XWEM.
PROMPT, INITIAL-INPUT and HISTORY are same as for `read-shell-command'."
;; Temporary redefine `read-from-minibuffer'
(flet ((read-from-minibuffer (&rest args) nil))
(fset 'read-from-minibuffer (symbol-function 'xwem-read-from-minibuffer))
(read-shell-command prompt initial-input history)))
;;;###autoload
(defun xwem-read-external-command (prompt)
"Read for external command using PROMPT."
(xwem-launcher-query prompt))
;;;###autoload
(defun xwem-read-client (prompt &optional predic)
"Read for client name prompting PROMPT and return xwem client.
Additional argument PREDIC is passed right to `xwem-client-name'."
(flet ((read-from-minibuffer (&rest args) nil))
(fset 'read-from-minibuffer (symbol-function 'xwem-read-from-minibuffer))
(let* ((rcl nil)
(clsnl (xwem-cl-normal-list xwem-clients predic))
(clns (mapcar
(lambda (cl)
(cons (xwem-client-name cl clsnl) cl))
clsnl))
(name (flet ((iswitchb-make-buflist
(default)
(setq iswitchb-buflist (mapcar (lambda (cl) (car cl)) clns))))
(iswitchb-read-buffer prompt))))
(while clns
(when (string= (caar clns) name)
(setq rcl (cdar clns))
(setq clns nil))
(setq clns (cdr clns)))
rcl)))
;;;###autoload
(defun xwem-read-frame (prompt)
"Read for frame number prompting PROMPT and return xwem frame."
)
;; For `xwem-interactive' take a look at xwem-macros.el
;;;###autoload
(defun xwem-interactive-ilist (spec)
"Return list valid for `interactive'.
SPEC is specification of list items."
(let ((xwem-interactively t))
(declare (special xwem-interactively))
;; XXX if ?_ is first than command need to run with ungrabbed
;; keyboard.
(when (and spec (eq (aref (car spec) 0) ?_))
(xwem-kbd-stop-grabbing)
;; Remove ?_ from first element in SPEC
(if (= (length (car spec)) 1)
(setq spec (cdr spec))
(setq spec (cons (substring (car spec) 1) (cdr spec)))))
(mapcar (lambda (el)
(let ((code (aref el 0))
(prompt (substring el 1)))
(cond ((eq code ?P) xwem-prefix-arg)
((eq code ?p) (prefix-numeric-value xwem-prefix-arg))
((eq code ?k) (xwem-read-key prompt))
((eq code ?K) (xwem-read-key-sequence prompt))
((eq code ?c) (xwem-read-client prompt))
((eq code ?f) (xwem-read-filename prompt nil nil t))
((eq code ?F) (xwem-read-filename prompt))
((eq code ?s) (xwem-read-from-minibuffer prompt))
((eq code ?C) (xwem-read-command prompt))
((eq code ?c) (xwem-read-client prompt))
((eq code ?e) (xwem-read-external-command prompt))
)))
spec)))
(provide 'xwem-interactive)
;;; xwem-interactive.el ends here