~technomancy/fennel-mode

f4bd34e1c3b14313c20af94dd34430b40c0ef35f — Andrey Listopadov a month ago a4ddd17 main
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
2 files changed, 18 insertions(+), 11 deletions(-)

M fennel-proto-repl.el
M test/fennel-proto-repl-test.el
M fennel-proto-repl.el => fennel-proto-repl.el +10 -10
@@ 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.

M test/fennel-proto-repl-test.el => test/fennel-proto-repl-test.el +8 -1
@@ 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