emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/forth-mode b8024ac331 088/153: Loading a Forth file provid


From: ELPA Syncer
Subject: [nongnu] elpa/forth-mode b8024ac331 088/153: Loading a Forth file provides some feedback.
Date: Sat, 29 Jan 2022 08:02:21 -0500 (EST)

branch: elpa/forth-mode
commit b8024ac331d926a74ad938c508ed38db8f050da7
Author: Lars Brinkhoff <lars@nocrew.org>
Commit: Lars Brinkhoff <lars@nocrew.org>

    Loading a Forth file provides some feedback.
---
 forth-interaction-mode.el | 29 ++++++++++++++++++++++-------
 1 file changed, 22 insertions(+), 7 deletions(-)

diff --git a/forth-interaction-mode.el b/forth-interaction-mode.el
index 760fc23fbf..c40286d71c 100644
--- a/forth-interaction-mode.el
+++ b/forth-interaction-mode.el
@@ -1,3 +1,5 @@
+(eval-when-compile (byte-compile-disable-warning 'cl-functions))
+
 (require 'comint)
 (require 'forth-mode)
 
@@ -91,18 +93,19 @@
     (run-forth))
   (get-buffer-process forth-interaction-buffer))
 
-(defun forth-scrub (string)
+(defun forth-scrub (string &optional keep-ok)
   "Remove terminal escape sequences from STRING."
   (let ((n 0))
     (while (setq n (string-match "[?[0-9;]*[a-z]" string n))
       (setq string (replace-match "" t t string))))
   (setq string (replace-regexp-in-string "\\`[[:space:]\n]*" "" string))
   (setq string (replace-regexp-in-string "[[:space:]\n]*\\'" "" string))
-  (setq string (replace-regexp-in-string "ok\\'" "" string))
-  (setq string (replace-regexp-in-string "[[:space:]\n]*\\'" "" string)))
+  (if keep-ok
+      string
+    (setq string (replace-regexp-in-string "ok\\'" "" string))
+    (setq string (replace-regexp-in-string "[[:space:]\n]*\\'" "" string))))
 
-;;;###autoload
-(defun forth-interaction-send (&rest strings)
+(defun forth-interaction-send-raw-result (&rest strings)
   (let* ((proc (forth-ensure))
         (forth-result nil)
         (forth-interaction-callback (lambda (x)
@@ -115,7 +118,11 @@
     (while (< (float-time) end-time)
       (accept-process-output proc 0.1))
     (setq forth-words-cache nil)
-    (forth-scrub forth-result)))
+    forth-result))
+
+;;;###autoload
+(defun forth-interaction-send (&rest strings)
+  (forth-scrub (apply #'forth-interaction-send-raw-result strings)))
 
 ;;;###autoload
 (defun forth-words ()
@@ -144,7 +151,15 @@
 ;;;###autoload
 (defun forth-load-file (file)
   (interactive (list (buffer-file-name (current-buffer))))
-  (forth-interaction-send "include " file))
+  (let ((result (forth-interaction-send-raw-result "include " file)))
+    (setq result (forth-scrub result t))
+    (if (< (count ?\n result) 2)
+       (message "%s" result)
+      (let ((buffer (current-buffer)))
+       (pop-to-buffer forth-interaction-buffer)
+       (goto-char (point-max))
+       (insert result "\n")
+       (pop-to-buffer buffer)))))
 
 ;;;###autoload
 (defun forth-see (word)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]