From: Eli Zaretskii Date: Mon, 31 Mar 2025 13:55:49 +0000 (+0300) Subject: Fix replace-region in japan-util.el X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=005e123a24c9baa8581a698bdc77b1ef071f9b57;p=emacs.git Fix replace-region in japan-util.el * lisp/language/japan-util.el (japanese-replace-region): Allow STRING to be a character in addition to a string. Un-obsolete it. (japanese-katakana-region, japanese-hiragana-region) (japanese-hankaku-region, japanese-zenkaku-region): Call 'japanese-replace-region' instead of 'replace-region-contents'. (Bug#77397) (cherry picked from commit fa5cd6b4d917ea6468a4950bff5b8b122468c7ec) --- diff --git a/lisp/language/japan-util.el b/lisp/language/japan-util.el index 6fbb52b627e..0a25c373b7b 100644 --- a/lisp/language/japan-util.el +++ b/lisp/language/japan-util.el @@ -217,9 +217,12 @@ The argument object is not altered--the value is a copy." (defun japanese-replace-region (from to string) "Replace the region specified by FROM and TO to STRING." - (declare (obsolete replace-region-contents "31.1")) (goto-char to) - (replace-region-contents from to string 0)) + (replace-region-contents from to + (if (stringp string) + string + (string string)) + 0)) ;;;###autoload (defun japanese-katakana-region (from to &optional hankaku) @@ -238,15 +241,13 @@ of which charset is `japanese-jisx0201-kana'." (get-char-code-property kana 'kana-composition))) slot) ;; next (if (and composition (setq slot (assq (following-char) composition))) - (progn - (goto-char (1+ (point))) - (replace-region-contents (match-beginning 0) (point) - (cdr slot) 0)) + (japanese-replace-region (match-beginning 0) (1+ (point)) + (cdr slot)) (let ((kata (get-char-code-property kana (if hankaku 'jisx0201 'katakana)))) (if kata - (replace-region-contents (match-beginning 0) (point) - kata 0))))))))) + (japanese-replace-region (match-beginning 0) (point) + kata))))))))) ;;;###autoload @@ -262,16 +263,13 @@ of which charset is `japanese-jisx0201-kana'." (composition (get-char-code-property kata 'kana-composition)) slot) ;; next (if (and composition (setq slot (assq (following-char) composition))) - (progn - (goto-char (1+ (point))) - (replace-region-contents (match-beginning 0) (point) - (get-char-code-property - (cdr slot) 'hiragana) - 0)) + (japanese-replace-region (match-beginning 0) (1+ (point)) + (get-char-code-property + (cdr slot) 'hiragana)) (let ((hira (get-char-code-property kata 'hiragana))) (if hira - (replace-region-contents (match-beginning 0) (point) - hira 0))))))))) + (japanese-replace-region (match-beginning 0) (point) + hira))))))))) ;;;###autoload (defun japanese-hankaku-region (from to &optional ascii-only) @@ -290,8 +288,8 @@ Optional argument ASCII-ONLY non-nil means to convert only to ASCII char." (get-char-code-property zenkaku 'jisx0201)) (get-char-code-property zenkaku 'ascii)))) (if hankaku - (replace-region-contents (match-beginning 0) (match-end 0) - hankaku 0))))))) + (japanese-replace-region (match-beginning 0) (match-end 0) + hankaku))))))) ;;;###autoload (defun japanese-zenkaku-region (from to &optional katakana-only) @@ -312,14 +310,12 @@ Optional argument KATAKANA-ONLY non-nil means to convert only KATAKANA char." (composition (get-char-code-property hankaku 'kana-composition)) slot) ;; next (if (and composition (setq slot (assq (following-char) composition))) - (progn - (goto-char (1+ (point))) - (replace-region-contents (match-beginning 0) (point) - (cdr slot) 0)) + (japanese-replace-region (match-beginning 0) (1+ (point)) + (cdr slot)) (let ((zenkaku (japanese-zenkaku hankaku))) (if zenkaku - (replace-region-contents (match-beginning 0) (match-end 0) - zenkaku 0))))))))) + (japanese-replace-region (match-beginning 0) (match-end 0) + zenkaku))))))))) ;;;###autoload (defun read-hiragana-string (prompt &optional initial-input)