From c7bc28bf038e08fcc03e5dc96cd762af06b34e09 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 16 May 2020 17:04:15 -0700 Subject: Don’t attempt to modify constant conses MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From a patch privately suggested by Mattias Engdegård on 2020-05-11 in a followup to Bug#40671. * admin/charsets/cp51932.awk: * admin/charsets/eucjp-ms.awk: Generate code that does not modify constant conses. * doc/misc/emacs-mime.texi (Encoding Customization): * lisp/emacs-lisp/byte-opt.el (byte-compile-side-effect-free-ops): * lisp/frameset.el (frameset-persistent-filter-alist): * lisp/gnus/gnus-sum.el (gnus-article-mode-line-format-alist): Use append instead of nconc. * lisp/language/japanese.el (japanese-ucs-cp932-to-jis-map) (jisx0213-to-unicode): Use mapcar instead of mapc. * lisp/language/lao-util.el (lao-transcription-consonant-alist) (lao-transcription-vowel-alist): * lisp/language/tibetan.el (tibetan-subjoined-transcription-alist): Use copy-sequence. * test/src/fns-tests.el (fns-tests-nreverse): (fns-tests-sort, fns-tests-collate-sort) (fns-tests-string-version-lessp, fns-tests-mapcan): Use copy-sequence, vector, and list. --- lisp/language/japanese.el | 10 +++++----- lisp/language/lao-util.el | 16 ++++++++++------ lisp/language/tibetan.el | 8 +++++--- 3 files changed, 20 insertions(+), 14 deletions(-) (limited to 'lisp/language') diff --git a/lisp/language/japanese.el b/lisp/language/japanese.el index d77efa48c9b..9a99245dfde 100644 --- a/lisp/language/japanese.el +++ b/lisp/language/japanese.el @@ -82,9 +82,7 @@ (#x00A6 . #xFFE4) ; BROKEN LINE FULLWIDTH BROKEN LINE ))) (define-translation-table 'japanese-ucs-jis-to-cp932-map map) - (mapc #'(lambda (x) (let ((tmp (car x))) - (setcar x (cdr x)) (setcdr x tmp))) - map) + (setq map (mapcar (lambda (x) (cons (cdr x) (car x))) map)) (define-translation-table 'japanese-ucs-cp932-to-jis-map map)) ;; U+2014 (EM DASH) vs U+2015 (HORIZONTAL BAR) @@ -241,8 +239,10 @@ eucJP-ms is defined in ." (#x2b65 . [#x02E9 #x02E5]) (#x2b66 . [#x02E5 #x02E9]))) table) - (dolist (elt map) - (setcar elt (decode-char 'japanese-jisx0213-1 (car elt)))) + (setq map + (mapcar (lambda (x) (cons (decode-char 'japanese-jisx0213-1 (car x)) + (cdr x))) + map)) (setq table (make-translation-table-from-alist map)) (define-translation-table 'jisx0213-to-unicode table) (define-translation-table 'unicode-to-jisx0213 diff --git a/lisp/language/lao-util.el b/lisp/language/lao-util.el index a20aecee421..fa4c2f7f891 100644 --- a/lisp/language/lao-util.el +++ b/lisp/language/lao-util.el @@ -183,7 +183,9 @@ ;; Semi-vowel-sign-lo and lower vowels are put under the letter. (defconst lao-transcription-consonant-alist - (sort '(;; single consonants + (sort + (copy-sequence + '(;; single consonants ("k" . "ກ") ("kh" . "ຂ") ("qh" . "ຄ") @@ -223,14 +225,16 @@ ("hy" . ["ຫຍ"]) ("hn" . ["ຫນ"]) ("hm" . ["ຫມ"]) - ) - (function (lambda (x y) (> (length (car x)) (length (car y))))))) + )) + (lambda (x y) (> (length (car x)) (length (car y)))))) (defconst lao-transcription-semi-vowel-alist '(("r" . "ຼ"))) (defconst lao-transcription-vowel-alist - (sort '(("a" . "ະ") + (sort + (copy-sequence + '(("a" . "ະ") ("ar" . "າ") ("i" . "ິ") ("ii" . "ີ") @@ -257,8 +261,8 @@ ("ai" . "ໄ") ("ei" . "ໃ") ("ao" . ["ເົາ"]) - ("aM" . "ຳ")) - (function (lambda (x y) (> (length (car x)) (length (car y))))))) + ("aM" . "ຳ"))) + (lambda (x y) (> (length (car x)) (length (car y)))))) ;; Maa-sakod is put at the tail. (defconst lao-transcription-maa-sakod-alist diff --git a/lisp/language/tibetan.el b/lisp/language/tibetan.el index d31cd5cd528..bbd4729f6c5 100644 --- a/lisp/language/tibetan.el +++ b/lisp/language/tibetan.el @@ -326,7 +326,9 @@ (defconst tibetan-subjoined-transcription-alist - (sort '(("+k" . "ྐ") + (sort + (copy-sequence + '(("+k" . "ྐ") ("+kh" . "ྑ") ("+g" . "ྒ") ("+gh" . "ྒྷ") @@ -371,8 +373,8 @@ ("+W" . "ྺ") ;; fixed form subscribed WA ("+Y" . "ྻ") ;; fixed form subscribed YA ("+R" . "ྼ") ;; fixed form subscribed RA - ) - (lambda (x y) (> (length (car x)) (length (car y)))))) + )) + (lambda (x y) (> (length (car x)) (length (car y)))))) ;;; ;;; alist for Tibetan base consonant <-> subjoined consonant conversion. -- cgit v1.2.3