Skip to content

Commit c3be413

Browse files
authored
lsp-inline-completion: cleanup autoload to make it loads correctly (#4633)
1 parent 57ea512 commit c3be413

File tree

3 files changed

+31
-41
lines changed

3 files changed

+31
-41
lines changed

lsp-completion.el

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
(define-obsolete-variable-alias 'lsp-enable-completion-at-point
4646
'lsp-completion-enable "lsp-mode 7.0.1")
4747

48+
;;;###autoload
4849
(defcustom lsp-completion-enable t
4950
"Enable `completion-at-point' integration."
5051
:type 'boolean

lsp-inline-completion.el

+3-33
Original file line numberDiff line numberDiff line change
@@ -28,36 +28,7 @@
2828

2929
;;; Code:
3030

31-
(require 'lsp-protocol)
32-
(require 'dash)
33-
(require 'cl-lib)
34-
(require 'fringe)
35-
36-
(if (version< emacs-version "29.1")
37-
;; Undo macro probably introduced in 29.1
38-
(defmacro lsp-inline-completion--with-undo-amalgamate (&rest body)
39-
"Like `progn' but perform BODY with amalgamated undo barriers.
40-
41-
This allows multiple operations to be undone in a single step.
42-
When undo is disabled this behaves like `progn'."
43-
(declare (indent 0) (debug t))
44-
(let ((handle (make-symbol "--change-group-handle--")))
45-
`(let ((,handle (prepare-change-group))
46-
;; Don't truncate any undo data in the middle of this,
47-
;; otherwise Emacs might truncate part of the resulting
48-
;; undo step: we want to mimic the behavior we'd get if the
49-
;; undo-boundaries were never added in the first place.
50-
(undo-outer-limit nil)
51-
(undo-limit most-positive-fixnum)
52-
(undo-strong-limit most-positive-fixnum))
53-
(unwind-protect
54-
(progn
55-
(activate-change-group ,handle)
56-
,@body)
57-
(progn
58-
(accept-change-group ,handle)
59-
(undo-amalgamate-change-group ,handle))))))
60-
(defalias 'lsp-inline-completion--with-undo-amalgamate 'with-undo-amalgamate))
31+
(require 'lsp-mode)
6132

6233
(defun lsp-inline-completion--params (implicit &optional identifier position)
6334
"Returns a InlineCompletionParams instance"
@@ -91,7 +62,6 @@ InlineCompletionItem objects"
9162

9263
;;;;;; Default UI -- overlay
9364

94-
;;;###autoload
9565
(defvar lsp-inline-completion-active-map
9666
(let ((map (make-sparse-keymap)))
9767
;; accept
@@ -115,7 +85,6 @@ InlineCompletionItem objects"
11585
map)
11686
"Keymap active when showing inline code suggestions")
11787

118-
;;;###autoload
11988
(defface lsp-inline-completion-overlay-face
12089
'((t :inherit shadow))
12190
"Face for the inline code suggestions overlay."
@@ -334,7 +303,7 @@ text range that was updated by the completion"
334303

335304
(with-no-warnings
336305
;; Compiler does not believes this macro is defined
337-
(lsp-inline-completion--with-undo-amalgamate
306+
(lsp-with-undo-amalgamate
338307
(lsp-inline-completion--insert-sugestion text kind start end command?)))))
339308

340309
(defun lsp-inline-completion-accept-on-click (event)
@@ -422,6 +391,7 @@ text range that was updated by the completion"
422391

423392

424393
;; Inline Completion Mode
394+
;;;###autoload
425395
(defcustom lsp-inline-completion-enable t
426396
"If non-nil it will enable inline completions on idle."
427397
:type 'boolean

lsp-mode.el

+27-8
Original file line numberDiff line numberDiff line change
@@ -529,14 +529,6 @@ If this is set to nil, `eldoc' will show only the symbol information."
529529
:type 'boolean
530530
:group 'lsp-mode)
531531

532-
(define-obsolete-variable-alias 'lsp-enable-completion-at-point
533-
'lsp-completion-enable "lsp-mode 7.0.1")
534-
535-
(defcustom lsp-completion-enable t
536-
"Enable `completion-at-point' integration."
537-
:type 'boolean
538-
:group 'lsp-completion)
539-
540532
(defcustom lsp-enable-symbol-highlighting t
541533
"Highlight references of the symbol at point."
542534
:type 'boolean
@@ -1408,6 +1400,33 @@ Symlinks are not followed."
14081400
(s-prefix? (concat (lsp-f-canonical path-a) (f-path-separator))
14091401
(lsp-f-canonical path-b))))
14101402

1403+
;; compat
1404+
(if (version< emacs-version "29.1")
1405+
;; Undo macro probably introduced in 29.1
1406+
(defmacro lsp-with-undo-amalgamate (&rest body)
1407+
"Like `progn' but perform BODY with amalgamated undo barriers.
1408+
1409+
This allows multiple operations to be undone in a single step.
1410+
When undo is disabled this behaves like `progn'."
1411+
(declare (indent 0) (debug t))
1412+
(let ((handle (make-symbol "--change-group-handle--")))
1413+
`(let ((,handle (prepare-change-group))
1414+
;; Don't truncate any undo data in the middle of this,
1415+
;; otherwise Emacs might truncate part of the resulting
1416+
;; undo step: we want to mimic the behavior we'd get if the
1417+
;; undo-boundaries were never added in the first place.
1418+
(undo-outer-limit nil)
1419+
(undo-limit most-positive-fixnum)
1420+
(undo-strong-limit most-positive-fixnum))
1421+
(unwind-protect
1422+
(progn
1423+
(activate-change-group ,handle)
1424+
,@body)
1425+
(progn
1426+
(accept-change-group ,handle)
1427+
(undo-amalgamate-change-group ,handle))))))
1428+
(defalias 'lsp-with-undo-amalgamate 'with-undo-amalgamate))
1429+
14111430
(defun lsp--merge-results (results method)
14121431
"Merge RESULTS by filtering the empty hash-tables and merging
14131432
the lists according to METHOD."

0 commit comments

Comments
 (0)