emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] master a61d78e 03/13: Ask the user about saving network interface


From: Ian Dunn
Subject: [elpa] master a61d78e 03/13: Ask the user about saving network interfaces during `enwc-setup'
Date: Sat, 15 Apr 2017 16:02:43 -0400 (EDT)

branch: master
commit a61d78e3f98f53744aa2c616e1fc71bc6d43c3d0
Author: Ian Dunn <address@hidden>
Commit: Ian Dunn <address@hidden>

    Ask the user about saving network interfaces during `enwc-setup'
    
    * enwc.el (enwc-ask-to-save-interfaces): New defcustom.
      (enwc--select-interfaces): Use it, and ask about saving interface changes
      using `customize-save-variable'.
---
 enwc.el | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/enwc.el b/enwc.el
index ce98cd4..f2dd613 100644
--- a/enwc.el
+++ b/enwc.el
@@ -122,6 +122,11 @@ connection.
   :group 'enwc
   :type 'boolean)
 
+(defcustom enwc-ask-to-save-interfaces t
+  "Whether to ask about saving changes to the network interfaces during 
`enwc-setup'."
+  :group 'enwc
+  :type 'boolean)
+
 (defvar enwc-display-string " [0%] "
   "The mode line display string.
 This is altered every second to display the current network strength
@@ -695,11 +700,19 @@ One interface will be used for wireless, and the other 
for wired.
 There is no need to call this function manually; that should be
 left to `enwc-setup'.  Instead, set `enwc-wireless-device' and
 `enwc-wired-device'."
-  (let ((interfaces (funcall enwc-interface-list-function)))
+  (let ((interfaces (funcall enwc-interface-list-function))
+        changed)
     (when (string-empty-p enwc-wired-device)
-      (setq enwc-wired-device (completing-read "Wired Interface: " 
interfaces)))
+      (setq enwc-wired-device (completing-read "Wired Interface: " interfaces))
+      (setq changed t))
     (when (string-empty-p enwc-wireless-device)
-      (setq enwc-wireless-device (completing-read "Wireless Interface: " 
interfaces)))))
+      (setq enwc-wireless-device (completing-read "Wireless Interface: " 
interfaces))
+      (setq changed t))
+    (when (and changed
+               enwc-ask-to-save-interfaces
+               (y-or-n-p "Network Interfaces changed.  Save for future 
sessions? "))
+      (customize-save-variable 'enwc-wired-device enwc-wired-device)
+      (customize-save-variable 'enwc-wireless-device enwc-wireless-device))))
 
 (defvar enwc-mode-map
   (let ((map (make-sparse-keymap)))



reply via email to

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