From f4bd34e1c3b14313c20af94dd34430b40c0ef35f Mon Sep 17 00:00:00 2001 From: Andrey Listopadov Date: Sun, 21 Jul 2024 20:32:06 +0300 Subject: [PATCH] Provide a format string for fennel-proto-repl--display-result Previously, fennel-proto-repl--display-result used MESSAGE directly on the result string, which caused problems, if Emacs-recognized format characters appeared in the message. Updated some proto-repl tests, as these been failing for a while --- fennel-proto-repl.el | 20 ++++++++++---------- test/fennel-proto-repl-test.el | 9 ++++++++- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/fennel-proto-repl.el b/fennel-proto-repl.el index 0576a6a..7919f63 100644 --- a/fennel-proto-repl.el +++ b/fennel-proto-repl.el @@ -4,7 +4,7 @@ ;; Author: Andrey Listopadov ;; URL: https://git.sr.ht/~technomancy/fennel-mode -;; Version: 0.5.0 +;; Version: 0.5.1 ;; Created: 2023-04-08 ;; Package-Requires: ((emacs "26.1") (fennel-mode "0.8.1")) ;; @@ -1440,15 +1440,15 @@ start the REPL only check for one." "Display result VALUES in the echo area." (let* ((text (ansi-color-apply (string-trim (string-join values "\t")))) (end (length text))) - (message - ;; `ansi-color-apply' adds `font-lock-face' properties but `message' - ;; expects `face' properties, so copy `font-lock-face' properties as - ;; `face' properties. - (named-let recur ((from 0)) - (let* ((value (get-text-property from 'font-lock-face text)) - (to (text-property-not-all from end 'font-lock-face value text))) - (put-text-property from (or to end) 'face value text) - (if to (recur to) text)))))) + (message "%s" + ;; `ansi-color-apply' adds `font-lock-face' properties but `message' + ;; expects `face' properties, so copy `font-lock-face' properties as + ;; `face' properties. + (named-let recur ((from 0)) + (let* ((value (get-text-property from 'font-lock-face text)) + (to (text-property-not-all from end 'font-lock-face value text))) + (put-text-property from (or to end) 'face value text) + (if to (recur to) text)))))) (defun fennel-proto-repl-eval-print-last-sexp (&optional pretty-print) "Evaluate the expression preceding point. diff --git a/test/fennel-proto-repl-test.el b/test/fennel-proto-repl-test.el index c57413e..4b41663 100644 --- a/test/fennel-proto-repl-test.el +++ b/test/fennel-proto-repl-test.el @@ -284,6 +284,13 @@ (fennel-proto-repl-send-message-sync :eval "(print 789)") (should (equal "123456789\n\n>> " (buffer-substring-no-properties (point-min) (point-max)))))) +(ert-deftest fpr-error-capture-test () + (with-fennel-proto-repl + (fennel-proto-repl-clear-buffer) + (should (equal ">> " (buffer-substring-no-properties (point-min) (point-max)))) + (fennel-proto-repl-send-message-sync :eval "(error \"%s\")") + (should (equal "%s\n>> " (buffer-substring-no-properties (point-min) (point-max)))))) + (ert-deftest fpr-clean-output-test () (with-fennel-proto-repl (fennel-proto-repl-clear-output) @@ -433,7 +440,7 @@ (ert-deftest fpr-comma-commands () (should (equal '("apropos" "apropos-doc" "apropos-show-docs" "compile" - "complete" "doc" "exit" "find" "help" "reload" "reset") + "complete" "doc" "exit" "find" "help" "reload" "reset" "return") (sort (fennel-proto-repl--available-comma-commands) #'string<))) (with-fennel-proto-repl (should-error -- 2.45.2