Browse Source

Add the Poc for Rigel support

ep6
Sameer Rahmani 3 months ago
parent
commit
699bc88830
  1. 71
      core/cubes/rigel.el

71
core/cubes/rigel.el

@ -0,0 +1,71 @@ @@ -0,0 +1,71 @@
;;; RigelCube --- Rigel client for FG42 -*- lexical-binding: t; -*-
;;
;; Copyright (c) 2010-2021 Sameer Rahmani & Contributors
;;
;; Author: Sameer Rahmani <lxsameer@gnu.org>
;; 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 <http://www.gnu.org/licenses/>.
;;
;;; 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
Loading…
Cancel
Save