branch: externals/xelb commit 2edbaa0ab4057ff8bdf24c4b1c7077f47d5f013d Author: Chris Feng <chris.w.f...@gmail.com> Commit: Chris Feng <chris.w.f...@gmail.com>
Code cleanups * xcb-keysyms.el (xcb:keysyms:-function-keys): change from list to vector * xcb-keysyms.el (xcb:keysyms:event->keysym), xcb-types.el (cl--slot-descriptor-name, cl--slot-descriptor-initform) (cl--slot-descriptor-type, xcb:-unpack-u1, xcb:-unpack-u2) (xcb:-unpack-u2-lsb, xcb:-unpack-u4, xcb:-unpack-u4-lsb) (xcb:-unmarshal-field), xcb.el (xcb:-connection-filter): use `aref` instead of `elt` to index vectors * xelb.el, xcb.el: fix first line * .elpaignore: ignore Makefile and README.md --- .elpaignore | 2 ++ xcb-keysyms.el | 6 +++--- xcb-types.el | 44 ++++++++++++++++++++++---------------------- xcb.el | 14 +++++++------- xelb.el | 2 +- 5 files changed, 35 insertions(+), 33 deletions(-) diff --git a/.elpaignore b/.elpaignore index 8f36919..24d4051 100644 --- a/.elpaignore +++ b/.elpaignore @@ -1 +1,3 @@ +Makefile +README.md el_client.el diff --git a/xcb-keysyms.el b/xcb-keysyms.el index 01bb96c..8ca7e1f 100644 --- a/xcb-keysyms.el +++ b/xcb-keysyms.el @@ -197,7 +197,7 @@ SHIFT LOCK is ignored." ;; keysyms, which seems not very useful here. ;; FIXME: shall we also include 'iso_lispy_function_keys' there? (defconst xcb:keysyms:-function-keys - `( ;#xff00 - #xff0f + `[ ;#xff00 - #xff0f ,@(make-list 8 nil) backspace tab linefeed clear nil return nil nil ;#xff10 - #xff1f nil nil nil pause nil nil nil nil nil nil nil escape nil nil nil nil @@ -237,7 +237,7 @@ SHIFT LOCK is ignored." f35 lshift* rshift* lcontrol* rcontrol* caps-lock* shift-lock* lmeta* rmeta* lalt* ralt* lsuper* rsuper* lhyper* rhyper* ;#xff00 - #xffff - ,@(make-list 15 nil) delete) + ,@(make-list 15 nil) delete] "Emacs event representations of X function keys (keysym #xff00 to #xffff).") (defun xcb:keysyms:event->keysym (event) @@ -288,7 +288,7 @@ this function will also return symbols for pure modifiers keys." (let ((event (cond ((and (<= #x20 keysym) (>= #xff keysym)) keysym) ((and (<= #xff00 keysym) (>= #xffff keysym)) - (elt xcb:keysyms:-function-keys (logand keysym #xff))) + (aref xcb:keysyms:-function-keys (logand keysym #xff))) ((and (<= #x1000100 keysym) (>= #x110ffff keysym)) (- keysym #x1000000)) ((and (<= 1 keysym) (>= 5 keysym)) ;ButtonPress assuemd diff --git a/xcb-types.el b/xcb-types.el index 0d16a08..e093e7a 100644 --- a/xcb-types.el +++ b/xcb-types.el @@ -74,9 +74,9 @@ (elt initforms i) (elt types i)))))) result)) - (defsubst cl--slot-descriptor-name (slot) (elt slot 0)) - (defsubst cl--slot-descriptor-initform (slot) (elt slot 1)) - (defsubst cl--slot-descriptor-type (slot) (elt slot 2))) + (defsubst cl--slot-descriptor-name (slot) (aref slot 0)) + (defsubst cl--slot-descriptor-initform (slot) (aref slot 1)) + (defsubst cl--slot-descriptor-type (slot) (aref slot 2))) ;;;; Utility functions @@ -155,7 +155,7 @@ (defsubst xcb:-unpack-u1 (data offset) "Byte array => 1 byte unsigned integer." - (elt data offset)) + (aref data offset)) (defsubst xcb:-unpack-i1 (data offset) "Byte array => 1 byte signed integer." @@ -166,11 +166,11 @@ (defsubst xcb:-unpack-u2 (data offset) "Byte array => 2 bytes unsigned integer (MSB first)." - (logior (lsh (elt data offset) 8) (elt data (1+ offset)))) + (logior (lsh (aref data offset) 8) (aref data (1+ offset)))) (defsubst xcb:-unpack-u2-lsb (data offset) "Byte array => 2 bytes unsigned integer (LSB first)." - (logior (elt data offset) (lsh (elt data (1+ offset)) 8))) + (logior (aref data offset) (lsh (aref data (1+ offset)) 8))) (defsubst xcb:-unpack-i2 (data offset) "Byte array => 2 bytes signed integer (MSB first)." @@ -192,28 +192,28 @@ (progn (defsubst xcb:-unpack-u4 (data offset) "Byte array => 4 bytes unsigned integer (MSB first, 64-bit)." - (logior (lsh (elt data offset) 24) (lsh (elt data (1+ offset)) 16) - (lsh (elt data (+ offset 2)) 8) (elt data (+ offset 3)))) + (logior (lsh (aref data offset) 24) (lsh (aref data (1+ offset)) 16) + (lsh (aref data (+ offset 2)) 8) (aref data (+ offset 3)))) (defsubst xcb:-unpack-u4-lsb (data offset) "Byte array => 4 bytes unsigned integer (LSB first, 64-bit)." - (logior (elt data offset) (lsh (elt data (1+ offset)) 8) - (lsh (elt data (+ offset 2)) 16) - (lsh (elt data (+ offset 3)) 24)))) + (logior (aref data offset) (lsh (aref data (1+ offset)) 8) + (lsh (aref data (+ offset 2)) 16) + (lsh (aref data (+ offset 3)) 24)))) ;; 32-bit (30-bit actually; large numbers are represented as float type) (defsubst xcb:-unpack-u4 (data offset) "Byte array => 4 bytes unsigned integer (MSB first, 32-bit)." - (let ((msb (elt data offset))) + (let ((msb (aref data offset))) (+ (if (> msb 31) (* msb 16777216.0) (lsh msb 24)) - (logior (lsh (elt data (1+ offset)) 16) - (lsh (elt data (+ offset 2)) 8) - (elt data (+ offset 3)))))) + (logior (lsh (aref data (1+ offset)) 16) + (lsh (aref data (+ offset 2)) 8) + (aref data (+ offset 3)))))) (defsubst xcb:-unpack-u4-lsb (data offset) "Byte array => 4 bytes unsigned integer (LSB first, 32-bit)." - (let ((msb (elt data (+ offset 3)))) + (let ((msb (aref data (+ offset 3)))) (+ (if (> msb 31) (* msb 16777216.0) (lsh msb 24)) - (logior (elt data offset) - (lsh (elt data (1+ offset)) 8) - (lsh (elt data (+ offset 2)) 16))))))) + (logior (aref data offset) + (lsh (aref data (1+ offset)) 8) + (lsh (aref data (+ offset 2)) 16))))))) (defsubst xcb:-unpack-i4 (data offset) "Byte array => 4 bytes signed integer (MSB first)." @@ -423,8 +423,8 @@ The optional argument CTX is for <paramref>. This method returns a list of two components, with the first being the result and the second the consumed length." (pcase (indirect-variable type) - (`xcb:-u1 (list (elt data offset) 1)) - (`xcb:-i1 (let ((result (elt data offset))) + (`xcb:-u1 (list (aref data offset) 1)) + (`xcb:-i1 (let ((result (aref data offset))) (list (if (< result 128) result (- result 255)) 1))) (`xcb:-u2 (list (if (slot-value obj '~lsb) (xcb:-unpack-u2-lsb data offset) @@ -442,7 +442,7 @@ and the second the consumed length." (xcb:-unpack-i4-lsb data offset) (xcb:-unpack-i4 data offset)) 4)) - (`xcb:void (list (elt data offset) 1)) + (`xcb:void (list (aref data offset) 1)) (`xcb:-pad (unless (integerp initform) (when (eq 'quote (car initform)) diff --git a/xcb.el b/xcb.el index 029b2cf..eaa1c76 100644 --- a/xcb.el +++ b/xcb.el @@ -1,4 +1,4 @@ -;;; xcb.el --- X Protocol Emacs Lisp Binding (XELB) -*- lexical-binding: t -*- +;;; xcb.el --- X protocol Emacs Lisp Binding (XELB) -*- lexical-binding: t -*- ;; Copyright (C) 2015 Free Software Foundation, Inc. @@ -214,7 +214,7 @@ Concurrency is disabled as it breaks the orders of errors, replies and events." obj) (when (>= (length cache) data-len) (xcb:-log "Setup response: %s" cache) - (pcase (elt cache 0) + (pcase (aref cache 0) (0 ;failed (setq obj (make-instance 'xcb:SetupFailed)) (xcb:unmarshal obj cache) @@ -239,7 +239,7 @@ Concurrency is disabled as it breaks the orders of errors, replies and events." ;; Process error/reply/event (catch 'break (while (<= 32 (length cache)) - (pcase (elt cache 0) + (pcase (aref cache 0) (0 ;error (xcb:-log "Error received: %s" (substring cache 0 32)) (let ((sequence (funcall (if xcb:lsb #'xcb:-unpack-u2-lsb @@ -251,7 +251,7 @@ Concurrency is disabled as it breaks the orders of errors, replies and events." (setq struct (plist-get plist sequence)) (setf (slot-value connection 'error-plist) (plist-put plist sequence - (push `(,(elt cache 1) . + (push `(,(aref cache 1) . ,(substring cache 0 32)) struct)))) (setq cache (substring cache 32)) @@ -311,9 +311,9 @@ Concurrency is disabled as it breaks the orders of errors, replies and events." (cl-incf event-lock) (let (event data synthetic) (while (setq event (pop event-queue)) - (setq data (elt event 1) - synthetic (elt event 2)) - (dolist (listener (elt event 0)) + (setq data (aref event 1) + synthetic (aref event 2)) + (dolist (listener (aref event 0)) (funcall listener data synthetic)))) (cl-decf event-lock)))))) diff --git a/xelb.el b/xelb.el index 3b5057e..81dc82d 100644 --- a/xelb.el +++ b/xelb.el @@ -1,4 +1,4 @@ -;;; xelb.el --- X Protocol Emacs Lisp Binding -*- lexical-binding: t -*- +;;; xelb.el --- X protocol Emacs Lisp Binding -*- lexical-binding: t -*- ;; Copyright (C) 2015 Free Software Foundation, Inc.