From: Tim Vaughan Date: Tue, 15 Jun 2021 21:26:16 +0000 (+0200) Subject: Can now send no-argument server commands. X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=commitdiff_plain;h=6d15ff371e4f3e62fbc46febd0cec79a3f594ce8;p=lurk.git Can now send no-argument server commands. --- diff --git a/lirc.el b/lirc.el index ee6bdd4..cd746b5 100644 --- a/lirc.el +++ b/lirc.el @@ -189,7 +189,8 @@ (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.") @@ -224,11 +225,30 @@ (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"