summaryrefslogtreecommitdiff
path: root/wifi-bluetooth-conf.el
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2021-05-25 16:00:02 +0800
committerJSDurand <mmemmew@gmail.com>2021-05-25 16:00:02 +0800
commit853c5214e4863330016cc983b6c5f30a5bcd3750 (patch)
tree40b8635e2677b7097479e0f4619843039141adbf /wifi-bluetooth-conf.el
parenta018531108b1b51eaadb576750dec9c40b84c1f8 (diff)
Refine the mechanism of joining WIFI ports.
* wifi-bluetooth-conf.el (durand-wifi-ssid-machine-alist): The port EX has the same password as that of 4F. (durand-wifi-scanned-ssids): (durand-wifi-list-sentinel): Record the scanned ports in a variable for the purpose of completion. (durand-wifi-join-history): Record the history (durand-wifi-join-port): Use `completing-read' to read the port.
Diffstat (limited to 'wifi-bluetooth-conf.el')
-rw-r--r--wifi-bluetooth-conf.el25
1 files changed, 19 insertions, 6 deletions
diff --git a/wifi-bluetooth-conf.el b/wifi-bluetooth-conf.el
index 52bff4d..588024d 100644
--- a/wifi-bluetooth-conf.el
+++ b/wifi-bluetooth-conf.el
@@ -151,16 +151,28 @@ If ARG is non-nil, then list the currently connected port."
(defvar durand-wifi-ssid-machine-alist
(list
(cons "20-1" "wifi-2")
- (cons "1-20-4F" "wifi-4"))
+ (cons "1-20-4F" "wifi-4")
+ (cons "1-20-4F_2EX" "wifi-4"))
"A list of associations between the SSID of WIFI and the
machine name that we can use to search for the password in my
secret file.")
;;;###autoload
+(defvar durand-wifi-scanned-ssids nil
+ "The variable that holds the list of SSIDs of WIFI ports found
+ during the scan.")
+
+;;;###autoload
+(defvar durand-wifi-join-history nil
+ "The variable that holds the history of WIFI ports joined.")
+
+;;;###autoload
(defun durand-wifi-join-port (port &optional pwd)
"Join PORT.
If PWD is non-nil, use that as the password."
- (interactive (let ((po (read-string "Port to join: "))
+ (interactive (let ((po (completing-read
+ "Port to join: " durand-wifi-scanned-ssids
+ nil nil nil 'durand-wifi-join-history))
(pwd (read-string "Password: ")))
(cond ((and pwd (not (string= pwd "")))
(list po pwd))
@@ -200,6 +212,7 @@ This only does something when STATUS is the string \"finished\\n\"."
process)))
(let (first-var)
(cond ((string-equal status "finished\n")
+ (setq durand-wifi-scanned-ssids nil)
(with-current-buffer durand-wifi-bluetooth-buffer
(goto-char (point-min))
(cond ((re-search-forward "AirPort: Off" nil t)
@@ -207,20 +220,20 @@ This only does something when STATUS is the string \"finished\\n\"."
((re-search-forward "\\s-+SSID" (line-end-position) t)
(setq first-var t)
(forward-line 1)
- (let ((start 0) list-of-ssids)
+ (let ((start 0))
(while (re-search-forward "\\S-" (line-end-position) t)
(forward-char -1)
(setq start (point))
(re-search-forward "\\s-" (line-end-position) t)
(forward-char -1)
- (setq list-of-ssids
+ (setq durand-wifi-scanned-ssids
(cons (buffer-substring-no-properties
start (point))
- list-of-ssids))
+ durand-wifi-scanned-ssids))
(forward-line 1))
(erase-buffer)
(goto-char (point-min))
- (insert (string-join list-of-ssids (string 10)))
+ (insert (string-join durand-wifi-scanned-ssids (string 10)))
(goto-char (point-min))))
((re-search-forward "\\s-+SSID: " nil t)
(message (buffer-substring-no-properties