diff options
author | Juri Linkov <juri@linkov.net> | 2019-11-10 00:43:09 +0200 |
---|---|---|
committer | Juri Linkov <juri@linkov.net> | 2019-11-10 00:43:09 +0200 |
commit | 8d68025baf912462748ce94ba79f2f54cdd22283 (patch) | |
tree | 58201e61386f5d99e363d06d31bf51848fe5fed5 /lisp/userlock.el | |
parent | d370c6a686b85abe1a617475e2d9279d506eac46 (diff) | |
download | emacs-8d68025baf912462748ce94ba79f2f54cdd22283.tar.gz |
Use the minibuffer to read answer in userlock.el (bug#38076)
* lisp/userlock.el: Rename 'fn' to 'filename'.
(ask-user-about-supersession-threat): Use read-char-from-minibuffer
instead of read-char-choice.
Diffstat (limited to 'lisp/userlock.el')
-rw-r--r-- | lisp/userlock.el | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/lisp/userlock.el b/lisp/userlock.el index 209768620c1..1d3ac845841 100644 --- a/lisp/userlock.el +++ b/lisp/userlock.el @@ -103,11 +103,11 @@ You can <q>uit; don't modify this file.") (define-error 'file-supersession nil 'file-error) -(defun userlock--check-content-unchanged (fn) +(defun userlock--check-content-unchanged (filename) (with-demoted-errors "Unchanged content check: %S" - ;; Even tho we receive `fn', we know that `fn' refers to the current + ;; Even tho we receive `filename', we know that `filename' refers to the current ;; buffer's file. - (cl-assert (equal fn (expand-file-name buffer-file-truename))) + (cl-assert (equal filename (expand-file-name buffer-file-truename))) ;; Note: rather than read the file and compare to the buffer, we could save ;; the buffer and compare to the file, but for encrypted data this ;; wouldn't work well (and would risk exposing the data). @@ -123,7 +123,7 @@ You can <q>uit; don't modify this file.") (when (with-temp-buffer (let ((coding-system-for-read cs) (non-essential t)) - (insert-file-contents fn)) + (insert-file-contents filename)) (when (= (buffer-size) (- end start)) ;Minor optimization. (= 0 (let ((case-fold-search nil)) (compare-buffer-substrings @@ -133,13 +133,13 @@ You can <q>uit; don't modify this file.") 'unchanged))))) ;;;###autoload -(defun userlock--ask-user-about-supersession-threat (fn) +(defun userlock--ask-user-about-supersession-threat (filename) ;; Called from filelock.c. - (unless (userlock--check-content-unchanged fn) - (ask-user-about-supersession-threat fn))) + (unless (userlock--check-content-unchanged filename) + (ask-user-about-supersession-threat filename))) ;;;###autoload -(defun ask-user-about-supersession-threat (fn) +(defun ask-user-about-supersession-threat (filename) "Ask a 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)), @@ -152,14 +152,14 @@ The buffer in question is current when this function is called." (let ((prompt (format "%s changed on disk; \ really edit the buffer? (y, n, r or C-h) " - (file-name-nondirectory fn))) + (file-name-nondirectory filename))) (choices '(?y ?n ?r ?? ?\C-h)) answer) (when noninteractive (message "%s" prompt) (error "Cannot resolve conflict in batch mode")) (while (null answer) - (setq answer (read-char-choice prompt choices)) + (setq answer (read-char-from-minibuffer prompt choices)) (cond ((memq answer '(?? ?\C-h)) (ask-user-about-supersession-help) (setq answer nil)) @@ -167,10 +167,10 @@ really edit the buffer? (y, n, r or C-h) " ;; Ask for confirmation if buffer modified (revert-buffer nil (not (buffer-modified-p))) (signal 'file-supersession - (list "File reverted" fn))) + (list "File reverted" filename))) ((eq answer ?n) (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)))) |