annotate lisp/vm/vm-mouse.el @ 100:4be1180a9e89 r20-1b2

Import from CVS: tag r20-1b2
author cvs
date Mon, 13 Aug 2007 09:15:11 +0200
parents 0d2f883870bc
children a145efe76779
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 ()
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
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 ()
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
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)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
29 (cond ((fboundp 'make-overlay)
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)))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
32 ((fboundp 'make-extent)
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)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
78 (vm-menu-popup-mode-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)))))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
93 (cond ((fboundp 'overlays-at)
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 ))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
104 ((fboundp 'extent-at)
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)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
187 (vm-unsaved-message "Sending URL to %s..." browser)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
188 (vm-run-background-command browser url)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
189 (vm-unsaved-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)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
192 (vm-unsaved-message "Sending URL to Netscape...")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (if new-netscape
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
194 (vm-run-background-command vm-netscape-program url)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
195 (or (equal 0 (vm-run-command vm-netscape-program "-remote"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
196 (concat "openURL(" url
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
197 (if new-window ", new-window" "")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
198 ")")))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (vm-mouse-send-url-to-netscape url t new-window)))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
200 (vm-unsaved-message "Sending URL to Netscape... done"))
54
05472e90ae02 Import from CVS: tag r19-16-pre2
cvs
parents: 36
diff changeset
201
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (defun vm-mouse-send-url-to-mosaic (url &optional new-mosaic new-window)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
203 (vm-unsaved-message "Sending URL to Mosaic...")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (if (null new-mosaic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (let ((pid-file "~/.mosaicpid")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (work-buffer " *mosaic work*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 pid)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (cond ((file-exists-p pid-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (set-buffer (get-buffer-create work-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (insert-file-contents pid-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (setq pid (int-to-string (string-to-int (buffer-string))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (insert (if new-window "newwin" "goto") ?\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (insert url ?\n)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
216 ;; newline convention used should be the local
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
217 ;; one, whatever that is.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
218 (setq buffer-file-type nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
219 (and (fboundp 'set-file-coding-system)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
220 (set-file-coding-system 'no-conversion nil))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (write-region (point-min) (point-max)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (concat "/tmp/Mosaic." pid)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 nil 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (kill-buffer work-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (cond ((or (null pid)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (not (equal 0 (vm-run-command "kill" "-USR1" pid))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (setq new-mosaic t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (if new-mosaic
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
230 (vm-run-background-command vm-mosaic-program url))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
231 (vm-unsaved-message "Sending URL to Mosaic... done"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232
54
05472e90ae02 Import from CVS: tag r19-16-pre2
cvs
parents: 36
diff changeset
233
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (defun vm-mouse-install-mouse ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (cond ((vm-mouse-xemacs-mouse-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (if (null (lookup-key vm-mode-map 'button2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (define-key vm-mode-map 'button2 'vm-mouse-button-2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 ((vm-mouse-fsfemacs-mouse-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (if (null (lookup-key vm-mode-map [mouse-2]))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (define-key vm-mode-map [mouse-2] 'vm-mouse-button-2))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
241 (if vm-popup-menu-on-mouse-3
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (define-key vm-mode-map [mouse-3] 'ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (define-key vm-mode-map [down-mouse-3] 'vm-mouse-button-3))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (defun vm-run-background-command (command &rest arg-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (apply (function call-process) command nil 0 nil arg-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (defun vm-run-command (command &rest arg-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (apply (function call-process) command nil nil nil arg-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
252 ;; return t on zero exit status
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
253 ;; return (exit-status . stderr-string) on nonzero exit status
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
254 (defun vm-run-command-on-region (start end output-buffer command
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
255 &rest arg-list)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
256 (let ((tempfile nil) status errstring)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
257 (unwind-protect
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
258 (progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
259 (setq tempfile (vm-make-tempfile-name))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
260 (setq status
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
261 (apply 'call-process-region
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
262 start end command nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
263 (list output-buffer tempfile)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
264 nil arg-list))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
265 (cond ((equal status 0) t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
266 ((zerop (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
267 (set-buffer (find-file-noselect tempfile))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
268 (buffer-size)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
269 t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
270 (t (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
271 (set-buffer (find-file-noselect tempfile))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
272 (setq errstring (buffer-string))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
273 (kill-buffer nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
274 (cons status errstring)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
275 (vm-error-free-call 'delete-file tempfile))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
276
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 ;; stupid yammering compiler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (defvar vm-mouse-read-file-name-prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (defvar vm-mouse-read-file-name-dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (defvar vm-mouse-read-file-name-default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (defvar vm-mouse-read-file-name-must-match)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (defvar vm-mouse-read-file-name-initial)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (defvar vm-mouse-read-file-name-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (defvar vm-mouse-read-file-name-return-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (defun vm-mouse-read-file-name (prompt &optional dir default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 must-match initial history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 "Like read-file-name, except uses a mouse driven interface.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 HISTORY argument is ignored."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (or dir (setq dir default-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (set-buffer (generate-new-buffer " *Files*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (use-local-map (make-sparse-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (setq buffer-read-only t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 default-directory dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (make-local-variable 'vm-mouse-read-file-name-prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (make-local-variable 'vm-mouse-read-file-name-dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (make-local-variable 'vm-mouse-read-file-name-default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (make-local-variable 'vm-mouse-read-file-name-must-match)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (make-local-variable 'vm-mouse-read-file-name-initial)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (make-local-variable 'vm-mouse-read-file-name-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (make-local-variable 'vm-mouse-read-file-name-return-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (setq vm-mouse-read-file-name-prompt prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (setq vm-mouse-read-file-name-dir dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (setq vm-mouse-read-file-name-default default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (setq vm-mouse-read-file-name-must-match must-match)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (setq vm-mouse-read-file-name-initial initial)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (setq vm-mouse-read-file-name-history history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (setq vm-mouse-read-file-name-prompt prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (setq vm-mouse-read-file-name-return-value nil)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
311 (if (and vm-frame-per-completion (vm-multiple-frames-possible-p))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
312 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
313 (vm-goto-new-frame 'completion)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (switch-to-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (vm-mouse-read-file-name-event-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (local-set-key "\C-g" 'vm-mouse-read-file-name-quit-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (recursive-edit))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 ;; buffer could have been killed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (and (boundp 'vm-mouse-read-file-name-return-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 vm-mouse-read-file-name-return-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (kill-buffer (current-buffer))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (defun vm-mouse-read-file-name-event-handler (&optional string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (let ((key-doc "Click here for keyboard interface.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 start list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (if string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (cond ((equal string key-doc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (save-excursion
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
332 (save-excursion
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
333 (let ((vm-mutable-frames t))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
334 (vm-delete-windows-or-frames-on (current-buffer))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (setq vm-mouse-read-file-name-return-value
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
336 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
337 (vm-keyboard-read-file-name
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
338 vm-mouse-read-file-name-prompt
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
339 vm-mouse-read-file-name-dir
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
340 vm-mouse-read-file-name-default
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
341 vm-mouse-read-file-name-must-match
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
342 vm-mouse-read-file-name-initial
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
343 vm-mouse-read-file-name-history)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (vm-mouse-read-file-name-quit-handler t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (quit (vm-mouse-read-file-name-quit-handler))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 ((file-directory-p string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (setq default-directory (expand-file-name string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (t (setq vm-mouse-read-file-name-return-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (expand-file-name string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (vm-mouse-read-file-name-quit-handler t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (setq buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (setq start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (insert vm-mouse-read-file-name-prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (vm-set-region-face start (point) 'bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (cond ((and (not string) vm-mouse-read-file-name-default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (setq start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (insert vm-mouse-read-file-name-default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (vm-mouse-set-mouse-track-highlight start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 ((not string) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (t (insert default-directory)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (insert ?\n ?\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (setq start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (insert key-doc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (vm-mouse-set-mouse-track-highlight start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (vm-set-region-face start (point) 'italic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (insert ?\n ?\n)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
368 (setq list (vm-delete-backup-file-names
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
369 (vm-delete-auto-save-file-names
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
370 (directory-files default-directory))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (vm-show-list list 'vm-mouse-read-file-name-event-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (setq buffer-read-only t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (defun vm-mouse-read-file-name-quit-handler (&optional normal-exit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (interactive)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
376 (let ((vm-mutable-frames t))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
377 (vm-delete-windows-or-frames-on (current-buffer))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
378 (if normal-exit
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
379 (throw 'exit nil)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
380 (throw 'exit t))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (defvar vm-mouse-read-string-prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (defvar vm-mouse-read-string-completion-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (defvar vm-mouse-read-string-multi-word)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (defvar vm-mouse-read-string-return-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (defun vm-mouse-read-string (prompt completion-list &optional multi-word)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (set-buffer (generate-new-buffer " *Choices*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (use-local-map (make-sparse-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (setq buffer-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (make-local-variable 'vm-mouse-read-string-prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (make-local-variable 'vm-mouse-read-string-completion-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (make-local-variable 'vm-mouse-read-string-multi-word)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (make-local-variable 'vm-mouse-read-string-return-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (setq vm-mouse-read-string-prompt prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (setq vm-mouse-read-string-completion-list completion-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (setq vm-mouse-read-string-multi-word multi-word)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (setq vm-mouse-read-string-return-value nil)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
400 (if (and vm-frame-per-completion (vm-multiple-frames-possible-p))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
401 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
402 (vm-goto-new-frame 'completion)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (switch-to-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (vm-mouse-read-string-event-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (local-set-key "\C-g" 'vm-mouse-read-string-quit-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (recursive-edit))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 ;; buffer could have been killed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (and (boundp 'vm-mouse-read-string-return-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (if (listp vm-mouse-read-string-return-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (mapconcat 'identity vm-mouse-read-string-return-value " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 vm-mouse-read-string-return-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (kill-buffer (current-buffer))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (defun vm-mouse-read-string-event-handler (&optional string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (let ((key-doc "Click here for keyboard interface.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (bs-doc " .... to go back one word.")
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
419 (done-doc " .... when you're done.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 start list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (if string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (cond ((equal string key-doc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (save-excursion
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
425 (save-excursion
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
426 (let ((vm-mutable-frames t))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
427 (vm-delete-windows-or-frames-on (current-buffer))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (setq vm-mouse-read-string-return-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (vm-keyboard-read-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 vm-mouse-read-string-prompt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 vm-mouse-read-string-completion-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 vm-mouse-read-string-multi-word))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (vm-mouse-read-string-quit-handler t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (quit (vm-mouse-read-string-quit-handler))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 ((equal string bs-doc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (setq vm-mouse-read-string-return-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (nreverse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (cdr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (nreverse vm-mouse-read-string-return-value)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 ((equal string done-doc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (vm-mouse-read-string-quit-handler t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (t (setq vm-mouse-read-string-return-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (nconc vm-mouse-read-string-return-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (list string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (if (null vm-mouse-read-string-multi-word)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (vm-mouse-read-string-quit-handler t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (setq buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (setq start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (insert vm-mouse-read-string-prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 (vm-set-region-face start (point) 'bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (insert (mapconcat 'identity vm-mouse-read-string-return-value " "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (insert ?\n ?\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (setq start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (insert key-doc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (vm-mouse-set-mouse-track-highlight start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (vm-set-region-face start (point) 'italic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (insert ?\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (if vm-mouse-read-string-multi-word
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (setq start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (insert bs-doc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (vm-mouse-set-mouse-track-highlight start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (vm-set-region-face start (point) 'italic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (insert ?\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (setq start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (insert done-doc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (vm-mouse-set-mouse-track-highlight start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (vm-set-region-face start (point) 'italic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (insert ?\n)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (insert ?\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (vm-show-list vm-mouse-read-string-completion-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 'vm-mouse-read-string-event-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (setq buffer-read-only t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (defun vm-mouse-read-string-quit-handler (&optional normal-exit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (interactive)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
478 (let ((vm-mutable-frames t))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
479 (vm-delete-windows-or-frames-on (current-buffer))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
480 (if normal-exit
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
481 (throw 'exit nil)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
482 (throw 'exit t))))