annotate lisp/prim/userlock.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children b82b59fe008d
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 ;;; userlock.el --- handle file access contention between multiple users
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Copyright (C) 1985, 1986, 1993 Free Software Foundation, inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Maintainer: FSF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Keywords: internal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; along with XEmacs; see the file COPYING. If not, write to the Free
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;; Synched up with: FSF 19.30.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;; This file is autoloaded to handle certain conditions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;; detected by the file-locking code within XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; The two entry points are `ask-user-about-lock' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;; `ask-user-about-supersession-threat'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (define-error 'file-locked "File is locked" 'file-error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (defun ask-user-about-lock-minibuf (fn opponent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 (let (answer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (while (null answer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (message "%s is locking %s: action (s, q, p, ?)? " opponent fn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (let ((tem (let ((inhibit-quit t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (cursor-in-echo-area t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (prog1 (downcase (read-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (setq quit-flag nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (if (= tem help-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (ask-user-about-lock-help)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (setq answer (assoc tem '((?s . t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (?q . yield)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (?\C-g . yield)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (?p . nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (?? . help))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (cond ((null answer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (message "Please type q, s, or p; or ? for help")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (sit-for 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ((eq (cdr answer) 'help)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (ask-user-about-lock-help)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (setq answer nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ((eq (cdr answer) 'yield)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (signal 'file-locked (list fn opponent)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (cdr answer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (defun ask-user-about-lock-help ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (with-output-to-temp-buffer "*Help*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (princ "It has been detected that you want to modify a file that someone else has
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 already started modifying in EMACS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 You can <s>teal the file; The other user becomes the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 intruder if (s)he ever unmodifies the file and then changes it again.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 You can <p>roceed; you edit at your own (and the other user's) risk.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 You can <q>uit; don't modify this file.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (set-buffer standard-output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (help-mode))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (define-error 'file-supersession "File changed on disk" 'file-error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (defun ask-user-about-supersession-threat-minibuf (fn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (let (answer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (while (null answer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (message "%s changed on disk; really edit the buffer? (y, n or C-h) "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (file-name-nondirectory fn))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (let ((tem (downcase (let ((cursor-in-echo-area t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (read-char)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (setq answer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (if (= tem help-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 'help
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (cdr (assoc tem '((?n . yield)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (?\C-g . yield)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (?y . proceed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (?? . help))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (cond ((null answer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (message "Please type y or n; or ? for help")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (sit-for 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ((eq answer 'help)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (ask-user-about-supersession-help)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (setq answer nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 ((eq answer 'yield)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (signal 'file-supersession
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (list fn))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 "File on disk now will become a backup file if you save these changes.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (setq buffer-backed-up nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (defun ask-user-about-supersession-help ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (with-output-to-temp-buffer "*Help*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (princ "You want to modify a buffer whose disk file has changed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 since you last read it in or saved it with this buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 If you say `y' to go ahead and modify this buffer,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 you risk ruining the work of whoever rewrote the file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 If you say `n', the change you started to make will be aborted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 Usually, you should type `n' and then `M-x revert-buffer',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 to get the latest version of the file, then make the change again.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (set-buffer standard-output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (help-mode))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 ;;; dialog-box versions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (defun ask-user-about-lock-dbox (fn opponent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (let ((echo-keystrokes 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (dbox
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (format "%s is locking %s\n
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 It has been detected that you want to modify a file that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 someone else has already started modifying in XEmacs."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 opponent fn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 '(["Steal Lock\n\nThe other user will\nbecome the intruder" steal t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 ["Proceed\n\nEdit file at your own\n\(and the other user's) risk"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 proceed t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 ["Abort\n\nDon't modify the buffer\n" yield t]))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (popup-dialog-box dbox)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (catch 'aual-done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (while t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (let ((event (next-command-event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (cond ((and (misc-user-event-p event) (eq (event-object event) 'proceed))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (throw 'aual-done nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 ((and (misc-user-event-p event) (eq (event-object event) 'steal))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (throw 'aual-done t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 ((and (misc-user-event-p event) (eq (event-object event) 'yield))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (signal 'file-locked (list fn opponent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 ((button-release-event-p event) ;; don't beep twice
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (message "please answer the dialog box"))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (defun ask-user-about-supersession-threat-dbox (fn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (let ((echo-keystrokes 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (dbox
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (format "File %s has changed on disk
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 since its buffer was last read in or saved.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 Do you really want to edit the buffer? " fn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 '(["Yes\n\nEdit the buffer anyway,\nignoring the disk file"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 proceed t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 ["No\n\nDon't modify the buffer\n" yield t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 ["No\n\nDon't modify the buffer\nbut revert it" revert t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (popup-dialog-box dbox)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (catch 'auast-done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (while t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (let ((event (next-command-event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (cond ((and (misc-user-event-p event) (eq (event-object event) 'proceed))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (throw 'auast-done nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 ((and (misc-user-event-p event) (eq (event-object event) 'yield))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (signal 'file-supersession (list fn)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 ((and (misc-user-event-p event) (eq (event-object event) 'revert))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (or (equal fn (buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 "ask-user-about-supersession-threat called bogusly"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (revert-buffer nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (signal 'file-supersession
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (list fn "(reverted)")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ((button-release-event-p event) ;; don't beep twice
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (message "please answer the dialog box"))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 ;;; top-level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (defun ask-user-about-lock (fn opponent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 "Ask user what to do when he wants to edit FILE but it is locked by USER.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 This function has a choice of three things to do:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 do (signal 'file-locked (list FILE USER))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 to refrain from editing the file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 return t (grab the lock on the file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 return nil (edit the file even though it is locked).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 You can rewrite it to use any criterion you like to choose which one to do."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (discard-input)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (if (and (fboundp 'popup-dialog-box)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (or (button-press-event-p last-command-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (button-release-event-p last-command-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (misc-user-event-p last-command-event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (ask-user-about-lock-dbox fn opponent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (ask-user-about-lock-minibuf fn opponent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (defun ask-user-about-supersession-threat (fn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 "Ask a user who is about to modify an obsolete buffer what to do.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 This function has two choices: it can return, in which case the modification
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 of the buffer will proceed, or it can (signal 'file-supersession (file)),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 in which case the proposed buffer modification will not be made.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 You can rewrite this to use any criterion you like to choose which one to do.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 The buffer in question is current when this function is called."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (discard-input)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (if (and (fboundp 'popup-dialog-box)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (or (button-press-event-p last-command-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (button-release-event-p last-command-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (misc-user-event-p last-command-event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (ask-user-about-supersession-threat-dbox fn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (ask-user-about-supersession-threat-minibuf fn)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 ;;; userlock.el ends here