Can now send no-argument server commands.
authorTim Vaughan <plugd@thelambdalab.xyz>
Tue, 15 Jun 2021 21:26:16 +0000 (23:26 +0200)
committerTim Vaughan <plugd@thelambdalab.xyz>
Tue, 15 Jun 2021 21:26:40 +0000 (23:26 +0200)
lirc.el

diff --git a/lirc.el b/lirc.el
index ee6bdd4..cd746b5 100644 (file)
--- a/lirc.el
+++ b/lirc.el
         (insert (propertize lirc-prompt-string
                             'face 'lirc-prompt
                             'read-only t
-                            'rear-nonsticky 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)))))
+
+
 ;;; 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"