branch: elpa/cider commit c1d1efd8c98a51ea070934e66f6b9e791f33f9fa Author: Bozhidar Batsov <bozhi...@batsov.dev> Commit: Bozhidar Batsov <bozhi...@batsov.dev>
[#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. --- cider-completion.el | 6 +++--- cider-docstring.el | 8 ++++---- cider-eldoc.el | 32 ++++++++++++++++---------------- cider-repl.el | 6 +++--- cider-util.el | 16 ++++++++++++++++ nrepl-client.el | 6 +++--- nrepl-dict.el | 5 +++-- 7 files changed, 48 insertions(+), 31 deletions(-) diff --git a/cider-completion.el b/cider-completion.el index 4a1437bbc4..23954ffd4a 100644 --- a/cider-completion.el +++ b/cider-completion.el @@ -249,9 +249,9 @@ in the buffer." (defun cider-company-docsig (thing) "Return signature for THING." (when-let ((eldoc-info (cider-eldoc-info thing))) - (let* ((ns (lax-plist-get eldoc-info "ns")) - (symbol (lax-plist-get eldoc-info "symbol")) - (arglists (lax-plist-get eldoc-info "arglists"))) + (let* ((ns (cider-plist-get eldoc-info "ns")) + (symbol (cider-plist-get eldoc-info "symbol")) + (arglists (cider-plist-get eldoc-info "arglists"))) (format "%s: %s" (cider-eldoc-format-thing ns symbol thing (cider-eldoc-thing-type eldoc-info)) diff --git a/cider-docstring.el b/cider-docstring.el index 73b29ad24a..4b4430c320 100644 --- a/cider-docstring.el +++ b/cider-docstring.el @@ -101,15 +101,15 @@ Note that `cider-docstring' will trim thing smartly, for Java doc comments: (defun cider--render-docstring-first-sentence (eldoc-info) "Render the first sentence of the docstring extracted from ELDOC-INFO." - (when-let ((first-sentence-fragments (lax-plist-get eldoc-info "doc-first-sentence-fragments"))) + (when-let ((first-sentence-fragments (cider-plist-get eldoc-info "doc-first-sentence-fragments"))) (cider--fragments-to-s first-sentence-fragments))) (defun cider--render-docstring (eldoc-info) "Renders the docstring from ELDOC-INFO based on its length and content. Prioritize rendering as much as possible while staying within `cider-docstring-max-lines'." - (let* ((first-sentence-fragments (lax-plist-get eldoc-info "doc-first-sentence-fragments")) - (body-fragments (lax-plist-get eldoc-info "doc-fragments")) - (block-tags-fragments (lax-plist-get eldoc-info "doc-block-tags-fragments")) + (let* ((first-sentence-fragments (cider-plist-get eldoc-info "doc-first-sentence-fragments")) + (body-fragments (cider-plist-get eldoc-info "doc-fragments")) + (block-tags-fragments (cider-plist-get eldoc-info "doc-block-tags-fragments")) (block-tags-fragments-rendered (cider--fragments-to-s block-tags-fragments)) (first-sentence-fragments-rendered) ;; mutable, for performance (first-attempt (when body-fragments diff --git a/cider-eldoc.el b/cider-eldoc.el index a787393ba9..3a04f1df95 100644 --- a/cider-eldoc.el +++ b/cider-eldoc.el @@ -214,15 +214,15 @@ Otherwise, only the docstring is returned." THING is the variable name. ELDOC-INFO is a p-list containing the eldoc information." - (let* ((ns (lax-plist-get eldoc-info "ns")) - (symbol (lax-plist-get eldoc-info "symbol")) + (let* ((ns (cider-plist-get eldoc-info "ns")) + (symbol (cider-plist-get eldoc-info "symbol")) (docstring (or (cider--render-docstring-first-sentence eldoc-info) (cider--render-docstring eldoc-info) - (when-let (docstring (lax-plist-get eldoc-info "docstring")) + (when-let (docstring (cider-plist-get eldoc-info "docstring")) (cider-docstring--trim (cider-docstring--format docstring))))) ;; if it's a single class (and not multiple class candidates), that's it - (maybe-class (car (lax-plist-get eldoc-info "class"))) + (maybe-class (car (cider-plist-get eldoc-info "class"))) (formatted-var (or (when maybe-class (cider-propertize maybe-class 'var)) (cider-eldoc-format-thing ns symbol thing 'var)))) @@ -233,9 +233,9 @@ information." "Return the formatted eldoc string for a function. THING is the function name. POS is the argument-index of the functions arglists. ELDOC-INFO is a p-list containing the eldoc information." - (let ((ns (lax-plist-get eldoc-info "ns")) - (symbol (lax-plist-get eldoc-info "symbol")) - (arglists (lax-plist-get eldoc-info "arglists"))) + (let ((ns (cider-plist-get eldoc-info "ns")) + (symbol (cider-plist-get eldoc-info "symbol")) + (arglists (cider-plist-get eldoc-info "arglists"))) (format "%s: %s" (cider-eldoc-format-thing ns symbol thing 'fn) (cider-eldoc-format-arglist arglists pos)))) @@ -245,13 +245,13 @@ arglists. ELDOC-INFO is a p-list containing the eldoc information." THING is the special form's name. POS is the argument index of the special-form's arglists. ELDOC-INFO is a p-list containing the eldoc information." - (let* ((ns (lax-plist-get eldoc-info "ns")) - (special-form-symbol (lax-plist-get eldoc-info "symbol")) + (let* ((ns (cider-plist-get eldoc-info "ns")) + (special-form-symbol (cider-plist-get eldoc-info "symbol")) (arglists (mapcar (lambda (arglist) (if (equal (car arglist) special-form-symbol) (cdr arglist) arglist)) - (lax-plist-get eldoc-info "arglists")))) + (cider-plist-get eldoc-info "arglists")))) (format "%s: %s" (cider-eldoc-format-thing ns special-form-symbol thing 'fn) (cider-eldoc-format-arglist arglists pos)))) @@ -333,7 +333,7 @@ if the maximum number of sexps to skip is exceeded." (defun cider-eldoc-thing-type (eldoc-info) "Return the type of the ELDOC-INFO being displayed by eldoc. It can be a function or var now." - (or (pcase (lax-plist-get eldoc-info "type") + (or (pcase (cider-plist-get eldoc-info "type") ("function" 'fn) ("special-form" 'special-form) ("macro" 'macro) @@ -453,8 +453,8 @@ This includes the arglist and ns and symbol name (if available)." ;; add inputs of datomic query ((and (equal ns-or-class "datomic.api") (equal name-or-member "q")) - (let ((arglists (lax-plist-get eldoc-plist "arglists"))) - (lax-plist-put eldoc-plist "arglists" + (let ((arglists (cider-plist-get eldoc-plist "arglists"))) + (cider-plist-put eldoc-plist "arglists" (cider--eldoc-add-datomic-query-inputs-to-arglists arglists)))) ;; if none of the clauses is successful, do cache the eldoc (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." ;; don't try to provide eldoc in EDN buffers (not (cider--eldoc-edn-file-p buffer-file-name))) (let* ((sexp-eldoc-info (cider-eldoc-info-in-current-sexp)) - (eldoc-info (lax-plist-get sexp-eldoc-info "eldoc-info")) - (pos (lax-plist-get sexp-eldoc-info "pos")) - (thing (lax-plist-get sexp-eldoc-info "thing"))) + (eldoc-info (cider-plist-get sexp-eldoc-info "eldoc-info")) + (pos (cider-plist-get sexp-eldoc-info "pos")) + (thing (cider-plist-get sexp-eldoc-info "thing"))) (when eldoc-info (cond ((eq (cider-eldoc-thing-type eldoc-info) 'var) diff --git a/cider-repl.el b/cider-repl.el index 202845a379..12681f34c0 100644 --- a/cider-repl.el +++ b/cider-repl.el @@ -260,7 +260,7 @@ This cache is stored in the connection buffer.") (let* ((current-repl (cider-current-repl nil 'ensure)) (require-code (cdr (assoc (cider-repl-type current-repl) cider-repl-require-repl-utils-code)))) (nrepl-send-sync-request - (lax-plist-put + (cider-plist-put (nrepl--eval-request require-code (cider-current-ns)) "inhibit-cider-middleware" "true") current-repl))) @@ -660,7 +660,7 @@ the input stream may block the whole colorization process." "Return non-nil if NS-FORM for CONNECTION changed since last eval." (when-let* ((ns (cider-ns-from-form ns-form))) (not (string= ns-form - (lax-plist-get + (cider-plist-get (buffer-local-value 'cider-repl--ns-forms-plist connection) ns))))) @@ -679,7 +679,7 @@ the input stream may block the whole colorization process." (when-let* ((ns (cider-ns-from-form ns-form))) ;; cache ns-form (setq cider-repl--ns-forms-plist - (lax-plist-put cider-repl--ns-forms-plist ns ns-form)) + (cider-plist-put cider-repl--ns-forms-plist ns ns-form)) ;; cache ns roots regexp (when (string-match "\\([^.]+\\)" ns) (let ((root (match-string-no-properties 1 ns))) diff --git a/cider-util.el b/cider-util.el index 0f2e360c81..779c64be70 100644 --- a/cider-util.el +++ b/cider-util.el @@ -251,6 +251,22 @@ Can only error if SKIP is non-nil." (forward-sexp 2) (cider-sexp-at-point)) (error nil))) + + +;;; Plists + +(defun cider-plist-get (plist prop) + "Extract PROP from PLIST using `equal'. + +An alternative `lax-plist-get' that got deprecated in Emacs 29." + (lax-plist-get plist prop)) + +(defun cider-plist-put (plist prop val) + "Change value in PLIST of PROP to VAL, comparing with `equal'. + +An alternative to `lax-plist-put' that got deprecated in Emacs 29." + (lax-plist-put plist prop val)) + ;;; Text properties diff --git a/nrepl-client.el b/nrepl-client.el index b5b50ba48a..17b2acd803 100644 --- a/nrepl-client.el +++ b/nrepl-client.el @@ -930,7 +930,7 @@ the standard session." (when-let* ((session (if tooling nrepl-tooling-session nrepl-session))) (setq request (append request `("session" ,session)))) (let* ((id (nrepl-next-request-id connection)) - (request (cons 'dict (lax-plist-put request "id" id))) + (request (cons 'dict (cider-plist-put request "id" id))) (message (nrepl-bencode request))) (nrepl-log-message request 'request) (puthash id callback nrepl-pending-requests) @@ -1324,7 +1324,7 @@ described by `nrepl-message-buffer-name-template'." ;; append a time-stamp to the message before logging it ;; the time-stamps are quite useful for debugging (setq msg (cons (car msg) - (lax-plist-put (cdr msg) "time-stamp" + (cider-plist-put (cdr msg) "time-stamp" (format-time-string "%Y-%m-%0d %H:%M:%S.%N")))) (with-current-buffer (nrepl-messages-buffer (current-buffer)) (setq buffer-read-only nil) @@ -1334,7 +1334,7 @@ described by `nrepl-message-buffer-name-template'." (delete-region (point-min) (- (point) 1))) (goto-char (point-max)) (nrepl-log-pp-object (nrepl-decorate-msg msg type) - (nrepl-log--message-color (lax-plist-get (cdr msg) "id")) + (nrepl-log--message-color (cider-plist-get (cdr msg) "id")) t) (when-let* ((win (get-buffer-window))) (set-window-point win (point-max))) diff --git a/nrepl-dict.el b/nrepl-dict.el index e946dacfbe..bbf1b8f30a 100644 --- a/nrepl-dict.el +++ b/nrepl-dict.el @@ -33,6 +33,7 @@ ;;; Code: (require 'cl-lib) +(require 'cider-util) (defun nrepl-dict (&rest key-vals) @@ -75,7 +76,7 @@ removed in a future release." (if (nrepl-dict-p dict) ;; Note: The structure of the following expression avoids the ;; expensive containment check in nearly all cases, see #3717 - (or (lax-plist-get (cdr dict) key) + (or (cider-plist-get (cdr dict) key) ;; TODO: remove DEFAULT argument and the following clause (when default (and (not (nrepl-dict-contains dict key)) @@ -89,7 +90,7 @@ Return new dict. Dict is modified by side effects." `(dict ,key ,value) (if (not (nrepl-dict-p dict)) (error "Not an nREPL dict object: %s" dict) - (setcdr dict (lax-plist-put (cdr dict) key value)) + (setcdr dict (cider-plist-put (cdr dict) key value)) dict))) (defun nrepl-dict-keys (dict)