From 70e749f0f18254271106da7f60b7ecba9fee84f8 Mon Sep 17 00:00:00 2001 From: rasensuihei Date: Fri, 2 Aug 2019 18:32:40 +0900 Subject: [PATCH] * A network process never querying before exit Emacs. * Highlights valid scoreboard name. * Display command execution result. * Added reload command. --- README.md | 8 ++++++-- mcf-mode.el | 23 ++++++++++++++++------- mcf-rcon.el | 1 + 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index c9dc136..5ef59db 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ ## Default key bindings * `C-c C-c mcf-execute` * `C-c C-e mcf-execute-at-point` +* `C-c C-r mcf-reload` --- @@ -68,9 +69,12 @@ rcon.password=PASSWORD `mcf-eval` does not block processing, and BODY is evaluated when the server responds. -`mcf-eval` must be nested. If you call consecutively in a loop, the Minecraft RCON server will disconnect the client. - ## Changelog +### 0.2.4 +* A network process never querying before exit Emacs. +* Highlights valid scoreboard name. +* Display command execution result. +* Added reload command. ### 0.2.3 * Auto connect/Reconnect to RCON server when executes command. * RCON Command queue feature. diff --git a/mcf-mode.el b/mcf-mode.el index d6a20c5..681f8fc 100644 --- a/mcf-mode.el +++ b/mcf-mode.el @@ -75,7 +75,7 @@ (1 font-lock-variable-name-face t) (2 font-lock-constant-face t)) ;; Selector arguments - '("\\([a-zA-Z0-9_]+\\)\s*=" + '("\\([a-zA-Z0-9_.+-]+\\)\s*=" (1 font-lock-builtin-face t)) '("\\([,=:]\\)" (1 font-lock-builtin-face t)) @@ -95,6 +95,7 @@ (let ((map (make-sparse-keymap))) (define-key map "\C-c" 'mcf-execute) (define-key map "\C-e" 'mcf-execute-at-point) + (define-key map "\C-r" 'mcf-reload) map)) (defvar mcf-mode-map @@ -124,11 +125,14 @@ (setq-local comment-start "#") (setq-local comment-end "")) -(defun mcf-execute (str &optional handler) - "Execute Minecraft command STR. HANDLER is a function for server response handle." +(defun mcf-execute (str) + "Execute Minecraft command STR and display the result in the minibuffer." (interactive "MCommand: ") - (mcf-rcon-execute-command str handler) - t) + ;; (mcf-rcon-execute str handler) + (mcf-rcon-execute str (lambda (payload) + (if (eq payload "") + (message "Minecraft: ") + (message "Minecraft: %s" payload))))) (defun mcf-execute-at-point () "Execute a command at point." @@ -137,14 +141,19 @@ (when (string-match "^[# ]*\\(.+\\)$" line) (mcf-execute (match-string 1 line))))) +(defun mcf-reload () + "Execute a reload command." + (interactive) + (mcf-execute "reload")) + (defmacro mcf-eval (command &rest args) "(mcf-eval COMMAND ARGS...) Evaluate minecraft command with RCON server. A First argument must be payload variable name. (mcf-eval \"COMMAND\" (PAYLOAD) BODY...)" (declare (indent defun) (debug args)) (if args - `(mcf-rcon-execute-command ,command (lambda (x) (let ((,(caar args) x)) ,@(cdr args)))) - `(mcf-rcon-execute-command ,command))) + `(mcf-rcon-execute ,command (lambda (x) (let ((,(caar args) x)) ,@(cdr args)))) + `(mcf-rcon-execute ,command))) (provide 'mcf-mode) ;;; mcf-mode.el ends here diff --git a/mcf-rcon.el b/mcf-rcon.el index 5485a80..ab14bc9 100644 --- a/mcf-rcon.el +++ b/mcf-rcon.el @@ -146,6 +146,7 @@ :buffer mcf-rcon--buffer-name :address mcf-rcon-address :service mcf-rcon-port + :noquery t :nowait t :filter 'mcf-rcon--filter :sentinel 'mcf-rcon--sentinel))))