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

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

[elpa] master e8b1d77 05/76: * enwc.el (enwc-display-mode-line-timer): A


From: Ian Dunn
Subject: [elpa] master e8b1d77 05/76: * enwc.el (enwc-display-mode-line-timer): Added a variable for the mode line timer.
Date: Thu, 23 Feb 2017 19:42:43 -0500 (EST)

branch: master
commit e8b1d77f4940804f97a7d8cbc865bca86c25090a
Author: Ian D <address@hidden>
Commit: Ian D <address@hidden>

    * enwc.el (enwc-display-mode-line-timer): Added a variable for the mode 
line timer.
    (enwc-scan-timer, enwc-auto-scan, enwc-auto-scan-interval, 
enwc-toggle-auto-scan):  Added support for automatic scans.
    (enwc-scan-internal-wireless, enwc-process-scan): Only displays scanning 
message when interactive.
    
    * enwc-setup.el (enwc-setup): Initializes the timers for mode line display 
and automatic scanning.
---
 lisp/enwc-setup.el | 10 +++++++---
 lisp/enwc.el       | 35 +++++++++++++++++++++++++++++++++--
 2 files changed, 40 insertions(+), 5 deletions(-)

diff --git a/lisp/enwc-setup.el b/lisp/enwc-setup.el
index fddcd08..33a156c 100644
--- a/lisp/enwc-setup.el
+++ b/lisp/enwc-setup.el
@@ -89,8 +89,7 @@
                                                "-get-nw-info"))
          enwc-save-nw-settings-func (intern (concat "enwc-"
                                                     sym-name
-                                                    "-save-nw-settings"))
-         )
+                                                    "-save-nw-settings")))
     (funcall (intern (concat "enwc-" sym-name "-setup")))))
 
 (defun enwc-setup ()
@@ -100,7 +99,12 @@ on D-Bus."
   (if enwc-display-mode-line
       (setq global-mode-string (append global-mode-string
                                        '(enwc-display-string))))
-  (run-at-time t 1 'enwc-update-mode-line)
+  (setq enwc-display-mode-line-timer 
+        (run-at-time t 1 'enwc-update-mode-line))
+
+  (if (and enwc-auto-scan (> enwc-auto-scan-interval 0))
+      (setq enwc-scan-timer
+            (run-at-time t enwc-auto-scan-interval 'enwc-scan t)))
 
   (let ((cur-back nil)
        (back-list enwc-backends))
diff --git a/lisp/enwc.el b/lisp/enwc.el
index 8436c79..1f786dc 100644
--- a/lisp/enwc.el
+++ b/lisp/enwc.el
@@ -78,6 +78,18 @@ Emacs mode line."
   :group 'enwc
   :type 'boolean)
 
+(defcustom enwc-auto-scan 't
+  "Whether or not to have ENWC automatically scan.
+If non-nil, then ENWC will automatically scan for
+networks every `enwc-auto-scan-interval' seconds."
+  :group 'enwc
+  :type 'boolean)
+
+(defcustom enwc-auto-scan-interval 20
+  "The interval between automatic scans."
+  :group 'enwc
+  :type 'integer)
+
 ;;; The function variables for the abstract layer.
 
 (defvar enwc-scan-func nil
@@ -245,6 +257,12 @@ This is used so as to avoid multiple updates of the scan 
data.")
   "Indicates that a scan was interactively requested.
 This is only used internally.")
 
+(defvar enwc-display-mode-line-timer nil
+  "The timer that updates the mode line display.")
+
+(defvar enwc-scan-timer nil
+  "The timer for automatic scanning.")
+
 (make-local-variable 'enwc-edit-id)
 ;; The Fonts
 
@@ -448,6 +466,17 @@ This is initiated during setup, and runs once every 
second."
       (setq global-mode-string (delq 'enwc-display-string global-mode-string)))
     (setq enwc-display-mode-line new)))
 
+(defun enwc-toggle-auto-scan ()
+  "Toggles automatic scanning.
+This will use the current value of `enwc-auto-scan-interval'."
+  (interactive)
+  (let ((new (not enwc-auto-scan)))
+    (if new
+        (setq enwc-scan-timer
+              (run-at-time t enwc-auto-scan-interval 'enwc-scan t))
+      (cancel-timer enwc-scan-timer))
+    (setq enwc-auto-scan new)))
+
 ;;;;;;;;;;;;;;;;;;
 ;; Scan internal
 ;;;;;;;;;;;;;;;;;;
@@ -456,7 +485,8 @@ This is initiated during setup, and runs once every second."
   "The initial scan routine.
 This initiates a scan using D-Bus, then exits,
 waiting for the callback."
-  (message "Scanning...")
+  (if enwc-scan-interactive
+      (message "Scanning..."))
   (setq enwc-scan-requested t)
   (setq enwc-scan-done nil)
   (enwc-do-scan))
@@ -470,7 +500,8 @@ the scan results."
     (setq enwc-scan-requested nil)
     (let ((cur-id 0)
          (nw-prop-list nil))
-      (message "Scanning... Done")
+      (if enwc-scan-interactive
+          (message "Scanning... Done"))
       (setq enwc-access-points (enwc-get-nw)
            enwc-essid-width 5)
       (setq nw-prop-list



reply via email to

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