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

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

[elpa] externals/poke 560a396b6b 21/76: poke.el: poke-ios buffer with a


From: ELPA Syncer
Subject: [elpa] externals/poke 560a396b6b 21/76: poke.el: poke-ios buffer with a list of open IO spaces
Date: Tue, 5 Apr 2022 14:59:34 -0400 (EDT)

branch: externals/poke
commit 560a396b6b738199aff86651cd9d2bb6cf9e9be7
Author: Jose E. Marchesi <jose.marchesi@oracle.com>
Commit: Jose E. Marchesi <jose.marchesi@oracle.com>

    poke.el: poke-ios buffer with a list of open IO spaces
    
    2022-03-14  Jose E. Marchesi  <jemarch@gnu.org>
    
            * emacs/poke.el (tabulated-list): Require tabulated-list.
            (poke-ios-mode): Define.
            (poke-ios-populate): Likewise.
            (poke-ios): Likewise.
---
 poke.el | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 56 insertions(+), 9 deletions(-)

diff --git a/poke.el b/poke.el
index a5281434f3..759c468752 100644
--- a/poke.el
+++ b/poke.el
@@ -47,6 +47,7 @@
 
 (require 'comint)
 (require 'subr-x)
+(require 'tabulated-list)
 
 ;;;; First, some utilities
 
@@ -623,6 +624,61 @@ fun plet_elval = (string s) void:
   (when (called-interactively-p)
     (switch-to-buffer-other-window "*poke-repl*")))
 
+;;;; poke-ios
+
+(defvar poke-ios-alist nil
+  "List of IO spaces currently open.")
+
+(defun poke-ios-open (ios iohandler ioflags)
+  (add-to-list 'poke-ios-alist (list ios iohandler ioflags))
+  (poke-ios-populate))
+
+(defun poke-ios-close (ios)
+  (setq poke-ios-alist (assq-delete-all ios poke-ios-alist))
+  (poke-ios-populate))
+
+(define-derived-mode poke-ios-mode tabulated-list-mode "Poke IOS List"
+  "Major mode for summarizing the open IO spaces in poke.
+\\<poke-ios-mode-map>
+\\{poke-ios-mode-map}"
+  (setq tabulated-list-format nil)
+  (setq tabulated-list-padding 2)
+  (setq tabulated-list-sort-key nil)
+  (tabulated-list-init-header)
+                                        ;  (add-hook 'post-command-hook 
#'poke-set-ios nil t))
+  )
+
+(defun poke-ios-populate ()
+  "Populate a `poke-ios-mode' buffer with the data in `poke-ios-alist."
+  (when (get-buffer "*poke-ios*")
+    (save-excursion
+      (set-buffer "*poke-ios*")
+      (let ((headers [("Id" 5 t) ("Handler" 10 nil) ("Flags" 8 nil)])
+            (entries (mapcar
+                      (lambda (ios)
+                        (let ((ios-id (car ios))
+                              (ios-handler (cadr ios))
+                              (ios-flags (caddr ios)))
+                          ;; XXX interpret flags.
+                          (list ios-id (vector (number-to-string ios-id)
+                                               ios-handler
+                                               (number-to-string ios-flags)))))
+                      poke-ios-alist)))
+        (setq tabulated-list-format headers)
+        (setq tabulated-list-padding 2)
+        (tabulated-list-init-header)
+        (setq tabulated-list-entries entries)
+        (tabulated-list-print nil)))))
+
+(defun poke-ios ()
+  (interactive)
+  (let ((buf (get-buffer-create "*poke-ios*")))
+    (with-current-buffer buf
+      (poke-ios-mode)
+      (poke-ios-populate)))
+  (when (called-interactively-p)
+    (switch-to-buffer-other-window "*poke-ios*")))
+  
 ;;;; Main interface
 
 (defconst poke-pk
@@ -654,15 +710,6 @@ fun quit = void:
   plet_elval (\"(poke-exit)\");
 }")
 
-(defvar poke-ios-alist nil
-  "List of IO spaces currently open.")
-
-(defun poke-ios-open (ios iohandler ioflags)
-  (add-to-list 'poke-ios-alist (list ios iohandler ioflags)))
-
-(defun poke-ios-close (ios)
-  (setq poke-ios-alist (assq-delete-all ios poke-ios-alist)))
-
 (defun poke-open-file (filename)
   (interactive "fFile to open: ")
   ;; XXX: quote filename if needed



reply via email to

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