[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/poke 4e7d779635 13/76: poke.el: convert poke-vu to new
From: |
ELPA Syncer |
Subject: |
[elpa] externals/poke 4e7d779635 13/76: poke.el: convert poke-vu to new infrastructure |
Date: |
Tue, 5 Apr 2022 14:59:32 -0400 (EDT) |
branch: externals/poke
commit 4e7d7796356d607fabb9f8ba94718bbde1ad5e68
Author: Jose E. Marchesi <jose.marchesi@oracle.com>
Commit: Jose E. Marchesi <jose.marchesi@oracle.com>
poke.el: convert poke-vu to new infrastructure
---
poke.el | 92 +++++++++++++++++++++++------------------------------------------
1 file changed, 32 insertions(+), 60 deletions(-)
diff --git a/poke.el b/poke.el
index 39e3571a8b..dd8035d14f 100644
--- a/poke.el
+++ b/poke.el
@@ -374,60 +374,35 @@ Commands:
;;;; poke-vu pokelet
(defvar poke-vu-process nil)
-(defvar poke-vu-buf "")
-(defvar poke-vu-length 0)
-(defvar poke-vu-output "")
-
-(defconst poke-vu-state-waiting-for-length 0)
-(defconst poke-vu-state-waiting-for-msg 1)
-(defvar poke-vu-state poke-vu-state-waiting-for-length)
-
-(defun poke-vu-filter (proc string)
- (setq poke-vu-buf (concat poke-vu-buf string))
- (while (or (and (= poke-vu-state poke-vu-state-waiting-for-length)
- (>= (length poke-vu-buf) 2))
- (and (= poke-vu-state poke-vu-state-waiting-for-msg)
- (>= (length poke-vu-buf) poke-vu-length)))
- (if (= poke-vu-state poke-vu-state-waiting-for-length)
- (progn
- (setq poke-vu-length
- (logior (ash (aref poke-vu-buf 1) 8) (aref poke-vu-buf 0)))
- (setq poke-vu-buf (substring poke-vu-buf 2))
- (setq poke-vu-state poke-vu-state-waiting-for-msg))
- ;; state is poke-vu-state-waiting-for-msg.
- (when (>= (length poke-vu-buf) poke-vu-length)
- ;; Action on the message according to the command.
- (pcase (aref poke-vu-buf 0)
- (1 ;; RESET
- (when (buffer-live-p (process-buffer proc))
- (with-current-buffer (process-buffer proc)
- (let ((buffer-read-only nil))
- (delete-region (point-min) (point-max))))))
- (2 ;; APPEND
- (setq poke-vu-output
- (concat poke-vu-output
- (substring poke-vu-buf 1 (- poke-vu-length 1)))))
- (3 ;; HIGHLIGHT
- ;; XXX
- )
- (4 ;; FILTER
- ;; XXX
- )
- (5 ;; FINISH
- (when (buffer-live-p (process-buffer proc))
- (with-current-buffer (process-buffer proc)
- (let ((buffer-read-only nil))
- (delete-region (point-min) (point-max))
- (insert poke-vu-output)
- (goto-char (point-min)))))
- (setq poke-vu-output ""))
- (_ ;; Protocol error
- (setq poke-vu-buf "")
- (setq poke-vu-length 0)
- (error "pokelet protocol error")))
- ;; Discard used portion of poke-vu-buf and reset state.
- (setq poke-vu-buf (substring poke-vu-buf poke-vu-length))
- (setq poke-vu-state poke-vu-state-waiting-for-length)))))
+(defvar poke-vu-output "") ;; XXX
+
+(defun poke-vu-handle-cmd (proc cmd data)
+ (pcase cmd
+ (1 ;; RESET
+ (when (buffer-live-p (process-buffer proc))
+ (with-current-buffer (process-buffer proc)
+ (let ((buffer-read-only nil))
+ (delete-region (point-min) (point-max))))))
+ (2 ;; APPEND
+ (setq poke-vu-output (concat poke-vu-output data)))
+ (3 ;; HIGHLIGHT
+ ;; XXX
+ )
+ (4 ;; FILTER
+ ;; XXX
+ )
+ (5 ;; FINISH
+ (when (buffer-live-p (process-buffer proc))
+ (with-current-buffer (process-buffer proc)
+ (let ((buffer-read-only nil))
+ (delete-region (point-min) (point-max))
+ (insert poke-vu-output)
+ (goto-char (point-min)))))
+ (setq poke-vu-output ""))
+ (_ ;; Protocol error
+ (process-put proc 'pokelet-buf "")
+ (process-put proc 'pokelet-msg-lenght 0)
+ (error "pokelet protocol error"))))
(defvar poke-vu-font-lock
`(("^[0-9a-zA-Z]+:" . 'poke-vu-addr-face)
@@ -504,14 +479,11 @@ Commands:
(defun poke-vu ()
(interactive)
(when (not (process-live-p poke-vu-process))
- (setq poke-vu-state poke-vu-state-waiting-for-length)
- (setq poke-vu-buf "")
+ ;; XXX turn this into a process attribute
(setq poke-vu-output "")
- (setq poke-vu-length 0)
(setq poke-vu-process
- (poke-make-pokelet-process "poke-vu" "\x82"))
- (set-process-query-on-exit-flag poke-vu-process nil)
- (set-process-filter poke-vu-process #'poke-vu-filter)
+ (poke-make-pokelet-process-new "poke-vu" "\x82"
+ #'poke-vu-handle-cmd))
(save-excursion
(set-buffer "*poke-vu*")
(poke-vu-mode)))
- [elpa] externals/poke 23f72d3b9a 41/76: poke.el: many changes, (continued)
- [elpa] externals/poke 23f72d3b9a 41/76: poke.el: many changes, ELPA Syncer, 2022/04/05
- [elpa] externals/poke 53d0275eac 60/76: poke.el: change vu refresh to use poked hooks, ELPA Syncer, 2022/04/05
- [elpa] externals/poke f9f332c37d 70/76: poke.el: new command `w' in poke-maps-mode, ELPA Syncer, 2022/04/05
- [elpa] externals/poke 2f0f847284 72/76: poke.el: keep the current position upon *poke-vu* updates, ELPA Syncer, 2022/04/05
- [elpa] externals/poke 55295aaf7b 74/76: syntax-check fixes, ELPA Syncer, 2022/04/05
- [elpa] externals/poke f7edc87b48 01/76: Initial commit, ELPA Syncer, 2022/04/05
- [elpa] externals/poke 3e5e2cbc4a 07/76: poke.el: improve layout of windows, ELPA Syncer, 2022/04/05
- [elpa] externals/poke 72c5ec9ba3 10/76: poke.el: new function `quit', ELPA Syncer, 2022/04/05
- [elpa] externals/poke d9e55b8d64 03/76: poke.el: several fixes, ELPA Syncer, 2022/04/05
- [elpa] externals/poke e85c5fdcea 08/76: poke.el: accummulate output in poke-vu, ELPA Syncer, 2022/04/05
- [elpa] externals/poke 4e7d779635 13/76: poke.el: convert poke-vu to new infrastructure,
ELPA Syncer <=
- [elpa] externals/poke 157431f80e 15/76: emacs.el: remove global state from poke-out, ELPA Syncer, 2022/04/05
- [elpa] externals/poke 7851b82ef7 19/76: poke.el: require subr-ex, ELPA Syncer, 2022/04/05
- [elpa] externals/poke 7bca885bb1 20/76: poke.el: use hooks ios_open_hook and ios_close_hook, ELPA Syncer, 2022/04/05
- [elpa] externals/poke f457341424 22/76: poke.el: command for setting the current IOS in the poke-ios, ELPA Syncer, 2022/04/05
- [elpa] externals/poke 923ec644ba 24/76: poke.el: add size to poke-ios, ELPA Syncer, 2022/04/05
- [elpa] externals/poke e71f9cea1a 26/76: pkl: immutable declarations in compiler bootstrapping, ELPA Syncer, 2022/04/05
- [elpa] externals/poke 224e283c86 27/76: poke.el: transmit flags in a string to poke-ios-open, ELPA Syncer, 2022/04/05
- [elpa] externals/poke 2e6411d56a 29/76: poke.el: improvs, ELPA Syncer, 2022/04/05
- [elpa] externals/poke 84ae4121b9 30/76: poke.el: get unibyte strings in pokelet processes, ELPA Syncer, 2022/04/05
- [elpa] externals/poke 4743725592 34/76: poke.el: poke-code send command, ELPA Syncer, 2022/04/05