-;;; lirc.el --- Lambdalabs irc client -*- lexical-binding:t -*-
+;;; lirc.el --- Lightweight irc client -*- lexical-binding:t -*-
;; Copyright (C) 2021 Tim Vaughan
"Default full name.")
(defcustom lirc-user-name "plugd"
"Default user name.")
-(defcustom lirc-host "localhost"
+(defcustom lirc-host "irc.libera.chat"
"Default server.")
(defcustom lirc-port 6667
"Default port.")
-(defcustom lirc-prompt-string "prompt> "
+(defcustom lirc-prompt-string "> "
"Prompt.")
;;; Faces
;;
(defface lirc-prompt
- '((t :inherit font-lock-string-face))
+ '((t :inherit org-level-2))
"Face used for the prompt.")
+(defface lirc-channel
+ '((t :inherit org-list-dt))
+ "Face used for the channel name in the prompt.")
+
;;; Global variables
;;
(save-excursion
(goto-char lirc-prompt-marker)
(let ((inhibit-read-only t))
- (insert (propertize lirc-prompt-string
- 'face 'lirc-prompt
- 'read-only t
- 'rear-nonsticky t))))))
+ (insert
+ (propertize (if lirc-current-channel
+ lirc-current-channel
+ "[no channel]")
+ 'face 'lirc-channel
+ 'read-only t)
+ (propertize lirc-prompt-string
+ 'face 'lirc-prompt
+ 'read-only t
+ 'rear-nonsticky t))))
+ (set-marker-insertion-type lirc-input-marker nil)))
(defvar lirc-prompt-marker nil
"Marker for prompt position in LIRC buffer.")
(lirc-display-string (lirc-msg->string msg))))))
+;;; Command entering
+;;
+
+(defun lirc-enter-string (string)
+ (cond ((string-prefix-p "/" string)
+ (let ((cmd-str (substring string 1)))
+ (lirc-send-msg (lirc-msg nil nil cmd-str))))
+ (t
+ (error "Unknown command" string))))
+
+(defun lirc-enter ()
+ "Enter current contents of line after prompt."
+ (interactive)
+ (with-current-buffer "*lirc*"
+ (lirc-enter-string
+ (buffer-substring lirc-input-marker (point-max)))
+ (let ((inhibit-read-only t))
+ (delete-region lirc-input-marker (point-max)))))
+
+
+
;;; Mode
;;
(defvar lirc-mode-map
(let ((map (make-sparse-keymap)))
+ (define-key map (kbd "RET") 'lirc-enter)
map))
(define-derived-mode lirc-mode text-mode "lirc"