branch: externals/firefox-javascript-repl
commit b4186a576257c75ca73e440ff24532df3a5700c1
Author: Thomas Fitzsimmons <[email protected]>
Commit: Thomas Fitzsimmons <[email protected]>
Backport to Emacs 26.1
* firefox-javascript-repl.el: Fill out and format testing table in
commentary. Require json. Reorder require lines.
(messages-buffer-name): Declare variable.
(firefox-javascript-repl-mode): Fix Emacs 26.1 compatibility
issues.
(fjrepl--parse-prior-message): Replace json-parse-string with
json-read-from-string for Emacs 26.1 compatiblity.
(firefox-javascript-repl): Replace string-trim with
string-trim-left and string-trim-right for Emacs 26.1
compatibility.
---
firefox-javascript-repl.el | 30 +++++++++++++++++++++++-------
1 file changed, 23 insertions(+), 7 deletions(-)
diff --git a/firefox-javascript-repl.el b/firefox-javascript-repl.el
index 164652e3cc..b4ee0fd85c 100644
--- a/firefox-javascript-repl.el
+++ b/firefox-javascript-repl.el
@@ -62,12 +62,19 @@
;; Compatibility:
-;; Tested 2023-05-19 on ppc64le Debian Firefox 102.11.0esr (64-bit).
+;; ╔════════════╦══════════════╦══════════╦══════════════════════╗
+;; ║ Test Date ║ Architecture ║ Browser ║ Version ║
+;; ╠════════════╬══════════════╬══════════╬══════════════════════╣
+;; ║ 2023-05-26 ║ ppc64le ║ Firefox ║ 102.11.0esr (64-bit) ║
+;; ║ 2023-05-26 ║ x86-64 ║ Firefox ║ 113.0.2 (64-bit) ║
+;; ║ 2023-05-26 ║ x86-64 ║ Abrowser ║ 111.0.1 (64-bit) ║
+;; ╙────────────╨──────────────╨──────────╨──────────────────────╜
;;; Code:
(require 'cc-langs)
-(require 'js)
(require 'comint)
+(require 'js)
+(require 'json)
(defvar fjrepl--debug nil
"Non-nil to print debug messages to buffer *fjrepl-debug*.")
@@ -75,6 +82,8 @@
(defvar fjrepl--console-actor nil
"The console actor used to evaluate JavaScript in Firefox.")
+(defvar messages-buffer-name) ; Emacs 26.1 byte-compiler.
+
(defun fjrepl--debug (message)
"Print MESSAGE, a string, to *fjrep-debug*."
(when fjrepl--debug
@@ -164,9 +173,12 @@ ARGUMENTS will be used for FORMAT, like `messages'."
(set-marker (process-mark (get-buffer-process (current-buffer)))
(point))
(set-marker (cdr comint-last-prompt) (point-max))
- (setq-local comint-indirect-setup-function 'js-mode)
- (comint-indirect-buffer)
- (comint-fontify-input-mode)
+ (when (boundp 'comint-indirect-setup-function)
+ (setq-local comint-indirect-setup-function 'js-mode))
+ (when (fboundp 'comint-indirect-buffer)
+ (comint-indirect-buffer))
+ (when (fboundp 'comint-fontify-input-mode)
+ (comint-fontify-input-mode))
(make-local-variable 'kill-buffer-hook)
(add-hook 'kill-buffer-hook 'comint--indirect-cleanup)
(add-hook 'kill-buffer-hook
@@ -204,7 +216,9 @@ ARGUMENTS will be used for FORMAT, like `messages'."
(let ((start (point)))
(forward-sexp)
(prog1
- (json-parse-string (buffer-substring start (point)))
+ (let ((json-object-type 'hash-table))
+ (json-read-from-string
+ (buffer-substring start (point))))
(backward-sexp))))) )
(defun fjrepl--get-result (buffer descend &rest arguments)
@@ -438,7 +452,9 @@ localhost (127.0.0.1) TCP port 6000."
"finished\n"))
(fjrepl--message
"%s %s; deleting %s"
- process (string-trim event) profile-directory)
+ process
+ (string-trim-left (string-trim-right event))
+ profile-directory)
(setq fjrepl--console-actor nil)
(kill-buffer
firefox-standard-output-buffer-name)