From 0001542cafaf3e8162cd1c09dedbed826f1c2445 Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Tue, 7 Jan 2025 20:06:17 +0100 Subject: [PATCH] Use 'alist-set' where appropriate --- lisp/files.el | 2 +- lisp/frameset.el | 6 +++--- lisp/gnus/gnus-agent.el | 25 +++++++++++++------------ lisp/gnus/gnus-group.el | 4 ++-- lisp/gnus/gnus-search.el | 20 ++++++++++---------- lisp/gnus/nnmaildir.el | 4 +--- lisp/gnus/nnselect.el | 4 ++-- lisp/kmacro.el | 12 ++++++------ lisp/mouse.el | 6 +++--- lisp/net/rcirc.el | 4 ++-- lisp/org/org-persist.el | 4 ++-- lisp/progmodes/elisp-mode.el | 2 +- lisp/progmodes/flymake.el | 4 ++-- lisp/progmodes/gud.el | 3 +-- lisp/progmodes/refactor-elisp.el | 4 ++-- lisp/register.el | 2 +- lisp/tab-bar.el | 10 +++++----- lisp/tempo.el | 2 +- lisp/textmodes/tex-mode.el | 3 +-- lisp/tooltip.el | 6 +++--- lisp/transient.el | 22 +++++++++++----------- lisp/treesit.el | 8 ++++---- lisp/tty-tip.el | 4 ++-- lisp/winner.el | 2 +- lisp/yank-media.el | 3 +-- 25 files changed, 81 insertions(+), 85 deletions(-) diff --git a/lisp/files.el b/lisp/files.el index 0e9fe928576..b4f24bf4d57 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -4701,7 +4701,7 @@ VARIABLES list of the class. The list is processed in order. * If the element is of the form (DIRECTORY . LIST), and DIRECTORY is an initial substring of the file's directory, then LIST is applied by recursively following these rules." - (setf (alist-get class dir-locals-class-alist) variables)) + (alist-set class dir-locals-class-alist variables)) (defconst dir-locals-file ".dir-locals.el" "File that contains directory-local variables. diff --git a/lisp/frameset.el b/lisp/frameset.el index a3d53e45492..73f6137672e 100644 --- a/lisp/frameset.el +++ b/lisp/frameset.el @@ -702,7 +702,7 @@ nil while the filtering is done to restore it." ;; Set the display parameter after filtering, so that filter functions ;; have access to its original value. (when frameset--target-display - (setf (alist-get 'display filtered) (cdr frameset--target-display))) + (alist-set 'display filtered (cdr frameset--target-display))) filtered)) @@ -1035,9 +1035,9 @@ Internal use only." (let ((text-pixel-width (cdr (assq 'frameset--text-pixel-width parameters))) (text-pixel-height (cdr (assq 'frameset--text-pixel-height parameters)))) (when text-pixel-width - (setf (alist-get 'width filtered-cfg) (cons 'text-pixels text-pixel-width))) + (alist-set 'width filtered-cfg (cons 'text-pixels text-pixel-width))) (when text-pixel-height - (setf (alist-get 'height filtered-cfg) (cons 'text-pixels text-pixel-height)))) + (alist-set 'height filtered-cfg (cons 'text-pixels text-pixel-height)))) (when fullscreen ;; Currently Emacs has the limitation that it does not record the size diff --git a/lisp/gnus/gnus-agent.el b/lisp/gnus/gnus-agent.el index 73f636b5992..f61e8bcfa1c 100644 --- a/lisp/gnus/gnus-agent.el +++ b/lisp/gnus/gnus-agent.el @@ -2724,12 +2724,12 @@ The following commands are available: old-list))))))) ;; Possibly decode group names. (dolist (cat list) - (setf (alist-get 'agent-groups cat) - (mapcar (lambda (g) - (if (string-match-p "[^[:ascii:]]" g) - (decode-coding-string g 'utf-8-emacs) - g)) - (alist-get 'agent-groups cat)))) + (alist-set 'agent-groups cat + (mapcar (lambda (g) + (if (string-match-p "[^[:ascii:]]" g) + (decode-coding-string g 'utf-8-emacs) + g)) + (alist-get 'agent-groups cat)))) list) (list (gnus-agent-cat-make 'default 'short))))) @@ -2741,12 +2741,13 @@ The following commands are available: ;; pending an upgrade of Gnus' file formats. (let ((gnus-category-alist (mapcar (lambda (cat) - (setf (alist-get 'agent-groups cat) - (mapcar (lambda (g) - (if (multibyte-string-p g) - (encode-coding-string g 'utf-8-emacs) - g)) - (alist-get 'agent-groups cat))) + (alist-set + 'agent-groups cat + (mapcar (lambda (g) + (if (multibyte-string-p g) + (encode-coding-string g 'utf-8-emacs) + g)) + (alist-get 'agent-groups cat))) cat) (copy-tree gnus-category-alist)))) (gnus-make-directory (nnheader-concat gnus-agent-directory "lib")) diff --git a/lisp/gnus/gnus-group.el b/lisp/gnus/gnus-group.el index 5b1fa038555..9156b7f5a1c 100644 --- a/lisp/gnus/gnus-group.el +++ b/lisp/gnus/gnus-group.el @@ -3177,7 +3177,7 @@ non-nil SPECS arg must be an alist with `search-query-spec' and ;; If our query came via an old call to nnir, we know not to ;; parse the query. (when (assq 'nnir-query-spec specs) - (setf (alist-get 'raw query-spec) t)) + (alist-set 'raw query-spec t)) (gnus-group-make-group name (list 'nnselect "nnselect") @@ -3231,7 +3231,7 @@ non-nil SPECS arg must be an alist with `search-query-spec' and ;; If our query came via an old call to nnir, we know not to parse ;; the query. (when (assq 'nnir-query-spec specs) - (setf (alist-get 'raw query-spec) t)) + (alist-set 'raw query-spec t)) (gnus-group-read-ephemeral-group (concat "nnselect-" (message-unique-id)) (list 'nnselect "nnselect") diff --git a/lisp/gnus/gnus-search.el b/lisp/gnus/gnus-search.el index 6cce9af87ff..56732ea7826 100644 --- a/lisp/gnus/gnus-search.el +++ b/lisp/gnus/gnus-search.el @@ -2114,20 +2114,20 @@ remaining string, then adds all that to the top-level spec." "\\(thread\\|grep\\|limit\\|raw\\):\\([^ ]+\\)" query) (setq val (match-string 2 query)) - (setf (alist-get (intern (match-string 1 query)) query-spec) - ;; This is stupid. - (cond - ((equal val "t")) - ((null (zerop (string-to-number val))) - (string-to-number val)) - (t val))) + (alist-set (intern (match-string 1 query)) query-spec + ;; This is stupid. + (cond + ((equal val "t")) + ((null (zerop (string-to-number val))) + (string-to-number val)) + (t val))) (setq query (string-trim (replace-match "" t t query 0))) - (setf (alist-get 'query query-spec) query))) + (alist-set 'query query-spec query))) (when (and gnus-search-use-parsed-queries (null (alist-get 'raw query-spec))) - (setf (alist-get 'parsed-query query-spec) - (gnus-search-parse-query query))) + (alist-set 'parsed-query query-spec + (gnus-search-parse-query query))) query-spec)) ;; This should be done once at Gnus startup time, when the servers are diff --git a/lisp/gnus/nnmaildir.el b/lisp/gnus/nnmaildir.el index 3fb87f3a712..7f40b46f38d 100644 --- a/lisp/gnus/nnmaildir.el +++ b/lisp/gnus/nnmaildir.el @@ -678,9 +678,7 @@ This variable is set by `nnmaildir-request-article'.") (throw 'return t)) (setq server (make-nnmaildir--srv :address server-string)) (let ((inhibit-quit t)) - (setf (alist-get server-string nnmaildir--servers - nil nil #'equal) - server))) + (alist-set server-string nnmaildir--servers server #'equal))) (setq dir (assq 'directory defs)) (unless dir (setf (nnmaildir--srv-error server) diff --git a/lisp/gnus/nnselect.el b/lisp/gnus/nnselect.el index 19d3936777f..ca6305690af 100644 --- a/lisp/gnus/nnselect.el +++ b/lisp/gnus/nnselect.el @@ -669,8 +669,8 @@ group info." (pcase-dolist (`(,type . ,mark-list) newmarks) (let ((mark-type (gnus-article-mark-to-type type))) (unless (eq mark-type 'tuple) - (setf (alist-get type newmarks) - (gnus-compress-sequence (sort mark-list #'<)))))) + (alist-set type newmarks + (gnus-compress-sequence (sort mark-list #'<)))))) ;; and ensure an unexist key. (unless (assq 'unexist newmarks) (push (cons 'unexist nil) newmarks)) diff --git a/lisp/kmacro.el b/lisp/kmacro.el index 893db781d6e..53029fdc195 100644 --- a/lisp/kmacro.el +++ b/lisp/kmacro.el @@ -1705,9 +1705,9 @@ Marked macros can be operated on by `kmacro-menu-do-copy' and (kmacro-menu--query-revert) (kmacro-menu--do-region (lambda (id) - (setf (alist-get (kmacro-menu--id-position id) - kmacro-menu--marks) - t) + (alist-set (kmacro-menu--id-position id) + kmacro-menu--marks + t) (kmacro-menu--propertize-keys 'kmacro-menu-marked) (tabulated-list-put-tag #("*" 0 1 (face kmacro-menu-mark)))))) @@ -1724,9 +1724,9 @@ Flagged macros can be deleted via `kmacro-menu-do-flagged-delete'." (kmacro-menu--query-revert) (kmacro-menu--do-region (lambda (id) - (setf (alist-get (kmacro-menu--id-position id) - kmacro-menu--deletion-flags) - t) + (alist-set (kmacro-menu--id-position id) + kmacro-menu--deletion-flags + t) (kmacro-menu--propertize-keys 'kmacro-menu-flagged) (tabulated-list-put-tag #("D" 0 1 (face kmacro-menu-mark)))))) diff --git a/lisp/mouse.el b/lisp/mouse.el index 2e9862852d2..2574b9da0f7 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -3156,10 +3156,10 @@ Call `tooltip-show-help-non-mode' instead on non-graphical displays." (fg (face-attribute 'tooltip :foreground)) (bg (face-attribute 'tooltip :background))) (when (stringp fg) - (setf (alist-get 'foreground-color params) fg) - (setf (alist-get 'border-color params) fg)) + (alist-set 'foreground-color params fg) + (alist-set 'border-color params fg)) (when (stringp bg) - (setf (alist-get 'background-color params) bg)) + (alist-set 'background-color params bg)) ;; Don't time out: this leads to very confusing behavior when ;; Emacs isn't visible, and the only indication that the user ;; is actually dragging something abruptly disappears. diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el index a1d8c655c3e..3bc4006cfda 100644 --- a/lisp/net/rcirc.el +++ b/lisp/net/rcirc.el @@ -3800,8 +3800,8 @@ object for the current connection." ((= (aref (car args) 0) ?+) ;start a new batch (when (assoc id rcirc-batch-attributes) (error "Starting batch with already used ID")) - (setf (alist-get id rcirc-batch-attributes nil nil #'string=) - (cons type (cddr args)))) + (alist-set id rcirc-batch-attributes (cons type (cddr args)) + #'string=)) ((= (aref (car args) 0) ?-) ;close a batch (unless (assoc id rcirc-batch-attributes) (error "Closing a unknown batch")) diff --git a/lisp/org/org-persist.el b/lisp/org/org-persist.el index 2d91f34e839..deab2544cbd 100644 --- a/lisp/org/org-persist.el +++ b/lisp/org/org-persist.el @@ -1226,8 +1226,8 @@ Remove expired sessions timestamps." (let* ((file (org-file-name-concat org-persist-directory org-persist-gc-lock-file)) (alist (when (file-exists-p file) (org-persist--read-elisp-file file))) new-alist) - (setf (alist-get before-init-time alist nil nil #'equal) - (current-time)) + (alist-set before-init-time alist (current-time) + #'equal) (dolist (record alist) (when (< (- (float-time (cdr record)) (float-time (current-time))) org-persist-gc-lock-expiry) diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index d7c5d2a80a7..82c92593d2a 100644 --- a/lisp/progmodes/elisp-mode.el +++ b/lisp/progmodes/elisp-mode.el @@ -1044,7 +1044,7 @@ namespace but with lower confidence." (scope (lambda (_type beg len bin) (when (<= beg pos (+ beg len)) (setq cur bin)) - (when bin (setf (alist-get beg all) (list len bin)))) + (when bin (alist-set beg all (list len bin)))) (current-buffer))) (seq-keep (pcase-lambda (`(,sym ,len ,bin)) (when (equal bin cur) (cons sym len))) diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el index 3ab48b0a542..9ec7a7b59f0 100644 --- a/lisp/progmodes/flymake.el +++ b/lisp/progmodes/flymake.el @@ -1998,8 +1998,8 @@ correctly.") TYPE is usually keyword `:error', `:warning' or `:note'." (let ((probe (alist-get type flymake--mode-line-counter-cache 'none))) (if (eq probe 'none) - (setf (alist-get type flymake--mode-line-counter-cache) - (flymake--mode-line-counter-1 type)) + (alist-set type flymake--mode-line-counter-cache + (flymake--mode-line-counter-1 type)) probe))) ;;; Per-buffer diagnostic listing diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el index d8ec1c8872b..dd8e7608aef 100644 --- a/lisp/progmodes/gud.el +++ b/lisp/progmodes/gud.el @@ -303,8 +303,7 @@ Check it when `gud-running' is t") :button (:toggle . gud-tooltip-mode)] ["Info (debugger)" gud-goto-info])) -(setf (alist-get 'gud-minor-mode minor-mode-map-alist) - gud-minor-mode-map) +(alist-set 'gud-minor-mode minor-mode-map-alist gud-minor-mode-map) (defvar gud-tool-bar-map (let ((map (make-sparse-keymap))) diff --git a/lisp/progmodes/refactor-elisp.el b/lisp/progmodes/refactor-elisp.el index a747ecc761f..10ecab64925 100644 --- a/lisp/progmodes/refactor-elisp.el +++ b/lisp/progmodes/refactor-elisp.el @@ -62,7 +62,7 @@ (let (res) (pcase-dolist (`(,beg ,len ,bin) all) (when (equal bin dec) - (setf (alist-get beg res) (list (+ beg len) new)))) + (alist-set beg res (list (+ beg len) new)))) res))))) (cl-defmethod refactor-backend-rename-highlight-regions @@ -81,7 +81,7 @@ (let (res) (pcase-dolist (`(,beg ,len ,bin) all) (when (equal bin dec) - (setf (alist-get beg res) (+ beg len)))) + (alist-set beg res (+ beg len)))) res)))) (provide 'refactor-elisp) diff --git a/lisp/register.el b/lisp/register.el index f11ab31c661..fe8dbe11000 100644 --- a/lisp/register.el +++ b/lisp/register.el @@ -127,7 +127,7 @@ argument of that function." (defun set-register (register value) "Set contents of Emacs register named REGISTER to VALUE. Return VALUE. See the documentation of the variable `register-alist' for possible VALUEs." - (setf (alist-get register register-alist) value)) + (alist-set register register-alist value)) (defun register-describe-oneline (c) "Return a one-line description of register C." diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index b1c6e793a10..400c7a4a744 100644 --- a/lisp/tab-bar.el +++ b/lisp/tab-bar.el @@ -133,11 +133,11 @@ For easier selection of tabs by their numbers, consider customizing (when (and (memq 'tab-bar-format-global tab-bar-format) (member '(global-mode-string ("" global-mode-string)) mode-line-misc-info)) - (setf (alist-get 'global-mode-string mode-line-misc-info) - '(("" (:eval (if (and tab-bar-mode - (memq 'tab-bar-format-global - tab-bar-format)) - "" global-mode-string))))))) + (alist-set 'global-mode-string mode-line-misc-info + '(("" (:eval (if (and tab-bar-mode + (memq 'tab-bar-format-global + tab-bar-format)) + "" global-mode-string))))))) (defun tab-bar--undefine-keys () "Uninstall key bindings previously bound by `tab-bar--define-keys'." diff --git a/lisp/tempo.el b/lisp/tempo.el index 9849fe12711..1fb9b3b172c 100644 --- a/lisp/tempo.el +++ b/lisp/tempo.el @@ -586,7 +586,7 @@ function or string that is used by \\[tempo-complete-tag] to find a string to match the tag against. It has the same definition as the variable `tempo-match-finder'. In this version, supplying a COMPLETION-FUNCTION just sets `tempo-match-finder' locally." - (setf (alist-get tag-list tempo-local-tags) completion-function) + (alist-set tag-list tempo-local-tags completion-function) (if completion-function (setq tempo-match-finder completion-function)) (tempo-invalidate-collection)) diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el index 8ab387d6180..a112cfc1179 100644 --- a/lisp/textmodes/tex-mode.el +++ b/lisp/textmodes/tex-mode.el @@ -3968,8 +3968,7 @@ There might be text before point." extlist-new))) ((push finext extlist-new))))) (unless (seq-set-equal-p extlist-new extlist) - (setf (alist-get mode grep-filepattern-alist) - extlist-new)))) + (alist-set mode grep-filepattern-alist extlist-new)))) (let* (setsyntax (punct (with-syntax-table (tex-find-references-syntax-table) (seq-positions identifier (list ?w ?_) diff --git a/lisp/tooltip.el b/lisp/tooltip.el index a198a3d8d08..072a8c41ae2 100644 --- a/lisp/tooltip.el +++ b/lisp/tooltip.el @@ -258,10 +258,10 @@ toolkit." (fg (face-attribute (or default-face 'tooltip) :foreground)) (bg (face-attribute (or default-face 'tooltip) :background))) (when (stringp fg) - (setf (alist-get 'foreground-color params) fg) - (setf (alist-get 'border-color params) fg)) + (alist-set 'foreground-color params fg) + (alist-set 'border-color params fg)) (when (stringp bg) - (setf (alist-get 'background-color params) bg)) + (alist-set 'background-color params bg)) ;; Use non-nil APPEND argument below to avoid overriding any ;; faces used in our TEXT. Among other things, this allows ;; tooltips to use the `help-key-binding' face used in diff --git a/lisp/transient.el b/lisp/transient.el index bf64dd94e19..66120128729 100644 --- a/lisp/transient.el +++ b/lisp/transient.el @@ -3120,8 +3120,8 @@ For example: (eq (oref obj command) command)) transient--suffixes)) (setq akey (cons command (this-command-keys)))))) - (setf (alist-get akey alist) level) - (setf (alist-get prefix transient-levels) alist)) + (alist-set akey alist level) + (alist-set prefix transient-levels alist)) (transient-save-levels) (transient--show)) (t @@ -3435,8 +3435,8 @@ it\", in which case it is pointless to preserve history.)" (stringp (car transient--history))) (set-text-properties 0 (length (car transient--history)) nil (car transient--history))) - (setf (alist-get history-key transient-history) - (delete-dups transient--history))) + (alist-set history-key transient-history + (delete-dups transient--history))) value)))) (cl-defmethod transient-infix-read ((obj transient-switch)) @@ -3607,7 +3607,7 @@ See also `transient-prefix-set'.") (cl-defmethod transient-save-value ((obj transient-prefix)) (let ((value (transient-get-value))) (oset (oref obj prototype) value value) - (setf (alist-get (oref obj command) transient-values) value) + (alist-set (oref obj command) transient-values value) (transient-save-values)) (transient--history-push obj)) @@ -3842,9 +3842,9 @@ Otherwise return the value of the `command' slot." (cl-defmethod transient--history-push ((obj transient-prefix)) (let ((key (transient--history-key obj))) - (setf (alist-get key transient-history) - (let ((args (transient-get-value))) - (cons args (delete args (alist-get key transient-history))))))) + (alist-set key transient-history + (let ((args (transient-get-value))) + (cons args (delete args (alist-get key transient-history))))))) (cl-defgeneric transient--history-init (obj) "Initialize OBJ's `history' slot. @@ -3957,9 +3957,9 @@ have a history of their own.") (pcase-let ((`(,height ,width) (buffer-line-statistics transient--buffer)) (params (assq 'pop-up-frame-parameters (cdr action)))) - (setf (alist-get 'height params) height) - (setf (alist-get 'width params) - (max width (or transient-minimal-frame-width 0))))) + (alist-set 'height params height) + (alist-set 'width params + (max width (or transient-minimal-frame-width 0))))) action)) (defun transient--fit-window-to-buffer (window) diff --git a/lisp/treesit.el b/lisp/treesit.el index 99368a4db83..3e6a109b605 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -3284,8 +3284,9 @@ meaning the order of elements are kept." (alist-get category return-entries nil nil #'equal))) (if (not existing-entries) (push entry return-entries) - (setf (alist-get category return-entries nil nil #'equal) - (append existing-entries sub-entries))))) + (alist-set category return-entries + (append existing-entries sub-entries) + #'equal)))) (nreverse return-entries))) (defun treesit--generate-simple-imenu (node settings) @@ -4241,8 +4242,7 @@ nil, the grammar is installed to the standard location, the (cdr err)) " "))) ;; If success, Save the recipe for the current session. - (setf (alist-get lang treesit-language-source-alist) - (cdr recipe))))) + (alist-set lang treesit-language-source-alist (cdr recipe))))) (error (display-warning 'treesit diff --git a/lisp/tty-tip.el b/lisp/tty-tip.el index e02efdfd359..988b255016d 100644 --- a/lisp/tty-tip.el +++ b/lisp/tty-tip.el @@ -94,9 +94,9 @@ (fg (face-attribute 'tooltip :foreground)) (bg (face-attribute 'tooltip :background))) (when (stringp fg) - (setf (alist-get 'foreground-color params) fg)) + (alist-set 'foreground-color params fg)) (when (stringp bg) - (setf (alist-get 'background-color params) bg)) + (alist-set 'background-color params bg)) params)) (defvar tty-tip--help-message nil) diff --git a/lisp/winner.el b/lisp/winner.el index 7fdf3b65fba..4e279504c09 100644 --- a/lisp/winner.el +++ b/lisp/winner.el @@ -97,7 +97,7 @@ You may want to include buffer names such as *Help*, *Buffer List*, ;; Save current configuration. ;; (Called below by `winner-save-old-configurations'). (defun winner-remember () - (setf (alist-get (selected-frame) winner-currents) (winner-conf))) + (alist-set (selected-frame) winner-currents (winner-conf))) ;; Consult `winner-currents'. (defun winner-configuration (&optional frame) diff --git a/lisp/yank-media.el b/lisp/yank-media.el index 62f5b34355a..8929181df83 100644 --- a/lisp/yank-media.el +++ b/lisp/yank-media.el @@ -102,8 +102,7 @@ MIME type (a symbol of the form `image/png') and the selection data (a string)." (make-local-variable 'yank-media--registered-handlers) (dolist (type (ensure-list types)) - (setf (alist-get type yank-media--registered-handlers nil nil #'equal) - handler))) + (alist-set type yank-media--registered-handlers handler #'equal))) (defun yank-media-types (&optional all) "Yank any element present in the primary selection or the clipboard. -- 2.39.5