Skip to content

Commit 40da8c7

Browse files
committed
fix: make code compatible with emacs-28
1 parent 90da1c7 commit 40da8c7

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

clients/lsp-copilot.el

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,26 @@ The input are the file name and the major mode of the buffer."
104104
(defvar-local lsp-copilot-panel-completion-items nil
105105
"A list of completion items returned by the Panel Completion call")
106106

107+
(if (version< emacs-version "29.0")
108+
;; Backport from emacs 29
109+
(defun lsp-copilot-panel--delete-all-space (&optional backward-only)
110+
"Delete all spaces, tabs, and newlines around point.
111+
If BACKWARD-ONLY is non-nil, delete them only before point."
112+
(interactive "*P")
113+
(let ((chars " \t\r\n")
114+
(orig-pos (point)))
115+
(delete-region
116+
(if backward-only
117+
orig-pos
118+
(progn
119+
(skip-chars-forward chars)
120+
(constrain-to-field nil orig-pos t)))
121+
(progn
122+
(skip-chars-backward chars)
123+
(constrain-to-field nil orig-pos)))))
124+
(defalias 'lsp-copilot-panel--delete-all-space 'delete-all-space))
125+
126+
107127
(defvar-local lsp-copilot-panel-completion-token nil
108128
"The per-request token")
109129

@@ -175,7 +195,7 @@ The input are the file name and the major mode of the buffer."
175195
("C-<return>" . lsp-copilot--panel-accept-suggestion-at-point)
176196
("q" . quit-window))))
177197
(dolist (binding key-bindings)
178-
(bind-key (kbd (car binding)) (cdr binding) 'lsp-copilot-panel-buffer-mode-map)))
198+
(define-key lsp-copilot-panel-buffer-mode-map (kbd (car binding)) (cdr binding))))
179199

180200

181201
(defcustom lsp-copilot-panel-display-fn #'pop-to-buffer
@@ -234,7 +254,7 @@ The input are the file name and the major mode of the buffer."
234254
(put-text-property start-point (point) 'lsp-panel-item item)
235255
(put-text-property start-point (point) 'lsp-panel-completing-buffer-name completing-buffer-name)))
236256

237-
(delete-all-space t)
257+
(lsp-copilot-panel--delete-all-space t)
238258
(lsp-copilot-panel-buffer-mode)
239259
(read-only-mode +1)
240260

@@ -258,7 +278,7 @@ The input are the file name and the major mode of the buffer."
258278

259279
(defun lsp-copilot--panel-completions-progress-handler (_ params)
260280
(-let* (((&ProgressParams :token :value) params)
261-
((action completing-buffer-name panel-completion-token) (string-split token " /// " )))
281+
((action completing-buffer-name panel-completion-token) (s-split " /// " token)))
262282
(pcase action
263283
;; copilot sends results in the report
264284
("PANEL-PARTIAL-RESULT"

0 commit comments

Comments
 (0)