From 699bc88830bc228bb8512fd15217afabf366d165 Mon Sep 17 00:00:00 2001 From: Sameer Rahmani Date: Fri, 15 Apr 2022 16:45:44 +0100 Subject: [PATCH] Add the Poc for Rigel support --- core/cubes/rigel.el | 71 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 core/cubes/rigel.el diff --git a/core/cubes/rigel.el b/core/cubes/rigel.el new file mode 100644 index 0000000..7357452 --- /dev/null +++ b/core/cubes/rigel.el @@ -0,0 +1,71 @@ +;;; RigelCube --- Rigel client for FG42 -*- lexical-binding: t; -*- +;; +;; Copyright (c) 2010-2021 Sameer Rahmani & Contributors +;; +;; Author: Sameer Rahmani +;; URL: https://ziglab.com/FG42/FG42 +;; Version: 3.0.0 +;; +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . +;; +;;; Commentary: +;;; Code: +(require 'fpkg) +(require 'fg42/cube) + + +(defcube fg42/rigel-cube + "This is a [Rigel](https://devheroes.codes/lxsameer/Orion/src/branch/master/rigel) +for *FG42*. Refer to *Rigel* docs to set it up. + +This cube exposes few functions that interact with regel. Checkout the docstrings of +functions in `fg42/rigel/` namespace. For example `fg42/rigel/read` function." + (:title "rigel Cube" + :flag rigel + :flag-default t) + + (defun fg42/rigel/-sentinel (process event) + (message "[Rigel] %s" event)) + + (defun fg42/rigel/read (txt) + (interactive "sRead: ") + (let ((proc (make-network-process + :name "rigel-client" + :type nil + :server nil + :host (or (plist-get fg42/rigel-cube-params :host) "127.0.0.1") + :service (or (plist-get fg42/rigel-cube-params :port) "6666") + :nowait t + :buffer (get-buffer-create "*rigel*") + :sentinel 'fg42/rigel/-sentinel + ))) + (process-send-string proc txt) + (process-send-eof proc) + (stop-process proc))) + + (defun fg42/rigel/read-region (beg end) + (interactive (if (use-region-p) + (list (region-beginning) (region-end)) + (list nil nil))) + (fg42/rigel/read + (if (and beg end) (buffer-substring-no-properties beg end) ""))) + + (defun fg42/rigel/read-clipboard () + (interactive) + (fg42/rigel/read + (or (current-kill 0) "")))) + + +(provide 'cubes/rigel) +;;; rigel.el ends here