Skip to content

Commit c1d1efd

Browse files
committed
[#3606] Replace usages of lax-plist-get and lax-plist-put
They were deprecated in Emacs 29, but sadly there's clean way to avoid their usage on Emacs 27 and 28. That's why I'm just adding a couple of trivial wrappers, that will reduce the number of complication warnings.
1 parent c46dc49 commit c1d1efd

7 files changed

+48
-31
lines changed

cider-completion.el

+3-3
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,9 @@ in the buffer."
249249
(defun cider-company-docsig (thing)
250250
"Return signature for THING."
251251
(when-let ((eldoc-info (cider-eldoc-info thing)))
252-
(let* ((ns (lax-plist-get eldoc-info "ns"))
253-
(symbol (lax-plist-get eldoc-info "symbol"))
254-
(arglists (lax-plist-get eldoc-info "arglists")))
252+
(let* ((ns (cider-plist-get eldoc-info "ns"))
253+
(symbol (cider-plist-get eldoc-info "symbol"))
254+
(arglists (cider-plist-get eldoc-info "arglists")))
255255
(format "%s: %s"
256256
(cider-eldoc-format-thing ns symbol thing
257257
(cider-eldoc-thing-type eldoc-info))

cider-docstring.el

+4-4
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,15 @@ Note that `cider-docstring' will trim thing smartly, for Java doc comments:
101101

102102
(defun cider--render-docstring-first-sentence (eldoc-info)
103103
"Render the first sentence of the docstring extracted from ELDOC-INFO."
104-
(when-let ((first-sentence-fragments (lax-plist-get eldoc-info "doc-first-sentence-fragments")))
104+
(when-let ((first-sentence-fragments (cider-plist-get eldoc-info "doc-first-sentence-fragments")))
105105
(cider--fragments-to-s first-sentence-fragments)))
106106

107107
(defun cider--render-docstring (eldoc-info)
108108
"Renders the docstring from ELDOC-INFO based on its length and content.
109109
Prioritize rendering as much as possible while staying within `cider-docstring-max-lines'."
110-
(let* ((first-sentence-fragments (lax-plist-get eldoc-info "doc-first-sentence-fragments"))
111-
(body-fragments (lax-plist-get eldoc-info "doc-fragments"))
112-
(block-tags-fragments (lax-plist-get eldoc-info "doc-block-tags-fragments"))
110+
(let* ((first-sentence-fragments (cider-plist-get eldoc-info "doc-first-sentence-fragments"))
111+
(body-fragments (cider-plist-get eldoc-info "doc-fragments"))
112+
(block-tags-fragments (cider-plist-get eldoc-info "doc-block-tags-fragments"))
113113
(block-tags-fragments-rendered (cider--fragments-to-s block-tags-fragments))
114114
(first-sentence-fragments-rendered) ;; mutable, for performance
115115
(first-attempt (when body-fragments

cider-eldoc.el

+16-16
Original file line numberDiff line numberDiff line change
@@ -214,15 +214,15 @@ Otherwise, only the docstring is returned."
214214
215215
THING is the variable name. ELDOC-INFO is a p-list containing the eldoc
216216
information."
217-
(let* ((ns (lax-plist-get eldoc-info "ns"))
218-
(symbol (lax-plist-get eldoc-info "symbol"))
217+
(let* ((ns (cider-plist-get eldoc-info "ns"))
218+
(symbol (cider-plist-get eldoc-info "symbol"))
219219
(docstring (or (cider--render-docstring-first-sentence eldoc-info)
220220
(cider--render-docstring eldoc-info)
221-
(when-let (docstring (lax-plist-get eldoc-info "docstring"))
221+
(when-let (docstring (cider-plist-get eldoc-info "docstring"))
222222
(cider-docstring--trim
223223
(cider-docstring--format docstring)))))
224224
;; if it's a single class (and not multiple class candidates), that's it
225-
(maybe-class (car (lax-plist-get eldoc-info "class")))
225+
(maybe-class (car (cider-plist-get eldoc-info "class")))
226226
(formatted-var (or (when maybe-class
227227
(cider-propertize maybe-class 'var))
228228
(cider-eldoc-format-thing ns symbol thing 'var))))
@@ -233,9 +233,9 @@ information."
233233
"Return the formatted eldoc string for a function.
234234
THING is the function name. POS is the argument-index of the functions
235235
arglists. ELDOC-INFO is a p-list containing the eldoc information."
236-
(let ((ns (lax-plist-get eldoc-info "ns"))
237-
(symbol (lax-plist-get eldoc-info "symbol"))
238-
(arglists (lax-plist-get eldoc-info "arglists")))
236+
(let ((ns (cider-plist-get eldoc-info "ns"))
237+
(symbol (cider-plist-get eldoc-info "symbol"))
238+
(arglists (cider-plist-get eldoc-info "arglists")))
239239
(format "%s: %s"
240240
(cider-eldoc-format-thing ns symbol thing 'fn)
241241
(cider-eldoc-format-arglist arglists pos))))
@@ -245,13 +245,13 @@ arglists. ELDOC-INFO is a p-list containing the eldoc information."
245245
THING is the special form's name. POS is the argument index of the
246246
special-form's arglists. ELDOC-INFO is a p-list containing the eldoc
247247
information."
248-
(let* ((ns (lax-plist-get eldoc-info "ns"))
249-
(special-form-symbol (lax-plist-get eldoc-info "symbol"))
248+
(let* ((ns (cider-plist-get eldoc-info "ns"))
249+
(special-form-symbol (cider-plist-get eldoc-info "symbol"))
250250
(arglists (mapcar (lambda (arglist)
251251
(if (equal (car arglist) special-form-symbol)
252252
(cdr arglist)
253253
arglist))
254-
(lax-plist-get eldoc-info "arglists"))))
254+
(cider-plist-get eldoc-info "arglists"))))
255255
(format "%s: %s"
256256
(cider-eldoc-format-thing ns special-form-symbol thing 'fn)
257257
(cider-eldoc-format-arglist arglists pos))))
@@ -333,7 +333,7 @@ if the maximum number of sexps to skip is exceeded."
333333
(defun cider-eldoc-thing-type (eldoc-info)
334334
"Return the type of the ELDOC-INFO being displayed by eldoc.
335335
It can be a function or var now."
336-
(or (pcase (lax-plist-get eldoc-info "type")
336+
(or (pcase (cider-plist-get eldoc-info "type")
337337
("function" 'fn)
338338
("special-form" 'special-form)
339339
("macro" 'macro)
@@ -453,8 +453,8 @@ This includes the arglist and ns and symbol name (if available)."
453453
;; add inputs of datomic query
454454
((and (equal ns-or-class "datomic.api")
455455
(equal name-or-member "q"))
456-
(let ((arglists (lax-plist-get eldoc-plist "arglists")))
457-
(lax-plist-put eldoc-plist "arglists"
456+
(let ((arglists (cider-plist-get eldoc-plist "arglists")))
457+
(cider-plist-put eldoc-plist "arglists"
458458
(cider--eldoc-add-datomic-query-inputs-to-arglists arglists))))
459459
;; if none of the clauses is successful, do cache the eldoc
460460
(t (setq cider-eldoc-last-symbol (list thing eldoc-plist))))
@@ -499,9 +499,9 @@ Only useful for interop forms. Clojure forms would be returned unchanged."
499499
;; don't try to provide eldoc in EDN buffers
500500
(not (cider--eldoc-edn-file-p buffer-file-name)))
501501
(let* ((sexp-eldoc-info (cider-eldoc-info-in-current-sexp))
502-
(eldoc-info (lax-plist-get sexp-eldoc-info "eldoc-info"))
503-
(pos (lax-plist-get sexp-eldoc-info "pos"))
504-
(thing (lax-plist-get sexp-eldoc-info "thing")))
502+
(eldoc-info (cider-plist-get sexp-eldoc-info "eldoc-info"))
503+
(pos (cider-plist-get sexp-eldoc-info "pos"))
504+
(thing (cider-plist-get sexp-eldoc-info "thing")))
505505
(when eldoc-info
506506
(cond
507507
((eq (cider-eldoc-thing-type eldoc-info) 'var)

cider-repl.el

+3-3
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ This cache is stored in the connection buffer.")
260260
(let* ((current-repl (cider-current-repl nil 'ensure))
261261
(require-code (cdr (assoc (cider-repl-type current-repl) cider-repl-require-repl-utils-code))))
262262
(nrepl-send-sync-request
263-
(lax-plist-put
263+
(cider-plist-put
264264
(nrepl--eval-request require-code (cider-current-ns))
265265
"inhibit-cider-middleware" "true")
266266
current-repl)))
@@ -660,7 +660,7 @@ the input stream may block the whole colorization process."
660660
"Return non-nil if NS-FORM for CONNECTION changed since last eval."
661661
(when-let* ((ns (cider-ns-from-form ns-form)))
662662
(not (string= ns-form
663-
(lax-plist-get
663+
(cider-plist-get
664664
(buffer-local-value 'cider-repl--ns-forms-plist connection)
665665
ns)))))
666666

@@ -679,7 +679,7 @@ the input stream may block the whole colorization process."
679679
(when-let* ((ns (cider-ns-from-form ns-form)))
680680
;; cache ns-form
681681
(setq cider-repl--ns-forms-plist
682-
(lax-plist-put cider-repl--ns-forms-plist ns ns-form))
682+
(cider-plist-put cider-repl--ns-forms-plist ns ns-form))
683683
;; cache ns roots regexp
684684
(when (string-match "\\([^.]+\\)" ns)
685685
(let ((root (match-string-no-properties 1 ns)))

cider-util.el

+16
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,22 @@ Can only error if SKIP is non-nil."
251251
(forward-sexp 2)
252252
(cider-sexp-at-point))
253253
(error nil)))
254+
255+
256+
;;; Plists
257+
258+
(defun cider-plist-get (plist prop)
259+
"Extract PROP from PLIST using `equal'.
260+
261+
An alternative `lax-plist-get' that got deprecated in Emacs 29."
262+
(lax-plist-get plist prop))
263+
264+
(defun cider-plist-put (plist prop val)
265+
"Change value in PLIST of PROP to VAL, comparing with `equal'.
266+
267+
An alternative to `lax-plist-put' that got deprecated in Emacs 29."
268+
(lax-plist-put plist prop val))
269+
254270

255271
;;; Text properties
256272

nrepl-client.el

+3-3
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,7 @@ the standard session."
930930
(when-let* ((session (if tooling nrepl-tooling-session nrepl-session)))
931931
(setq request (append request `("session" ,session))))
932932
(let* ((id (nrepl-next-request-id connection))
933-
(request (cons 'dict (lax-plist-put request "id" id)))
933+
(request (cons 'dict (cider-plist-put request "id" id)))
934934
(message (nrepl-bencode request)))
935935
(nrepl-log-message request 'request)
936936
(puthash id callback nrepl-pending-requests)
@@ -1324,7 +1324,7 @@ described by `nrepl-message-buffer-name-template'."
13241324
;; append a time-stamp to the message before logging it
13251325
;; the time-stamps are quite useful for debugging
13261326
(setq msg (cons (car msg)
1327-
(lax-plist-put (cdr msg) "time-stamp"
1327+
(cider-plist-put (cdr msg) "time-stamp"
13281328
(format-time-string "%Y-%m-%0d %H:%M:%S.%N"))))
13291329
(with-current-buffer (nrepl-messages-buffer (current-buffer))
13301330
(setq buffer-read-only nil)
@@ -1334,7 +1334,7 @@ described by `nrepl-message-buffer-name-template'."
13341334
(delete-region (point-min) (- (point) 1)))
13351335
(goto-char (point-max))
13361336
(nrepl-log-pp-object (nrepl-decorate-msg msg type)
1337-
(nrepl-log--message-color (lax-plist-get (cdr msg) "id"))
1337+
(nrepl-log--message-color (cider-plist-get (cdr msg) "id"))
13381338
t)
13391339
(when-let* ((win (get-buffer-window)))
13401340
(set-window-point win (point-max)))

nrepl-dict.el

+3-2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
;;; Code:
3535
(require 'cl-lib)
36+
(require 'cider-util)
3637

3738

3839
(defun nrepl-dict (&rest key-vals)
@@ -75,7 +76,7 @@ removed in a future release."
7576
(if (nrepl-dict-p dict)
7677
;; Note: The structure of the following expression avoids the
7778
;; expensive containment check in nearly all cases, see #3717
78-
(or (lax-plist-get (cdr dict) key)
79+
(or (cider-plist-get (cdr dict) key)
7980
;; TODO: remove DEFAULT argument and the following clause
8081
(when default
8182
(and (not (nrepl-dict-contains dict key))
@@ -89,7 +90,7 @@ Return new dict. Dict is modified by side effects."
8990
`(dict ,key ,value)
9091
(if (not (nrepl-dict-p dict))
9192
(error "Not an nREPL dict object: %s" dict)
92-
(setcdr dict (lax-plist-put (cdr dict) key value))
93+
(setcdr dict (cider-plist-put (cdr dict) key value))
9394
dict)))
9495

9596
(defun nrepl-dict-keys (dict)

0 commit comments

Comments
 (0)