Skip to content

Fix compatibility with Emacs 31+ #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions drepl.el
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ buffers, this is a dREPL buffer or nil.")
(defvar drepl--log-buffer nil
"Name of the event log buffer, or nil to disable logging.")

(defvar drepl--display-buffer-action
(if (boundp 'display-comint-buffer-action) ; Emacs >= 29, <= 30
display-comint-buffer-action
(append display-buffer--same-window-action '((category . comint)))))

;;; Basic definitions

(cl-defstruct (drepl-base
Expand Down Expand Up @@ -122,7 +127,7 @@ addition to those of `drepl-base'."
(format "Start the %s interpreter." display-name))
(interactive)
(pop-to-buffer (drepl--get-buffer-create ',name t)
display-comint-buffer-action))
drepl--display-buffer-action))
(cl-defstruct (,name
(:include drepl-base (history-variable ',hist-var))
(:copier nil)
Expand Down Expand Up @@ -153,15 +158,19 @@ The message is formed by calling `format' with STRING and ARGS."
;;; Communication protocol

(defalias 'drepl--json-decode
(if (json-available-p)
(if (fboundp 'json-parse-string)
(lambda (s)
(json-parse-string s :object-type 'alist :null-object nil))
(error "Not implemented")))
(require 'json)
(declare-function json-read-from-string "json" (string))
#'json-read-from-string))

(defalias 'drepl--json-encode
(if (json-available-p)
(if (fboundp 'json-serialize)
(lambda (s) (json-serialize s :null-object nil))
(error "Not implemented")))
(require 'json)
(declare-function json-encode "json" (object))
#'json-encode))

(cl-defgeneric drepl--send-request (repl data)
"Send request data to REPL.
Expand Down Expand Up @@ -324,7 +333,7 @@ interactively."
(if ask
(drepl--read-buffer "Pop to REPL: ")
(drepl--buffer (drepl--get-repl nil t)))
display-comint-buffer-action))
drepl--display-buffer-action))

;;; Complete operation

Expand Down