annotate lisp/vm/vm-mouse.el @ 126:1370575f1259 xemacs-20-1p1

Import from CVS: tag xemacs-20-1p1
author cvs
date Mon, 13 Aug 2007 09:27:39 +0200
parents cca96a509cfe
children b980b6286996
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; Mouse related functions and commands
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
2 ;;; Copyright (C) 1995-1997 Kyle E. Jones
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;;; This program is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;;; the Free Software Foundation; either version 1, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;;; This program is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;; along with this program; if not, write to the Free Software
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 (provide 'vm-mouse)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 (defun vm-mouse-fsfemacs-mouse-p ()
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 114
diff changeset
21 (and vm-fsfemacs-19-p
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 (fboundp 'set-mouse-position)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 (defun vm-mouse-xemacs-mouse-p ()
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 114
diff changeset
25 (and vm-xemacs-p
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 (fboundp 'set-mouse-position)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 (defun vm-mouse-set-mouse-track-highlight (start end)
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 114
diff changeset
29 (cond (vm-fsfemacs-19-p
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 (let ((o (make-overlay start end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 (overlay-put o 'mouse-face 'highlight)))
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 114
diff changeset
32 (vm-xemacs-p
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 (let ((o (make-extent start end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 (set-extent-property o 'highlight t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 (defun vm-mouse-button-2 (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;; go to where the event occurred
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 (cond ((vm-mouse-xemacs-mouse-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (set-buffer (window-buffer (event-window event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (and (event-point event) (goto-char (event-point event))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ((vm-mouse-fsfemacs-mouse-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (set-buffer (window-buffer (posn-window (event-start event))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (goto-char (posn-point (event-start event)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;; now dispatch depending on where we are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (cond ((eq major-mode 'vm-summary-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (mouse-set-point event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (if (let ((vm-follow-summary-cursor t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (vm-follow-summary-cursor))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
51 nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (setq this-command 'vm-scroll-forward)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (call-interactively 'vm-scroll-forward)))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
54 ((memq major-mode '(vm-mode vm-virtual-mode vm-presentation-mode))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
55 (vm-mouse-popup-or-select event))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (defun vm-mouse-button-3 (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (if vm-use-menus
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;; go to where the event occurred
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (cond ((vm-mouse-xemacs-mouse-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (set-buffer (window-buffer (event-window event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (and (event-point event) (goto-char (event-point event))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ((vm-mouse-fsfemacs-mouse-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (set-buffer (window-buffer (posn-window (event-start event))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (goto-char (posn-point (event-start event)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ;; now dispatch depending on where we are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (cond ((eq major-mode 'vm-summary-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (vm-menu-popup-mode-menu event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ((eq major-mode 'vm-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (vm-menu-popup-context-menu event))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
73 ((eq major-mode 'vm-presentation-mode)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
74 (vm-menu-popup-context-menu event))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ((eq major-mode 'vm-virtual-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (vm-menu-popup-context-menu event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ((eq major-mode 'mail-mode)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
78 (vm-menu-popup-context-menu event))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (defun vm-mouse-3-help (object)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
81 nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 "Use mouse button 3 to see a menu of options.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (defun vm-mouse-get-mouse-track-string (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ;; go to where the event occurred
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (cond ((vm-mouse-xemacs-mouse-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (set-buffer (window-buffer (event-window event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (and (event-point event) (goto-char (event-point event))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ((vm-mouse-fsfemacs-mouse-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (set-buffer (window-buffer (posn-window (event-start event))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (goto-char (posn-point (event-start event)))))
126
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 120
diff changeset
93 (cond (vm-fsfemacs-19-p
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (let ((o-list (overlays-at (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (string nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (while o-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (if (overlay-get (car o-list) 'mouse-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (setq string (vm-buffer-substring-no-properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (overlay-start (car o-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (overlay-end (car o-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 o-list nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (setq o-list (cdr o-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 string ))
126
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 120
diff changeset
104 (vm-xemacs-p
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (let ((e (extent-at (point) nil 'highlight)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (if e
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (buffer-substring (extent-start-position e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (extent-end-position e))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (t nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (defun vm-mouse-popup-or-select (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (cond ((vm-mouse-fsfemacs-mouse-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (set-buffer (window-buffer (posn-window (event-start event))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (goto-char (posn-point (event-start event)))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
117 (let (o-list (found nil))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (setq o-list (overlays-at (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (while (and o-list (not found))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (cond ((overlay-get (car o-list) 'vm-url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (setq found t)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
122 (vm-mouse-send-url-at-event event))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
123 ((overlay-get (car o-list) 'vm-mime-function)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
124 (setq found t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
125 (funcall (overlay-get (car o-list) 'vm-mime-function)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
126 (car o-list))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (setq o-list (cdr o-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (and (not found) (vm-menu-popup-context-menu event))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 ;; The XEmacs code is not actually used now, since all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 ;; selectable objects are handled by an extent keymap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ;; binding that points to a more specific function. But
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ;; this might come in handy later if I want selectable
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
133 ;; objects that don't have an extent or extent keymap
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
134 ;; attached.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 ((vm-mouse-xemacs-mouse-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (set-buffer (window-buffer (event-window event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (and (event-point event) (goto-char (event-point event)))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
138 (let (e)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
139 (cond ((extent-at (point) (current-buffer) 'vm-url)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
140 (vm-mouse-send-url-at-event event))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
141 ((setq e (extent-at (point) nil 'vm-mime-function))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
142 (funcall (extent-property e 'vm-mime-function) e))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
143 (t (vm-menu-popup-context-menu event)))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (defun vm-mouse-send-url-at-event (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (cond ((vm-mouse-xemacs-mouse-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (set-buffer (window-buffer (event-window event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (and (event-point event) (goto-char (event-point event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (vm-mouse-send-url-at-position (event-point event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 ((vm-mouse-fsfemacs-mouse-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (set-buffer (window-buffer (posn-window (event-start event))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (goto-char (posn-point (event-start event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (vm-mouse-send-url-at-position (posn-point (event-start event))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (defun vm-mouse-send-url-at-position (pos &optional browser)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
157 (save-restriction
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
158 (widen)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
159 (cond ((vm-mouse-xemacs-mouse-p)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
160 (let ((e (extent-at pos (current-buffer) 'vm-url))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
161 url)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
162 (if (null e)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
163 nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
164 (setq url (buffer-substring (extent-start-position e)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
165 (extent-end-position e)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
166 (vm-mouse-send-url url browser))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
167 ((vm-mouse-fsfemacs-mouse-p)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
168 (let (o-list url o)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
169 (setq o-list (overlays-at pos))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
170 (while (and o-list (null (overlay-get (car o-list) 'vm-url)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
171 (setq o-list (cdr o-list)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
172 (if (null o-list)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
173 nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
174 (setq o (car o-list))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
175 (setq url (vm-buffer-substring-no-properties
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
176 (overlay-start o)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
177 (overlay-end o)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
178 (vm-mouse-send-url url browser)))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (defun vm-mouse-send-url (url &optional browser)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
181 (if (string-match "^mailto:" url)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
182 (vm-mail-to-mailto-url url)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
183 (let ((browser (or browser vm-url-browser)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
184 (cond ((symbolp browser)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
185 (funcall browser url))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
186 ((stringp browser)
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
187 (message "Sending URL to %s..." browser)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
188 (vm-run-background-command browser url)
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
189 (message "Sending URL to %s... done" browser))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (defun vm-mouse-send-url-to-netscape (url &optional new-netscape new-window)
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
192 (message "Sending URL to Netscape...")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (if new-netscape
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 110
diff changeset
194 (apply 'vm-run-background-command vm-netscape-program
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 110
diff changeset
195 (append vm-netscape-program-switches (list url)))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 110
diff changeset
196 (or (equal 0 (apply 'vm-run-command vm-netscape-program "-remote"
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 110
diff changeset
197 (append (list (concat "openURL(" url
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 110
diff changeset
198 (if new-window ", new-window" "")
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 110
diff changeset
199 ")"))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 110
diff changeset
200 vm-netscape-program-switches)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (vm-mouse-send-url-to-netscape url t new-window)))
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
202 (message "Sending URL to Netscape... done"))
54
05472e90ae02 Import from CVS: tag r19-16-pre2
cvs
parents: 36
diff changeset
203
126
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 120
diff changeset
204 (defun vm-mouse-send-url-to-netscape-new-window (url)
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 120
diff changeset
205 (vm-mouse-send-url-to-netscape url nil t))
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 120
diff changeset
206
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (defun vm-mouse-send-url-to-mosaic (url &optional new-mosaic new-window)
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
208 (message "Sending URL to Mosaic...")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (if (null new-mosaic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (let ((pid-file "~/.mosaicpid")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (work-buffer " *mosaic work*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 pid)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (cond ((file-exists-p pid-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (set-buffer (get-buffer-create work-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (insert-file-contents pid-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (setq pid (int-to-string (string-to-int (buffer-string))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (insert (if new-window "newwin" "goto") ?\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (insert url ?\n)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
221 ;; newline convention used should be the local
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
222 ;; one, whatever that is.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
223 (setq buffer-file-type nil)
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 114
diff changeset
224 (and vm-xemacs-mule-p
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
225 (set-buffer-file-coding-system 'no-conversion nil))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (write-region (point-min) (point-max)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (concat "/tmp/Mosaic." pid)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 nil 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (kill-buffer work-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (cond ((or (null pid)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (not (equal 0 (vm-run-command "kill" "-USR1" pid))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (setq new-mosaic t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (if new-mosaic
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 110
diff changeset
235 (apply 'vm-run-background-command vm-mosaic-program
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 110
diff changeset
236 (append vm-mosaic-program-switches (list url))))
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
237 (message "Sending URL to Mosaic... done"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238
126
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 120
diff changeset
239 (defun vm-mouse-send-url-to-mosaic-new-window (url)
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 120
diff changeset
240 (vm-mouse-send-url-to-mosaic url nil t))
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 120
diff changeset
241
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (defun vm-mouse-install-mouse ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (cond ((vm-mouse-xemacs-mouse-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (if (null (lookup-key vm-mode-map 'button2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (define-key vm-mode-map 'button2 'vm-mouse-button-2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 ((vm-mouse-fsfemacs-mouse-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (if (null (lookup-key vm-mode-map [mouse-2]))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (define-key vm-mode-map [mouse-2] 'vm-mouse-button-2))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
249 (if vm-popup-menu-on-mouse-3
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (define-key vm-mode-map [mouse-3] 'ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (define-key vm-mode-map [down-mouse-3] 'vm-mouse-button-3))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (defun vm-run-background-command (command &rest arg-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (apply (function call-process) command nil 0 nil arg-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (defun vm-run-command (command &rest arg-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (apply (function call-process) command nil nil nil arg-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
260 ;; return t on zero exit status
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
261 ;; return (exit-status . stderr-string) on nonzero exit status
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
262 (defun vm-run-command-on-region (start end output-buffer command
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
263 &rest arg-list)
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
264 (let ((tempfile nil)
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
265 ;; for DOS/Windows command to tell it that its input is
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
266 ;; binary.
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
267 (binary-process-input t)
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
268 status errstring)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
269 (unwind-protect
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
270 (progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
271 (setq tempfile (vm-make-tempfile-name))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
272 (setq status
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
273 (apply 'call-process-region
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
274 start end command nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
275 (list output-buffer tempfile)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
276 nil arg-list))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
277 (cond ((equal status 0) t)
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
278 ;; even if exit status non-zero, if there was no
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
279 ;; diagnostic output the command probably
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
280 ;; succeeded. I have tried to just use exit status
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
281 ;; as the failure criterion and users complained.
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
282 ((equal (nth 7 (file-attributes tempfile)) 0)
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
283 (message "%s exited non-zero (code %s)" command status)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
284 t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
285 (t (save-excursion
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
286 (message "%s exited non-zero (code %s)" command status)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
287 (set-buffer (find-file-noselect tempfile))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
288 (setq errstring (buffer-string))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
289 (kill-buffer nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
290 (cons status errstring)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
291 (vm-error-free-call 'delete-file tempfile))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
292
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 ;; stupid yammering compiler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (defvar vm-mouse-read-file-name-prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (defvar vm-mouse-read-file-name-dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (defvar vm-mouse-read-file-name-default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (defvar vm-mouse-read-file-name-must-match)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (defvar vm-mouse-read-file-name-initial)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (defvar vm-mouse-read-file-name-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (defvar vm-mouse-read-file-name-return-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (defun vm-mouse-read-file-name (prompt &optional dir default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 must-match initial history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 "Like read-file-name, except uses a mouse driven interface.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 HISTORY argument is ignored."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (or dir (setq dir default-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (set-buffer (generate-new-buffer " *Files*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (use-local-map (make-sparse-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (setq buffer-read-only t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 default-directory dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (make-local-variable 'vm-mouse-read-file-name-prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (make-local-variable 'vm-mouse-read-file-name-dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (make-local-variable 'vm-mouse-read-file-name-default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (make-local-variable 'vm-mouse-read-file-name-must-match)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (make-local-variable 'vm-mouse-read-file-name-initial)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (make-local-variable 'vm-mouse-read-file-name-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (make-local-variable 'vm-mouse-read-file-name-return-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (setq vm-mouse-read-file-name-prompt prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (setq vm-mouse-read-file-name-dir dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (setq vm-mouse-read-file-name-default default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (setq vm-mouse-read-file-name-must-match must-match)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (setq vm-mouse-read-file-name-initial initial)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (setq vm-mouse-read-file-name-history history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (setq vm-mouse-read-file-name-prompt prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (setq vm-mouse-read-file-name-return-value nil)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
327 (if (and vm-frame-per-completion (vm-multiple-frames-possible-p))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
328 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
329 (vm-goto-new-frame 'completion)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (switch-to-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (vm-mouse-read-file-name-event-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (local-set-key "\C-g" 'vm-mouse-read-file-name-quit-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (recursive-edit))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 ;; buffer could have been killed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (and (boundp 'vm-mouse-read-file-name-return-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 vm-mouse-read-file-name-return-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (kill-buffer (current-buffer))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (defun vm-mouse-read-file-name-event-handler (&optional string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (let ((key-doc "Click here for keyboard interface.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 start list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (if string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (cond ((equal string key-doc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (save-excursion
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
348 (save-excursion
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
349 (let ((vm-mutable-frames t))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
350 (vm-delete-windows-or-frames-on (current-buffer))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (setq vm-mouse-read-file-name-return-value
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
352 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
353 (vm-keyboard-read-file-name
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
354 vm-mouse-read-file-name-prompt
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
355 vm-mouse-read-file-name-dir
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
356 vm-mouse-read-file-name-default
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
357 vm-mouse-read-file-name-must-match
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
358 vm-mouse-read-file-name-initial
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
359 vm-mouse-read-file-name-history)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (vm-mouse-read-file-name-quit-handler t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (quit (vm-mouse-read-file-name-quit-handler))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 ((file-directory-p string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (setq default-directory (expand-file-name string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (t (setq vm-mouse-read-file-name-return-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (expand-file-name string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (vm-mouse-read-file-name-quit-handler t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (setq buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (setq start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (insert vm-mouse-read-file-name-prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (vm-set-region-face start (point) 'bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (cond ((and (not string) vm-mouse-read-file-name-default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (setq start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (insert vm-mouse-read-file-name-default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (vm-mouse-set-mouse-track-highlight start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 ((not string) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (t (insert default-directory)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (insert ?\n ?\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (setq start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (insert key-doc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (vm-mouse-set-mouse-track-highlight start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (vm-set-region-face start (point) 'italic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (insert ?\n ?\n)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
384 (setq list (vm-delete-backup-file-names
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
385 (vm-delete-auto-save-file-names
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
386 (directory-files default-directory))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (vm-show-list list 'vm-mouse-read-file-name-event-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (setq buffer-read-only t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (defun vm-mouse-read-file-name-quit-handler (&optional normal-exit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (interactive)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
392 (let ((vm-mutable-frames t))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
393 (vm-delete-windows-or-frames-on (current-buffer))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
394 (if normal-exit
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
395 (throw 'exit nil)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
396 (throw 'exit t))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (defvar vm-mouse-read-string-prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (defvar vm-mouse-read-string-completion-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (defvar vm-mouse-read-string-multi-word)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (defvar vm-mouse-read-string-return-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (defun vm-mouse-read-string (prompt completion-list &optional multi-word)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (set-buffer (generate-new-buffer " *Choices*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (use-local-map (make-sparse-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (setq buffer-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (make-local-variable 'vm-mouse-read-string-prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (make-local-variable 'vm-mouse-read-string-completion-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (make-local-variable 'vm-mouse-read-string-multi-word)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (make-local-variable 'vm-mouse-read-string-return-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (setq vm-mouse-read-string-prompt prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (setq vm-mouse-read-string-completion-list completion-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (setq vm-mouse-read-string-multi-word multi-word)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (setq vm-mouse-read-string-return-value nil)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
416 (if (and vm-frame-per-completion (vm-multiple-frames-possible-p))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
417 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
418 (vm-goto-new-frame 'completion)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (switch-to-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (vm-mouse-read-string-event-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (local-set-key "\C-g" 'vm-mouse-read-string-quit-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (recursive-edit))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 ;; buffer could have been killed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (and (boundp 'vm-mouse-read-string-return-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (if (listp vm-mouse-read-string-return-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (mapconcat 'identity vm-mouse-read-string-return-value " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 vm-mouse-read-string-return-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (kill-buffer (current-buffer))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (defun vm-mouse-read-string-event-handler (&optional string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (let ((key-doc "Click here for keyboard interface.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (bs-doc " .... to go back one word.")
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
435 (done-doc " .... when you're done.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 start list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (if string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (cond ((equal string key-doc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (save-excursion
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
441 (save-excursion
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
442 (let ((vm-mutable-frames t))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
443 (vm-delete-windows-or-frames-on (current-buffer))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (setq vm-mouse-read-string-return-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (vm-keyboard-read-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 vm-mouse-read-string-prompt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 vm-mouse-read-string-completion-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 vm-mouse-read-string-multi-word))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (vm-mouse-read-string-quit-handler t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (quit (vm-mouse-read-string-quit-handler))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 ((equal string bs-doc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (setq vm-mouse-read-string-return-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (nreverse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (cdr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (nreverse vm-mouse-read-string-return-value)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 ((equal string done-doc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (vm-mouse-read-string-quit-handler t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (t (setq vm-mouse-read-string-return-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (nconc vm-mouse-read-string-return-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (list string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (if (null vm-mouse-read-string-multi-word)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (vm-mouse-read-string-quit-handler t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (setq buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (setq start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (insert vm-mouse-read-string-prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (vm-set-region-face start (point) 'bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (insert (mapconcat 'identity vm-mouse-read-string-return-value " "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (insert ?\n ?\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (setq start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (insert key-doc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (vm-mouse-set-mouse-track-highlight start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (vm-set-region-face start (point) 'italic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (insert ?\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (if vm-mouse-read-string-multi-word
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (setq start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (insert bs-doc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (vm-mouse-set-mouse-track-highlight start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (vm-set-region-face start (point) 'italic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (insert ?\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (setq start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (insert done-doc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (vm-mouse-set-mouse-track-highlight start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (vm-set-region-face start (point) 'italic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (insert ?\n)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (insert ?\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (vm-show-list vm-mouse-read-string-completion-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 'vm-mouse-read-string-event-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 (setq buffer-read-only t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 (defun vm-mouse-read-string-quit-handler (&optional normal-exit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 (interactive)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
494 (let ((vm-mutable-frames t))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
495 (vm-delete-windows-or-frames-on (current-buffer))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
496 (if normal-exit
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
497 (throw 'exit nil)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
498 (throw 'exit t))))