Eliminate some gratuitous string mutation

* lisp/play/zone.el (zone-replace-char):
* lisp/international/quail.el (quail-get-translations):
* lisp/hippie-exp.el (he-capitalize-first): Clarify the code by removing
mutation that is probably not resizing but just in case.
This commit is contained in:
Mattias Engdegård 2025-08-08 21:23:23 +02:00
parent 475a5d56d0
commit 14c2e5f1be
3 changed files with 17 additions and 11 deletions

View file

@ -334,11 +334,12 @@ undoes the expansion."
(defun he-capitalize-first (str)
(save-match-data
(if (string-match "\\Sw*\\(\\sw\\).*" str)
(let ((res (downcase str))
(no (match-beginning 1)))
(aset res no (upcase (aref str no)))
res)
(if (string-match "\\Sw*\\(\\sw\\)" str)
(let ((b (match-beginning 1))
(e (match-end 1)))
(concat (substring str 0 b)
(upcase (substring str b e))
(downcase (substring str e))))
str)))
(defun he-ordinary-case-p (str)

View file

@ -2135,10 +2135,14 @@ minibuffer and the selected frame has no other windows)."
(let ((guidance (quail-guidance)))
(if (listp guidance)
;; We must replace the typed key with the specified PROMPT-KEY.
(dotimes (i (length str))
(let ((prompt-key (cdr (assoc (aref str i) guidance))))
(if prompt-key
(aset str i (aref prompt-key 0)))))))
(setq str (apply #'string
(mapcar
(lambda (c)
(let ((prompt-key (assq c guidance)))
(if prompt-key
(aref (cdr prompt-key) 0)
c)))
str)))))
;; Show followable keys.
(if (and (> (length quail-current-key) 0) (cdr map))

View file

@ -433,8 +433,9 @@ run a specific program. The program must be a member of
(defsubst zone-replace-char (count del-count char-as-string new-value)
(delete-char (or del-count (- count)))
(aset char-as-string 0 new-value)
(dotimes (_ count) (insert char-as-string)))
(let ((s (apply #'propertize (string new-value)
(text-properties-at 0 char-as-string))))
(dotimes (_ count) (insert s))))
(defsubst zone-park/sit-for (pos seconds)
(let ((p (point)))