X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=lisp%2Fuserlock.el;h=7f4657c5d2260cd1cce68a044eaa093b21ba9137;hb=d8c05de64f98142760a5c0dceda85841d839caa4;hp=ff7f3440800bc2a36ec54fa07eb041906d068ec2;hpb=59eec5f21669e81977b5b1fe9bf717cab49cf7fb;p=chise%2Fxemacs-chise.git.1 diff --git a/lisp/userlock.el b/lisp/userlock.el index ff7f344..7f4657c 100644 --- a/lisp/userlock.el +++ b/lisp/userlock.el @@ -35,11 +35,11 @@ (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)) @@ -59,7 +59,7 @@ (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 () @@ -77,12 +77,12 @@ You can uit; don't modify this file.") (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 @@ -104,10 +104,10 @@ You can uit; don't modify this file.") (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)))) @@ -131,14 +131,14 @@ to get the latest version of the file, then make the change again.") ;;; 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" @@ -156,7 +156,7 @@ to get the latest version of the file, then make the change again.") (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)) @@ -170,7 +170,7 @@ to get the latest version of the file, then make the change again.") (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 @@ -178,7 +178,7 @@ to get the latest version of the file, then make the change again.") (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] @@ -192,14 +192,14 @@ Do you really want to edit the buffer? " fn) (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)) @@ -217,31 +217,31 @@ Do you really want to edit the buffer? " fn) ;;; 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