emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 8d68025: Use the minibuffer to read answer in userlock.el (bug#38


From: Juri Linkov
Subject: master 8d68025: Use the minibuffer to read answer in userlock.el (bug#38076)
Date: Sat, 9 Nov 2019 17:43:17 -0500 (EST)

branch: master
commit 8d68025baf912462748ce94ba79f2f54cdd22283
Author: Juri Linkov <address@hidden>
Commit: Juri Linkov <address@hidden>

    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.
---
 lisp/userlock.el | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/lisp/userlock.el b/lisp/userlock.el
index 2097686..1d3ac845 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))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]