emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master e49c46f 2/3: Make NSM prompting clearer


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] master e49c46f 2/3: Make NSM prompting clearer
Date: Fri, 05 Feb 2016 03:43:53 +0000

branch: master
commit e49c46f771e52dd1d050114bba605a26c2061ab2
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>

    Make NSM prompting clearer
    
    * lisp/net/nsm.el (nsm-query-user): Use read-multiple-choice
    to prompt in a nicer way (bug#19368).
---
 lisp/net/nsm.el |   38 +++++++++++++++-----------------------
 1 files changed, 15 insertions(+), 23 deletions(-)

diff --git a/lisp/net/nsm.el b/lisp/net/nsm.el
index ee8b55b..b039d11 100644
--- a/lisp/net/nsm.el
+++ b/lisp/net/nsm.el
@@ -297,7 +297,11 @@ unencrypted."
       nil
     (let ((response
           (condition-case nil
-              (nsm-query-user message args (nsm-format-certificate status))
+               (intern
+                (car (split-string
+                      (nsm-query-user message args
+                                      (nsm-format-certificate status))))
+                obarray)
             ;; Make sure we manage to close the process if the user hits
             ;; `C-g'.
             (quit 'no)
@@ -309,6 +313,7 @@ unencrypted."
 
 (defun nsm-query-user (message args cert)
   (let ((buffer (get-buffer-create "*Network Security Manager*")))
+    ;; First format the certificate and warnings.
     (with-help-window buffer
       (with-current-buffer buffer
        (erase-buffer)
@@ -320,28 +325,15 @@ unencrypted."
          ;; Fill the first line of the message, which usually
          ;; contains lots of explanatory text.
          (fill-region (point) (line-end-position)))))
-    (let ((responses '((?n . no)
-                      (?s . session)
-                      (?a . always)))
-         (prefix "")
-         (cursor-in-echo-area t)
-         response)
-      (while (not response)
-       (setq response
-             (cdr
-              (assq (downcase
-                     (read-char
-                      (concat prefix
-                              "Continue connecting? (No, Session only, Always) 
")))
-                    responses)))
-       (unless response
-         (ding)
-         (setq prefix "Invalid choice.  ")))
-      (kill-buffer buffer)
-      ;; If called from a callback, `read-char' will insert things
-      ;; into the pending input.  Clear that.
-      (clear-this-command-keys)
-      response)))
+    ;; Then ask the user what to do about it.
+    (unwind-protect
+        (cadr
+         (read-multiple-choice
+          "Continue connecting?"
+          '((?a "always" "Accept this certificate this session and for all 
future sessions.")
+            (?s "session only" "Accept this certificate this session only.")
+            (?n "no" "Refuse to use this certificate, and close the 
connection."))))
+      (kill-buffer buffer))))
 
 (defun nsm-save-host (host port status what permanency)
   (let* ((id (nsm-id host port))



reply via email to

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