[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 8e44368 68/76: Moved enwc-setup to enwc.el, and added it t
From: |
Ian Dunn |
Subject: |
[elpa] master 8e44368 68/76: Moved enwc-setup to enwc.el, and added it to enwc. |
Date: |
Thu, 23 Feb 2017 19:42:55 -0500 (EST) |
branch: master
commit 8e44368d4e404f2b4a1e80cd4a8995f986c58027
Author: Ian Dunn <address@hidden>
Commit: Ian Dunn <address@hidden>
Moved enwc-setup to enwc.el, and added it to enwc.
* enwc-backend.el (enwc-force-backend-loading): New defcustom to force
loading
of default backend in enwc-setup.
(enwc-load-backend): Load the file that contains the backend.
* enwc.el (enwc-display-mode-line): Fixed default.
(enwc-auto-scan): Changed default to nil.
(enwc--setup-done): New defvar to determine if setup has been run.
(enwc-setup): Added.
(enwc): Call enwc-setup.
---
lisp/enwc-backend.el | 9 ++++++++
lisp/enwc-setup.el | 59 ----------------------------------------------------
lisp/enwc.el | 37 ++++++++++++++++++++++++++------
3 files changed, 40 insertions(+), 65 deletions(-)
diff --git a/lisp/enwc-backend.el b/lisp/enwc-backend.el
index fa4083f..a296477 100644
--- a/lisp/enwc-backend.el
+++ b/lisp/enwc-backend.el
@@ -66,8 +66,14 @@ an enwc-backend struct.")
:type 'symbol
:group 'enwc)
+(defcustom enwc-force-backend-loading nil
+ "Non-nil if backends should be loaded even if they claim they cannot."
+ :type 'boolean
+ :group 'enwc)
+
(defvar enwc--current-backend nil)
+;;;###autoload
(defun enwc-register-backend (definition &optional forcep)
"Register the backend KEY with DEFINITION.
@@ -125,6 +131,9 @@ Signals an error if a backend with KEY already exists and
FORCEP is nil."
(not (eq (enwc-backend-key enwc--current-backend) backend)))
(enwc-unload-current-backend))
+ (unless (require (intern (format "enwc-%s" backend)) nil t)
+ (error "Cannot find enwc feature for backend %s" backend))
+
(let ((new-backend (map-elt enwc-registered-backend-alist backend)))
(unless new-backend
(error "No registered backend %s" backend))
diff --git a/lisp/enwc-setup.el b/lisp/enwc-setup.el
deleted file mode 100644
index 5c463c7..0000000
--- a/lisp/enwc-setup.el
+++ /dev/null
@@ -1,59 +0,0 @@
-;; enwc-setup.el - Setup routines for ENWC
-
-;; Copyright (C) 2012-2014 Free Software Foundation, Inc.
-
-;; Author: Ian Dunn <address@hidden>
-;; Keywords: network, wicd, manager, nm
-;; Version: 2.0
-;; Homepage: https://savannah.nongnu.org/p/enwc
-
-;; This file is part of GNU Emacs.
-
-;; GNU Emacs is free software; you can redistribute it and/or modify it
-;; under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
-
-;; GNU Emacs is distributed in the hope that it will be useful, but WITHOUT
-;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
-;; License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to the Free
-;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-;; 02110-1301, USA.
-
-;;; Commentary:
-
-;;; Code:
-
-(require 'enwc)
-(require 'enwc-backend)
-(require 'enwc-wicd)
-(require 'enwc-nm)
-
-;;;###autoload
-(defun enwc-setup ()
- "Set up ENWC.
-This sets up ENWC and confirms that one of the backends can be found on D-Bus."
- (when enwc-display-mode-line
- (enwc-enable-display-mode-line))
-
- (when (and enwc-auto-scan
- (> enwc-auto-scan-interval 0)
- (not enwc-scan-timer))
- (setq enwc-scan-timer
- (run-at-time t enwc-auto-scan-interval 'enwc-scan t)))
-
- (let ((back-list enwc-backends)
- cur-back pass)
- (while (and back-list (not pass))
- (setq cur-back (pop back-list))
- (setq pass (ignore-errors (enwc-load-backend cur-back))))
- (unless pass
- (error "No usable backend was found."))))
-
-(provide 'enwc-setup)
-
-;;; enwc-setup.el ends here
diff --git a/lisp/enwc.el b/lisp/enwc.el
index 215381a..dfd2511 100644
--- a/lisp/enwc.el
+++ b/lisp/enwc.el
@@ -35,12 +35,11 @@
;;
;; In order to use this package, add
;;
-;; (require 'enwc)
-;; (enwc-load-default-backend)
-;; (enwc-enable-auto-scan)
-;; (enwc-enable-display-mode-line)
+;; (setq enwc-default-backend 'backend-symbol)
;;
;; to your .emacs file (or other init file).
+;;
+;; Then you can just run `enwc' to start everything.
;;; TODO:
;;
@@ -76,13 +75,13 @@
:group 'enwc
:type 'string)
-(defcustom enwc-display-mode-line 't
+(defcustom enwc-display-mode-line t
"Non-nil means display network information in the mode line.
The specific information can be set using `enwc-mode-line-format'."
:group 'enwc
:type 'boolean)
-(defcustom enwc-auto-scan 't
+(defcustom enwc-auto-scan nil
"Whether or not to have ENWC automatically scan.
If non-nil, then ENWC will automatically scan for
networks every `enwc-auto-scan-interval' seconds."
@@ -667,6 +666,31 @@ newly created buffer."
(unless (get-buffer "*ENWC*")
(enwc-setup-buffer t)))
+(defvar enwc--setup-done nil
+ "Non-nil if enwc has already been set up.")
+
+(defun enwc-setup ()
+ "Set up ENWC.
+
+If `enwc-display-mode-line' is non-nil, enable the mode line.
+
+If `enwc-auto-scan' is non-nil, start the auto-scan timer.
+
+Finally, the default backend is loaded."
+ (unless enwc--setup-done
+ (enwc-load-default-backend enwc-force-backend-loading)
+
+ (when enwc-display-mode-line
+ (enwc-enable-display-mode-line))
+
+ (when (and enwc-auto-scan
+ (> enwc-auto-scan-interval 0)
+ (not enwc-scan-timer))
+ (setq enwc-scan-timer
+ (run-at-time t enwc-auto-scan-interval 'enwc-scan t)))
+
+ (setq enwc--setup-done t)))
+
;;;###autoload
(defun enwc ()
"The main front-end to ENWC.
@@ -676,6 +700,7 @@ In order to use this, one must have already run
\\{enwc-mode-map}"
(interactive)
+ (enwc-setup)
(enwc-setup-buffer)
(enwc-scan))
- [elpa] master a46fe3c 64/76: Don't switch to the ENWC buffer when processing a scan., (continued)
- [elpa] master a46fe3c 64/76: Don't switch to the ENWC buffer when processing a scan., Ian Dunn, 2017/02/23
- [elpa] master 33515f8 66/76: Silenced byte-compiler., Ian Dunn, 2017/02/23
- [elpa] master bcb33e6 30/76: (enwc-get-networks): Improved docstring., Ian Dunn, 2017/02/23
- [elpa] master 245a82f 52/76: Moved Wicd and NetworkManager backends to new system., Ian Dunn, 2017/02/23
- [elpa] master 3b1bbc6 69/76: Fixed autoloads target in Makefile, Ian Dunn, 2017/02/23
- [elpa] master 8c17c8c 73/76: Updated hgignore to ignore elc files in top-level directory., Ian Dunn, 2017/02/23
- [elpa] master a3c59cc 74/76: Updated version to 2.0beta1, Ian Dunn, 2017/02/23
- [elpa] master 2e271c6 72/76: Moved lisp files into top-level directory., Ian Dunn, 2017/02/23
- [elpa] master b673e3a 63/76: Added default setup and removed experimental WPA supplicant backend., Ian Dunn, 2017/02/23
- [elpa] master 2c298fc 70/76: Updated copyright and keywords on all files., Ian Dunn, 2017/02/23
- [elpa] master 8e44368 68/76: Moved enwc-setup to enwc.el, and added it to enwc.,
Ian Dunn <=
- [elpa] master 4462fba 56/76: Lots of changes to enwc.el., Ian Dunn, 2017/02/23
- [elpa] master 62fe017 71/76: Removed some files from docs., Ian Dunn, 2017/02/23
- [elpa] master 942d83d 15/76: enwc.el, enwc-setup.el: Consolidated and concretely defined front-end interface., Ian Dunn, 2017/02/23
- [elpa] master 6417d2c 49/76: Correctly merged old branch., Ian Dunn, 2017/02/23
- [elpa] master eb6b085 11/76: Fixed up copyright information., Ian Dunn, 2017/02/23
- [elpa] master 218aa82 25/76: Fixed prefix of customization group., Ian Dunn, 2017/02/23
- [elpa] master c9a94c8 44/76: Added tag 2.0 for changeset 3e2cab525cbc, Ian Dunn, 2017/02/23
- [elpa] master c4ac6fc 60/76: Fixed bug in 'enwc-load-default-backend', Ian Dunn, 2017/02/23
- [elpa] master b8697fd 62/76: Added force parameter to `enwc-load-backend'., Ian Dunn, 2017/02/23
- [elpa] master 2ebc214 01/76: Changed timeout on enwc-wicd-get-wireless-network-property., Ian Dunn, 2017/02/23