(define-error 'file-locked "File is locked" 'file-error) ; XEmacs
-(defun ask-user-about-lock-minibuf (fn opponent)
+(defun ask-user-about-lock-minibuf (filename other-user)
(save-window-excursion
(let (answer)
(while (null answer)
- (message "%s is locking %s: action (s, q, p, ?)? " opponent fn)
+ (message "%s is locking %s: action (s, q, p, ?)? " other-user filename)
(let ((tem (let ((inhibit-quit t)
(cursor-in-echo-area t))
(prog1 (downcase (read-char))
(ask-user-about-lock-help)
(setq answer nil))
((eq (cdr answer) 'yield)
- (signal 'file-locked (list "File is locked" fn opponent)))))))
+ (signal 'file-locked (list "File is locked" filename other-user)))))))
(cdr answer))))
(defun ask-user-about-lock-help ()
(define-error 'file-supersession "File changed on disk" 'file-error) ; XEmacs
-(defun ask-user-about-supersession-threat-minibuf (fn)
+(defun ask-user-about-supersession-threat-minibuf (filename)
(save-window-excursion
(let (answer)
(while (null answer)
(message "%s changed on disk; really edit the buffer? (y, n, r or C-h) "
- (file-name-nondirectory fn))
+ (file-name-nondirectory filename))
(let ((tem (downcase (let ((cursor-in-echo-area t))
(read-char)))))
(setq answer
(revert-buffer nil (not (buffer-modified-p)))
; ask confirmation iff buffer modified
(signal 'file-supersession
- (list "File reverted" fn)))
+ (list "File reverted" filename)))
((eq answer 'yield)
(signal 'file-supersession
- (list "File changed on disk" fn))))))
+ (list "File changed on disk" filename))))))
(message
"File on disk now will become a backup file if you save these changes.")
(setq buffer-backed-up nil))))
\f
;;; dialog-box versions [XEmacs]
-(defun ask-user-about-lock-dbox (fn opponent)
+(defun ask-user-about-lock-dbox (filename other-user)
(let ((echo-keystrokes 0))
(make-dialog-box
'question
:question (format "%s is locking %s\n
It has been detected that you want to modify a file that
someone else has already started modifying in XEmacs."
- opponent fn)
+ other-user filename)
:buttons
'(["Steal Lock\n\nThe other user will\nbecome the intruder" steal t]
["Proceed\n\nEdit file at your own\n\(and the other user's) risk"
(throw 'aual-done t))
((and (misc-user-event-p event)
(eq (event-object event) 'yield))
- (signal 'file-locked (list "File is locked" fn opponent)))
+ (signal 'file-locked (list "File is locked" filename other-user)))
((and (misc-user-event-p event)
(eq (event-object event) 'menu-no-selection-hook))
(signal 'quit nil))
(beep)
(message "please answer the dialog box"))))))))
-(defun ask-user-about-supersession-threat-dbox (fn)
+(defun ask-user-about-supersession-threat-dbox (filename)
(let ((echo-keystrokes 0))
(make-dialog-box
'question
(format "File %s has changed on disk
since its buffer was last read in or saved.
-Do you really want to edit the buffer? " fn)
+Do you really want to edit the buffer? " filename)
:buttons
'(["Yes\n\nEdit the buffer anyway,\nignoring the disk file"
proceed t]
(cond ((and (misc-user-event-p event) (eq (event-object event) 'proceed))
(throw 'auast-done nil))
((and (misc-user-event-p event) (eq (event-object event) 'yield))
- (signal 'file-supersession (list fn)))
+ (signal 'file-supersession (list filename)))
((and (misc-user-event-p event) (eq (event-object event) 'revert))
- (or (equal fn (buffer-file-name))
+ (or (equal filename (buffer-file-name))
(error
"ask-user-about-supersession-threat called bogusly"))
(revert-buffer nil t)
(signal 'file-supersession
- (list fn "(reverted)")))
+ (list filename "(reverted)")))
((and (misc-user-event-p event)
(eq (event-object event) 'menu-no-selection-hook))
(signal 'quit nil))
;;; top-level
;;;###autoload
-(defun ask-user-about-lock (fn opponent)
- "Ask user what to do when he wants to edit FILE but it is locked by USER.
+(defun ask-user-about-lock (filename other-user)
+ "Ask user wanting to edit FILENAME, locked by OTHER-USER, what to do.
This function has a choice of three things to do:
- do (signal 'file-locked (list FILE USER))
+ do (signal 'file-locked (list FILENAME OTHER-USER))
to refrain from editing the file
return t (grab the lock on the file)
return nil (edit the file even though it is locked).
-You can rewrite it to use any criterion you like to choose which one to do."
+You can rewrite it to use any criteria you like to choose which one to do."
(discard-input)
(if (should-use-dialog-box-p)
- (ask-user-about-lock-dbox fn opponent)
- (ask-user-about-lock-minibuf fn opponent)))
+ (ask-user-about-lock-dbox filename other-user)
+ (ask-user-about-lock-minibuf filename other-user)))
;;;###autoload
-(defun ask-user-about-supersession-threat (fn)
- "Ask a user who is about to modify an obsolete buffer what to do.
+(defun ask-user-about-supersession-threat (filename)
+ "Ask user who is about to modify an obsolete buffer what to do.
This function has two choices: it can return, in which case the modification
-of the buffer will proceed, or it can (signal 'file-supersession (file)),
+of the buffer will proceed, or it can (signal 'file-supersession (FILENAME)),
in which case the proposed buffer modification will not be made.
-You can rewrite this to use any criterion you like to choose which one to do.
+You can rewrite this to use any criteria you like to choose which one to do.
The buffer in question is current when this function is called."
(discard-input)
(if (should-use-dialog-box-p)
- (ask-user-about-supersession-threat-dbox fn)
- (ask-user-about-supersession-threat-minibuf fn)))
+ (ask-user-about-supersession-threat-dbox filename)
+ (ask-user-about-supersession-threat-minibuf filename)))
;;; userlock.el ends here