diff options
| author | Stefan Monnier | 2025-03-28 01:01:17 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2025-03-29 17:49:49 -0400 |
| commit | 1d07a6d7e34677be1653b1d4d464ff00cabfa102 (patch) | |
| tree | 9f27c30bd71b3ab9f7f5ed14e31f66e6b0fa85a6 /lisp/language | |
| parent | 468c2aebae0ee13273f4b06e92f4188c4c46d2b3 (diff) | |
| download | emacs-1d07a6d7e34677be1653b1d4d464ff00cabfa102.tar.gz emacs-1d07a6d7e34677be1653b1d4d464ff00cabfa102.zip | |
Use `replace-region-contents` to replace insert+delete
* lisp/minibuffer.el (completion--replace):
* lisp/emacs-lisp/cl-lib.el (cl--set-buffer-substring):
* lisp/subr.el (replace-string-in-region):
Use `replace-region-contents` instead of insert+delete.
* lisp/help-fns.el (help-fns--signature):
Use `replace-region-contents` instead of `cl--set-buffer-substring`.
* lisp/language/japan-util.el (japanese-replace-region):
Rewrite using `replace-region-contents` and mark obsolete.
(japanese-katakana-region, japanese-hankaku-region):
Use `replace-region-contents` instead.
* lisp/progmodes/flymake-proc.el (flymake-proc--replace-region):
Rewrite using `replace-region-contents` and mark obsolete.
(flymake-proc--check-patch-master-file-buffer):
Use `replace-region-contents` instead.
Diffstat (limited to 'lisp/language')
| -rw-r--r-- | lisp/language/japan-util.el | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/lisp/language/japan-util.el b/lisp/language/japan-util.el index 718c469d562..6fbb52b627e 100644 --- a/lisp/language/japan-util.el +++ b/lisp/language/japan-util.el | |||
| @@ -217,9 +217,9 @@ The argument object is not altered--the value is a copy." | |||
| 217 | 217 | ||
| 218 | (defun japanese-replace-region (from to string) | 218 | (defun japanese-replace-region (from to string) |
| 219 | "Replace the region specified by FROM and TO to STRING." | 219 | "Replace the region specified by FROM and TO to STRING." |
| 220 | (goto-char from) | 220 | (declare (obsolete replace-region-contents "31.1")) |
| 221 | (insert string) | 221 | (goto-char to) |
| 222 | (delete-char (- to from))) | 222 | (replace-region-contents from to string 0)) |
| 223 | 223 | ||
| 224 | ;;;###autoload | 224 | ;;;###autoload |
| 225 | (defun japanese-katakana-region (from to &optional hankaku) | 225 | (defun japanese-katakana-region (from to &optional hankaku) |
| @@ -238,13 +238,15 @@ of which charset is `japanese-jisx0201-kana'." | |||
| 238 | (get-char-code-property kana 'kana-composition))) | 238 | (get-char-code-property kana 'kana-composition))) |
| 239 | slot) ;; next | 239 | slot) ;; next |
| 240 | (if (and composition (setq slot (assq (following-char) composition))) | 240 | (if (and composition (setq slot (assq (following-char) composition))) |
| 241 | (japanese-replace-region (match-beginning 0) (1+ (point)) | 241 | (progn |
| 242 | (cdr slot)) | 242 | (goto-char (1+ (point))) |
| 243 | (replace-region-contents (match-beginning 0) (point) | ||
| 244 | (cdr slot) 0)) | ||
| 243 | (let ((kata (get-char-code-property | 245 | (let ((kata (get-char-code-property |
| 244 | kana (if hankaku 'jisx0201 'katakana)))) | 246 | kana (if hankaku 'jisx0201 'katakana)))) |
| 245 | (if kata | 247 | (if kata |
| 246 | (japanese-replace-region (match-beginning 0) (point) | 248 | (replace-region-contents (match-beginning 0) (point) |
| 247 | kata))))))))) | 249 | kata 0))))))))) |
| 248 | 250 | ||
| 249 | 251 | ||
| 250 | ;;;###autoload | 252 | ;;;###autoload |
| @@ -260,13 +262,16 @@ of which charset is `japanese-jisx0201-kana'." | |||
| 260 | (composition (get-char-code-property kata 'kana-composition)) | 262 | (composition (get-char-code-property kata 'kana-composition)) |
| 261 | slot) ;; next | 263 | slot) ;; next |
| 262 | (if (and composition (setq slot (assq (following-char) composition))) | 264 | (if (and composition (setq slot (assq (following-char) composition))) |
| 263 | (japanese-replace-region (match-beginning 0) (1+ (point)) | 265 | (progn |
| 264 | (get-char-code-property | 266 | (goto-char (1+ (point))) |
| 265 | (cdr slot) 'hiragana)) | 267 | (replace-region-contents (match-beginning 0) (point) |
| 268 | (get-char-code-property | ||
| 269 | (cdr slot) 'hiragana) | ||
| 270 | 0)) | ||
| 266 | (let ((hira (get-char-code-property kata 'hiragana))) | 271 | (let ((hira (get-char-code-property kata 'hiragana))) |
| 267 | (if hira | 272 | (if hira |
| 268 | (japanese-replace-region (match-beginning 0) (point) | 273 | (replace-region-contents (match-beginning 0) (point) |
| 269 | hira))))))))) | 274 | hira 0))))))))) |
| 270 | 275 | ||
| 271 | ;;;###autoload | 276 | ;;;###autoload |
| 272 | (defun japanese-hankaku-region (from to &optional ascii-only) | 277 | (defun japanese-hankaku-region (from to &optional ascii-only) |
| @@ -285,8 +290,8 @@ Optional argument ASCII-ONLY non-nil means to convert only to ASCII char." | |||
| 285 | (get-char-code-property zenkaku 'jisx0201)) | 290 | (get-char-code-property zenkaku 'jisx0201)) |
| 286 | (get-char-code-property zenkaku 'ascii)))) | 291 | (get-char-code-property zenkaku 'ascii)))) |
| 287 | (if hankaku | 292 | (if hankaku |
| 288 | (japanese-replace-region (match-beginning 0) (match-end 0) | 293 | (replace-region-contents (match-beginning 0) (match-end 0) |
| 289 | hankaku))))))) | 294 | hankaku 0))))))) |
| 290 | 295 | ||
| 291 | ;;;###autoload | 296 | ;;;###autoload |
| 292 | (defun japanese-zenkaku-region (from to &optional katakana-only) | 297 | (defun japanese-zenkaku-region (from to &optional katakana-only) |
| @@ -307,12 +312,14 @@ Optional argument KATAKANA-ONLY non-nil means to convert only KATAKANA char." | |||
| 307 | (composition (get-char-code-property hankaku 'kana-composition)) | 312 | (composition (get-char-code-property hankaku 'kana-composition)) |
| 308 | slot) ;; next | 313 | slot) ;; next |
| 309 | (if (and composition (setq slot (assq (following-char) composition))) | 314 | (if (and composition (setq slot (assq (following-char) composition))) |
| 310 | (japanese-replace-region (match-beginning 0) (1+ (point)) | 315 | (progn |
| 311 | (cdr slot)) | 316 | (goto-char (1+ (point))) |
| 317 | (replace-region-contents (match-beginning 0) (point) | ||
| 318 | (cdr slot) 0)) | ||
| 312 | (let ((zenkaku (japanese-zenkaku hankaku))) | 319 | (let ((zenkaku (japanese-zenkaku hankaku))) |
| 313 | (if zenkaku | 320 | (if zenkaku |
| 314 | (japanese-replace-region (match-beginning 0) (match-end 0) | 321 | (replace-region-contents (match-beginning 0) (match-end 0) |
| 315 | zenkaku))))))))) | 322 | zenkaku 0))))))))) |
| 316 | 323 | ||
| 317 | ;;;###autoload | 324 | ;;;###autoload |
| 318 | (defun read-hiragana-string (prompt &optional initial-input) | 325 | (defun read-hiragana-string (prompt &optional initial-input) |