Files
creature/example/websocket/websocket.el
T
zedhugh b5d9ce18a7 use "creature/pkg-active" manage packages manually
- replace "add-pkg-in-pkg-dir" (recursive load-path scanning) with a
  central "creature/pkgs" registry that handles load path, autoloads,
  info dirs and dependencies
- adapt all init-*.el files to the new activation function
- add a top-level Makefile to byte-compile site-lisp packages
- remove unused "emacs-kv" and "emacs-db" submodules
2026-09-14 15:02:43 +08:00

39 lines
1.4 KiB
EmacsLisp

;; -*- coding: utf-8; lexical-binding: t; -*-
(require 'init-package)
(add-to-list 'load-path (file-name-concat creature/pkg-dir "emacs-websocket"))
(require 'websocket)
(setq-local websocket-eldoc-callback nil)
(defun test-websocket-eldoc (callback)
(setq websocket-eldoc-callback
(if (compiled-function-p callback) callback nil)))
(set (make-local-variable 'eldoc-documentation-strategy)
'eldoc-documentation-compose-eagerly)
(run-with-timer 1 nil
(lambda ()
(funcall websocket-eldoc-callback "hel")))
(test-websocket-eldoc "hel")
(make-local-variable 'eldoc-documentation-functions)
(add-to-list 'eldoc-documentation-functions #'test-websocket-eldoc)
(setq ws-server (websocket-server
4000
:host 'local
:on-message (lambda (ws frame)
(when (and (boundp 'websocket-eldoc-callback) (compiled-function-p websocket-eldoc-callback))
(websocket-send-text ws (format "eldoc showed: %s" (websocket-frame-text frame)))
(funcall websocket-eldoc-callback (websocket-frame-text frame))))))
(funcall (symbol-value (obarray-get obarray "websocket-eldoc-callback")) "hello")
(symbol-value 'websocket-eldoc-callback)
(websocket-server-close ws-server)
(funcall websocket-eldoc-callback "hello")