Skip to content

Commit 32f93b8

Browse files
committed
fix: make code compatible with emacs-28
1 parent 9e10c1b commit 32f93b8

File tree

2 files changed

+43
-22
lines changed

2 files changed

+43
-22
lines changed

clients/lsp-copilot.el

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ The input are the file name and the major mode of the buffer."
175175
("C-<return>" . lsp-copilot--panel-accept-suggestion-at-point)
176176
("q" . quit-window))))
177177
(dolist (binding key-bindings)
178-
(bind-key (kbd (car binding)) (cdr binding) 'lsp-copilot-panel-buffer-mode-map)))
178+
(define-key lsp-copilot-panel-buffer-mode-map (kbd (car binding)) (cdr binding))))
179179

180180

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

237-
(delete-all-space t)
237+
(lsp-delete-all-space t)
238238
(lsp-copilot-panel-buffer-mode)
239239
(read-only-mode +1)
240240

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

259259
(defun lsp-copilot--panel-completions-progress-handler (_ params)
260260
(-let* (((&ProgressParams :token :value) params)
261-
((action completing-buffer-name panel-completion-token) (string-split token " /// " )))
261+
((action completing-buffer-name panel-completion-token) (s-split " /// " token)))
262262
(pcase action
263263
;; copilot sends results in the report
264264
("PANEL-PARTIAL-RESULT"

lsp-mode.el

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,30 +1429,51 @@ Symlinks are not followed."
14291429

14301430
;; compat
14311431
(if (version< emacs-version "29.1")
1432-
;; Undo macro probably introduced in 29.1
1433-
(defmacro lsp-with-undo-amalgamate (&rest body)
1434-
"Like `progn' but perform BODY with amalgamated undo barriers.
1432+
(progn
1433+
;; Undo macro probably introduced in 29.1
1434+
(defmacro lsp-with-undo-amalgamate (&rest body)
1435+
"Like `progn' but perform BODY with amalgamated undo barriers.
14351436

14361437
This allows multiple operations to be undone in a single step.
14371438
When undo is disabled this behaves like `progn'."
1438-
(declare (indent 0) (debug t))
1439-
(let ((handle (make-symbol "--change-group-handle--")))
1440-
`(let ((,handle (prepare-change-group))
1441-
;; Don't truncate any undo data in the middle of this,
1442-
;; otherwise Emacs might truncate part of the resulting
1443-
;; undo step: we want to mimic the behavior we'd get if the
1444-
;; undo-boundaries were never added in the first place.
1445-
(undo-outer-limit nil)
1446-
(undo-limit most-positive-fixnum)
1447-
(undo-strong-limit most-positive-fixnum))
1448-
(unwind-protect
1439+
(declare (indent 0) (debug t))
1440+
(let ((handle (make-symbol "--change-group-handle--")))
1441+
`(let ((,handle (prepare-change-group))
1442+
;; Don't truncate any undo data in the middle of this,
1443+
;; otherwise Emacs might truncate part of the resulting
1444+
;; undo step: we want to mimic the behavior we'd get if the
1445+
;; undo-boundaries were never added in the first place.
1446+
(undo-outer-limit nil)
1447+
(undo-limit most-positive-fixnum)
1448+
(undo-strong-limit most-positive-fixnum))
1449+
(unwind-protect
1450+
(progn
1451+
(activate-change-group ,handle)
1452+
,@body)
14491453
(progn
1450-
(activate-change-group ,handle)
1451-
,@body)
1454+
(accept-change-group ,handle)
1455+
(undo-amalgamate-change-group ,handle))))))
1456+
1457+
;; delete-all-space function introduced in 29
1458+
(defun lsp-delete-all-space (&optional backward-only)
1459+
"Delete all spaces, tabs, and newlines around point.
1460+
If BACKWARD-ONLY is non-nil, delete them only before point."
1461+
(interactive "*P")
1462+
(let ((chars " \t\r\n")
1463+
(orig-pos (point)))
1464+
(delete-region
1465+
(if backward-only
1466+
orig-pos
14521467
(progn
1453-
(accept-change-group ,handle)
1454-
(undo-amalgamate-change-group ,handle))))))
1455-
(defalias 'lsp-with-undo-amalgamate 'with-undo-amalgamate))
1468+
(skip-chars-forward chars)
1469+
(constrain-to-field nil orig-pos t)))
1470+
(progn
1471+
(skip-chars-backward chars)
1472+
(constrain-to-field nil orig-pos))))))
1473+
;;29.1+
1474+
(defalias 'lsp-with-undo-amalgamate 'with-undo-amalgamate)
1475+
(defalias 'lsp-delete-all-space 'delete-all-space))
1476+
14561477

14571478
(defun lsp--merge-results (results method)
14581479
"Merge RESULTS by filtering the empty hash-tables and merging

0 commit comments

Comments
 (0)