annotate lisp/prim/userlock.el @ 70:131b0175ea99 r20-0b30

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