aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias EngdegÄrd2020-02-01 18:07:32 +0100
committerMattias EngdegÄrd2020-02-01 22:27:23 +0100
commit32763dac46e61cc34e8fe4d19df4905d09c1a27f (patch)
treee7f831860af5d3a412dc3dcfbdb958fa23cbd5b3
parentd07f177382b24945e1f579744702908b33605c3e (diff)
downloademacs-32763dac46e61cc34e8fe4d19df4905d09c1a27f.tar.gz
emacs-32763dac46e61cc34e8fe4d19df4905d09c1a27f.zip
Replace add-to-list to lexical variable with push (bug#39373)
Since 'add-to-list', being a plain function, cannot access lexical variables, such use must be rewritten for correctness. (Some instances actually do work thanks to a compiler macro, but it's not something code should rely on.) * lisp/autoinsert.el (auto-insert-alist): * lisp/cedet/mode-local.el (mode-local-print-bindings): * lisp/net/tramp-cache.el (tramp-flush-connection-properties) (tramp-list-connections): * lisp/net/zeroconf.el (zeroconf-list-service-names) (zeroconf-list-service-types, zeroconf-list-services): * lisp/org/org.el (org-reload): * lisp/whitespace.el (whitespace-report-region): * test/lisp/emacs-lisp/map-tests.el (test-map-do): Replace add-to-list with push.
-rw-r--r--lisp/autoinsert.el2
-rw-r--r--lisp/cedet/mode-local.el14
-rw-r--r--lisp/net/tramp-cache.el4
-rw-r--r--lisp/net/zeroconf.el12
-rw-r--r--lisp/org/org.el5
-rw-r--r--lisp/whitespace.el2
-rw-r--r--test/lisp/emacs-lisp/map-tests.el2
7 files changed, 20 insertions, 21 deletions
diff --git a/lisp/autoinsert.el b/lisp/autoinsert.el
index 9bc3aad2785..25961d41089 100644
--- a/lisp/autoinsert.el
+++ b/lisp/autoinsert.el
@@ -171,7 +171,7 @@ If this contains a %s, that will be replaced by the matching rule."
171 (mapatoms (lambda (mode) 171 (mapatoms (lambda (mode)
172 (let ((name (symbol-name mode))) 172 (let ((name (symbol-name mode)))
173 (when (string-match "-mode$" name) 173 (when (string-match "-mode$" name)
174 (add-to-list 'modes name))))) 174 (push name modes)))))
175 (sort modes 'string<))) 175 (sort modes 'string<)))
176 (completing-read "Local variables for mode: " v1 nil t) 176 (completing-read "Local variables for mode: " v1 nil t)
177 " . ((" 177 " . (("
diff --git a/lisp/cedet/mode-local.el b/lisp/cedet/mode-local.el
index a6e143cfcd6..a1aea30c20d 100644
--- a/lisp/cedet/mode-local.el
+++ b/lisp/cedet/mode-local.el
@@ -819,14 +819,12 @@ META-NAME is a cons (OVERLOADABLE-SYMBOL . MAJOR-MODE)."
819 ) 819 )
820 ;; Order symbols by type 820 ;; Order symbols by type
821 (mapatoms 821 (mapatoms
822 #'(lambda (s) 822 (lambda (s) (push s (cond
823 (add-to-list (cond 823 ((get s 'mode-variable-flag)
824 ((get s 'mode-variable-flag) 824 (if (get s 'constant-flag) mc mv))
825 (if (get s 'constant-flag) 'mc 'mv)) 825 ((get s 'override-flag)
826 ((get s 'override-flag) 826 (if (get s 'constant-flag) fo ov))
827 (if (get s 'constant-flag) 'fo 'ov)) 827 (t us))))
828 ('us))
829 s))
830 table) 828 table)
831 ;; Print symbols by type 829 ;; Print symbols by type
832 (when us 830 (when us
diff --git a/lisp/net/tramp-cache.el b/lisp/net/tramp-cache.el
index b81a1a23d5f..62e25fa1f08 100644
--- a/lisp/net/tramp-cache.el
+++ b/lisp/net/tramp-cache.el
@@ -373,7 +373,7 @@ used to cache connection properties of the local machine."
373 (let ((hash (gethash key tramp-cache-data)) 373 (let ((hash (gethash key tramp-cache-data))
374 properties) 374 properties)
375 (when (hash-table-p hash) 375 (when (hash-table-p hash)
376 (maphash (lambda (x _y) (add-to-list 'properties x 'append)) hash)) 376 (maphash (lambda (x _y) (push x properties)) hash))
377 properties)) 377 properties))
378 (setq tramp-cache-data-changed t) 378 (setq tramp-cache-data-changed t)
379 (remhash key tramp-cache-data)) 379 (remhash key tramp-cache-data))
@@ -427,7 +427,7 @@ used to cache connection properties of the local machine."
427 (when (and (tramp-file-name-p key) 427 (when (and (tramp-file-name-p key)
428 (null (tramp-file-name-localname key)) 428 (null (tramp-file-name-localname key))
429 (tramp-connection-property-p key "process-buffer")) 429 (tramp-connection-property-p key "process-buffer"))
430 (add-to-list 'result key))) 430 (push key result)))
431 tramp-cache-data) 431 tramp-cache-data)
432 result)) 432 result))
433 433
diff --git a/lisp/net/zeroconf.el b/lisp/net/zeroconf.el
index b8becd712f5..cb3c0f2a7ee 100644
--- a/lisp/net/zeroconf.el
+++ b/lisp/net/zeroconf.el
@@ -256,17 +256,17 @@ supported keys depend on the service type.")
256 "Return all discovered Avahi service names as list." 256 "Return all discovered Avahi service names as list."
257 (let (result) 257 (let (result)
258 (maphash 258 (maphash
259 (lambda (_key value) (add-to-list 'result (zeroconf-service-name value))) 259 (lambda (_key value) (push (zeroconf-service-name value) result))
260 zeroconf-services-hash) 260 zeroconf-services-hash)
261 result)) 261 (delete-dups result)))
262 262
263(defun zeroconf-list-service-types () 263(defun zeroconf-list-service-types ()
264 "Return all discovered Avahi service types as list." 264 "Return all discovered Avahi service types as list."
265 (let (result) 265 (let (result)
266 (maphash 266 (maphash
267 (lambda (_key value) (add-to-list 'result (zeroconf-service-type value))) 267 (lambda (_key value) (push (zeroconf-service-type value) result))
268 zeroconf-services-hash) 268 zeroconf-services-hash)
269 result)) 269 (delete-dups result)))
270 270
271(defun zeroconf-list-services (type) 271(defun zeroconf-list-services (type)
272 "Return all discovered Avahi services for a given service type TYPE. 272 "Return all discovered Avahi services for a given service type TYPE.
@@ -278,9 +278,9 @@ format of SERVICE."
278 (maphash 278 (maphash
279 (lambda (_key value) 279 (lambda (_key value)
280 (when (equal type (zeroconf-service-type value)) 280 (when (equal type (zeroconf-service-type value))
281 (add-to-list 'result value))) 281 (push value result)))
282 zeroconf-services-hash) 282 zeroconf-services-hash)
283 result)) 283 (delete-dups result)))
284 284
285(defvar zeroconf-service-added-hooks-hash (make-hash-table :test 'equal) 285(defvar zeroconf-service-added-hooks-hash (make-hash-table :test 'equal)
286 "Hash table of hooks for newly added services. 286 "Hash table of hooks for newly added services.
diff --git a/lisp/org/org.el b/lisp/org/org.el
index 5c8b02b9d1f..568f5b9b873 100644
--- a/lisp/org/org.el
+++ b/lisp/org/org.el
@@ -18682,13 +18682,14 @@ With prefix arg UNCOMPILED, load the uncompiled versions."
18682 (and (string= org-dir contrib-dir) 18682 (and (string= org-dir contrib-dir)
18683 (org-load-noerror-mustsuffix (concat contrib-dir f))) 18683 (org-load-noerror-mustsuffix (concat contrib-dir f)))
18684 (and (org-load-noerror-mustsuffix (concat (org-find-library-dir f) f)) 18684 (and (org-load-noerror-mustsuffix (concat (org-find-library-dir f) f))
18685 (add-to-list 'load-uncore f 'append) 18685 (push f load-uncore)
18686 't) 18686 't)
18687 f)) 18687 f))
18688 lfeat))) 18688 lfeat)))
18689 (when load-uncore 18689 (when load-uncore
18690 (message "The following feature%s found in load-path, please check if that's correct:\n%s" 18690 (message "The following feature%s found in load-path, please check if that's correct:\n%s"
18691 (if (> (length load-uncore) 1) "s were" " was") load-uncore)) 18691 (if (> (length load-uncore) 1) "s were" " was")
18692 (reverse load-uncore)))
18692 (if load-misses 18693 (if load-misses
18693 (message "Some error occurred while reloading Org feature%s\n%s\nPlease check *Messages*!\n%s" 18694 (message "Some error occurred while reloading Org feature%s\n%s\nPlease check *Messages*!\n%s"
18694 (if (> (length load-misses) 1) "s" "") load-misses (org-version nil 'full)) 18695 (if (> (length load-misses) 1) "s" "") load-misses (org-version nil 'full))
diff --git a/lisp/whitespace.el b/lisp/whitespace.el
index 111b1752632..db7c023324b 100644
--- a/lisp/whitespace.el
+++ b/lisp/whitespace.el
@@ -1684,7 +1684,7 @@ cleaning up these problems."
1684 (mapcar 1684 (mapcar
1685 #'(lambda (option) 1685 #'(lambda (option)
1686 (when force 1686 (when force
1687 (add-to-list 'style (car option))) 1687 (push (car option) style))
1688 (goto-char rstart) 1688 (goto-char rstart)
1689 (let ((regexp 1689 (let ((regexp
1690 (cond 1690 (cond
diff --git a/test/lisp/emacs-lisp/map-tests.el b/test/lisp/emacs-lisp/map-tests.el
index 06fd55faad3..c52bb83fa33 100644
--- a/test/lisp/emacs-lisp/map-tests.el
+++ b/test/lisp/emacs-lisp/map-tests.el
@@ -227,7 +227,7 @@ Evaluate BODY for each created map.
227 (with-maps-do map 227 (with-maps-do map
228 (let ((result nil)) 228 (let ((result nil))
229 (map-do (lambda (k v) 229 (map-do (lambda (k v)
230 (add-to-list 'result (list (int-to-string k) v))) 230 (push (list (int-to-string k) v) result))
231 map) 231 map)
232 (should (equal result '(("2" 5) ("1" 4) ("0" 3))))))) 232 (should (equal result '(("2" 5) ("1" 4) ("0" 3)))))))
233 233